Revision 1006

View differences:

tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/buildNumber.properties
1
#Tue Jul 05 19:54:21 CEST 2022
2
buildNumber=2280
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/src/test/java/org/gvsig/dwg/fmap/dal/store/dwg/TestDWG.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.dwg.fmap.dal.store.dwg;
29

  
30
import java.io.File;
31

  
32
import org.gvsig.fmap.dal.DataStoreParameters;
33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36

  
37
public class TestDWG extends BaseTestFeatureStore {
38

  
39

  
40
	protected boolean testDXFInitialized = false;
41

  
42
	public static File file_prueba = new File(TestDWG.class.getResource(
43
			"data/V2000.dwg").getFile());
44

  
45
	/*
46
	 * (non-Javadoc)
47
	 *
48
	 * @see
49
	 * org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters
50
	 * ()
51
	 */
52
	public DataStoreParameters getDefaultDataStoreParameters()
53
			throws DataException {
54
		DWGStoreParameters dwgParameters = null;
55

  
56
		dwgParameters = (DWGStoreParameters) dataManager
57
				.createStoreParameters(DWGStoreProvider.NAME);
58

  
59
		dwgParameters.setFile(file_prueba);
60
		dwgParameters.setCRS("EPSG:23030");
61
		return dwgParameters;
62
	}
63

  
64
	/*
65
	 * (non-Javadoc)
66
	 *
67
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
68
	 */
69
	public boolean hasExplorer() {
70
		// TODO Auto-generated method stub
71
		return false;
72
	}
73

  
74
	public boolean usesResources() {
75
		return true;
76
	}
77

  
78

  
79
	public void testLegendAndLabeling() throws Exception {
80
		DataStoreParameters params = getDefaultDataStoreParameters();
81
		FeatureStore store = (FeatureStore) dataManager.openStore(params
82
				.getDataStoreName(), params);
83

  
84
		assertNotNull(store.invokeDynMethod("getLegend", null));
85
		assertNotNull(store.invokeDynMethod("getLabeling", null));
86
		store.dispose();
87
	}
88
}
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/src/test/java/org/gvsig/dwg/fmap/dal/store/dwg/TestDWG2004.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.dwg.fmap.dal.store.dwg;
29

  
30
import java.io.File;
31

  
32
public class TestDWG2004 extends TestDWG {
33
	public static File file_prueba = new File(TestDWG.class.getResource(
34
			"data/V2004.dwg").getFile());
35
}
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/src/main/java/org/gvsig/dwg/DWGRegisterExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.dwg;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.dwg.fmap.dal.store.dwg.DWGStoreProvider;
27
import org.gvsig.fmap.mapcontext.MapContextLocator;
28

  
29
/**
30
 * Dummy DWG extension, as all the registration happens in the
31
 * {@link DWGLibrary}.
32
 *
33
 * @author gvSIG Team
34
 */
35
public class DWGRegisterExtension extends Extension {
36

  
37
	public void execute(String actionCommand) {
38
		// Nothing to do
39
	}
40

  
41
	public void initialize() {
42
		IconThemeHelper.registerIcon("layer", "layer-icon-dwg", this);
43
	}
44

  
45
	public void postInitialize() {
46
		MapContextLocator.getMapContextManager().registerIconLayer(DWGStoreProvider.NAME, "layer-icon-dwg");
47
	}
48

  
49
	public boolean isEnabled() {
50
		// Nothing to do
51
		return false;
52
	}
53

  
54
	public boolean isVisible() {
55
		// Nothing to do
56
		return false;
57
	}
58

  
59
}
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib">
4
	</libraries>
5
	<depends plugin-name="org.gvsig.app.mainplugin"/>
6
		<resourceBundle name="text"/>
7
	<extensions>
8
		<extension class-name="org.gvsig.dwg.DWGRegisterExtension"
9
			description="DWG Driver"
10
			active="true">
11
		</extension>
12

  
13
	</extensions>
14
</plugin-config>
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
    <dependencySet>
27
      <useProjectArtifact>false</useProjectArtifact>
28
      <useTransitiveDependencies>false</useTransitiveDependencies>
29
      <outputDirectory>lib</outputDirectory>
30
      <includes>
31
        <include>org.gvsig:org.gvsig.dwg.provider.legend</include>
32
        <include>org.gvsig:org.gvsig.dwg.provider</include>
33
        <include>org.gvsig:org.gvsig.dwg.lib</include>
34
      </includes>
35
    </dependencySet>
36
  </dependencySets>
37

  
38
</assembly>
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
  <modelVersion>4.0.0</modelVersion>
6
  <artifactId>org.gvsig.dwg.app.mainplugin</artifactId>
7
  <packaging>jar</packaging>
8
  <name>${project.artifactId}</name>
9
  <description>
10
DWG file format support (read-only)
11

  
12
Supported versions:
13
- v12
14
- v14
15
- v15
16
- v2004
17

  
18
  </description>
19
  <parent>
20
      <groupId>org.gvsig</groupId>
21
      <artifactId>org.gvsig.dwg.app</artifactId>
22
      <version>2.0.211</version>
23
  </parent>
24

  
25
  <dependencies>
26
    <dependency>
27
        <groupId>org.gvsig</groupId>
28
        <artifactId>org.gvsig.tools.lib</artifactId>
29
        <scope>compile</scope>
30
    </dependency>
31
    <dependency>
32
        <groupId>org.gvsig</groupId>
33
        <artifactId>org.gvsig.andami</artifactId>
34
        <scope>compile</scope>
35
    </dependency>
36
    <dependency>
37
        <groupId>org.gvsig</groupId>
38
        <artifactId>org.gvsig.dwg.provider</artifactId>
39
        <scope>compile</scope>
40
    </dependency>
41
    <dependency>
42
        <groupId>org.gvsig</groupId>
43
        <artifactId>org.gvsig.dwg.provider.legend</artifactId>
44
        <scope>compile</scope>
45
    </dependency>
46

  
47
    <dependency>
48
        <groupId>org.gvsig</groupId>
49
        <artifactId>org.gvsig.dwg.lib</artifactId>
50
        <scope>runtime</scope>
51
    </dependency>
52

  
53
    <!-- Tests -->
54

  
55
    <dependency>
56
      <groupId>org.gvsig</groupId>
57
      <artifactId>org.gvsig.fmap.dal.impl</artifactId>
58
      <type>test-jar</type>
59
      <scope>test</scope>
60
    </dependency>
61

  
62
    <dependency>
63
      <groupId>org.gvsig</groupId>
64
      <artifactId>org.gvsig.fmap.dal.impl</artifactId>
65
      <type>jar</type>
66
      <scope>test</scope>
67
    </dependency>
68

  
69
  </dependencies>
70

  
71
    <properties>
72
        <!-- Package info property values -->
73
        <!-- Default values in org.gvsig.desktop -->
74
        <gvsig.package.info.name>Formats: dwg file format support (read-only)</gvsig.package.info.name>
75
        <gvsig.package.info.state>testing</gvsig.package.info.state>
76
        <gvsig.package.info.official>true</gvsig.package.info.official>
77
        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies>
78
        <gvsig.package.info.categories>Formats,Vector</gvsig.package.info.categories>
79
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-dwg/pool</gvsig.package.info.poolURL>
80
    </properties>
81

  
82
  <build>
83
    <plugins>
84

  
85
      <plugin>
86
        <!-- Skip compilation tests -->
87
        <groupId>org.apache.maven.plugins</groupId>
88
        <artifactId>maven-compiler-plugin</artifactId>
89
        <executions>
90
          <execution>
91
            <id>default-testCompile</id>
92
            <phase>process-test-sources</phase>
93
            <goals>
94
              <goal>testCompile</goal>
95
            </goals>
96
            <configuration>
97
              <skip>true</skip>
98
            </configuration>
99
          </execution>
100
        </executions>
101
      </plugin>
102

  
103
      <plugin>
104
        <!-- Skip test execution -->
105
        <groupId>org.apache.maven.plugins</groupId>
106
        <artifactId>maven-surefire-plugin</artifactId>
107
        <configuration>
108
          <skipTests>true</skipTests>
109
        </configuration>
110
      </plugin>
111

  
112
    </plugins>
113
  </build>
114

  
115
</project>
116

  
0 117

  
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.app/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
  <modelVersion>4.0.0</modelVersion>
6
  <artifactId>org.gvsig.dwg.app</artifactId>
7
  <packaging>pom</packaging>
8
  <name>${project.artifactId}</name>
9
  <parent>
10
      <groupId>org.gvsig</groupId>
11
      <artifactId>org.gvsig.dwg</artifactId>
12
      <version>2.0.211</version>
13
  </parent>
14

  
15
  <modules>
16
    <module>org.gvsig.dwg.app.mainplugin</module>
17
  </modules>
18

  
19

  
20
</project>
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.lib/src/test/java/org/gvsig/dwg/lib/DwgTestSuite.java
1
/*
2
 * Created on 08-feb-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DwgTestSuite.java 28970 2009-05-25 13:27:14Z jmvivo $
47
* $Log$
48
* Revision 1.1.2.1  2007-02-28 07:35:10  jmvivo
49
* Actualizado desde el HEAD.
50
*
51
* Revision 1.1  2007/02/08 20:27:57  azabala
52
* *** empty log message ***
53
*
54
*
55
*/
56
package org.gvsig.dwg.lib;
57

  
58
import junit.framework.Test;
59
import junit.framework.TestSuite;
60

  
61
public class DwgTestSuite {
62

  
63
	public static Test suite() {
64
		TestSuite suite = new TestSuite("Test for com.iver.cit.jdwglib.dwg");
65
		//$JUnit-BEGIN$
66
		suite.addTestSuite(DwgFileTest.class);
67
		//$JUnit-END$
68
		return suite;
69
	}
70

  
71
}
72

  
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.lib/src/test/java/org/gvsig/dwg/lib/DwgFileTest.java
1
package org.gvsig.dwg.lib;
2

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

  
7
import junit.framework.TestCase;
8

  
9
public class DwgFileTest extends TestCase {
10
	private File baseDataPath;
11

  
12
	protected void setUp() throws Exception {
13
		super.setUp();
14
		URL url = this.getClass().getResource("data");
15
		if (url == null) {
16
			throw new Exception("Can't find 'data' dir");
17
		}
18

  
19
		baseDataPath = new File(url.getFile());
20
		if (!baseDataPath.exists()) {
21
			throw new Exception("Can't find 'data' dir");
22
		}
23

  
24
	}
25

  
26
	protected void tearDown() throws Exception {
27
		super.tearDown();
28
	}
29
	public void test1() throws IOException, DwgVersionNotSupportedException {
30
//		String fileName = baseDataPath.getAbsolutePath()+"/Un punto.dwg";
31
//		DwgFile dwg = new DwgFile(fileName);
32
//
33
//		dwg.read();
34
//		dwg.calculateGisModelDwgPolylines();
35
//		dwg.blockManagement();
36
//		LinkedList dwgObjects = dwg.getDwgObjects();
37
	}
38

  
39
	public void test2() throws RuntimeException, CorruptedDwgEntityException{
40
        //Dwg Object that is supposed to be
41
        //an LWPOLYLINE in V14 version
42
		/*
43
        int[] data = new int[]{61,64,64,183,19,227,104,16
44
                            ,0,5,8,59,72,32,252,47,90,142,
45
                            234,145,50,10,71,11,213,36,229,
46
                            162,130,10,228,126,23,174,130,
47
                            145,50,15,98,141,196,244,229,
48
                            162,130,12,126,23,169,66,58,
49
                            145,50,12,47,90,138,68,229,
50
                            162,130,8,0,0,4,7,74,137,50,
51
                            15,177,66,231,252,221,162,130,
52
                            9,130,151,21,242,151,21,190,
53
                            8,21,8,56};
54
         */
55
//		int[] data = new int[]{62,128,64,71,99,
56
//							   40,48,0,5,8,27,72,
57
//							   100,126,23,169,68,
58
//							   178,105,50,13,114,
59
//							   63,11,82,165,162,130,
60
//							   13,114,63,11,210,138,
61
//							   105,50,8,173,114,59,
62
//							   138,205,162,130,15,98,
63
//							   141,192,241,58,105,50,
64
//							   11,51,51,52,178,229,162,
65
//							   130,14,110,102,98,97,234,
66
//							   105,50,11,51,51,52,179,21,
67
//							   162,130,10,149,192,240,42,
68
//							   162,105,50,14,189,27,131,
69
//							   107,69,162,130,14,31,169,
70
//							   66,227,74,105,50,9,240,86,
71
//							   185,27,117,162,130,11,59,
72
//							   51,51,52,234,105,50,13,114,
73
//							   63,11,83,85,162,130,9,74,228,
74
//							   126,22,186,105,50,11,51,51,50,
75
//							   51,53,162,130,11,137,232,82,190,
76
//							   58,105,50,9,74,228,122,147,13,162,
77
//							   130,11,137,232,82,189,106,105,50,9,
78
//							   74,228,122,146,213,162,130,9,74,228,122,20,202,105,50,12,126,23,171,194,173,162,130,12,126,23,169,68,178,105,50,13,114,63,11,82,165,162,130,9,130,151,22,10,136,182,8,21,8,120};
79
//        //1er intento: suponemos que la LWPOLYLINE cumple la especificaci?n
80
//        //a rajatabla
81
//        int bitPos = 0;
82
//        List val = DwgUtil.getBitShort(data, bitPos);
83
//        bitPos = ((Integer) val.get(0)).intValue();
84
//        int type = ((Integer) val.get(1)).intValue();
85
//        System.out.println("type = " + type);
86
//
87
//        DwgHandleReference hr = new DwgHandleReference();
88
//        bitPos = hr.read(data, bitPos);
89
//        System.out.println("handle, code="+
90
//                    hr.getCode()+
91
//                    " ,offset="+
92
//                    hr.getOffset());
93
//
94
//        //Ahora pasamos a la extended data
95
//        val = DwgUtil.getBitShort(data, bitPos);
96
//        bitPos = ((Integer) val.get(0)).intValue();
97
//        int extendedDataSize = ((Integer) val.get(1)).intValue();
98
//        System.out.println("EED size="+extendedDataSize);
99
//        //como el size es 0, me lo salto
100
//
101
//        //ver si tiene datos graficos
102
//        val = DwgUtil.testBit(data, bitPos);
103
//        bitPos = ((Integer) val.get(0)).intValue();
104
//        boolean hasGraphicsData = ((Boolean) val.get(1))
105
//                .booleanValue();
106
//        System.out.println("graphics = "+hasGraphicsData);
107
//
108
//        //como se que no hay graphics me lo salto
109
//        //tama?o en bits
110
//        val = DwgUtil.getRawLong(data, bitPos);
111
//        bitPos = ((Integer) val.get(0)).intValue();
112
//        int sizeInBits = ((Integer) val.get(1)).intValue();
113
//        System.out.println("sizeInBits = "+sizeInBits);
114
//
115
//        /*
116
//         * Ahora, lo que viene es lo que en la spec se dice
117
//         * "Common entity data". Revisar bien pues PythonCAD no lo lee
118
//         * como en la spec.
119
//         *
120
//         * pag 42.
121
//          R13-R14 Only:
122
//          	RL	:	Size of object data in bits
123
//          	6B	:	Flags (FEDCBA)
124
//          	6B	:	Common parameters (CCSSII)
125
//          	Segun esto, deberia leer 6 bits y 6 bits
126
//
127
//          	FLAGS
128
//	      	Mas adelante (pag 43), dice:
129
//	      	DC	:	This is the number of reactors attached to an
130
//	      	entity as a bitshort.
131
//	      	This feature may have been dormant in R13,
132
//	      	but it appears in R14, and in files saved as R13 by R14.
133
//
134
//	      	Ahora bien, pythoncad las est? leyendo como bitLong
135
//          	?En que quedamos, son 2 bits, 1 bitLong o 1 bitShort?
136
//          	TODO REVISAR
137
//
138
//          	COMMON PARAMETERS
139
//          	Al principio, dice que son 6 bits (CC, SS, II)
140
//          	pero luego dice (pag 43):
141
//          	CC	:	Color bitshort
142
//          	SS	:	Linetype scale bitdouble
143
//          	II	:	"Invisible" flag bitshort
144
//
145
//			Pythoncad, en vez de como 2 bits, los est? leyendo
146
//			como BitShort, BitDouble y BitShort
147
//
148
//         * */
149
//
150
//        Integer mode = (Integer) DwgUtil.getBits(data, 2, bitPos);
151
//		bitPos += 2;
152
//		System.out.println("mode = "+mode);
153
//
154
//	/*
155
//		val = DwgUtil.getBitLong(data, bitPos);
156
//		bitPos = ((Integer) val.get(0)).intValue();
157
//		int rnum = ((Integer) val.get(1)).intValue();
158
//		System.out.println("numReactors = "+rnum);
159
//*/
160
//		val = DwgUtil.getBitShort(data, bitPos);
161
//		bitPos = ((Integer) val.get(0)).intValue();
162
//		int rnum = ((Integer) val.get(1)).intValue();
163
//		System.out.println("numReactors = "+rnum);
164
//
165
//
166
//		val = DwgUtil.testBit(data, bitPos);
167
//		bitPos = ((Integer) val.get(0)).intValue();
168
//		boolean isLyrByLineType = ((Boolean) val.get(1)).booleanValue();
169
//		System.out.println("isLyrByLineType="+isLyrByLineType);
170
//
171
//		val = DwgUtil.testBit(data, bitPos);
172
//		bitPos = ((Integer) val.get(0)).intValue();
173
//		boolean noLinks = ((Boolean) val.get(1)).booleanValue();
174
//		System.out.println("noLinks="+noLinks);
175
//
176
//
177
//		val = DwgUtil.getBitShort(data, bitPos);
178
//		bitPos = ((Integer) val.get(0)).intValue();
179
//		int color = ((Integer) val.get(1)).intValue();
180
//		System.out.println("color="+color);
181
//
182
//
183
//		val = DwgUtil.getBitDouble(data, bitPos);
184
//		bitPos = ((Integer) val.get(0)).intValue();
185
//		float ltscale = ((Double) val.get(1)).floatValue();
186
//		System.out.println("ltscale="+ltscale);
187
//
188
//		val = DwgUtil.getBitShort(data, bitPos);
189
//		bitPos = ((Integer) val.get(0)).intValue();
190
//		int invis = ((Integer) val.get(1)).intValue();
191
//		System.out.println("invis="+invis);
192
//
193
//		val = DwgUtil.getBitShort(data, bitPos);
194
//		bitPos = ((Integer) val.get(0)).intValue();
195
//		int flag = ((Integer) val.get(1)).intValue();
196
//		System.out.println("flag="+flag);
197
//
198
//		double dVal = 0d;
199
//		if((flag & 0x4) > 0){
200
//			val = DwgUtil.getBitDouble(data, bitPos);
201
//			bitPos = ((Integer) val.get(0)).intValue();
202
//			dVal = ((Double) val.get(1)).doubleValue();
203
//		}
204
//		System.out.println("constWidth="+dVal);
205
//
206
//		dVal = 0d;
207
//		if((flag & 0x8) > 0){
208
//			val = DwgUtil.getBitDouble(data, bitPos);
209
//			bitPos = ((Integer) val.get(0)).intValue();
210
//			dVal = ((Double) val.get(1)).doubleValue();
211
//		}
212
//		System.out.println("elevation="+dVal);
213
//
214
//		dVal = 0d;
215
//		if ((flag & 0x2) > 0){
216
//			val = DwgUtil.getBitDouble(data, bitPos);
217
//			bitPos = ((Integer) val.get(0)).intValue();
218
//			dVal = ((Double) val.get(1)).doubleValue();
219
//		}
220
//		System.out.println("thickness="+dVal);
221
//
222
//		double x, y, z ;
223
//		x = 0d;
224
//		y = 0d;
225
//		z = 0d;
226
//
227
//		if ((flag & 0x1) > 0){
228
//			val = DwgUtil.getBitDouble(data, bitPos);
229
//			bitPos = ((Integer) val.get(0)).intValue();
230
//			x = ((Double) val.get(1)).doubleValue();
231
//
232
//			val = DwgUtil.getBitDouble(data, bitPos);
233
//			bitPos = ((Integer) val.get(0)).intValue();
234
//			y = ((Double) val.get(1)).doubleValue();
235
//
236
//			val = DwgUtil.getBitDouble(data, bitPos);
237
//			bitPos = ((Integer) val.get(0)).intValue();
238
//			z = ((Double) val.get(1)).doubleValue();
239
//		}
240
//		System.out.println("normal="+x+","+y+","+z);
241
//
242
//		val = DwgUtil.getBitLong(data, bitPos);
243
//		bitPos = ((Integer) val.get(0)).intValue();
244
//		int np = ((Integer) val.get(1)).intValue();
245
//		System.out.println("numPoints="+np);
246
//
247
//		int nb = 0;
248
//		if((flag & 0x10) > 0){
249
//			val = DwgUtil.getBitLong(data, bitPos);
250
//			bitPos = ((Integer) val.get(0)).intValue();
251
//			nb = ((Integer) val.get(1)).intValue();
252
//		}
253
//		System.out.println("numBulges="+nb);
254
//		int nw = 0;
255
//		if((flag & 0x20) > 0){
256
//			val = DwgUtil.getBitLong(data, bitPos);
257
//			bitPos = ((Integer) val.get(0)).intValue();
258
//			nw = ((Integer) val.get(1)).intValue();
259
//		}
260
//		System.out.println("numWidths="+nw);
261
//		if(np > 0){
262
//			Point2D[] points = new Point2D[np];
263
//			for(int i = 0; i < np; i++){
264
//				val = DwgUtil.getRawDouble(data, bitPos);
265
//				bitPos = ((Integer) val.get(0)).intValue();
266
//				x = ((Double) val.get(1)).doubleValue();
267
//
268
//				val = DwgUtil.getRawDouble(data, bitPos);
269
//				bitPos = ((Integer) val.get(0)).intValue();
270
//				y = ((Double) val.get(1)).doubleValue();
271
//
272
//				points[i] = new Point2D.Double(x, y);
273
//				System.out.println("Punto"+i+"="+x+","+y);
274
//			}//for
275
//		}//if np
276
//
277
//		if(nb > 0){
278
//			double[] bulges = new double[nb];
279
//			for(int i = 0; i < nb; i++){
280
//				val = DwgUtil.getRawDouble(data, bitPos);
281
//				bitPos = ((Integer) val.get(0)).intValue();
282
//				bulges[i] = ((Double) val.get(1)).doubleValue();
283
//				System.out.println("Bulge"+i+"="+bulges[i]);
284
//			}//for
285
//
286
//		}//if nb
287
//
288
//		if(nw > 0){
289
//			double[][] widths = new double[nw][2];
290
//			for(int i = 0; i < nw; i++){
291
//				val = DwgUtil.getBitDouble(data, bitPos);
292
//				bitPos = ((Integer) val.get(0)).intValue();
293
//				double sw = ((Double) val.get(1)).doubleValue();
294
//
295
//				val = DwgUtil.getBitDouble(data, bitPos);
296
//				bitPos = ((Integer) val.get(0)).intValue();
297
//				double ew = ((Double) val.get(1)).doubleValue();
298
//
299
//				widths[i][0] = sw;
300
//				widths[i][1] = ew;
301
//				System.out.println("Width"+i+"="+sw+","+ew);
302
//			}//for
303
//		}
304
     }
305

  
306
	public void test3(){
307
		//test of extrusion
308
		double[] coord = null;
309
		double[] extrusion = null;
310
		double[] extrusion2 = new double[]{0, 0, 1};
311

  
312
		coord = new double[]{790089.65, 4477974.75, 9.560000000114087};
313
		extrusion = new double[]{-0.5037965987025721, 0.07005064807841195, 0.8609772899673451};
314
		//1. algoritmo original, vector normal distinto
315
//		double[] newCoord = AcadExtrusionCalculator.extrude(coord, extrusion);
316
//		newCoord = AcadExtrusionCalculator.extrude3(coord, extrusion);
317
//
318
		//2? ahora con vector normal coincidente con eje Z
319
//		newCoord = AcadExtrusionCalculator.extrude(coord, extrusion2);
320
//		newCoord = AcadExtrusionCalculator.extrude3(coord, extrusion2);
321
	}
322
}
tags/org.gvsig.dwg-2.0.211/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/DwgFileVR2004Reader.java
1
/*
2
 * Created on 09-ene-2007
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44

  
45
package org.gvsig.dwg.lib.readers;
46

  
47
import java.io.IOException;
48
import java.nio.ByteBuffer;
49
import java.nio.ByteOrder;
50
import java.util.ArrayList;
51
import java.util.Comparator;
52
import java.util.List;
53
import java.util.TreeSet;
54

  
55
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
56
import org.gvsig.dwg.lib.DwgClass2004;
57
import org.gvsig.dwg.lib.DwgFile;
58
import org.gvsig.dwg.lib.DwgHandleReference;
59
import org.gvsig.dwg.lib.DwgObject;
60
import org.gvsig.dwg.lib.DwgObjectFactory;
61
import org.gvsig.dwg.lib.DwgObjectOffset;
62
import org.gvsig.dwg.lib.DwgUtil;
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65

  
66

  
67

  
68
/**
69
 * @author alzabord
70
 *
71
 * TODO To change the template for this generated type comment go to Window -
72
 * Preferences - Java - Code Style - Code Templates
73
 */
74
public class DwgFileVR2004Reader implements IDwgFileReader {
75

  
76
	protected DwgFile dwgFile;
77

  
78
	protected ByteBuffer bb;
79

  
80
	static byte[] magicNumber = null;
81

  
82
	private String version = "";
83

  
84
	private byte[] unknowSixBytes;
85

  
86
	private byte[] threeBytes0;
87

  
88
	private byte[] unknowTwoBytes;
89

  
90
	private byte[] eightyTwoBytes0;
91

  
92
	private byte[] encryptedData;
93

  
94
	private byte[] decryptedData;
95

  
96
	private String fileID = "";
97

  
98
	private int rootTreeNodeGap;
99

  
100
	private int lowermostLeftTreeNodeGap;
101

  
102
	private int lowermostRightTreeNodeGap;
103

  
104
	private int lastSectionId; // Last Section identifier
105

  
106
	private int lastSectionAddress; // Last Section Address
107

  
108
	private int SecondHeaderAddress; // Second Header Address
109

  
110
	private int gapAmount; // Number of Gaps
111

  
112
	private int sectionAmount; // Number of Sections
113

  
114
	private int sectionMapId; // Section Map identifier
115

  
116
	private int sectionMapAddress; // Section Map address
117

  
118
	private int sectionInfoId; // Section Info identifier
119

  
120
	private int sectionInfoIndex = 0; // Section Info identifier into the
121

  
122
	// Sections Array
123

  
124
	private int sectionArraySize;
125

  
126
	private int gapArraySize;
127

  
128
	private byte[] generatedSequence;
129

  
130
	private Section[] sections;
131

  
132
	private Gap[] gaps;
133

  
134
	static final int TYPE_SECTION_MAP = 1;
135

  
136
	static final int TYPE_SECTION_INFO = 2;
137

  
138
	private static Logger logger = LoggerFactory.getLogger(DwgFileVR2004Reader.class.getName());
139

  
140
	/**
141
	 * Reads the DWG version 2004 format
142
	 *
143
	 * @param dwgFile
144
	 *            Represents the DWG file that we want to read
145
	 * @throws IOException
146
	 *             When DWG file path is wrong
147
	 */
148
	public void read(DwgFile dwgFile, ByteBuffer bb) throws IOException {
149

  
150
		this.dwgFile = dwgFile;
151
		this.bb = bb;
152

  
153
		readDwgR2004FileHeader(bb);
154
		readDwgR2004SectionMap(bb);
155
		readDwgR2004InfoSection(bb);
156
		readDwgR2004Headers(bb);
157
		readDwgR2004Classes(bb);
158
		readDwgR2004ObjectOffsets(bb);
159

  
160
		readDwgR2004Objects();
161

  
162
	}
163

  
164
	protected void readDwgR2004InfoSection(ByteBuffer bb) {
165
		int numDescriptions;
166

  
167
		int sizeOfSection;
168
		int numSections;
169
		int maxDecompressedSize;
170
		int compressed;
171
		int sectionType;
172
		int encrypted;
173
		String sectionName = "";
174

  
175
		int sectionNumber;
176
		int dataSize;
177
		int startOffset;
178

  
179
		char c;
180
		int pos;
181

  
182
		if (sectionInfoIndex == 0) {
183
			logger.trace("No se ha encontrado la Section Info en el array de secciones.");
184
		}
185

  
186
		pos = sections[sectionInfoIndex].getAddress(); // we get the address for the Section Info
187

  
188
		bb.position(pos);
189

  
190
		ByteBuffer dData = readSystemSection(bb);
191
		dData.order(ByteOrder.LITTLE_ENDIAN);
192
		dData.position(0);
193

  
194
		/*
195
		 * We start reading the Section Info once decompressed We will find data
196
		 * blocks depending on numDescriptions value
197
		 */
198
		numDescriptions = dData.getInt();
199
		dData.getInt(); // 0x02
200
		dData.getInt(); // 0x00007400
201
		dData.getInt(); // 0x00
202
		dData.getInt(); // unknown
203

  
204
		for (int i = 0; i < numDescriptions; i++) {
205
			sizeOfSection = dData.getInt();
206
			dData.getInt(); // unknown
207
			numSections = dData.getInt();
208
			maxDecompressedSize = dData.getInt();
209
			dData.getInt(); // unknown
210
			compressed = dData.getInt();
211
			sectionType = dData.getInt();
212
			encrypted = dData.getInt();
213
			sectionName = "";
214
			for (int j = 0; j < 64; j++) {
215
				c = (char) dData.get();
216
				sectionName = sectionName + c;
217
			}
218

  
219
			for (int k = 0; k < numSections; k++) {
220
				sectionNumber = dData.getInt(); // index into the Sections Array
221
				dataSize = dData.getInt();
222
				startOffset = dData.getInt();
223
				dData.getInt(); // unknown
224

  
225

  
226
				// We set the name for the Section, so we can localize it by the name
227
				for (int j = 0; j < sectionAmount; j++) {
228
					Section section = sections[j];
229
					if (section.getNumber() == sectionNumber) {
230
						section.setName(sectionName);
231
						section.setSizeOfLogicalSection(sizeOfSection);
232
						section.setDataSize(dataSize);
233
						section.setMaxDecompressedSize(maxDecompressedSize);
234
						section.setCompressed(compressed);
235
						section.setType(sectionType);
236
						section.setEncrypted(encrypted);
237
						section.setStartOffset(startOffset);
238
					}
239
				}
240

  
241
			}
242
		}
243
	}
244

  
245
	/**
246
	 * This function reads the header section of the file, with the encrypted
247
	 * data
248
	 *
249
	 * @param bb
250
	 *            ByteBuffer containing the opened DWG file
251
	 */
252
	protected void readDwgR2004FileHeader(ByteBuffer bb) {
253

  
254
		logger.trace("STARTING TO READ DWG FILE.");
255
		bb.order(ByteOrder.LITTLE_ENDIAN);
256
		for (int i = 0; i < 6; i++) {
257
			version = version + (char) bb.get();
258
		}
259
		if (!version.equalsIgnoreCase("AC1018")) {
260
			logger.trace("Error en la version: " + version);
261
		}
262

  
263
		/*
264
		 * OpenAlliance documentation says we will read 6 0x00 bytes but the
265
		 * sixth one is always 0x4C
266
		 */
267
		unknowSixBytes = new byte[6];
268
		int pos = 6;
269
		for (int i = 0; i < 5; i++) {
270
			unknowSixBytes[i] = bb.get();
271
			if (unknowSixBytes[i] != 0) {
272
				logger.trace("(unknowSixBytes) En la posicion 0x"
273
						+ Integer.toHexString(pos + i)
274
						+ " debería haber un 0, pero hay un 0x"
275
						+ Integer.toHexString(unknowSixBytes[i]));
276
			}
277
		}
278
		pos = 0xB;
279
		unknowSixBytes[5] = bb.get();
280
		if (unknowSixBytes[5] != 0x4C) {
281
			logger.trace("(unknowSixBytes) En la posicion 0x"
282
					+ Integer.toHexString(pos)
283
					+ " debería haber un 0x4C, pero hay un 0x"
284
					+ Integer.toHexString(unknowSixBytes[5]));
285
		}
286

  
287
		bb.get(); // Unknown Byte
288
		bb.getInt(); // previewAddress
289
		bb.get(); // dwgVer
290
		bb.get(); // maintReleaseVer
291
		bb.getShort(); // codepage
292

  
293
		/*
294
		 * OpenAlliance documentation says we will read 3 0x00 bytes but what we
295
		 * always find is 0x00, 0x19 and then 0x4C
296
		 */
297
		threeBytes0 = new byte[3];
298
		pos = 0x15;
299
		bb.get(threeBytes0);
300
		if (threeBytes0[0] != 0x0) {
301
			logger.trace("Posible error leyendo la cabecera del archivo DWG: " +
302
					"En la posicion 0x" + Integer.toHexString(pos)
303
					+ " deber?a haber un 0x0, pero hay un 0x"
304
					+ Integer.toHexString(threeBytes0[0]));
305
		}
306
		pos = 0x16;
307
		if (threeBytes0[1] != 0x19) {
308
			logger.trace("Posible error leyendo la cabecera del archivo DWG: " +
309
					"En la posicion 0x" + Integer.toHexString(pos)
310
					+ " deber?a haber un 0x19, pero hay un 0x"
311
					+ Integer.toHexString(threeBytes0[1]));
312
		}
313
		pos = 0x17;
314
		if (threeBytes0[2] != 0x4C) {
315
			logger.trace("Posible error leyendo la cabecera del archivo DWG: " +
316
					"En la posicion 0x" + Integer.toHexString(pos)
317
					+ " deber?a haber un 0x4C, pero hay un 0x"
318
					+ Integer.toHexString(threeBytes0[2]));
319
		}
320

  
321
		bb.getInt(); // security Type
322
		bb.getInt(); // unknownLong
323
		bb.getInt(); // dwgPropertyAddr
324
		bb.getInt(); // vbaProjectAddr
325
		bb.getInt(); // 0x00000080
326

  
327
		pos = 0x2C;
328

  
329
		unknowTwoBytes = new byte[2];
330
		for (int i = 0; i < 2; i++) {
331
			unknowTwoBytes[i] = bb.get();
332
		}
333
		pos = 0x2E;
334
		eightyTwoBytes0 = new byte[82];
335
		for (int i = 0; i < eightyTwoBytes0.length; i++) {
336
			eightyTwoBytes0[i] = bb.get();
337
			if (eightyTwoBytes0[i] != 0) {
338
				logger.trace("Posible error leyendo la cabecera del archivo DWG: " +
339
						"(eightyTwoBytes0) En la posicion 0x"
340
						+ Integer.toHexString(pos + i)
341
						+ " deber?a haber un 0, pero hay un 0x"
342
						+ Integer.toHexString(eightyTwoBytes0[i]));
343
			}
344
		}
345

  
346
		int len = 0x6C;
347
		encryptedData = new byte[len];
348
		decryptedData = new byte[len];
349
		if (magicNumber == null) {
350
			DwgFileVR2004Reader.setMagicNumber();
351
		}
352

  
353
		// decryptedData will contain the decrypted sequence after xor'ing the
354
		// encrypted data
355
		for (int i = 0; i < len; i++) {
356
			encryptedData[i] = bb.get();
357
			decryptedData[i] = (byte) (encryptedData[i] ^ magicNumber[i]);
358
		}
359

  
360
		ByteBuffer decryptedDataBB = ByteBuffer.allocate(len);
361
		decryptedDataBB.put(decryptedData);
362
		decryptedDataBB.position(0);
363
		decryptedDataBB.order(ByteOrder.LITTLE_ENDIAN);
364

  
365
		// we start intercepting the decrypted variables
366
		for (int i = 0; i < 12; i++) {
367
			fileID = fileID + (char) decryptedDataBB.get();
368
		}
369
		decryptedDataBB.getInt(); // 0x00
370

  
371
		decryptedDataBB.getInt(); // 0x6C
372

  
373
		decryptedDataBB.getInt(); // 0x04
374

  
375
		rootTreeNodeGap = decryptedDataBB.getInt();
376
		lowermostLeftTreeNodeGap = decryptedDataBB.getInt();
377
		lowermostRightTreeNodeGap = decryptedDataBB.getInt();
378
		decryptedDataBB.getInt(); // unknown
379
		lastSectionId = decryptedDataBB.getInt();
380

  
381
		lastSectionAddress = decryptedDataBB.getInt();
382
		decryptedDataBB.getInt(); // 0x00
383

  
384
		SecondHeaderAddress = decryptedDataBB.getInt();
385
		decryptedDataBB.getInt(); // 0x00
386

  
387
		gapAmount = decryptedDataBB.getInt();
388
		sectionAmount = decryptedDataBB.getInt(); // Very important: this is
389
		// the number of sections in the file
390
		decryptedDataBB.getInt(); // 0x20
391
		decryptedDataBB.getInt(); // 0x80
392
		decryptedDataBB.getInt(); // 0x40
393

  
394
		sectionMapId = decryptedDataBB.getInt();
395
		sectionMapAddress = decryptedDataBB.getInt() + 0x100; // the Section Map Address
396
		decryptedDataBB.getInt(); // 0x00
397
		sectionInfoId = decryptedDataBB.getInt(); // Very important: the id of the Section Info
398
		sectionArraySize = decryptedDataBB.getInt();
399
		gapArraySize = decryptedDataBB.getInt();
400
		decryptedDataBB.getInt(); // CRC
401
		len = 0x14;
402
		generatedSequence = new byte[len];
403
		bb.get(generatedSequence);
404
		// Done reading the encrypted variables
405

  
406
	}
407

  
408
	/*************************************************************************************
409
	 * **********************************************************************/
410

  
411
	/**
412
	 * Read and store all the header variables into the
413
	 * <code> HeaderVars </code> Map
414
	 *
415
	 * @param bb
416
	 *            ByteBuffer containing the opened DWG file
417
	 */
418
	private void readDwgR2004Headers(ByteBuffer bb) {
419

  
420
		/*
421
		 * NOTA (Paco) He encontrado un sitio web con explicacion de ¿todas?
422
		 * estas variables: http://www.hispacad.com/variables
423
		 */
424

  
425
		ByteBuffer decompressedBB = readSection(bb, "AcDb:Header");
426

  
427
		byte[] sentinel = new byte[16];
428
		decompressedBB.order(ByteOrder.nativeOrder());
429
		decompressedBB.position(0);
430
		decompressedBB.get(sentinel); // we get the sentinel that ALWAYS
431
		// appears before the data
432

  
433
		if ((sentinel[0] & 0xFF) != 0xcf)
434
			logger.trace("sentinel[0] != 0xcf found " + (sentinel[0] & 0xFF));
435
		if ((sentinel[1] & 0xFF) != 0x7b)
436
			logger.trace("sentinel[1] != 0x7b found " + (sentinel[1] & 0xFF));
437
		if ((sentinel[2] & 0xFF) != 0x1f)
438
			logger.trace("sentinel[2] != 0x1f found " + (sentinel[2] & 0xFF));
439
		if ((sentinel[3] & 0xFF) != 0x23)
440
			logger.trace("sentinel[3] != 0x23 found " + (sentinel[3] & 0xFF));
441
		if ((sentinel[4] & 0xFF) != 0xfd)
442
			logger.trace("sentinel[4] != 0xfd found " + (sentinel[4] & 0xFF));
443
		if ((sentinel[5] & 0xFF) != 0xde)
444
			logger.trace("sentinel[5] != 0xde found " + (sentinel[5] & 0xFF));
445
		if ((sentinel[6] & 0xFF) != 0x38)
446
			logger.trace("sentinel[6] != 0x38 found " + (sentinel[6] & 0xFF));
447
		if ((sentinel[7] & 0xFF) != 0xa9)
448
			logger.trace("sentinel[7] != 0xa9 found " + (sentinel[7] & 0xFF));
449
		if ((sentinel[8] & 0xFF) != 0x5f)
450
			logger.trace("sentinel[8] != 0x5f found " + (sentinel[8] & 0xFF));
451
		if ((sentinel[9] & 0xFF) != 0x7c)
452
			logger.trace("sentinel[9] != 0x7c found " + (sentinel[9] & 0xFF));
453
		if ((sentinel[10] & 0xFF) != 0x68)
454
			logger.trace("sentinel[10] != 0x68 found " + (sentinel[10] & 0xFF));
455
		if ((sentinel[11] & 0xFF) != 0xb8)
456
			logger.trace("sentinel[11] != 0xb8 found " + (sentinel[11] & 0xFF));
457
		if ((sentinel[12] & 0xFF) != 0x4e)
458
			logger.trace("sentinel[12] != 0x4e found " + (sentinel[12] & 0xFF));
459
		if ((sentinel[13] & 0xFF) != 0x6d)
460
			logger.trace("sentinel[13] != 0x6d found " + (sentinel[13] & 0xFF));
461
		if ((sentinel[14] & 0xFF) != 0x33)
462
			logger.trace("sentinel[14] != 0x33 found " + (sentinel[14] & 0xFF));
463
		if ((sentinel[15] & 0xFF) != 0x5f)
464
			logger.trace("sentinel[15] != 0x5f found " + (sentinel[15] & 0xFF));
465

  
466
		// we start working with data that comes after the beginning sentinel
467
		decompressedBB.order(ByteOrder.LITTLE_ENDIAN);
468
		int size = decompressedBB.getInt(); // this size is never correct
469

  
470
		decompressedBB.order(ByteOrder.nativeOrder());
471
		byte[] data = new byte[size];
472
		decompressedBB.get(data);
473

  
474
		int[] intData = DwgUtil.toIntArray(data);
475

  
476
		bb.order(ByteOrder.LITTLE_ENDIAN);
477
		decompressedBB.getShort(); // CRC
478

  
479
		decompressedBB.order(ByteOrder.nativeOrder());
480
		byte[] lastSentinnel = new byte[16]; // we know it comes there because we already found it
481
		decompressedBB.get(lastSentinnel);
482

  
483
		if ((lastSentinnel[0] & 0xFF) != 0x30)
484
			logger.trace("lastSentinnel[0] != 0x30 , is: " + lastSentinnel[0]);
485
		if ((lastSentinnel[1] & 0xFF) != 0x84)
486
			logger.trace("lastSentinnel[1] != 0x84 , is: " + lastSentinnel[1]);
487
		if ((lastSentinnel[2] & 0xFF) != 0xe0)
488
			logger.trace("lastSentinnel[2] != 0xe0 , is: " + lastSentinnel[2]);
489
		if ((lastSentinnel[3] & 0xFF) != 0xdc)
490
			logger.trace("lastSentinnel[3] != 0xdc , is: " + lastSentinnel[3]);
491
		if ((lastSentinnel[4] & 0xFF) != 0x02)
492
			logger.trace("lastSentinnel[4] != 0x02 , is: " + lastSentinnel[4]);
493
		if ((lastSentinnel[5] & 0xFF) != 0x21)
494
			logger.trace("lastSentinnel[5] != 0x21 , is: " + lastSentinnel[5]);
495
		if ((lastSentinnel[6] & 0xFF) != 0xc7)
496
			logger.trace("lastSentinnel[6] != 0xc7 , is: " + lastSentinnel[6]);
497
		if ((lastSentinnel[7] & 0xFF) != 0x56)
498
			logger.trace("lastSentinnel[7] != 0x56 , is: " + lastSentinnel[7]);
499
		if ((lastSentinnel[8] & 0xFF) != 0xa0)
500
			logger.trace("lastSentinnel[8] != 0xa0 , is: " + lastSentinnel[8]);
501
		if ((lastSentinnel[9] & 0xFF) != 0x83)
502
			logger.trace("lastSentinnel[9] != 0x83 , is: " + lastSentinnel[9]);
503
		if ((lastSentinnel[10] & 0xFF) != 0x97)
504
			logger.trace("lastSentinnel[10] != 0x97 , is: " + lastSentinnel[10]);
505
		if ((lastSentinnel[11] & 0xFF) != 0x47)
506
			logger.trace("lastSentinnel[11] != 0x47 , is: " + lastSentinnel[11]);
507
		if ((lastSentinnel[12] & 0xFF) != 0xb1)
508
			logger.trace("lastSentinnel[12] != 0xb1 , is: " + lastSentinnel[12]);
509
		if ((lastSentinnel[13] & 0xFF) != 0x92)
510
			logger.trace("lastSentinnel[13] != 0x92 , is: " + lastSentinnel[13]);
511
		if ((lastSentinnel[14] & 0xFF) != 0xcc)
512
			logger.trace("lastSentinnel[14] != 0xcc , is: " + lastSentinnel[14]);
513
		if ((lastSentinnel[15] & 0xFF) != 0xa0)
514
			logger.trace("lastSentinnel[15] != 0xa0 , is: " + lastSentinnel[15]);
515

  
516
		int bitPos = 0;
517
		try {
518

  
519
			List val = DwgUtil.getBitDouble(intData, bitPos); // Unknown
520
			bitPos = ((Integer) val.get(0)).intValue();
521
			dwgFile.setHeader("VAL1", val.get(1));
522

  
523
			val = DwgUtil.getBitDouble(intData, bitPos); // Unknown
524
			bitPos = ((Integer) val.get(0)).intValue();
525
			dwgFile.setHeader("VAL2", val.get(1));
526

  
527
			val = DwgUtil.getBitDouble(intData, bitPos); // Unknown
528
			bitPos = ((Integer) val.get(0)).intValue();
529
			dwgFile.setHeader("VAL3", val.get(1));
530

  
531
			val = DwgUtil.getBitDouble(intData, bitPos); // Unknown
532
			bitPos = ((Integer) val.get(0)).intValue();
533
			dwgFile.setHeader("VAL4", val.get(1));
534

  
535
			val = DwgUtil.getTextString(intData, bitPos); // Unknown
536
			bitPos = ((Integer) val.get(0)).intValue();
537
			dwgFile.setHeader("STRING1", val.get(1));
538

  
539
			val = DwgUtil.getTextString(intData, bitPos); // Unknown
540
			bitPos = ((Integer) val.get(0)).intValue();
541
			dwgFile.setHeader("STRING2", val.get(1));
542

  
543
			val = DwgUtil.getTextString(intData, bitPos); // Unknown
544
			bitPos = ((Integer) val.get(0)).intValue();
545
			dwgFile.setHeader("STRING3", val.get(1));
546

  
547
			val = DwgUtil.getTextString(intData, bitPos); // Unknown
548
			bitPos = ((Integer) val.get(0)).intValue();
549
			dwgFile.setHeader("STRING4", val.get(1));
550

  
551
			val = DwgUtil.getBitLong(intData, bitPos); // Unknown
552
			bitPos = ((Integer) val.get(0)).intValue();
553
			dwgFile.setHeader("LONG1", val.get(1));
554

  
555
			val = DwgUtil.getBitLong(intData, bitPos); // Unknown
556
			bitPos = ((Integer) val.get(0)).intValue();
557
			dwgFile.setHeader("LONG2", val.get(1));
558

  
559
			val = DwgUtil.testBit(intData, bitPos);
560
			bitPos = ((Integer) val.get(0)).intValue();
561
			dwgFile.setHeader("DIMASO", val.get(1));
562

  
563
			val = DwgUtil.testBit(intData, bitPos);
564
			bitPos = ((Integer) val.get(0)).intValue();
565
			dwgFile.setHeader("DIMSHO", val.get(1));
566

  
567
			val = DwgUtil.testBit(intData, bitPos);
568
			bitPos = ((Integer) val.get(0)).intValue();
569
			dwgFile.setHeader("PLINEGEN", val.get(1));
570

  
571
			val = DwgUtil.testBit(intData, bitPos);
572
			bitPos = ((Integer) val.get(0)).intValue();
573
			dwgFile.setHeader("ORTHOMODE", val.get(1));
574

  
575
			val = DwgUtil.testBit(intData, bitPos);
576
			bitPos = ((Integer) val.get(0)).intValue();
577
			dwgFile.setHeader("REGENMODE", val.get(1));
578

  
579
			val = DwgUtil.testBit(intData, bitPos);
580
			bitPos = ((Integer) val.get(0)).intValue();
581
			dwgFile.setHeader("FILLMODE", val.get(1));
582

  
583
			val = DwgUtil.testBit(intData, bitPos);
584
			bitPos = ((Integer) val.get(0)).intValue();
585
			dwgFile.setHeader("QTEXTMODE", val.get(1));
586

  
587
			val = DwgUtil.testBit(intData, bitPos);
588
			bitPos = ((Integer) val.get(0)).intValue();
589
			dwgFile.setHeader("PSLTSCALE", val.get(1));
590

  
591
			val = DwgUtil.testBit(intData, bitPos);
592
			bitPos = ((Integer) val.get(0)).intValue();
593
			dwgFile.setHeader("LIMCHECK", val.get(1));
594

  
595
			val = DwgUtil.testBit(intData, bitPos);
596
			bitPos = ((Integer) val.get(0)).intValue();
597
			dwgFile.setHeader("UNDOCUMENTED1", val.get(1));
598

  
599
			val = DwgUtil.testBit(intData, bitPos);
600
			bitPos = ((Integer) val.get(0)).intValue();
601
			dwgFile.setHeader("USER_TIMER", val.get(1));
602

  
603
			val = DwgUtil.testBit(intData, bitPos);
604
			bitPos = ((Integer) val.get(0)).intValue();
605
			dwgFile.setHeader("SKPOLY", val.get(1));
606

  
607
			val = DwgUtil.testBit(intData, bitPos);
608
			bitPos = ((Integer) val.get(0)).intValue();
609
			dwgFile.setHeader("ANGDIR", val.get(1));
610

  
611
			val = DwgUtil.testBit(intData, bitPos);
612
			bitPos = ((Integer) val.get(0)).intValue();
613
			dwgFile.setHeader("SPLFRAME", val.get(1));
614

  
615
			val = DwgUtil.testBit(intData, bitPos);
616
			bitPos = ((Integer) val.get(0)).intValue();
617
			dwgFile.setHeader("MIRRTEXT", val.get(1));
618

  
619
			val = DwgUtil.testBit(intData, bitPos);
620
			bitPos = ((Integer) val.get(0)).intValue();
621
			dwgFile.setHeader("WORLDVIEW", val.get(1));
622

  
623
			val = DwgUtil.testBit(intData, bitPos);
624
			bitPos = ((Integer) val.get(0)).intValue();
625
			dwgFile.setHeader("TILEMODE", val.get(1));
626

  
627
			val = DwgUtil.testBit(intData, bitPos);
628
			bitPos = ((Integer) val.get(0)).intValue();
629
			dwgFile.setHeader("PLIMCHECK", val.get(1));
630

  
631
			val = DwgUtil.testBit(intData, bitPos);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff