root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgMeshPolyline.java @ 10820
History | View | Annotate | Download (7.56 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 10820 2007-03-20 19:57:09Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.4 2007-03-20 19:57:08 azabala
|
49 |
* source code cleaning
|
50 |
*
|
51 |
* Revision 1.3 2007/03/06 19:39:38 azabala
|
52 |
* Changes to adapt dwg 12 to general architecture
|
53 |
*
|
54 |
* Revision 1.2 2007/03/02 20:31:22 azabala
|
55 |
* *** empty log message ***
|
56 |
*
|
57 |
* Revision 1.1 2007/03/01 19:58:53 azabala
|
58 |
* refactor of pface and mesh names
|
59 |
*
|
60 |
* Revision 1.2 2007/02/07 12:44:27 fdiaz
|
61 |
* A?adido o modificado el metodo clone para que el DwgObject se encargue de las propiedades comunes a todos los objetos.
|
62 |
* A?adido el metodo fill.
|
63 |
*
|
64 |
* Revision 1.1 2007/02/05 07:03:22 azabala
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
package com.iver.cit.jdwglib.dwg.objects; |
70 |
|
71 |
import java.awt.geom.Point2D; |
72 |
import java.util.ArrayList; |
73 |
import java.util.List; |
74 |
import java.util.Map; |
75 |
|
76 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
77 |
import com.iver.cit.jdwglib.dwg.DwgFile; |
78 |
import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
79 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
80 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
81 |
import com.iver.cit.jdwglib.dwg.IDwgBlockMember; |
82 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
83 |
import com.iver.cit.jdwglib.dwg.IDwgVertex; |
84 |
|
85 |
/**
|
86 |
* This class is a Mesh (polyline mesh), what is different of
|
87 |
* a Polyface mesh (polyline pface).
|
88 |
*
|
89 |
*
|
90 |
* */
|
91 |
public class DwgMeshPolyline extends DwgObject |
92 |
implements IDwgPolyline, IDwg2FMap, IDwgBlockMember{
|
93 |
|
94 |
private int flags; |
95 |
/**
|
96 |
* Curves and smooth surface type (optional; default = 0);
|
97 |
* integer codes, not bit-coded:
|
98 |
0 = No smooth surface fitted
|
99 |
5 = Quadratic B-spline surface
|
100 |
6 = Cubic B-spline surface
|
101 |
8 = Bezier surface
|
102 |
* */
|
103 |
private int curveType; |
104 |
|
105 |
/**
|
106 |
* Polygon mesh M vertex count
|
107 |
* (if curvetype is Spline, it has smooth M density)
|
108 |
*/
|
109 |
private int mVerticies; |
110 |
/**
|
111 |
* Polygon mesh N vertex count
|
112 |
* (if curvetype is Spline, it has smooth n density)
|
113 |
* */
|
114 |
private int nVerticies; |
115 |
/**
|
116 |
* If the mesh is closed in the M direction
|
117 |
* */
|
118 |
private boolean isClosedM; |
119 |
/**
|
120 |
* If the mesh is closed in the N direction
|
121 |
* */
|
122 |
private boolean isClosedN; |
123 |
|
124 |
/**
|
125 |
* handle of the first vertex of the mesh
|
126 |
* */
|
127 |
private DwgHandleReference firstVertexHandle;
|
128 |
/**
|
129 |
* handle of the last vertex of the mesh
|
130 |
* */
|
131 |
private DwgHandleReference lastVertexHandle;
|
132 |
/**
|
133 |
* handle of the seqend of the mesh
|
134 |
* */
|
135 |
private DwgHandleReference seqendHandle;
|
136 |
|
137 |
/**
|
138 |
* Vertices of the mesh
|
139 |
* */
|
140 |
private List vertices; |
141 |
|
142 |
/**
|
143 |
* Constructor
|
144 |
* */
|
145 |
public DwgMeshPolyline(int index) { |
146 |
super(index);
|
147 |
} |
148 |
|
149 |
public void setFlags(int flags) { |
150 |
this.flags = flags;
|
151 |
} |
152 |
|
153 |
public void setCurveType(int curveType) { |
154 |
this.curveType = curveType;
|
155 |
} |
156 |
|
157 |
public void setMVerticies(int verticies) { |
158 |
this.mVerticies = verticies;
|
159 |
} |
160 |
|
161 |
public void setNVerticies(int verticies) { |
162 |
this.nVerticies = verticies;
|
163 |
} |
164 |
|
165 |
|
166 |
public void setFirstVertexHandle(DwgHandleReference handle) { |
167 |
this.firstVertexHandle = handle;
|
168 |
} |
169 |
|
170 |
public void setLastVertexHandle(DwgHandleReference handle) { |
171 |
this.lastVertexHandle = handle;
|
172 |
} |
173 |
|
174 |
public void setSeqendHandle(DwgHandleReference handle) { |
175 |
this.seqendHandle = handle;
|
176 |
} |
177 |
|
178 |
public int getCurveType() { |
179 |
return curveType;
|
180 |
} |
181 |
|
182 |
public DwgHandleReference getFirstVertexHandle() {
|
183 |
return firstVertexHandle;
|
184 |
} |
185 |
|
186 |
public int getFlags() { |
187 |
return flags;
|
188 |
} |
189 |
|
190 |
public DwgHandleReference getLastVertexHandle() {
|
191 |
return lastVertexHandle;
|
192 |
} |
193 |
|
194 |
|
195 |
public int getMVerticies() { |
196 |
return mVerticies;
|
197 |
} |
198 |
|
199 |
|
200 |
public int getNVerticies() { |
201 |
return nVerticies;
|
202 |
} |
203 |
|
204 |
public DwgHandleReference getSeqendHandle() {
|
205 |
return seqendHandle;
|
206 |
} |
207 |
public Object clone(){ |
208 |
DwgMeshPolyline obj = new DwgMeshPolyline(index);
|
209 |
this.fill(obj);
|
210 |
return obj;
|
211 |
} |
212 |
|
213 |
protected void fill(DwgObject obj){ |
214 |
super.fill(obj);
|
215 |
DwgMeshPolyline myObj = (DwgMeshPolyline)obj; |
216 |
|
217 |
myObj.setCurveType(curveType); |
218 |
myObj.setFirstVertexHandle(firstVertexHandle); |
219 |
myObj.setFlags(flags); |
220 |
myObj.setLastVertexHandle(lastVertexHandle); |
221 |
myObj.setMVerticies(mVerticies); |
222 |
myObj.setNVerticies(nVerticies); |
223 |
myObj.setSeqendHandle(seqendHandle); |
224 |
} |
225 |
|
226 |
public void calculateGisModel(DwgFile dwgFile) { |
227 |
} |
228 |
|
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 |
} |
248 |
|
249 |
public String toString(){ |
250 |
return "MeshPolyline"; |
251 |
} |
252 |
|
253 |
public List getVertices() { |
254 |
return vertices;
|
255 |
} |
256 |
|
257 |
public void setVertices(List vertices) { |
258 |
this.vertices = vertices;
|
259 |
} |
260 |
|
261 |
public boolean isClosedM() { |
262 |
return isClosedM;
|
263 |
} |
264 |
|
265 |
public void setClosedM(boolean isClosedM) { |
266 |
this.isClosedM = isClosedM;
|
267 |
} |
268 |
|
269 |
public boolean isClosedN() { |
270 |
return isClosedN;
|
271 |
} |
272 |
|
273 |
public void setClosedN(boolean isClosedN) { |
274 |
this.isClosedN = isClosedN;
|
275 |
} |
276 |
|
277 |
public void setMDensity(int density) { |
278 |
this.mVerticies = density;
|
279 |
} |
280 |
|
281 |
public void setNDensity(int density) { |
282 |
this.nVerticies = density;
|
283 |
} |
284 |
|
285 |
public void addVertex(IDwgVertex vertex) { |
286 |
vertices.add(vertex.getPoint()); |
287 |
|
288 |
} |
289 |
|
290 |
public void transform2Block(double[] bPoint, Point2D insPoint, |
291 |
double[] scale, double rot, |
292 |
List dwgObjectsWithoutBlocks,
|
293 |
Map handleObjWithoutBlocks, DwgFile callBack) {
|
294 |
|
295 |
DwgPolyline3D transformedEntity = null;
|
296 |
List vertices = this.getVertices(); |
297 |
|
298 |
if (vertices != null) { |
299 |
List transformedVertices = new ArrayList(); |
300 |
for (int i=0;i < vertices.size();i++) { |
301 |
double[] pointAux = null; |
302 |
pointAux = new double[]{((double[]) vertices.get(i))[0] - bPoint[0], |
303 |
((double[]) vertices.get(i))[1] - bPoint[1]}; |
304 |
|
305 |
double laX = insPoint.getX() + ((pointAux[0] * scale[0])*Math.cos(rot) + (pointAux[1]*scale[1])*(-1)*Math.sin(rot)); |
306 |
double laY = insPoint.getY() + ((pointAux[0]*scale[0])*Math.sin(rot) + (pointAux[1]*scale[1])*Math.cos(rot)); |
307 |
double laZ = ((double[]) vertices.get(i))[2] - bPoint[2]; |
308 |
transformedVertices.add(new double[]{laX, laY, laZ}); |
309 |
}//for
|
310 |
transformedEntity = (DwgPolyline3D)this.clone();
|
311 |
transformedEntity.setPts(transformedVertices); |
312 |
dwgObjectsWithoutBlocks.add(transformedEntity); |
313 |
handleObjWithoutBlocks.put(new Integer(transformedEntity.getHandle().getOffset()), transformedEntity); |
314 |
} |
315 |
} |
316 |
} |
317 |
|