Statistics
| Revision:

root / trunk / libraries / libDwg / src-test / com / iver / cit / jdwglib / dwg / DwgFileTest.java @ 10821

History | View | Annotate | Download (4.56 KB)

1 10198 fdiaz
package com.iver.cit.jdwglib.dwg;
2
3
import java.io.File;
4
import java.io.IOException;
5
import java.net.URL;
6 10224 azabala
import java.util.List;
7 10198 fdiaz
8
import junit.framework.TestCase;
9
10 10821 azabala
import com.iver.cit.jdwglib.dwg.objects.DwgPFacePolyline;
11
12 10198 fdiaz
public class DwgFileTest extends TestCase {
13
        private File baseDataPath;
14
15
        protected void setUp() throws Exception {
16
                super.setUp();
17
                URL url = this.getClass().getResource("DwgFileTest_data");
18 10821 azabala
                if (url == null)
19 10198 fdiaz
                        throw new Exception("Can't find 'DwgFileTest_data' dir");
20 10821 azabala
21 10198 fdiaz
                baseDataPath = new File(url.getFile());
22 10821 azabala
                if (!baseDataPath.exists())
23 10198 fdiaz
                        throw new Exception("Can't find 'DwgFileTest_data' dir");
24 10821 azabala
25 10198 fdiaz
        }
26
27
        protected void tearDown() throws Exception {
28
                super.tearDown();
29
        }
30 10821 azabala
31 10198 fdiaz
        public void test1() throws IOException, DwgVersionNotSupportedException {
32 10821 azabala
                // String fileName = baseDataPath.getAbsolutePath()+"/Un punto.dwg";
33
                // DwgFile dwg = new DwgFile(fileName);
34
                //
35
                // dwg.read();
36
                // dwg.calculateGisModelDwgPolylines();
37
                // dwg.blockManagement();
38
                // LinkedList dwgObjects = dwg.getDwgObjects();
39 10224 azabala
        }
40 10821 azabala
41 10599 azabala
        /*
42 10821 azabala
         * 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};
54 10599 azabala
55 10821 azabala
                //
56 10319 azabala
        }
57 10821 azabala
58
        // test of DWG 12 format
59
        public void test4() throws IOException, DwgVersionNotSupportedException {
60
                String fileName = baseDataPath.getAbsolutePath() + "/TORRE03.DWG";
61 10599 azabala
                DwgFile dwg = new DwgFile(fileName);
62
                dwg.read();
63
                dwg.calculateGisModelDwgPolylines();
64 10821 azabala
                //antes de los bloques
65 10599 azabala
                List dwgObjects = dwg.getDwgObjects();
66 10821 azabala
                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
                }
75 10599 azabala
        }
76 10821 azabala
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);
106
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
138
        }
139
140
141
142 10198 fdiaz
}