svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / objects / DwgMeshPolyline.java @ 29001
History | View | Annotate | Download (8.52 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-feb-2007
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib��ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: DwgMeshPolyline.java 29001 2009-05-26 15:32:46Z jmvivo $
|
47 |
* $Log$
|
48 |
* Revision 1.4.2.1 2007-03-21 19:49:16 azabala
|
49 |
* implementation of dwg 12, 13, 14.
|
50 |
*
|
51 |
* Revision 1.4 2007/03/20 19:57:08 azabala
|
52 |
* source code cleaning
|
53 |
*
|
54 |
* Revision 1.3 2007/03/06 19:39:38 azabala
|
55 |
* Changes to adapt dwg 12 to general architecture
|
56 |
*
|
57 |
* Revision 1.2 2007/03/02 20:31:22 azabala
|
58 |
* *** empty log message ***
|
59 |
*
|
60 |
* Revision 1.1 2007/03/01 19:58:53 azabala
|
61 |
* refactor of pface and mesh names
|
62 |
*
|
63 |
* Revision 1.2 2007/02/07 12:44:27 fdiaz
|
64 |
* A�adido o modificado el metodo clone para que el DwgObject se encargue de las propiedades comunes a todos los objetos.
|
65 |
* A�adido el metodo fill.
|
66 |
*
|
67 |
* Revision 1.1 2007/02/05 07:03:22 azabala
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
*
|
71 |
*/
|
72 |
package org.gvsig.dwg.lib.objects; |
73 |
|
74 |
import java.awt.geom.Point2D; |
75 |
import java.util.ArrayList; |
76 |
import java.util.List; |
77 |
import java.util.Map; |
78 |
|
79 |
import org.gvsig.dwg.lib.DwgFile; |
80 |
import org.gvsig.dwg.lib.DwgHandleReference; |
81 |
import org.gvsig.dwg.lib.DwgObject; |
82 |
import org.gvsig.dwg.lib.IDwg2FMap; |
83 |
import org.gvsig.dwg.lib.IDwgBlockMember; |
84 |
import org.gvsig.dwg.lib.IDwgPolyline; |
85 |
import org.gvsig.dwg.lib.IDwgVertex; |
86 |
import org.gvsig.fmap.geom.Geometry; |
87 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
88 |
|
89 |
/**
|
90 |
* This class is a Mesh (polyline mesh), what is different of
|
91 |
* a Polyface mesh (polyline pface).
|
92 |
*
|
93 |
*
|
94 |
* */
|
95 |
public class DwgMeshPolyline extends DwgObject |
96 |
implements IDwgPolyline, IDwg2FMap, IDwgBlockMember{
|
97 |
|
98 |
private int flags; |
99 |
/**
|
100 |
* Curves and smooth surface type (optional; default = 0);
|
101 |
* integer codes, not bit-coded:
|
102 |
0 = No smooth surface fitted
|
103 |
5 = Quadratic B-spline surface
|
104 |
6 = Cubic B-spline surface
|
105 |
8 = Bezier surface
|
106 |
* */
|
107 |
private int curveType; |
108 |
|
109 |
/**
|
110 |
* Polygon mesh M vertex count
|
111 |
* (if curvetype is Spline, it has smooth M density)
|
112 |
*/
|
113 |
private int mVerticies; |
114 |
/**
|
115 |
* Polygon mesh N vertex count
|
116 |
* (if curvetype is Spline, it has smooth n density)
|
117 |
* */
|
118 |
private int nVerticies; |
119 |
/**
|
120 |
* If the mesh is closed in the M direction
|
121 |
* */
|
122 |
private boolean isClosedM; |
123 |
/**
|
124 |
* If the mesh is closed in the N direction
|
125 |
* */
|
126 |
private boolean isClosedN; |
127 |
|
128 |
/**
|
129 |
* handle of the first vertex of the mesh
|
130 |
* */
|
131 |
private DwgHandleReference firstVertexHandle;
|
132 |
/**
|
133 |
* handle of the last vertex of the mesh
|
134 |
* */
|
135 |
private DwgHandleReference lastVertexHandle;
|
136 |
/**
|
137 |
* handle of the seqend of the mesh
|
138 |
* */
|
139 |
private DwgHandleReference seqendHandle;
|
140 |
|
141 |
/**
|
142 |
* Vertices of the mesh
|
143 |
* */
|
144 |
private List vertices; |
145 |
|
146 |
/**
|
147 |
* Owned Objects Handles of the mesh
|
148 |
* */
|
149 |
private ArrayList ownedObjectsHandles; //For R2004+ |
150 |
|
151 |
|
152 |
/**
|
153 |
* Constructor
|
154 |
* */
|
155 |
public DwgMeshPolyline(int index) { |
156 |
super(index);
|
157 |
ownedObjectsHandles = new ArrayList(); |
158 |
} |
159 |
|
160 |
public void setFlags(int flags) { |
161 |
this.flags = flags;
|
162 |
} |
163 |
|
164 |
public void setCurveType(int curveType) { |
165 |
this.curveType = curveType;
|
166 |
} |
167 |
|
168 |
public void setMVerticies(int verticies) { |
169 |
this.mVerticies = verticies;
|
170 |
} |
171 |
|
172 |
public void setNVerticies(int verticies) { |
173 |
this.nVerticies = verticies;
|
174 |
} |
175 |
|
176 |
|
177 |
public void setFirstVertexHandle(DwgHandleReference handle) { |
178 |
this.firstVertexHandle = handle;
|
179 |
} |
180 |
|
181 |
public void setLastVertexHandle(DwgHandleReference handle) { |
182 |
this.lastVertexHandle = handle;
|
183 |
} |
184 |
|
185 |
public void setSeqendHandle(DwgHandleReference handle) { |
186 |
this.seqendHandle = handle;
|
187 |
} |
188 |
|
189 |
public int getCurveType() { |
190 |
return curveType;
|
191 |
} |
192 |
|
193 |
public DwgHandleReference getFirstVertexHandle() {
|
194 |
return firstVertexHandle;
|
195 |
} |
196 |
|
197 |
public int getFlags() { |
198 |
return flags;
|
199 |
} |
200 |
|
201 |
public DwgHandleReference getLastVertexHandle() {
|
202 |
return lastVertexHandle;
|
203 |
} |
204 |
|
205 |
|
206 |
public int getMVerticies() { |
207 |
return mVerticies;
|
208 |
} |
209 |
|
210 |
|
211 |
public int getNVerticies() { |
212 |
return nVerticies;
|
213 |
} |
214 |
|
215 |
public DwgHandleReference getSeqendHandle() {
|
216 |
return seqendHandle;
|
217 |
} |
218 |
public Object clone(){ |
219 |
DwgMeshPolyline obj = new DwgMeshPolyline(index);
|
220 |
this.fill(obj);
|
221 |
return obj;
|
222 |
} |
223 |
|
224 |
protected void fill(DwgObject obj){ |
225 |
super.fill(obj);
|
226 |
DwgMeshPolyline myObj = (DwgMeshPolyline)obj; |
227 |
|
228 |
myObj.setCurveType(curveType); |
229 |
myObj.setFirstVertexHandle(firstVertexHandle); |
230 |
myObj.setFlags(flags); |
231 |
myObj.setLastVertexHandle(lastVertexHandle); |
232 |
myObj.setMVerticies(mVerticies); |
233 |
myObj.setNVerticies(nVerticies); |
234 |
myObj.setSeqendHandle(seqendHandle); |
235 |
} |
236 |
|
237 |
public void calculateGisModel(DwgFile dwgFile) { |
238 |
} |
239 |
|
240 |
/*
|
241 |
* By the moment, we consideer that PFacePolyline
|
242 |
* is a Polyline3D TODO Implement real conversion
|
243 |
* from a polyface mesh to a FMap geometry
|
244 |
* */
|
245 |
public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException { |
246 |
//TODO Implementar la conversion de DWG Mesh a
|
247 |
//FMap (coleccion de poligonos??)
|
248 |
return null; |
249 |
} |
250 |
/* (non-Javadoc)
|
251 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean)
|
252 |
*/
|
253 |
public String toFMapString(boolean is3DFile) { |
254 |
if(is3DFile) {
|
255 |
return "FPolyline3D"; |
256 |
} else {
|
257 |
return "FPolyline2D"; |
258 |
} |
259 |
} |
260 |
|
261 |
public String toString(){ |
262 |
return "MeshPolyline"; |
263 |
} |
264 |
|
265 |
public List getVertices() { |
266 |
return vertices;
|
267 |
} |
268 |
|
269 |
public void setVertices(List vertices) { |
270 |
this.vertices = vertices;
|
271 |
} |
272 |
|
273 |
public boolean isClosedM() { |
274 |
return isClosedM;
|
275 |
} |
276 |
|
277 |
public void setClosedM(boolean isClosedM) { |
278 |
this.isClosedM = isClosedM;
|
279 |
} |
280 |
|
281 |
public boolean isClosedN() { |
282 |
return isClosedN;
|
283 |
} |
284 |
|
285 |
public void setClosedN(boolean isClosedN) { |
286 |
this.isClosedN = isClosedN;
|
287 |
} |
288 |
|
289 |
public void setMDensity(int density) { |
290 |
this.mVerticies = density;
|
291 |
} |
292 |
|
293 |
public void setNDensity(int density) { |
294 |
this.nVerticies = density;
|
295 |
} |
296 |
|
297 |
public void addVertex(IDwgVertex vertex) { |
298 |
vertices.add(vertex.getPoint()); |
299 |
|
300 |
} |
301 |
|
302 |
/**
|
303 |
* @return Returns the owned objects handles.
|
304 |
*/
|
305 |
public ArrayList getOwnedObjectsHandles() { |
306 |
return ownedObjectsHandles;
|
307 |
} |
308 |
/**
|
309 |
* @param objects The owned objects handles to set.
|
310 |
*/
|
311 |
public void setOwnedObjectsHandles(ArrayList handles) { |
312 |
this.ownedObjectsHandles = handles;
|
313 |
} |
314 |
/**
|
315 |
* Add a handle to the ownedBbjectsHandle vector
|
316 |
*
|
317 |
* @param handle handle
|
318 |
*/
|
319 |
public void addOwnedObjectHandle(DwgHandleReference handle) { |
320 |
this.ownedObjectsHandles.add(handle);
|
321 |
} |
322 |
|
323 |
public void transform2Block(double[] bPoint, Point2D insPoint, |
324 |
double[] scale, double rot, |
325 |
List dwgObjectsWithoutBlocks,
|
326 |
Map handleObjWithoutBlocks, DwgFile callBack) {
|
327 |
|
328 |
DwgPolyline3D transformedEntity = null;
|
329 |
List vertices = this.getVertices(); |
330 |
|
331 |
if (vertices != null) { |
332 |
List transformedVertices = new ArrayList(); |
333 |
for (int i=0;i < vertices.size();i++) { |
334 |
double[] pointAux = null; |
335 |
pointAux = new double[]{((double[]) vertices.get(i))[0] - bPoint[0], |
336 |
((double[]) vertices.get(i))[1] - bPoint[1]}; |
337 |
|
338 |
double laX = insPoint.getX() + ((pointAux[0] * scale[0])*Math.cos(rot) + (pointAux[1]*scale[1])*(-1)*Math.sin(rot)); |
339 |
double laY = insPoint.getY() + ((pointAux[0]*scale[0])*Math.sin(rot) + (pointAux[1]*scale[1])*Math.cos(rot)); |
340 |
double laZ = ((double[]) vertices.get(i))[2] - bPoint[2]; |
341 |
transformedVertices.add(new double[]{laX, laY, laZ}); |
342 |
}//for
|
343 |
transformedEntity = (DwgPolyline3D)this.clone();
|
344 |
transformedEntity.setPts(transformedVertices); |
345 |
dwgObjectsWithoutBlocks.add(transformedEntity); |
346 |
handleObjWithoutBlocks.put(new Integer(transformedEntity.getHandle().getOffset()), transformedEntity); |
347 |
} |
348 |
} |
349 |
|
350 |
|
351 |
public int getGeometrySubType(boolean is3DFile) { |
352 |
if (is3DFile) {
|
353 |
return Geometry.SUBTYPES.GEOM3D;
|
354 |
} else {
|
355 |
return Geometry.SUBTYPES.GEOM2D;
|
356 |
} |
357 |
} |
358 |
|
359 |
public int getGeometryType() { |
360 |
return Geometry.TYPES.MULTICURVE;
|
361 |
} |
362 |
|
363 |
} |
364 |
|