Revision 139 trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfFeatureMaker.java
DxfFeatureMaker.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected { |
26 | 26 |
IProjection proj = null; |
27 |
Feature lastFeature = null; |
|
27 |
//Feature lastFeature = null;
|
|
28 | 28 |
|
29 | 29 |
Feature lastFeaBordes = null; |
30 | 30 |
Feature lastFeaFondos = null; |
... | ... | |
74 | 74 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
75 | 75 |
LineString lineString = new LineString(); |
76 | 76 |
Polygon polygon = new Polygon(); |
77 |
Feature feature= new Feature(); |
|
77 |
//Feature feature= new Feature();
|
|
78 | 78 |
Feature feaBordes= new Feature(); |
79 | 79 |
Feature feaFondos= new Feature(); |
80 | 80 |
double x = 0.0, y = 0.0, z = 0.0; |
81 | 81 |
int flags = 0; |
82 | 82 |
|
83 |
feature.setProp("dxfEntity", "Polyline"); |
|
83 |
//feature.setProp("dxfEntity", "Polyline");
|
|
84 | 84 |
feaBordes.setProp("dxfEntity", "Polyline"); |
85 | 85 |
feaFondos.setProp("dxfEntity", "Polyline"); |
86 | 86 |
if (grp.hasCode(8)) { |
87 |
feature.setProp("layer", grp.getDataAsString(8)); |
|
87 |
//feature.setProp("layer", grp.getDataAsString(8));
|
|
88 | 88 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
89 | 89 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
90 | 90 |
} |
91 | 91 |
if (grp.hasCode(39)) { |
92 | 92 |
Double doub = new Double(grp.getDataAsDouble(39)); |
93 | 93 |
String string = doub.toString(); |
94 |
feature.setProp("thickness", string); |
|
94 |
//feature.setProp("thickness", string);
|
|
95 | 95 |
feaBordes.setProp("thickness", string); |
96 | 96 |
feaFondos.setProp("thickness", string); |
97 | 97 |
} else { |
98 | 98 |
Double doub = new Double(0.0); |
99 |
feature.setProp("thickness", doub.toString()); |
|
99 |
//feature.setProp("thickness", doub.toString());
|
|
100 | 100 |
feaBordes.setProp("thickness", doub.toString()); |
101 | 101 |
feaFondos.setProp("thickness", doub.toString()); |
102 | 102 |
} |
103 | 103 |
if (grp.hasCode(62)) { |
104 | 104 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
105 | 105 |
String string = integer.toString(); |
106 |
feature.setProp("color", string); |
|
106 |
//feature.setProp("color", string);
|
|
107 | 107 |
feaBordes.setProp("color", string); |
108 | 108 |
feaFondos.setProp("color", string); |
109 | 109 |
} else { |
... | ... | |
111 | 111 |
int clr = layer.colorNumber; |
112 | 112 |
Integer integer = new Integer(clr); |
113 | 113 |
String string = integer.toString(); |
114 |
feature.setProp("color", string); |
|
114 |
//feature.setProp("color", string);
|
|
115 | 115 |
feaBordes.setProp("color", string); |
116 | 116 |
feaFondos.setProp("color", string); |
117 | 117 |
} |
... | ... | |
123 | 123 |
z = grp.getDataAsDouble(30); |
124 | 124 |
Double doub = new Double(z); |
125 | 125 |
String string = doub.toString(); |
126 |
feature.setProp("elevation", string); |
|
126 |
//feature.setProp("elevation", string);
|
|
127 | 127 |
feaBordes.setProp("elevation", string); |
128 | 128 |
feaFondos.setProp("elevation", string); |
129 | 129 |
} |
... | ... | |
136 | 136 |
if (grp.hasCode(230)) |
137 | 137 |
xtruZ = grp.getDataAsDouble(230); |
138 | 138 |
if ((flags & 0x01) == 0x00) { |
139 |
feature.setGeometry(lineString); |
|
140 |
lastFeature = feature; |
|
141 |
lastFeature.setGeometry(lineString); |
|
139 |
feaBordes.setGeometry(lineString); |
|
140 |
lastFeaBordes = feaBordes; |
|
142 | 141 |
isDoubleFeatured = false; |
143 | 142 |
} else if ((flags & 0x01) == 0x01) { |
144 | 143 |
feaBordes.setGeometry(lineString); |
... | ... | |
175 | 174 |
} |
176 | 175 |
lastFeaBordes.setGeometry(lineString); |
177 | 176 |
lastFeaFondos.setGeometry(polygon); |
178 |
/*if (!(bulge==0)) { |
|
179 |
int cnt = polygon.pointNr(); |
|
180 |
Vector arc = createArc((Point2D)(polygon.get(cnt-2)), (Point2D)(polygon.get(cnt-1)), bulge); |
|
181 |
polygon.remove(cnt-1); |
|
182 |
for (int i=0; i<arc.size(); i++) { |
|
183 |
Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
|
184 |
polygon.add(pt); |
|
185 |
if (polygon.pointNr() == 1) firstPt = pt; |
|
186 |
} |
|
187 |
bulge = 0.0; |
|
188 |
} |
|
189 |
lastFeaFondos.setGeometry(polygon);*/ |
|
190 | 177 |
if (addingToBlock == false) { |
191 | 178 |
features.add(lastFeaBordes); |
192 | 179 |
features.add(lastFeaFondos); |
... | ... | |
197 | 184 |
lastFeaBordes = null; |
198 | 185 |
lastFeaFondos = null; |
199 | 186 |
} else { |
200 |
Feature feature = lastFeature; |
|
201 |
|
|
202 |
Geometry g = lastFeature.getGeometry(); |
|
203 |
System.out.println("feature = " + feature); |
|
204 |
System.out.println("feature.getGeometry() = " + feature.getGeometry()); |
|
205 |
|
|
206 |
LineString lineString = (LineString)feature.getGeometry(); |
|
187 |
Feature feaBordes = lastFeaBordes; |
|
188 |
LineString lineString = (LineString)feaBordes.getGeometry(); |
|
207 | 189 |
if (!(bulge==0)) { |
208 | 190 |
int cnt = lineString.pointNr(); |
209 | 191 |
Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge); |
... | ... | |
215 | 197 |
} |
216 | 198 |
bulge = 0.0; |
217 | 199 |
} |
218 |
lastFeature.setGeometry(lineString);
|
|
200 |
lastFeaBordes.setGeometry(lineString);
|
|
219 | 201 |
if (addingToBlock == false) { |
220 |
features.add(lastFeature);
|
|
202 |
features.add(lastFeaBordes);
|
|
221 | 203 |
} else { |
222 |
blk.add(lastFeature);
|
|
204 |
blk.add(lastFeaBordes);
|
|
223 | 205 |
} |
224 |
lastFeature = null;
|
|
206 |
lastFeaBordes = null;
|
|
225 | 207 |
} |
226 |
/*if (feature.getGeometry() instanceof LineString) { |
|
227 |
LineString lineString = (LineString)feature.getGeometry(); |
|
228 |
//lineString.add(firstPt); |
|
229 |
if (!(bulge==0)) { |
|
230 |
int cnt = lineString.pointNr(); |
|
231 |
Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge); |
|
232 |
lineString.remove(cnt-1); |
|
233 |
for (int i=0; i<arc.size(); i++) { |
|
234 |
Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
|
235 |
lineString.add(pt); |
|
236 |
if (lineString.pointNr() == 1) firstPt = pt; |
|
237 |
} |
|
238 |
bulge = 0.0; |
|
239 |
} |
|
240 |
lastFeature.setGeometry(lineString); |
|
241 |
} |
|
242 |
if (feature.getGeometry() instanceof Polygon) { |
|
243 |
Polygon polygon = (Polygon)feature.getGeometry(); |
|
244 |
polygon.add(firstPt); |
|
245 |
if (!(bulge==0)) { |
|
246 |
int cnt = polygon.pointNr(); |
|
247 |
Vector arc = createArc((Point2D)(polygon.get(cnt-2)), (Point2D)(polygon.get(cnt-1)), bulge); |
|
248 |
polygon.remove(cnt-1); |
|
249 |
for (int i=0; i<arc.size(); i++) { |
|
250 |
Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
|
251 |
polygon.add(pt); |
|
252 |
if (polygon.pointNr() == 1) firstPt = pt; |
|
253 |
} |
|
254 |
bulge = 0.0; |
|
255 |
} |
|
256 |
lastFeature.setGeometry(polygon); |
|
257 |
}*/ |
|
258 | 208 |
xtruX = 0.0; |
259 | 209 |
xtruY = 0.0; |
260 | 210 |
xtruZ = 1.0; |
... | ... | |
322 | 272 |
} |
323 | 273 |
bulge = bulge_aux; |
324 | 274 |
} |
325 |
/*if (bulge == 0.0) { |
|
326 |
if (grp.hasCode(42)) { |
|
327 |
bulge = grp.getDataAsDouble(42); |
|
328 |
} else { bulge = 0.0; } |
|
329 |
} else { |
|
330 |
double bulge_aux = 0.0; |
|
331 |
if (grp.hasCode(42)) { |
|
332 |
bulge_aux = grp.getDataAsDouble(42); |
|
333 |
} else { bulge_aux = 0.0; } |
|
334 |
int cnt = polygon.pointNr(); |
|
335 |
Vector arc = createArc((Point2D)(polygon.get(cnt-2)), (Point2D)(polygon.get(cnt-1)), bulge); |
|
336 |
polygon.remove(cnt-1); |
|
337 |
for (int i=0; i<arc.size(); i++) { |
|
338 |
pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
|
339 |
polygon.add(pt); |
|
340 |
if (polygon.pointNr() == 1) firstPt = pt; |
|
341 |
} |
|
342 |
bulge = bulge_aux; |
|
343 |
}*/ |
|
344 | 275 |
} else { |
345 |
Feature feature = lastFeature;
|
|
346 |
LineString lineString = (LineString)feature.getGeometry();
|
|
276 |
Feature feaBordes = lastFeaBordes;
|
|
277 |
LineString lineString = (LineString)feaBordes.getGeometry();
|
|
347 | 278 |
if (grp.hasCode(8)) |
348 |
feature.setProp("layer", grp.getDataAsString(8));
|
|
279 |
feaBordes.setProp("layer", grp.getDataAsString(8));
|
|
349 | 280 |
if (grp.hasCode(62)) { |
350 | 281 |
Integer integer = new Integer(grp.getDataAsInt(62)); |
351 | 282 |
String string = integer.toString(); |
352 |
feature.setProp("color", string);
|
|
283 |
feaBordes.setProp("color", string);
|
|
353 | 284 |
} else { |
354 | 285 |
DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8)); |
355 | 286 |
int clr = layer.colorNumber; |
356 | 287 |
Integer integer = new Integer(clr); |
357 | 288 |
String string = integer.toString(); |
358 |
feature.setProp("color", string);
|
|
289 |
feaBordes.setProp("color", string);
|
|
359 | 290 |
} |
360 | 291 |
x = grp.getDataAsDouble(10); |
361 | 292 |
y = grp.getDataAsDouble(20); |
Also available in: Unified diff