// Path: src/net/sourceforge/arbaro/export/Console.java
// final public class Console {
// 	static final public int REALLY_QUIET=0;
// 	static final public int QUIET=1;
// 	static final public int VERBOSE=2;
// 	static final public int DEBUG=3;
// 
// 	static public char progrChr=' '; // show progress on Console
// 	
// 	static public int outputLevel;
// 
// 	static public void setOutputLevel(int level) {
// 		outputLevel = level;
// 		if (outputLevel>= VERBOSE)
// 			progrChr = '.';
// 		else
// 			progrChr = ' ';
// 	}
// 	
// 	static synchronized public boolean debug() {
// 		return outputLevel>=DEBUG;
// 	}
// 	
// 	static synchronized public void progressChar() {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.print(progrChr);
// 		}
// 	}
// 	
// 	static synchronized public void verboseOutput(String msg) {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.println(msg);
// 		}
// 	}
// 	
// 	static synchronized public void debugOutput(String msg) {
// 		if (outputLevel>=DEBUG) {
// 			System.err.println(msg);
// 		}
// 	}
// 
// 	static synchronized public void errorOutput(String msg) {
// 		if (outputLevel>REALLY_QUIET) {
// 			System.err.println(msg);
// 		}
// 	}
// 	
// 	static synchronized public void printException(Exception e) {
// 		if (outputLevel>REALLY_QUIET) {
// 			System.err.println(e);
// 			e.printStackTrace(System.err);
// 		}
// 	}
// 
// 	static synchronized public void progressChar(char c) {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.print(c);
// 		}
// 	}
// 
// 	static public void setProgressChar(char consoleChar) {
// 		Console.progrChr= consoleChar;
// 	}
// 
// }


import java.lang.Math;
import java.util.Enumeration;
import net.sourceforge.arbaro.tree.Stem;
import net.sourceforge.arbaro.export.Console;
	private class FaceEnumerator implements Enumeration {
		private Enumeration sections;
		private Enumeration sectionFaces;
		private MeshSection section;
		private boolean UVFaces;
		private boolean useQuads;
		private int startIndex;
//		private int sectionSize;
		
		public FaceEnumerator(Mesh mesh, int startInx, boolean uv, boolean quads) {
			UVFaces = uv;
			startIndex = startInx;
			useQuads = quads;
			sections = elements();
			
			// ignore root point
			MeshSection sec =
				(MeshSection)sections.nextElement();
			
			// if it's a clone calculate a vertex offset
			// finding the corresponding segment in the parent stem's mesh
			int uvVertexOffset=0; 
			if (uv && stem.isClone()) {
				MeshPart mp = ((MeshPart)mesh.elementAt(mesh.firstMeshPart[stem.getLevel()]));
				
				MeshSection ms = ((MeshSection)mp.elementAt(1)); // ignore root vertex
				
//				if (Console.debug()) Console.debugOutput("cloneOff: "+stem.getCloneSectionOffset());
				for (int i=0; i<stem.getCloneSectionOffset(); i++) {
					uvVertexOffset += ms.size()==1? 1 : ms.size()+1;
// Path: src/net/sourceforge/arbaro/export/Console.java
// final public class Console {
// 	static final public int REALLY_QUIET=0;
// 	static final public int QUIET=1;
// 	static final public int VERBOSE=2;
// 	static final public int DEBUG=3;
// 
// 	static public char progrChr=' '; // show progress on Console
// 	
// 	static public int outputLevel;
// 
// 	static public void setOutputLevel(int level) {
// 		outputLevel = level;
// 		if (outputLevel>= VERBOSE)
// 			progrChr = '.';
// 		else
// 			progrChr = ' ';
// 	}
// 	
// 	static synchronized public boolean debug() {
// 		return outputLevel>=DEBUG;
// 	}
// 	
// 	static synchronized public void progressChar() {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.print(progrChr);
// 		}
// 	}
// 	
// 	static synchronized public void verboseOutput(String msg) {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.println(msg);
// 		}
// 	}
// 	
// 	static synchronized public void debugOutput(String msg) {
// 		if (outputLevel>=DEBUG) {
// 			System.err.println(msg);
// 		}
// 	}
// 
// 	static synchronized public void errorOutput(String msg) {
// 		if (outputLevel>REALLY_QUIET) {
// 			System.err.println(msg);
// 		}
// 	}
// 	
// 	static synchronized public void printException(Exception e) {
// 		if (outputLevel>REALLY_QUIET) {
// 			System.err.println(e);
// 			e.printStackTrace(System.err);
// 		}
// 	}
// 
// 	static synchronized public void progressChar(char c) {
// 		if (outputLevel>=VERBOSE) {
// 			System.err.print(c);
// 		}
// 	}
// 
// 	static public void setProgressChar(char consoleChar) {
// 		Console.progrChr= consoleChar;
// 	}
// 
// }


// Path: src/net/sourceforge/arbaro/mesh/MeshPart.java
import java.lang.Math;
import java.util.Enumeration;
import net.sourceforge.arbaro.tree.Stem;
import net.sourceforge.arbaro.export.Console;

	private class FaceEnumerator implements Enumeration {
		private Enumeration sections;
		private Enumeration sectionFaces;
		private MeshSection section;
		private boolean UVFaces;
		private boolean useQuads;
		private int startIndex;
//		private int sectionSize;
		
		public FaceEnumerator(Mesh mesh, int startInx, boolean uv, boolean quads) {
			UVFaces = uv;
			startIndex = startInx;
			useQuads = quads;
			sections = elements();
			
			// ignore root point
			MeshSection sec =
				(MeshSection)sections.nextElement();
			
			// if it's a clone calculate a vertex offset
			// finding the corresponding segment in the parent stem's mesh
			int uvVertexOffset=0; 
			if (uv && stem.isClone()) {
				MeshPart mp = ((MeshPart)mesh.elementAt(mesh.firstMeshPart[stem.getLevel()]));
				
				MeshSection ms = ((MeshSection)mp.elementAt(1)); // ignore root vertex
				
//				if (Console.debug()) Console.debugOutput("cloneOff: "+stem.getCloneSectionOffset());
				for (int i=0; i<stem.getCloneSectionOffset(); i++) {
					uvVertexOffset += ms.size()==1? 1 : ms.size()+1;
					if (Console.debug()) Console.debugOutput("i: "+i+" vertexOff: "+uvVertexOffset);