svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / objects / DwgMeshPolyline.java @ 28969
History | View | Annotate | Download (8.19 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 28969 2009-05-25 13:23:12Z 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 |
|
88 |
/**
|
89 |
* This class is a Mesh (polyline mesh), what is different of
|
90 |
* a Polyface mesh (polyline pface).
|
91 |
*
|
92 |
*
|
93 |
* */
|
94 |
public class DwgMeshPolyline extends DwgObject |
95 |
implements IDwgPolyline, IDwg2FMap, IDwgBlockMember{
|
96 |
|
97 |
private int flags; |
98 |
/**
|
99 |
* Curves and smooth surface type (optional; default = 0);
|
100 |
* integer codes, not bit-coded:
|
101 |
0 = No smooth surface fitted
|
102 |
5 = Quadratic B-spline surface
|
103 |
6 = Cubic B-spline surface
|
104 |
8 = Bezier surface
|
105 |
* */
|
106 |
private int curveType; |
107 |
|
108 |
/**
|
109 |
* Polygon mesh M vertex count
|
110 |
* (if curvetype is Spline, it has smooth M density)
|
111 |
*/
|
112 |
private int mVerticies; |
113 |
/**
|
114 |
* Polygon mesh N vertex count
|
115 |
* (if curvetype is Spline, it has smooth n density)
|
116 |
* */
|
117 |
private int nVerticies; |
118 |
/**
|
119 |
* If the mesh is closed in the M direction
|
120 |
* */
|
121 |
private boolean isClosedM; |
122 |
/**
|
123 |
* If the mesh is closed in the N direction
|
124 |
* */
|
125 |
private boolean isClosedN; |
126 |
|
127 |
/**
|
128 |
* handle of the first vertex of the mesh
|
129 |
* */
|
130 |
private DwgHandleReference firstVertexHandle;
|
131 |
/**
|
132 |
* handle of the last vertex of the mesh
|
133 |
* */
|
134 |
private DwgHandleReference lastVertexHandle;
|
135 |
/**
|
136 |
* handle of the seqend of the mesh
|
137 |
* */
|
138 |
private DwgHandleReference seqendHandle;
|
139 |
|
140 |
/**
|
141 |
* Vertices of the mesh
|
142 |
* */
|
143 |
private List vertices; |
144 |
|
145 |
/**
|
146 |
* Owned Objects Handles of the mesh
|
147 |
* */
|
148 |
private ArrayList ownedObjectsHandles; //For R2004+ |
149 |
|
150 |
|
151 |
/**
|
152 |
* Constructor
|
153 |
* */
|
154 |
public DwgMeshPolyline(int index) { |
155 |
super(index);
|
156 |
ownedObjectsHandles = new ArrayList(); |
157 |
} |
158 |
|
159 |
public void setFlags(int flags) { |
160 |
this.flags = flags;
|
161 |
} |
162 |
|
163 |
public void setCurveType(int curveType) { |
164 |
this.curveType = curveType;
|
165 |
} |
166 |
|
167 |
public void setMVerticies(int verticies) { |
168 |
this.mVerticies = verticies;
|
169 |
} |
170 |
|
171 |
public void setNVerticies(int verticies) { |
172 |
this.nVerticies = verticies;
|
173 |
} |
174 |
|
175 |
|
176 |
public void setFirstVertexHandle(DwgHandleReference handle) { |
177 |
this.firstVertexHandle = handle;
|
178 |
} |
179 |
|
180 |
public void setLastVertexHandle(DwgHandleReference handle) { |
181 |
this.lastVertexHandle = handle;
|
182 |
} |
183 |
|
184 |
public void setSeqendHandle(DwgHandleReference handle) { |
185 |
this.seqendHandle = handle;
|
186 |
} |
187 |
|
188 |
public int getCurveType() { |
189 |
return curveType;
|
190 |
} |
191 |
|
192 |
public DwgHandleReference getFirstVertexHandle() {
|
193 |
return firstVertexHandle;
|
194 |
} |
195 |
|
196 |
public int getFlags() { |
197 |
return flags;
|
198 |
} |
199 |
|
200 |
public DwgHandleReference getLastVertexHandle() {
|
201 |
return lastVertexHandle;
|
202 |
} |
203 |
|
204 |
|
205 |
public int getMVerticies() { |
206 |
return mVerticies;
|
207 |
} |
208 |
|
209 |
|
210 |
public int getNVerticies() { |
211 |
return nVerticies;
|
212 |
} |
213 |
|
214 |
public DwgHandleReference getSeqendHandle() {
|
215 |
return seqendHandle;
|
216 |
} |
217 |
public Object clone(){ |
218 |
DwgMeshPolyline obj = new DwgMeshPolyline(index);
|
219 |
this.fill(obj);
|
220 |
return obj;
|
221 |
} |
222 |
|
223 |
protected void fill(DwgObject obj){ |
224 |
super.fill(obj);
|
225 |
DwgMeshPolyline myObj = (DwgMeshPolyline)obj; |
226 |
|
227 |
myObj.setCurveType(curveType); |
228 |
myObj.setFirstVertexHandle(firstVertexHandle); |
229 |
myObj.setFlags(flags); |
230 |
myObj.setLastVertexHandle(lastVertexHandle); |
231 |
myObj.setMVerticies(mVerticies); |
232 |
myObj.setNVerticies(nVerticies); |
233 |
myObj.setSeqendHandle(seqendHandle); |
234 |
} |
235 |
|
236 |
public void calculateGisModel(DwgFile dwgFile) { |
237 |
} |
238 |
|
239 |
/*
|
240 |
* By the moment, we consideer that PFacePolyline
|
241 |
* is a Polyline3D TODO Implement real conversion
|
242 |
* from a polyface mesh to a FMap geometry
|
243 |
* */
|
244 |
public Geometry toFMapGeometry(boolean is3DFile) { |
245 |
//TODO Implementar la conversion de DWG Mesh a
|
246 |
//FMap (coleccion de poligonos??)
|
247 |
return null; |
248 |
} |
249 |
/* (non-Javadoc)
|
250 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean)
|
251 |
*/
|
252 |
public String toFMapString(boolean is3DFile) { |
253 |
if(is3DFile)
|
254 |
return "FPolyline3D"; |
255 |
else
|
256 |
return "FPolyline2D"; |
257 |
} |
258 |
|
259 |
public String toString(){ |
260 |
return "MeshPolyline"; |
261 |
} |
262 |
|
263 |
public List getVertices() { |
264 |
return vertices;
|
265 |
} |
266 |
|
267 |
public void setVertices(List vertices) { |
268 |
this.vertices = vertices;
|
269 |
} |
270 |
|
271 |
public boolean isClosedM() { |
272 |
return isClosedM;
|
273 |
} |
274 |
|
275 |
public void setClosedM(boolean isClosedM) { |
276 |
this.isClosedM = isClosedM;
|
277 |
} |
278 |
|
279 |
public boolean isClosedN() { |
280 |
return isClosedN;
|
281 |
} |
282 |
|
283 |
public void setClosedN(boolean isClosedN) { |
284 |
this.isClosedN = isClosedN;
|
285 |
} |
286 |
|
287 |
public void setMDensity(int density) { |
288 |
this.mVerticies = density;
|
289 |
} |
290 |
|
291 |
public void setNDensity(int density) { |
292 |
this.nVerticies = density;
|
293 |
} |
294 |
|
295 |
public void addVertex(IDwgVertex vertex) { |
296 |
vertices.add(vertex.getPoint()); |
297 |
|
298 |
} |
299 |
|
300 |
/**
|
301 |
* @return Returns the owned objects handles.
|
302 |
*/
|
303 |
public ArrayList getOwnedObjectsHandles() { |
304 |
return ownedObjectsHandles;
|
305 |
} |
306 |
/**
|
307 |
* @param objects The owned objects handles to set.
|
308 |
*/
|
309 |
public void setOwnedObjectsHandles(ArrayList handles) { |
310 |
this.ownedObjectsHandles = handles;
|
311 |
} |
312 |
/**
|
313 |
* Add a handle to the ownedBbjectsHandle vector
|
314 |
*
|
315 |
* @param handle handle
|
316 |
*/
|
317 |
public void addOwnedObjectHandle(DwgHandleReference handle) { |
318 |
this.ownedObjectsHandles.add(handle);
|
319 |
} |
320 |
|
321 |
public void transform2Block(double[] bPoint, Point2D insPoint, |
322 |
double[] scale, double rot, |
323 |
List dwgObjectsWithoutBlocks,
|
324 |
Map handleObjWithoutBlocks, DwgFile callBack) {
|
325 |
|
326 |
DwgPolyline3D transformedEntity = null;
|
327 |
List vertices = this.getVertices(); |
328 |
|
329 |
if (vertices != null) { |
330 |
List transformedVertices = new ArrayList(); |
331 |
for (int i=0;i < vertices.size();i++) { |
332 |
double[] pointAux = null; |
333 |
pointAux = new double[]{((double[]) vertices.get(i))[0] - bPoint[0], |
334 |
((double[]) vertices.get(i))[1] - bPoint[1]}; |
335 |
|
336 |
double laX = insPoint.getX() + ((pointAux[0] * scale[0])*Math.cos(rot) + (pointAux[1]*scale[1])*(-1)*Math.sin(rot)); |
337 |
double laY = insPoint.getY() + ((pointAux[0]*scale[0])*Math.sin(rot) + (pointAux[1]*scale[1])*Math.cos(rot)); |
338 |
double laZ = ((double[]) vertices.get(i))[2] - bPoint[2]; |
339 |
transformedVertices.add(new double[]{laX, laY, laZ}); |
340 |
}//for
|
341 |
transformedEntity = (DwgPolyline3D)this.clone();
|
342 |
transformedEntity.setPts(transformedVertices); |
343 |
dwgObjectsWithoutBlocks.add(transformedEntity); |
344 |
handleObjWithoutBlocks.put(new Integer(transformedEntity.getHandle().getOffset()), transformedEntity); |
345 |
} |
346 |
} |
347 |
} |
348 |
|