Revision 11058
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/util/FMapUtil.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 18-ene-2007 by azabala |
|
3 |
* |
|
4 |
*/ |
|
5 |
package com.iver.cit.jdwglib.util; |
|
6 |
|
|
7 |
import java.awt.geom.Point2D; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
11 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
|
12 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
13 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
|
14 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
15 |
import com.iver.cit.jdwglib.dwg.objects.DwgVertexPFace; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author alzabord |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class FMapUtil { |
|
22 |
/** |
|
23 |
* Method that changes a Point3D array to a FPolyline3D. Is useful to |
|
24 |
* convert a polyline given by it points to a FPolyline3D, a polyline 3D in |
|
25 |
* the FMap model object |
|
26 |
* |
|
27 |
* @param pts |
|
28 |
* Array of Point3D that defines the polyline 3D that will be |
|
29 |
* converted in a FPolyline3D |
|
30 |
* @return FPolyline3D This FPolyline3D is build using the array of Point3D |
|
31 |
* that is the argument of the method |
|
32 |
*/ |
|
33 |
public static FPolyline3D points3DToFPolyline3D(List pts) { |
|
34 |
GeneralPathX genPathX = getGeneralPathX(pts); |
|
35 |
double[] elevations = new double[pts.size()]; |
|
36 |
for (int i = 0; i < pts.size(); i++) { |
|
37 |
elevations[i] = ((double[])pts.get(i))[2]; |
|
38 |
} |
|
39 |
return new FPolyline3D(genPathX, elevations); |
|
40 |
} |
|
41 |
|
|
42 |
private static GeneralPathX getGeneralPathX(List pts){ |
|
43 |
GeneralPathX genPathX = new GeneralPathX(); |
|
44 |
|
|
45 |
Object firstVertex = pts.get(0); |
|
46 |
double[] coordinate = null; |
|
47 |
if(firstVertex instanceof double[]) |
|
48 |
coordinate = (double[])firstVertex; |
|
49 |
else if(firstVertex instanceof DwgVertexPFace){ |
|
50 |
DwgVertexPFace v = (DwgVertexPFace)firstVertex; |
|
51 |
coordinate = v.getPoint(); |
|
52 |
}else if(firstVertex instanceof Point2D){ |
|
53 |
Point2D point = (Point2D)firstVertex; |
|
54 |
coordinate = new double[]{point.getX(), point.getY()}; |
|
55 |
} |
|
56 |
genPathX.moveTo(coordinate[0], |
|
57 |
coordinate[1]); |
|
58 |
|
|
59 |
//TODO ESTE LIO SE DEBE A QUE EN ALGUNOS CASOS SE GUARDAN |
|
60 |
//double[] y en otros el IDwgVertex UNIFICAR |
|
61 |
for (int i = 1; i < pts.size(); i++) { |
|
62 |
Object vertex = pts.get(i); |
|
63 |
double[] vertexCoordinate = null; |
|
64 |
if(vertex instanceof double[]) |
|
65 |
vertexCoordinate = (double[])vertex; |
|
66 |
else if(vertex instanceof DwgVertexPFace){ |
|
67 |
DwgVertexPFace v = (DwgVertexPFace)vertex; |
|
68 |
vertexCoordinate = v.getPoint(); |
|
69 |
}else if(firstVertex instanceof Point2D){ |
|
70 |
Point2D point = (Point2D)vertex; |
|
71 |
vertexCoordinate = new double[]{point.getX(), point.getY()}; |
|
72 |
} |
|
73 |
genPathX.lineTo(vertexCoordinate[0], |
|
74 |
vertexCoordinate[1]); |
|
75 |
} |
|
76 |
return genPathX; |
|
77 |
} |
|
78 |
|
|
79 |
public static FPolygon3D ptsTo3DPolygon(List pts){ |
|
80 |
GeneralPathX genPathX = getGeneralPathX(pts); |
|
81 |
double[] elevations = new double[pts.size()]; |
|
82 |
for (int i = 0; i < pts.size(); i++) { |
|
83 |
// TODO ESTE LIO SE DEBE A QUE EN ALGUNOS CASOS SE GUARDAN |
|
84 |
//double[] y en otros el IDwgVertex UNIFICAR |
|
85 |
Object vertex = pts.get(i); |
|
86 |
double[] vertexCoordinate = null; |
|
87 |
if(vertex instanceof double[]) |
|
88 |
vertexCoordinate = (double[])vertex; |
|
89 |
else{ |
|
90 |
DwgVertexPFace v = (DwgVertexPFace)vertex; |
|
91 |
vertexCoordinate = v.getPoint(); |
|
92 |
} |
|
93 |
elevations[i] = vertexCoordinate[2]; |
|
94 |
} |
|
95 |
return new FPolygon3D(genPathX, elevations); |
|
96 |
} |
|
97 |
/** |
|
98 |
* Method that changes a Point2D array to a FPolyline2D. Is useful to |
|
99 |
* convert a polyline given by it points to a FPolyline2D, a polyline in the |
|
100 |
* FMap model object |
|
101 |
* |
|
102 |
* @param pts |
|
103 |
* Array of Point2D that defines the polyline that will be |
|
104 |
* converted in a FPolyline2D |
|
105 |
* @return FPolyline2D This FPolyline2D is build using the array of Point2D |
|
106 |
* that is the argument of the method |
|
107 |
*/ |
|
108 |
public static FPolyline2D points2DToFPolyline2D(List pts) { |
|
109 |
GeneralPathX genPathX = getGeneralPathX(pts); |
|
110 |
return new FPolyline2D(genPathX); |
|
111 |
} |
|
112 |
|
|
113 |
public static FPolygon2D ptsTo2DPolygon(List pts){ |
|
114 |
GeneralPathX genPathX = getGeneralPathX(pts); |
|
115 |
return new FPolygon2D(genPathX); |
|
116 |
} |
|
117 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/IDwg2FMap.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 |
/* CVS MESSAGES: |
|
46 |
* |
|
47 |
* $Id$ |
|
48 |
* $Log$ |
|
49 |
* Revision 1.3 2007-03-20 19:55:27 azabala |
|
50 |
* source code cleaning |
|
51 |
* |
|
52 |
* Revision 1.2 2007/01/18 13:35:22 azabala |
|
53 |
* Refactoring general para evitar dar tantas pasadas en la carga, y para incrementar |
|
54 |
* la legibilidad del codigo (demasiados if-else-if en vez de usar polimorfismo) |
|
55 |
* |
|
56 |
* Revision 1.1 2007/01/12 19:29:58 azabala |
|
57 |
* first version in cvs |
|
58 |
* |
|
59 |
* |
|
60 |
*/ |
|
61 |
package com.iver.cit.jdwglib.dwg; |
|
62 |
|
|
63 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
64 |
|
|
65 |
/** |
|
66 |
* All dwg objects that are drawing entities |
|
67 |
* and that can be converted to a fmap geometry |
|
68 |
* implements this interface. |
|
69 |
* |
|
70 |
* */ |
|
71 |
/* |
|
72 |
* TODO |
|
73 |
* Esta solucion tiene el problema de que es mas simple |
|
74 |
* (cada entidad dwg se ocupa de su conversion a fmap),pero acopla |
|
75 |
* libDwg con fmap |
|
76 |
* (una clase Dwg2FMap lo desacoplar?a, pero llenar?a el codigo de |
|
77 |
* infinitos if(dwg instanceof ...) else if..... |
|
78 |
* |
|
79 |
* */ |
|
80 |
public interface IDwg2FMap { |
|
81 |
public IGeometry toFMapGeometry(boolean is3DFile); |
|
82 |
public String toFMapString(boolean is3DFile); |
|
83 |
public String toString(); |
|
84 |
} |
|
85 |
|
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgMText.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
38 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
|
39 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
40 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
41 | 37 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
42 | 38 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
43 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
44 | 39 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
45 | 40 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
46 | 41 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
... | ... | |
51 | 46 |
* @author jmorell, azabala |
52 | 47 |
*/ |
53 | 48 |
public class DwgMText extends DwgObject |
54 |
implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap {
|
|
49 |
implements IDwgExtrusionable, IDwg3DTestable { |
|
55 | 50 |
public DwgMText(int index) { |
56 | 51 |
super(index); |
57 | 52 |
// TODO Auto-generated constructor stub |
... | ... | |
247 | 242 |
return getInsertionPoint()[2]; |
248 | 243 |
} |
249 | 244 |
|
250 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
251 |
FPoint2D fPoint = null; |
|
252 |
double[] p = getInsertionPoint(); |
|
253 |
if (is3DFile) { |
|
254 |
fPoint = new FPoint3D(p[0], p[1], p[2]); |
|
255 |
} else { |
|
256 |
fPoint = new FPoint2D(p[0], p[1]); |
|
257 |
} |
|
258 |
return ShapeFactory.createGeometry(fPoint); |
|
259 |
} |
|
260 |
public String toFMapString(boolean is3DFile) { |
|
261 |
if(is3DFile) |
|
262 |
return "FPoint3D"; |
|
263 |
else |
|
264 |
return "FPoint2D"; |
|
265 |
} |
|
266 |
|
|
267 | 245 |
public String toString(){ |
268 | 246 |
return "MText"; |
269 | 247 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgCircle.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 |
import java.util.ArrayList; |
|
39 | 38 |
import java.util.List; |
40 | 39 |
import java.util.Map; |
41 | 40 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
51 | 46 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
52 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
53 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
54 | 47 |
|
55 | 48 |
/** |
56 | 49 |
* The DwgCircle class represents a DWG Circle |
... | ... | |
58 | 51 |
* @author jmorell |
59 | 52 |
*/ |
60 | 53 |
public class DwgCircle extends DwgObject |
61 |
implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
|
|
54 |
implements IDwgExtrusionable, IDwg3DTestable, IDwgBlockMember{ |
|
62 | 55 |
|
63 | 56 |
private double[] center; |
64 | 57 |
private double radius; |
... | ... | |
163 | 156 |
public double getZ() { |
164 | 157 |
return getCenter()[2]; |
165 | 158 |
} |
166 |
/* (non-Javadoc) |
|
167 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
168 |
*/ |
|
169 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
170 |
FPolyline2D arcc; |
|
171 |
double[] c = getCenter(); |
|
172 |
Point2D center = new Point2D.Double(c[0], c[1]); |
|
173 |
double radius = getRadius(); |
|
174 |
List arc = GisModelCurveCalculator |
|
175 |
.calculateGisModelCircle(center, radius); |
|
176 |
if (is3DFile) { |
|
177 |
List arc3D = new ArrayList(); |
|
178 |
for (int j = 0; j < arc.size(); j++) { |
|
179 |
double[] pt2d = (double[]) arc.get(j); |
|
180 |
double[] pt3d = new double[]{ pt2d[0], pt2d[1], c[2] }; |
|
181 |
arc3D.add(pt3d); |
|
182 |
} |
|
183 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
184 |
} else { |
|
185 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
186 |
} |
|
187 |
|
|
188 |
return ShapeFactory.createGeometry(arcc); |
|
189 |
} |
|
190 |
/* (non-Javadoc) |
|
191 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
192 |
*/ |
|
193 |
public String toFMapString(boolean is3DFile) { |
|
194 |
if(is3DFile) |
|
195 |
return "FPolyline3D"; |
|
196 |
else |
|
197 |
return "FPolyline2D"; |
|
198 |
} |
|
159 |
|
|
199 | 160 |
|
161 |
|
|
200 | 162 |
public String toString(){ |
201 | 163 |
return "Circle"; |
202 | 164 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgMeshPolyline.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.4 2007-03-20 19:57:08 azabala |
|
48 |
* Revision 1.5 2007-04-04 17:36:19 azabala |
|
49 |
* Dependencies of libDwg with libFMap removed |
|
50 |
* |
|
51 |
* Revision 1.4 2007/03/20 19:57:08 azabala |
|
49 | 52 |
* source code cleaning |
50 | 53 |
* |
51 | 54 |
* Revision 1.3 2007/03/06 19:39:38 azabala |
... | ... | |
73 | 76 |
import java.util.List; |
74 | 77 |
import java.util.Map; |
75 | 78 |
|
76 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
77 | 79 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
78 | 80 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
79 | 81 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
80 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
81 | 82 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
82 | 83 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
83 | 84 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
... | ... | |
89 | 90 |
* |
90 | 91 |
* */ |
91 | 92 |
public class DwgMeshPolyline extends DwgObject |
92 |
implements IDwgPolyline, IDwg2FMap, IDwgBlockMember{
|
|
93 |
implements IDwgPolyline, IDwgBlockMember{ |
|
93 | 94 |
|
94 | 95 |
private int flags; |
95 | 96 |
/** |
... | ... | |
226 | 227 |
public void calculateGisModel(DwgFile dwgFile) { |
227 | 228 |
} |
228 | 229 |
|
229 |
/* |
|
230 |
* By the moment, we consideer that PFacePolyline |
|
231 |
* is a Polyline3D TODO Implement real conversion |
|
232 |
* from a polyface mesh to a FMap geometry |
|
233 |
* */ |
|
234 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
235 |
//TODO Implementar la conversion de DWG Mesh a |
|
236 |
//FMap (coleccion de poligonos??) |
|
237 |
return null; |
|
238 |
} |
|
239 |
/* (non-Javadoc) |
|
240 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
241 |
*/ |
|
242 |
public String toFMapString(boolean is3DFile) { |
|
243 |
if(is3DFile) |
|
244 |
return "FPolyline3D"; |
|
245 |
else |
|
246 |
return "FPolyline2D"; |
|
247 |
} |
|
230 |
|
|
248 | 231 |
|
249 | 232 |
public String toString(){ |
250 | 233 |
return "MeshPolyline"; |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline2D.java | ||
---|---|---|
39 | 39 |
import java.util.List; |
40 | 40 |
import java.util.Map; |
41 | 41 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 42 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 43 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
47 | 44 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
48 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
49 | 45 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
50 | 46 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
51 | 47 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
52 | 48 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
53 | 49 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
54 | 50 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
55 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
56 | 51 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
57 | 52 |
|
58 | 53 |
/** |
... | ... | |
61 | 56 |
* @author jmorell |
62 | 57 |
*/ |
63 | 58 |
public class DwgPolyline2D extends DwgObject |
64 |
implements IDwgPolyline, IDwgExtrusionable, IDwg3DTestable, IDwg2FMap, IDwgBlockMember{ |
|
59 |
implements IDwgPolyline, IDwgExtrusionable, |
|
60 |
IDwg3DTestable, IDwgBlockMember{ |
|
65 | 61 |
|
66 | 62 |
|
67 |
|
|
68 | 63 |
private int flags; |
69 | 64 |
private int curveType; |
70 | 65 |
private double initWidth; |
... | ... | |
423 | 418 |
public double getZ() { |
424 | 419 |
return getElevation(); |
425 | 420 |
} |
426 |
/* (non-Javadoc) |
|
427 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
428 |
*/ |
|
429 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
430 |
FPolyline2D pline = null; |
|
431 |
List points = getPts(); |
|
432 |
double elev = getElevation(); |
|
433 |
|
|
434 |
if (points != null) { |
|
435 |
if (is3DFile) { |
|
436 |
List pline3D = new ArrayList(); |
|
437 |
for (int j = 0; j < points.size(); j++) { |
|
438 |
double[] point = new double[3]; |
|
439 |
point[0] = ((double[])vertices.get(j))[0]; |
|
440 |
point[1] = ((double[])vertices.get(j))[1]; |
|
441 |
point[2] = elev; |
|
442 |
pline3D.add(point); |
|
443 |
} |
|
444 |
pline = FMapUtil.points3DToFPolyline3D(pline3D); |
|
445 |
} else { |
|
446 |
pline = FMapUtil.points2DToFPolyline2D(points); |
|
447 |
} |
|
448 |
} |
|
449 |
return ShapeFactory.createGeometry(pline); |
|
450 |
} |
|
451 |
/* (non-Javadoc) |
|
452 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
453 |
*/ |
|
454 |
public String toFMapString(boolean is3DFile) { |
|
455 |
if(is3DFile) |
|
456 |
return "FPolyline3D"; |
|
457 |
else |
|
458 |
return "FPolyline2D"; |
|
459 |
} |
|
421 |
|
|
460 | 422 |
|
461 | 423 |
public String toString(){ |
462 | 424 |
return "Polyline2D"; |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline3D.java | ||
---|---|---|
39 | 39 |
import java.util.List; |
40 | 40 |
import java.util.Map; |
41 | 41 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 42 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 43 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
47 | 44 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
48 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
49 | 45 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
50 | 46 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
51 | 47 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
52 | 48 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
53 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
54 | 49 |
|
55 | 50 |
/** |
56 | 51 |
* The DwgPolyline3D class represents a DWG Polyline3D |
... | ... | |
58 | 53 |
* @author jmorell |
59 | 54 |
*/ |
60 | 55 |
public class DwgPolyline3D extends DwgObject |
61 |
implements IDwgPolyline, IDwg3DTestable, IDwg2FMap, IDwgBlockMember{ |
|
56 |
implements IDwgPolyline, IDwg3DTestable, |
|
57 |
IDwgBlockMember{ |
|
62 | 58 |
|
63 | 59 |
private int splineFlags; |
64 | 60 |
private int closedFlags; |
... | ... | |
326 | 322 |
} |
327 | 323 |
return 0d; |
328 | 324 |
} |
329 |
/* (non-Javadoc) |
|
330 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
331 |
*/ |
|
332 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
333 |
FPolyline2D pline = null; |
|
334 |
List points3D = getPts(); |
|
335 |
if (points3D != null) { |
|
336 |
if (is3DFile) { |
|
337 |
pline = FMapUtil.points3DToFPolyline3D(points3D); |
|
338 |
} else { |
|
339 |
List points2D = new ArrayList(); |
|
340 |
for (int j = 0; j < points3D.size(); j++) { |
|
341 |
double[] pt3d = (double[]) points3D.get(j); |
|
342 |
double[] pt = new double[]{pt3d[0], |
|
343 |
pt3d[1]}; |
|
344 |
points2D.add(pt); |
|
345 |
} |
|
346 |
pline = FMapUtil.points2DToFPolyline2D(points2D); |
|
347 |
}//if |
|
348 |
}//if |
|
349 |
return ShapeFactory.createGeometry(pline); |
|
350 |
} |
|
351 |
/* (non-Javadoc) |
|
352 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
353 |
*/ |
|
354 |
public String toFMapString(boolean is3DFile) { |
|
355 |
if(is3DFile) |
|
356 |
return "FPolyline3D"; |
|
357 |
else |
|
358 |
return "FPolyline2D"; |
|
359 |
} |
|
360 |
|
|
325 |
|
|
361 | 326 |
public String toString(){ |
362 | 327 |
return "Polyline3D"; |
363 | 328 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgText.java | ||
---|---|---|
38 | 38 |
import java.util.List; |
39 | 39 |
import java.util.Map; |
40 | 40 |
|
41 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
47 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
48 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
50 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
51 | 46 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
... | ... | |
59 | 54 |
public class DwgText extends DwgObject |
60 | 55 |
implements IDwgExtrusionable, |
61 | 56 |
IDwg3DTestable, |
62 |
IDwg2FMap, |
|
63 | 57 |
IDwgBlockMember{ |
64 | 58 |
public DwgText(int index) { |
65 | 59 |
super(index); |
... | ... | |
281 | 275 |
public double getZ() { |
282 | 276 |
return getElevation(); |
283 | 277 |
} |
284 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
285 |
FPoint2D point = null; |
|
286 |
Point2D p = getInsertionPoint(); |
|
287 |
double elev = 0.0; |
|
288 |
if ((getDataFlag() & 0x1) == 0) |
|
289 |
elev = getElevation(); |
|
290 |
if (is3DFile) { |
|
291 |
point = new FPoint3D(p.getX(), p.getY(), elev); |
|
292 |
} else { |
|
293 |
point = new FPoint2D(p.getX(), p.getY()); |
|
294 |
} |
|
295 |
return ShapeFactory.createGeometry(point); |
|
296 |
} |
|
297 | 278 |
|
298 |
public String toFMapString(boolean is3DFile) { |
|
299 |
if(is3DFile) |
|
300 |
return "FPoint3D"; |
|
301 |
else |
|
302 |
return "FPoint2D"; |
|
303 |
} |
|
304 | 279 |
public String toString(){ |
305 | 280 |
return "Text"; |
306 | 281 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLine.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 |
import java.util.ArrayList; |
|
39 | 38 |
import java.util.List; |
40 | 39 |
import java.util.Map; |
41 | 40 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 45 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
51 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
52 | 46 |
|
53 | 47 |
/** |
54 | 48 |
* The DwgLine class represents a DWG Line |
... | ... | |
56 | 50 |
* @author jmorell, azabala |
57 | 51 |
*/ |
58 | 52 |
public class DwgLine extends DwgObject |
59 |
implements /*IDwgExtrusionable,*/ IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
|
|
53 |
implements /*IDwgExtrusionable,*/ IDwg3DTestable, IDwgBlockMember{ |
|
60 | 54 |
public DwgLine(int index) { |
61 | 55 |
super(index); |
62 | 56 |
// TODO Auto-generated constructor stub |
... | ... | |
195 | 189 |
return 0d; |
196 | 190 |
} |
197 | 191 |
} |
198 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
199 |
FPolyline2D line = null; |
|
200 |
double[] p1 = getP1(); |
|
201 |
double[] p2 = getP2(); |
|
202 |
if (is3DFile && isZflag()) { |
|
203 |
List lin3D = new ArrayList(); |
|
204 |
lin3D.add(p1); |
|
205 |
lin3D.add(p2); |
|
206 |
line = FMapUtil.points3DToFPolyline3D(lin3D); |
|
207 |
} else if (is3DFile && ! isZflag()) { |
|
208 |
List lin3D = new ArrayList(); |
|
209 |
p1[2] = 0d; |
|
210 |
p2[2] = 0d; |
|
211 |
lin3D.add(p1); |
|
212 |
lin3D.add(p2); |
|
213 |
line = FMapUtil.points3DToFPolyline3D(lin3D); |
|
214 |
} else { |
|
215 |
List lin = new ArrayList(); |
|
216 |
lin.add(p1); |
|
217 |
lin.add(p2); |
|
218 |
line = FMapUtil.points2DToFPolyline2D(lin); |
|
219 |
} |
|
220 |
return ShapeFactory.createGeometry(line); |
|
221 |
|
|
222 |
} |
|
223 |
public String toFMapString(boolean is3DFile) { |
|
224 |
if(is3DFile){ |
|
225 |
return "FPolyline3D"; |
|
226 |
}else{ |
|
227 |
return "FPolyline2D"; |
|
228 |
} |
|
229 |
} |
|
192 |
|
|
230 | 193 |
|
231 | 194 |
public String toString(){ |
232 | 195 |
return "Line"; |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPFacePolyline.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.3 2007-03-20 19:57:08 azabala |
|
48 |
* Revision 1.4 2007-04-04 17:36:19 azabala |
|
49 |
* Dependencies of libDwg with libFMap removed |
|
50 |
* |
|
51 |
* Revision 1.3 2007/03/20 19:57:08 azabala |
|
49 | 52 |
* source code cleaning |
50 | 53 |
* |
51 | 54 |
* Revision 1.2 2007/03/06 19:39:38 azabala |
... | ... | |
70 | 73 |
import java.util.List; |
71 | 74 |
import java.util.Map; |
72 | 75 |
|
73 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
74 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
|
75 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
76 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
77 | 76 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
78 | 77 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
79 | 78 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
80 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
81 | 79 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
82 | 80 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
83 | 81 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
84 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
85 | 82 |
|
86 | 83 |
/** |
87 | 84 |
* This DWG entity is a "Polyface Mesh". |
... | ... | |
108 | 105 |
* But DWG 12 spec doesnt say anything about 71,72,73 and 74 fields for VERTEX. |
109 | 106 |
*/ |
110 | 107 |
public class DwgPFacePolyline extends DwgObject |
111 |
implements IDwgPolyline, IDwg2FMap, IDwgBlockMember{
|
|
108 |
implements IDwgPolyline, IDwgBlockMember{ |
|
112 | 109 |
|
113 | 110 |
public static final int NUM_VERTEX_OF_FACE = 4; |
114 | 111 |
|
... | ... | |
276 | 273 |
} |
277 | 274 |
|
278 | 275 |
} |
276 |
|
|
279 | 277 |
|
280 |
|
|
281 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
282 |
FGeometryCollection solution = null; |
|
283 |
IGeometry[] geometries = null; |
|
284 |
if(vertices != null && faces != null){ |
|
285 |
if(vertices.size() == 0 || faces.size() == 0){ |
|
286 |
return solution; |
|
287 |
} |
|
288 |
ArrayList geomList = new ArrayList(); |
|
289 |
int numFaces = faces.size(); |
|
290 |
for(int i = 0; i < numFaces; i++){ |
|
291 |
DwgVertexPFaceFace face = (DwgVertexPFaceFace) faces.get(i); |
|
292 |
int[] verticesId = face.getVerticesidx(); |
|
293 |
ArrayList pts = new ArrayList(); |
|
294 |
boolean lastWasInvisible = true; |
|
295 |
for(int j = 0; j < NUM_VERTEX_OF_FACE; j++){ |
|
296 |
if(verticesId[j] > 0){ |
|
297 |
if(lastWasInvisible){ |
|
298 |
pts.clear(); |
|
299 |
lastWasInvisible = false; |
|
300 |
} |
|
301 |
// the index is 1-based |
|
302 |
try{ |
|
303 |
pts.add(vertices.get(verticesId[j] -1)); |
|
304 |
}catch(Throwable t){ |
|
305 |
t.printStackTrace(); |
|
306 |
} |
|
307 |
|
|
308 |
} else if(verticesId[j] < 0 && !lastWasInvisible){ |
|
309 |
lastWasInvisible = true; |
|
310 |
pts.add(vertices.get( (verticesId[j] * -1) -1)); |
|
311 |
} |
|
312 |
}// for j |
|
313 |
|
|
314 |
FPolygon3D polygon = FMapUtil.ptsTo3DPolygon(pts); |
|
315 |
IGeometry geom = ShapeFactory.createGeometry(polygon); |
|
316 |
geomList.add(geom); |
|
317 |
|
|
318 |
|
|
319 |
// if(!lastWasInvisible){ |
|
320 |
// if(vertex[nrV] < 0){ |
|
321 |
// line.addPoint(knot[-vertex[nrV] - 1]); |
|
322 |
// } else{ |
|
323 |
// line.addPoint(knot[vertex[nrV] - 1]); |
|
324 |
// } |
|
325 |
// set.addDrawable(line); |
|
326 |
// } |
|
327 |
|
|
328 |
}// for i |
|
329 |
geometries = new IGeometry[geomList.size()]; |
|
330 |
geomList.toArray(geometries); |
|
331 |
solution = new FGeometryCollection(geometries); |
|
332 |
} |
|
333 |
return solution; |
|
334 |
|
|
335 |
} |
|
336 |
/* |
|
337 |
* (non-Javadoc) |
|
338 |
* |
|
339 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
340 |
*/ |
|
341 |
public String toFMapString(boolean is3DFile) { |
|
342 |
if(is3DFile) |
|
343 |
return "FPolyline3D"; |
|
344 |
else |
|
345 |
return "FPolyline2D"; |
|
346 |
} |
|
347 |
|
|
348 | 278 |
public String toString(){ |
349 | 279 |
return "PFacePolyline"; |
350 | 280 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgEllipse.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 |
import java.util.ArrayList; |
|
39 | 38 |
import java.util.List; |
40 | 39 |
import java.util.Map; |
41 | 40 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
51 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
52 | 45 |
|
53 | 46 |
/** |
54 | 47 |
* The DwgEllipse class represents a DWG Ellipse |
... | ... | |
56 | 49 |
* @author jmorell |
57 | 50 |
*/ |
58 | 51 |
public class DwgEllipse extends DwgObject |
59 |
implements IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
|
|
52 |
implements IDwg3DTestable, IDwgBlockMember{ |
|
60 | 53 |
public DwgEllipse(int index) { |
61 | 54 |
super(index); |
62 | 55 |
// TODO Auto-generated constructor stub |
... | ... | |
152 | 145 |
public double getZ() { |
153 | 146 |
return getCenter()[2]; |
154 | 147 |
} |
155 |
/* (non-Javadoc) |
|
156 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
157 |
*/ |
|
158 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
159 |
FPolyline2D arcc; |
|
160 |
double[] c = getCenter(); |
|
161 |
Point2D center = new Point2D.Double(c[0], c[1]); |
|
162 |
double[] majorAxisVector = getMajorAxisVector(); |
|
163 |
Point2D mav = new Point2D.Double(majorAxisVector[0], |
|
164 |
majorAxisVector[1]); |
|
165 |
double axisRatio = getAxisRatio(); |
|
166 |
double initAngle = Math.toDegrees(getInitAngle()); |
|
167 |
double endAngle = Math.toDegrees(getEndAngle()); |
|
168 |
List arc = GisModelCurveCalculator |
|
169 |
.calculateGisModelEllipse(center, mav, axisRatio, |
|
170 |
initAngle, endAngle); |
|
171 |
if (is3DFile) { |
|
172 |
List arc3D = new ArrayList(); |
|
173 |
for (int j = 0; j < arc.size(); j++) { |
|
174 |
double[] pt = (double[]) arc.get(j); |
|
175 |
double[] newPt = new double[]{ pt[0], pt[1], c[2]} ; |
|
176 |
arc3D.add(newPt); |
|
177 |
} |
|
178 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
179 |
} else { |
|
180 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
181 |
} |
|
182 |
return ShapeFactory.createGeometry(arcc); |
|
183 |
} |
|
148 |
|
|
184 | 149 |
|
185 |
/* (non-Javadoc) |
|
186 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
187 |
*/ |
|
188 |
public String toFMapString(boolean is3DFile) { |
|
189 |
if(is3DFile) |
|
190 |
return "FPolyline3D"; |
|
191 |
else |
|
192 |
return "FPolyline2D"; |
|
193 |
} |
|
194 |
|
|
195 | 150 |
public String toString(){ |
196 | 151 |
return "Ellipse"; |
197 | 152 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgInsert.java | ||
---|---|---|
38 | 38 |
import java.util.List; |
39 | 39 |
import java.util.Map; |
40 | 40 |
|
41 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
44 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
45 | 42 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
46 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 44 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 46 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
... | ... | |
205 | 201 |
public double getZ() { |
206 | 202 |
return getInsertionPoint()[2]; |
207 | 203 |
} |
204 |
/* |
|
205 |
* azabala: It doesnt have sense to transform an insert |
|
206 |
* like as its insertion point once we already are transforming |
|
207 |
* insert's block entities. |
|
208 | 208 |
public FShape toFMapGeometry(boolean is3DFile) { |
209 | 209 |
double[] p = getInsertionPoint(); |
210 | 210 |
// Point2D point = new Point2D.Double(p[0], p[1]); |
211 | 211 |
FPoint2D fPoint; |
212 |
/* |
|
213 |
* double[] scale = ((DwgInsert)entity).getScale(); double rot = |
|
214 |
* ((DwgInsert)entity).getRotation(); int blockHandle = |
|
215 |
* ((DwgInsert)entity).getBlockHeaderHandle(); |
|
216 |
*/ |
|
212 |
|
|
217 | 213 |
// manageInsert(dwgObjects, point, scale, rot, blockHandle, i, |
218 | 214 |
// auxRow); |
219 | 215 |
if (is3DFile) { |
... | ... | |
229 | 225 |
else |
230 | 226 |
return "FPoint2D"; |
231 | 227 |
} |
232 |
|
|
228 |
*/ |
|
233 | 229 |
public String toString(){ |
234 | 230 |
return "Insert"; |
235 | 231 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgArc.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 |
import java.util.ArrayList; |
|
39 | 38 |
import java.util.List; |
40 | 39 |
import java.util.Map; |
41 | 40 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
51 | 46 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
52 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
53 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
54 | 47 |
|
55 | 48 |
/** |
56 | 49 |
* The DwgArc class represents a DWG Arc |
... | ... | |
58 | 51 |
* @author jmorell |
59 | 52 |
*/ |
60 | 53 |
public class DwgArc extends DwgObject |
61 |
implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap, IDwgBlockMember {
|
|
54 |
implements IDwgExtrusionable, IDwg3DTestable, IDwgBlockMember { |
|
62 | 55 |
|
63 | 56 |
private double[] center; |
64 | 57 |
private double radius; |
... | ... | |
165 | 158 |
return (getCenter()[2] != 0.0); |
166 | 159 |
} |
167 | 160 |
|
168 |
/* (non-Javadoc) |
|
169 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry() |
|
170 |
*/ |
|
171 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
172 |
double[] center = getCenter(); |
|
173 |
double radius = getRadius(); |
|
174 |
double initAngle = Math.toDegrees(getInitAngle()); |
|
175 |
double endAngle = Math.toDegrees(getEndAngle()); |
|
176 |
List arc = GisModelCurveCalculator.calculateGisModelArc( |
|
177 |
center, radius, initAngle, endAngle); |
|
178 |
FPolyline2D arcc; |
|
179 |
if (is3DFile) { |
|
180 |
List arc3D = new ArrayList(); |
|
181 |
for (int j = 0; j < arc.size(); j++) { |
|
182 |
double[] point = (double[]) arc.get(j); |
|
183 |
double[] newP = new double[]{point[0], point[1], center[2]}; |
|
184 |
arc3D.add(newP); |
|
185 |
} |
|
186 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
187 |
|
|
188 |
} else { |
|
189 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
190 |
} |
|
191 |
return ShapeFactory.createGeometry(arcc); |
|
192 |
} |
|
193 | 161 |
|
194 | 162 |
public String toString(){ |
195 | 163 |
return "Arc"; |
196 | 164 |
} |
197 | 165 |
|
198 | 166 |
/* (non-Javadoc) |
199 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString() |
|
200 |
*/ |
|
201 |
public String toFMapString(boolean is3dFile) { |
|
202 |
if(is3dFile) |
|
203 |
return "FPolyline3D"; |
|
204 |
else |
|
205 |
return "FPolyline2D"; |
|
206 |
} |
|
207 |
|
|
208 |
/* (non-Javadoc) |
|
209 | 167 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
210 | 168 |
*/ |
211 | 169 |
public double getZ() { |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgSolid.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 |
import java.util.ArrayList; |
|
39 | 38 |
import java.util.List; |
40 | 39 |
import java.util.Map; |
41 | 40 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 41 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 44 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
51 | 46 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
52 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
53 | 47 |
|
54 | 48 |
/** |
55 | 49 |
* The DwgSolid class represents a DWG Solid |
... | ... | |
58 | 52 |
*/ |
59 | 53 |
public class DwgSolid extends DwgObject |
60 | 54 |
implements IDwgExtrusionable, |
61 |
IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
|
|
55 |
IDwg3DTestable, IDwgBlockMember{ |
|
62 | 56 |
|
63 | 57 |
|
64 | 58 |
public DwgSolid(int index) { |
... | ... | |
224 | 218 |
public double getZ() { |
225 | 219 |
return getElevation(); |
226 | 220 |
} |
227 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
228 |
FPolyline2D solid = null; |
|
229 |
double[] p1 = getCorner1(); |
|
230 |
double[] p2 = getCorner2(); |
|
231 |
double[] p3 = getCorner3(); |
|
232 |
double[] p4 = getCorner4(); |
|
233 |
double elev = getElevation(); |
|
234 |
List pts = new ArrayList(); |
|
235 |
|
|
236 |
if (is3DFile) { |
|
237 |
double[] p13d = new double[]{p1[0], p1[1], elev}; |
|
238 |
double[] p23d = new double[]{p2[0], p2[1], elev}; |
|
239 |
double[] p33d = new double[]{p3[0], p3[1], elev}; |
|
240 |
double[] p43d = new double[]{p4[0], p4[1], elev}; |
|
241 |
pts.add(p13d); |
|
242 |
pts.add(p23d); |
|
243 |
pts.add(p33d); |
|
244 |
pts.add(p43d); |
|
245 |
|
|
246 |
solid = FMapUtil.ptsTo3DPolygon(pts); |
|
247 |
|
|
248 |
|
|
249 |
} else { |
|
250 |
pts.add(p1); |
|
251 |
pts.add(p2); |
|
252 |
pts.add(p3); |
|
253 |
pts.add(p4); |
|
254 |
solid = FMapUtil.ptsTo2DPolygon(pts); |
|
255 |
} |
|
256 |
return ShapeFactory.createGeometry(solid); |
|
257 |
|
|
258 |
} |
|
259 |
public String toFMapString(boolean is3DFile) { |
|
260 |
if(is3DFile){ |
|
261 |
return "FPolyline3D"; |
|
262 |
}else{ |
|
263 |
return "FPolyline2D"; |
|
264 |
} |
|
265 |
} |
|
266 | 221 |
|
267 | 222 |
public String toString(){ |
268 | 223 |
return "Solid"; |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPoint.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
38 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
|
39 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
40 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
41 | 37 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
42 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
43 | 38 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
44 | 39 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
45 | 40 |
|
... | ... | |
49 | 44 |
* @author jmorell |
50 | 45 |
*/ |
51 | 46 |
public class DwgPoint extends DwgObject |
52 |
implements/* IDwgExtrusionable,*/ IDwg3DTestable, IDwg2FMap{
|
|
47 |
implements/* IDwgExtrusionable,*/ IDwg3DTestable{ |
|
53 | 48 |
public DwgPoint(int index) { |
54 | 49 |
super(index); |
55 | 50 |
// TODO Auto-generated constructor stub |
... | ... | |
129 | 124 |
public double getZ() { |
130 | 125 |
return getPoint()[2]; |
131 | 126 |
} |
132 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
133 |
FPoint2D point = null; |
|
134 |
double[] p = getPoint(); |
|
135 |
if (is3DFile) { |
|
136 |
point = new FPoint3D(p[0], p[1], p[2]); |
|
137 |
|
|
138 |
} else { |
|
139 |
point = new FPoint2D(p[0], p[1]); |
|
140 |
} |
|
141 |
return ShapeFactory.createGeometry(point); |
|
142 |
} |
|
127 |
|
|
143 | 128 |
|
144 |
public String toFMapString(boolean is3DFile) { |
|
145 |
if(is3DFile) |
|
146 |
return "FPoint3D"; |
|
147 |
else |
|
148 |
return "FPoint2D"; |
|
149 |
} |
|
150 |
|
|
151 | 129 |
public String toString(){ |
152 | 130 |
return "Point"; |
153 | 131 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLwPolyline.java | ||
---|---|---|
39 | 39 |
import java.util.List; |
40 | 40 |
import java.util.Map; |
41 | 41 |
|
42 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
45 | 42 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
46 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
47 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
48 | 44 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
49 | 45 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
50 | 46 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
51 | 47 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
52 | 48 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
53 | 49 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
54 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
55 | 50 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
56 | 51 |
|
57 | 52 |
/** |
... | ... | |
61 | 56 |
*/ |
62 | 57 |
public class DwgLwPolyline extends DwgObject |
63 | 58 |
implements IDwgPolyline, IDwgExtrusionable, |
64 |
IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
|
|
59 |
IDwg3DTestable, IDwgBlockMember{ |
|
65 | 60 |
|
66 | 61 |
private int flag; |
67 | 62 |
private double constWidth; |
... | ... | |
305 | 300 |
public double getZ() { |
306 | 301 |
return getElevation(); |
307 | 302 |
} |
308 |
public IGeometry toFMapGeometry(boolean is3DFile) { |
|
309 |
FPolyline2D lwpline = null; |
|
310 |
List pts = getVertices(); |
|
311 |
double elev = getElevation(); |
|
312 |
if (pts != null && pts.size() > 0) { |
|
313 |
|
|
314 |
if (is3DFile) { |
|
315 |
List pline3D = new ArrayList(); |
|
316 |
for (int j = 0; j < pts.size(); j++) { |
|
317 |
Object vertex = pts.get(j); |
|
318 |
double[] pt = new double[3]; |
|
319 |
if(vertex instanceof double[]){ |
|
320 |
double[] vertexArray = (double[])vertex; |
|
321 |
pt[0] = vertexArray[0]; |
|
322 |
pt[1] = vertexArray[1]; |
|
323 |
}else if(vertex instanceof Point2D){ |
|
324 |
Point2D vertexPt = (Point2D)vertex; |
|
325 |
pt[0] = vertexPt.getX(); |
|
326 |
pt[1] = vertexPt.getY(); |
|
327 |
} |
|
328 |
pt[2] = elev; |
|
329 |
pline3D.add(pt); |
|
330 |
} |
|
331 |
lwpline = FMapUtil.points3DToFPolyline3D(pline3D); |
|
332 |
} else { |
|
333 |
lwpline = FMapUtil.points2DToFPolyline2D(pts); |
|
334 |
} |
|
335 |
|
|
336 |
} |
|
337 |
return ShapeFactory.createGeometry(lwpline); |
|
338 |
} |
|
339 |
public String toFMapString(boolean is3DFile) { |
|
340 |
if(is3DFile) |
|
341 |
return "FPolyline3D"; |
|
342 |
else |
|
343 |
return "FPolyline2D"; |
|
344 |
} |
|
303 |
|
|
345 | 304 |
|
346 | 305 |
public String toString(){ |
347 | 306 |
return "LwPolyline"; |
trunk/libraries/libDwg/.classpath | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 | 3 |
<classpathentry kind="src" path="src"/> |
4 |
<classpathentry output="bin-test" kind="src" path="src-test"/>
|
|
4 |
<classpathentry kind="src" output="bin-test" path="src-test"/>
|
|
5 | 5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
6 |
<classpathentry kind="src" path="/libFMap"/> |
|
7 | 6 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/> |
8 | 7 |
<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/> |
9 | 8 |
<classpathentry kind="output" path="bin"/> |
Also available in: Unified diff