| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: DXF Translator |
| 4 | * Purpose: Implements OGRDXFLayer class. |
| 5 | * Author: Frank Warmerdam, [email protected] |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2009, Frank Warmerdam <[email protected]> |
| 9 | * Copyright (c) 2011-2013, Even Rouault <even dot rouault at spatialys.com> |
| 10 | * Copyright (c) 2017-2020, Alan Thomas <[email protected]> |
| 11 | * |
| 12 | * SPDX-License-Identifier: MIT |
| 13 | ****************************************************************************/ |
| 14 | |
| 15 | #include "ogr_dxf.h"cxx . . $ `<file>/ogr/ogrsf_frmts/dxf/ogr_dxf.h`/ |
| 16 | #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/ |
| 17 | #include "ogrdxf_polyline_smooth.h"cxx . . $ `<file>/ogr/ogrsf_frmts/dxf/ogrdxf_polyline_smooth.h`/ |
| 18 | #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/ |
| 19 | |
| 20 | #include <cmath> |
| 21 | #include <algorithm> |
| 22 | #include <limits> |
| 23 | #include <stdexcept> |
| 24 | #include <memory> |
| 25 | |
| 26 | /************************************************************************/ |
| 27 | /* push() */ |
| 28 | /************************************************************************/ |
| 29 | |
| 30 | void OGRDXFFeatureQueuecxx . . $ OGRDXFFeatureQueue#::pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature) |
| 31 | { |
| 32 | apoFeaturescxx . . $ OGRDXFFeatureQueue#apoFeatures..pushcxx . . $ std/queue#push(5cd2eaf705c8bad3).(poFeature); |
| 33 | } |
| 34 | |
| 35 | /************************************************************************/ |
| 36 | /* pop() */ |
| 37 | /************************************************************************/ |
| 38 | |
| 39 | void OGRDXFFeatureQueuecxx . . $ OGRDXFFeatureQueue#::popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).() |
| 40 | { |
| 41 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(!apoFeatures.empty()); |
| 42 | apoFeaturescxx . . $ OGRDXFFeatureQueue#apoFeatures..popcxx . . $ std/queue#pop(49f6e7a06ebc5aa8).(); |
| 43 | } |
| 44 | |
| 45 | /************************************************************************/ |
| 46 | /* OGRDXFLayer() */ |
| 47 | /************************************************************************/ |
| 48 | |
| 49 | OGRDXFLayercxx . . $ OGRDXFLayer#::OGRDXFLayercxx . . $ OGRDXFLayer#OGRDXFLayer(8ad2815c52b45e68).(OGRDXFDataSourcecxx . . $ OGRDXFDataSource# *poDSIn) |
| 50 | : poDScxx . . $ OGRDXFLayer#poDS.(poDSIn), poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.(new OGRFeatureDefncxx . . $ OGRFeatureDefn#("entities")), iNextFIDcxx . . $ OGRDXFLayer#iNextFID.(0) |
| 51 | { |
| 52 | poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 53 | |
| 54 | int nModes = ODFM_Nonecxx . . $ ODFM_None.; |
| 55 | if (!poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).()) |
| 56 | nModes |= ODFM_IncludeBlockFieldscxx . . $ ODFM_IncludeBlockFields.; |
| 57 | if (poDScxx . . $ OGRDXFLayer#poDS.->ShouldIncludeRawCodeValuescxx . . $ OGRDXFDataSource#ShouldIncludeRawCodeValues(50ce9a9e25b4a850).()) |
| 58 | nModes |= ODFM_IncludeRawCodeValuescxx . . $ ODFM_IncludeRawCodeValues.; |
| 59 | if (poDScxx . . $ OGRDXFLayer#poDS.->In3DExtensibleModecxx . . $ OGRDXFDataSource#In3DExtensibleMode(50ce9a9e25b4a850).()) |
| 60 | nModes |= ODFM_Include3DModeFieldscxx . . $ ODFM_Include3DModeFields.; |
| 61 | OGRDXFDataSourcecxx . . $ OGRDXFDataSource#::AddStandardFieldscxx . . $ OGRDXFDataSource#AddStandardFields(41d46926725bb188).(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn., nModes); |
| 62 | |
| 63 | SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 64 | } |
| 65 | |
| 66 | /************************************************************************/ |
| 67 | /* ~OGRDXFLayer() */ |
| 68 | /************************************************************************/ |
| 69 | |
| 70 | OGRDXFLayercxx . . $ OGRDXFLayer#::~cxx . . $ OGRDXFLayer#`~OGRDXFLayer`(ced63f7c635d850d).OGRDXFLayercxx . . $ OGRDXFLayer#() |
| 71 | |
| 72 | { |
| 73 | ClearPendingFeaturescxx . . $ OGRDXFLayer#ClearPendingFeatures(49f6e7a06ebc5aa8).(); |
| 74 | if (m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead. > 0 && poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn. != nullptr) |
| 75 | { |
| 76 | CPLDebug("DXF", "%d features read on layer '%s'.", (int)m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead., |
| 77 | poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 78 | } |
| 79 | |
| 80 | if (poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.) |
| 81 | poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->Releasecxx . . $ OGRFeatureDefn#Release(49f6e7a06ebc5aa8).(); |
| 82 | } |
| 83 | |
| 84 | /************************************************************************/ |
| 85 | /* ClearPendingFeatures() */ |
| 86 | /************************************************************************/ |
| 87 | |
| 88 | void OGRDXFLayercxx . . $ OGRDXFLayer#::ClearPendingFeaturescxx . . $ OGRDXFLayer#ClearPendingFeatures(49f6e7a06ebc5aa8).() |
| 89 | |
| 90 | { |
| 91 | while (!apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 92 | { |
| 93 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature = apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).(); |
| 94 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 95 | delete poFeature; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /************************************************************************/ |
| 100 | /* ResetReading() */ |
| 101 | /************************************************************************/ |
| 102 | |
| 103 | void OGRDXFLayercxx . . $ OGRDXFLayer#::ResetReadingcxx . . $ OGRDXFLayer#ResetReading(49f6e7a06ebc5aa8).() |
| 104 | |
| 105 | { |
| 106 | iNextFIDcxx . . $ OGRDXFLayer#iNextFID. = 0; |
| 107 | ClearPendingFeaturescxx . . $ OGRDXFLayer#ClearPendingFeatures(49f6e7a06ebc5aa8).(); |
| 108 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 109 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 110 | poDScxx . . $ OGRDXFLayer#poDS.->RestartEntitiescxx . . $ OGRDXFDataSource#RestartEntities(49f6e7a06ebc5aa8).(); |
| 111 | } |
| 112 | |
| 113 | /************************************************************************/ |
| 114 | /* TranslateGenericProperty() */ |
| 115 | /* */ |
| 116 | /* Try and convert entity properties handled similarly for most */ |
| 117 | /* or all entity types. */ |
| 118 | /************************************************************************/ |
| 119 | |
| 120 | void OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature, int nCode, |
| 121 | char *pszValue) |
| 122 | |
| 123 | { |
| 124 | switch (nCode) |
| 125 | { |
| 126 | case 8: |
| 127 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Layer", TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(pszValue)); |
| 128 | break; |
| 129 | |
| 130 | case 100: |
| 131 | { |
| 132 | CPLString osSubClass = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("SubClasses"); |
| 133 | if (!osSubClass.empty()) |
| 134 | osSubClass += ":"; |
| 135 | osSubClass += pszValue; |
| 136 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("SubClasses", osSubClass.c_str()); |
| 137 | } |
| 138 | break; |
| 139 | |
| 140 | case 101: |
| 141 | // Embedded objects mark the end of meaningful DXF data |
| 142 | // See |
| 143 | // http://docs.autodesk.com/ACDMAC/2016/ENU/ObjectARX_Dev_Guide/files/GUID-C953866F-A335-4FFD-AE8C-256A76065552.htm |
| 144 | { |
| 145 | char szLineBuf[257]; |
| 146 | // Eat the rest of this entity |
| 147 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > |
| 148 | 0) |
| 149 | { |
| 150 | } |
| 151 | |
| 152 | if (nCode < 0) |
| 153 | { |
| 154 | // Let the entity reader function discover this error for |
| 155 | // itself |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nCode == 0); |
| 160 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 161 | } |
| 162 | break; |
| 163 | |
| 164 | case 60: |
| 165 | if (atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszValue)) |
| 166 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."Hidden"] = "1"; |
| 167 | break; |
| 168 | |
| 169 | case 67: |
| 170 | if (atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszValue)) |
| 171 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(34d26762b42c433a).("PaperSpace", 1); |
| 172 | break; |
| 173 | |
| 174 | case 62: |
| 175 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."Color"] = pszValue; |
| 176 | break; |
| 177 | |
| 178 | case 420: |
| 179 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."TrueColor"] = pszValue; |
| 180 | break; |
| 181 | |
| 182 | case 440: |
| 183 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."Transparency"] = pszValue; |
| 184 | break; |
| 185 | |
| 186 | case 6: |
| 187 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Linetype", TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(pszValue)); |
| 188 | break; |
| 189 | |
| 190 | case 48: |
| 191 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LinetypeScale"] = pszValue; |
| 192 | break; |
| 193 | |
| 194 | case 370: |
| 195 | case 39: |
| 196 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LineWeight"] = pszValue; |
| 197 | break; |
| 198 | |
| 199 | case 5: |
| 200 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("EntityHandle", pszValue); |
| 201 | break; |
| 202 | |
| 203 | // OCS vector. |
| 204 | case 210: |
| 205 | poFeature->oOCScxx . . $ OGRDXFFeature#oOCS..dfXcxx . . $ DXFTriple#dfX. = CPLAtof(pszValue); |
| 206 | break; |
| 207 | |
| 208 | case 220: |
| 209 | poFeature->oOCScxx . . $ OGRDXFFeature#oOCS..dfYcxx . . $ DXFTriple#dfY. = CPLAtof(pszValue); |
| 210 | break; |
| 211 | |
| 212 | case 230: |
| 213 | poFeature->oOCScxx . . $ OGRDXFFeature#oOCS..dfZcxx . . $ DXFTriple#dfZ. = CPLAtof(pszValue); |
| 214 | break; |
| 215 | |
| 216 | default: |
| 217 | if (poDScxx . . $ OGRDXFLayer#poDS.->ShouldIncludeRawCodeValuescxx . . $ OGRDXFDataSource#ShouldIncludeRawCodeValues(50ce9a9e25b4a850).()) |
| 218 | { |
| 219 | char **papszRawCodeValues = |
| 220 | poFeature->GetFieldAsStringListcxx . . $ OGRFeature#GetFieldAsStringList(e5c0a17ddea5f7b).("RawCodeValues"); |
| 221 | |
| 222 | papszRawCodeValues = CSLDuplicate(papszRawCodeValues); |
| 223 | |
| 224 | papszRawCodeValues = CSLAddString( |
| 225 | papszRawCodeValues, |
| 226 | CPLString() |
| 227 | .Printf("%d %s", nCode, TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(pszValue).c_str()) |
| 228 | .c_str()); |
| 229 | |
| 230 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(7bdc0c6e2c70929f).("RawCodeValues", papszRawCodeValues); |
| 231 | |
| 232 | CSLDestroy(papszRawCodeValues); |
| 233 | } |
| 234 | break; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /************************************************************************/ |
| 239 | /* PrepareFeatureStyle() */ |
| 240 | /* */ |
| 241 | /* - poBlockFeature: If this is not NULL, style properties on */ |
| 242 | /* poFeature with ByBlock values will be replaced with the */ |
| 243 | /* corresponding property from poBlockFeature. If this */ |
| 244 | /* parameter is supplied it is assumed that poFeature is a */ |
| 245 | /* clone, not an "original" feature object. */ |
| 246 | /************************************************************************/ |
| 247 | |
| 248 | void OGRDXFLayercxx . . $ OGRDXFLayer#::PrepareFeatureStylecxx . . $ OGRDXFLayer#PrepareFeatureStyle(7c5a60073ff99cd2).( |
| 249 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poFeature, |
| 250 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poBlockFeature /* = NULL */) |
| 251 | |
| 252 | { |
| 253 | const char *pszStyleString = poFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).(); |
| 254 | |
| 255 | if (pszStyleString && STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszStyleString, "BRUSH(")) |
| 256 | { |
| 257 | PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).(poFeature, poBlockFeature); |
| 258 | } |
| 259 | else if (pszStyleString && STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszStyleString, "LABEL(")) |
| 260 | { |
| 261 | // Find the new color of this feature, and replace it into |
| 262 | // the style string |
| 263 | const CPLString osNewColor = poFeature->GetColorcxx . . $ OGRDXFFeature#GetColor(6c955dda065cd6e3).(poDScxx . . $ OGRDXFLayer#poDS., poBlockFeature); |
| 264 | |
| 265 | CPLString osNewStyle = pszStyleString; |
| 266 | const size_t nColorStartPos = osNewStyle.rfind(",c:"); |
| 267 | if (nColorStartPos != stdcxx . . $ std/::string::npos) |
| 268 | { |
| 269 | const size_t nColorEndPos = |
| 270 | osNewStyle.find_first_of(",)", nColorStartPos + 3); |
| 271 | |
| 272 | if (nColorEndPos != stdcxx . . $ std/::string::npos) |
| 273 | { |
| 274 | osNewStyle.replace(nColorStartPos + 3, |
| 275 | nColorEndPos - (nColorStartPos + 3), |
| 276 | osNewColor); |
| 277 | poFeature->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(osNewStyle); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature, poBlockFeature); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /************************************************************************/ |
| 288 | /* PrepareBrushStyle() */ |
| 289 | /************************************************************************/ |
| 290 | |
| 291 | void OGRDXFLayercxx . . $ OGRDXFLayer#::PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).( |
| 292 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poFeature, |
| 293 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poBlockFeature /* = NULL */) |
| 294 | |
| 295 | { |
| 296 | CPLString osStyle = "BRUSH(fc:"; |
| 297 | const stdcxx . . $ std/::string osForegroundColor = |
| 298 | poFeature->GetColorcxx . . $ OGRDXFFeature#GetColor(6c955dda065cd6e3).(poDScxx . . $ OGRDXFLayer#poDS., poBlockFeature); |
| 299 | osStyle += osForegroundColor; |
| 300 | |
| 301 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("FillFlag") > 0 && |
| 302 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."FillFlag"] == "Pattern") |
| 303 | { |
| 304 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("HatchBackgroundColor") > 0) |
| 305 | { |
| 306 | unsigned nColor = static_cast<unsigned>( |
| 307 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchBackgroundColor"])); |
| 308 | if ((nColor >> 24) == 0xC3) |
| 309 | { |
| 310 | // Indexed color |
| 311 | nColor &= 0xFFFFFF; |
| 312 | if (nColor < 256) |
| 313 | { |
| 314 | const unsigned char *pabyDXFColors = ACGetColorTablecxx . . $ ACGetColorTable(ad8e97e14537000a).(); |
| 315 | |
| 316 | osStyle += CPLSPrintf(",bc:#%02x%02x%02x", |
| 317 | pabyDXFColors[nColor * 3 + 0], |
| 318 | pabyDXFColors[nColor * 3 + 1], |
| 319 | pabyDXFColors[nColor * 3 + 2]); |
| 320 | } |
| 321 | } |
| 322 | else if ((nColor >> 24) == 0xC2) |
| 323 | { |
| 324 | // True color |
| 325 | nColor &= 0xFFFFFF; |
| 326 | |
| 327 | osStyle += CPLSPrintf(",bc:#%06x", nColor); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | double dfRotation = 0.0; |
| 332 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("HatchPatternRotation") > 0) |
| 333 | { |
| 334 | dfRotation = |
| 335 | CPLAtof(poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchPatternRotation"]); |
| 336 | } |
| 337 | |
| 338 | const char *pszPatternName = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Text"); |
| 339 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszPatternName, "ANSI31")) |
| 340 | { |
| 341 | if (stdcxx . . $ std/::fabs(dfRotation - -45) < 1e-12 || |
| 342 | stdcxx . . $ std/::fabs(dfRotation - 315) < 1e-12) |
| 343 | { |
| 344 | osStyle += ",id:\"ogr-brush-2\""; |
| 345 | } |
| 346 | else if (stdcxx . . $ std/::fabs(dfRotation - 45) < 1e-12 || |
| 347 | stdcxx . . $ std/::fabs(dfRotation - 225) < 1e-12) |
| 348 | { |
| 349 | osStyle += ",id:\"ogr-brush-3\""; |
| 350 | } |
| 351 | else if (stdcxx . . $ std/::fabs(dfRotation - 90) < 1e-12 || |
| 352 | stdcxx . . $ std/::fabs(dfRotation - -90) < 1e-12 || |
| 353 | stdcxx . . $ std/::fabs(dfRotation - 270) < 1e-12) |
| 354 | { |
| 355 | osStyle += ",id:\"ogr-brush-4\""; |
| 356 | } |
| 357 | else if (stdcxx . . $ std/::fabs(dfRotation) < 1e-12) |
| 358 | { |
| 359 | osStyle += ",id:\"ogr-brush-5\""; |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | osStyle += ",id:\"ogr-brush-5\""; |
| 364 | osStyle += CPLSPrintf(",a:%f", dfRotation); |
| 365 | } |
| 366 | } |
| 367 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszPatternName, "ANSI37")) |
| 368 | { |
| 369 | if (stdcxx . . $ std/::fabs(dfRotation - 45) < 1e-12 || |
| 370 | stdcxx . . $ std/::fabs(dfRotation - 225) < 1e-12) |
| 371 | { |
| 372 | osStyle += ",id:\"ogr-brush-6\""; |
| 373 | } |
| 374 | else if (stdcxx . . $ std/::fabs(dfRotation) < 1e-12) |
| 375 | { |
| 376 | osStyle += ",id:\"ogr-brush-7\""; |
| 377 | } |
| 378 | else |
| 379 | { |
| 380 | osStyle += ",id:\"ogr-brush-7\""; |
| 381 | osStyle += CPLSPrintf(",a:%f", dfRotation); |
| 382 | } |
| 383 | } |
| 384 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszPatternName, "null")) |
| 385 | { |
| 386 | // NOTE: null is a totally made up name to express the intent |
| 387 | osStyle += ",id:\"ogr-brush-1\""; |
| 388 | } |
| 389 | |
| 390 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("HatchPatternScale") > 0) |
| 391 | { |
| 392 | const double dfScale = |
| 393 | CPLAtof(poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."HatchPatternScale"]); |
| 394 | if (stdcxx . . $ std/::fabs(dfScale - 1) > 1e-12) |
| 395 | { |
| 396 | osStyle += CPLSPrintf(",s:%f", dfScale); |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | else if (osForegroundColor == "#00000000") |
| 401 | { |
| 402 | osStyle += ",id:\"ogr-brush-1\""; |
| 403 | } |
| 404 | |
| 405 | osStyle += ")"; |
| 406 | |
| 407 | poFeature->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(osStyle); |
| 408 | } |
| 409 | |
| 410 | /************************************************************************/ |
| 411 | /* PrepareLineStyle() */ |
| 412 | /************************************************************************/ |
| 413 | |
| 414 | void OGRDXFLayercxx . . $ OGRDXFLayer#::PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).( |
| 415 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poFeature, |
| 416 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poBlockFeature /* = NULL */) |
| 417 | |
| 418 | { |
| 419 | const CPLString osLayer = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Layer"); |
| 420 | |
| 421 | /* -------------------------------------------------------------------- */ |
| 422 | /* Get line weight if available. */ |
| 423 | /* -------------------------------------------------------------------- */ |
| 424 | double dfWeight = 0.0; |
| 425 | CPLString osWeight = "-1"; |
| 426 | |
| 427 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("LineWeight") > 0) |
| 428 | osWeight = poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LineWeight"]; |
| 429 | |
| 430 | // Use ByBlock lineweight? |
| 431 | if (CPLAtof(osWeight) == -2 && poBlockFeature) |
| 432 | { |
| 433 | if (poBlockFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("LineWeight") > 0) |
| 434 | { |
| 435 | // Inherit lineweight from the owning block |
| 436 | osWeight = poBlockFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LineWeight"]; |
| 437 | |
| 438 | // Use the inherited lineweight if we regenerate the style |
| 439 | // string again during block insertion |
| 440 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LineWeight"] = osWeight; |
| 441 | } |
| 442 | else |
| 443 | { |
| 444 | // If the owning block has no explicit lineweight, |
| 445 | // assume ByLayer |
| 446 | osWeight = "-1"; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | // Use layer lineweight? |
| 451 | if (CPLAtof(osWeight) == -1) |
| 452 | { |
| 453 | auto osLayerLineWeight = |
| 454 | poDScxx . . $ OGRDXFLayer#poDS.->LookupLayerPropertycxx . . $ OGRDXFDataSource#LookupLayerProperty(d951f0804cb7b925).(osLayer, "LineWeight"); |
| 455 | osWeight = osLayerLineWeight ? *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).osLayerLineWeight : CPLString(); |
| 456 | } |
| 457 | |
| 458 | // Will be zero in the case of an invalid value |
| 459 | dfWeight = CPLAtof(osWeight) / 100.0; |
| 460 | |
| 461 | /* -------------------------------------------------------------------- */ |
| 462 | /* Do we have a dash/dot line style? */ |
| 463 | /* -------------------------------------------------------------------- */ |
| 464 | CPLString osLinetype = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Linetype"); |
| 465 | |
| 466 | // Use ByBlock line style? |
| 467 | if (!osLinetype.empty() && EQUALcxx . . $ `port/cpl_port.h:532:9`!(osLinetype, "ByBlock") && poBlockFeature) |
| 468 | { |
| 469 | osLinetype = poBlockFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Linetype"); |
| 470 | |
| 471 | // Use the inherited line style if we regenerate the style string |
| 472 | // again during block insertion |
| 473 | if (!osLinetype.empty()) |
| 474 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Linetype", osLinetype); |
| 475 | } |
| 476 | |
| 477 | // Use layer line style? |
| 478 | if (osLinetype.empty()) |
| 479 | { |
| 480 | auto osLayerLineType = poDScxx . . $ OGRDXFLayer#poDS.->LookupLayerPropertycxx . . $ OGRDXFDataSource#LookupLayerProperty(d951f0804cb7b925).(osLayer, "Linetype"); |
| 481 | if (osLayerLineType) |
| 482 | osLinetype = *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).osLayerLineType; |
| 483 | } |
| 484 | |
| 485 | const stdcxx . . $ std/::vector<double> oLineType = poDScxx . . $ OGRDXFLayer#poDS.->LookupLineTypecxx . . $ OGRDXFDataSource#LookupLineType(4ad212c1d2e9f284).(osLinetype); |
| 486 | |
| 487 | // Linetype scale is not inherited from the block feature |
| 488 | double dfLineTypeScale = CPLAtof(poDScxx . . $ OGRDXFLayer#poDS.->GetVariablecxx . . $ OGRDXFDataSource#GetVariable(1320557f0feba62c).("$LTSCALE", "1.0")); |
| 489 | if (poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties..countcxx . . $ std/map#count(ea780b5adf43227).("LinetypeScale") > 0) |
| 490 | dfLineTypeScale *= |
| 491 | CPLAtof(poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."LinetypeScale"]); |
| 492 | |
| 493 | CPLString osPattern; |
| 494 | for (stdcxx . . $ std/::vector<double>::const_iterator oIt = oLineType.begin(); |
| 495 | oIt != oLineType.end(); ++oIt) |
| 496 | { |
| 497 | // this is the format specifier %g followed by a literal 'g' |
| 498 | osPattern += |
| 499 | CPLString().Printf("%.11gg ", fabscxx . . $ fabs(fee4f1d22bc8e617).(*oIt) * dfLineTypeScale); |
| 500 | } |
| 501 | |
| 502 | if (osPattern.length() > 0) |
| 503 | osPattern.erase(osPattern.end() - 1); |
| 504 | |
| 505 | /* -------------------------------------------------------------------- */ |
| 506 | /* Format the style string. */ |
| 507 | /* -------------------------------------------------------------------- */ |
| 508 | |
| 509 | CPLString osStyle = "PEN(c:"; |
| 510 | osStyle += poFeature->GetColorcxx . . $ OGRDXFFeature#GetColor(6c955dda065cd6e3).(poDScxx . . $ OGRDXFLayer#poDS., poBlockFeature); |
| 511 | |
| 512 | if (dfWeight > 0.0) |
| 513 | { |
| 514 | char szBuffer[64]; |
| 515 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.2g", dfWeight); |
| 516 | osStyle += CPLString().Printf(",w:%sg", szBuffer); |
| 517 | } |
| 518 | |
| 519 | if (osPattern != "") |
| 520 | { |
| 521 | osStyle += ",p:\""; |
| 522 | osStyle += osPattern; |
| 523 | osStyle += "\""; |
| 524 | } |
| 525 | |
| 526 | osStyle += ")"; |
| 527 | |
| 528 | poFeature->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(osStyle); |
| 529 | } |
| 530 | |
| 531 | /************************************************************************/ |
| 532 | /* TextRecode() */ |
| 533 | /************************************************************************/ |
| 534 | |
| 535 | CPLString OGRDXFLayercxx . . $ OGRDXFLayer#::TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(const char *pszInput) |
| 536 | |
| 537 | { |
| 538 | return CPLString(pszInput).Recode(poDScxx . . $ OGRDXFLayer#poDS.->GetEncodingcxx . . $ OGRDXFDataSource#GetEncoding(33a1f659e94feb42).(), CPL_ENC_UTF8cxx . . $ `port/cpl_string.h:251:9`!); |
| 539 | } |
| 540 | |
| 541 | /************************************************************************/ |
| 542 | /* TextUnescape() */ |
| 543 | /* */ |
| 544 | /* Unexcape DXF style escape sequences such as \P for newline */ |
| 545 | /* and \~ for space, and do the recoding to UTF8. */ |
| 546 | /************************************************************************/ |
| 547 | |
| 548 | CPLString OGRDXFLayercxx . . $ OGRDXFLayer#::TextUnescapecxx . . $ OGRDXFLayer#TextUnescape(b291ddbdb582e104).(const char *pszInput, bool bIsMText) |
| 549 | |
| 550 | { |
| 551 | if (poDScxx . . $ OGRDXFLayer#poDS.->ShouldTranslateEscapescxx . . $ OGRDXFDataSource#ShouldTranslateEscapes(50ce9a9e25b4a850).()) |
| 552 | return ACTextUnescapecxx . . $ ACTextUnescape(1fdcccfd9ce54408).(pszInput, poDScxx . . $ OGRDXFLayer#poDS.->GetEncodingcxx . . $ OGRDXFDataSource#GetEncoding(33a1f659e94feb42).(), bIsMText); |
| 553 | |
| 554 | return TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(pszInput); |
| 555 | } |
| 556 | |
| 557 | /************************************************************************/ |
| 558 | /* TranslateMTEXT() */ |
| 559 | /************************************************************************/ |
| 560 | |
| 561 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateMTEXTcxx . . $ OGRDXFLayer#TranslateMTEXT(e6624aae671b4354).() |
| 562 | |
| 563 | { |
| 564 | char szLineBuf[512]; |
| 565 | int nCode = 0; |
| 566 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 567 | double dfX = 0.0; |
| 568 | double dfY = 0.0; |
| 569 | double dfZ = 0.0; |
| 570 | double dfAngle = 0.0; |
| 571 | double dfHeight = 0.0; |
| 572 | double dfXDirection = 0.0; |
| 573 | double dfYDirection = 0.0; |
| 574 | bool bHaveZ = false; |
| 575 | int nAttachmentPoint = -1; |
| 576 | CPLString osText; |
| 577 | CPLString osStyleName = "STANDARD"; |
| 578 | |
| 579 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 580 | { |
| 581 | switch (nCode) |
| 582 | { |
| 583 | case 10: |
| 584 | dfX = CPLAtof(szLineBuf); |
| 585 | break; |
| 586 | |
| 587 | case 20: |
| 588 | dfY = CPLAtof(szLineBuf); |
| 589 | break; |
| 590 | |
| 591 | case 30: |
| 592 | dfZ = CPLAtof(szLineBuf); |
| 593 | bHaveZ = true; |
| 594 | break; |
| 595 | |
| 596 | case 40: |
| 597 | dfHeight = CPLAtof(szLineBuf); |
| 598 | break; |
| 599 | |
| 600 | case 71: |
| 601 | nAttachmentPoint = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 602 | break; |
| 603 | |
| 604 | case 11: |
| 605 | dfXDirection = CPLAtof(szLineBuf); |
| 606 | break; |
| 607 | |
| 608 | case 21: |
| 609 | dfYDirection = CPLAtof(szLineBuf); |
| 610 | dfAngle = atan2cxx . . $ atan2(b71928d39fde4295).(dfYDirection, dfXDirection) * 180.0 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!; |
| 611 | break; |
| 612 | |
| 613 | case 1: |
| 614 | case 3: |
| 615 | osText += TextUnescapecxx . . $ OGRDXFLayer#TextUnescape(b291ddbdb582e104).(szLineBuf, true); |
| 616 | break; |
| 617 | |
| 618 | case 50: |
| 619 | dfAngle = CPLAtof(szLineBuf); |
| 620 | break; |
| 621 | |
| 622 | case 7: |
| 623 | osStyleName = TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(szLineBuf); |
| 624 | break; |
| 625 | |
| 626 | default: |
| 627 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 628 | break; |
| 629 | } |
| 630 | } |
| 631 | if (nCode < 0) |
| 632 | { |
| 633 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 634 | return nullptr; |
| 635 | } |
| 636 | |
| 637 | if (nCode == 0) |
| 638 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 639 | |
| 640 | OGRPointcxx . . $ OGRPoint# *poGeom = nullptr; |
| 641 | if (bHaveZ) |
| 642 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(98dd472ac7e5c3d4).(dfX, dfY, dfZ); |
| 643 | else |
| 644 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(bc12c9ec15586e6a).(dfX, dfY); |
| 645 | |
| 646 | /* We do NOT apply the OCS for MTEXT. See |
| 647 | * https://trac.osgeo.org/gdal/ticket/7049 */ |
| 648 | /* ApplyOCSTransformer( poGeom ); */ |
| 649 | |
| 650 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 651 | |
| 652 | /* -------------------------------------------------------------------- */ |
| 653 | /* Apply text after stripping off any extra terminating newline. */ |
| 654 | /* -------------------------------------------------------------------- */ |
| 655 | if (!osText.empty() && osText.back() == '\n') |
| 656 | osText.pop_back(); |
| 657 | |
| 658 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Text", osText); |
| 659 | |
| 660 | /* -------------------------------------------------------------------- */ |
| 661 | /* We need to escape double quotes with backslashes before they */ |
| 662 | /* can be inserted in the style string. */ |
| 663 | /* -------------------------------------------------------------------- */ |
| 664 | if (strchr(osText, '"') != nullptr) |
| 665 | { |
| 666 | stdcxx . . $ std/::string osEscaped; |
| 667 | |
| 668 | for (size_t iC = 0; iC < osText.size(); iC++) |
| 669 | { |
| 670 | if (osText[iC] == '"') |
| 671 | osEscaped += "\\\""; |
| 672 | else |
| 673 | osEscaped += osText[iC]; |
| 674 | } |
| 675 | osText = stdcxx . . $ std/::move(osEscaped); |
| 676 | } |
| 677 | |
| 678 | /* -------------------------------------------------------------------- */ |
| 679 | /* Prepare style string. */ |
| 680 | /* -------------------------------------------------------------------- */ |
| 681 | CPLString osStyle; |
| 682 | char szBuffer[64]; |
| 683 | |
| 684 | // Font name |
| 685 | osStyle.Printf("LABEL(f:\""); |
| 686 | |
| 687 | // Preserve legacy behavior of specifying "Arial" as a default font name. |
| 688 | osStyle += poDScxx . . $ OGRDXFLayer#poDS.->LookupTextStylePropertycxx . . $ OGRDXFDataSource#LookupTextStyleProperty(9e72f0106375db22).(osStyleName, "Font", "Arial"); |
| 689 | |
| 690 | osStyle += "\""; |
| 691 | |
| 692 | // Bold, italic |
| 693 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poDS->LookupTextStyleProperty(osStyleName, "Bold", "0"), "1")) |
| 694 | { |
| 695 | osStyle += ",bo:1"; |
| 696 | } |
| 697 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poDS->LookupTextStyleProperty(osStyleName, "Italic", "0"), "1")) |
| 698 | { |
| 699 | osStyle += ",it:1"; |
| 700 | } |
| 701 | |
| 702 | // Text string itself |
| 703 | osStyle += ",t:\""; |
| 704 | osStyle += osText; |
| 705 | osStyle += "\""; |
| 706 | |
| 707 | if (dfAngle != 0.0) |
| 708 | { |
| 709 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfAngle); |
| 710 | osStyle += CPLString().Printf(",a:%s", szBuffer); |
| 711 | } |
| 712 | |
| 713 | if (dfHeight != 0.0) |
| 714 | { |
| 715 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfHeight); |
| 716 | osStyle += CPLString().Printf(",s:%sg", szBuffer); |
| 717 | } |
| 718 | |
| 719 | const char *pszWidthFactor = |
| 720 | poDScxx . . $ OGRDXFLayer#poDS.->LookupTextStylePropertycxx . . $ OGRDXFDataSource#LookupTextStyleProperty(9e72f0106375db22).(osStyleName, "Width", "1"); |
| 721 | if (pszWidthFactor && CPLAtof(pszWidthFactor) != 1.0) |
| 722 | { |
| 723 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.4g", |
| 724 | CPLAtof(pszWidthFactor) * 100.0); |
| 725 | osStyle += CPLString().Printf(",w:%s", szBuffer); |
| 726 | } |
| 727 | |
| 728 | if (nAttachmentPoint >= 0 && nAttachmentPoint <= 9) |
| 729 | { |
| 730 | const static int anAttachmentMap[10] = {-1, 7, 8, 9, 4, 5, 6, 1, 2, 3}; |
| 731 | |
| 732 | osStyle += |
| 733 | CPLString().Printf(",p:%d", anAttachmentMap[nAttachmentPoint]); |
| 734 | } |
| 735 | |
| 736 | // Color |
| 737 | osStyle += ",c:"; |
| 738 | osStyle += poFeature->GetColorcxx . . $ OGRDXFFeature#GetColor(6c955dda065cd6e3).(poDScxx . . $ OGRDXFLayer#poDS.); |
| 739 | |
| 740 | osStyle += ")"; |
| 741 | |
| 742 | poFeature->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(osStyle); |
| 743 | |
| 744 | return poFeature.release(); |
| 745 | } |
| 746 | |
| 747 | /************************************************************************/ |
| 748 | /* TranslateTEXT() */ |
| 749 | /* */ |
| 750 | /* This function translates TEXT and ATTRIB entities, as well as */ |
| 751 | /* ATTDEF entities when we are not inlining blocks. */ |
| 752 | /************************************************************************/ |
| 753 | |
| 754 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateTEXTcxx . . $ OGRDXFLayer#TranslateTEXT(dbaf5f13b4270cb3).(const bool bIsAttribOrAttdef) |
| 755 | |
| 756 | { |
| 757 | char szLineBuf[257]; |
| 758 | int nCode = 0; |
| 759 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 760 | |
| 761 | double dfX = 0.0; |
| 762 | double dfY = 0.0; |
| 763 | double dfZ = 0.0; |
| 764 | bool bHaveZ = false; |
| 765 | |
| 766 | double dfAngle = 0.0; |
| 767 | double dfHeight = 0.0; |
| 768 | double dfWidthFactor = 1.0; |
| 769 | bool bHasAlignmentPoint = false; |
| 770 | double dfAlignmentPointX = 0.0; |
| 771 | double dfAlignmentPointY = 0.0; |
| 772 | |
| 773 | CPLString osText; |
| 774 | CPLString osStyleName = "STANDARD"; |
| 775 | |
| 776 | int nAnchorPosition = 1; |
| 777 | int nHorizontalAlignment = 0; |
| 778 | int nVerticalAlignment = 0; |
| 779 | |
| 780 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 781 | { |
| 782 | switch (nCode) |
| 783 | { |
| 784 | case 10: |
| 785 | dfX = CPLAtof(szLineBuf); |
| 786 | break; |
| 787 | |
| 788 | case 20: |
| 789 | dfY = CPLAtof(szLineBuf); |
| 790 | break; |
| 791 | |
| 792 | case 11: |
| 793 | dfAlignmentPointX = CPLAtof(szLineBuf); |
| 794 | break; |
| 795 | |
| 796 | case 21: |
| 797 | dfAlignmentPointY = CPLAtof(szLineBuf); |
| 798 | bHasAlignmentPoint = true; |
| 799 | break; |
| 800 | |
| 801 | case 30: |
| 802 | dfZ = CPLAtof(szLineBuf); |
| 803 | bHaveZ = true; |
| 804 | break; |
| 805 | |
| 806 | case 40: |
| 807 | dfHeight = CPLAtof(szLineBuf); |
| 808 | break; |
| 809 | |
| 810 | case 41: |
| 811 | dfWidthFactor = CPLAtof(szLineBuf); |
| 812 | break; |
| 813 | |
| 814 | case 1: |
| 815 | osText += TextUnescapecxx . . $ OGRDXFLayer#TextUnescape(b291ddbdb582e104).(szLineBuf, false); |
| 816 | break; |
| 817 | |
| 818 | case 50: |
| 819 | dfAngle = CPLAtof(szLineBuf); |
| 820 | break; |
| 821 | |
| 822 | case 72: |
| 823 | nHorizontalAlignment = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 824 | break; |
| 825 | |
| 826 | case 73: |
| 827 | if (!bIsAttribOrAttdef) |
| 828 | nVerticalAlignment = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 829 | break; |
| 830 | |
| 831 | case 74: |
| 832 | if (bIsAttribOrAttdef) |
| 833 | nVerticalAlignment = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 834 | break; |
| 835 | |
| 836 | case 7: |
| 837 | osStyleName = TextRecodecxx . . $ OGRDXFLayer#TextRecode(a9d72c988d85d6d8).(szLineBuf); |
| 838 | break; |
| 839 | |
| 840 | // 2 and 70 are for ATTRIB and ATTDEF entities only |
| 841 | case 2: |
| 842 | if (bIsAttribOrAttdef) |
| 843 | { |
| 844 | // Attribute tags are not supposed to contain spaces (but |
| 845 | // sometimes they do) |
| 846 | while (char *pchSpace = strchr(szLineBuf, ' ')) |
| 847 | *pchSpace = '_'; |
| 848 | |
| 849 | poFeature->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag. = szLineBuf; |
| 850 | } |
| 851 | break; |
| 852 | |
| 853 | case 70: |
| 854 | if (bIsAttribOrAttdef) |
| 855 | { |
| 856 | // When the LSB is set, this ATTRIB is "invisible" |
| 857 | if (atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) & 1) |
| 858 | poFeature->oStylePropertiescxx . . $ OGRDXFFeature#oStyleProperties.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3)."Hidden"] = "1"; |
| 859 | // If the next bit is set, this ATTDEF is to be preserved |
| 860 | // and treated as constant TEXT |
| 861 | else if (atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) & 2) |
| 862 | poFeature->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag..Clear(); |
| 863 | } |
| 864 | break; |
| 865 | |
| 866 | default: |
| 867 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 868 | break; |
| 869 | } |
| 870 | } |
| 871 | if (nCode < 0) |
| 872 | { |
| 873 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 874 | return nullptr; |
| 875 | } |
| 876 | |
| 877 | if (nCode == 0) |
| 878 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 879 | |
| 880 | OGRPointcxx . . $ OGRPoint# *poGeom = nullptr; |
| 881 | if (bHaveZ) |
| 882 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(98dd472ac7e5c3d4).(dfX, dfY, dfZ); |
| 883 | else |
| 884 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(bc12c9ec15586e6a).(dfX, dfY); |
| 885 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poGeom); |
| 886 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 887 | |
| 888 | /* -------------------------------------------------------------------- */ |
| 889 | /* Determine anchor position. */ |
| 890 | /* -------------------------------------------------------------------- */ |
| 891 | if (nHorizontalAlignment > 0 || nVerticalAlignment > 0) |
| 892 | { |
| 893 | switch (nVerticalAlignment) |
| 894 | { |
| 895 | case 1: // bottom |
| 896 | nAnchorPosition = 10; |
| 897 | break; |
| 898 | |
| 899 | case 2: // middle |
| 900 | nAnchorPosition = 4; |
| 901 | break; |
| 902 | |
| 903 | case 3: // top |
| 904 | nAnchorPosition = 7; |
| 905 | break; |
| 906 | |
| 907 | default: |
| 908 | // Handle "Middle" alignment approximately (this is rather like |
| 909 | // MTEXT alignment in that it uses the actual height of the text |
| 910 | // string to position the text, and thus requires knowledge of |
| 911 | // text metrics) |
| 912 | if (nHorizontalAlignment == 4) |
| 913 | nAnchorPosition = 5; |
| 914 | break; |
| 915 | } |
| 916 | if (nHorizontalAlignment < 3) |
| 917 | nAnchorPosition += nHorizontalAlignment; |
| 918 | // TODO other alignment options |
| 919 | } |
| 920 | |
| 921 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("Text", osText); |
| 922 | |
| 923 | /* -------------------------------------------------------------------- */ |
| 924 | /* We need to escape double quotes with backslashes before they */ |
| 925 | /* can be inserted in the style string. */ |
| 926 | /* -------------------------------------------------------------------- */ |
| 927 | if (strchr(osText, '"') != nullptr) |
| 928 | { |
| 929 | CPLString osEscaped; |
| 930 | |
| 931 | for (size_t iC = 0; iC < osText.size(); iC++) |
| 932 | { |
| 933 | if (osText[iC] == '"') |
| 934 | osEscaped += "\\\""; |
| 935 | else |
| 936 | osEscaped += osText[iC]; |
| 937 | } |
| 938 | osText = stdcxx . . $ std/::move(osEscaped); |
| 939 | } |
| 940 | |
| 941 | /* -------------------------------------------------------------------- */ |
| 942 | /* Prepare style string. */ |
| 943 | /* -------------------------------------------------------------------- */ |
| 944 | CPLString osStyle; |
| 945 | char szBuffer[64]; |
| 946 | |
| 947 | // Font name |
| 948 | osStyle.Printf("LABEL(f:\""); |
| 949 | |
| 950 | // Preserve legacy behavior of specifying "Arial" as a default font name. |
| 951 | osStyle += poDScxx . . $ OGRDXFLayer#poDS.->LookupTextStylePropertycxx . . $ OGRDXFDataSource#LookupTextStyleProperty(9e72f0106375db22).(osStyleName, "Font", "Arial"); |
| 952 | |
| 953 | osStyle += "\""; |
| 954 | |
| 955 | // Bold, italic |
| 956 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poDS->LookupTextStyleProperty(osStyleName, "Bold", "0"), "1")) |
| 957 | { |
| 958 | osStyle += ",bo:1"; |
| 959 | } |
| 960 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poDS->LookupTextStyleProperty(osStyleName, "Italic", "0"), "1")) |
| 961 | { |
| 962 | osStyle += ",it:1"; |
| 963 | } |
| 964 | |
| 965 | // Text string itself |
| 966 | osStyle += ",t:\""; |
| 967 | osStyle += osText; |
| 968 | osStyle += "\""; |
| 969 | |
| 970 | // Other attributes |
| 971 | osStyle += CPLString().Printf(",p:%d", nAnchorPosition); |
| 972 | |
| 973 | if (dfAngle != 0.0) |
| 974 | { |
| 975 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfAngle); |
| 976 | osStyle += CPLString().Printf(",a:%s", szBuffer); |
| 977 | } |
| 978 | |
| 979 | if (dfHeight != 0.0) |
| 980 | { |
| 981 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfHeight); |
| 982 | osStyle += CPLString().Printf(",s:%sg", szBuffer); |
| 983 | } |
| 984 | |
| 985 | if (dfWidthFactor != 1.0) |
| 986 | { |
| 987 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.4g", dfWidthFactor * 100.0); |
| 988 | osStyle += CPLString().Printf(",w:%s", szBuffer); |
| 989 | } |
| 990 | |
| 991 | if (bHasAlignmentPoint && dfAlignmentPointX != dfX) |
| 992 | { |
| 993 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.6g", |
| 994 | dfAlignmentPointX - dfX); |
| 995 | osStyle += CPLString().Printf(",dx:%sg", szBuffer); |
| 996 | } |
| 997 | |
| 998 | if (bHasAlignmentPoint && dfAlignmentPointY != dfY) |
| 999 | { |
| 1000 | CPLsnprintf(szBuffer, sizeof(szBuffer), "%.6g", |
| 1001 | dfAlignmentPointY - dfY); |
| 1002 | osStyle += CPLString().Printf(",dy:%sg", szBuffer); |
| 1003 | } |
| 1004 | |
| 1005 | // Color |
| 1006 | osStyle += ",c:"; |
| 1007 | osStyle += poFeature->GetColorcxx . . $ OGRDXFFeature#GetColor(6c955dda065cd6e3).(poDScxx . . $ OGRDXFLayer#poDS.); |
| 1008 | |
| 1009 | osStyle += ")"; |
| 1010 | |
| 1011 | poFeature->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(osStyle); |
| 1012 | |
| 1013 | return poFeature.release(); |
| 1014 | } |
| 1015 | |
| 1016 | /************************************************************************/ |
| 1017 | /* TranslatePOINT() */ |
| 1018 | /************************************************************************/ |
| 1019 | |
| 1020 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslatePOINTcxx . . $ OGRDXFLayer#TranslatePOINT(e6624aae671b4354).() |
| 1021 | |
| 1022 | { |
| 1023 | char szLineBuf[257]; |
| 1024 | int nCode = 0; |
| 1025 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1026 | double dfX = 0.0; |
| 1027 | double dfY = 0.0; |
| 1028 | double dfZ = 0.0; |
| 1029 | bool bHaveZ = false; |
| 1030 | |
| 1031 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1032 | { |
| 1033 | switch (nCode) |
| 1034 | { |
| 1035 | case 10: |
| 1036 | dfX = CPLAtof(szLineBuf); |
| 1037 | break; |
| 1038 | |
| 1039 | case 20: |
| 1040 | dfY = CPLAtof(szLineBuf); |
| 1041 | break; |
| 1042 | |
| 1043 | case 30: |
| 1044 | dfZ = CPLAtof(szLineBuf); |
| 1045 | bHaveZ = true; |
| 1046 | break; |
| 1047 | |
| 1048 | default: |
| 1049 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1050 | break; |
| 1051 | } |
| 1052 | } |
| 1053 | if (nCode < 0) |
| 1054 | { |
| 1055 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1056 | return nullptr; |
| 1057 | } |
| 1058 | |
| 1059 | if (nCode == 0) |
| 1060 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1061 | |
| 1062 | OGRPointcxx . . $ OGRPoint# *poGeom = nullptr; |
| 1063 | if (bHaveZ) |
| 1064 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(98dd472ac7e5c3d4).(dfX, dfY, dfZ); |
| 1065 | else |
| 1066 | poGeom = new OGRPointcxx . . $ OGRPoint#OGRPoint(bc12c9ec15586e6a).(dfX, dfY); |
| 1067 | |
| 1068 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 1069 | |
| 1070 | // Set style pen color |
| 1071 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1072 | |
| 1073 | return poFeature.release(); |
| 1074 | } |
| 1075 | |
| 1076 | /************************************************************************/ |
| 1077 | /* TranslateLINE() */ |
| 1078 | /************************************************************************/ |
| 1079 | |
| 1080 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateLINEcxx . . $ OGRDXFLayer#TranslateLINE(e6624aae671b4354).() |
| 1081 | |
| 1082 | { |
| 1083 | char szLineBuf[257]; |
| 1084 | int nCode = 0; |
| 1085 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1086 | double dfX1 = 0.0; |
| 1087 | double dfY1 = 0.0; |
| 1088 | double dfZ1 = 0.0; |
| 1089 | double dfX2 = 0.0; |
| 1090 | double dfY2 = 0.0; |
| 1091 | double dfZ2 = 0.0; |
| 1092 | bool bHaveZ = false; |
| 1093 | |
| 1094 | /* -------------------------------------------------------------------- */ |
| 1095 | /* Process values. */ |
| 1096 | /* -------------------------------------------------------------------- */ |
| 1097 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1098 | { |
| 1099 | switch (nCode) |
| 1100 | { |
| 1101 | case 10: |
| 1102 | dfX1 = CPLAtof(szLineBuf); |
| 1103 | break; |
| 1104 | |
| 1105 | case 11: |
| 1106 | dfX2 = CPLAtof(szLineBuf); |
| 1107 | break; |
| 1108 | |
| 1109 | case 20: |
| 1110 | dfY1 = CPLAtof(szLineBuf); |
| 1111 | break; |
| 1112 | |
| 1113 | case 21: |
| 1114 | dfY2 = CPLAtof(szLineBuf); |
| 1115 | break; |
| 1116 | |
| 1117 | case 30: |
| 1118 | dfZ1 = CPLAtof(szLineBuf); |
| 1119 | bHaveZ = true; |
| 1120 | break; |
| 1121 | |
| 1122 | case 31: |
| 1123 | dfZ2 = CPLAtof(szLineBuf); |
| 1124 | bHaveZ = true; |
| 1125 | break; |
| 1126 | |
| 1127 | default: |
| 1128 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1129 | break; |
| 1130 | } |
| 1131 | } |
| 1132 | if (nCode < 0) |
| 1133 | { |
| 1134 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1135 | return nullptr; |
| 1136 | } |
| 1137 | |
| 1138 | if (nCode == 0) |
| 1139 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1140 | |
| 1141 | /* -------------------------------------------------------------------- */ |
| 1142 | /* Create geometry */ |
| 1143 | /* -------------------------------------------------------------------- */ |
| 1144 | auto poLS = stdcxx . . $ std/::make_unique<OGRLineStringcxx . . $ OGRLineString#>(); |
| 1145 | if (bHaveZ) |
| 1146 | { |
| 1147 | poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX1, dfY1, dfZ1); |
| 1148 | poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX2, dfY2, dfZ2); |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(828b76dce88fac).(dfX1, dfY1); |
| 1153 | poLS->addPointcxx . . $ OGRSimpleCurve#addPoint(828b76dce88fac).(dfX2, dfY2); |
| 1154 | } |
| 1155 | |
| 1156 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poLS.release()); |
| 1157 | |
| 1158 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1159 | |
| 1160 | return poFeature.release(); |
| 1161 | } |
| 1162 | |
| 1163 | /************************************************************************/ |
| 1164 | /* TranslateLWPOLYLINE() */ |
| 1165 | /************************************************************************/ |
| 1166 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateLWPOLYLINEcxx . . $ OGRDXFLayer#TranslateLWPOLYLINE(e6624aae671b4354).() |
| 1167 | |
| 1168 | { |
| 1169 | // Collect vertices and attributes into a smooth polyline. |
| 1170 | // If there are no bulges, then we are a straight-line polyline. |
| 1171 | // Single-vertex polylines become points. |
| 1172 | // Group code 30 (vertex Z) is not part of this entity. |
| 1173 | char szLineBuf[257]; |
| 1174 | int nCode = 0; |
| 1175 | int nPolylineFlag = 0; |
| 1176 | |
| 1177 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1178 | double dfX = 0.0; |
| 1179 | double dfY = 0.0; |
| 1180 | double dfZ = 0.0; |
| 1181 | bool bHaveX = false; |
| 1182 | bool bHaveY = false; |
| 1183 | |
| 1184 | int nNumVertices = 1; // use 1 based index |
| 1185 | int npolyarcVertexCount = 1; |
| 1186 | double dfBulge = 0.0; |
| 1187 | DXFSmoothPolylinecxx . . $ DXFSmoothPolyline# smoothPolylinecxx . . $ DXFSmoothPolyline#DXFSmoothPolyline(49f6e7a06ebc5aa8).; |
| 1188 | |
| 1189 | smoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(2); |
| 1190 | |
| 1191 | /* -------------------------------------------------------------------- */ |
| 1192 | /* Collect information from the LWPOLYLINE object itself. */ |
| 1193 | /* -------------------------------------------------------------------- */ |
| 1194 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1195 | { |
| 1196 | if (npolyarcVertexCount > nNumVertices) |
| 1197 | { |
| 1198 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1199 | "Too many vertices found in LWPOLYLINE."); |
| 1200 | return nullptr; |
| 1201 | } |
| 1202 | |
| 1203 | switch (nCode) |
| 1204 | { |
| 1205 | case 38: |
| 1206 | // Constant elevation. |
| 1207 | dfZ = CPLAtof(szLineBuf); |
| 1208 | smoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(3); |
| 1209 | break; |
| 1210 | |
| 1211 | case 90: |
| 1212 | nNumVertices = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1213 | break; |
| 1214 | |
| 1215 | case 70: |
| 1216 | nPolylineFlag = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1217 | break; |
| 1218 | |
| 1219 | case 10: |
| 1220 | if (bHaveX && bHaveY) |
| 1221 | { |
| 1222 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfZ, dfBulge); |
| 1223 | npolyarcVertexCount++; |
| 1224 | dfBulge = 0.0; |
| 1225 | bHaveY = false; |
| 1226 | } |
| 1227 | dfX = CPLAtof(szLineBuf); |
| 1228 | bHaveX = true; |
| 1229 | break; |
| 1230 | |
| 1231 | case 20: |
| 1232 | if (bHaveX && bHaveY) |
| 1233 | { |
| 1234 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfZ, dfBulge); |
| 1235 | npolyarcVertexCount++; |
| 1236 | dfBulge = 0.0; |
| 1237 | bHaveX = false; |
| 1238 | } |
| 1239 | dfY = CPLAtof(szLineBuf); |
| 1240 | bHaveY = true; |
| 1241 | break; |
| 1242 | |
| 1243 | case 42: |
| 1244 | dfBulge = CPLAtof(szLineBuf); |
| 1245 | break; |
| 1246 | |
| 1247 | default: |
| 1248 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1249 | break; |
| 1250 | } |
| 1251 | } |
| 1252 | if (nCode < 0) |
| 1253 | { |
| 1254 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1255 | return nullptr; |
| 1256 | } |
| 1257 | |
| 1258 | if (nCode == 0) |
| 1259 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1260 | |
| 1261 | if (bHaveX && bHaveY) |
| 1262 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfZ, dfBulge); |
| 1263 | |
| 1264 | if (smoothPolyline.IsEmptycxx . . $ DXFSmoothPolyline#IsEmpty(50ce9a9e25b4a850).()) |
| 1265 | { |
| 1266 | return nullptr; |
| 1267 | } |
| 1268 | |
| 1269 | /* -------------------------------------------------------------------- */ |
| 1270 | /* Close polyline if necessary. */ |
| 1271 | /* -------------------------------------------------------------------- */ |
| 1272 | const bool bIsClosed = (nPolylineFlag & 0x01) != 0; |
| 1273 | if (bIsClosed) |
| 1274 | smoothPolyline.Closecxx . . $ DXFSmoothPolyline#Close(49f6e7a06ebc5aa8).(); |
| 1275 | |
| 1276 | const bool bAsPolygon = bIsClosed && poDScxx . . $ OGRDXFLayer#poDS.->ClosedLineAsPolygoncxx . . $ OGRDXFDataSource#ClosedLineAsPolygon(50ce9a9e25b4a850).(); |
| 1277 | |
| 1278 | smoothPolyline.SetUseMaxGapWhenTessellatingArcscxx . . $ DXFSmoothPolyline#SetUseMaxGapWhenTessellatingArcs(b45ddcbc8423892c).(poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).()); |
| 1279 | auto poGeom = |
| 1280 | stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>(smoothPolyline.Tessellatecxx . . $ DXFSmoothPolyline#Tessellate(9bece52a439d3243).(bAsPolygon)); |
| 1281 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poGeom.get()); |
| 1282 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom.release()); |
| 1283 | |
| 1284 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1285 | |
| 1286 | return poFeature.release(); |
| 1287 | } |
| 1288 | |
| 1289 | /************************************************************************/ |
| 1290 | /* SafeAbs() */ |
| 1291 | /************************************************************************/ |
| 1292 | |
| 1293 | static inline int SafeAbscxx . . $ SafeAbs(7864480464b09eea).(int x) |
| 1294 | { |
| 1295 | if (x == stdcxx . . $ std/::numeric_limits<int>::min()) |
| 1296 | return stdcxx . . $ std/::numeric_limits<int>::max(); |
| 1297 | return abscxx . . $ abs(a1851578aea3f541).(x); |
| 1298 | } |
| 1299 | |
| 1300 | /************************************************************************/ |
| 1301 | /* TranslatePOLYLINE() */ |
| 1302 | /* */ |
| 1303 | /* We also capture the following vertices. */ |
| 1304 | /************************************************************************/ |
| 1305 | |
| 1306 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslatePOLYLINEcxx . . $ OGRDXFLayer#TranslatePOLYLINE(e6624aae671b4354).() |
| 1307 | |
| 1308 | { |
| 1309 | char szLineBuf[257]; |
| 1310 | int nCode = 0; |
| 1311 | int nPolylineFlag = 0; |
| 1312 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1313 | |
| 1314 | /* -------------------------------------------------------------------- */ |
| 1315 | /* Collect information from the POLYLINE object itself. */ |
| 1316 | /* -------------------------------------------------------------------- */ |
| 1317 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1318 | { |
| 1319 | switch (nCode) |
| 1320 | { |
| 1321 | case 70: |
| 1322 | nPolylineFlag = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1323 | break; |
| 1324 | |
| 1325 | default: |
| 1326 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1327 | break; |
| 1328 | } |
| 1329 | } |
| 1330 | if (nCode < 0) |
| 1331 | { |
| 1332 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1333 | return nullptr; |
| 1334 | } |
| 1335 | |
| 1336 | if ((nPolylineFlag & 16) != 0) |
| 1337 | { |
| 1338 | CPLDebug("DXF", "Polygon mesh not supported."); |
| 1339 | return nullptr; |
| 1340 | } |
| 1341 | |
| 1342 | /* -------------------------------------------------------------------- */ |
| 1343 | /* Collect vertices as a smooth polyline. */ |
| 1344 | /* -------------------------------------------------------------------- */ |
| 1345 | double dfX = 0.0; |
| 1346 | double dfY = 0.0; |
| 1347 | double dfZ = 0.0; |
| 1348 | double dfBulge = 0.0; |
| 1349 | int nVertexFlag = 0; |
| 1350 | DXFSmoothPolylinecxx . . $ DXFSmoothPolyline# smoothPolylinecxx . . $ DXFSmoothPolyline#DXFSmoothPolyline(49f6e7a06ebc5aa8).; |
| 1351 | unsigned int vertexIndex71 = 0; |
| 1352 | unsigned int vertexIndex72 = 0; |
| 1353 | unsigned int vertexIndex73 = 0; |
| 1354 | unsigned int vertexIndex74 = 0; |
| 1355 | stdcxx . . $ std/::vector<OGRPointcxx . . $ OGRPoint#> aoPoints; |
| 1356 | auto poPS = stdcxx . . $ std/::make_unique<OGRPolyhedralSurfacecxx . . $ OGRPolyhedralSurface#>(); |
| 1357 | |
| 1358 | smoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(2); |
| 1359 | |
| 1360 | while (nCode == 0 && !EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "SEQEND")) |
| 1361 | { |
| 1362 | // Eat non-vertex objects. |
| 1363 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "VERTEX")) |
| 1364 | { |
| 1365 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1366 | { |
| 1367 | } |
| 1368 | if (nCode < 0) |
| 1369 | { |
| 1370 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1371 | return nullptr; |
| 1372 | } |
| 1373 | |
| 1374 | continue; |
| 1375 | } |
| 1376 | |
| 1377 | // process a Vertex |
| 1378 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1379 | { |
| 1380 | switch (nCode) |
| 1381 | { |
| 1382 | case 10: |
| 1383 | dfX = CPLAtof(szLineBuf); |
| 1384 | break; |
| 1385 | |
| 1386 | case 20: |
| 1387 | dfY = CPLAtof(szLineBuf); |
| 1388 | break; |
| 1389 | |
| 1390 | case 30: |
| 1391 | dfZ = CPLAtof(szLineBuf); |
| 1392 | smoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(3); |
| 1393 | break; |
| 1394 | |
| 1395 | case 42: |
| 1396 | dfBulge = CPLAtof(szLineBuf); |
| 1397 | break; |
| 1398 | |
| 1399 | case 70: |
| 1400 | nVertexFlag = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1401 | break; |
| 1402 | |
| 1403 | case 71: |
| 1404 | // See comment below about negative values for 71, 72, 73, |
| 1405 | // 74 |
| 1406 | vertexIndex71 = SafeAbscxx . . $ SafeAbs(7864480464b09eea).(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf)); |
| 1407 | break; |
| 1408 | |
| 1409 | case 72: |
| 1410 | vertexIndex72 = SafeAbscxx . . $ SafeAbs(7864480464b09eea).(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf)); |
| 1411 | break; |
| 1412 | |
| 1413 | case 73: |
| 1414 | vertexIndex73 = SafeAbscxx . . $ SafeAbs(7864480464b09eea).(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf)); |
| 1415 | break; |
| 1416 | |
| 1417 | case 74: |
| 1418 | vertexIndex74 = SafeAbscxx . . $ SafeAbs(7864480464b09eea).(atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf)); |
| 1419 | break; |
| 1420 | |
| 1421 | default: |
| 1422 | break; |
| 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | if (((nVertexFlag & 64) != 0) && ((nVertexFlag & 128) != 0)) |
| 1427 | { |
| 1428 | // add the point to the list of points |
| 1429 | try |
| 1430 | { |
| 1431 | aoPoints.emplace_back(dfX, dfY, dfZ); |
| 1432 | } |
| 1433 | catch (const stdcxx . . $ std/::exception &e) |
| 1434 | { |
| 1435 | CPLError(CE_Failure, CPLE_OutOfMemorycxx . . $ `port/cpl_error.h:110:9`!, "%s", e.what()); |
| 1436 | return nullptr; |
| 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | // Note - If any index out of vertexIndex71, vertexIndex72, |
| 1441 | // vertexIndex73 or vertexIndex74 is negative, it means that the line |
| 1442 | // starting from that vertex is invisible. However, it still needs to be |
| 1443 | // constructed as part of the resultant polyhedral surface; there is no |
| 1444 | // way to specify the visibility of individual edges in a polyhedral |
| 1445 | // surface at present |
| 1446 | |
| 1447 | if (nVertexFlag == 128) |
| 1448 | { |
| 1449 | // create a polygon and add it to the Polyhedral Surface |
| 1450 | auto poLR = stdcxx . . $ std/::make_unique<OGRLinearRingcxx . . $ OGRLinearRing#>(); |
| 1451 | int iPoint = 0; |
| 1452 | int startPoint = -1; |
| 1453 | poLR->set3Dcxx . . $ OGRSimpleCurve#set3D(83c267b20bac841a).(TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 1454 | if (vertexIndex71 != 0 && vertexIndex71 <= aoPoints.size()) |
| 1455 | { |
| 1456 | // if (startPoint == -1) |
| 1457 | startPoint = vertexIndex71 - 1; |
| 1458 | poLR->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(iPoint, &aoPoints[vertexIndex71 - 1]); |
| 1459 | iPoint++; |
| 1460 | vertexIndex71 = 0; |
| 1461 | } |
| 1462 | if (vertexIndex72 != 0 && vertexIndex72 <= aoPoints.size()) |
| 1463 | { |
| 1464 | if (startPoint == -1) |
| 1465 | startPoint = vertexIndex72 - 1; |
| 1466 | poLR->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(iPoint, &aoPoints[vertexIndex72 - 1]); |
| 1467 | iPoint++; |
| 1468 | vertexIndex72 = 0; |
| 1469 | } |
| 1470 | if (vertexIndex73 != 0 && vertexIndex73 <= aoPoints.size()) |
| 1471 | { |
| 1472 | if (startPoint == -1) |
| 1473 | startPoint = vertexIndex73 - 1; |
| 1474 | poLR->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(iPoint, &aoPoints[vertexIndex73 - 1]); |
| 1475 | iPoint++; |
| 1476 | vertexIndex73 = 0; |
| 1477 | } |
| 1478 | if (vertexIndex74 != 0 && vertexIndex74 <= aoPoints.size()) |
| 1479 | { |
| 1480 | if (startPoint == -1) |
| 1481 | startPoint = vertexIndex74 - 1; |
| 1482 | poLR->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(iPoint, &aoPoints[vertexIndex74 - 1]); |
| 1483 | iPoint++; |
| 1484 | vertexIndex74 = 0; |
| 1485 | } |
| 1486 | if (startPoint >= 0) |
| 1487 | { |
| 1488 | // complete the ring |
| 1489 | poLR->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(iPoint, &aoPoints[startPoint]); |
| 1490 | |
| 1491 | OGRPolygoncxx . . $ OGRPolygon# *poPolygon = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 1492 | poPolygon->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poLR.release()); |
| 1493 | |
| 1494 | poPS->addGeometryDirectlycxx . . $ OGRPolyhedralSurface#addGeometryDirectly(cec3429dca426eb8).(poPolygon); |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | if (nCode < 0) |
| 1499 | { |
| 1500 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1501 | return nullptr; |
| 1502 | } |
| 1503 | |
| 1504 | // Ignore Spline frame control points ( see #4683 ) |
| 1505 | if ((nVertexFlag & 16) == 0) |
| 1506 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfX, dfY, dfZ, dfBulge); |
| 1507 | dfBulge = 0.0; |
| 1508 | } |
| 1509 | |
| 1510 | if (smoothPolyline.IsEmptycxx . . $ DXFSmoothPolyline#IsEmpty(50ce9a9e25b4a850).()) |
| 1511 | { |
| 1512 | return nullptr; |
| 1513 | } |
| 1514 | |
| 1515 | if (poPS->getNumGeometriescxx . . $ OGRPolyhedralSurface#getNumGeometries(455f465bc33b4cdf).() > 0) |
| 1516 | { |
| 1517 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poPS.release()); |
| 1518 | PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1519 | return poFeature.release(); |
| 1520 | } |
| 1521 | |
| 1522 | /* -------------------------------------------------------------------- */ |
| 1523 | /* Close polyline if necessary. */ |
| 1524 | /* -------------------------------------------------------------------- */ |
| 1525 | const bool bIsClosed = (nPolylineFlag & 0x01) != 0; |
| 1526 | if (bIsClosed) |
| 1527 | smoothPolyline.Closecxx . . $ DXFSmoothPolyline#Close(49f6e7a06ebc5aa8).(); |
| 1528 | |
| 1529 | const bool bAsPolygon = bIsClosed && poDScxx . . $ OGRDXFLayer#poDS.->ClosedLineAsPolygoncxx . . $ OGRDXFDataSource#ClosedLineAsPolygon(50ce9a9e25b4a850).(); |
| 1530 | |
| 1531 | smoothPolyline.SetUseMaxGapWhenTessellatingArcscxx . . $ DXFSmoothPolyline#SetUseMaxGapWhenTessellatingArcs(b45ddcbc8423892c).(poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).()); |
| 1532 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = smoothPolyline.Tessellatecxx . . $ DXFSmoothPolyline#Tessellate(9bece52a439d3243).(bAsPolygon); |
| 1533 | |
| 1534 | if ((nPolylineFlag & 8) == 0) |
| 1535 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poGeom); |
| 1536 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 1537 | |
| 1538 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1539 | |
| 1540 | return poFeature.release(); |
| 1541 | } |
| 1542 | |
| 1543 | /************************************************************************/ |
| 1544 | /* TranslateMLINE() */ |
| 1545 | /************************************************************************/ |
| 1546 | |
| 1547 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateMLINEcxx . . $ OGRDXFLayer#TranslateMLINE(e6624aae671b4354).() |
| 1548 | |
| 1549 | { |
| 1550 | char szLineBuf[257]; |
| 1551 | int nCode = 0; |
| 1552 | |
| 1553 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1554 | |
| 1555 | bool bIsClosed = false; |
| 1556 | int nNumVertices = 0; |
| 1557 | int nNumElements = 0; |
| 1558 | |
| 1559 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0 && |
| 1560 | nCode != 11) |
| 1561 | { |
| 1562 | switch (nCode) |
| 1563 | { |
| 1564 | case 71: |
| 1565 | bIsClosed = (atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) & 2) == 2; |
| 1566 | break; |
| 1567 | |
| 1568 | case 72: |
| 1569 | nNumVertices = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1570 | break; |
| 1571 | |
| 1572 | case 73: |
| 1573 | nNumElements = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1574 | // No-one should ever need more than 1000 elements! |
| 1575 | if (nNumElements <= 0 || nNumElements > 1000) |
| 1576 | { |
| 1577 | CPLDebug("DXF", "Invalid number of MLINE elements (73): %s", |
| 1578 | szLineBuf); |
| 1579 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1580 | return nullptr; |
| 1581 | } |
| 1582 | break; |
| 1583 | |
| 1584 | default: |
| 1585 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1586 | break; |
| 1587 | } |
| 1588 | } |
| 1589 | if (nCode < 0) |
| 1590 | { |
| 1591 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1592 | return nullptr; |
| 1593 | } |
| 1594 | |
| 1595 | if (nCode == 0 || nCode == 11) |
| 1596 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1597 | |
| 1598 | /* -------------------------------------------------------------------- */ |
| 1599 | /* Read in the position and parameters for each vertex, and */ |
| 1600 | /* translate these values into line geometries. */ |
| 1601 | /* -------------------------------------------------------------------- */ |
| 1602 | |
| 1603 | auto poMLS = stdcxx . . $ std/::make_unique<OGRMultiLineStringcxx . . $ OGRMultiLineString#>(); |
| 1604 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRLineStringcxx . . $ OGRLineString#>> apoCurrentLines(nNumElements); |
| 1605 | |
| 1606 | // For use when bIsClosed is true |
| 1607 | stdcxx . . $ std/::vector<DXFTriplecxx . . $ DXFTriple#> aoInitialVertices(nNumElements); |
| 1608 | |
| 1609 | #define EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(code) \ |
| 1610 | if (poDS->ReadValue(szLineBuf, sizeof(szLineBuf)) != (code)) \ |
| 1611 | { \ |
| 1612 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); \ |
| 1613 | return nullptr; \ |
| 1614 | } |
| 1615 | |
| 1616 | for (int iVertex = 0; iVertex < nNumVertices; iVertex++) |
| 1617 | { |
| 1618 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(11); |
| 1619 | const double dfVertexX = CPLAtof(szLineBuf); |
| 1620 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(21); |
| 1621 | const double dfVertexY = CPLAtof(szLineBuf); |
| 1622 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(31); |
| 1623 | const double dfVertexZ = CPLAtof(szLineBuf); |
| 1624 | |
| 1625 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(12); |
| 1626 | const double dfSegmentDirectionX = CPLAtof(szLineBuf); |
| 1627 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(22); |
| 1628 | const double dfSegmentDirectionY = CPLAtof(szLineBuf); |
| 1629 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(32); |
| 1630 | const double dfSegmentDirectionZ = CPLAtof(szLineBuf); |
| 1631 | |
| 1632 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(13); |
| 1633 | const double dfMiterDirectionX = CPLAtof(szLineBuf); |
| 1634 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(23); |
| 1635 | const double dfMiterDirectionY = CPLAtof(szLineBuf); |
| 1636 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(33); |
| 1637 | const double dfMiterDirectionZ = CPLAtof(szLineBuf); |
| 1638 | |
| 1639 | for (int iElement = 0; iElement < nNumElements; iElement++) |
| 1640 | { |
| 1641 | double dfStartSegmentX = 0.0; |
| 1642 | double dfStartSegmentY = 0.0; |
| 1643 | double dfStartSegmentZ = 0.0; |
| 1644 | |
| 1645 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(74); |
| 1646 | const int nNumParameters = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1647 | |
| 1648 | // The first parameter is special: it is a distance along the |
| 1649 | // miter vector from the initial vertex to the start of the |
| 1650 | // element line. |
| 1651 | if (nNumParameters > 0) |
| 1652 | { |
| 1653 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(41); |
| 1654 | const double dfDistance = CPLAtof(szLineBuf); |
| 1655 | |
| 1656 | dfStartSegmentX = dfVertexX + dfMiterDirectionX * dfDistance; |
| 1657 | dfStartSegmentY = dfVertexY + dfMiterDirectionY * dfDistance; |
| 1658 | dfStartSegmentZ = dfVertexZ + dfMiterDirectionZ * dfDistance; |
| 1659 | |
| 1660 | if (bIsClosed && iVertex == 0) |
| 1661 | { |
| 1662 | aoInitialVertices[iElement] =cxx . . $ DXFTriple#`operator=`(6f9f1b49437be6c6). DXFTriplecxx . . $ DXFTriple#DXFTriple(98dd472ac7e5c3d4).( |
| 1663 | dfStartSegmentX, dfStartSegmentY, dfStartSegmentZ); |
| 1664 | } |
| 1665 | |
| 1666 | // If we have an unfinished line for this element, we need |
| 1667 | // to close it off. |
| 1668 | if (apoCurrentLines[iElement]) |
| 1669 | { |
| 1670 | apoCurrentLines[iElement]->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).( |
| 1671 | dfStartSegmentX, dfStartSegmentY, dfStartSegmentZ); |
| 1672 | poMLS->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).( |
| 1673 | apoCurrentLines[iElement].release()); |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | // Parameters with an odd index give pen-up distances (breaks), |
| 1678 | // while even indexes are pen-down distances (line segments). |
| 1679 | for (int iParameter = 1; iParameter < nNumParameters; iParameter++) |
| 1680 | { |
| 1681 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(41); |
| 1682 | const double dfDistance = CPLAtof(szLineBuf); |
| 1683 | |
| 1684 | const double dfCurrentX = |
| 1685 | dfStartSegmentX + dfSegmentDirectionX * dfDistance; |
| 1686 | const double dfCurrentY = |
| 1687 | dfStartSegmentY + dfSegmentDirectionY * dfDistance; |
| 1688 | const double dfCurrentZ = |
| 1689 | dfStartSegmentZ + dfSegmentDirectionZ * dfDistance; |
| 1690 | |
| 1691 | if (iParameter % 2 == 0) |
| 1692 | { |
| 1693 | // The dfCurrent(X,Y,Z) point is the end of a line segment |
| 1694 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(apoCurrentLines[iElement]); |
| 1695 | apoCurrentLines[iElement]->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfCurrentX, dfCurrentY, |
| 1696 | dfCurrentZ); |
| 1697 | poMLS->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).( |
| 1698 | apoCurrentLines[iElement].release()); |
| 1699 | } |
| 1700 | else |
| 1701 | { |
| 1702 | // The dfCurrent(X,Y,Z) point is the end of a break |
| 1703 | apoCurrentLines[iElement] = |
| 1704 | stdcxx . . $ std/::make_unique<OGRLineStringcxx . . $ OGRLineString#>(); |
| 1705 | apoCurrentLines[iElement]->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfCurrentX, dfCurrentY, |
| 1706 | dfCurrentZ); |
| 1707 | } |
| 1708 | } |
| 1709 | |
| 1710 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(75); |
| 1711 | const int nNumAreaFillParams = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 1712 | |
| 1713 | for (int iParameter = 0; iParameter < nNumAreaFillParams; |
| 1714 | iParameter++) |
| 1715 | { |
| 1716 | EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`!(42); |
| 1717 | } |
| 1718 | } |
| 1719 | } |
| 1720 | |
| 1721 | #undef EXPECT_CODEcxx . . $ `ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp:1609:9`! |
| 1722 | |
| 1723 | // Close the MLINE if required. |
| 1724 | if (bIsClosed) |
| 1725 | { |
| 1726 | for (int iElement = 0; iElement < nNumElements; iElement++) |
| 1727 | { |
| 1728 | if (apoCurrentLines[iElement]) |
| 1729 | { |
| 1730 | apoCurrentLines[iElement]->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).( |
| 1731 | aoInitialVertices[iElement].dfXcxx . . $ DXFTriple#dfX., |
| 1732 | aoInitialVertices[iElement].dfYcxx . . $ DXFTriple#dfY., |
| 1733 | aoInitialVertices[iElement].dfZcxx . . $ DXFTriple#dfZ.); |
| 1734 | poMLS->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(apoCurrentLines[iElement].release()); |
| 1735 | } |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | // Apparently extrusions are ignored for MLINE entities. |
| 1740 | // poFeature->ApplyOCSTransformer( poMLS ); |
| 1741 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poMLS.release()); |
| 1742 | |
| 1743 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1744 | |
| 1745 | return poFeature.release(); |
| 1746 | } |
| 1747 | |
| 1748 | /************************************************************************/ |
| 1749 | /* TranslateCIRCLE() */ |
| 1750 | /************************************************************************/ |
| 1751 | |
| 1752 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateCIRCLEcxx . . $ OGRDXFLayer#TranslateCIRCLE(e6624aae671b4354).() |
| 1753 | |
| 1754 | { |
| 1755 | char szLineBuf[257]; |
| 1756 | int nCode = 0; |
| 1757 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1758 | double dfX1 = 0.0; |
| 1759 | double dfY1 = 0.0; |
| 1760 | double dfZ1 = 0.0; |
| 1761 | double dfRadius = 0.0; |
| 1762 | double dfThickness = 0.0; |
| 1763 | bool bHaveZ = false; |
| 1764 | |
| 1765 | /* -------------------------------------------------------------------- */ |
| 1766 | /* Process values. */ |
| 1767 | /* -------------------------------------------------------------------- */ |
| 1768 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1769 | { |
| 1770 | switch (nCode) |
| 1771 | { |
| 1772 | case 10: |
| 1773 | dfX1 = CPLAtof(szLineBuf); |
| 1774 | break; |
| 1775 | |
| 1776 | case 20: |
| 1777 | dfY1 = CPLAtof(szLineBuf); |
| 1778 | break; |
| 1779 | |
| 1780 | case 30: |
| 1781 | dfZ1 = CPLAtof(szLineBuf); |
| 1782 | bHaveZ = true; |
| 1783 | break; |
| 1784 | |
| 1785 | case 39: |
| 1786 | dfThickness = CPLAtof(szLineBuf); |
| 1787 | break; |
| 1788 | |
| 1789 | case 40: |
| 1790 | dfRadius = CPLAtof(szLineBuf); |
| 1791 | break; |
| 1792 | |
| 1793 | default: |
| 1794 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1795 | break; |
| 1796 | } |
| 1797 | } |
| 1798 | if (nCode < 0) |
| 1799 | { |
| 1800 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1801 | return nullptr; |
| 1802 | } |
| 1803 | |
| 1804 | if (nCode == 0) |
| 1805 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1806 | |
| 1807 | /* -------------------------------------------------------------------- */ |
| 1808 | /* Create geometry */ |
| 1809 | /* -------------------------------------------------------------------- */ |
| 1810 | auto poCircle = stdcxx . . $ std/::unique_ptr<OGRLineStringcxx . . $ OGRLineString#>( |
| 1811 | OGRGeometryFactorycxx . . $ OGRGeometryFactory#::approximateArcAnglescxx . . $ OGRGeometryFactory#approximateArcAngles(ad77857dadd20571).(dfX1, dfY1, dfZ1, dfRadius, |
| 1812 | dfRadius, 0.0, 0.0, 360.0, 0.0, |
| 1813 | poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).()) |
| 1814 | ->toLineStringcxx . . $ OGRGeometry#toLineString(67733397082bfaf6).()); |
| 1815 | |
| 1816 | const int nPoints = poCircle->getNumPointscxx . . $ OGRSimpleCurve#getNumPoints(455f465bc33b4cdf).(); |
| 1817 | |
| 1818 | // If dfThickness is nonzero, we need to extrude a cylinder of height |
| 1819 | // dfThickness in the Z axis. |
| 1820 | if (dfThickness != 0.0 && nPoints > 1) |
| 1821 | { |
| 1822 | OGRPolyhedralSurfacecxx . . $ OGRPolyhedralSurface# *poSurface = new OGRPolyhedralSurfacecxx . . $ OGRPolyhedralSurface#OGRPolyhedralSurface(49f6e7a06ebc5aa8).(); |
| 1823 | |
| 1824 | // Add the bottom base as a polygon |
| 1825 | OGRLinearRingcxx . . $ OGRLinearRing# *poRing1 = new OGRLinearRingcxx . . $ OGRLinearRing#OGRLinearRing(49f6e7a06ebc5aa8).(); |
| 1826 | poRing1->addSubLineStringcxx . . $ OGRSimpleCurve#addSubLineString(7c19cb04df4be82b).(poCircle.get()); |
| 1827 | |
| 1828 | OGRPolygoncxx . . $ OGRPolygon# *poBase1 = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 1829 | poBase1->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poRing1); |
| 1830 | poSurface->addGeometryDirectlycxx . . $ OGRPolyhedralSurface#addGeometryDirectly(cec3429dca426eb8).(poBase1); |
| 1831 | |
| 1832 | // Create and add the top base |
| 1833 | OGRLinearRingcxx . . $ OGRLinearRing# *poRing2 = poRing1->clonecxx . . $ OGRLinearRing#clone(622f41c01c4313e5).(); |
| 1834 | |
| 1835 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oTransformercxx . . $ OGRDXFInsertTransformer#OGRDXFInsertTransformer(ced63f7c635d850d).; |
| 1836 | oTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset. = dfThickness; |
| 1837 | poRing2->transformcxx . . $ OGRLinearRing#transform(8ea9c28d9400a78d).(&oTransformer); |
| 1838 | |
| 1839 | OGRPolygoncxx . . $ OGRPolygon# *poBase2 = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 1840 | poBase2->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poRing2); |
| 1841 | poSurface->addGeometryDirectlycxx . . $ OGRPolyhedralSurface#addGeometryDirectly(cec3429dca426eb8).(poBase2); |
| 1842 | |
| 1843 | // Add the side of the cylinder as two "semicylindrical" polygons |
| 1844 | auto poRect = stdcxx . . $ std/::make_unique<OGRLinearRingcxx . . $ OGRLinearRing#>(); |
| 1845 | OGRPointcxx . . $ OGRPoint# oPointcxx . . $ OGRPoint#OGRPoint(49f6e7a06ebc5aa8).; |
| 1846 | |
| 1847 | for (int iPoint = nPoints / 2; iPoint >= 0; iPoint--) |
| 1848 | { |
| 1849 | poRing1->getPointcxx . . $ OGRSimpleCurve#getPoint(e9103e3929e51b56).(iPoint, &oPoint); |
| 1850 | poRect->addPointcxx . . $ OGRSimpleCurve#addPoint(92edeffd6e08544c).(&oPoint); |
| 1851 | } |
| 1852 | for (int iPoint = 0; iPoint <= nPoints / 2; iPoint++) |
| 1853 | { |
| 1854 | poRing2->getPointcxx . . $ OGRSimpleCurve#getPoint(e9103e3929e51b56).(iPoint, &oPoint); |
| 1855 | poRect->addPointcxx . . $ OGRSimpleCurve#addPoint(92edeffd6e08544c).(&oPoint); |
| 1856 | } |
| 1857 | |
| 1858 | poRect->closeRingscxx . . $ OGRLinearRing#closeRings(49f6e7a06ebc5aa8).(); |
| 1859 | |
| 1860 | OGRPolygoncxx . . $ OGRPolygon# *poRectPolygon = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 1861 | poRectPolygon->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poRect.release()); |
| 1862 | poSurface->addGeometryDirectlycxx . . $ OGRPolyhedralSurface#addGeometryDirectly(cec3429dca426eb8).(poRectPolygon); |
| 1863 | |
| 1864 | poRect = stdcxx . . $ std/::make_unique<OGRLinearRingcxx . . $ OGRLinearRing#>(); |
| 1865 | |
| 1866 | for (int iPoint = nPoints - 1; iPoint >= nPoints / 2; iPoint--) |
| 1867 | { |
| 1868 | poRing1->getPointcxx . . $ OGRSimpleCurve#getPoint(e9103e3929e51b56).(iPoint, &oPoint); |
| 1869 | poRect->addPointcxx . . $ OGRSimpleCurve#addPoint(92edeffd6e08544c).(&oPoint); |
| 1870 | } |
| 1871 | for (int iPoint = nPoints / 2; iPoint < nPoints; iPoint++) |
| 1872 | { |
| 1873 | poRing2->getPointcxx . . $ OGRSimpleCurve#getPoint(e9103e3929e51b56).(iPoint, &oPoint); |
| 1874 | poRect->addPointcxx . . $ OGRSimpleCurve#addPoint(92edeffd6e08544c).(&oPoint); |
| 1875 | } |
| 1876 | |
| 1877 | poRect->closeRingscxx . . $ OGRLinearRing#closeRings(49f6e7a06ebc5aa8).(); |
| 1878 | |
| 1879 | poRectPolygon = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 1880 | poRectPolygon->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poRect.release()); |
| 1881 | poSurface->addGeometryDirectlycxx . . $ OGRPolyhedralSurface#addGeometryDirectly(cec3429dca426eb8).(poRectPolygon); |
| 1882 | |
| 1883 | // That's your cylinder, folks |
| 1884 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poSurface); |
| 1885 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poSurface); |
| 1886 | } |
| 1887 | else |
| 1888 | { |
| 1889 | if (!bHaveZ) |
| 1890 | poCircle->flattenTo2Dcxx . . $ OGRSimpleCurve#flattenTo2D(49f6e7a06ebc5aa8).(); |
| 1891 | |
| 1892 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poCircle.get()); |
| 1893 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poCircle.release()); |
| 1894 | } |
| 1895 | |
| 1896 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 1897 | |
| 1898 | return poFeature.release(); |
| 1899 | } |
| 1900 | |
| 1901 | /************************************************************************/ |
| 1902 | /* TranslateELLIPSE() */ |
| 1903 | /************************************************************************/ |
| 1904 | |
| 1905 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateELLIPSEcxx . . $ OGRDXFLayer#TranslateELLIPSE(e6624aae671b4354).() |
| 1906 | |
| 1907 | { |
| 1908 | char szLineBuf[257]; |
| 1909 | int nCode = 0; |
| 1910 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 1911 | double dfX1 = 0.0; |
| 1912 | double dfY1 = 0.0; |
| 1913 | double dfZ1 = 0.0; |
| 1914 | double dfRatio = 0.0; |
| 1915 | double dfStartAngle = 0.0; |
| 1916 | double dfEndAngle = 360.0; |
| 1917 | double dfAxisX = 0.0; |
| 1918 | double dfAxisY = 0.0; |
| 1919 | double dfAxisZ = 0.0; |
| 1920 | bool bHaveZ = false; |
| 1921 | bool bApplyOCSTransform = false; |
| 1922 | |
| 1923 | /* -------------------------------------------------------------------- */ |
| 1924 | /* Process values. */ |
| 1925 | /* -------------------------------------------------------------------- */ |
| 1926 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 1927 | { |
| 1928 | switch (nCode) |
| 1929 | { |
| 1930 | case 10: |
| 1931 | dfX1 = CPLAtof(szLineBuf); |
| 1932 | break; |
| 1933 | |
| 1934 | case 20: |
| 1935 | dfY1 = CPLAtof(szLineBuf); |
| 1936 | break; |
| 1937 | |
| 1938 | case 30: |
| 1939 | dfZ1 = CPLAtof(szLineBuf); |
| 1940 | bHaveZ = true; |
| 1941 | break; |
| 1942 | |
| 1943 | case 11: |
| 1944 | dfAxisX = CPLAtof(szLineBuf); |
| 1945 | break; |
| 1946 | |
| 1947 | case 21: |
| 1948 | dfAxisY = CPLAtof(szLineBuf); |
| 1949 | break; |
| 1950 | |
| 1951 | case 31: |
| 1952 | dfAxisZ = CPLAtof(szLineBuf); |
| 1953 | break; |
| 1954 | |
| 1955 | case 40: |
| 1956 | dfRatio = CPLAtof(szLineBuf); |
| 1957 | break; |
| 1958 | |
| 1959 | case 41: |
| 1960 | // These *seem* to always be in radians regardless of $AUNITS |
| 1961 | dfEndAngle = -1 * CPLAtof(szLineBuf) * 180.0 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!; |
| 1962 | break; |
| 1963 | |
| 1964 | case 42: |
| 1965 | // These *seem* to always be in radians regardless of $AUNITS |
| 1966 | dfStartAngle = -1 * CPLAtof(szLineBuf) * 180.0 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!; |
| 1967 | break; |
| 1968 | |
| 1969 | default: |
| 1970 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 1971 | break; |
| 1972 | } |
| 1973 | } |
| 1974 | if (nCode < 0) |
| 1975 | { |
| 1976 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 1977 | return nullptr; |
| 1978 | } |
| 1979 | |
| 1980 | if (nCode == 0) |
| 1981 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 1982 | |
| 1983 | /* -------------------------------------------------------------------- */ |
| 1984 | /* Setup coordinate system */ |
| 1985 | /* -------------------------------------------------------------------- */ |
| 1986 | double adfN[3]; |
| 1987 | poFeature->oOCScxx . . $ OGRDXFFeature#oOCS..ToArraycxx . . $ DXFTriple#ToArray(b0764271c3b728b7).(adfN); |
| 1988 | |
| 1989 | if ((adfN[0] == 0.0 && adfN[1] == 0.0 && adfN[2] == 1.0) == false) |
| 1990 | { |
| 1991 | OGRDXFOCSTransformercxx . . $ OGRDXFOCSTransformer# oTransformercxx . . $ OGRDXFOCSTransformer#OGRDXFOCSTransformer(5447228a225b8fb8).(adfN, true); |
| 1992 | |
| 1993 | bApplyOCSTransform = true; |
| 1994 | |
| 1995 | double *x = &dfX1; |
| 1996 | double *y = &dfY1; |
| 1997 | double *z = &dfZ1; |
| 1998 | oTransformer.InverseTransformcxx . . $ OGRDXFOCSTransformer#InverseTransform(be2aa0ebf00c252c).(1, x, y, z); |
| 1999 | |
| 2000 | x = &dfAxisX; |
| 2001 | y = &dfAxisY; |
| 2002 | z = &dfAxisZ; |
| 2003 | oTransformer.InverseTransformcxx . . $ OGRDXFOCSTransformer#InverseTransform(be2aa0ebf00c252c).(1, x, y, z); |
| 2004 | } |
| 2005 | |
| 2006 | /* -------------------------------------------------------------------- */ |
| 2007 | /* Compute primary and secondary axis lengths, and the angle of */ |
| 2008 | /* rotation for the ellipse. */ |
| 2009 | /* -------------------------------------------------------------------- */ |
| 2010 | double dfPrimaryRadius = |
| 2011 | sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dfAxisX * dfAxisX + dfAxisY * dfAxisY + dfAxisZ * dfAxisZ); |
| 2012 | |
| 2013 | double dfSecondaryRadius = dfRatio * dfPrimaryRadius; |
| 2014 | |
| 2015 | double dfRotation = -1 * atan2cxx . . $ atan2(b71928d39fde4295).(dfAxisY, dfAxisX) * 180 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!; |
| 2016 | |
| 2017 | /* -------------------------------------------------------------------- */ |
| 2018 | /* Create geometry */ |
| 2019 | /* -------------------------------------------------------------------- */ |
| 2020 | if (dfStartAngle > dfEndAngle) |
| 2021 | dfEndAngle += 360.0; |
| 2022 | |
| 2023 | if (fabscxx . . $ fabs(fee4f1d22bc8e617).(dfEndAngle - dfStartAngle) <= 361.0) |
| 2024 | { |
| 2025 | // Only honor OGR_DXF_MAX_GAP if this geometry isn't at risk of |
| 2026 | // being enlarged or shrunk as part of a block insertion. |
| 2027 | auto poEllipse = stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>( |
| 2028 | OGRGeometryFactorycxx . . $ OGRGeometryFactory#::approximateArcAnglescxx . . $ OGRGeometryFactory#approximateArcAngles(ad77857dadd20571).( |
| 2029 | dfX1, dfY1, dfZ1, dfPrimaryRadius, dfSecondaryRadius, |
| 2030 | dfRotation, dfStartAngle, dfEndAngle, 0.0, |
| 2031 | poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).())); |
| 2032 | |
| 2033 | if (!bHaveZ) |
| 2034 | poEllipse->flattenTo2Dcxx . . $ OGRGeometry#flattenTo2D(49f6e7a06ebc5aa8).(); |
| 2035 | |
| 2036 | if (bApplyOCSTransform == true) |
| 2037 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poEllipse.get()); |
| 2038 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poEllipse.release()); |
| 2039 | } |
| 2040 | else |
| 2041 | { |
| 2042 | // TODO: emit error ? |
| 2043 | } |
| 2044 | |
| 2045 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2046 | |
| 2047 | return poFeature.release(); |
| 2048 | } |
| 2049 | |
| 2050 | /************************************************************************/ |
| 2051 | /* TranslateARC() */ |
| 2052 | /************************************************************************/ |
| 2053 | |
| 2054 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateARCcxx . . $ OGRDXFLayer#TranslateARC(e6624aae671b4354).() |
| 2055 | |
| 2056 | { |
| 2057 | char szLineBuf[257]; |
| 2058 | int nCode = 0; |
| 2059 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2060 | double dfX1 = 0.0; |
| 2061 | double dfY1 = 0.0; |
| 2062 | double dfZ1 = 0.0; |
| 2063 | double dfRadius = 0.0; |
| 2064 | double dfStartAngle = 0.0; |
| 2065 | double dfEndAngle = 360.0; |
| 2066 | bool bHaveZ = false; |
| 2067 | |
| 2068 | /* -------------------------------------------------------------------- */ |
| 2069 | /* Process values. */ |
| 2070 | /* -------------------------------------------------------------------- */ |
| 2071 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2072 | { |
| 2073 | switch (nCode) |
| 2074 | { |
| 2075 | case 10: |
| 2076 | dfX1 = CPLAtof(szLineBuf); |
| 2077 | break; |
| 2078 | |
| 2079 | case 20: |
| 2080 | dfY1 = CPLAtof(szLineBuf); |
| 2081 | break; |
| 2082 | |
| 2083 | case 30: |
| 2084 | dfZ1 = CPLAtof(szLineBuf); |
| 2085 | bHaveZ = true; |
| 2086 | break; |
| 2087 | |
| 2088 | case 40: |
| 2089 | dfRadius = CPLAtof(szLineBuf); |
| 2090 | break; |
| 2091 | |
| 2092 | case 50: |
| 2093 | // This is apparently always degrees regardless of AUNITS |
| 2094 | dfEndAngle = -1 * CPLAtof(szLineBuf); |
| 2095 | break; |
| 2096 | |
| 2097 | case 51: |
| 2098 | // This is apparently always degrees regardless of AUNITS |
| 2099 | dfStartAngle = -1 * CPLAtof(szLineBuf); |
| 2100 | break; |
| 2101 | |
| 2102 | default: |
| 2103 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2104 | break; |
| 2105 | } |
| 2106 | } |
| 2107 | if (nCode < 0) |
| 2108 | { |
| 2109 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2110 | return nullptr; |
| 2111 | } |
| 2112 | |
| 2113 | if (nCode == 0) |
| 2114 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2115 | |
| 2116 | /* -------------------------------------------------------------------- */ |
| 2117 | /* Create geometry */ |
| 2118 | /* -------------------------------------------------------------------- */ |
| 2119 | if (dfStartAngle > dfEndAngle) |
| 2120 | dfEndAngle += 360.0; |
| 2121 | |
| 2122 | if (fabscxx . . $ fabs(fee4f1d22bc8e617).(dfEndAngle - dfStartAngle) <= 361.0) |
| 2123 | { |
| 2124 | auto poArc = stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>( |
| 2125 | OGRGeometryFactorycxx . . $ OGRGeometryFactory#::approximateArcAnglescxx . . $ OGRGeometryFactory#approximateArcAngles(ad77857dadd20571).( |
| 2126 | dfX1, dfY1, dfZ1, dfRadius, dfRadius, 0.0, dfStartAngle, |
| 2127 | dfEndAngle, 0.0, poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).())); |
| 2128 | if (!bHaveZ) |
| 2129 | poArc->flattenTo2Dcxx . . $ OGRGeometry#flattenTo2D(49f6e7a06ebc5aa8).(); |
| 2130 | |
| 2131 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poArc.get()); |
| 2132 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poArc.release()); |
| 2133 | } |
| 2134 | else |
| 2135 | { |
| 2136 | // TODO: emit error ? |
| 2137 | } |
| 2138 | |
| 2139 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2140 | |
| 2141 | return poFeature.release(); |
| 2142 | } |
| 2143 | |
| 2144 | /************************************************************************/ |
| 2145 | /* TranslateSPLINE() */ |
| 2146 | /************************************************************************/ |
| 2147 | |
| 2148 | void rbspline2cxx . . $ rbspline2(1058712a2909355).(int npts, int k, int p1, double b[], double h[], |
| 2149 | bool bCalculateKnots, double knots[], double p[]); |
| 2150 | |
| 2151 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateSPLINEcxx . . $ OGRDXFLayer#TranslateSPLINE(e6624aae671b4354).() |
| 2152 | |
| 2153 | { |
| 2154 | char szLineBuf[257]; |
| 2155 | int nCode; |
| 2156 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2157 | |
| 2158 | stdcxx . . $ std/::vector<double> adfControlPoints(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0); |
| 2159 | stdcxx . . $ std/::vector<double> adfKnots(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0); |
| 2160 | stdcxx . . $ std/::vector<double> adfWeights(FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING., 0.0); |
| 2161 | int nDegree = -1; |
| 2162 | int nControlPoints = -1; |
| 2163 | int nKnots = -1; |
| 2164 | bool bInsertNullZ = false; |
| 2165 | bool bHasZ = false; |
| 2166 | |
| 2167 | /* -------------------------------------------------------------------- */ |
| 2168 | /* Process values. */ |
| 2169 | /* -------------------------------------------------------------------- */ |
| 2170 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2171 | { |
| 2172 | bool bStop = false; |
| 2173 | switch (nCode) |
| 2174 | { |
| 2175 | case 10: |
| 2176 | if (bInsertNullZ) |
| 2177 | { |
| 2178 | adfControlPoints.push_back(0.0); |
| 2179 | bInsertNullZ = false; |
| 2180 | } |
| 2181 | adfControlPoints.push_back(CPLAtof(szLineBuf)); |
| 2182 | break; |
| 2183 | |
| 2184 | case 20: |
| 2185 | adfControlPoints.push_back(CPLAtof(szLineBuf)); |
| 2186 | bInsertNullZ = true; |
| 2187 | break; |
| 2188 | |
| 2189 | case 30: |
| 2190 | adfControlPoints.push_back(CPLAtof(szLineBuf)); |
| 2191 | bHasZ = true; |
| 2192 | bInsertNullZ = false; |
| 2193 | break; |
| 2194 | |
| 2195 | case 40: |
| 2196 | { |
| 2197 | double dfVal = CPLAtof(szLineBuf); |
| 2198 | // Ad-hoc fix for https://github.com/OSGeo/gdal/issues/1969 |
| 2199 | // where the first knot is at a very very close to zero negative |
| 2200 | // value and following knots are at 0. |
| 2201 | if (dfVal < 0 && dfVal > -1.0e-10) |
| 2202 | dfVal = 0; |
| 2203 | adfKnots.push_back(dfVal); |
| 2204 | break; |
| 2205 | } |
| 2206 | |
| 2207 | case 41: |
| 2208 | adfWeights.push_back(CPLAtof(szLineBuf)); |
| 2209 | break; |
| 2210 | |
| 2211 | case 70: |
| 2212 | break; |
| 2213 | |
| 2214 | case 71: |
| 2215 | nDegree = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 2216 | // Arbitrary threshold |
| 2217 | if (nDegree < 0 || nDegree > 100) |
| 2218 | { |
| 2219 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2220 | return nullptr; |
| 2221 | } |
| 2222 | break; |
| 2223 | |
| 2224 | case 72: |
| 2225 | nKnots = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 2226 | // Arbitrary threshold |
| 2227 | if (nKnots < 0 || nKnots > 10000000) |
| 2228 | { |
| 2229 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2230 | return nullptr; |
| 2231 | } |
| 2232 | break; |
| 2233 | |
| 2234 | case 73: |
| 2235 | nControlPoints = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 2236 | // Arbitrary threshold |
| 2237 | if (nControlPoints < 0 || nControlPoints > 10000000) |
| 2238 | { |
| 2239 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2240 | return nullptr; |
| 2241 | } |
| 2242 | break; |
| 2243 | |
| 2244 | case 100: |
| 2245 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "AcDbHelix")) |
| 2246 | bStop = true; |
| 2247 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2248 | break; |
| 2249 | |
| 2250 | default: |
| 2251 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2252 | break; |
| 2253 | } |
| 2254 | |
| 2255 | if (bStop) |
| 2256 | break; |
| 2257 | } |
| 2258 | if (nCode < 0) |
| 2259 | { |
| 2260 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2261 | return nullptr; |
| 2262 | } |
| 2263 | |
| 2264 | if (nCode == 0) |
| 2265 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2266 | |
| 2267 | if (bInsertNullZ) |
| 2268 | { |
| 2269 | adfControlPoints.push_back(0.0); |
| 2270 | } |
| 2271 | |
| 2272 | if (static_cast<int>(adfControlPoints.size() % 3) != FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.) |
| 2273 | { |
| 2274 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2275 | "Invalid number of values for spline control points"); |
| 2276 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2277 | return nullptr; |
| 2278 | } |
| 2279 | |
| 2280 | /* -------------------------------------------------------------------- */ |
| 2281 | /* Use the helper function to check the input data and insert */ |
| 2282 | /* the spline. */ |
| 2283 | /* -------------------------------------------------------------------- */ |
| 2284 | auto poLS = |
| 2285 | InsertSplineWithCheckscxx . . $ OGRDXFLayer#InsertSplineWithChecks(f1ac5519f6c1de45).(nDegree, adfControlPoints, bHasZ, nControlPoints, |
| 2286 | adfKnots, nKnots, adfWeights); |
| 2287 | |
| 2288 | if (!poLS) |
| 2289 | { |
| 2290 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2291 | return nullptr; |
| 2292 | } |
| 2293 | |
| 2294 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poLS.release()); |
| 2295 | |
| 2296 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2297 | |
| 2298 | return poFeature.release(); |
| 2299 | } |
| 2300 | |
| 2301 | /************************************************************************/ |
| 2302 | /* InsertSplineWithChecks() */ |
| 2303 | /* */ |
| 2304 | /* Inserts a spline based on unchecked DXF input. The arrays are */ |
| 2305 | /* one-based. */ |
| 2306 | /************************************************************************/ |
| 2307 | |
| 2308 | stdcxx . . $ std/::unique_ptr<OGRLineStringcxx . . $ OGRLineString#> OGRDXFLayercxx . . $ OGRDXFLayer#::InsertSplineWithCheckscxx . . $ OGRDXFLayer#InsertSplineWithChecks(f1ac5519f6c1de45).( |
| 2309 | const int nDegree, stdcxx . . $ std/::vector<double> &adfControlPoints, bool bHasZ, |
| 2310 | int nControlPoints, stdcxx . . $ std/::vector<double> &adfKnots, int nKnots, |
| 2311 | stdcxx . . $ std/::vector<double> &adfWeights) |
| 2312 | { |
| 2313 | /* -------------------------------------------------------------------- */ |
| 2314 | /* Sanity checks */ |
| 2315 | /* -------------------------------------------------------------------- */ |
| 2316 | const int nOrder = nDegree + 1; |
| 2317 | |
| 2318 | bool bResult = (nOrder >= 2); |
| 2319 | if (bResult == true) |
| 2320 | { |
| 2321 | // Check whether nctrlpts value matches number of vertices read |
| 2322 | int nCheck = |
| 2323 | (static_cast<int>(adfControlPoints.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.) / 3; |
| 2324 | |
| 2325 | if (nControlPoints == -1) |
| 2326 | nControlPoints = |
| 2327 | (static_cast<int>(adfControlPoints.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.) / |
| 2328 | 3; |
| 2329 | |
| 2330 | // min( num(ctrlpts) ) = order |
| 2331 | bResult = (nControlPoints >= nOrder && nControlPoints == nCheck); |
| 2332 | } |
| 2333 | |
| 2334 | bool bCalculateKnots = false; |
| 2335 | if (bResult == true) |
| 2336 | { |
| 2337 | int nCheck = static_cast<int>(adfKnots.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.; |
| 2338 | |
| 2339 | // Recalculate knots when: |
| 2340 | // - no knots data present, nknots is -1 and ncheck is 0 |
| 2341 | // - nknots value present, no knot vertices |
| 2342 | // nknots is (nctrlpts + order), ncheck is 0 |
| 2343 | if (nCheck == 0) |
| 2344 | { |
| 2345 | bCalculateKnots = true; |
| 2346 | for (int i = 0; i < (nControlPoints + nOrder); i++) |
| 2347 | adfKnots.push_back(0.0); |
| 2348 | |
| 2349 | nCheck = static_cast<int>(adfKnots.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.; |
| 2350 | } |
| 2351 | // Adjust nknots value when: |
| 2352 | // - nknots value not present, knot vertices present |
| 2353 | // nknots is -1, ncheck is (nctrlpts + order) |
| 2354 | if (nKnots == -1) |
| 2355 | nKnots = static_cast<int>(adfKnots.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.; |
| 2356 | |
| 2357 | // num(knots) = num(ctrlpts) + order |
| 2358 | bResult = (nKnots == (nControlPoints + nOrder) && nKnots == nCheck); |
| 2359 | } |
| 2360 | |
| 2361 | if (bResult == true) |
| 2362 | { |
| 2363 | int nWeights = static_cast<int>(adfWeights.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.; |
| 2364 | |
| 2365 | if (nWeights == 0) |
| 2366 | { |
| 2367 | for (int i = 0; i < nControlPoints; i++) |
| 2368 | adfWeights.push_back(1.0); |
| 2369 | |
| 2370 | nWeights = static_cast<int>(adfWeights.size()) - FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.; |
| 2371 | } |
| 2372 | |
| 2373 | // num(weights) = num(ctrlpts) |
| 2374 | bResult = (nWeights == nControlPoints); |
| 2375 | } |
| 2376 | |
| 2377 | if (bResult == false) |
| 2378 | return nullptr; |
| 2379 | |
| 2380 | /* -------------------------------------------------------------------- */ |
| 2381 | /* Interpolate spline */ |
| 2382 | /* -------------------------------------------------------------------- */ |
| 2383 | int p1 = nControlPoints * 8; |
| 2384 | stdcxx . . $ std/::vector<double> p(3 * p1 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.); |
| 2385 | |
| 2386 | rbspline2cxx . . $ rbspline2(1058712a2909355).(nControlPoints, nOrder, p1, &(adfControlPoints[0]), |
| 2387 | &(adfWeights[0]), bCalculateKnots, &(adfKnots[0]), &(p[0])); |
| 2388 | |
| 2389 | /* -------------------------------------------------------------------- */ |
| 2390 | /* Turn into OGR geometry. */ |
| 2391 | /* -------------------------------------------------------------------- */ |
| 2392 | auto poLS = stdcxx . . $ std/::make_unique<OGRLineStringcxx . . $ OGRLineString#>(); |
| 2393 | |
| 2394 | poLS->setNumPointscxx . . $ OGRSimpleCurve#setNumPoints(cf9ef193275fa6d8).(p1); |
| 2395 | if (bHasZ) |
| 2396 | { |
| 2397 | for (int i = 0; i < p1; i++) |
| 2398 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(e4764ef0909f73e).(i, p[i * 3 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.], |
| 2399 | p[i * 3 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING. + 1], |
| 2400 | p[i * 3 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING. + 2]); |
| 2401 | } |
| 2402 | else |
| 2403 | { |
| 2404 | for (int i = 0; i < p1; i++) |
| 2405 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(9f72e67440d8b329).(i, p[i * 3 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING.], |
| 2406 | p[i * 3 + FORTRAN_INDEXINGcxx . . $ OGRDXFLayer#FORTRAN_INDEXING. + 1]); |
| 2407 | } |
| 2408 | |
| 2409 | return poLS; |
| 2410 | } |
| 2411 | |
| 2412 | /************************************************************************/ |
| 2413 | /* Translate3DFACE() */ |
| 2414 | /************************************************************************/ |
| 2415 | |
| 2416 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::Translate3DFACEcxx . . $ OGRDXFLayer#Translate3DFACE(e6624aae671b4354).() |
| 2417 | |
| 2418 | { |
| 2419 | char szLineBuf[257]; |
| 2420 | int nCode = 0; |
| 2421 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2422 | double dfX1 = 0.0; |
| 2423 | double dfY1 = 0.0; |
| 2424 | double dfZ1 = 0.0; |
| 2425 | double dfX2 = 0.0; |
| 2426 | double dfY2 = 0.0; |
| 2427 | double dfZ2 = 0.0; |
| 2428 | double dfX3 = 0.0; |
| 2429 | double dfY3 = 0.0; |
| 2430 | double dfZ3 = 0.0; |
| 2431 | double dfX4 = 0.0; |
| 2432 | double dfY4 = 0.0; |
| 2433 | double dfZ4 = 0.0; |
| 2434 | |
| 2435 | /* -------------------------------------------------------------------- */ |
| 2436 | /* Process values. */ |
| 2437 | /* -------------------------------------------------------------------- */ |
| 2438 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2439 | { |
| 2440 | switch (nCode) |
| 2441 | { |
| 2442 | case 10: |
| 2443 | dfX1 = CPLAtof(szLineBuf); |
| 2444 | break; |
| 2445 | |
| 2446 | case 11: |
| 2447 | dfX2 = CPLAtof(szLineBuf); |
| 2448 | break; |
| 2449 | |
| 2450 | case 12: |
| 2451 | dfX3 = CPLAtof(szLineBuf); |
| 2452 | break; |
| 2453 | |
| 2454 | case 13: |
| 2455 | dfX4 = CPLAtof(szLineBuf); |
| 2456 | break; |
| 2457 | |
| 2458 | case 20: |
| 2459 | dfY1 = CPLAtof(szLineBuf); |
| 2460 | break; |
| 2461 | |
| 2462 | case 21: |
| 2463 | dfY2 = CPLAtof(szLineBuf); |
| 2464 | break; |
| 2465 | |
| 2466 | case 22: |
| 2467 | dfY3 = CPLAtof(szLineBuf); |
| 2468 | break; |
| 2469 | |
| 2470 | case 23: |
| 2471 | dfY4 = CPLAtof(szLineBuf); |
| 2472 | break; |
| 2473 | |
| 2474 | case 30: |
| 2475 | dfZ1 = CPLAtof(szLineBuf); |
| 2476 | break; |
| 2477 | |
| 2478 | case 31: |
| 2479 | dfZ2 = CPLAtof(szLineBuf); |
| 2480 | break; |
| 2481 | |
| 2482 | case 32: |
| 2483 | dfZ3 = CPLAtof(szLineBuf); |
| 2484 | break; |
| 2485 | |
| 2486 | case 33: |
| 2487 | dfZ4 = CPLAtof(szLineBuf); |
| 2488 | break; |
| 2489 | |
| 2490 | default: |
| 2491 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2492 | break; |
| 2493 | } |
| 2494 | } |
| 2495 | if (nCode < 0) |
| 2496 | { |
| 2497 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2498 | return nullptr; |
| 2499 | } |
| 2500 | |
| 2501 | if (nCode == 0) |
| 2502 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2503 | |
| 2504 | /* -------------------------------------------------------------------- */ |
| 2505 | /* Create geometry */ |
| 2506 | /* -------------------------------------------------------------------- */ |
| 2507 | auto poPoly = stdcxx . . $ std/::make_unique<OGRPolygoncxx . . $ OGRPolygon#>(); |
| 2508 | OGRLinearRingcxx . . $ OGRLinearRing# *poLR = new OGRLinearRingcxx . . $ OGRLinearRing#OGRLinearRing(49f6e7a06ebc5aa8).(); |
| 2509 | poLR->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX1, dfY1, dfZ1); |
| 2510 | poLR->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX2, dfY2, dfZ2); |
| 2511 | poLR->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX3, dfY3, dfZ3); |
| 2512 | if (dfX4 != dfX3 || dfY4 != dfY3 || dfZ4 != dfZ3) |
| 2513 | poLR->addPointcxx . . $ OGRSimpleCurve#addPoint(c3c51e0645da350e).(dfX4, dfY4, dfZ4); |
| 2514 | poPoly->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poLR); |
| 2515 | poPoly->closeRingscxx . . $ OGRPolygon#closeRings(49f6e7a06ebc5aa8).(); |
| 2516 | |
| 2517 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poLR); |
| 2518 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poPoly.release()); |
| 2519 | |
| 2520 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2521 | |
| 2522 | return poFeature.release(); |
| 2523 | } |
| 2524 | |
| 2525 | /* -------------------------------------------------------------------- */ |
| 2526 | /* PointXAxisComparer */ |
| 2527 | /* */ |
| 2528 | /* Returns true if oP1 is to the left of oP2, or they have the */ |
| 2529 | /* same x-coordinate and oP1 is below oP2. */ |
| 2530 | /* -------------------------------------------------------------------- */ |
| 2531 | |
| 2532 | static bool PointXAxisComparercxx . . $ PointXAxisComparer(3adfba4fa64e1053).(const OGRPointcxx . . $ OGRPoint# &oP1, const OGRPointcxx . . $ OGRPoint# &oP2) |
| 2533 | { |
| 2534 | return oP1.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).() == oP2.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).() ? oP1.getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).() < oP2.getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).() |
| 2535 | : oP1.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).() < oP2.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).(); |
| 2536 | } |
| 2537 | |
| 2538 | /* -------------------------------------------------------------------- */ |
| 2539 | /* PointXYZEqualityComparer */ |
| 2540 | /* */ |
| 2541 | /* Returns true if oP1 is equal to oP2 in the X, Y and Z axes. */ |
| 2542 | /* -------------------------------------------------------------------- */ |
| 2543 | |
| 2544 | static bool PointXYZEqualityComparercxx . . $ PointXYZEqualityComparer(3adfba4fa64e1053).(const OGRPointcxx . . $ OGRPoint# &oP1, const OGRPointcxx . . $ OGRPoint# &oP2) |
| 2545 | { |
| 2546 | return oP1.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).() == oP2.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).() && oP1.getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).() == oP2.getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).() && |
| 2547 | oP1.getZcxx . . $ OGRPoint#getZ(21b6c25e127938e2).() == oP2.getZcxx . . $ OGRPoint#getZ(21b6c25e127938e2).(); |
| 2548 | } |
| 2549 | |
| 2550 | /************************************************************************/ |
| 2551 | /* TranslateSOLID() */ |
| 2552 | /************************************************************************/ |
| 2553 | |
| 2554 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateSOLIDcxx . . $ OGRDXFLayer#TranslateSOLID(e6624aae671b4354).() |
| 2555 | |
| 2556 | { |
| 2557 | char szLineBuf[257]; |
| 2558 | int nCode = 0; |
| 2559 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2560 | double dfX1 = 0.0; |
| 2561 | double dfY1 = 0.0; |
| 2562 | double dfZ1 = 0.0; |
| 2563 | double dfX2 = 0.0; |
| 2564 | double dfY2 = 0.0; |
| 2565 | double dfZ2 = 0.0; |
| 2566 | double dfX3 = 0.0; |
| 2567 | double dfY3 = 0.0; |
| 2568 | double dfZ3 = 0.0; |
| 2569 | double dfX4 = 0.0; |
| 2570 | double dfY4 = 0.0; |
| 2571 | double dfZ4 = 0.0; |
| 2572 | |
| 2573 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2574 | { |
| 2575 | switch (nCode) |
| 2576 | { |
| 2577 | case 10: |
| 2578 | dfX1 = CPLAtof(szLineBuf); |
| 2579 | break; |
| 2580 | |
| 2581 | case 20: |
| 2582 | dfY1 = CPLAtof(szLineBuf); |
| 2583 | break; |
| 2584 | |
| 2585 | case 30: |
| 2586 | dfZ1 = CPLAtof(szLineBuf); |
| 2587 | break; |
| 2588 | |
| 2589 | case 11: |
| 2590 | dfX2 = CPLAtof(szLineBuf); |
| 2591 | break; |
| 2592 | |
| 2593 | case 21: |
| 2594 | dfY2 = CPLAtof(szLineBuf); |
| 2595 | break; |
| 2596 | |
| 2597 | case 31: |
| 2598 | dfZ2 = CPLAtof(szLineBuf); |
| 2599 | break; |
| 2600 | |
| 2601 | case 12: |
| 2602 | dfX3 = CPLAtof(szLineBuf); |
| 2603 | break; |
| 2604 | |
| 2605 | case 22: |
| 2606 | dfY3 = CPLAtof(szLineBuf); |
| 2607 | break; |
| 2608 | |
| 2609 | case 32: |
| 2610 | dfZ3 = CPLAtof(szLineBuf); |
| 2611 | break; |
| 2612 | |
| 2613 | case 13: |
| 2614 | dfX4 = CPLAtof(szLineBuf); |
| 2615 | break; |
| 2616 | |
| 2617 | case 23: |
| 2618 | dfY4 = CPLAtof(szLineBuf); |
| 2619 | break; |
| 2620 | |
| 2621 | case 33: |
| 2622 | dfZ4 = CPLAtof(szLineBuf); |
| 2623 | break; |
| 2624 | |
| 2625 | default: |
| 2626 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2627 | break; |
| 2628 | } |
| 2629 | } |
| 2630 | if (nCode < 0) |
| 2631 | { |
| 2632 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2633 | return nullptr; |
| 2634 | } |
| 2635 | if (nCode == 0) |
| 2636 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2637 | |
| 2638 | // do we want Z-coordinates? |
| 2639 | const bool bWantZ = |
| 2640 | dfZ1 != 0.0 || dfZ2 != 0.0 || dfZ3 != 0.0 || dfZ4 != 0.0; |
| 2641 | |
| 2642 | // check how many unique corners we have |
| 2643 | OGRPointcxx . . $ OGRPoint# oCornerscxx . . $ OGRPoint#OGRPoint(49f6e7a06ebc5aa8).[4]; |
| 2644 | oCorners[0].setXcxx . . $ OGRPoint#setX(ba8836b59fb42830).(dfX1); |
| 2645 | oCorners[0].setYcxx . . $ OGRPoint#setY(ba8836b59fb42830).(dfY1); |
| 2646 | if (bWantZ) |
| 2647 | oCorners[0].setZcxx . . $ OGRPoint#setZ(ba8836b59fb42830).(dfZ1); |
| 2648 | oCorners[1].setXcxx . . $ OGRPoint#setX(ba8836b59fb42830).(dfX2); |
| 2649 | oCorners[1].setYcxx . . $ OGRPoint#setY(ba8836b59fb42830).(dfY2); |
| 2650 | if (bWantZ) |
| 2651 | oCorners[1].setZcxx . . $ OGRPoint#setZ(ba8836b59fb42830).(dfZ2); |
| 2652 | oCorners[2].setXcxx . . $ OGRPoint#setX(ba8836b59fb42830).(dfX3); |
| 2653 | oCorners[2].setYcxx . . $ OGRPoint#setY(ba8836b59fb42830).(dfY3); |
| 2654 | if (bWantZ) |
| 2655 | oCorners[2].setZcxx . . $ OGRPoint#setZ(ba8836b59fb42830).(dfZ3); |
| 2656 | oCorners[3].setXcxx . . $ OGRPoint#setX(ba8836b59fb42830).(dfX4); |
| 2657 | oCorners[3].setYcxx . . $ OGRPoint#setY(ba8836b59fb42830).(dfY4); |
| 2658 | if (bWantZ) |
| 2659 | oCorners[3].setZcxx . . $ OGRPoint#setZ(ba8836b59fb42830).(dfZ4); |
| 2660 | |
| 2661 | stdcxx . . $ std/::sortcxx . . $ std/sort(4d3091562df4e52e).(&oCorners[0], &oCorners[4], PointXAxisComparercxx . . $ PointXAxisComparer(3adfba4fa64e1053).); |
| 2662 | int nCornerCount = static_cast<int>( |
| 2663 | stdcxx . . $ std/::uniquecxx . . $ std/unique(f0a0a4f94ee5cb00).(&oCorners[0], &oCorners[4], PointXYZEqualityComparercxx . . $ PointXYZEqualityComparer(3adfba4fa64e1053).) - |
| 2664 | &oCorners[0]); |
| 2665 | if (nCornerCount < 1) |
| 2666 | { |
| 2667 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2668 | return nullptr; |
| 2669 | } |
| 2670 | |
| 2671 | stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#> poFinalGeom; |
| 2672 | |
| 2673 | // what kind of object do we need? |
| 2674 | if (nCornerCount == 1) |
| 2675 | { |
| 2676 | poFinalGeom.reset(oCorners[0].clonecxx . . $ OGRPoint#clone(55168d33c3bbbbaa).()); |
| 2677 | |
| 2678 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2679 | } |
| 2680 | else if (nCornerCount == 2) |
| 2681 | { |
| 2682 | auto poLS = stdcxx . . $ std/::make_unique<OGRLineStringcxx . . $ OGRLineString#>(); |
| 2683 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(0, &oCorners[0]); |
| 2684 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(e3539a2fde6244df).(1, &oCorners[1]); |
| 2685 | poFinalGeom.reset(poLS.release()); |
| 2686 | |
| 2687 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2688 | } |
| 2689 | else |
| 2690 | { |
| 2691 | // SOLID vertices seem to be joined in the order 1-2-4-3-1. |
| 2692 | // See trac ticket #7089 |
| 2693 | OGRLinearRingcxx . . $ OGRLinearRing# *poLinearRing = new OGRLinearRingcxx . . $ OGRLinearRing#OGRLinearRing(49f6e7a06ebc5aa8).(); |
| 2694 | int iIndex = 0; |
| 2695 | poLinearRing->setPointcxx . . $ OGRSimpleCurve#setPoint(e4764ef0909f73e).(iIndex++, dfX1, dfY1, dfZ1); |
| 2696 | if (dfX1 != dfX2 || dfY1 != dfY2 || dfZ1 != dfZ2) |
| 2697 | poLinearRing->setPointcxx . . $ OGRSimpleCurve#setPoint(e4764ef0909f73e).(iIndex++, dfX2, dfY2, dfZ2); |
| 2698 | if (dfX2 != dfX4 || dfY2 != dfY4 || dfZ2 != dfZ4) |
| 2699 | poLinearRing->setPointcxx . . $ OGRSimpleCurve#setPoint(e4764ef0909f73e).(iIndex++, dfX4, dfY4, dfZ4); |
| 2700 | if (dfX4 != dfX3 || dfY4 != dfY3 || dfZ4 != dfZ3) |
| 2701 | poLinearRing->setPointcxx . . $ OGRSimpleCurve#setPoint(e4764ef0909f73e).(iIndex++, dfX3, dfY3, dfZ3); |
| 2702 | poLinearRing->closeRingscxx . . $ OGRLinearRing#closeRings(49f6e7a06ebc5aa8).(); |
| 2703 | |
| 2704 | if (!bWantZ) |
| 2705 | poLinearRing->flattenTo2Dcxx . . $ OGRSimpleCurve#flattenTo2D(49f6e7a06ebc5aa8).(); |
| 2706 | |
| 2707 | auto poPoly = stdcxx . . $ std/::make_unique<OGRPolygoncxx . . $ OGRPolygon#>(); |
| 2708 | poPoly->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poLinearRing); |
| 2709 | poFinalGeom.reset(poPoly.release()); |
| 2710 | |
| 2711 | PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2712 | } |
| 2713 | |
| 2714 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poFinalGeom.get()); |
| 2715 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poFinalGeom.release()); |
| 2716 | |
| 2717 | return poFeature.release(); |
| 2718 | } |
| 2719 | |
| 2720 | /************************************************************************/ |
| 2721 | /* TranslateASMEntity() */ |
| 2722 | /* */ |
| 2723 | /* Translate Autodesk ShapeManager entities (3DSOLID, REGION, */ |
| 2724 | /* SURFACE), also known as ACIS entities. */ |
| 2725 | /************************************************************************/ |
| 2726 | |
| 2727 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateASMEntitycxx . . $ OGRDXFLayer#TranslateASMEntity(e6624aae671b4354).() |
| 2728 | |
| 2729 | { |
| 2730 | char szLineBuf[257]; |
| 2731 | int nCode = 0; |
| 2732 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2733 | |
| 2734 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2735 | { |
| 2736 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2737 | } |
| 2738 | |
| 2739 | if (nCode < 0) |
| 2740 | { |
| 2741 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2742 | return nullptr; |
| 2743 | } |
| 2744 | |
| 2745 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2746 | |
| 2747 | const char *pszEntityHandle = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("EntityHandle"); |
| 2748 | |
| 2749 | // The actual data is located at the end of the DXF file (sigh). |
| 2750 | const GBytecxx . . $ GByte# *pabyBinaryData; |
| 2751 | size_t nDataLength = |
| 2752 | poDScxx . . $ OGRDXFLayer#poDS.->GetEntryFromAcDsDataSectioncxx . . $ OGRDXFDataSource#GetEntryFromAcDsDataSection(f14b2194c690bca8).(pszEntityHandle, &pabyBinaryData); |
| 2753 | if (!pabyBinaryData) |
| 2754 | { |
| 2755 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2756 | "ACDSRECORD data for entity %s was not found.", |
| 2757 | pszEntityHandle); |
| 2758 | return poFeature.release(); |
| 2759 | } |
| 2760 | |
| 2761 | // Return a feature with no geometry but with one very interesting field. |
| 2762 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(fa49024a5dd9af3b).(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->GetFieldIndexcxx . . $ OGRFeatureDefn#GetFieldIndex(78f035161ffa9fe2).("ASMData"), |
| 2763 | static_cast<int>(nDataLength), pabyBinaryData); |
| 2764 | |
| 2765 | // Set up an affine transformation matrix so the user will be able to |
| 2766 | // transform the resulting 3D geometry |
| 2767 | poFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform. = stdcxx . . $ std/::make_unique<OGRDXFAffineTransformcxx . . $ OGRDXFAffineTransform#>(); |
| 2768 | |
| 2769 | poFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform.->SetFieldcxx . . $ OGRDXFAffineTransform#SetField(13efe1a5a1e805dd).(poFeature.get(), "ASMTransform"); |
| 2770 | |
| 2771 | #ifdef notdef |
| 2772 | FILE *fp; |
| 2773 | fopen_s(&fp, |
| 2774 | CPLString().Printf("C:\\Projects\\output.sab", pszEntityHandle), |
| 2775 | "wb"); |
| 2776 | |
| 2777 | if (fp != nullptr) |
| 2778 | { |
| 2779 | fprintf(fp, "Entity handle: %s\r\n\r\n", pszEntityHandle); |
| 2780 | fwrite(pabyBinaryData, sizeof(GByte), nDataLength, fp); |
| 2781 | if (ferror(fp) != 0) |
| 2782 | { |
| 2783 | fputs("Error writing .sab file", stderr); |
| 2784 | } |
| 2785 | fclose(fp); |
| 2786 | } |
| 2787 | #endif |
| 2788 | |
| 2789 | PrepareBrushStylecxx . . $ OGRDXFLayer#PrepareBrushStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 2790 | |
| 2791 | return poFeature.release(); |
| 2792 | } |
| 2793 | |
| 2794 | /************************************************************************/ |
| 2795 | /* SimplifyBlockGeometry() */ |
| 2796 | /************************************************************************/ |
| 2797 | |
| 2798 | OGRGeometrycxx . . $ OGRGeometry# * |
| 2799 | OGRDXFLayercxx . . $ OGRDXFLayer#::SimplifyBlockGeometrycxx . . $ OGRDXFLayer#SimplifyBlockGeometry(fa923c2636946706).(OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poCollection) |
| 2800 | { |
| 2801 | /* -------------------------------------------------------------------- */ |
| 2802 | /* If there is only one geometry in the collection, just return */ |
| 2803 | /* it. */ |
| 2804 | /* -------------------------------------------------------------------- */ |
| 2805 | if (poCollection->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).() == 1) |
| 2806 | { |
| 2807 | OGRGeometrycxx . . $ OGRGeometry# *poReturn = poCollection->getGeometryRefcxx . . $ OGRGeometryCollection#getGeometryRef(ea443ccec24c6360).(0); |
| 2808 | poCollection->removeGeometrycxx . . $ OGRGeometryCollection#removeGeometry(9b79fb6aee4c0440).(0, FALSEcxx . . $ `port/cpl_port.h:1180:9`!); |
| 2809 | delete poCollection; |
| 2810 | return poReturn; |
| 2811 | } |
| 2812 | |
| 2813 | /* -------------------------------------------------------------------- */ |
| 2814 | /* Convert to polygon, multipolygon, multilinestring or multipoint */ |
| 2815 | /* -------------------------------------------------------------------- */ |
| 2816 | |
| 2817 | OGRwkbGeometryType eType = |
| 2818 | wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poCollection->getGeometryRef(0)->getGeometryType()); |
| 2819 | for (int i = 1; i < poCollection->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).(); i++) |
| 2820 | { |
| 2821 | if (wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poCollection->getGeometryRef(i)->getGeometryType()) != |
| 2822 | eType) |
| 2823 | { |
| 2824 | eType = wkbUnknown; |
| 2825 | break; |
| 2826 | } |
| 2827 | } |
| 2828 | if (eType == wkbPoint || eType == wkbLineString) |
| 2829 | { |
| 2830 | OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poNewColl; |
| 2831 | if (eType == wkbPoint) |
| 2832 | poNewColl = new OGRMultiPointcxx . . $ OGRMultiPoint#OGRMultiPoint(49f6e7a06ebc5aa8).(); |
| 2833 | else |
| 2834 | poNewColl = new OGRMultiLineStringcxx . . $ OGRMultiLineString#OGRMultiLineString(49f6e7a06ebc5aa8).(); |
| 2835 | while (poCollection->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).() > 0) |
| 2836 | { |
| 2837 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = poCollection->getGeometryRefcxx . . $ OGRGeometryCollection#getGeometryRef(ea443ccec24c6360).(0); |
| 2838 | poCollection->removeGeometrycxx . . $ OGRGeometryCollection#removeGeometry(9b79fb6aee4c0440).(0, FALSEcxx . . $ `port/cpl_port.h:1180:9`!); |
| 2839 | poNewColl->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 2840 | } |
| 2841 | delete poCollection; |
| 2842 | return poNewColl; |
| 2843 | } |
| 2844 | else if (eType == wkbPolygon) |
| 2845 | { |
| 2846 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>> apoPolygons; |
| 2847 | const int nSubGeoms = poCollection->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).(); |
| 2848 | for (int i = nSubGeoms - 1; i >= 0; --i) |
| 2849 | { |
| 2850 | auto poGeom = poCollection->stealGeometrycxx . . $ OGRGeometryCollection#stealGeometry(ccdaaf29b8fa7664).(i); |
| 2851 | // This test avoids a performance issue as in |
| 2852 | // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8067 |
| 2853 | if (apoPolygons.empty() || !apoPolygons[0]->Equalscxx . . $ OGRGeometry#Equals(eb832217f7fb7f92).(poGeom.get())) |
| 2854 | { |
| 2855 | apoPolygons.push_back(stdcxx . . $ std/::move(poGeom)); |
| 2856 | } |
| 2857 | } |
| 2858 | stdcxx . . $ std/::reversecxx . . $ std/reverse(249673c20e2b8d5).(apoPolygons.begin(), apoPolygons.end()); |
| 2859 | delete poCollection; |
| 2860 | return OGRGeometryFactorycxx . . $ OGRGeometryFactory#::organizePolygonscxx . . $ OGRGeometryFactory#organizePolygons(36da63c1caf5e687).(apoPolygons).release(); |
| 2861 | } |
| 2862 | |
| 2863 | return poCollection; |
| 2864 | } |
| 2865 | |
| 2866 | /************************************************************************/ |
| 2867 | /* TranslateWIPEOUT() */ |
| 2868 | /* */ |
| 2869 | /* Translate Autodesk Wipeout entities */ |
| 2870 | /* This function reads only the geometry of the image outline and */ |
| 2871 | /* doesn't output the embedded image */ |
| 2872 | /************************************************************************/ |
| 2873 | |
| 2874 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateWIPEOUTcxx . . $ OGRDXFLayer#TranslateWIPEOUT(e6624aae671b4354).() |
| 2875 | |
| 2876 | { |
| 2877 | char szLineBuf[257]; |
| 2878 | int nCode; |
| 2879 | auto poFeature = stdcxx . . $ std/::make_unique<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.); |
| 2880 | double dfX = 0.0, dfY = 0.0, dfXOffset = 0.0, dfYOffset = 0.0; |
| 2881 | double dfXscale = 1.0, dfYscale = 1.0; |
| 2882 | |
| 2883 | int nNumVertices = 0; |
| 2884 | int nBoundaryVertexCount = 0; |
| 2885 | int nFormat = 0; |
| 2886 | |
| 2887 | DXFSmoothPolylinecxx . . $ DXFSmoothPolyline# smoothPolylinecxx . . $ DXFSmoothPolyline#DXFSmoothPolyline(49f6e7a06ebc5aa8).; |
| 2888 | |
| 2889 | smoothPolyline.setCoordinateDimensioncxx . . $ DXFSmoothPolyline#setCoordinateDimension(d4f767463ce0a6b3).(2); |
| 2890 | |
| 2891 | /* Read main feature properties as class, insertion point (in WCS) */ |
| 2892 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 2893 | { |
| 2894 | if (nBoundaryVertexCount > nNumVertices) |
| 2895 | { |
| 2896 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2897 | "Too many vertices found in WIPEOUT."); |
| 2898 | return nullptr; |
| 2899 | } |
| 2900 | |
| 2901 | switch (nCode) |
| 2902 | { |
| 2903 | /* Group codes 10, 20 control the insertion point of the lower |
| 2904 | left corner of your image. */ |
| 2905 | case 10: |
| 2906 | dfXOffset = CPLAtof(szLineBuf); |
| 2907 | break; |
| 2908 | |
| 2909 | case 20: |
| 2910 | dfYOffset = CPLAtof(szLineBuf); |
| 2911 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfXOffset, dfYOffset, 0.0, 0.0); |
| 2912 | break; |
| 2913 | |
| 2914 | /* --------------------------------------------------------------------- */ |
| 2915 | /* The group codes 11, 21 and 31 are used to define a vector in 3D space */ |
| 2916 | /* that is the endpoint of a line whose start point is assumed to be */ |
| 2917 | /* 0,0,0, regardless of the origin point of the image. */ |
| 2918 | /* These group codes describe a relative vector. */ |
| 2919 | /* --------------------------------------------------------------------- */ |
| 2920 | |
| 2921 | case 11: |
| 2922 | dfXscale = CPLAtof(szLineBuf); |
| 2923 | break; |
| 2924 | |
| 2925 | case 22: |
| 2926 | dfYscale = CPLAtof(szLineBuf); |
| 2927 | break; |
| 2928 | |
| 2929 | case 31: |
| 2930 | break; |
| 2931 | |
| 2932 | /* Read image properties and set them in feature style (contrast...) */ |
| 2933 | case 281: |
| 2934 | break; |
| 2935 | |
| 2936 | case 282: |
| 2937 | break; |
| 2938 | |
| 2939 | case 293: |
| 2940 | break; |
| 2941 | |
| 2942 | case 71: |
| 2943 | nFormat = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 2944 | if (nFormat == 1) |
| 2945 | { |
| 2946 | // Here ignore feature because point format set to 1 is not supported |
| 2947 | CPLError( |
| 2948 | CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2949 | "Format of points in WIPEOUT entity not supported."); |
| 2950 | return nullptr; |
| 2951 | } |
| 2952 | break; |
| 2953 | |
| 2954 | case 91: |
| 2955 | nNumVertices = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 2956 | break; |
| 2957 | |
| 2958 | /* -------------------------------------------------------------------- */ |
| 2959 | /* Read clipping boundary properties and set them feature geometry */ |
| 2960 | /* Collect vertices as a smooth polyline. */ |
| 2961 | /* -------------------------------------------------------------------- */ |
| 2962 | case 14: |
| 2963 | dfX = CPLAtof(szLineBuf); |
| 2964 | break; |
| 2965 | |
| 2966 | case 24: |
| 2967 | dfY = CPLAtof(szLineBuf); |
| 2968 | smoothPolyline.AddPointcxx . . $ DXFSmoothPolyline#AddPoint(52a61fa14d44b641).(dfXOffset + (0.5 + dfX) * dfXscale, |
| 2969 | dfYOffset + (0.5 - dfY) * dfYscale, 0.0, |
| 2970 | 0.0); |
| 2971 | nBoundaryVertexCount++; |
| 2972 | break; |
| 2973 | |
| 2974 | default: |
| 2975 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).(poFeature.get(), nCode, szLineBuf); |
| 2976 | break; |
| 2977 | } |
| 2978 | } |
| 2979 | if (nCode < 0) |
| 2980 | { |
| 2981 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 2982 | return nullptr; |
| 2983 | } |
| 2984 | |
| 2985 | if (nCode == 0) |
| 2986 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 2987 | |
| 2988 | if (smoothPolyline.IsEmptycxx . . $ DXFSmoothPolyline#IsEmpty(50ce9a9e25b4a850).()) |
| 2989 | { |
| 2990 | return nullptr; |
| 2991 | } |
| 2992 | |
| 2993 | /* -------------------------------------------------------------------- */ |
| 2994 | /* Close polyline to output polygon geometry. */ |
| 2995 | /* -------------------------------------------------------------------- */ |
| 2996 | smoothPolyline.Closecxx . . $ DXFSmoothPolyline#Close(49f6e7a06ebc5aa8).(); |
| 2997 | |
| 2998 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = smoothPolyline.Tessellatecxx . . $ DXFSmoothPolyline#Tessellate(9bece52a439d3243).(TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 2999 | |
| 3000 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 3001 | |
| 3002 | // Set style pen color |
| 3003 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature.get()); |
| 3004 | |
| 3005 | return poFeature.release(); |
| 3006 | } |
| 3007 | |
| 3008 | /************************************************************************/ |
| 3009 | |
| 3010 | /************************************************************************/ |
| 3011 | /* InsertBlockReference() */ |
| 3012 | /* */ |
| 3013 | /* Returns a point geometry located at the block's insertion */ |
| 3014 | /* point. */ |
| 3015 | /************************************************************************/ |
| 3016 | OGRDXFFeaturecxx . . $ OGRDXFFeature# * |
| 3017 | OGRDXFLayercxx . . $ OGRDXFLayer#::InsertBlockReferencecxx . . $ OGRDXFLayer#InsertBlockReference(673cd2db3cbbd3e7).(const CPLString &osBlockName, |
| 3018 | const OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# &oTransformer, |
| 3019 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poFeature) |
| 3020 | { |
| 3021 | // Store the block's properties in the special DXF-specific members |
| 3022 | // on the feature object |
| 3023 | poFeature->bIsBlockReferencecxx . . $ OGRDXFFeature#bIsBlockReference. = true; |
| 3024 | poFeature->osBlockNamecxx . . $ OGRDXFFeature#osBlockName. = osBlockName; |
| 3025 | poFeature->dfBlockAnglecxx . . $ OGRDXFFeature#dfBlockAngle. = oTransformer.dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle. * 180 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!; |
| 3026 | poFeature->oBlockScalecxx . . $ OGRDXFFeature#oBlockScale. =cxx . . $ DXFTriple#`operator=`(6f9f1b49437be6c6). DXFTriplecxx . . $ DXFTriple#DXFTriple(98dd472ac7e5c3d4).( |
| 3027 | oTransformer.dfXScalecxx . . $ OGRDXFInsertTransformer#dfXScale., oTransformer.dfYScalecxx . . $ OGRDXFInsertTransformer#dfYScale., oTransformer.dfZScalecxx . . $ OGRDXFInsertTransformer#dfZScale.); |
| 3028 | poFeature->oOriginalCoordscxx . . $ OGRDXFFeature#oOriginalCoords. =cxx . . $ DXFTriple#`operator=`(6f9f1b49437be6c6). DXFTriplecxx . . $ DXFTriple#DXFTriple(98dd472ac7e5c3d4).( |
| 3029 | oTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset., oTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset., oTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset.); |
| 3030 | |
| 3031 | // Only if DXF_INLINE_BLOCKS is false should we ever need to expose these |
| 3032 | // to the end user as fields. |
| 3033 | if (poFeature->GetFieldIndexcxx . . $ OGRFeature#GetFieldIndex(78f035161ffa9fe2).("BlockName") != -1) |
| 3034 | { |
| 3035 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).("BlockName", poFeature->osBlockNamecxx . . $ OGRDXFFeature#osBlockName.); |
| 3036 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(d6fe15e337e23cca).("BlockAngle", poFeature->dfBlockAnglecxx . . $ OGRDXFFeature#dfBlockAngle.); |
| 3037 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(bc43acbabd03d582).("BlockScale", 3, &(poFeature->oBlockScalecxx . . $ OGRDXFFeature#oBlockScale..dfXcxx . . $ DXFTriple#dfX.)); |
| 3038 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(bc43acbabd03d582).("BlockOCSNormal", 3, &(poFeature->oOCScxx . . $ OGRDXFFeature#oOCS..dfXcxx . . $ DXFTriple#dfX.)); |
| 3039 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(bc43acbabd03d582).("BlockOCSCoords", 3, |
| 3040 | &(poFeature->oOriginalCoordscxx . . $ OGRDXFFeature#oOriginalCoords..dfXcxx . . $ DXFTriple#dfX.)); |
| 3041 | } |
| 3042 | |
| 3043 | // For convenience to the end user, the point geometry will be located |
| 3044 | // at the WCS coordinates of the insertion point. |
| 3045 | OGRPointcxx . . $ OGRPoint# *poInsertionPoint = new OGRPointcxx . . $ OGRPoint#OGRPoint(98dd472ac7e5c3d4).( |
| 3046 | oTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset., oTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset., oTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset.); |
| 3047 | |
| 3048 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poInsertionPoint); |
| 3049 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poInsertionPoint); |
| 3050 | |
| 3051 | return poFeature; |
| 3052 | } |
| 3053 | |
| 3054 | /************************************************************************/ |
| 3055 | /* InsertBlockInline() */ |
| 3056 | /* */ |
| 3057 | /* Inserts the given block at the location specified by the given */ |
| 3058 | /* transformer. Returns poFeature, or NULL if all features on */ |
| 3059 | /* the block have been pushed to the extra feature queue. */ |
| 3060 | /* If poFeature is not returned, it is deleted. */ |
| 3061 | /* Throws std::invalid_argument if the requested block */ |
| 3062 | /* doesn't exist. */ |
| 3063 | /* */ |
| 3064 | /* - poFeature: The feature to use as a template. This feature's */ |
| 3065 | /* OCS will be applied to the block. */ |
| 3066 | /* - bInlineRecursively: If true, INSERTs within this block */ |
| 3067 | /* will be recursively inserted. Otherwise, they will be */ |
| 3068 | /* represented as a point geometry using InsertBlockReference. */ |
| 3069 | /* - bMergeGeometry: If true, all features in the block, */ |
| 3070 | /* apart from text features, are merged into a */ |
| 3071 | /* GeometryCollection which is returned by the function. */ |
| 3072 | /************************************************************************/ |
| 3073 | |
| 3074 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::InsertBlockInlinecxx . . $ OGRDXFLayer#InsertBlockInline(10516ba2e234833c).( |
| 3075 | GUInt32cxx . . $ GUInt32# nInitialErrorCounter, const CPLString &osBlockName, |
| 3076 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oTransformer, OGRDXFFeaturecxx . . $ OGRDXFFeature# *const poFeature, |
| 3077 | OGRDXFFeatureQueuecxx . . $ OGRDXFFeatureQueue# &apoExtraFeatures, const bool bInlineRecursively, |
| 3078 | const bool bMergeGeometry) |
| 3079 | { |
| 3080 | /* -------------------------------------------------------------------- */ |
| 3081 | /* Set up protection against excessive recursion on this layer. */ |
| 3082 | /* -------------------------------------------------------------------- */ |
| 3083 | if (!poDScxx . . $ OGRDXFLayer#poDS.->PushBlockInsertioncxx . . $ OGRDXFDataSource#PushBlockInsertion(86da8d82cde12b2b).(osBlockName)) |
| 3084 | { |
| 3085 | delete poFeature; |
| 3086 | return nullptr; |
| 3087 | } |
| 3088 | |
| 3089 | /* -------------------------------------------------------------------- */ |
| 3090 | /* Transform the insertion point from OCS into */ |
| 3091 | /* world coordinates. */ |
| 3092 | /* -------------------------------------------------------------------- */ |
| 3093 | OGRPointcxx . . $ OGRPoint# oInsertionPointcxx . . $ OGRPoint#OGRPoint(98dd472ac7e5c3d4).(oTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset., oTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset., |
| 3094 | oTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset.); |
| 3095 | |
| 3096 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(&oInsertionPoint); |
| 3097 | |
| 3098 | oTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset. = oInsertionPoint.getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).(); |
| 3099 | oTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset. = oInsertionPoint.getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).(); |
| 3100 | oTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset. = oInsertionPoint.getZcxx . . $ OGRPoint#getZ(21b6c25e127938e2).(); |
| 3101 | |
| 3102 | /* -------------------------------------------------------------------- */ |
| 3103 | /* Lookup the block. */ |
| 3104 | /* -------------------------------------------------------------------- */ |
| 3105 | DXFBlockDefinitioncxx . . $ DXFBlockDefinition# *poBlock = poDScxx . . $ OGRDXFLayer#poDS.->LookupBlockcxx . . $ OGRDXFDataSource#LookupBlock(45c1b3460c056ef0).(osBlockName); |
| 3106 | |
| 3107 | if (poBlock == nullptr) |
| 3108 | { |
| 3109 | // CPLDebug( "DXF", "Attempt to insert missing block %s", osBlockName ); |
| 3110 | poDScxx . . $ OGRDXFLayer#poDS.->PopBlockInsertioncxx . . $ OGRDXFDataSource#PopBlockInsertion(49f6e7a06ebc5aa8).(); |
| 3111 | throw stdcxx . . $ std/::invalid_argument("osBlockName"); |
| 3112 | } |
| 3113 | |
| 3114 | /* -------------------------------------------------------------------- */ |
| 3115 | /* If we have complete features associated with the block, push */ |
| 3116 | /* them on the pending feature stack copying over key override */ |
| 3117 | /* information. */ |
| 3118 | /* */ |
| 3119 | /* If bMergeGeometry is true, we merge the features */ |
| 3120 | /* (except text) into a single GeometryCollection. */ |
| 3121 | /* -------------------------------------------------------------------- */ |
| 3122 | OGRGeometryCollectioncxx . . $ OGRGeometryCollection# *poMergedGeometry = nullptr; |
| 3123 | if (bMergeGeometry) |
| 3124 | poMergedGeometry = new OGRGeometryCollectioncxx . . $ OGRGeometryCollection#OGRGeometryCollection(49f6e7a06ebc5aa8).(); |
| 3125 | |
| 3126 | OGRDXFFeatureQueuecxx . . $ OGRDXFFeatureQueue# apoInnerExtraFeaturescxx . . $ OGRDXFFeatureQueue#OGRDXFFeatureQueue(49f6e7a06ebc5aa8).; |
| 3127 | |
| 3128 | for (unsigned int iSubFeat = 0; iSubFeat < poBlock->apoFeaturescxx . . $ DXFBlockDefinition#apoFeatures..size(); |
| 3129 | iSubFeat++) |
| 3130 | { |
| 3131 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *poSubFeature = |
| 3132 | poBlock->apoFeaturescxx . . $ DXFBlockDefinition#apoFeatures.[iSubFeat]->CloneDXFFeaturecxx . . $ OGRDXFFeature#CloneDXFFeature(e6624aae671b4354).(); |
| 3133 | |
| 3134 | // If the template feature is in PaperSpace, set this on the |
| 3135 | // subfeature too |
| 3136 | if (poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("PaperSpace")) |
| 3137 | poSubFeature->SetFieldcxx . . $ OGRFeature#SetField(34d26762b42c433a).("PaperSpace", 1); |
| 3138 | |
| 3139 | // Does this feature represent a block reference? If so, |
| 3140 | // insert that block |
| 3141 | if (bInlineRecursively && poSubFeature->IsBlockReferencecxx . . $ OGRDXFFeature#IsBlockReference(50ce9a9e25b4a850).()) |
| 3142 | { |
| 3143 | // Unpack the transformation data stored in fields of this |
| 3144 | // feature |
| 3145 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oInnerTransformercxx . . $ OGRDXFInsertTransformer#OGRDXFInsertTransformer(ced63f7c635d850d).; |
| 3146 | oInnerTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset. = poSubFeature->oOriginalCoordscxx . . $ OGRDXFFeature#oOriginalCoords..dfXcxx . . $ DXFTriple#dfX.; |
| 3147 | oInnerTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset. = poSubFeature->oOriginalCoordscxx . . $ OGRDXFFeature#oOriginalCoords..dfYcxx . . $ DXFTriple#dfY.; |
| 3148 | oInnerTransformer.dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset. = poSubFeature->oOriginalCoordscxx . . $ OGRDXFFeature#oOriginalCoords..dfZcxx . . $ DXFTriple#dfZ.; |
| 3149 | oInnerTransformer.dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle. = poSubFeature->dfBlockAnglecxx . . $ OGRDXFFeature#dfBlockAngle. * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! / 180; |
| 3150 | oInnerTransformer.dfXScalecxx . . $ OGRDXFInsertTransformer#dfXScale. = poSubFeature->oBlockScalecxx . . $ OGRDXFFeature#oBlockScale..dfXcxx . . $ DXFTriple#dfX.; |
| 3151 | oInnerTransformer.dfYScalecxx . . $ OGRDXFInsertTransformer#dfYScale. = poSubFeature->oBlockScalecxx . . $ OGRDXFFeature#oBlockScale..dfYcxx . . $ DXFTriple#dfY.; |
| 3152 | oInnerTransformer.dfZScalecxx . . $ OGRDXFInsertTransformer#dfZScale. = poSubFeature->oBlockScalecxx . . $ OGRDXFFeature#oBlockScale..dfZcxx . . $ DXFTriple#dfZ.; |
| 3153 | |
| 3154 | poSubFeature->bIsBlockReferencecxx . . $ OGRDXFFeature#bIsBlockReference. = false; |
| 3155 | |
| 3156 | // Keep a reference to the attributes that need to be inserted |
| 3157 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRDXFFeaturecxx . . $ OGRDXFFeature#>> apoInnerAttribFeatures = |
| 3158 | stdcxx . . $ std/::move(poSubFeature->apoAttribFeaturescxx . . $ OGRDXFFeature#apoAttribFeatures.); |
| 3159 | |
| 3160 | // Insert this block recursively |
| 3161 | try |
| 3162 | { |
| 3163 | poSubFeature = InsertBlockInlinecxx . . $ OGRDXFLayer#InsertBlockInline(10516ba2e234833c).( |
| 3164 | nInitialErrorCounter, poSubFeature->osBlockNamecxx . . $ OGRDXFFeature#osBlockName., |
| 3165 | stdcxx . . $ std/::move(oInnerTransformer), poSubFeature, |
| 3166 | apoInnerExtraFeatures, true, bMergeGeometry); |
| 3167 | } |
| 3168 | catch (const stdcxx . . $ std/::invalid_argument &) |
| 3169 | { |
| 3170 | // Block doesn't exist. Skip it and keep going |
| 3171 | delete poSubFeature; |
| 3172 | if (CPLGetErrorCounter() > nInitialErrorCounter + 1000) |
| 3173 | { |
| 3174 | break; |
| 3175 | } |
| 3176 | continue; |
| 3177 | } |
| 3178 | |
| 3179 | if (!poSubFeature) |
| 3180 | { |
| 3181 | if (CPLGetErrorCounter() > nInitialErrorCounter + 1000) |
| 3182 | { |
| 3183 | break; |
| 3184 | } |
| 3185 | |
| 3186 | // Append the attribute features to the pending feature stack |
| 3187 | for (auto &poAttribFeature : apoInnerAttribFeatures) |
| 3188 | { |
| 3189 | // Clear the attribute tag so the feature doesn't get mistaken |
| 3190 | // for an ATTDEF and skipped |
| 3191 | poAttribFeature->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag. = ""; |
| 3192 | |
| 3193 | apoInnerExtraFeatures.pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(poAttribFeature.release()); |
| 3194 | } |
| 3195 | |
| 3196 | if (apoInnerExtraFeatures.emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 3197 | { |
| 3198 | // Block is empty and has no attributes. Skip it and keep going |
| 3199 | continue; |
| 3200 | } |
| 3201 | else |
| 3202 | { |
| 3203 | // Load up the first extra feature ready for |
| 3204 | // transformation |
| 3205 | poSubFeature = apoInnerExtraFeatures.frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).(); |
| 3206 | apoInnerExtraFeatures.popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 3207 | } |
| 3208 | } |
| 3209 | } |
| 3210 | |
| 3211 | // Go through the current feature and any extra features generated |
| 3212 | // by the recursive insert, and apply transformations |
| 3213 | while (true) |
| 3214 | { |
| 3215 | OGRGeometrycxx . . $ OGRGeometry# *poSubFeatGeom = poSubFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).(); |
| 3216 | if (poSubFeatGeom != nullptr) |
| 3217 | { |
| 3218 | // Rotation and scaling first |
| 3219 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oInnerTrans = |
| 3220 | oTransformer.GetRotateScaleTransformercxx . . $ OGRDXFInsertTransformer#GetRotateScaleTransformer(bf1dc6cb35fbffbf).(); |
| 3221 | poSubFeatGeom->transformcxx . . $ OGRGeometry#transform(8ea9c28d9400a78d).(&oInnerTrans); |
| 3222 | |
| 3223 | // Then the OCS to WCS transformation |
| 3224 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(a872eb556e1260b5).(poSubFeatGeom); |
| 3225 | |
| 3226 | // Offset translation last |
| 3227 | oInnerTrans =cxx . . $ OGRDXFInsertTransformer#`operator=`(65c7c78ca7877e9b). oTransformer.GetOffsetTransformercxx . . $ OGRDXFInsertTransformer#GetOffsetTransformer(bf1dc6cb35fbffbf).(); |
| 3228 | poSubFeatGeom->transformcxx . . $ OGRGeometry#transform(8ea9c28d9400a78d).(&oInnerTrans); |
| 3229 | } |
| 3230 | // Transform the specially-stored data for ASM entities |
| 3231 | else if (poSubFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform.) |
| 3232 | { |
| 3233 | // Rotation and scaling first |
| 3234 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oInnerTrans = |
| 3235 | oTransformer.GetRotateScaleTransformercxx . . $ OGRDXFInsertTransformer#GetRotateScaleTransformer(bf1dc6cb35fbffbf).(); |
| 3236 | poSubFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform.->ComposeWithcxx . . $ OGRDXFAffineTransform#ComposeWith(609a59e8213b163b).(oInnerTrans); |
| 3237 | |
| 3238 | // Then the OCS to WCS transformation |
| 3239 | poFeature->ApplyOCSTransformercxx . . $ OGRDXFFeature#ApplyOCSTransformer(95af7f32a2189d12).( |
| 3240 | poSubFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform..get()); |
| 3241 | |
| 3242 | // Offset translation last |
| 3243 | oInnerTrans =cxx . . $ OGRDXFInsertTransformer#`operator=`(65c7c78ca7877e9b). oTransformer.GetOffsetTransformercxx . . $ OGRDXFInsertTransformer#GetOffsetTransformer(bf1dc6cb35fbffbf).(); |
| 3244 | poSubFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform.->ComposeWithcxx . . $ OGRDXFAffineTransform#ComposeWith(609a59e8213b163b).(oInnerTrans); |
| 3245 | |
| 3246 | poSubFeature->poASMTransformcxx . . $ OGRDXFFeature#poASMTransform.->SetFieldcxx . . $ OGRDXFAffineTransform#SetField(13efe1a5a1e805dd).(poSubFeature, |
| 3247 | "ASMTransform"); |
| 3248 | } |
| 3249 | |
| 3250 | // If we are merging features, and this is not text or a block |
| 3251 | // reference, merge it into the GeometryCollection |
| 3252 | if (bMergeGeometry && |
| 3253 | (poSubFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).() == nullptr || |
| 3254 | strstr(poSubFeature->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).(), "LABEL") == nullptr) && |
| 3255 | !poSubFeature->IsBlockReferencecxx . . $ OGRDXFFeature#IsBlockReference(50ce9a9e25b4a850).() && |
| 3256 | poSubFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).()) |
| 3257 | { |
| 3258 | poMergedGeometry->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).( |
| 3259 | poSubFeature->StealGeometrycxx . . $ OGRFeature#StealGeometry(3dfc1d32c7db2584).()); |
| 3260 | delete poSubFeature; |
| 3261 | } |
| 3262 | // Import all other features, except ATTDEFs when inlining |
| 3263 | // recursively |
| 3264 | else if (!bInlineRecursively || poSubFeature->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag. == "") |
| 3265 | { |
| 3266 | // If the subfeature is on layer 0, this is a special case: the |
| 3267 | // subfeature should take on the style properties of the layer |
| 3268 | // the block is being inserted onto. |
| 3269 | // But don't do this if we are inserting onto a Blocks layer |
| 3270 | // (that is, the owning feature has no layer). |
| 3271 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poSubFeature->GetFieldAsString("Layer"), "0") && |
| 3272 | !EQUALcxx . . $ `port/cpl_port.h:532:9`!(poFeature->GetFieldAsString("Layer"), "")) |
| 3273 | { |
| 3274 | poSubFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).( |
| 3275 | "Layer", poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Layer")); |
| 3276 | } |
| 3277 | |
| 3278 | // Update the style string to replace ByBlock and ByLayer |
| 3279 | // values. |
| 3280 | PrepareFeatureStylecxx . . $ OGRDXFLayer#PrepareFeatureStyle(7c5a60073ff99cd2).(poSubFeature, poFeature); |
| 3281 | |
| 3282 | ACAdjustTextcxx . . $ ACAdjustText(2895f01e422713a3).(oTransformer.dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle. * 180 / M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!, |
| 3283 | oTransformer.dfXScalecxx . . $ OGRDXFInsertTransformer#dfXScale., oTransformer.dfYScalecxx . . $ OGRDXFInsertTransformer#dfYScale., |
| 3284 | poSubFeature); |
| 3285 | |
| 3286 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(poFeature->GetFieldAsString("EntityHandle"), "")) |
| 3287 | { |
| 3288 | poSubFeature->SetFieldcxx . . $ OGRFeature#SetField(2fa786934fe80e24).( |
| 3289 | "EntityHandle", |
| 3290 | poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("EntityHandle")); |
| 3291 | } |
| 3292 | |
| 3293 | apoExtraFeatures.pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(poSubFeature); |
| 3294 | } |
| 3295 | else |
| 3296 | { |
| 3297 | delete poSubFeature; |
| 3298 | } |
| 3299 | |
| 3300 | if (apoInnerExtraFeatures.emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 3301 | { |
| 3302 | break; |
| 3303 | } |
| 3304 | else |
| 3305 | { |
| 3306 | poSubFeature = apoInnerExtraFeatures.frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).(); |
| 3307 | apoInnerExtraFeatures.popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 3308 | } |
| 3309 | } |
| 3310 | } |
| 3311 | |
| 3312 | while (!apoInnerExtraFeatures.emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 3313 | { |
| 3314 | auto poFeatureToDelete = apoInnerExtraFeatures.frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).(); |
| 3315 | apoInnerExtraFeatures.popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 3316 | delete poFeatureToDelete; |
| 3317 | } |
| 3318 | |
| 3319 | poDScxx . . $ OGRDXFLayer#poDS.->PopBlockInsertioncxx . . $ OGRDXFDataSource#PopBlockInsertion(49f6e7a06ebc5aa8).(); |
| 3320 | |
| 3321 | /* -------------------------------------------------------------------- */ |
| 3322 | /* Return the merged geometry if applicable. Otherwise */ |
| 3323 | /* return NULL and let the machinery find the rest of the */ |
| 3324 | /* features in the pending feature stack. */ |
| 3325 | /* -------------------------------------------------------------------- */ |
| 3326 | if (bMergeGeometry) |
| 3327 | { |
| 3328 | if (poMergedGeometry->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).() == 0) |
| 3329 | { |
| 3330 | delete poMergedGeometry; |
| 3331 | } |
| 3332 | else |
| 3333 | { |
| 3334 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).( |
| 3335 | SimplifyBlockGeometrycxx . . $ OGRDXFLayer#SimplifyBlockGeometry(fa923c2636946706).(poMergedGeometry)); |
| 3336 | |
| 3337 | PrepareLineStylecxx . . $ OGRDXFLayer#PrepareLineStyle(7c5a60073ff99cd2).(poFeature); |
| 3338 | return poFeature; |
| 3339 | } |
| 3340 | } |
| 3341 | |
| 3342 | delete poFeature; |
| 3343 | return nullptr; |
| 3344 | } |
| 3345 | |
| 3346 | /************************************************************************/ |
| 3347 | /* TranslateINSERT() */ |
| 3348 | /************************************************************************/ |
| 3349 | |
| 3350 | bool OGRDXFLayercxx . . $ OGRDXFLayer#::TranslateINSERTcxx . . $ OGRDXFLayer#TranslateINSERT(c9857a73d68e59ba).() |
| 3351 | |
| 3352 | { |
| 3353 | char szLineBuf[257]; |
| 3354 | int nCode = 0; |
| 3355 | |
| 3356 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_poTemplateFeaturecxx . . $ OGRDXFLayer#InsertState#m_poTemplateFeature..reset(new OGRDXFFeaturecxx . . $ OGRDXFFeature#OGRDXFFeature(dc2636911e7adfe).(poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.)); |
| 3357 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer. =cxx . . $ OGRDXFInsertTransformer#`operator=`(65c7c78ca7877e9b). OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer#OGRDXFInsertTransformer(ced63f7c635d850d).(); |
| 3358 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_osBlockNamecxx . . $ OGRDXFLayer#InsertState#m_osBlockName..clear(); |
| 3359 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 1; |
| 3360 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 1; |
| 3361 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol. = 0; |
| 3362 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow. = 0; |
| 3363 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfColumnSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfColumnSpacing. = 0.0; |
| 3364 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfRowSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfRowSpacing. = 0.0; |
| 3365 | |
| 3366 | bool bHasAttribs = false; |
| 3367 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs..clear(); |
| 3368 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_aosAttribscxx . . $ OGRDXFLayer#InsertState#m_aosAttribs..Clear(); |
| 3369 | |
| 3370 | /* -------------------------------------------------------------------- */ |
| 3371 | /* Process values. */ |
| 3372 | /* -------------------------------------------------------------------- */ |
| 3373 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 3374 | { |
| 3375 | switch (nCode) |
| 3376 | { |
| 3377 | case 10: |
| 3378 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset. = CPLAtof(szLineBuf); |
| 3379 | break; |
| 3380 | |
| 3381 | case 20: |
| 3382 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset. = CPLAtof(szLineBuf); |
| 3383 | break; |
| 3384 | |
| 3385 | case 30: |
| 3386 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfZOffsetcxx . . $ OGRDXFInsertTransformer#dfZOffset. = CPLAtof(szLineBuf); |
| 3387 | break; |
| 3388 | |
| 3389 | case 41: |
| 3390 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfXScalecxx . . $ OGRDXFInsertTransformer#dfXScale. = CPLAtof(szLineBuf); |
| 3391 | break; |
| 3392 | |
| 3393 | case 42: |
| 3394 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfYScalecxx . . $ OGRDXFInsertTransformer#dfYScale. = CPLAtof(szLineBuf); |
| 3395 | break; |
| 3396 | |
| 3397 | case 43: |
| 3398 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfZScalecxx . . $ OGRDXFInsertTransformer#dfZScale. = CPLAtof(szLineBuf); |
| 3399 | break; |
| 3400 | |
| 3401 | case 44: |
| 3402 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfColumnSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfColumnSpacing. = CPLAtof(szLineBuf); |
| 3403 | break; |
| 3404 | |
| 3405 | case 45: |
| 3406 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfRowSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfRowSpacing. = CPLAtof(szLineBuf); |
| 3407 | break; |
| 3408 | |
| 3409 | case 50: |
| 3410 | // We want to transform this to radians. |
| 3411 | // It is apparently always in degrees regardless of $AUNITS |
| 3412 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle. = |
| 3413 | CPLAtof(szLineBuf) * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! / 180.0; |
| 3414 | break; |
| 3415 | |
| 3416 | case 66: |
| 3417 | bHasAttribs = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf) == 1; |
| 3418 | break; |
| 3419 | |
| 3420 | case 70: |
| 3421 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 3422 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. < 0) |
| 3423 | { |
| 3424 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 3425 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3426 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3427 | return false; |
| 3428 | } |
| 3429 | break; |
| 3430 | |
| 3431 | case 71: |
| 3432 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(szLineBuf); |
| 3433 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. < 0) |
| 3434 | { |
| 3435 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 3436 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3437 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3438 | return false; |
| 3439 | } |
| 3440 | break; |
| 3441 | |
| 3442 | case 2: |
| 3443 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_osBlockNamecxx . . $ OGRDXFLayer#InsertState#m_osBlockName. = szLineBuf; |
| 3444 | break; |
| 3445 | |
| 3446 | default: |
| 3447 | TranslateGenericPropertycxx . . $ OGRDXFLayer#TranslateGenericProperty(66d983117de70e31).( |
| 3448 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_poTemplateFeaturecxx . . $ OGRDXFLayer#InsertState#m_poTemplateFeature..get(), nCode, szLineBuf); |
| 3449 | break; |
| 3450 | } |
| 3451 | } |
| 3452 | if (nCode < 0) |
| 3453 | { |
| 3454 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 3455 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3456 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3457 | return false; |
| 3458 | } |
| 3459 | |
| 3460 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. == 0 || m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. == 0) |
| 3461 | { |
| 3462 | // AutoCad doesn't allow setting to 0 in its UI, but interprets 0 |
| 3463 | // as 1 (but other software such as LibreCAD interpret 0 as 0) |
| 3464 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 1; |
| 3465 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 1; |
| 3466 | } |
| 3467 | |
| 3468 | /* -------------------------------------------------------------------- */ |
| 3469 | /* Process any attribute entities. */ |
| 3470 | /* -------------------------------------------------------------------- */ |
| 3471 | |
| 3472 | if (bHasAttribs) |
| 3473 | { |
| 3474 | while (nCode == 0 && !EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "SEQEND")) |
| 3475 | { |
| 3476 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ATTRIB")) |
| 3477 | { |
| 3478 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 3479 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3480 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3481 | return false; |
| 3482 | } |
| 3483 | |
| 3484 | auto poAttribFeature = |
| 3485 | stdcxx . . $ std/::unique_ptr<OGRDXFFeaturecxx . . $ OGRDXFFeature#>(TranslateTEXTcxx . . $ OGRDXFLayer#TranslateTEXT(dbaf5f13b4270cb3).(true)); |
| 3486 | |
| 3487 | if (poAttribFeature && poAttribFeature->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag. != "") |
| 3488 | { |
| 3489 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs..emplace_back( |
| 3490 | stdcxx . . $ std/::move(poAttribFeature)); |
| 3491 | } |
| 3492 | |
| 3493 | nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf)); |
| 3494 | } |
| 3495 | } |
| 3496 | else if (nCode == 0) |
| 3497 | { |
| 3498 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 3499 | } |
| 3500 | |
| 3501 | /* -------------------------------------------------------------------- */ |
| 3502 | /* Prepare a string list of the attributes and their text values */ |
| 3503 | /* as space-separated entries, to be stored in the */ |
| 3504 | /* BlockAttributes field if we are not inlining blocks. */ |
| 3505 | /* -------------------------------------------------------------------- */ |
| 3506 | |
| 3507 | if (!poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).() && bHasAttribs && |
| 3508 | poFeatureDefncxx . . $ OGRDXFLayer#poFeatureDefn.->GetFieldIndexcxx . . $ OGRFeatureDefn#GetFieldIndex(78f035161ffa9fe2).("BlockAttributes") != -1) |
| 3509 | { |
| 3510 | for (const auto &poAttr : m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs.) |
| 3511 | { |
| 3512 | CPLString osAttribString = poAttr->osAttributeTagcxx . . $ OGRDXFFeature#osAttributeTag.; |
| 3513 | osAttribString += " "; |
| 3514 | osAttribString += poAttr->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(865ea18671f48fc1).("Text"); |
| 3515 | |
| 3516 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_aosAttribscxx . . $ OGRDXFLayer#InsertState#m_aosAttribs..AddString(osAttribString); |
| 3517 | } |
| 3518 | } |
| 3519 | |
| 3520 | return true; |
| 3521 | } |
| 3522 | |
| 3523 | /************************************************************************/ |
| 3524 | /* GenerateINSERTFeatures() */ |
| 3525 | /************************************************************************/ |
| 3526 | |
| 3527 | bool OGRDXFLayercxx . . $ OGRDXFLayer#::GenerateINSERTFeaturescxx . . $ OGRDXFLayer#GenerateINSERTFeatures(c9857a73d68e59ba).() |
| 3528 | { |
| 3529 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature = |
| 3530 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_poTemplateFeaturecxx . . $ OGRDXFLayer#InsertState#m_poTemplateFeature.->CloneDXFFeaturecxx . . $ OGRDXFFeature#CloneDXFFeature(e6624aae671b4354).(); |
| 3531 | |
| 3532 | const double dfExtraXOffset = |
| 3533 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol. * m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfColumnSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfColumnSpacing. * |
| 3534 | coscxx . . $ cos(fee4f1d22bc8e617).(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle.) + |
| 3535 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow. * m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfRowSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfRowSpacing. * |
| 3536 | -sincxx . . $ sin(fee4f1d22bc8e617).(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle.); |
| 3537 | const double dfExtraYOffset = |
| 3538 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol. * m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfColumnSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfColumnSpacing. * |
| 3539 | sincxx . . $ sin(fee4f1d22bc8e617).(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle.) + |
| 3540 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow. * m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_dfRowSpacingcxx . . $ OGRDXFLayer#InsertState#m_dfRowSpacing. * |
| 3541 | coscxx . . $ cos(fee4f1d22bc8e617).(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer..dfAnglecxx . . $ OGRDXFInsertTransformer#dfAngle.); |
| 3542 | |
| 3543 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oTransformer(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_oTransformercxx . . $ OGRDXFLayer#InsertState#m_oTransformer.); |
| 3544 | oTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset. += dfExtraXOffset; |
| 3545 | oTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset. += dfExtraYOffset; |
| 3546 | |
| 3547 | // If we are not inlining blocks, just insert a point that refers |
| 3548 | // to this block |
| 3549 | if (!poDScxx . . $ OGRDXFLayer#poDS.->InlineBlockscxx . . $ OGRDXFDataSource#InlineBlocks(50ce9a9e25b4a850).()) |
| 3550 | { |
| 3551 | poFeature = InsertBlockReferencecxx . . $ OGRDXFLayer#InsertBlockReference(673cd2db3cbbd3e7).(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_osBlockNamecxx . . $ OGRDXFLayer#InsertState#m_osBlockName., |
| 3552 | oTransformer, poFeature); |
| 3553 | |
| 3554 | auto papszAttribs = m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_aosAttribscxx . . $ OGRDXFLayer#InsertState#m_aosAttribs..List(); |
| 3555 | if (papszAttribs) |
| 3556 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(7bdc0c6e2c70929f).("BlockAttributes", papszAttribs); |
| 3557 | |
| 3558 | poFeature->apoAttribFeaturescxx . . $ OGRDXFFeature#apoAttribFeatures. = stdcxx . . $ std/::move(m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs.); |
| 3559 | |
| 3560 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(poFeature); |
| 3561 | } |
| 3562 | // Otherwise, try inlining the contents of this block |
| 3563 | else |
| 3564 | { |
| 3565 | OGRDXFFeatureQueuecxx . . $ OGRDXFFeatureQueue# apoExtraFeaturescxx . . $ OGRDXFFeatureQueue#OGRDXFFeatureQueue(49f6e7a06ebc5aa8).; |
| 3566 | try |
| 3567 | { |
| 3568 | poFeature = InsertBlockInlinecxx . . $ OGRDXFLayer#InsertBlockInline(10516ba2e234833c).( |
| 3569 | CPLGetErrorCounter(), m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_osBlockNamecxx . . $ OGRDXFLayer#InsertState#m_osBlockName., |
| 3570 | stdcxx . . $ std/::move(oTransformer), poFeature, apoExtraFeatures, true, |
| 3571 | poDScxx . . $ OGRDXFLayer#poDS.->ShouldMergeBlockGeometriescxx . . $ OGRDXFDataSource#ShouldMergeBlockGeometries(50ce9a9e25b4a850).()); |
| 3572 | } |
| 3573 | catch (const stdcxx . . $ std/::invalid_argument &) |
| 3574 | { |
| 3575 | // Block doesn't exist |
| 3576 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Block %s does not exist", |
| 3577 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_osBlockNamecxx . . $ OGRDXFLayer#InsertState#m_osBlockName..c_str()); |
| 3578 | delete poFeature; |
| 3579 | return false; |
| 3580 | } |
| 3581 | |
| 3582 | if (poFeature) |
| 3583 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(poFeature); |
| 3584 | |
| 3585 | while (!apoExtraFeatures.emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 3586 | { |
| 3587 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(apoExtraFeatures.frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).()); |
| 3588 | apoExtraFeatures.popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 3589 | } |
| 3590 | |
| 3591 | // Append the attribute features to the pending feature stack |
| 3592 | if (!m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs..empty()) |
| 3593 | { |
| 3594 | OGRDXFInsertTransformercxx . . $ OGRDXFInsertTransformer# oAttribTransformercxx . . $ OGRDXFInsertTransformer#OGRDXFInsertTransformer(ced63f7c635d850d).; |
| 3595 | oAttribTransformer.dfXOffsetcxx . . $ OGRDXFInsertTransformer#dfXOffset. = dfExtraXOffset; |
| 3596 | oAttribTransformer.dfYOffsetcxx . . $ OGRDXFInsertTransformer#dfYOffset. = dfExtraYOffset; |
| 3597 | |
| 3598 | for (const auto &poAttr : m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_apoAttribscxx . . $ OGRDXFLayer#InsertState#m_apoAttribs.) |
| 3599 | { |
| 3600 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *poAttribFeature = poAttr->CloneDXFFeaturecxx . . $ OGRDXFFeature#CloneDXFFeature(e6624aae671b4354).(); |
| 3601 | |
| 3602 | if (poAttribFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).()) |
| 3603 | { |
| 3604 | poAttribFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).()->transformcxx . . $ OGRGeometry#transform(8ea9c28d9400a78d).( |
| 3605 | &oAttribTransformer); |
| 3606 | } |
| 3607 | |
| 3608 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..pushcxx . . $ OGRDXFFeatureQueue#push(409eaf123d04801f).(poAttribFeature); |
| 3609 | } |
| 3610 | } |
| 3611 | } |
| 3612 | return true; |
| 3613 | } |
| 3614 | |
| 3615 | /************************************************************************/ |
| 3616 | /* GetNextUnfilteredFeature() */ |
| 3617 | /************************************************************************/ |
| 3618 | |
| 3619 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::GetNextUnfilteredFeaturecxx . . $ OGRDXFLayer#GetNextUnfilteredFeature(e6624aae671b4354).() |
| 3620 | |
| 3621 | { |
| 3622 | OGRDXFFeaturecxx . . $ OGRDXFFeature# *poFeature = nullptr; |
| 3623 | while (poFeature == nullptr) |
| 3624 | { |
| 3625 | /* -------------------------------------------------------------------- |
| 3626 | */ |
| 3627 | /* If we have pending features, return one of them. */ |
| 3628 | /* -------------------------------------------------------------------- |
| 3629 | */ |
| 3630 | if (!apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..emptycxx . . $ OGRDXFFeatureQueue#empty(50ce9a9e25b4a850).()) |
| 3631 | { |
| 3632 | poFeature = apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..frontcxx . . $ OGRDXFFeatureQueue#front(5702df0a4fb1fc65).(); |
| 3633 | apoPendingFeaturescxx . . $ OGRDXFLayer#apoPendingFeatures..popcxx . . $ OGRDXFFeatureQueue#pop(49f6e7a06ebc5aa8).(); |
| 3634 | |
| 3635 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(iNextFIDcxx . . $ OGRDXFLayer#iNextFID.++); |
| 3636 | return poFeature; |
| 3637 | } |
| 3638 | |
| 3639 | /* -------------------------------------------------------------------- |
| 3640 | */ |
| 3641 | /* Emit INSERT features. */ |
| 3642 | /* -------------------------------------------------------------------- |
| 3643 | */ |
| 3644 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow. < m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount.) |
| 3645 | { |
| 3646 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol. == m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount.) |
| 3647 | { |
| 3648 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow.++; |
| 3649 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol. = 0; |
| 3650 | if (m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurRowcxx . . $ OGRDXFLayer#InsertState#m_iCurRow. == m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount.) |
| 3651 | { |
| 3652 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3653 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3654 | continue; |
| 3655 | } |
| 3656 | } |
| 3657 | if (GenerateINSERTFeaturescxx . . $ OGRDXFLayer#GenerateINSERTFeatures(c9857a73d68e59ba).()) |
| 3658 | { |
| 3659 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_iCurColcxx . . $ OGRDXFLayer#InsertState#m_iCurCol.++; |
| 3660 | } |
| 3661 | else |
| 3662 | { |
| 3663 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nRowCountcxx . . $ OGRDXFLayer#InsertState#m_nRowCount. = 0; |
| 3664 | m_oInsertStatecxx . . $ OGRDXFLayer#m_oInsertState..m_nColumnCountcxx . . $ OGRDXFLayer#InsertState#m_nColumnCount. = 0; |
| 3665 | } |
| 3666 | continue; |
| 3667 | } |
| 3668 | |
| 3669 | // read ahead to an entity. |
| 3670 | char szLineBuf[257]; |
| 3671 | int nCode = 0; |
| 3672 | while ((nCode = poDScxx . . $ OGRDXFLayer#poDS.->ReadValuecxx . . $ OGRDXFDataSource#ReadValue(6abd07ddb1a912f0).(szLineBuf, sizeof(szLineBuf))) > 0) |
| 3673 | { |
| 3674 | } |
| 3675 | if (nCode < 0) |
| 3676 | { |
| 3677 | DXF_LAYER_READER_ERRORcxx . . $ `ogr/ogrsf_frmts/dxf/ogr_dxf.h:586:9`!(); |
| 3678 | return nullptr; |
| 3679 | } |
| 3680 | |
| 3681 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ENDSEC")) |
| 3682 | { |
| 3683 | // CPLDebug( "DXF", "Clean end of features at ENDSEC." ); |
| 3684 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 3685 | return nullptr; |
| 3686 | } |
| 3687 | |
| 3688 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ENDBLK")) |
| 3689 | { |
| 3690 | // CPLDebug( "DXF", "Clean end of block at ENDBLK." ); |
| 3691 | poDScxx . . $ OGRDXFLayer#poDS.->UnreadValuecxx . . $ OGRDXFDataSource#UnreadValue(49f6e7a06ebc5aa8).(); |
| 3692 | return nullptr; |
| 3693 | } |
| 3694 | |
| 3695 | /* -------------------------------------------------------------------- |
| 3696 | */ |
| 3697 | /* Handle the entity. */ |
| 3698 | /* -------------------------------------------------------------------- |
| 3699 | */ |
| 3700 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "POINT")) |
| 3701 | { |
| 3702 | poFeature = TranslatePOINTcxx . . $ OGRDXFLayer#TranslatePOINT(e6624aae671b4354).(); |
| 3703 | } |
| 3704 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "MTEXT")) |
| 3705 | { |
| 3706 | poFeature = TranslateMTEXTcxx . . $ OGRDXFLayer#TranslateMTEXT(e6624aae671b4354).(); |
| 3707 | } |
| 3708 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "TEXT")) |
| 3709 | { |
| 3710 | poFeature = TranslateTEXTcxx . . $ OGRDXFLayer#TranslateTEXT(dbaf5f13b4270cb3).(false); |
| 3711 | } |
| 3712 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ATTDEF")) |
| 3713 | { |
| 3714 | poFeature = TranslateTEXTcxx . . $ OGRDXFLayer#TranslateTEXT(dbaf5f13b4270cb3).(true); |
| 3715 | } |
| 3716 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "LINE")) |
| 3717 | { |
| 3718 | poFeature = TranslateLINEcxx . . $ OGRDXFLayer#TranslateLINE(e6624aae671b4354).(); |
| 3719 | } |
| 3720 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "POLYLINE")) |
| 3721 | { |
| 3722 | poFeature = TranslatePOLYLINEcxx . . $ OGRDXFLayer#TranslatePOLYLINE(e6624aae671b4354).(); |
| 3723 | } |
| 3724 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "LWPOLYLINE")) |
| 3725 | { |
| 3726 | poFeature = TranslateLWPOLYLINEcxx . . $ OGRDXFLayer#TranslateLWPOLYLINE(e6624aae671b4354).(); |
| 3727 | } |
| 3728 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "MLINE")) |
| 3729 | { |
| 3730 | poFeature = TranslateMLINEcxx . . $ OGRDXFLayer#TranslateMLINE(e6624aae671b4354).(); |
| 3731 | } |
| 3732 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "CIRCLE")) |
| 3733 | { |
| 3734 | poFeature = TranslateCIRCLEcxx . . $ OGRDXFLayer#TranslateCIRCLE(e6624aae671b4354).(); |
| 3735 | } |
| 3736 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ELLIPSE")) |
| 3737 | { |
| 3738 | poFeature = TranslateELLIPSEcxx . . $ OGRDXFLayer#TranslateELLIPSE(e6624aae671b4354).(); |
| 3739 | } |
| 3740 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "ARC")) |
| 3741 | { |
| 3742 | poFeature = TranslateARCcxx . . $ OGRDXFLayer#TranslateARC(e6624aae671b4354).(); |
| 3743 | } |
| 3744 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "SPLINE") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "HELIX")) |
| 3745 | { |
| 3746 | poFeature = TranslateSPLINEcxx . . $ OGRDXFLayer#TranslateSPLINE(e6624aae671b4354).(); |
| 3747 | } |
| 3748 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "3DFACE")) |
| 3749 | { |
| 3750 | poFeature = Translate3DFACEcxx . . $ OGRDXFLayer#Translate3DFACE(e6624aae671b4354).(); |
| 3751 | } |
| 3752 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "INSERT")) |
| 3753 | { |
| 3754 | if (!TranslateINSERTcxx . . $ OGRDXFLayer#TranslateINSERT(c9857a73d68e59ba).()) |
| 3755 | return nullptr; |
| 3756 | } |
| 3757 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "DIMENSION")) |
| 3758 | { |
| 3759 | poFeature = TranslateDIMENSIONcxx . . $ OGRDXFLayer#TranslateDIMENSION(e6624aae671b4354).(); |
| 3760 | } |
| 3761 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "HATCH")) |
| 3762 | { |
| 3763 | poFeature = TranslateHATCHcxx . . $ OGRDXFLayer#TranslateHATCH(e6624aae671b4354).(); |
| 3764 | } |
| 3765 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "SOLID") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "TRACE")) |
| 3766 | { |
| 3767 | poFeature = TranslateSOLIDcxx . . $ OGRDXFLayer#TranslateSOLID(e6624aae671b4354).(); |
| 3768 | } |
| 3769 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "LEADER")) |
| 3770 | { |
| 3771 | poFeature = TranslateLEADERcxx . . $ OGRDXFLayer#TranslateLEADER(e6624aae671b4354).(); |
| 3772 | } |
| 3773 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "MLEADER") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "MULTILEADER")) |
| 3774 | { |
| 3775 | poFeature = TranslateMLEADERcxx . . $ OGRDXFLayer#TranslateMLEADER(e6624aae671b4354).(); |
| 3776 | } |
| 3777 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "WIPEOUT")) |
| 3778 | { |
| 3779 | poFeature = TranslateWIPEOUTcxx . . $ OGRDXFLayer#TranslateWIPEOUT(e6624aae671b4354).(); |
| 3780 | } |
| 3781 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "3DSOLID") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "BODY") || |
| 3782 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "REGION") || EQUALcxx . . $ `port/cpl_port.h:532:9`!(szLineBuf, "SURFACE")) |
| 3783 | { |
| 3784 | if (poDScxx . . $ OGRDXFLayer#poDS.->In3DExtensibleModecxx . . $ OGRDXFDataSource#In3DExtensibleMode(50ce9a9e25b4a850).()) |
| 3785 | { |
| 3786 | poFeature = TranslateASMEntitycxx . . $ OGRDXFLayer#TranslateASMEntity(e6624aae671b4354).(); |
| 3787 | } |
| 3788 | else if (oIgnoredEntitiescxx . . $ OGRDXFLayer#oIgnoredEntities..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(szLineBuf) == 0) |
| 3789 | { |
| 3790 | oIgnoredEntitiescxx . . $ OGRDXFLayer#oIgnoredEntities..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(szLineBuf); |
| 3791 | CPLDebug("DXF", "3D mode is off; ignoring all '%s' entities.", |
| 3792 | szLineBuf); |
| 3793 | } |
| 3794 | } |
| 3795 | else |
| 3796 | { |
| 3797 | if (oIgnoredEntitiescxx . . $ OGRDXFLayer#oIgnoredEntities..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(szLineBuf) == 0) |
| 3798 | { |
| 3799 | oIgnoredEntitiescxx . . $ OGRDXFLayer#oIgnoredEntities..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(szLineBuf); |
| 3800 | CPLDebug("DXF", "Ignoring one or more of entity '%s'.", |
| 3801 | szLineBuf); |
| 3802 | } |
| 3803 | } |
| 3804 | } |
| 3805 | |
| 3806 | /* -------------------------------------------------------------------- */ |
| 3807 | /* Set FID. */ |
| 3808 | /* -------------------------------------------------------------------- */ |
| 3809 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(iNextFIDcxx . . $ OGRDXFLayer#iNextFID.++); |
| 3810 | m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead.++; |
| 3811 | |
| 3812 | return poFeature; |
| 3813 | } |
| 3814 | |
| 3815 | /************************************************************************/ |
| 3816 | /* GetNextFeature() */ |
| 3817 | /************************************************************************/ |
| 3818 | |
| 3819 | OGRFeaturecxx . . $ OGRFeature# *OGRDXFLayercxx . . $ OGRDXFLayer#::GetNextFeaturecxx . . $ OGRDXFLayer#GetNextFeature(ec9eceddec1d9563).() |
| 3820 | |
| 3821 | { |
| 3822 | while (true) |
| 3823 | { |
| 3824 | OGRFeaturecxx . . $ OGRFeature# *poFeature = GetNextUnfilteredFeaturecxx . . $ OGRDXFLayer#GetNextUnfilteredFeature(e6624aae671b4354).(); |
| 3825 | |
| 3826 | if (poFeature == nullptr) |
| 3827 | return nullptr; |
| 3828 | |
| 3829 | if ((m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr || |
| 3830 | FilterGeometrycxx . . $ OGRLayer#FilterGeometry(fed901b2566802ff).(poFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).())) && |
| 3831 | (m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr || m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery.->Evaluatecxx . . $ OGRFeatureQuery#Evaluate(2048609adab03aab).(poFeature))) |
| 3832 | { |
| 3833 | return poFeature; |
| 3834 | } |
| 3835 | |
| 3836 | delete poFeature; |
| 3837 | } |
| 3838 | } |
| 3839 | |
| 3840 | /************************************************************************/ |
| 3841 | /* TestCapability() */ |
| 3842 | /************************************************************************/ |
| 3843 | |
| 3844 | int OGRDXFLayercxx . . $ OGRDXFLayer#::TestCapabilitycxx . . $ OGRDXFLayer#TestCapability(78f035161ffa9fe2).(const char *pszCap) const |
| 3845 | |
| 3846 | { |
| 3847 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCStringsAsUTF8cxx . . $ `ogr/ogr_core.h:1016:9`!)) |
| 3848 | return true; |
| 3849 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCZGeometriescxx . . $ `ogr/ogr_core.h:1028:9`!)) |
| 3850 | return true; |
| 3851 | return false; |
| 3852 | } |
| 3853 | |
| 3854 | /************************************************************************/ |
| 3855 | /* GetDataset() */ |
| 3856 | /************************************************************************/ |
| 3857 | |
| 3858 | GDALDatasetcxx . . $ GDALDataset# *OGRDXFLayercxx . . $ OGRDXFLayer#::GetDatasetcxx . . $ OGRDXFLayer#GetDataset(76c1989f6ffbc048).() |
| 3859 | { |
| 3860 | return poDScxx . . $ OGRDXFLayer#poDS.; |
| 3861 | } |