Statistics
| Revision:

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

History | View | Annotate | Download (2.31 KB)

1
package com.iver.cit.jdwglib.dwg;
2

    
3
import java.io.File;
4
import java.io.IOException;
5
import java.net.URL;
6
import java.util.List;
7

    
8
import junit.framework.TestCase;
9

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

    
13
public class DwgFileTest extends TestCase {
14
        private File baseDataPath;
15

    
16
        protected void setUp() throws Exception {
17
                super.setUp();
18
                URL url = this.getClass().getResource("DwgFileTest_data");
19
                if (url == null)
20
                        throw new Exception("Can't find 'DwgFileTest_data' dir");
21

    
22
                baseDataPath = new File(url.getFile());
23
                if (!baseDataPath.exists())
24
                        throw new Exception("Can't find 'DwgFileTest_data' dir");
25

    
26
        }
27

    
28
        protected void tearDown() throws Exception {
29
                super.tearDown();
30
        }
31

    
32
        public void test1() throws IOException, DwgVersionNotSupportedException {
33
                // String fileName = baseDataPath.getAbsolutePath()+"/Un punto.dwg";
34
                // DwgFile dwg = new DwgFile(fileName);
35
                //
36
                // dwg.read();
37
                // dwg.calculateGisModelDwgPolylines();
38
                // dwg.blockManagement();
39
                // LinkedList dwgObjects = dwg.getDwgObjects();
40
        }
41

    
42
        
43

    
44
        // test of DWG 12 format
45
        public void test4() throws IOException, DwgVersionNotSupportedException {
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
//                }
61
        }
62
        
63
        public void test5() throws IOException, DwgVersionNotSupportedException{
64
                 String fileName = baseDataPath.getAbsolutePath()+"/TORRE03.DWG";
65
                 DwgFile dwg = new DwgFile(fileName);
66
                
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
                 }
79
        }
80

    
81
}