Revision 1011

View differences:

tags/org.gvsig.dwg-2.0.212/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.212</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.212/org.gvsig.dwg.app/org.gvsig.dwg.app.mainplugin/buildNumber.properties
1
#Mon Jul 18 19:43:29 CEST 2022
2
buildNumber=2281
tags/org.gvsig.dwg-2.0.212/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.212/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.212/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.212/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.212/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.212/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.212</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.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgAttribReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.awt.geom.Point2D;
8
import java.util.ArrayList;
9

  
10
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
11
import org.gvsig.dwg.lib.DwgHandleReference;
12
import org.gvsig.dwg.lib.DwgObject;
13
import org.gvsig.dwg.lib.DwgUtil;
14
import org.gvsig.dwg.lib.objects.DwgArc;
15
import org.gvsig.dwg.lib.objects.DwgAttrib;
16
import org.gvsig.dwg.lib.readers.IDwgFileReader;
17
import org.gvsig.dwg.lib.readers.IDwgObjectReader;
18

  
19

  
20
/**
21
 * @author alzabord
22
 * 
23
 * TODO To change the template for this generated type comment go to Window -
24
 * Preferences - Java - Code Style - Code Templates
25
 */
26
public class DwgAttribReader15 extends AbstractDwg15Reader {
27

  
28
	/*
29
	 * (non-Javadoc)
30
	 * 
31
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[],
32
	 *      int, com.iver.cit.jdwglib.dwg.DwgObject)
33
	 */
34
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
35

  
36
		if (!(dwgObj instanceof DwgAttrib))
37
			throw new RuntimeException("ArcReader 15 solo puede leer DwgAttrib");
38
		DwgAttrib att = (DwgAttrib) dwgObj;
39

  
40
		int bitPos = offset;
41
		bitPos = headTailReader.readObjectHeader(data, bitPos, att);
42
		ArrayList v = DwgUtil.getRawChar(data, bitPos);
43
		bitPos = ((Integer) v.get(0)).intValue();
44
		int dflag = ((Integer) v.get(1)).intValue();
45
		att.setDataFlag(dflag);
46
		if ((dflag & 0x1) == 0) {
47
			v = DwgUtil.getRawDouble(data, bitPos);
48
			bitPos = ((Integer) v.get(0)).intValue();
49
			double elev = ((Double) v.get(1)).doubleValue();
50
			att.setElevation(elev);
51
		}
52
		v = DwgUtil.getRawDouble(data, bitPos);
53
		bitPos = ((Integer) v.get(0)).intValue();
54
		double x1 = ((Double) v.get(1)).doubleValue();
55
		v = DwgUtil.getRawDouble(data, bitPos);
56
		bitPos = ((Integer) v.get(0)).intValue();
57
		double y1 = ((Double) v.get(1)).doubleValue();
58
		att.setInsertionPoint(new Point2D.Double(x1, y1));
59
		double x = 0, y = 0, z = 0;
60
		if ((dflag & 0x2) == 0) {
61
			v = DwgUtil.getDefaultDouble(data, bitPos, x1);
62
			bitPos = ((Integer) v.get(0)).intValue();
63
			x = ((Double) v.get(1)).doubleValue();
64
			v = DwgUtil.getDefaultDouble(data, bitPos, y1);
65
			bitPos = ((Integer) v.get(0)).intValue();
66
			y = ((Double) v.get(1)).doubleValue();
67
		}
68
		att.setAlignmentPoint(new Point2D.Double(x, y));
69
		v = DwgUtil.testBit(data, bitPos);
70
		bitPos = ((Integer) v.get(0)).intValue();
71
		boolean flag = ((Boolean) v.get(1)).booleanValue();
72
		if (flag) {
73
			y = 0.0;
74
			x = y;
75
			z = 1.0;
76
		} else {
77
			v = DwgUtil.getBitDouble(data, bitPos);
78
			bitPos = ((Integer) v.get(0)).intValue();
79
			x = ((Double) v.get(1)).doubleValue();
80
			v = DwgUtil.getBitDouble(data, bitPos);
81
			bitPos = ((Integer) v.get(0)).intValue();
82
			y = ((Double) v.get(1)).doubleValue();
83
			v = DwgUtil.getBitDouble(data, bitPos);
84
			bitPos = ((Integer) v.get(0)).intValue();
85
			z = ((Double) v.get(1)).doubleValue();
86
		}
87
		att.setExtrusion(new double[] { x, y, z });
88
		v = DwgUtil.testBit(data, bitPos);
89
		bitPos = ((Integer) v.get(0)).intValue();
90
		flag = ((Boolean) v.get(1)).booleanValue();
91
		double th;
92
		if (flag) {
93
			th = 0.0;
94
		} else {
95
			v = DwgUtil.getBitDouble(data, bitPos);
96
			bitPos = ((Integer) v.get(0)).intValue();
97
			th = ((Double) v.get(1)).doubleValue();
98
		}
99
		att.setThickness(th);
100
		if ((dflag & 0x4) == 0) {
101
			v = DwgUtil.getRawDouble(data, bitPos);
102
			bitPos = ((Integer) v.get(0)).intValue();
103
			double oblique = ((Double) v.get(1)).doubleValue();
104
			att.setObliqueAngle(oblique);
105
		}
106
		if ((dflag & 0x8) == 0) {
107
			v = DwgUtil.getRawDouble(data, bitPos);
108
			bitPos = ((Integer) v.get(0)).intValue();
109
			double rot = ((Double) v.get(1)).doubleValue();
110
			att.setRotationAngle(rot);
111
		}
112
		v = DwgUtil.getRawDouble(data, bitPos);
113
		bitPos = ((Integer) v.get(0)).intValue();
114
		double height = ((Double) v.get(1)).doubleValue();
115
		att.setHeight(height);
116
		if ((dflag & 0x10) == 0) {
117
			v = DwgUtil.getRawDouble(data, bitPos);
118
			bitPos = ((Integer) v.get(0)).intValue();
119
			double width = ((Double) v.get(1)).doubleValue();
120
			att.setWidthFactor(width);
121
		}
122
		v = DwgUtil.getTextString(data, bitPos);
123
		bitPos = ((Integer) v.get(0)).intValue();
124
		String text = (String) v.get(1);
125
		att.setText(text);
126
		if ((dflag & 0x20) == 0) {
127
			v = DwgUtil.getBitShort(data, bitPos);
128
			bitPos = ((Integer) v.get(0)).intValue();
129
			int gen = ((Integer) v.get(1)).intValue();
130
			att.setGeneration(gen);
131
		}
132
		if ((dflag & 0x40) == 0) {
133
			v = DwgUtil.getBitShort(data, bitPos);
134
			bitPos = ((Integer) v.get(0)).intValue();
135
			int halign = ((Integer) v.get(1)).intValue();
136
			att.setHalign(halign);
137
		}
138
		if ((dflag & 0x80) == 0) {
139
			v = DwgUtil.getBitShort(data, bitPos);
140
			bitPos = ((Integer) v.get(0)).intValue();
141
			int valign = ((Integer) v.get(1)).intValue();
142
			att.setValign(valign);
143
		}
144
		v = DwgUtil.getTextString(data, bitPos);
145
		bitPos = ((Integer) v.get(0)).intValue();
146
		String tag = (String) v.get(1);
147
		att.setTag(tag);
148
		v = DwgUtil.getBitShort(data, bitPos);
149
		bitPos = ((Integer) v.get(0)).intValue();
150
		int fl = ((Integer) v.get(1)).intValue();
151
		att.setFieldLength(fl);
152
		v = DwgUtil.getRawChar(data, bitPos);
153
		bitPos = ((Integer) v.get(0)).intValue();
154
		int flags = ((Integer) v.get(1)).intValue();
155
		att.setFlags(flags);
156
		bitPos = headTailReader.readObjectTailer(data, bitPos, att);
157
		DwgHandleReference styleHandle = new DwgHandleReference();
158
		bitPos = styleHandle.read(data, bitPos);
159
		att.setStyleHandle(styleHandle);
160
	}
161
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgPointReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgPoint;
13

  
14

  
15
/**
16
 * @author alzabord
17
 *
18
 * TODO To change the template for this generated type comment go to
19
 * Window - Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgPointReader15 extends AbstractDwg15Reader{
22

  
23
	/* (non-Javadoc)
24
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
25
	 */
26
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
27
		if(! (dwgObj instanceof DwgPoint))
28
			throw new RuntimeException("ArcReader 15 solo puede leer DwgPoint");
29
		DwgPoint pt = (DwgPoint) dwgObj;
30
		int bitPos = offset;
31
		bitPos = headTailReader.readObjectHeader(data, bitPos, pt);
32
		ArrayList v = DwgUtil.getBitDouble(data, bitPos);
33
		bitPos = ((Integer)v.get(0)).intValue();
34
		double x = ((Double)v.get(1)).doubleValue();
35
		v = DwgUtil.getBitDouble(data, bitPos);
36
		bitPos = ((Integer)v.get(0)).intValue();
37
		double y = ((Double)v.get(1)).doubleValue();
38
		v = DwgUtil.getBitDouble(data, bitPos);
39
		bitPos = ((Integer)v.get(0)).intValue();
40
		double z = ((Double)v.get(1)).doubleValue();
41
		double[] coord = new double[]{x, y, z};
42
		pt.setPoint(coord);
43
		v = DwgUtil.testBit(data, bitPos);
44
		bitPos = ((Integer)v.get(0)).intValue();
45
		boolean flag = ((Boolean)v.get(1)).booleanValue();
46
	    double val;
47
		if (flag) {
48
			val=0.0;
49
		} else {
50
			v = DwgUtil.getBitDouble(data, bitPos);
51
			bitPos = ((Integer)v.get(0)).intValue();
52
			val = ((Double)v.get(1)).doubleValue();
53
		}
54
		pt.setThickness(val);
55
		v = DwgUtil.testBit(data, bitPos);
56
		bitPos = ((Integer)v.get(0)).intValue();
57
		flag = ((Boolean)v.get(1)).booleanValue();
58
		if (flag) {
59
			 x = y = 0.0;
60
			 z = 1.0;
61
		} else {
62
			v = DwgUtil.getBitDouble(data, bitPos);
63
			bitPos = ((Integer)v.get(0)).intValue();
64
			x = ((Double)v.get(1)).doubleValue();
65
			v = DwgUtil.getBitDouble(data, bitPos);
66
			bitPos = ((Integer)v.get(0)).intValue();
67
			y = ((Double)v.get(1)).doubleValue();
68
			v = DwgUtil.getBitDouble(data, bitPos);
69
			bitPos = ((Integer)v.get(0)).intValue();
70
			z = ((Double)v.get(1)).doubleValue();
71
		}
72
		coord = new double[]{x, y, z};
73
		pt.setExtrusion(coord);
74
		v = DwgUtil.getBitDouble(data, bitPos);
75
		bitPos = ((Integer)v.get(0)).intValue();
76
		val = ((Double)v.get(1)).doubleValue();
77
		pt.setXAxisAngle(val);
78
		bitPos = headTailReader.readObjectTailer(data, bitPos, pt);
79
	}
80
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgSplineReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgSpline;
13

  
14

  
15
/**
16
 * @author alzabord
17
 *
18
 * TODO To change the template for this generated type comment go to
19
 * Window - Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgSplineReader15 extends AbstractDwg15Reader{
22

  
23
	/* (non-Javadoc)
24
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
25
	 */
26
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
27
		if(! (dwgObj instanceof DwgSpline))
28
			throw new RuntimeException("ArcReader 15 solo puede leer DwgSpline");
29
		DwgSpline spline = (DwgSpline) dwgObj;
30
		int bitPos = offset;
31
		bitPos = headTailReader.readObjectHeader(data, bitPos, spline);
32
		ArrayList v = DwgUtil.getBitShort(data, bitPos);
33
		bitPos = ((Integer)v.get(0)).intValue();
34
		int sc = ((Integer)v.get(1)).intValue();
35
		spline.setScenario(sc);
36
		v = DwgUtil.getBitShort(data, bitPos);
37
		bitPos = ((Integer)v.get(0)).intValue();
38
		int deg = ((Integer)v.get(1)).intValue();
39
		spline.setDegree(deg);
40
		int knotsNumber = 0;
41
		int controlPointsNumber = 0;
42
		int fitPointsNumber = 0;
43
		boolean weight = false;
44
		if (sc==2) {
45
			v = DwgUtil.getBitDouble(data, bitPos);
46
			bitPos = ((Integer)v.get(0)).intValue();
47
			double ft = ((Double)v.get(1)).doubleValue();
48
			spline.setFitTolerance(ft);
49
			v = DwgUtil.getBitDouble(data, bitPos);
50
			bitPos = ((Integer)v.get(0)).intValue();
51
			double x = ((Double)v.get(1)).doubleValue();
52
			v = DwgUtil.getBitDouble(data, bitPos);
53
			bitPos = ((Integer)v.get(0)).intValue();
54
			double y = ((Double)v.get(1)).doubleValue();
55
			v = DwgUtil.getBitDouble(data, bitPos);
56
			bitPos = ((Integer)v.get(0)).intValue();
57
			double z = ((Double)v.get(1)).doubleValue();
58
			double[] coord = new double[]{x, y, z};
59
			spline.setBeginTanVector(coord);
60
			v = DwgUtil.getBitDouble(data, bitPos);
61
			bitPos = ((Integer)v.get(0)).intValue();
62
			x = ((Double)v.get(1)).doubleValue();
63
			v = DwgUtil.getBitDouble(data, bitPos);
64
			bitPos = ((Integer)v.get(0)).intValue();
65
			y = ((Double)v.get(1)).doubleValue();
66
			v = DwgUtil.getBitDouble(data, bitPos);
67
			bitPos = ((Integer)v.get(0)).intValue();
68
			z = ((Double)v.get(1)).doubleValue();
69
			coord = new double[]{x, y, z};
70
			spline.setEndTanVector(coord);
71
			v = DwgUtil.getBitShort(data, bitPos);
72
			bitPos = ((Integer)v.get(0)).intValue();
73
			fitPointsNumber = ((Integer)v.get(1)).intValue();
74
		} else if (sc==1) {
75
			v = DwgUtil.testBit(data, bitPos);
76
			bitPos = ((Integer)v.get(0)).intValue();
77
			boolean rat = ((Boolean)v.get(1)).booleanValue();
78
			spline.setRational(rat);
79
			v = DwgUtil.testBit(data, bitPos);
80
			bitPos = ((Integer)v.get(0)).intValue();
81
			boolean closed = ((Boolean)v.get(1)).booleanValue();
82
			spline.setClosed(closed);
83
			v = DwgUtil.testBit(data, bitPos);
84
			bitPos = ((Integer)v.get(0)).intValue();
85
			boolean per = ((Boolean)v.get(1)).booleanValue();
86
			spline.setPeriodic(per);
87
			v = DwgUtil.getBitDouble(data, bitPos);
88
			bitPos = ((Integer)v.get(0)).intValue();
89
			double ktol = ((Double)v.get(1)).doubleValue();
90
			spline.setKnotTolerance(ktol);
91
			v = DwgUtil.getBitDouble(data, bitPos);
92
			bitPos = ((Integer)v.get(0)).intValue();
93
			double ctol = ((Double)v.get(1)).doubleValue();
94
			spline.setControlTolerance(ctol);
95
			v = DwgUtil.getBitLong(data, bitPos);
96
			bitPos = ((Integer)v.get(0)).intValue();
97
			knotsNumber = ((Integer)v.get(1)).intValue();
98
			v = DwgUtil.getBitLong(data, bitPos);
99
			bitPos = ((Integer)v.get(0)).intValue();
100
			controlPointsNumber = ((Integer)v.get(1)).intValue();
101
			v = DwgUtil.testBit(data, bitPos);
102
			bitPos = ((Integer)v.get(0)).intValue();
103
			weight = ((Boolean)v.get(1)).booleanValue();
104
		} else {
105
			System.out.println("ERROR: Escenario desconocido");
106
		}
107
		if (knotsNumber>0) {
108
			double[] knotpts = new double[knotsNumber];
109
			for (int i=0;i<knotsNumber;i++) {
110
				v = DwgUtil.getBitDouble(data, bitPos);
111
				bitPos = ((Integer)v.get(0)).intValue();
112
				knotpts[i] = ((Double)v.get(1)).doubleValue();
113
			}
114
			spline.setKnotPoints(knotpts);
115
		}
116
		if (controlPointsNumber>0) {
117
			// Si el n?mero de weights no coincide con el de ctrlpts habr? problemas ...
118
			double[][] ctrlpts = new double[controlPointsNumber][3];
119
			double[] weights = new double[controlPointsNumber];
120
			for (int i=0;i<controlPointsNumber;i++) {
121
				v = DwgUtil.getBitDouble(data, bitPos);
122
				bitPos = ((Integer)v.get(0)).intValue();
123
				double x = ((Double)v.get(1)).doubleValue();
124
				v = DwgUtil.getBitDouble(data, bitPos);
125
				bitPos = ((Integer)v.get(0)).intValue();
126
				double y = ((Double)v.get(1)).doubleValue();
127
				v = DwgUtil.getBitDouble(data, bitPos);
128
				bitPos = ((Integer)v.get(0)).intValue();
129
				double z = ((Double)v.get(1)).doubleValue();
130
				//double[] coord = new double[]{x, y, z};
131
				ctrlpts[i][0] = x;
132
				ctrlpts[i][1] = y;
133
				ctrlpts[i][2] = z;
134
				if (weight) {
135
					v = DwgUtil.getBitDouble(data, bitPos);
136
					bitPos = ((Integer)v.get(0)).intValue();
137
					weights[i] = ((Double)v.get(1)).doubleValue();
138
				}
139
			}
140
			spline.setControlPoints(ctrlpts);
141
			if (weight) {
142
				spline.setWeights(weights);
143
			}
144
		}
145
		if (fitPointsNumber>0) {
146
			double[][] fitpts = new double[fitPointsNumber][3];
147
			for (int i=0;i<fitPointsNumber;i++) {
148
				v = DwgUtil.getBitDouble(data, bitPos);
149
				bitPos = ((Integer)v.get(0)).intValue();
150
				double x = ((Double)v.get(1)).doubleValue();
151
				v = DwgUtil.getBitDouble(data, bitPos);
152
				bitPos = ((Integer)v.get(0)).intValue();
153
				double y = ((Double)v.get(1)).doubleValue();
154
				v = DwgUtil.getBitDouble(data, bitPos);
155
				bitPos = ((Integer)v.get(0)).intValue();
156
				double z = ((Double)v.get(1)).doubleValue();
157
				fitpts[i][0] = x;
158
				fitpts[i][1] = y;
159
				fitpts[i][2] = z;
160
			}
161
			spline.setFitPoints(fitpts);
162
		}
163
		bitPos = headTailReader.readObjectTailer(data, bitPos, spline);
164
	}
165

  
166

  
167
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgBlockReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgBlock;
13

  
14

  
15
/**
16
 * @author alzabord
17
 * 
18
 * TODO To change the template for this generated type comment go to Window -
19
 * Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgBlockReader15 extends AbstractDwg15Reader{
22

  
23
	/*
24
	 * (non-Javadoc)
25
	 * 
26
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[],
27
	 *      int, com.iver.cit.jdwglib.dwg.DwgObject)
28
	 */
29
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException{
30
			if(! (dwgObj instanceof DwgBlock))
31
				throw new RuntimeException("DwgBlockReader15 solo puede leer DwgBlock");
32
			DwgBlock blk = (DwgBlock) dwgObj;
33
			int bitPos = offset;
34
			bitPos = headTailReader.readObjectHeader(data, bitPos, dwgObj);
35
			ArrayList v = DwgUtil.getTextString(data, bitPos);
36
			bitPos = ((Integer)v.get(0)).intValue();
37
			String text = (String)v.get(1);
38
			blk.setName(text);
39
			bitPos = headTailReader.readObjectTailer(data, bitPos, dwgObj);
40
	}
41
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgMeshReader15.java
1
/*
2
 * Created on 19-mar-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: DwgMeshReader15.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.1.2.1  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.1  2007/03/20 19:57:08  azabala
52
* source code cleaning
53
*
54
*
55
*/
56
package org.gvsig.dwg.lib.readers.v15;
57

  
58
import java.util.List;
59

  
60
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
61
import org.gvsig.dwg.lib.DwgHandleReference;
62
import org.gvsig.dwg.lib.DwgObject;
63
import org.gvsig.dwg.lib.DwgUtil;
64
import org.gvsig.dwg.lib.objects.DwgMeshPolyline;
65

  
66

  
67
public class DwgMeshReader15 extends AbstractDwg15Reader {
68

  
69
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
70
			throws RuntimeException, CorruptedDwgEntityException {
71
		if(! (dwgObj instanceof DwgMeshPolyline))
72
	    	throw new RuntimeException("ArcReader 15 solo puede leer DwgMeshPolyline");
73
		DwgMeshPolyline m = (DwgMeshPolyline) dwgObj;
74
		int bitPos = offset;
75
		bitPos = headTailReader.readObjectHeader(data, bitPos, m);
76
		
77
		List val = DwgUtil.getBitShort(data, bitPos);
78
		bitPos = ((Integer) val.get(0)).intValue();
79
		int flags = ((Integer) val.get(1)).intValue();
80
		m.setFlags(flags);
81
		
82
		val = DwgUtil.getBitShort(data, bitPos);
83
		bitPos = ((Integer) val.get(0)).intValue();
84
		int curveType = ((Integer) val.get(1)).intValue();
85
		m.setCurveType(curveType);
86
		
87
		val = DwgUtil.getBitShort(data, bitPos);
88
		bitPos = ((Integer) val.get(0)).intValue();
89
		int mVerticies = ((Integer) val.get(1)).intValue();
90
		m.setMVerticies(mVerticies);
91
		
92
		val = DwgUtil.getBitShort(data, bitPos);
93
		bitPos = ((Integer) val.get(0)).intValue();
94
		int nVerticies = ((Integer) val.get(1)).intValue();
95
		m.setNVerticies(nVerticies);
96
		
97
		val = DwgUtil.getBitShort(data, bitPos);
98
		bitPos = ((Integer) val.get(0)).intValue();
99
		int mDensity = ((Integer) val.get(1)).intValue();
100
		m.setMDensity(mDensity);
101
		
102
		val = DwgUtil.getBitShort(data, bitPos);
103
		bitPos = ((Integer) val.get(0)).intValue();
104
		int nDensity = ((Integer) val.get(1)).intValue();
105
		m.setNDensity(nDensity);
106
		
107
		bitPos = headTailReader.readObjectTailer(data, bitPos, m);
108
		
109
		DwgHandleReference handle = new DwgHandleReference();
110
		bitPos = handle.read(data, bitPos);
111
		m.setFirstVertexHandle(handle);
112
		
113
		handle = new DwgHandleReference();
114
		bitPos = handle.read(data, bitPos);
115
		m.setLastVertexHandle(handle);
116
		
117
		handle = new DwgHandleReference();
118
		bitPos = handle.read(data, bitPos);
119
		m.setSeqendHandle(handle);
120
	}
121

  
122
}
123

  
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgLwPolylineReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.awt.geom.Point2D;
8
import java.util.ArrayList;
9
import java.util.List;
10

  
11
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
12
import org.gvsig.dwg.lib.DwgObject;
13
import org.gvsig.dwg.lib.DwgUtil;
14
import org.gvsig.dwg.lib.objects.DwgLwPolyline;
15

  
16

  
17
/**
18
 * @author alzabord
19
 * 
20
 * TODO To change the template for this generated type comment go to Window -
21
 * Preferences - Java - Code Style - Code Templates
22
 */
23
public class DwgLwPolylineReader15 extends AbstractDwg15Reader {
24

  
25
	/*
26
	 *TODO El metodo original de J.Morell daba excepciones (que eran
27
	 *ocultadas con un catch(Exception){}...BUF!
28
	 *
29
	 * Este metodo trata de copiar literalmente el de Python, para ver
30
	 * si somos capaces de resolver el bug.
31
	 * 
32
	 * */
33
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
34
		
35
			if (!(dwgObj instanceof DwgLwPolyline))
36
				throw new RuntimeException(
37
						"ArcReader 15 solo puede leer DwgLwPolyLine");
38
			DwgLwPolyline line = (DwgLwPolyline) dwgObj;
39
			List val = null;
40
			int bitPos = offset;
41
			bitPos = headTailReader.readObjectHeader(data, bitPos, dwgObj);
42
			val = DwgUtil.getBitShort(data, bitPos);
43
			bitPos = ((Integer) val.get(0)).intValue();
44
			int flag = ((Integer) val.get(1)).intValue();
45
			line.setFlag(flag);
46
			
47
			/*
48
			 * Flag son 4 bits que indican si la lwpline tiene ancho,
49
			 * (3er bit), elevacion (4o bit), grosor (2? bit) y vector
50
			 * de extrusion (1er bit).
51
			 * 5? bit -> n? de bulges
52
			 * 60 bit -> n? de widths
53
			 * 
54
			 * ahora se verifican y se van leyendo
55
			 * */
56
			
57
			
58
			double constWidth = 0d;
59
		    if( (flag & 0x4) > 0){
60
		    	val = DwgUtil.getBitDouble(data, bitPos);
61
				bitPos = ((Integer) val.get(0)).intValue();
62
				constWidth = ((Double) val.get(1)).doubleValue();
63
		    }//if
64
		    line.setConstWidth(constWidth);
65
		    
66
		    double elev = 0d;
67
		    if ( (flag & 0x8) > 0){
68
		    	val = DwgUtil.getBitDouble(data, bitPos);
69
		    	bitPos = ((Integer) val.get(0)).intValue();
70
		    	elev = ((Double) val.get(1)).doubleValue();
71
		    }
72
		    line.setElevation(elev);
73
		    
74
		    double thickness = 0d;
75
		    if ( (flag & 0x2) > 0){
76
		    	val = DwgUtil.getBitDouble(data, bitPos);
77
		    	bitPos = ((Integer) val.get(0)).intValue();
78
		    	thickness = ((Double) val.get(1)).doubleValue();
79
		    }
80
		    line.setThickness(thickness);
81
		    
82
		    double nx = 0d; 
83
		    double ny = 0d;
84
		    double nz = 0d;
85
		    if( (flag & 0x1) > 0){
86
		    	val = DwgUtil.getBitDouble(data, bitPos);
87
		    	bitPos = ((Integer) val.get(0)).intValue();
88
		    	nx = ((Double) val.get(1)).doubleValue();
89
		    	
90
		    	val = DwgUtil.getBitDouble(data, bitPos);
91
		    	bitPos = ((Integer) val.get(0)).intValue();
92
		    	ny = ((Double) val.get(1)).doubleValue();
93
		    	
94
		    	val = DwgUtil.getBitDouble(data, bitPos);
95
		    	bitPos = ((Integer) val.get(0)).intValue();
96
		    	nz = ((Double) val.get(1)).doubleValue();
97
		    }
98
		    line.setNormal(new double[]{nx, ny, nz});
99
		  
100
		    val = DwgUtil.getBitLong(data, bitPos);
101
		    bitPos = ((Integer) val.get(0)).intValue();
102
		    int numberOfPoints = ((Integer) val.get(1)).intValue();
103
		    
104
		    int numberOfBulges = 0;
105
		    if ((flag & 0x10) > 0){
106
		    	val = DwgUtil.getBitLong(data, bitPos);
107
		 	    bitPos = ((Integer) val.get(0)).intValue();
108
		 	    numberOfBulges = ((Integer) val.get(1)).intValue();
109
		    }
110
		    
111
		    int numberOfWidths = 0;
112
		    if ((flag & 0x20) > 0){
113
		    	val = DwgUtil.getBitLong(data, bitPos);
114
		 	    bitPos = ((Integer) val.get(0)).intValue();
115
		 	    numberOfWidths = ((Integer) val.get(1)).intValue();
116
		    }
117
		    
118
		    if(numberOfPoints > 0){
119
		    	//Esto es una chapuza, pero las LwPolylines no se est?n
120
		    	//leyendo bien y en ocasiones nos llegan entidades
121
		    	//con MILLONES de puntos (OutOfMemoryException)
122
		    	//Plantear en la lista de PythonCAD
123
		    	if(numberOfPoints > 10000)
124
		    		throw new CorruptedDwgEntityException("LwPolyline corrupta");
125
		    	List vertices = new ArrayList();
126
		  	    val = DwgUtil.getRawDouble(data, bitPos);
127
		  	    bitPos = ((Integer) val.get(0)).intValue();
128
		  		double x0 = ((Double) val.get(1)).doubleValue();
129
		  		
130
		  		val = DwgUtil.getRawDouble(data, bitPos);
131
		  		bitPos = ((Integer) val.get(0)).intValue();
132
		  		double y0 = ((Double) val.get(1)).doubleValue();
133
		  		
134
		  		vertices.add(new double[]{x0, y0});
135
		  		
136
		  		
137
		  		/*
138
		  		 * TODO azabala 
139
		  		 * Algunos metodos de DwgUtil lanzan excepciones inexperadas
140
		  		 * cuando trabajan para rellenar clases de LwPolyline:
141
		  		 * ->getDefaultDouble
142
		  		 * ->getBits
143
		  		 * etc
144
		  		 * 
145
		  		 * Estas excepciones son del tipo OutOfBounds (se intenta leer un bit
146
		  		 * cuyo orden excede de la capacidad del array)
147
		  		 * La especificaci?n 15 de DWG es seguida al pie de la letra por Pythoncad,
148
		  		 * (y por nosotros) as? que puede ser que el problema est? en los metodos
149
		  		 * de DwgUtil.
150
		  		 * 
151
		  		 * Intentar capturar la excepcion para que no se pierdan las entidades que las
152
		  		 * provocan, y luego solucionar el error
153
		  		 * 
154
		  		 * 
155
		  		 * */
156
		  		for (int i = 1; i < numberOfPoints; i++) {
157
		  			val = DwgUtil.getDefaultDouble(data, bitPos, x0);
158
		  			bitPos = ((Integer) val.get(0)).intValue();
159
		  			double x = ((Double) val.get(1)).doubleValue();
160
		  			
161
		  			val = DwgUtil.getDefaultDouble(data, bitPos, y0);
162
		  			bitPos = ((Integer) val.get(0)).intValue();
163
		  			double y = ((Double) val.get(1)).doubleValue();
164
		  			
165
		  			vertices.add(new double[]{x, y});
166
		  			
167
		  			x0 = x;//se proporcionan como valores por defecto las coordenadas del pto anterior
168
		  			y0 = y;
169
		  		}
170
		  		line.setVertices(vertices);
171
		    }else{
172
		    	System.out.println("vertices == 0: lanzamos una excepcion??");
173
		    }
174
		    
175
		  
176
			
177
			if(numberOfBulges > 0){
178
				if (numberOfBulges != numberOfPoints){
179
			    	System.out.println("bulges != vertices: lanzamos una excepcion??");
180
			    }
181
				double[] bulges = new double[numberOfBulges];
182
				for(int i = 0; i < numberOfBulges; i++){
183
					//TODO OJOOOOOO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
184
					//En PythonCAD se hacia getRawDouble, pero en la especificacion
185
					//(pagina 136) dice que es BitDouble (BD) 
186
					val = DwgUtil.getBitDouble(data, bitPos);
187
					bitPos = ((Integer) val.get(0)).intValue();
188
					bulges[i] = ((Double) val.get(1)).doubleValue();
189
				}
190
				line.setBulges(bulges);
191
			}else{
192
				double[] bulges = new double[numberOfPoints];
193
				for(int i = 0; i < numberOfPoints; i++)
194
					bulges[i] = 0d;
195
				line.setBulges(bulges);
196
			}
197
			
198
			if(numberOfWidths > 0){
199
			    if (numberOfWidths != numberOfPoints){
200
			    	System.out.println("widths != vertices: lanzamos una excepcion??");
201
			    }
202
				double[][] widths = new double[numberOfWidths][2];
203
				for (int i = 0; i < numberOfWidths; i++) {
204
					val = DwgUtil.getBitDouble(data, bitPos);
205
					bitPos = ((Integer) val.get(0)).intValue();
206
					double sw = ((Double) val.get(1)).doubleValue();
207
					
208
					val = DwgUtil.getBitDouble(data, bitPos);
209
					bitPos = ((Integer) val.get(0)).intValue();
210
					double ew = ((Double) val.get(1)).doubleValue();
211
					widths[i][0] = sw;
212
					widths[i][1] = ew;
213
				}
214
				line.setWidths(widths);
215
			}else{
216
				line.setWidths(new double[0][0]);
217
			}
218
			
219
			
220
			
221
			/*
222
			 * azabala: de siempre se producen excepciones al tratar de leer
223
			 * LwPolyline (si no se veian es pq se capturaban y no se sacaba
224
			 * traza)
225
			 * 
226
			 * Se producen siempre que numVertices == 0 ????
227
			 * Probar a saltarmelos.
228
			 * 
229
			 * 
230
			 * 
231
			 * TODO Ver por qu? aparecen (y lo peor, pq una vez se da una se propagan 
232
			 * todas)
233
			 * 
234
			 * */
235
				bitPos = headTailReader.readObjectTailer(data, bitPos, line);
236
	}
237
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgCircleReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgObject;
11
import org.gvsig.dwg.lib.DwgUtil;
12
import org.gvsig.dwg.lib.objects.DwgCircle;
13

  
14

  
15
/**
16
 * @author alzabord
17
 *
18
 * TODO To change the template for this generated type comment go to
19
 * Window - Preferences - Java - Code Style - Code Templates
20
 */
21
public class DwgCircleReader15 extends AbstractDwg15Reader{
22

  
23
	/* (non-Javadoc)
24
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
25
	 */
26
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
27
		if(! (dwgObj instanceof DwgCircle))
28
			throw new RuntimeException("ArcReader 15 solo puede leer DwgCircle");
29
		DwgCircle circle = (DwgCircle) dwgObj;
30
		int bitPos = offset;
31
		bitPos = headTailReader.readObjectHeader(data, bitPos, dwgObj);
32
		ArrayList v = DwgUtil.getBitDouble(data, bitPos);
33
		bitPos = ((Integer)v.get(0)).intValue();
34
		double x = ((Double)v.get(1)).doubleValue();
35
		v = DwgUtil.getBitDouble(data, bitPos);
36
		bitPos = ((Integer)v.get(0)).intValue();
37
		double y = ((Double)v.get(1)).doubleValue();
38
		v = DwgUtil.getBitDouble(data, bitPos);
39
		bitPos = ((Integer)v.get(0)).intValue();
40
		double z = ((Double)v.get(1)).doubleValue();
41
		double[] coord = new double[]{x, y, z};
42
		circle.setCenter(coord);
43
		v = DwgUtil.getBitDouble(data, bitPos);
44
		bitPos = ((Integer)v.get(0)).intValue();
45
		double val = ((Double)v.get(1)).doubleValue();
46
		circle.setRadius(val);
47
		v = DwgUtil.testBit(data, bitPos);
48
		bitPos = ((Integer)v.get(0)).intValue();
49
		boolean flag = ((Boolean)v.get(1)).booleanValue();
50
	    if (flag) {
51
			val=0.0;
52
		} else {
53
			v = DwgUtil.getBitDouble(data, bitPos);
54
			bitPos = ((Integer)v.get(0)).intValue();
55
			val = ((Double)v.get(1)).doubleValue();
56
		}
57
	    circle.setThickness(val);
58
		v = DwgUtil.testBit(data, bitPos);
59
		bitPos = ((Integer)v.get(0)).intValue();
60
		flag = ((Boolean)v.get(1)).booleanValue();
61
		if (flag) {
62
			 x = y = 0.0;
63
			 z = 1.0;
64
		} else {
65
			v = DwgUtil.getBitDouble(data, bitPos);
66
			bitPos = ((Integer)v.get(0)).intValue();
67
			x = ((Double)v.get(1)).doubleValue();
68
			v = DwgUtil.getBitDouble(data, bitPos);
69
			bitPos = ((Integer)v.get(0)).intValue();
70
			y = ((Double)v.get(1)).doubleValue();
71
			v = DwgUtil.getBitDouble(data, bitPos);
72
			bitPos = ((Integer)v.get(0)).intValue();
73
			z = ((Double)v.get(1)).doubleValue();
74
		}
75
		coord = new double[]{x, y, z};
76
		circle.setExtrusion(coord);
77
		bitPos = headTailReader.readObjectTailer(data, bitPos, dwgObj);
78
	}
79
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgMTextReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
7
import java.util.ArrayList;
8

  
9
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
10
import org.gvsig.dwg.lib.DwgHandleReference;
11
import org.gvsig.dwg.lib.DwgObject;
12
import org.gvsig.dwg.lib.DwgUtil;
13
import org.gvsig.dwg.lib.objects.DwgMText;
14

  
15

  
16
/**
17
 * @author alzabord
18
 *
19
 * TODO To change the template for this generated type comment go to
20
 * Window - Preferences - Java - Code Style - Code Templates
21
 */
22
public class DwgMTextReader15 extends AbstractDwg15Reader{
23

  
24
	/* (non-Javadoc)
25
	 * @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
26
	 */
27
	public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException {
28
		if(! (dwgObj instanceof DwgMText))
29
			throw new RuntimeException("ArcReader 15 solo puede leer DwgMText");
30
		DwgMText txt = (DwgMText) dwgObj;
31
		int bitPos = offset;
32
		bitPos = headTailReader.readObjectHeader(data, bitPos, txt);
33
		ArrayList v = DwgUtil.getBitDouble(data, bitPos);
34
		bitPos = ((Integer)v.get(0)).intValue();
35
		double x = ((Double)v.get(1)).doubleValue();
36
		v = DwgUtil.getBitDouble(data, bitPos);
37
		bitPos = ((Integer)v.get(0)).intValue();
38
		double y = ((Double)v.get(1)).doubleValue();
39
		v = DwgUtil.getBitDouble(data, bitPos);
40
		bitPos = ((Integer)v.get(0)).intValue();
41
		double z = ((Double)v.get(1)).doubleValue();
42
		double[] coord = new double[]{x, y, z};
43
		txt.setInsertionPoint(coord);
44
		v = DwgUtil.getBitDouble(data, bitPos);
45
		bitPos = ((Integer)v.get(0)).intValue();
46
		x = ((Double)v.get(1)).doubleValue();
47
		v = DwgUtil.getBitDouble(data, bitPos);
48
		bitPos = ((Integer)v.get(0)).intValue();
49
		y = ((Double)v.get(1)).doubleValue();
50
		v = DwgUtil.getBitDouble(data, bitPos);
51
		bitPos = ((Integer)v.get(0)).intValue();
52
		z = ((Double)v.get(1)).doubleValue();
53
		coord = new double[]{x, y, z};
54
		txt.setExtrusion(coord);
55
		v = DwgUtil.getBitDouble(data, bitPos);
56
		bitPos = ((Integer)v.get(0)).intValue();
57
		x = ((Double)v.get(1)).doubleValue();
58
		v = DwgUtil.getBitDouble(data, bitPos);
59
		bitPos = ((Integer)v.get(0)).intValue();
60
		y = ((Double)v.get(1)).doubleValue();
61
		v = DwgUtil.getBitDouble(data, bitPos);
62
		bitPos = ((Integer)v.get(0)).intValue();
63
		z = ((Double)v.get(1)).doubleValue();
64
		coord = new double[]{x, y, z};
65
		txt.setXAxisDirection(coord);
66
		v = DwgUtil.getBitDouble(data, bitPos);
67
		bitPos = ((Integer)v.get(0)).intValue();
68
		double val = ((Double)v.get(1)).doubleValue();
69
		txt.setWidth(val);
70
		v = DwgUtil.getBitDouble(data, bitPos);
71
		bitPos = ((Integer)v.get(0)).intValue();
72
		val = ((Double)v.get(1)).doubleValue();
73
		txt.setHeight(val);
74
		v = DwgUtil.getBitShort(data, bitPos);
75
		bitPos = ((Integer)v.get(0)).intValue();
76
		int ival = ((Integer)v.get(1)).intValue();
77
		txt.setAttachment(ival);
78
		v = DwgUtil.getBitShort(data, bitPos);
79
		bitPos = ((Integer)v.get(0)).intValue();
80
		ival = ((Integer)v.get(1)).intValue();
81
		txt.setDrawingDir(ival);
82
		v = DwgUtil.getBitDouble(data, bitPos);
83
		bitPos = ((Integer)v.get(0)).intValue();
84
		val = ((Double)v.get(1)).doubleValue();
85
		txt.setExtHeight(val);
86
		v = DwgUtil.getBitDouble(data, bitPos);
87
		bitPos = ((Integer)v.get(0)).intValue();
88
		val = ((Double)v.get(1)).doubleValue();
89
		txt.setExtWidth(val);
90
		v = DwgUtil.getTextString(data, bitPos);
91
		bitPos = ((Integer)v.get(0)).intValue();
92
		String text = (String)v.get(1);
93
		txt.setText(text);
94
		v = DwgUtil.getBitShort(data, bitPos);
95
		bitPos = ((Integer)v.get(0)).intValue();
96
		ival = ((Integer)v.get(1)).intValue();
97
		txt.setLineSpacingStyle(ival);
98
		v = DwgUtil.getBitDouble(data, bitPos);
99
		bitPos = ((Integer)v.get(0)).intValue();
100
		val = ((Double)v.get(1)).doubleValue();
101
		txt.setLineSpacingFactor(val);
102
		v = DwgUtil.testBit(data, bitPos);
103
		bitPos = ((Integer)v.get(0)).intValue();
104
		boolean flag = ((Boolean)v.get(1)).booleanValue();
105
		bitPos = headTailReader.readObjectTailer(data, bitPos, txt);
106
		
107
		DwgHandleReference hr = new DwgHandleReference();
108
		bitPos = hr.read(data, bitPos);
109
	    txt.setStyleHandle(hr);
110
	}
111
}
tags/org.gvsig.dwg-2.0.212/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/readers/v15/DwgLayerControlReader15.java
1
/*
2
 * Created on 25-ene-2007 by azabala
3
 *
4
 */
5
package org.gvsig.dwg.lib.readers.v15;
6

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff