Revision 9825
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 |
|
|
9 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
10 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
|
11 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author alzabord |
|
15 |
* |
|
16 |
* TODO To change the template for this generated type comment go to |
|
17 |
* Window - Preferences - Java - Code Style - Code Templates |
|
18 |
*/ |
|
19 |
public class FMapUtil { |
|
20 |
/** |
|
21 |
* Method that changes a Point3D array to a FPolyline3D. Is useful to |
|
22 |
* convert a polyline given by it points to a FPolyline3D, a polyline 3D in |
|
23 |
* the FMap model object |
|
24 |
* |
|
25 |
* @param pts |
|
26 |
* Array of Point3D that defines the polyline 3D that will be |
|
27 |
* converted in a FPolyline3D |
|
28 |
* @return FPolyline3D This FPolyline3D is build using the array of Point3D |
|
29 |
* that is the argument of the method |
|
30 |
*/ |
|
31 |
public static FPolyline3D points3DToFPolyline3D(double[][] pts) { |
|
32 |
GeneralPathX genPathX = new GeneralPathX(); |
|
33 |
genPathX.moveTo(pts[0][0], pts[0][1]); |
|
34 |
for (int i = 1; i < pts.length; i++) { |
|
35 |
genPathX.lineTo(pts[i][0], pts[i][1]); |
|
36 |
} |
|
37 |
double[] elevations = new double[pts.length]; |
|
38 |
for (int i = 0; i < pts.length; i++) { |
|
39 |
elevations[i] = pts[i][2]; |
|
40 |
} |
|
41 |
return new FPolyline3D(genPathX, elevations); |
|
42 |
} |
|
43 |
/** |
|
44 |
* Method that changes a Point2D array to a FPolyline2D. Is useful to |
|
45 |
* convert a polyline given by it points to a FPolyline2D, a polyline in the |
|
46 |
* FMap model object |
|
47 |
* |
|
48 |
* @param pts |
|
49 |
* Array of Point2D that defines the polyline that will be |
|
50 |
* converted in a FPolyline2D |
|
51 |
* @return FPolyline2D This FPolyline2D is build using the array of Point2D |
|
52 |
* that is the argument of the method |
|
53 |
*/ |
|
54 |
public static FPolyline2D points2DToFPolyline2D(Point2D[] pts) { |
|
55 |
GeneralPathX genPathX = new GeneralPathX(); |
|
56 |
genPathX.moveTo(pts[0].getX(), pts[0].getY()); |
|
57 |
for (int i = 1; i < pts.length; i++) { |
|
58 |
genPathX.lineTo(pts[i].getX(), pts[i].getY()); |
|
59 |
} |
|
60 |
return new FPolyline2D(genPathX); |
|
61 |
} |
|
62 |
} |
|
0 | 63 |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgMText.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
43 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
41 | 44 |
|
42 | 45 |
/** |
43 | 46 |
* The DwgMText class represents a DWG MText |
44 | 47 |
* |
45 | 48 |
* @author jmorell |
46 | 49 |
*/ |
47 |
public class DwgMText extends DwgObject { |
|
50 |
public class DwgMText extends DwgObject |
|
51 |
implements IDwgExtrusionable, IDwg3DTestable { |
|
48 | 52 |
public DwgMText(int index) { |
49 | 53 |
super(index); |
50 | 54 |
// TODO Auto-generated constructor stub |
... | ... | |
349 | 353 |
public void setExtrusion(double[] extrusion) { |
350 | 354 |
this.extrusion = extrusion; |
351 | 355 |
} |
356 |
/* (non-Javadoc) |
|
357 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
358 |
*/ |
|
359 |
public void applyExtrussion() { |
|
360 |
double[] mtextPoint = getInsertionPoint(); |
|
361 |
double[] mtextExt = getExtrusion(); |
|
362 |
mtextPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(mtextPoint, mtextExt); |
|
363 |
setInsertionPoint(mtextPoint); |
|
364 |
} |
|
365 |
/* (non-Javadoc) |
|
366 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
367 |
*/ |
|
368 |
public boolean has3DData() { |
|
369 |
return (getInsertionPoint()[2] != 0.0); |
|
370 |
} |
|
352 | 371 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgCircle.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import java.awt.geom.Point2D; |
|
37 | 38 |
import java.util.ArrayList; |
38 | 39 |
import java.util.Vector; |
39 | 40 |
|
41 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
42 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
40 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 44 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
45 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
46 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
47 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
48 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
49 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
50 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
42 | 51 |
|
43 | 52 |
/** |
44 | 53 |
* The DwgCircle class represents a DWG Circle |
45 | 54 |
* |
46 | 55 |
* @author jmorell |
47 | 56 |
*/ |
48 |
public class DwgCircle extends DwgObject { |
|
57 |
public class DwgCircle extends DwgObject |
|
58 |
implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap{ |
|
49 | 59 |
public DwgCircle(int index) { |
50 | 60 |
super(index); |
51 | 61 |
// TODO Auto-generated constructor stub |
... | ... | |
186 | 196 |
public void setExtrusion(double[] extrusion) { |
187 | 197 |
this.extrusion = extrusion; |
188 | 198 |
} |
199 |
/* (non-Javadoc) |
|
200 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
201 |
*/ |
|
202 |
public void applyExtrussion() { |
|
203 |
double[] circleCenter = getCenter(); |
|
204 |
double[] circleExt = getExtrusion(); |
|
205 |
circleCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(circleCenter, circleExt); |
|
206 |
setCenter(circleCenter); |
|
207 |
} |
|
208 |
/* (non-Javadoc) |
|
209 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
210 |
*/ |
|
211 |
public boolean has3DData() { |
|
212 |
return (getCenter()[2]!= 0.0) ; |
|
213 |
} |
|
214 |
/* (non-Javadoc) |
|
215 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
216 |
*/ |
|
217 |
public double getZ() { |
|
218 |
return getCenter()[2]; |
|
219 |
} |
|
220 |
/* (non-Javadoc) |
|
221 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
222 |
*/ |
|
223 |
public FShape toFMapGeometry(boolean is3DFile) { |
|
224 |
FPolyline2D arcc; |
|
225 |
double[] c = getCenter(); |
|
226 |
Point2D center = new Point2D.Double(c[0], c[1]); |
|
227 |
double radius = getRadius(); |
|
228 |
Point2D[] arc = GisModelCurveCalculator |
|
229 |
.calculateGisModelCircle(center, radius); |
|
230 |
if (is3DFile) { |
|
231 |
double[][] arc3D = new double[arc.length][3]; |
|
232 |
for (int j = 0; j < arc.length; j++) { |
|
233 |
arc3D[j][0] = arc[j].getX(); |
|
234 |
arc3D[j][1] = arc[j].getY(); |
|
235 |
arc3D[j][2] = c[2]; |
|
236 |
} |
|
237 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
238 |
} else { |
|
239 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
240 |
} |
|
241 |
|
|
242 |
return arcc; |
|
243 |
} |
|
244 |
/* (non-Javadoc) |
|
245 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
246 |
*/ |
|
247 |
public String toFMapString(boolean is3DFile) { |
|
248 |
if(is3DFile) |
|
249 |
return "FPolyline3D"; |
|
250 |
else |
|
251 |
return "FPolyline2D"; |
|
252 |
} |
|
253 |
|
|
254 |
public String toString(){ |
|
255 |
return "Circle"; |
|
256 |
} |
|
189 | 257 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgBlockHeader.java | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 41 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
42 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 | 43 |
|
43 | 44 |
/** |
44 | 45 |
* The DwgBlockHeader class represents a DWG Block header |
45 | 46 |
* |
46 | 47 |
* @author jmorell |
47 | 48 |
*/ |
48 |
public class DwgBlockHeader extends DwgObject { |
|
49 |
public class DwgBlockHeader extends DwgObject implements IDwg3DTestable {
|
|
49 | 50 |
private String name; |
50 | 51 |
private boolean flag64; |
51 | 52 |
private int xRefPlus; |
... | ... | |
543 | 544 |
public void addObject(DwgObject object) { |
544 | 545 |
this.objects.add(object); |
545 | 546 |
} |
547 |
/* (non-Javadoc) |
|
548 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
549 |
*/ |
|
550 |
public boolean has3DData() { |
|
551 |
return (getBasePoint()[2] != 0.0); |
|
552 |
} |
|
546 | 553 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgInsert.java | ||
---|---|---|
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 | 37 |
import java.util.ArrayList; |
38 |
import java.util.Vector; |
|
39 | 38 |
|
40 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
43 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
42 | 44 |
|
43 | 45 |
/** |
44 | 46 |
* The DwgInsert class represents a DWG Insert |
45 | 47 |
* |
46 | 48 |
* @author jmorell |
47 | 49 |
*/ |
48 |
public class DwgInsert extends DwgObject { |
|
50 |
public class DwgInsert extends DwgObject |
|
51 |
implements IDwgExtrusionable, IDwg3DTestable { |
|
49 | 52 |
public DwgInsert(int index) { |
50 | 53 |
super(index); |
51 | 54 |
// TODO Auto-generated constructor stub |
... | ... | |
306 | 309 |
dwgInsert.setSeqendHandle(seqendHandle); |
307 | 310 |
return dwgInsert; |
308 | 311 |
} |
312 |
/* (non-Javadoc) |
|
313 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
314 |
*/ |
|
315 |
public void applyExtrussion() { |
|
316 |
double[] insertPoint = getInsertionPoint(); |
|
317 |
double[] insertExt = getExtrusion(); |
|
318 |
insertPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(insertPoint, insertExt); |
|
319 |
setInsertionPoint(insertPoint); |
|
320 |
} |
|
321 |
/* (non-Javadoc) |
|
322 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
323 |
*/ |
|
324 |
public boolean has3DData() { |
|
325 |
return (getInsertionPoint()[2] != 0.0); |
|
326 |
} |
|
309 | 327 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgArc.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import java.awt.geom.Point2D; |
|
37 | 38 |
import java.util.ArrayList; |
38 | 39 |
|
40 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
41 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
39 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 43 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
44 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
45 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
46 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
47 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
48 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
49 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
41 | 50 |
|
42 | 51 |
/** |
43 | 52 |
* The DwgArc class represents a DWG Arc |
44 | 53 |
* |
45 | 54 |
* @author jmorell |
46 | 55 |
*/ |
47 |
public class DwgArc extends DwgObject { |
|
56 |
public class DwgArc extends DwgObject |
|
57 |
implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap { |
|
48 | 58 |
|
49 | 59 |
private double[] center; |
50 | 60 |
private double radius; |
... | ... | |
224 | 234 |
public void setExtrusion(double[] extrusion) { |
225 | 235 |
this.extrusion = extrusion; |
226 | 236 |
} |
237 |
|
|
238 |
/* (non-Javadoc) |
|
239 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
240 |
*/ |
|
241 |
public void applyExtrussion() { |
|
242 |
double[] arcCenter = getCenter(); |
|
243 |
double[] arcExt = getExtrusion(); |
|
244 |
arcCenter = AcadExtrusionCalculator. |
|
245 |
CalculateAcadExtrusion(arcCenter, arcExt); |
|
246 |
setCenter(arcCenter); |
|
247 |
|
|
248 |
} |
|
249 |
|
|
250 |
/* (non-Javadoc) |
|
251 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
252 |
*/ |
|
253 |
public boolean has3DData() { |
|
254 |
return (getCenter()[2] != 0.0); |
|
255 |
} |
|
256 |
|
|
257 |
/* (non-Javadoc) |
|
258 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry() |
|
259 |
*/ |
|
260 |
public FShape toFMapGeometry(boolean is3DFile) { |
|
261 |
double[] c = getCenter(); |
|
262 |
Point2D center = new Point2D.Double(c[0], c[1]); |
|
263 |
double radius = getRadius(); |
|
264 |
double initAngle = Math.toDegrees(getInitAngle()); |
|
265 |
double endAngle = Math.toDegrees(getEndAngle()); |
|
266 |
Point2D[] arc = GisModelCurveCalculator.calculateGisModelArc( |
|
267 |
center, radius, initAngle, endAngle); |
|
268 |
FPolyline2D arcc; |
|
269 |
if (is3DFile) { |
|
270 |
double[][] arc3D = new double[arc.length][3]; |
|
271 |
for (int j = 0; j < arc.length; j++) { |
|
272 |
arc3D[j][0] = arc[j].getX(); |
|
273 |
arc3D[j][1] = arc[j].getY(); |
|
274 |
arc3D[j][2] = c[2]; |
|
275 |
} |
|
276 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
277 |
|
|
278 |
} else { |
|
279 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
280 |
} |
|
281 |
return arcc; |
|
282 |
} |
|
283 |
|
|
284 |
public String toString(){ |
|
285 |
return "Arc"; |
|
286 |
} |
|
287 |
|
|
288 |
/* (non-Javadoc) |
|
289 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString() |
|
290 |
*/ |
|
291 |
public String toFMapString(boolean is3dFile) { |
|
292 |
if(is3dFile) |
|
293 |
return "FPolyline3D"; |
|
294 |
else |
|
295 |
return "FPolyline2D"; |
|
296 |
} |
|
297 |
|
|
298 |
/* (non-Javadoc) |
|
299 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
300 |
*/ |
|
301 |
public double getZ() { |
|
302 |
return getCenter()[2]; |
|
303 |
} |
|
227 | 304 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgSolid.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
43 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
41 | 44 |
|
42 | 45 |
/** |
43 | 46 |
* The DwgSolid class represents a DWG Solid |
44 | 47 |
* |
45 | 48 |
* @author jmorell |
46 | 49 |
*/ |
47 |
public class DwgSolid extends DwgObject { |
|
50 |
public class DwgSolid extends DwgObject |
|
51 |
implements IDwgExtrusionable, IDwg3DTestable{ |
|
48 | 52 |
public DwgSolid(int index) { |
49 | 53 |
super(index); |
50 | 54 |
// TODO Auto-generated constructor stub |
... | ... | |
250 | 254 |
public void setExtrusion(double[] extrusion) { |
251 | 255 |
this.extrusion = extrusion; |
252 | 256 |
} |
257 |
/* (non-Javadoc) |
|
258 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
259 |
*/ |
|
260 |
public void applyExtrussion() { |
|
261 |
double[] corner1 = getCorner1(); |
|
262 |
double[] corner2 = getCorner2(); |
|
263 |
double[] corner3 = getCorner3(); |
|
264 |
double[] corner4 = getCorner4(); |
|
265 |
double[] solidExt = getExtrusion(); |
|
266 |
corner1 = AcadExtrusionCalculator.CalculateAcadExtrusion(corner1, solidExt); |
|
267 |
setCorner1(corner1); |
|
268 |
setCorner2(corner2); |
|
269 |
setCorner3(corner3); |
|
270 |
setCorner4(corner4); |
|
271 |
} |
|
272 |
/* (non-Javadoc) |
|
273 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
274 |
*/ |
|
275 |
public boolean has3DData() { |
|
276 |
return (getElevation() != 0.0); |
|
277 |
} |
|
253 | 278 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline2D.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 | 38 |
import java.util.ArrayList; |
39 |
import java.util.List; |
|
39 | 40 |
|
41 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
42 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
40 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 44 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
45 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
46 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
47 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
48 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
|
49 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
50 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
51 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
42 | 52 |
|
43 | 53 |
/** |
44 | 54 |
* The DwgPolyline2D class represents a DWG Polyline2D |
45 | 55 |
* |
46 | 56 |
* @author jmorell |
47 | 57 |
*/ |
48 |
public class DwgPolyline2D extends DwgObject { |
|
58 |
public class DwgPolyline2D extends DwgObject |
|
59 |
implements IDwgPolyline, IDwgExtrusionable, IDwg3DTestable, IDwg2FMap{ |
|
60 |
|
|
61 |
|
|
49 | 62 |
public DwgPolyline2D(int index) { |
50 | 63 |
super(index); |
51 | 64 |
// TODO Auto-generated constructor stub |
... | ... | |
337 | 350 |
dwgPolyline2D.setBulges(bulges); |
338 | 351 |
return dwgPolyline2D; |
339 | 352 |
} |
353 |
/* (non-Javadoc) |
|
354 |
* @see com.iver.cit.jdwglib.dwg.IDwgPolyline#calculateGisModel() |
|
355 |
*/ |
|
356 |
public void calculateGisModel(List dwgObjects) { |
|
357 |
int flags = getFlags(); |
|
358 |
int firstHandle = getFirstVertexHandle(); |
|
359 |
int lastHandle = getLastVertexHandle(); |
|
360 |
ArrayList pts = new ArrayList(); |
|
361 |
ArrayList bulges = new ArrayList(); |
|
362 |
double[] pt = new double[3]; |
|
363 |
|
|
364 |
//TODO Esto cambiarlo. Es lento y poco elegante |
|
365 |
|
|
366 |
for (int j=0;j<dwgObjects.size();j++) { |
|
367 |
DwgObject firstVertex = (DwgObject)dwgObjects.get(j); |
|
368 |
|
|
369 |
if (firstVertex instanceof DwgVertex2D) { |
|
370 |
int vertexHandle = firstVertex.getHandle(); |
|
371 |
if (vertexHandle==firstHandle) { |
|
372 |
int k=0; |
|
373 |
while (true) { |
|
374 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
375 |
int vHandle = vertex.getHandle(); |
|
376 |
if (vertex instanceof DwgVertex2D) { |
|
377 |
pt = ((DwgVertex2D)vertex).getPoint(); |
|
378 |
pts.add(new Point2D.Double(pt[0], pt[1])); |
|
379 |
double bulge = ((DwgVertex2D)vertex).getBulge(); |
|
380 |
bulges.add(new Double(bulge)); |
|
381 |
k++; |
|
382 |
if (vHandle==lastHandle && vertex instanceof DwgVertex2D) { |
|
383 |
break; |
|
384 |
} |
|
385 |
} else if (vertex instanceof DwgSeqend) { |
|
386 |
// 051116, jmorell: Polil?neas_ACAD2000.dwg tiene un DwgSeqend en mitad de |
|
387 |
//una secuencia de v?rtices. Precauci?n con esto puesto que es posible que esta |
|
388 |
// condici?n fuera requerida en la carga de otros DWGs. |
|
389 |
//break; |
|
390 |
k++; |
|
391 |
} |
|
392 |
}//while |
|
393 |
}//if first handle |
|
394 |
}//if |
|
395 |
}//for |
|
396 |
|
|
397 |
if (pts.size()>0) { |
|
398 |
Point2D[] newPts = new Point2D[pts.size()]; |
|
399 |
if ((flags & 0x1)==0x1) { |
|
400 |
newPts = new Point2D[pts.size()+1]; |
|
401 |
for (int j=0;j<pts.size();j++) { |
|
402 |
newPts[j] = (Point2D)pts.get(j); |
|
403 |
} |
|
404 |
newPts[pts.size()] = (Point2D)pts.get(0); |
|
405 |
bulges.add(new Double(0)); |
|
406 |
} else { |
|
407 |
for (int j=0;j<pts.size();j++) { |
|
408 |
newPts[j] = (Point2D)pts.get(j); |
|
409 |
} |
|
410 |
} |
|
411 |
double[] bs = new double[bulges.size()]; |
|
412 |
for (int j=0;j<bulges.size();j++) { |
|
413 |
bs[j] = ((Double)bulges.get(j)).doubleValue(); |
|
414 |
} |
|
415 |
setBulges(bs); |
|
416 |
Point2D[] points = GisModelCurveCalculator. |
|
417 |
calculateGisModelBulge(newPts, bs); |
|
418 |
setPts(points); |
|
419 |
} else { |
|
420 |
// System.out.println("Encontrada polil?nea sin puntos ..."); |
|
421 |
// TODO: No se debe mandar nunca una polil?nea sin puntos, si esto |
|
422 |
// ocurre es porque existe un error que hay que corregir ... |
|
423 |
} |
|
424 |
} |
|
425 |
/* (non-Javadoc) |
|
426 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
427 |
*/ |
|
428 |
public void applyExtrussion() { |
|
429 |
if(getPts() == null) |
|
430 |
return; |
|
431 |
Point2D[] vertices = getPts(); |
|
432 |
double[] polyline2DExt = getExtrusion(); |
|
433 |
double elev = getElevation(); |
|
434 |
double[][] polylinePoints3D = new double[vertices.length][3]; |
|
435 |
for (int j=0;j<vertices.length;j++) { |
|
436 |
polylinePoints3D[j][0] = vertices[j].getX(); |
|
437 |
polylinePoints3D[j][1] = vertices[j].getY(); |
|
438 |
polylinePoints3D[j][2] = elev; |
|
439 |
polylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(polylinePoints3D[j], polyline2DExt); |
|
440 |
} |
|
441 |
setElevation(elev); |
|
442 |
for (int j=0;j<vertices.length;j++) { |
|
443 |
vertices[j] = new Point2D.Double(polylinePoints3D[j][0], polylinePoints3D[j][1]); |
|
444 |
} |
|
445 |
setPts(vertices); |
|
446 |
} |
|
447 |
/* (non-Javadoc) |
|
448 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
449 |
*/ |
|
450 |
public boolean has3DData() { |
|
451 |
return (getElevation() != 0.0); |
|
452 |
} |
|
453 |
/* (non-Javadoc) |
|
454 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
455 |
*/ |
|
456 |
public double getZ() { |
|
457 |
return getElevation(); |
|
458 |
} |
|
459 |
/* (non-Javadoc) |
|
460 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
461 |
*/ |
|
462 |
public FShape toFMapGeometry(boolean is3DFile) { |
|
463 |
FPolyline2D pline = null; |
|
464 |
Point2D[] points = getPts(); |
|
465 |
double elev = getElevation(); |
|
466 |
|
|
467 |
if (points != null) { |
|
468 |
if (is3DFile) { |
|
469 |
double[][] pline3D = new double[points.length][3]; |
|
470 |
for (int j = 0; j < points.length; j++) { |
|
471 |
pline3D[j][0] = points[j].getX(); |
|
472 |
pline3D[j][1] = points[j].getY(); |
|
473 |
pline3D[j][2] = elev; |
|
474 |
} |
|
475 |
pline = FMapUtil.points3DToFPolyline3D(pline3D); |
|
476 |
} else { |
|
477 |
pline = FMapUtil.points2DToFPolyline2D(points); |
|
478 |
} |
|
479 |
} |
|
480 |
return pline; |
|
481 |
} |
|
482 |
/* (non-Javadoc) |
|
483 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
484 |
*/ |
|
485 |
public String toFMapString(boolean is3DFile) { |
|
486 |
if(is3DFile) |
|
487 |
return "FPolyline3D"; |
|
488 |
else |
|
489 |
return "FPolyline2D"; |
|
490 |
} |
|
491 |
|
|
492 |
public String toString(){ |
|
493 |
return "Polyline2D"; |
|
494 |
} |
|
340 | 495 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPolyline3D.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import java.awt.geom.Point2D; |
|
37 | 38 |
import java.util.ArrayList; |
39 |
import java.util.List; |
|
38 | 40 |
|
41 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
42 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
39 | 43 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 44 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
45 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
46 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
47 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
|
48 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
41 | 49 |
|
42 | 50 |
/** |
43 | 51 |
* The DwgPolyline3D class represents a DWG Polyline3D |
44 | 52 |
* |
45 | 53 |
* @author jmorell |
46 | 54 |
*/ |
47 |
public class DwgPolyline3D extends DwgObject { |
|
55 |
public class DwgPolyline3D extends DwgObject |
|
56 |
implements IDwgPolyline, IDwg3DTestable, IDwg2FMap{ |
|
48 | 57 |
public DwgPolyline3D(int index) { |
49 | 58 |
super(index); |
50 | 59 |
// TODO Auto-generated constructor stub |
... | ... | |
223 | 232 |
public void setSplineFlags(int splineFlags) { |
224 | 233 |
this.splineFlags = splineFlags; |
225 | 234 |
} |
235 |
/* (non-Javadoc) |
|
236 |
* @see com.iver.cit.jdwglib.dwg.IDwgPolyline#calculateGisModel(java.util.List) |
|
237 |
*/ |
|
238 |
public void calculateGisModel(List dwgObjects) { |
|
239 |
int closedFlags = getClosedFlags(); |
|
240 |
int firstHandle = getFirstVertexHandle(); |
|
241 |
int lastHandle = getLastVertexHandle(); |
|
242 |
ArrayList pts = new ArrayList(); |
|
243 |
double[] pt = new double[3]; |
|
244 |
|
|
245 |
//TODO Sustituir esto por un hashtable handle->DwgObject |
|
246 |
for (int j=0;j< dwgObjects.size();j++) { |
|
247 |
DwgObject firstVertex = (DwgObject)dwgObjects.get(j); |
|
248 |
if (firstVertex instanceof DwgVertex3D) { |
|
249 |
int vertexHandle = firstVertex.getHandle(); |
|
250 |
if (vertexHandle==firstHandle) { |
|
251 |
int k=0; |
|
252 |
while (true) { |
|
253 |
DwgObject vertex = (DwgObject)dwgObjects.get(j+k); |
|
254 |
int vHandle = vertex.getHandle(); |
|
255 |
if (vertex instanceof DwgVertex3D) { |
|
256 |
pt = ((DwgVertex3D)vertex).getPoint(); |
|
257 |
pts.add(new double[]{pt[0], pt[1], pt[2]}); |
|
258 |
k++; |
|
259 |
if (vHandle==lastHandle && vertex instanceof DwgVertex3D) { |
|
260 |
break; |
|
261 |
} |
|
262 |
} else if (vertex instanceof DwgSeqend) { |
|
263 |
break; |
|
264 |
}//if |
|
265 |
}//while |
|
266 |
}//if |
|
267 |
}//if |
|
268 |
}//for |
|
269 |
|
|
270 |
if (pts.size()>0) { |
|
271 |
double[][] newPts = new double[pts.size()][3]; |
|
272 |
if ((closedFlags & 0x1)==0x1) { |
|
273 |
newPts = new double[pts.size()+1][3]; |
|
274 |
for (int j=0;j<pts.size();j++) { |
|
275 |
newPts[j][0] = ((double[])pts.get(j))[0]; |
|
276 |
newPts[j][1] = ((double[])pts.get(j))[1]; |
|
277 |
newPts[j][2] = ((double[])pts.get(j))[2]; |
|
278 |
} |
|
279 |
newPts[pts.size()][0] = ((double[])pts.get(0))[0]; |
|
280 |
newPts[pts.size()][1] = ((double[])pts.get(0))[1]; |
|
281 |
newPts[pts.size()][2] = ((double[])pts.get(0))[2]; |
|
282 |
} else { |
|
283 |
for (int j=0;j<pts.size();j++) { |
|
284 |
newPts[j][0] = ((double[])pts.get(j))[0]; |
|
285 |
newPts[j][1] = ((double[])pts.get(j))[1]; |
|
286 |
newPts[j][2] = ((double[])pts.get(j))[2]; |
|
287 |
}//for |
|
288 |
}//if |
|
289 |
setPts(newPts); |
|
290 |
} else { |
|
291 |
// System.out.println("Encontrada polil?nea sin puntos ..."); |
|
292 |
// TODO: No se debe mandar nunca una polil?nea sin puntos, si esto |
|
293 |
// ocurre es porque existe un error que hay que corregir ... |
|
294 |
} |
|
295 |
} |
|
296 |
/* (non-Javadoc) |
|
297 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
298 |
*/ |
|
299 |
public boolean has3DData() { |
|
300 |
|
|
301 |
double[][] pts = getPts(); |
|
302 |
if(pts == null) |
|
303 |
return false; |
|
304 |
double z = 0d; |
|
305 |
for (int j = 0; j<pts.length; j++) { |
|
306 |
z = pts[j][2]; |
|
307 |
if (z != 0.0) |
|
308 |
return true; |
|
309 |
} |
|
310 |
return false; |
|
311 |
|
|
312 |
} |
|
313 |
/* (non-Javadoc) |
|
314 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
315 |
*/ |
|
316 |
public double getZ() { |
|
317 |
double[][] points3D = getPts(); |
|
318 |
if (points3D != null) { |
|
319 |
boolean constantElevation = true; |
|
320 |
for (int j = 0; j < points3D.length; j++) { |
|
321 |
if (points3D[j][2] != points3D[0][2]) { |
|
322 |
constantElevation = false; |
|
323 |
break; |
|
324 |
} |
|
325 |
} |
|
326 |
if (constantElevation) |
|
327 |
return points3D[0][2]; |
|
328 |
} |
|
329 |
return 0d; |
|
330 |
} |
|
331 |
/* (non-Javadoc) |
|
332 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
333 |
*/ |
|
334 |
public FShape toFMapGeometry(boolean is3DFile) { |
|
335 |
FPolyline2D pline = null; |
|
336 |
double[][] points3D = getPts(); |
|
337 |
if (points3D != null) { |
|
338 |
if (is3DFile) { |
|
339 |
double[][] pline3D = new double[points3D.length][3]; |
|
340 |
pline = FMapUtil.points3DToFPolyline3D(points3D); |
|
341 |
} else { |
|
342 |
Point2D[] points2D = new Point2D[points3D.length]; |
|
343 |
for (int j = 0; j < points3D.length; j++) { |
|
344 |
points2D[j] = new Point2D.Double(points3D[j][0], |
|
345 |
points3D[j][1]); |
|
346 |
} |
|
347 |
pline = FMapUtil.points2DToFPolyline2D(points2D); |
|
348 |
}//if |
|
349 |
}//if |
|
350 |
return pline; |
|
351 |
} |
|
352 |
/* (non-Javadoc) |
|
353 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
354 |
*/ |
|
355 |
public String toFMapString(boolean is3DFile) { |
|
356 |
if(is3DFile) |
|
357 |
return "FPolyline3D"; |
|
358 |
else |
|
359 |
return "FPolyline2D"; |
|
360 |
} |
|
361 |
|
|
362 |
public String toString(){ |
|
363 |
return "Polyline3D"; |
|
364 |
} |
|
226 | 365 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgText.java | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 41 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
42 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
43 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
44 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
42 | 45 |
import com.iver.cit.jdwglib.util.TextToUnicodeConverter; |
43 | 46 |
|
44 | 47 |
/** |
... | ... | |
46 | 49 |
* |
47 | 50 |
* @author jmorell |
48 | 51 |
*/ |
49 |
public class DwgText extends DwgObject { |
|
52 |
public class DwgText extends DwgObject |
|
53 |
implements IDwgExtrusionable, IDwg3DTestable { |
|
50 | 54 |
public DwgText(int index) { |
51 | 55 |
super(index); |
52 | 56 |
// TODO Auto-generated constructor stub |
... | ... | |
386 | 390 |
public void setExtrusion(double[] extrusion) { |
387 | 391 |
this.extrusion = extrusion; |
388 | 392 |
} |
393 |
/* (non-Javadoc) |
|
394 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
395 |
*/ |
|
396 |
public void applyExtrussion() { |
|
397 |
Point2D tpoint = getInsertionPoint(); |
|
398 |
double elev = getElevation(); |
|
399 |
double[] textPoint = new double[]{tpoint.getX(), tpoint.getY(), elev}; |
|
400 |
double[] textExt = getExtrusion(); |
|
401 |
textPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(textPoint, textExt); |
|
402 |
setInsertionPoint(new Point2D.Double(textPoint[0], textPoint[1])); |
|
403 |
setElevation(elev); |
|
404 |
} |
|
405 |
/* (non-Javadoc) |
|
406 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
407 |
*/ |
|
408 |
public boolean has3DData() { |
|
409 |
return (getElevation() !=0.0); |
|
410 |
} |
|
389 | 411 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgAttrib.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 | 38 |
import java.util.ArrayList; |
39 |
import java.util.Vector; |
|
40 | 39 |
|
41 | 40 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
42 | 41 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
42 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
43 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
44 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
43 | 45 |
|
44 | 46 |
/** |
45 | 47 |
* The DwgAttrib class represents a DWG Attrib |
46 | 48 |
* |
47 | 49 |
* @author jmorell |
48 | 50 |
*/ |
49 |
public class DwgAttrib extends DwgObject { |
|
51 |
public class DwgAttrib extends DwgObject |
|
52 |
implements IDwgExtrusionable, IDwg3DTestable{ |
|
50 | 53 |
public DwgAttrib(int index) { |
51 | 54 |
super(index); |
52 | 55 |
// TODO Auto-generated constructor stub |
... | ... | |
478 | 481 |
public void setExtrusion(double[] extrusion) { |
479 | 482 |
this.extrusion = extrusion; |
480 | 483 |
} |
484 |
/* (non-Javadoc) |
|
485 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
486 |
*/ |
|
487 |
public void applyExtrussion() { |
|
488 |
Point2D attribInsertionPoint = getInsertionPoint(); |
|
489 |
double attribElevation = getElevation(); |
|
490 |
double[] attribInsertionPoint3D = new double[]{ |
|
491 |
attribInsertionPoint.getX(), |
|
492 |
attribInsertionPoint.getY(), |
|
493 |
attribElevation}; |
|
494 |
double[] attribExt = getExtrusion(); |
|
495 |
attribInsertionPoint3D = AcadExtrusionCalculator. |
|
496 |
CalculateAcadExtrusion(attribInsertionPoint3D, attribExt); |
|
497 |
setInsertionPoint(new Point2D.Double(attribInsertionPoint3D[0], |
|
498 |
attribInsertionPoint3D[1])); |
|
499 |
setElevation(attribInsertionPoint3D[2]); |
|
500 |
} |
|
501 |
/* (non-Javadoc) |
|
502 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
503 |
*/ |
|
504 |
public boolean has3DData() { |
|
505 |
return (getElevation() != 0.0); |
|
506 |
} |
|
481 | 507 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLine.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
43 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
41 | 44 |
|
42 | 45 |
/** |
43 | 46 |
* The DwgLine class represents a DWG Line |
44 | 47 |
* |
45 | 48 |
* @author jmorell |
46 | 49 |
*/ |
47 |
public class DwgLine extends DwgObject { |
|
50 |
public class DwgLine extends DwgObject |
|
51 |
implements IDwgExtrusionable, IDwg3DTestable{ |
|
48 | 52 |
public DwgLine(int index) { |
49 | 53 |
super(index); |
50 | 54 |
// TODO Auto-generated constructor stub |
... | ... | |
217 | 221 |
public void setZflag(boolean zflag) { |
218 | 222 |
this.zflag = zflag; |
219 | 223 |
} |
224 |
/* (non-Javadoc) |
|
225 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
226 |
*/ |
|
227 |
public void applyExtrussion() { |
|
228 |
double[] lineP1 = getP1(); |
|
229 |
double[] lineP2 = getP2(); |
|
230 |
boolean zflag = isZflag(); |
|
231 |
if (zflag) { |
|
232 |
// elev = 0.0; |
|
233 |
lineP1 = new double[]{lineP1[0], lineP1[1], 0.0}; |
|
234 |
lineP2 = new double[]{lineP2[0], lineP2[1], 0.0}; |
|
235 |
} |
|
236 |
double[] lineExt = getExtrusion(); |
|
237 |
lineP1 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP1, lineExt); |
|
238 |
lineP2 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP2, lineExt); |
|
239 |
setP1(lineP1); |
|
240 |
setP2(lineP2); |
|
241 |
} |
|
242 |
/* (non-Javadoc) |
|
243 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
244 |
*/ |
|
245 |
public boolean has3DData() { |
|
246 |
if (!isZflag()) { |
|
247 |
double z1 = getP1()[2]; |
|
248 |
double z2 = getP2()[2]; |
|
249 |
if (z1!=0.0 || z2!=0.0) |
|
250 |
return true; |
|
251 |
}//TODO y si zflag vale true? REVISAR |
|
252 |
return false; |
|
253 |
} |
|
220 | 254 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgPoint.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
42 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
43 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
41 | 44 |
|
42 | 45 |
/** |
43 | 46 |
* The DwgPoint class represents a DWG Point |
44 | 47 |
* |
45 | 48 |
* @author jmorell |
46 | 49 |
*/ |
47 |
public class DwgPoint extends DwgObject { |
|
50 |
public class DwgPoint extends DwgObject |
|
51 |
implements IDwgExtrusionable, IDwg3DTestable{ |
|
48 | 52 |
public DwgPoint(int index) { |
49 | 53 |
super(index); |
50 | 54 |
// TODO Auto-generated constructor stub |
... | ... | |
186 | 190 |
dwgPoint.setExtrusion(extrusion); |
187 | 191 |
return dwgPoint; |
188 | 192 |
} |
193 |
/* (non-Javadoc) |
|
194 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
195 |
*/ |
|
196 |
public void applyExtrussion() { |
|
197 |
double[] point = getPoint(); |
|
198 |
double[] pointExt = getExtrusion(); |
|
199 |
point = AcadExtrusionCalculator.CalculateAcadExtrusion(point, pointExt); |
|
200 |
setPoint(point); |
|
201 |
} |
|
202 |
/* (non-Javadoc) |
|
203 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
204 |
*/ |
|
205 |
public boolean has3DData() { |
|
206 |
return getPoint()[2] != 0.0; |
|
207 |
} |
|
208 |
/* (non-Javadoc) |
|
209 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
210 |
*/ |
|
211 |
public double getZ() { |
|
212 |
return getPoint()[2]; |
|
213 |
} |
|
189 | 214 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgSpline.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 | 40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
41 | 42 |
|
42 | 43 |
/** |
43 | 44 |
* The DwgSpline class represents a DWG Spline |
44 | 45 |
* |
45 | 46 |
* @author jmorell |
46 | 47 |
*/ |
47 |
public class DwgSpline extends DwgObject { |
|
48 |
public class DwgSpline extends DwgObject implements IDwg3DTestable{
|
|
48 | 49 |
public DwgSpline(int index) { |
49 | 50 |
super(index); |
50 | 51 |
// TODO Auto-generated constructor stub |
... | ... | |
411 | 412 |
public void setWeights(double[] weights) { |
412 | 413 |
this.weights = weights; |
413 | 414 |
} |
415 |
/* (non-Javadoc) |
|
416 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
417 |
*/ |
|
418 |
public boolean has3DData() { |
|
419 |
double[][] pts = getControlPoints(); |
|
420 |
if(pts == null) |
|
421 |
return false; |
|
422 |
double z = 0d; |
|
423 |
for (int j=0;j<pts.length;j++) { |
|
424 |
z = pts[j][2]; |
|
425 |
if (z != 0.0) |
|
426 |
return true; |
|
427 |
}//for |
|
428 |
return false; |
|
429 |
} |
|
414 | 430 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgEllipse.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import java.awt.geom.Point2D; |
|
37 | 38 |
import java.util.ArrayList; |
38 |
import java.util.Vector; |
|
39 | 39 |
|
40 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
41 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
40 | 42 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 43 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
44 |
import com.iver.cit.jdwglib.dwg.IDwg2FMap; |
|
45 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
46 |
import com.iver.cit.jdwglib.util.FMapUtil; |
|
47 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
42 | 48 |
|
43 | 49 |
/** |
44 | 50 |
* The DwgEllipse class represents a DWG Ellipse |
45 | 51 |
* |
46 | 52 |
* @author jmorell |
47 | 53 |
*/ |
48 |
public class DwgEllipse extends DwgObject { |
|
54 |
public class DwgEllipse extends DwgObject |
|
55 |
implements IDwg3DTestable, IDwg2FMap{ |
|
49 | 56 |
public DwgEllipse(int index) { |
50 | 57 |
super(index); |
51 | 58 |
// TODO Auto-generated constructor stub |
... | ... | |
214 | 221 |
public void setExtrusion(double[] extrusion) { |
215 | 222 |
this.extrusion = extrusion; |
216 | 223 |
} |
224 |
/* (non-Javadoc) |
|
225 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
226 |
*/ |
|
227 |
public boolean has3DData() { |
|
228 |
return (getCenter()[2] !=0.0); |
|
229 |
} |
|
230 |
/* (non-Javadoc) |
|
231 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ() |
|
232 |
*/ |
|
233 |
public double getZ() { |
|
234 |
return getCenter()[2]; |
|
235 |
} |
|
236 |
/* (non-Javadoc) |
|
237 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
|
238 |
*/ |
|
239 |
public FShape toFMapGeometry(boolean is3DFile) { |
|
240 |
FPolyline2D arcc; |
|
241 |
double[] c = getCenter(); |
|
242 |
Point2D center = new Point2D.Double(c[0], c[1]); |
|
243 |
double[] majorAxisVector = getMajorAxisVector(); |
|
244 |
Point2D mav = new Point2D.Double(majorAxisVector[0], |
|
245 |
majorAxisVector[1]); |
|
246 |
double axisRatio = getAxisRatio(); |
|
247 |
double initAngle = Math.toDegrees(getInitAngle()); |
|
248 |
double endAngle = Math.toDegrees(getEndAngle()); |
|
249 |
Point2D[] arc = GisModelCurveCalculator |
|
250 |
.calculateGisModelEllipse(center, mav, axisRatio, |
|
251 |
initAngle, endAngle); |
|
252 |
if (is3DFile) { |
|
253 |
double[][] arc3D = new double[arc.length][3]; |
|
254 |
for (int j = 0; j < arc.length; j++) { |
|
255 |
arc3D[j][0] = arc[j].getX(); |
|
256 |
arc3D[j][1] = arc[j].getY(); |
|
257 |
arc3D[j][2] = c[2]; |
|
258 |
} |
|
259 |
arcc = FMapUtil.points3DToFPolyline3D(arc3D); |
|
260 |
} else { |
|
261 |
arcc = FMapUtil.points2DToFPolyline2D(arc); |
|
262 |
} |
|
263 |
return arcc; |
|
264 |
} |
|
265 |
|
|
266 |
/* (non-Javadoc) |
|
267 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
|
268 |
*/ |
|
269 |
public String toFMapString(boolean is3DFile) { |
|
270 |
if(is3DFile) |
|
271 |
return "FPolyline3D"; |
|
272 |
else |
|
273 |
return "FPolyline2D"; |
|
274 |
} |
|
275 |
|
|
276 |
public String toString(){ |
|
277 |
return "Ellipse"; |
|
278 |
} |
|
217 | 279 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLwPolyline.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
import java.awt.geom.Point2D; |
38 | 38 |
import java.util.ArrayList; |
39 |
import java.util.List; |
|
39 | 40 |
|
40 | 41 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
41 | 42 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
43 |
import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
|
44 |
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
|
45 |
import com.iver.cit.jdwglib.dwg.IDwgPolyline; |
|
46 |
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
|
47 |
import com.iver.cit.jdwglib.util.GisModelCurveCalculator; |
|
42 | 48 |
|
43 | 49 |
/** |
44 | 50 |
* The DwgLwPolyline class represents a DWG LwPolyline |
45 | 51 |
* |
46 | 52 |
* @author jmorell |
47 | 53 |
*/ |
48 |
public class DwgLwPolyline extends DwgObject { |
|
54 |
public class DwgLwPolyline extends DwgObject |
|
55 |
implements IDwgPolyline, IDwgExtrusionable, IDwg3DTestable{ |
|
49 | 56 |
public DwgLwPolyline(int index) { |
50 | 57 |
super(index); |
51 | 58 |
// TODO Auto-generated constructor stub |
... | ... | |
312 | 319 |
public void setNormal(double[] normal) { |
313 | 320 |
this.normal = normal; |
314 | 321 |
} |
322 |
/* (non-Javadoc) |
|
323 |
* @see com.iver.cit.jdwglib.dwg.IDwgPolyline#calculateGisModel(java.util.List) |
|
324 |
*/ |
|
325 |
public void calculateGisModel(List dwgObjs) { |
|
326 |
if (getVertices() == null) |
|
327 |
return; |
|
328 |
int flags = getFlag(); |
|
329 |
Point2D[] pts = getVertices(); |
|
330 |
double[] bulges = getBulges(); |
|
331 |
Point2D[] newPts = new Point2D[pts.length]; |
|
332 |
double[] newBulges = new double[bulges.length]; |
|
333 |
// TODO: Aqu? pueden existir casos no contemplados ... |
|
334 |
// System.out.println("flags = " + flags); |
|
335 |
if (flags==512 || flags==776 || flags==768) { |
|
336 |
newPts = new Point2D[pts.length+1]; |
|
337 |
newBulges = new double[bulges.length+1]; |
|
338 |
for (int j=0;j<pts.length;j++) { |
|
339 |
newPts[j] = (Point2D)pts[j]; |
|
340 |
} |
|
341 |
newPts[pts.length] = (Point2D)pts[0]; |
|
342 |
newBulges[pts.length] = 0; |
|
343 |
} else { |
|
344 |
for (int j=0;j<pts.length;j++) { |
|
345 |
newPts[j] = (Point2D)pts[j]; |
|
346 |
} |
|
347 |
} |
|
348 |
if (pts.length>0) { |
|
349 |
setBulges(newBulges); |
|
350 |
Point2D[] points = GisModelCurveCalculator.calculateGisModelBulge(newPts, newBulges); |
|
351 |
setVertices(points); |
|
352 |
} else { |
|
353 |
// System.out.println("Encontrada polil?nea sin puntos ..."); |
|
354 |
// TODO: No se debe mandar nunca una polil?nea sin puntos, si esto |
|
355 |
// ocurre es porque existe un error que hay que corregir ... |
|
356 |
} |
|
357 |
} |
|
358 |
/* (non-Javadoc) |
|
359 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
|
360 |
*/ |
|
361 |
public void applyExtrussion() { |
|
362 |
if (getVertices() == null) |
|
363 |
return; |
|
364 |
Point2D[] vertices = getVertices(); |
|
365 |
double[] lwPolylineExt = getNormal(); |
|
366 |
// Normals and Extrusions aren`t the same |
|
367 |
if (lwPolylineExt[0]==0 && lwPolylineExt[1]==0 && lwPolylineExt[2]==0) lwPolylineExt[2] = 1.0; |
|
368 |
double elev = getElevation(); |
|
369 |
double[][] lwPolylinePoints3D = new double[vertices.length][3]; |
|
370 |
for (int j=0;j<vertices.length;j++) { |
|
371 |
lwPolylinePoints3D[j][0] = vertices[j].getX(); |
|
372 |
lwPolylinePoints3D[j][1] = vertices[j].getY(); |
|
373 |
lwPolylinePoints3D[j][2] = elev; |
|
374 |
lwPolylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(lwPolylinePoints3D[j], lwPolylineExt); |
|
375 |
} |
|
376 |
setElevation(elev); |
|
377 |
for (int j=0;j<vertices.length;j++) { |
|
378 |
vertices[j] = new Point2D.Double(lwPolylinePoints3D[j][0], lwPolylinePoints3D[j][1]); |
|
379 |
} |
|
380 |
setVertices(vertices); |
|
381 |
} |
|
382 |
/* (non-Javadoc) |
|
383 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData() |
|
384 |
*/ |
|
385 |
public boolean has3DData() { |
|
386 |
return getElevation() != 0.0; |
|
387 |
} |
|
315 | 388 |
} |
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/IDwg2FMap.java | ||
---|---|---|
46 | 46 |
* |
47 | 47 |
* $Id$ |
48 | 48 |
* $Log$ |
49 |
* Revision 1.1 2007-01-12 19:29:58 azabala |
|
49 |
* Revision 1.2 2007-01-18 13:35:22 azabala |
|
50 |
* Refactoring general para evitar dar tantas pasadas en la carga, y para incrementar |
|
51 |
* la legibilidad del codigo (demasiados if-else-if en vez de usar polimorfismo) |
|
52 |
* |
|
53 |
* Revision 1.1 2007/01/12 19:29:58 azabala |
|
50 | 54 |
* first version in cvs |
51 | 55 |
* |
52 | 56 |
* |
53 | 57 |
*/ |
54 | 58 |
package com.iver.cit.jdwglib.dwg; |
55 | 59 |
|
56 |
import com.iver.cit.gvsig.fmap.core.IGeometry;
|
|
60 |
import com.iver.cit.gvsig.fmap.core.FShape;
|
|
57 | 61 |
|
58 | 62 |
/** |
59 | 63 |
* All dwg objects that are drawing entities |
60 | 64 |
* and that can be converted to a fmap geometry |
61 |
* implements this interface |
|
65 |
* implements this interface.
|
|
62 | 66 |
* |
67 |
* */ |
|
68 |
/* |
|
69 |
* TODO |
|
70 |
* Esta solucion tiene el problema de que es mas simple |
|
71 |
* (cada entidad dwg se ocupa de su conversion a fmap),pero acopla |
|
72 |
* libDwg con fmap |
|
73 |
* (una clase Dwg2FMap lo desacoplar?a, pero llenar?a el codigo de |
|
74 |
* infinitos if(dwg instanceof ...) else if..... |
|
63 | 75 |
* |
64 |
* |
|
65 | 76 |
* */ |
66 | 77 |
public interface IDwg2FMap { |
67 |
IGeometry toFMapGeometry(); |
|
78 |
public FShape toFMapGeometry(boolean is3DFile); |
|
79 |
public String toFMapString(boolean is3DFile); |
|
80 |
public String toString(); |
|
68 | 81 |
} |
69 | 82 |
|
trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/DwgFile.java | ||
---|---|---|
42 | 42 |
import java.nio.channels.FileChannel; |
43 | 43 |
import java.util.HashMap; |
44 | 44 |
import java.util.Iterator; |
45 |
import java.util.List; |
|
45 | 46 |
//import java.util.Vector; |
46 | 47 |
import java.util.ArrayList; |
47 | 48 |
|
... | ... | |
115 | 116 |
private String fileName; |
116 | 117 |
private String dwgVersion; |
117 | 118 |
|
119 |
/** |
|
120 |
* Offsets to the DWG sections |
|
121 |
*/ |
|
118 | 122 |
private ArrayList dwgSectionOffsets; |
119 | 123 |
|
120 | 124 |
/** |
... | ... | |
131 | 135 |
* */ |
132 | 136 |
private ArrayList dwgObjects; |
133 | 137 |
|
134 |
|
|
135 | 138 |
/** |
136 | 139 |
* Unused |
137 | 140 |
* */ |
138 | 141 |
private ArrayList dwgClasses; |
139 | 142 |
|
140 | 143 |
|
141 |
// private ArrayList layerTable; |
|
142 | 144 |
/** |
143 | 145 |
* hash map that indexes all DwgLayer objects |
144 | 146 |
* by its handle property |
145 | 147 |
* */ |
146 | 148 |
private HashMap layerTable; |
147 | 149 |
|
148 |
|
|
150 |
/** |
|
151 |
* Specific reader of the DWG file version (12, 13, 14, 2000, etc., each |
|
152 |
* version will have an specific reader) |
|
153 |
* */ |
|
149 | 154 |
private DwgFileReader dwgReader; |
150 | 155 |
private boolean dwg3DFile; |
151 | 156 |
|
... | ... | |
154 | 159 |
* */ |
155 | 160 |
private ByteBuffer bb; |
156 | 161 |
|
162 |
/* |
|
163 |
* Optimizaciones para evitar leer el fichero completo en cada |
|
164 |
* pasada. |
|
165 |
* */ |
|
157 | 166 |
/** |
167 |
* Contains all IDwgPolyline implementations |
|
168 |
* */ |
|
169 |
private List dwgPolylines; |
|
170 |
|
|
171 |
/** |
|
158 | 172 |
* Creates a new DwgFile object given the absolute path to |
159 | 173 |
* a DWG file |
160 | 174 |
* |
... | ... | |
402 | 416 |
* is necessary |
403 | 417 |
*/ |
404 | 418 |
public void applyExtrusions() { |
419 |
|
|
420 |
//TODO CREO QUE ESTO SE PUEDE HACER CONFORME SE VAN LEYENDO LOS |
|
421 |
//OBJETOS, SIN NECESIDAD DE UNA SEGUNDA PASADA |
|
422 |
|
|
405 | 423 |
for (int i=0;i<dwgObjects.size();i++) { |
406 | 424 |
DwgObject dwgObject = (DwgObject)dwgObjects.get(i); |
407 |
if (dwgObject instanceof DwgArc) { |
|
408 |
double[] arcCenter = ((DwgArc)dwgObject).getCenter(); |
|
409 |
double[] arcExt = ((DwgArc)dwgObject).getExtrusion(); |
|
410 |
arcCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(arcCenter, arcExt); |
|
411 |
((DwgArc)dwgObject).setCenter(arcCenter); |
|
412 |
} else if (dwgObject instanceof DwgAttdef) { |
|
413 |
// Extrusion in DwgAttdef is not necessary |
|
414 |
} else if (dwgObject instanceof DwgAttrib) { |
|
415 |
Point2D attribInsertionPoint = ((DwgAttrib)dwgObject).getInsertionPoint(); |
|
416 |
double attribElevation = ((DwgAttrib)dwgObject).getElevation(); |
|
417 |
double[] attribInsertionPoint3D = new double[]{attribInsertionPoint.getX(), attribInsertionPoint.getY(), attribElevation}; |
|
418 |
double[] attribExt = ((DwgAttrib)dwgObject).getExtrusion(); |
|
419 |
attribInsertionPoint3D = AcadExtrusionCalculator.CalculateAcadExtrusion(attribInsertionPoint3D, attribExt); |
|
420 |
((DwgAttrib)dwgObject).setInsertionPoint(new Point2D.Double(attribInsertionPoint3D[0], attribInsertionPoint3D[1])); |
|
421 |
((DwgAttrib)dwgObject).setElevation(attribInsertionPoint3D[2]); |
|
422 |
} else if (dwgObject instanceof DwgBlock) { |
|
423 |
// DwgBlock hasn't Extrusion |
|
424 |
} else if (dwgObject instanceof DwgBlockControl) { |
|
425 |
// DwgBlockControl hasn't Extrusion |
|
426 |
} else if (dwgObject instanceof DwgBlockHeader) { |
|
427 |
// DwgBlockHeader hasn't Extrusion |
|
428 |
} else if (dwgObject instanceof DwgCircle) { |
|
429 |
double[] circleCenter = ((DwgCircle)dwgObject).getCenter(); |
|
430 |
double[] circleExt = ((DwgCircle)dwgObject).getExtrusion(); |
|
431 |
circleCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(circleCenter, circleExt); |
|
432 |
((DwgCircle)dwgObject).setCenter(circleCenter); |
|
425 |
if(dwgObject instanceof IDwgExtrusionable){ |
|
426 |
((IDwgExtrusionable)dwgObject).applyExtrussion(); |
|
427 |
} |
|
428 |
|
|
433 | 429 |
// Seems that Autocad don't apply the extrusion to Ellipses |
434 | 430 |
/*} else if (dwgObject instanceof DwgEllipse) { |
435 | 431 |
double[] ellipseCenter = ((DwgEllipse)dwgObject).getCenter(); |
436 | 432 |
double[] ellipseExt = ((DwgEllipse)dwgObject).getExtrusion(); |
437 | 433 |
ellipseCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(ellipseCenter, ellipseExt); |
438 | 434 |
((DwgEllipse)dwgObject).setCenter(ellipseCenter);*/ |
439 |
} else if (dwgObject instanceof DwgInsert) { |
|
440 |
double[] insertPoint = ((DwgInsert)dwgObject).getInsertionPoint(); |
|
441 |
double[] insertExt = ((DwgInsert)dwgObject).getExtrusion(); |
|
442 |
insertPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(insertPoint, insertExt); |
|
443 |
((DwgInsert)dwgObject).setInsertionPoint(insertPoint); |
|
444 |
} else if (dwgObject instanceof DwgLayer) { |
|
445 |
// DwgLayer hasn't Extrusion |
|
446 |
} else if (dwgObject instanceof DwgLayerControl) { |
|
447 |
// DwgLayerControl hasn't Extrusion |
|
448 |
} else if (dwgObject instanceof DwgLine) { |
|
449 |
double[] lineP1 = ((DwgLine)dwgObject).getP1(); |
|
450 |
double[] lineP2 = ((DwgLine)dwgObject).getP2(); |
|
451 |
boolean zflag = ((DwgLine)dwgObject).isZflag(); |
|
452 |
if (zflag) { |
|
453 |
// elev = 0.0; |
|
454 |
lineP1 = new double[]{lineP1[0], lineP1[1], 0.0}; |
|
455 |
lineP2 = new double[]{lineP2[0], lineP2[1], 0.0}; |
|
456 |
} |
|
457 |
double[] lineExt = ((DwgLine)dwgObject).getExtrusion(); |
|
458 |
lineP1 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP1, lineExt); |
|
459 |
lineP2 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP2, lineExt); |
|
460 |
((DwgLine)dwgObject).setP1(lineP1); |
|
461 |
((DwgLine)dwgObject).setP2(lineP2); |
|
462 |
} else if (dwgObject instanceof DwgLinearDimension) { |
|
463 |
// TODO: Extrusions in DwgLinearDimension elements |
|
464 |
// TODO: Void LwPolylines are a bug |
|
465 |
} else if (dwgObject instanceof DwgLwPolyline && ((DwgLwPolyline)dwgObject).getVertices()!=null) { |
|
466 |
Point2D[] vertices = ((DwgLwPolyline)dwgObject).getVertices(); |
|
467 |
double[] lwPolylineExt = ((DwgLwPolyline)dwgObject).getNormal(); |
|
468 |
// Normals and Extrusions aren`t the same |
|
469 |
if (lwPolylineExt[0]==0 && lwPolylineExt[1]==0 && lwPolylineExt[2]==0) lwPolylineExt[2] = 1.0; |
|
470 |
double elev = ((DwgLwPolyline)dwgObject).getElevation(); |
|
471 |
double[][] lwPolylinePoints3D = new double[vertices.length][3]; |
|
472 |
for (int j=0;j<vertices.length;j++) { |
|
473 |
lwPolylinePoints3D[j][0] = vertices[j].getX(); |
|
474 |
lwPolylinePoints3D[j][1] = vertices[j].getY(); |
|
475 |
lwPolylinePoints3D[j][2] = elev; |
|
476 |
lwPolylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(lwPolylinePoints3D[j], lwPolylineExt); |
|
477 |
} |
|
478 |
((DwgLwPolyline)dwgObject).setElevation(elev); |
|
479 |
for (int j=0;j<vertices.length;j++) { |
|
480 |
vertices[j] = new Point2D.Double(lwPolylinePoints3D[j][0], lwPolylinePoints3D[j][1]); |
|
481 |
} |
|
482 |
((DwgLwPolyline)dwgObject).setVertices(vertices); |
|
483 |
} else if (dwgObject instanceof DwgMText) { |
|
484 |
double[] mtextPoint = ((DwgMText)dwgObject).getInsertionPoint(); |
|
485 |
double[] mtextExt = ((DwgMText)dwgObject).getExtrusion(); |
|
486 |
mtextPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(mtextPoint, mtextExt); |
|
487 |
((DwgMText)dwgObject).setInsertionPoint(mtextPoint); |
|
488 |
} else if (dwgObject instanceof DwgPoint) { |
|
489 |
double[] point = ((DwgPoint)dwgObject).getPoint(); |
|
490 |
double[] pointExt = ((DwgPoint)dwgObject).getExtrusion(); |
|
491 |
point = AcadExtrusionCalculator.CalculateAcadExtrusion(point, pointExt); |
|
492 |
((DwgPoint)dwgObject).setPoint(point); |
|
493 |
} else if (dwgObject instanceof DwgSolid) { |
|
494 |
double[] corner1 = ((DwgSolid)dwgObject).getCorner1(); |
|
495 |
double[] corner2 = ((DwgSolid)dwgObject).getCorner2(); |
|
496 |
double[] corner3 = ((DwgSolid)dwgObject).getCorner3(); |
|
497 |
double[] corner4 = ((DwgSolid)dwgObject).getCorner4(); |
|
498 |
double[] solidExt = ((DwgSolid)dwgObject).getExtrusion(); |
|
499 |
corner1 = AcadExtrusionCalculator.CalculateAcadExtrusion(corner1, solidExt); |
|
500 |
((DwgSolid)dwgObject).setCorner1(corner1); |
|
501 |
((DwgSolid)dwgObject).setCorner2(corner2); |
|
502 |
((DwgSolid)dwgObject).setCorner3(corner3); |
|
503 |
((DwgSolid)dwgObject).setCorner4(corner4); |
|
504 |
} else if (dwgObject instanceof DwgSpline) { |
|
505 |
// DwgSpline hasn't Extrusion |
|
506 |
} else if (dwgObject instanceof DwgText) { |
|
507 |
Point2D tpoint = ((DwgText)dwgObject).getInsertionPoint(); |
|
508 |
double elev = ((DwgText)dwgObject).getElevation(); |
|
509 |
double[] textPoint = new double[]{tpoint.getX(), tpoint.getY(), elev}; |
|
510 |
double[] textExt = ((DwgText)dwgObject).getExtrusion(); |
|
511 |
textPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(textPoint, textExt); |
|
512 |
((DwgText)dwgObject).setInsertionPoint(new Point2D.Double(textPoint[0], textPoint[1])); |
|
513 |
((DwgText)dwgObject).setElevation(elev); |
|
514 |
} else if (dwgObject instanceof DwgPolyline2D && ((DwgPolyline2D)dwgObject).getPts()!=null) { |
|
515 |
Point2D[] vertices = ((DwgPolyline2D)dwgObject).getPts(); |
|
516 |
double[] polyline2DExt = ((DwgPolyline2D)dwgObject).getExtrusion(); |
|
517 |
double elev = ((DwgPolyline2D)dwgObject).getElevation(); |
|
518 |
double[][] polylinePoints3D = new double[vertices.length][3]; |
|
519 |
for (int j=0;j<vertices.length;j++) { |
|
520 |
polylinePoints3D[j][0] = vertices[j].getX(); |
|
521 |
polylinePoints3D[j][1] = vertices[j].getY(); |
|
522 |
polylinePoints3D[j][2] = elev; |
|
523 |
polylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(polylinePoints3D[j], polyline2DExt); |
|
524 |
} |
|
525 |
((DwgPolyline2D)dwgObject).setElevation(elev); |
|
526 |
for (int j=0;j<vertices.length;j++) { |
|
527 |
vertices[j] = new Point2D.Double(polylinePoints3D[j][0], polylinePoints3D[j][1]); |
|
528 |
} |
|
529 |
((DwgPolyline2D)dwgObject).setPts(vertices); |
|
530 |
} else if (dwgObject instanceof DwgPolyline3D) { |
|
531 |
// DwgPolyline3D hasn't Extrusion |
|
532 |
} else if (dwgObject instanceof DwgVertex2D) { |
|
533 |
// DwgVertex2D hasn't Extrusion |
|
534 |
} else if (dwgObject instanceof DwgVertex3D) { |
|
535 |
// DwgVertex3D hasn't Extrusion |
|
536 |
} else { |
|
537 |
// |
|
538 |
} |
|
539 |
} |
|
435 |
}//for |
|
540 | 436 |
} |
541 | 437 |
|
542 | 438 |
/** |
Also available in: Unified diff