|
23 | 23 | #include "ifcpp/Ifc/IfcFace.h"
|
24 | 24 | #include "ifcpp/Ifc/IfcFaceBasedSurfaceModel.h"
|
25 | 25 | #include "ifcpp/Ifc/IfcFeatureElementSubtraction.h"
|
| 26 | +#include "ifcpp/Ifc/IfcGeometricCurveSet.h" |
| 27 | +#include "ifcpp/Ifc/IfcGeometricSet.h" |
| 28 | +#include "ifcpp/Ifc/IfcMappedItem.h" |
26 | 29 | #include "ifcpp/Ifc/IfcObjectDefinition.h"
|
27 | 30 | #include "ifcpp/Ifc/IfcOpenShell.h"
|
28 | 31 | #include "ifcpp/Ifc/IfcProductRepresentation.h"
|
29 | 32 | #include "ifcpp/Ifc/IfcRelVoidsElement.h"
|
30 | 33 | #include "ifcpp/Ifc/IfcRepresentation.h"
|
| 34 | +#include "ifcpp/Ifc/IfcRepresentationMap.h" |
| 35 | +#include "ifcpp/Ifc/IfcSectionedSpine.h" |
31 | 36 | #include "ifcpp/Ifc/IfcShellBasedSurfaceModel.h"
|
32 | 37 | #include "ifcpp/Ifc/IfcSpace.h"
|
33 |
| -#include "ifcpp/Ifc/IfcMappedItem.h" |
34 |
| -#include "ifcpp/Ifc/IfcRepresentationMap.h" |
| 38 | +#include "ifcpp/Ifc/IfcTessellatedItem.h" |
| 39 | +#include "ifcpp/Ifc/IfcTextLiteral.h" |
| 40 | +#include "ifcpp/Ifc/IfcAnnotationFillArea.h" |
35 | 41 |
|
36 | 42 |
|
37 | 43 | namespace ifcpp {
|
@@ -145,8 +151,8 @@ class GeometryGenerator {
|
145 | 151 | std::copy( l.begin(), l.end(), std::back_inserter( polylines ) );
|
146 | 152 | }
|
147 | 153 |
|
148 |
| - auto matrix = TMatrix::GetScale( this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor ); |
149 |
| - TMatrix::Multiply( &matrix, this->m_primitivesConverter->ConvertPlacement( product->m_ObjectPlacement ) ); |
| 154 | + auto matrix = this->m_primitivesConverter->ConvertPlacement( product->m_ObjectPlacement ); |
| 155 | + TMatrix::Multiply( &matrix, TMatrix::GetScale( this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor ) ); |
150 | 156 | this->m_adapter->Transform( &polygons, matrix );
|
151 | 157 | this->m_adapter->Transform( &polylines, matrix );
|
152 | 158 |
|
@@ -176,11 +182,66 @@ class GeometryGenerator {
|
176 | 182 | std::copy( p.begin(), p.end(), std::back_inserter( polygons ) );
|
177 | 183 | std::copy( l.begin(), l.end(), std::back_inserter( polylines ) );
|
178 | 184 | }
|
| 185 | + |
| 186 | + const auto topologicalItem = std::dynamic_pointer_cast<IfcTopologicalRepresentationItem>( item ); |
| 187 | + if( topologicalItem ) { |
| 188 | + auto [ p, l ] = this->ConvertTopologicalRepresentationItem( topologicalItem ); |
| 189 | + std::copy( p.begin(), p.end(), std::back_inserter( polygons ) ); |
| 190 | + std::copy( l.begin(), l.end(), std::back_inserter( polylines ) ); |
| 191 | + } |
179 | 192 | }
|
180 | 193 |
|
181 | 194 | return { polygons, polylines };
|
182 | 195 | }
|
183 | 196 |
|
| 197 | + std::tuple<std::vector<TPolygon>, std::vector<TPolyline>> |
| 198 | + ConvertTopologicalRepresentationItem( const shared_ptr<IfcTopologicalRepresentationItem>& topological_item ) { |
| 199 | + // IfcTopologicalRepresentationItem ABSTRACT SUPERTYPE OF(ONEOF(IfcConnectedFaceSet, IfcEdge, IfcFace, IfcFaceBound, IfcLoop, IfcPath, IfcVertex)) |
| 200 | + |
| 201 | + const auto topo_connected_face_set = dynamic_pointer_cast<IfcConnectedFaceSet>( topological_item ); |
| 202 | + if( topo_connected_face_set ) { |
| 203 | + std::vector<std::vector<TVector>> loops = this->m_geometryConverter->ConvertFaces( topo_connected_face_set->m_CfsFaces ); |
| 204 | + |
| 205 | + // TODO: Rework (try to fix points order) |
| 206 | + auto reversed = loops; |
| 207 | + for( auto& l: reversed ) { |
| 208 | + std::reverse( l.begin(), l.end() ); |
| 209 | + } |
| 210 | + std::copy( std::begin( reversed ), std::end( reversed ), std::back_inserter( loops ) ); |
| 211 | + |
| 212 | + return { this->CreatePolygons( loops ), {} }; |
| 213 | + } |
| 214 | + |
| 215 | + const auto topo_edge = dynamic_pointer_cast<IfcEdge>( topological_item ); |
| 216 | + if( topo_edge ) { |
| 217 | + return { {}, { this->m_adapter->CreatePolyline( this->m_geometryConverter->ConvertEdge( topo_edge ) ) } }; |
| 218 | + } |
| 219 | + |
| 220 | + const shared_ptr<IfcFace> topo_face = dynamic_pointer_cast<IfcFace>( topological_item ); |
| 221 | + if( topo_face ) { |
| 222 | + auto loop = this->m_geometryConverter->ConvertFace( topo_face ); |
| 223 | + auto rloop = loop; |
| 224 | + std::reverse( rloop.begin(), rloop.end() ); |
| 225 | + return { this->CreatePolygons( { loop, rloop } ), {} }; |
| 226 | + } |
| 227 | + |
| 228 | + const auto topo_face_bound = dynamic_pointer_cast<IfcFaceBound>( topological_item ); |
| 229 | + if( topo_face_bound ) { |
| 230 | + const auto loop = this->m_geometryConverter->ConvertLoop( topo_face_bound->m_Bound ); |
| 231 | + auto rloop = loop; |
| 232 | + std::reverse( rloop.begin(), rloop.end() ); |
| 233 | + return { this->CreatePolygons( { loop, rloop } ), {} }; |
| 234 | + } |
| 235 | + |
| 236 | + const auto topo_loop = dynamic_pointer_cast<IfcLoop>( topological_item ); |
| 237 | + if( topo_loop ) { |
| 238 | + return { {}, { this->m_adapter->CreatePolyline( this->m_geometryConverter->ConvertLoop( topo_loop ) ) } }; |
| 239 | + } |
| 240 | + |
| 241 | + // TODO: Implement all |
| 242 | + return {}; |
| 243 | + } |
| 244 | + |
184 | 245 | std::tuple<std::vector<TPolygon>, std::vector<TPolyline>> ConvertMappedItem( const std::shared_ptr<IfcMappedItem>& mappedItem ) {
|
185 | 246 | if( !mappedItem->m_MappingSource || !mappedItem->m_MappingSource->m_MappedRepresentation ) {
|
186 | 247 | // TODO: Log error
|
@@ -215,8 +276,8 @@ class GeometryGenerator {
|
215 | 276 | auto [ p, l ] = this->ConvertRepresentation( representation );
|
216 | 277 | std::copy( p.begin(), p.end(), std::back_inserter( polygons ) );
|
217 | 278 | }
|
218 |
| - auto m = TMatrix::GetScale( this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor ); |
219 |
| - TMatrix::Multiply( &m, this->m_primitivesConverter->ConvertPlacement( opening->m_ObjectPlacement ) ); |
| 279 | + auto m = this->m_primitivesConverter->ConvertPlacement( opening->m_ObjectPlacement ); |
| 280 | + TMatrix::Multiply( &m, TMatrix::GetScale( this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor, this->m_parameters->m_lengthFactor ) ); |
220 | 281 | this->m_adapter->Transform( &polygons, m );
|
221 | 282 | std::copy( polygons.begin(), polygons.end(), std::back_inserter( resultPolygons ) );
|
222 | 283 | }
|
@@ -260,11 +321,80 @@ class GeometryGenerator {
|
260 | 321 | return this->ConvertShellBasedSurfaceModel( shellModel );
|
261 | 322 | }
|
262 | 323 |
|
| 324 | + const auto tessellatedItem = dynamic_pointer_cast<IfcTessellatedItem>( geometricRepresentation ); |
| 325 | + if( tessellatedItem ) { |
| 326 | + // TODO: implement |
| 327 | + return {}; |
| 328 | + } |
| 329 | + |
263 | 330 | const auto surface = dynamic_pointer_cast<IfcSurface>( geometricRepresentation );
|
264 | 331 | if( surface ) {
|
265 | 332 | return this->ConvertSurface( surface );
|
266 | 333 | }
|
267 | 334 |
|
| 335 | + const auto geometricSet = dynamic_pointer_cast<IfcGeometricSet>( geometricRepresentation ); |
| 336 | + if( geometricSet ) { |
| 337 | + std::vector<TPolygon> polygons; |
| 338 | + std::vector<TPolyline> polylines; |
| 339 | + |
| 340 | + for( const auto& geom_select: geometricSet->m_Elements ) { |
| 341 | + // TYPE IfcGeometricSetSelect = SELECT (IfcPoint, IfcCurve, IfcSurface); |
| 342 | + if( !geom_select ) { |
| 343 | + continue; |
| 344 | + } |
| 345 | + |
| 346 | + shared_ptr<IfcPoint> point = dynamic_pointer_cast<IfcPoint>( geom_select ); |
| 347 | + if( point ) { |
| 348 | + // TODO: Implement |
| 349 | + continue; |
| 350 | + } |
| 351 | + |
| 352 | + shared_ptr<IfcCurve> select_curve = dynamic_pointer_cast<IfcCurve>( geom_select ); |
| 353 | + if( select_curve ) { |
| 354 | + const auto [ p, l ] = this->ConvertGeometryRepresentation( select_curve ); |
| 355 | + std::copy( p.begin(), p.end(), std::back_inserter( polygons ) ); |
| 356 | + std::copy( l.begin(), l.end(), std::back_inserter( polylines ) ); |
| 357 | + } |
| 358 | + |
| 359 | + shared_ptr<IfcSurface> select_surface = dynamic_pointer_cast<IfcSurface>( geom_select ); |
| 360 | + if( select_surface ) { |
| 361 | + const auto [ p, l ] = this->ConvertGeometryRepresentation( select_surface ); |
| 362 | + std::copy( p.begin(), p.end(), std::back_inserter( polygons ) ); |
| 363 | + std::copy( l.begin(), l.end(), std::back_inserter( polylines ) ); |
| 364 | + } |
| 365 | + } |
| 366 | + |
| 367 | + shared_ptr<IfcGeometricCurveSet> geometric_curve_set = dynamic_pointer_cast<IfcGeometricCurveSet>( geometricSet ); |
| 368 | + if( geometric_curve_set ) { |
| 369 | + // no additional attributes |
| 370 | + } |
| 371 | + return { polygons, polylines }; |
| 372 | + } |
| 373 | + |
| 374 | + const auto sectioned_spine = dynamic_pointer_cast<IfcSectionedSpine>( geometricRepresentation ); |
| 375 | + if( sectioned_spine ) { |
| 376 | + // TODO: Implement |
| 377 | + return {}; |
| 378 | + } |
| 379 | + |
| 380 | + const auto text_literal = dynamic_pointer_cast<IfcTextLiteral>( geometricRepresentation ); |
| 381 | + if( text_literal ) { |
| 382 | + // TODO: Implement |
| 383 | + return {}; |
| 384 | + } |
| 385 | + |
| 386 | + const auto annotation_fill_area = dynamic_pointer_cast<IfcAnnotationFillArea>( geometricRepresentation ); |
| 387 | + if( annotation_fill_area ) { |
| 388 | + // TODO: Implement |
| 389 | + return {}; |
| 390 | + } |
| 391 | + |
| 392 | + shared_ptr<IfcPoint> ifc_point = dynamic_pointer_cast<IfcPoint>( geometricRepresentation ); |
| 393 | + if( ifc_point ) { |
| 394 | + // TODO: Implement |
| 395 | + return {}; |
| 396 | + } |
| 397 | + |
268 | 398 | // TODO: Implement all
|
269 | 399 | return {};
|
270 | 400 | }
|
@@ -334,7 +464,7 @@ class GeometryGenerator {
|
334 | 464 | continue;
|
335 | 465 | }
|
336 | 466 | const auto indices = this->m_adapter->Triangulate( l );
|
337 |
| - if( indices.size() < 3) { |
| 467 | + if( indices.size() < 3 ) { |
338 | 468 | continue;
|
339 | 469 | }
|
340 | 470 | for( int i = 0; i < indices.size() - 2; i += 3 ) {
|
|
0 commit comments