Debian Codegraph @

ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp

raw symbols SCIP
1 /******************************************************************************
2 *
3 * Project: DXF Translator
4 * Purpose: Implements translation support for HATCH elements as part
5 * of the OGRDXFLayer class.
6 * Author: Frank Warmerdam, [email protected]
7 *
8 ******************************************************************************
9 * Copyright (c) 2010, Frank Warmerdam <[email protected]>
10 * Copyright (c) 2011-2013, Even Rouault <even dot rouault at spatialys.com>
11 * Copyright (c) 2017, Alan Thomas <[email protected]>
12 *
13 * SPDX-License-Identifier: MIT
14 ****************************************************************************/
15
16 #include "ogr_dxf.h"cxx . . $ `<file>/ogr/ogrsf_frmts/dxf/ogr_dxf.h`/
17 #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/
18 #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/
19
20 #include <algorithm>
21 #include <cmath>
22 #include "ogrdxf_polyline_smooth.h"cxx . . $ `<file>/ogr/ogrsf_frmts/dxf/ogrdxf_polyline_smooth.h`/
23
24 /************************************************************************/
25 /* TranslateHATCH() */
26 /* */
27 /* We mostly just try to convert hatch objects as polygons or */
28 /* multipolygons representing the hatched area. It is hard to */
29 /* preserve the actual details of the hatching. */
30 /************************************************************************/
31
32 OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateHATCHcxx . . $ OGRDXFLayer#TranslateHATCH(e6624aae671b4354).()
33
34 {
35 char szLineBuf[257];
36 int nCode = 0;
37 OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature = new OGRDXFFeaturecxx . . $ OGRDXFFeature#OGRDXFFeature(dc2636911e7adfe).(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.);
38
39 double dfElevation = 0.0; // Z value to be used for EVERY point
40 OGRGeometryCollectioncxx . . $ OGRGeometryCollection# oGCcxx . . $ OGRGeometryCollection#OGRGeometryCollection(49f6e7a06ebc5aa8).;
41 stdcxx . . $ std/::string osExtendedData;
42
43 while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0)
44 {
45 switch (nCode)
46 {
47 case 30:
48 // Constant elevation.
49 dfElevation = CPLAtof(szLineBuf);
50 break;
51
52 case 70:
53 {
54 const int nFillFlag = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
55 poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."FillFlag"] =
56 nFillFlag ? "Filled" : "Pattern";
57 break;
58 }
59
60 case 2: // Hatch pattern name
61 poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Text", szLineBuf);
62 break;
63
64 case 91:
65 {
66 int nBoundaryPathCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
67
68 for (int iBoundary = 0; iBoundary < nBoundaryPathCount;
69 iBoundary++)
70 {
71 if (CollectBoundaryPathcxx . . $ OGRDXFLayer#CollectBoundaryPath(ac4b6aa35d63bbd6).(&oGC, dfElevation) != OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
72 break;
73 }
74 }
75 break;
76
77 case 52:
78 {
79 poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchPatternRotation"] = szLineBuf;
80 break;
81 }
82
83 case 41:
84 {
85 poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchPatternScale"] = szLineBuf;
86 break;
87 }
88
89 case 1001:
90 {
91 osExtendedData = szLineBuf;
92 break;
93 }
94
95 case 1071:
96 {
97 if (osExtendedData == "HATCHBACKGROUNDCOLOR")
98 poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchBackgroundColor"] =
99 szLineBuf;
100 break;
101 }
102
103 default:
104 TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature, nCode, szLineBuf);
105 break;
106 }
107 }
108 if (nCode < 0)
109 {
110 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
111 delete poFeature;
112 return nullptr;
113 }
114
115 if (nCode == 0)
116 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
117
118 /* -------------------------------------------------------------------- */
119 /* Obtain a tolerance value used when building the polygon. */
120 /* -------------------------------------------------------------------- */
121 double dfTolerance = poDScxx . . $ OGRDXFLayer#poDS.->HatchTolerancecxx . . $ OGRDXFDataSource#HatchTolerance(21b6c25e127938e2).();
122 if (dfTolerance < 0)
123 {
124 // If the configuration variable isn't set, compute the bounding box
125 // and work out a tolerance from that
126 OGREnvelope oEnvelope;
127 oGC.getEnvelopecxx . . $ OGRGeometryCollection#getEnvelope(e5217c1f2a4fd7ce).(&oEnvelope);
128 dfTolerance = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(oEnvelope.MaxX - oEnvelope.MinX,
129 oEnvelope.MaxY - oEnvelope.MinY) *
130 1e-7;
131 }
132
133 /* -------------------------------------------------------------------- */
134 /* Try to turn the set of lines into something useful. */
135 /* -------------------------------------------------------------------- */
136 OGRErr eErr;
137
138 auto poFinalGeom = stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>(
139 OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).(OGRBuildPolygonFromEdges(
140 OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).(&oGC), TRUEcxx . . $ `port/cpl_port.h:1184:9`!, TRUEcxx . . $ `port/cpl_port.h:1184:9`!, dfTolerance, &eErr)));
141 if (eErr != OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!)
142 {
143 auto poMLS = stdcxx . . $ std/::make_unique<OGRMultiLineStringcxx . . $ OGRMultiLineString#>();
144 for (int i = 0; i < oGC.getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).(); i++)
145 poMLS->addGeometrycxx . . $ OGRGeometryCollection#addGeometry(fed901b2566802ff).(oGC.getGeometryRefcxx . . $ OGRGeometryCollection#getGeometryRef(ea443ccec24c6360).(i));
146 poFinalGeom = stdcxx . . $ std/::move(poMLS);
147 }
148
149 poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poFinalGeom.get());
150 poFeature->SetGeometrycxx . . $ OGRFeature#SetGeometry(409c5ef120a740b2).(stdcxx . . $ std/::move(poFinalGeom));
151
152 PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).(poFeature);
153
154 return poFeature;
155 }
156
157 /************************************************************************/
158 /* CollectBoundaryPath() */
159 /************************************************************************/
160
161 OGRErr OGRDXFLayercxx . . $ OGRDXFLayer#::CollectBoundaryPathcxx . . $ OGRDXFLayer#CollectBoundaryPath(ac4b6aa35d63bbd6).(OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poGC,
162 const double dfElevation)
163
164 {
165 char szLineBuf[257];
166
167 /* -------------------------------------------------------------------- */
168 /* Read the boundary path type. */
169 /* -------------------------------------------------------------------- */
170 int nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
171 if (nCode != 92)
172 {
173 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
174 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
175 }
176
177 const int nBoundaryPathType = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
178
179 /* ==================================================================== */
180 /* Handle polyline loops. */
181 /* ==================================================================== */
182 if (nBoundaryPathType & 0x02)
183 return CollectPolylinePathcxx . . $ OGRDXFLayer#CollectPolylinePath(ac4b6aa35d63bbd6).(poGC, dfElevation);
184
185 /* ==================================================================== */
186 /* Handle non-polyline loops. */
187 /* ==================================================================== */
188
189 /* -------------------------------------------------------------------- */
190 /* Read number of edges. */
191 /* -------------------------------------------------------------------- */
192 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
193 if (nCode != 93)
194 {
195 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
196 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
197 }
198
199 const int nEdgeCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
200
201 /* -------------------------------------------------------------------- */
202 /* Loop reading edges. */
203 /* -------------------------------------------------------------------- */
204 for (int iEdge = 0; iEdge < nEdgeCount; iEdge++)
205 {
206 /* --------------------------------------------------------------------
207 */
208 /* Read the edge type. */
209 /* --------------------------------------------------------------------
210 */
211 const int ET_LINE = 1;
212 const int ET_CIRCULAR_ARC = 2;
213 const int ET_ELLIPTIC_ARC = 3;
214 const int ET_SPLINE = 4;
215
216 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
217 if (nCode != 72)
218 {
219 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
220 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
221 }
222
223 int nEdgeType = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
224
225 /* --------------------------------------------------------------------
226 */
227 /* Process a line edge. */
228 /* --------------------------------------------------------------------
229 */
230 if (nEdgeType == ET_LINE)
231 {
232 double dfStartX = 0.0;
233
234 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 10)
235 dfStartX = CPLAtof(szLineBuf);
236 else
237 break;
238
239 double dfStartY = 0.0;
240
241 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 20)
242 dfStartY = CPLAtof(szLineBuf);
243 else
244 break;
245
246 double dfEndX = 0.0;
247
248 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 11)
249 dfEndX = CPLAtof(szLineBuf);
250 else
251 break;
252
253 double dfEndY = 0.0;
254
255 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 21)
256 dfEndY = CPLAtof(szLineBuf);
257 else
258 break;
259
260 OGRLineStringcxx . . $ OGRLineString# *poLS = new OGRLineStringcxx . . $ OGRLineString#OGRLineString(49f6e7a06ebc5aa8).();
261
262 poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfStartX, dfStartY, dfElevation);
263 poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfEndX, dfEndY, dfElevation);
264
265 poGC->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poLS);
266 }
267 /* --------------------------------------------------------------------
268 */
269 /* Process a circular arc. */
270 /* --------------------------------------------------------------------
271 */
272 else if (nEdgeType == ET_CIRCULAR_ARC)
273 {
274 double dfCenterX = 0.0;
275
276 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 10)
277 dfCenterX = CPLAtof(szLineBuf);
278 else
279 break;
280
281 double dfCenterY = 0.0;
282
283 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 20)
284 dfCenterY = CPLAtof(szLineBuf);
285 else
286 break;
287
288 double dfRadius = 0.0;
289
290 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 40)
291 dfRadius = CPLAtof(szLineBuf);
292 else
293 break;
294
295 double dfStartAngle = 0.0;
296
297 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 50)
298 dfStartAngle = CPLAtof(szLineBuf);
299 else
300 break;
301
302 double dfEndAngle = 0.0;
303
304 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 51)
305 dfEndAngle = CPLAtof(szLineBuf);
306 else
307 break;
308
309 bool bCounterClockwise = false;
310
311 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 73)
312 bCounterClockwise = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) != 0;
313 else if (nCode >= 0)
314 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
315 else
316 break;
317
318 if (dfStartAngle > dfEndAngle)
319 dfEndAngle += 360.0;
320 if (bCounterClockwise)
321 {
322 dfStartAngle *= -1;
323 dfEndAngle *= -1;
324 }
325
326 if (fabscxx . . $ fabs(fee4f1d22bc8e617).(dfEndAngle - dfStartAngle) <= 361.0)
327 {
328 OGRGeometrycxx . . $ OGRGeometry# *poArc = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::approximateArcAnglescxx . . $ OGRGeometryFactory#approximateArcAngles(ad77857dadd20571).(
329 dfCenterX, dfCenterY, dfElevation, dfRadius, dfRadius, 0.0,
330 dfStartAngle, dfEndAngle, 0.0, poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).());
331
332 // If the input was 2D, we assume we want to keep it that way
333 if (dfElevation == 0.0)
334 poArc->flattenTo2Dcxx . . $ OGRGeometry#flattenTo2D(49f6e7a06ebc5aa8).();
335
336 poGC->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poArc);
337 }
338 else
339 {
340 // TODO: emit error ?
341 }
342 }
343
344 /* --------------------------------------------------------------------
345 */
346 /* Process an elliptical arc. */
347 /* --------------------------------------------------------------------
348 */
349 else if (nEdgeType == ET_ELLIPTIC_ARC)
350 {
351 double dfCenterX = 0.0;
352
353 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 10)
354 dfCenterX = CPLAtof(szLineBuf);
355 else
356 break;
357
358 double dfCenterY = 0.0;
359
360 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 20)
361 dfCenterY = CPLAtof(szLineBuf);
362 else
363 break;
364
365 double dfMajorX = 0.0;
366
367 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 11)
368 dfMajorX = CPLAtof(szLineBuf);
369 else
370 break;
371
372 double dfMajorY = 0.0;
373
374 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 21)
375 dfMajorY = CPLAtof(szLineBuf);
376 else
377 break;
378
379 double dfRatio = 0.0;
380
381 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 40)
382 dfRatio = CPLAtof(szLineBuf);
383 if (dfRatio == 0.0)
384 break;
385
386 double dfStartAngle = 0.0;
387
388 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 50)
389 dfStartAngle = CPLAtof(szLineBuf);
390 else
391 break;
392
393 double dfEndAngle = 0.0;
394
395 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 51)
396 dfEndAngle = CPLAtof(szLineBuf);
397 else
398 break;
399
400 bool bCounterClockwise = false;
401
402 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 73)
403 bCounterClockwise = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) != 0;
404 else if (nCode >= 0)
405 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
406 else
407 break;
408
409 if (dfStartAngle > dfEndAngle)
410 dfEndAngle += 360.0;
411 if (bCounterClockwise)
412 {
413 dfStartAngle *= -1;
414 dfEndAngle *= -1;
415 }
416
417 const double dfMajorRadius =
418 sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dfMajorX * dfMajorX + dfMajorY * dfMajorY);
419 const double dfMinorRadius = dfMajorRadius * dfRatio;
420
421 const double dfRotation =
422 -1 * atan2cxx . . $ atan2(b71928d39fde4295).(dfMajorY, dfMajorX) * 180 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!;
423
424 // The start and end angles are stored as circular angles. However,
425 // approximateArcAngles is expecting elliptical angles (what AutoCAD
426 // calls "parameters"), so let's transform them.
427 dfStartAngle =
428 180.0 * roundcxx . . $ round(fee4f1d22bc8e617).(dfStartAngle / 180) +
429 (fabscxx . . $ fabs(fee4f1d22bc8e617).(fmodcxx . . $ fmod(9454dda30a4b8335).(dfStartAngle, 180)) == 90
430 ? (stdcxx . . $ std/::signbit(dfStartAngle) ? 180 : -180)
431 : 0) +
432 atancxx . . $ atan(fee4f1d22bc8e617).((1.0 / dfRatio) * tancxx . . $ tan(fee4f1d22bc8e617).(dfStartAngle * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! / 180)) * 180 /
433 M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!;
434 dfEndAngle = 180.0 * roundcxx . . $ round(fee4f1d22bc8e617).(dfEndAngle / 180) +
435 (fabscxx . . $ fabs(fee4f1d22bc8e617).(fmodcxx . . $ fmod(9454dda30a4b8335).(dfEndAngle, 180)) == 90
436 ? (stdcxx . . $ std/::signbit(dfEndAngle) ? 180 : -180)
437 : 0) +
438 atancxx . . $ atan(fee4f1d22bc8e617).((1.0 / dfRatio) * tancxx . . $ tan(fee4f1d22bc8e617).(dfEndAngle * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! / 180)) *
439 180 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!;
440
441 if (fabscxx . . $ fabs(fee4f1d22bc8e617).(dfEndAngle - dfStartAngle) <= 361.0)
442 {
443 OGRGeometrycxx . . $ OGRGeometry# *poArc = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::approximateArcAnglescxx . . $ OGRGeometryFactory#approximateArcAngles(ad77857dadd20571).(
444 dfCenterX, dfCenterY, dfElevation, dfMajorRadius,
445 dfMinorRadius, dfRotation, dfStartAngle, dfEndAngle, 0.0,
446 poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).());
447
448 // If the input was 2D, we assume we want to keep it that way
449 if (dfElevation == 0.0)
450 poArc->flattenTo2Dcxx . . $ OGRGeometry#flattenTo2D(49f6e7a06ebc5aa8).();
451
452 poGC->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poArc);
453 }
454 else
455 {
456 // TODO: emit error ?
457 }
458 }
459
460 /* --------------------------------------------------------------------
461 */
462 /* Process an elliptical arc. */
463 /* --------------------------------------------------------------------
464 */
465 else if (nEdgeType == ET_SPLINE)
466 {
467 int nDegree = 3;
468
469 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 94)
470 nDegree = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
471 else
472 break;
473
474 // Skip a few things we don't care about
475 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) != 73)
476 break;
477 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) != 74)
478 break;
479
480 int nKnots = 0;
481
482 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 95)
483 nKnots = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
484 else
485 break;
486
487 int nControlPoints = 0;
488
489 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) == 96)
490 nControlPoints = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
491 else
492 break;
493
494 stdcxx . . $ std/::vector<double> adfKnots(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0);
495
496 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
497 if (nCode != 40)
498 break;
499
500 while (nCode == 40)
501 {
502 adfKnots.push_back(CPLAtof(szLineBuf));
503 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
504 }
505
506 stdcxx . . $ std/::vector<double> adfControlPoints(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0);
507 stdcxx . . $ std/::vector<double> adfWeights(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0);
508
509 if (nCode != 10)
510 break;
511
512 while (nCode == 10)
513 {
514 adfControlPoints.push_back(CPLAtof(szLineBuf));
515
516 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) ==
517 20)
518 {
519 adfControlPoints.push_back(CPLAtof(szLineBuf));
520 }
521 else
522 break;
523
524 adfControlPoints.push_back(0.0); // Z coordinate
525
526 // 42 (weights) are optional
527 if ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) ==
528 42)
529 {
530 adfWeights.push_back(CPLAtof(szLineBuf));
531 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
532 }
533 }
534
535 // Skip past the number of fit points
536 if (nCode != 97)
537 break;
538
539 // Eat the rest of this section, if present, until the next
540 // boundary segment (72) or the conclusion of the boundary data (97)
541 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
542 while (nCode > 0 && nCode != 72 && nCode != 97)
543 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
544 if (nCode > 0)
545 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
546
547 auto poLS =
548 InsertSplineWithCheckscxx . . $ OGRDXFLayer#InsertSplineWithChecks(f1ac5519f6c1de45).(nDegree, adfControlPoints,
549 /* bHaZ = */ false, nControlPoints,
550 adfKnots, nKnots, adfWeights);
551
552 if (!poLS)
553 {
554 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
555 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
556 }
557
558 poGC->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poLS.release());
559 }
560
561 else
562 {
563 CPLDebug("DXF", "Unsupported HATCH boundary line type:%d",
564 nEdgeType);
565 return OGRERR_UNSUPPORTED_OPERATIONcxx . . $ `ogr/ogr_core.h:394:9`!;
566 }
567 }
568
569 if (nCode < 0)
570 {
571 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
572 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
573 }
574
575 /* -------------------------------------------------------------------- */
576 /* Skip through source boundary objects if present. */
577 /* -------------------------------------------------------------------- */
578 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
579 if (nCode != 97)
580 {
581 if (nCode < 0)
582 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
583 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
584 }
585 else
586 {
587 int iObj, nObjCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
588
589 for (iObj = 0; iObj < nObjCount; iObj++)
590 {
591 if (poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf)) < 0)
592 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
593 }
594 }
595
596 return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!;
597 }
598
599 /************************************************************************/
600 /* CollectPolylinePath() */
601 /************************************************************************/
602
603 OGRErr OGRDXFLayercxx . . $ OGRDXFLayer#::CollectPolylinePathcxx . . $ OGRDXFLayer#CollectPolylinePath(ac4b6aa35d63bbd6).(OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poGC,
604 const double dfElevation)
605
606 {
607 int nCode = 0;
608 char szLineBuf[257];
609 DXFSmoothPolylinecxx . . $ DXFSmoothPolyline# oSmoothPolylinecxx . . $ DXFSmoothPolyline#DXFSmoothPolyline(49f6e7a06ebc5aa8).;
610 double dfBulge = 0.0;
611 double dfX = 0.0;
612 double dfY = 0.0;
613 bool bHaveX = false;
614 bool bHaveY = false;
615 bool bIsClosed = false;
616 int nVertexCount = -1;
617 bool bHaveBulges = false;
618
619 if (dfElevation != 0)
620 oSmoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(3);
621
622 /* -------------------------------------------------------------------- */
623 /* Read the boundary path type. */
624 /* -------------------------------------------------------------------- */
625 while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0)
626 {
627 if (nVertexCount > 0 && (int)oSmoothPolyline.sizecxx . . $ DXFSmoothPolyline#size(fe4d2d262d4164a8).() == nVertexCount)
628 break;
629
630 switch (nCode)
631 {
632 case 93:
633 nVertexCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
634 break;
635
636 case 72:
637 bHaveBulges = CPL_TO_BOOL(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf));
638 break;
639
640 case 73:
641 bIsClosed = CPL_TO_BOOL(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf));
642 break;
643
644 case 10:
645 if (bHaveX && bHaveY)
646 {
647 oSmoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfElevation, dfBulge);
648 dfBulge = 0.0;
649 bHaveY = false;
650 }
651 dfX = CPLAtof(szLineBuf);
652 bHaveX = true;
653 break;
654
655 case 20:
656 if (bHaveX && bHaveY)
657 {
658 oSmoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfElevation, dfBulge);
659 dfBulge = 0.0;
660 bHaveX = false;
661 }
662 dfY = CPLAtof(szLineBuf);
663 bHaveY = true;
664 if (bHaveX /* && bHaveY */ && !bHaveBulges)
665 {
666 oSmoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfElevation, dfBulge);
667 dfBulge = 0.0;
668 bHaveX = false;
669 bHaveY = false;
670 }
671 break;
672
673 case 42:
674 dfBulge = CPLAtof(szLineBuf);
675 if (bHaveX && bHaveY)
676 {
677 oSmoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfElevation, dfBulge);
678 dfBulge = 0.0;
679 bHaveX = false;
680 bHaveY = false;
681 }
682 break;
683
684 default:
685 break;
686 }
687 }
688 if (nCode < 0)
689 {
690 DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!();
691 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
692 }
693
694 if (nCode != 10 && nCode != 20 && nCode != 42)
695 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
696
697 if (bHaveX && bHaveY)
698 oSmoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfElevation, dfBulge);
699
700 if (bIsClosed)
701 oSmoothPolyline.Closecxx . . $ DXFSmoothPolyline#Close(49f6e7a06ebc5aa8).();
702
703 if (oSmoothPolyline.IsEmptycxx . . $ DXFSmoothPolyline#IsEmpty(50ce9a9e25b4a850).())
704 {
705 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
706 }
707
708 // Only process polylines with at least 2 vertices
709 if (nVertexCount >= 2)
710 {
711 oSmoothPolyline.SetUseMaxGapWhenTessellatingArcscxx . . $ DXFSmoothPolyline#SetUseMaxGapWhenTessellatingArcs(b45ddcbc8423892c).(poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).());
712 poGC->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(oSmoothPolyline.Tessellatecxx . . $ DXFSmoothPolyline#Tessellate(9bece52a439d3243).(false));
713 }
714
715 /* -------------------------------------------------------------------- */
716 /* Skip through source boundary objects if present. */
717 /* -------------------------------------------------------------------- */
718 nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf));
719 if (nCode != 97)
720 {
721 if (nCode < 0)
722 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
723 poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).();
724 }
725 else
726 {
727 int iObj, nObjCount = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf);
728
729 for (iObj = 0; iObj < nObjCount; iObj++)
730 {
731 if (poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf)) < 0)
732 return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!;
733 }
734 }
735 return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!;
736 }