00001 package commandline.dataToImage; 00002 00003 import java.io.File; 00004 import java.io.FileNotFoundException; 00005 import java.io.PrintWriter; 00006 import java.util.ArrayList; 00007 00008 import commandline.CodingUtils.CommitDataStructure; 00009 import commandline.debuggingCode.Debug; 00010 00011 public class MatlabEfficientWriter { 00012 private PrintWriter p; 00013 private ArrayList<String> TRI, XYZ,XY_param; 00014 00015 EfficientPolygonRetriever efficientPolygonRetriever; 00016 public MatlabEfficientWriter(CommitDataStructure commitDataStructure, File f) throws FileNotFoundException{ 00017 p=new PrintWriter(f); 00018 00019 efficientPolygonRetriever=new EfficientPolygonRetriever(commitDataStructure); 00020 efficientPolygonRetriever.makeDataStructures(); 00021 00022 TRI=new ArrayList<String>(); 00023 XYZ=new ArrayList<String>(); 00024 XY_param=new ArrayList<String>(); 00025 00026 print(); 00027 } 00028 00029 00030 public MatlabEfficientWriter(MeshToImageDataFilter triangleStorage, File f) throws FileNotFoundException{ 00031 p=new PrintWriter(f); 00032 00033 efficientPolygonRetriever=new EfficientPolygonRetriever(triangleStorage.getGeometricObjects()); 00034 efficientPolygonRetriever.makeDataStructures(); 00035 00036 TRI=new ArrayList<String>(); 00037 XYZ=new ArrayList<String>(); 00038 XY_param=new ArrayList<String>(); 00039 00040 print(); 00041 } 00042 00043 00044 public void print(){ 00045 int nbrTriangles=efficientPolygonRetriever.getTriangleArrayLength(); 00046 int a,b,c; 00047 for(int i =0;i!=nbrTriangles;i++){ 00048 a=efficientPolygonRetriever.getTriangleArray()[i][0]; 00049 b=efficientPolygonRetriever.getTriangleArray()[i][1]; 00050 c=efficientPolygonRetriever.getTriangleArray()[i][2]; 00051 TRI.add("["+ a + " " +b + " "+ c + "]"); 00052 } 00053 00054 float vx,vy,vz; 00055 for(int i =0;i!=efficientPolygonRetriever.getVertexArray().length;i++){ 00056 vx=efficientPolygonRetriever.getVertexArray()[i][0]; 00057 vy=efficientPolygonRetriever.getVertexArray()[i][1]; 00058 vz=efficientPolygonRetriever.getVertexArray()[i][2]; 00059 XYZ.add("["+ vx + " " +vy + " "+ vz + "]"); 00060 } 00061 00062 00063 00064 float x_param,y_param; 00065 for(int i =0;i!=efficientPolygonRetriever.getVertexArray().length;i++){ 00066 x_param=efficientPolygonRetriever.getVertexArray()[i][3]; 00067 y_param=efficientPolygonRetriever.getVertexArray()[i][4]; 00068 XY_param.add("["+ x_param + " " +y_param+ "]"); 00069 00070 } 00071 00072 00073 00074 } 00075 00076 00077 00078 public void closeWriter(){ 00079 if(Debug.VERBOSE) Debug.print("writing MatlabColoredTrimesh"); 00080 p.println("TRI=["); 00081 for(String s:TRI){ 00082 p.println(s); 00083 } 00084 p.println("];"); 00085 p.println("XYZ=["); 00086 for(String s:XYZ){ 00087 p.println(s); 00088 } 00089 p.println("];"); 00090 00091 p.println("XY_param=["); 00092 for(String s:XY_param){ 00093 p.println(s); 00094 } 00095 p.println("];"); 00096 00097 p.flush(); 00098 p.close(); 00099 } 00100 00101 } 00102
1.5.5