Revision 10880 trunk/libraries/libDwg/src-test/com/iver/cit/jdwglib/dwg/DwgFileTest.java

View differences:

DwgFileTest.java
7 7

  
8 8
import junit.framework.TestCase;
9 9

  
10
import com.iver.cit.jdwglib.dwg.objects.DwgBlockHeader;
10 11
import com.iver.cit.jdwglib.dwg.objects.DwgPFacePolyline;
11 12

  
12 13
public class DwgFileTest extends TestCase {
......
38 39
		// LinkedList dwgObjects = dwg.getDwgObjects();
39 40
	}
40 41

  
41
	/*
42
	 * 0 LWPOLYLINE 5 67A3 330 14B33 100 AcDbEntity 8 51 6 Continuous 62 1 100
43
	 * AcDbPolyline 90 2 70 0 43 0.05 38 3687388.508636616 10 2615813.541238185
44
	 * 20 31.11 10 2615809.722835378 20 31.13 210 0.7097208274403748 220
45
	 * 0.704483035350994 230 0.0
46
	 * 
47
	 */
48
	// test of extrusion
49
	public void test3() {
50
		// test of extrusion
51
		// double[] coord = null;
52
		// double[] extrusion = null;
53
		// double[] extrusion2 = new double[]{0, 0, 1};
42
	
54 43

  
55
		//	
56
	}
57

  
58 44
	// test of DWG 12 format
59 45
	public void test4() throws IOException, DwgVersionNotSupportedException {
60
		String fileName = baseDataPath.getAbsolutePath() + "/TORRE03.DWG";
61
		DwgFile dwg = new DwgFile(fileName);
62
		dwg.read();
63
		dwg.calculateGisModelDwgPolylines();
64
		//antes de los bloques
65
		List dwgObjects = dwg.getDwgObjects();
66
		dwg.blockManagement2();
67
		//despues de los bloques
68
		dwgObjects = dwg.getDwgObjects();
69
		for(int i = 0; i < dwgObjects.size(); i++){
70
			DwgObject o = (DwgObject) dwgObjects.get(i);
71
			if(o instanceof IDwg2FMap){
72
				((IDwg2FMap)o).toFMapGeometry(true);
73
			}
74
		}
46
//		String fileName = baseDataPath.getAbsolutePath() + "/TORRE03.DWG";
47
//		DwgFile dwg = new DwgFile(fileName);
48
//		dwg.read();
49
//		dwg.calculateGisModelDwgPolylines();
50
//		//antes de los bloques
51
//		List dwgObjects = dwg.getDwgObjects();
52
//		dwg.blockManagement2();
53
//		//despues de los bloques
54
//		dwgObjects = dwg.getDwgObjects();
55
//		for(int i = 0; i < dwgObjects.size(); i++){
56
//			DwgObject o = (DwgObject) dwgObjects.get(i);
57
//			if(o instanceof IDwg2FMap){
58
//				((IDwg2FMap)o).toFMapGeometry(true);
59
//			}
60
//		}
75 61
	}
76

  
77

  
78
	// test of block transform
79
	public void test5() {
80
		// datos del bloque
81
//		double[] insertionPoint = new double[] { 775183.239, 4453869.608, 0 };
82
//		double[] scale = new double[] { 0.20, 0.20, 5.512 };
83
//		double rotation = 0.2;
84
//		double[] basePoint = new double[] { 0, 0, 0 };
85
//
86
//		double[] p1 = new double[] { -4.7, 2.3, 0 };
87
//		double[] p2 = new double[] { -3.75, 0.6, 0 };
88
//		double[] p3 = new double[] { -1.8, -0.15, 0 };
89
//		double[] p4 = new double[] { 0, 0, 0 };
90
//
91
//		// a) Metodo actual
92
//		Point2D p11 = new Point2D.Double(p1[0], p1[1]);
93
//		Point2D p21 = new Point2D.Double(p2[0], p2[1]);
94
//		Point2D p31 = new Point2D.Double(p3[0], p3[1]);
95
//		Point2D p41 = new Point2D.Double(p4[0], p4[1]);
96
//
97
//		java.awt.geom.AffineTransform affineTrans = new java.awt.geom.AffineTransform();
98
//		affineTrans.translate(insertionPoint[0], insertionPoint[1]);
99
//		affineTrans.rotate(rotation);
100
//		affineTrans.scale(scale[0], scale[1]);
101
//
102
//		Point2D newP2d1 = affineTrans.transform(p11, null);
103
//		Point2D newP2d2 = affineTrans.transform(p21, null);
104
//		Point2D newP2d3 = affineTrans.transform(p31, null);
105
//		Point2D newP2d4 = affineTrans.transform(p41, null);
62
	
63
	public void test5() throws IOException, DwgVersionNotSupportedException{
64
		 String fileName = baseDataPath.getAbsolutePath()+"/TORRE03.DWG";
65
		 DwgFile dwg = new DwgFile(fileName);
106 66
		
107
		
108
		
109
//        com.iver.cit.jdwglib.util.Matrix4D scaleMat = new com.iver.cit.jdwglib.util.Matrix4D(scale[0], 0.0F, 0.0F, 0.0F, 
110
//        								0.0F, scale[1], 0.0F, 0.0F, 
111
//        								0.0F, 0.0F, scale[2], 0.0F, 
112
//        								0.0F, 0.0F, 0.0F, 1.0F);
113
//        com.iver.cit.jdwglib.util.Matrix4D rotationMat = 
114
//        	new com.iver.cit.jdwglib.util.Matrix4D();
115
//        rotationMat.zrot(rotation);
116
//        com.iver.cit.jdwglib.util.Matrix4D aaaMat =  
117
//        	new com.iver.cit.jdwglib.util.Matrix4D();
118
//        com.iver.cit.jdwglib.util.Matrix4D translationMat = 
119
//        	new com.iver.cit.jdwglib.util.Matrix4D();
120
//        translationMat.translate(new com.iver.cit.jdwglib.util.Vector3D(insertionPoint[0], 
121
//        																insertionPoint[1], 
122
//        																insertionPoint[2]));
123
//          
124
//        com.iver.cit.jdwglib.util.Matrix4D trafo = aaaMat.
125
//			        					mult(translationMat.
126
//			        					mult(rotationMat.
127
//			        					mult(scaleMat)));
128
//        
129
//        Point3D a1 = new Point3D(p1[0], p1[1], p1[2]);
130
//        trafo.transform(a1);
131
//        Point3D a2 = new Point3D(p2[0], p2[1], p2[2]);
132
//        trafo.transform(a2);
133
//        Point3D a3 = new Point3D(p3[0], p3[1], p3[2]);
134
//        trafo.transform(a3);
135
//        Point3D a4 = new Point3D(p4[0], p4[1], p4[2]);
136
//        trafo.transform(a4);
137
               
67
		 dwg.read();
68
		 List dwgObjects = dwg.getDwgObjects();
69
		 for(int i = 0; i < dwgObjects.size(); i++){
70
			 DwgObject obj = (DwgObject) dwgObjects.get(i);
71
			 if(obj instanceof DwgBlockHeader){
72
				 DwgBlockHeader blockHeader = (DwgBlockHeader)obj;
73
				 if(blockHeader.isBlkIsXRef()){
74
					 System.out.println("bloque "+blockHeader.getName()+" es referencia externa");
75
					 System.out.println("path="+blockHeader.getXRefPName());
76
				 }
77
			 }
78
		 }
138 79
	}
139
	
140
	
141 80

  
142 81
}

Also available in: Unified diff