Skip to content

Commit 757f919

Browse files
FaceSurface (hack) (#20)
1 parent 006e09e commit 757f919

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

include/ifcpp/Geometry/GeometryConverter.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ifcpp/Geometry/CurveConverter.h"
55
#include "ifcpp/Geometry/Extruder.h"
66
#include "ifcpp/Geometry/GeomUtils.h"
7+
#include "ifcpp/Geometry/Helpers.h"
78
#include "ifcpp/Geometry/Matrix.h"
89
#include "ifcpp/Geometry/Parameters.h"
910
#include "ifcpp/Geometry/PrimitiveTypesConverter.h"
@@ -20,6 +21,7 @@
2021
#include "ifcpp/Ifc/IfcFace.h"
2122
#include "ifcpp/Ifc/IfcFaceBound.h"
2223
#include "ifcpp/Ifc/IfcFaceOuterBound.h"
24+
#include "ifcpp/Ifc/IfcFaceSurface.h"
2325
#include "ifcpp/Ifc/IfcLoop.h"
2426
#include "ifcpp/Ifc/IfcOrientedEdge.h"
2527
#include "ifcpp/Ifc/IfcPlane.h"
@@ -128,7 +130,11 @@ class GeometryConverter {
128130
return {};
129131
}
130132

131-
TLoop ConvertFace( const std::shared_ptr<IfcFace>& face ) {
133+
std::vector<TLoop> ConvertFace( const std::shared_ptr<IfcFace>& face ) {
134+
if( auto faceSurface = std::dynamic_pointer_cast<IfcFaceSurface>( face ) ) {
135+
return this->ConvertSurface( faceSurface->m_FaceSurface );
136+
}
137+
132138
TLoop outer;
133139
std::vector<TLoop> inners;
134140

@@ -147,20 +153,20 @@ class GeometryConverter {
147153

148154
if( outer.empty() ) {
149155
if( inners.size() == 1 ) {
150-
outer = inners[0];
156+
outer = inners[ 0 ];
151157
inners.clear();
152158
} else {
153159
return {};
154160
}
155161
}
156162

157-
return this->m_geomUtils->IncorporateHoles( outer, loops );
163+
return { this->m_geomUtils->IncorporateHoles( outer, loops ) };
158164
}
159165

160166
std::vector<TLoop> ConvertFaces( const std::vector<std::shared_ptr<IfcFace>>& loops ) {
161167
std::vector<TLoop> result;
162168
for( const auto& face: loops ) {
163-
result.push_back( this->ConvertFace( face ) );
169+
Helpers::AppendTo( &result, this->ConvertFace( face ) );
164170
}
165171
return result;
166172
}
@@ -242,8 +248,8 @@ class GeometryConverter {
242248

243249
shared_ptr<IfcSurfaceOfLinearExtrusion> linear_extrusion = dynamic_pointer_cast<IfcSurfaceOfLinearExtrusion>( swept_surface );
244250
if( linear_extrusion ) {
245-
const auto extrusion = this->m_primitivesConverter->ConvertPoint( linear_extrusion->m_ExtrudedDirection->m_DirectionRatios ) *
246-
linear_extrusion->m_Depth->m_value;
251+
const auto extrusion =
252+
this->m_primitivesConverter->ConvertPoint( linear_extrusion->m_ExtrudedDirection->m_DirectionRatios ) * linear_extrusion->m_Depth->m_value;
247253
auto result = this->m_extruder->Extrude( curve, extrusion, false );
248254
m.TransformLoops( &result );
249255
return result;

include/ifcpp/Geometry/SolidConverter.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,38 @@ class SolidConverter {
313313
// Outer : IfcClosedShell;
314314
// END_ENTITY;
315315

316-
auto loops = this->m_geometryConverter->ConvertFaces( manifoldSolidBrep->m_Outer->m_CfsFaces );
316+
std::vector<TMesh> faceSurfaceMeshes;
317+
std::vector<std::shared_ptr<IfcFace>> faces;
318+
std::vector<TMesh> resultMeshes;
319+
320+
for( const auto& face: manifoldSolidBrep->m_Outer->m_CfsFaces ) {
321+
if( std::dynamic_pointer_cast<IfcFaceSurface>( face ) ) {
322+
faceSurfaceMeshes.push_back( Helpers::CreateMesh( this->m_adapter, this->m_geometryConverter->ConvertFace( face ) ) );
323+
} else {
324+
faces.push_back( face );
325+
}
326+
}
327+
328+
// FIXME: Hack for models with faceSurface - just intersect surface spaces using CSG
329+
if( !faceSurfaceMeshes.empty() ) {
330+
TMesh faceSurfaceCombinedMesh = faceSurfaceMeshes[ 0 ];
331+
bool isValidResult = true;
332+
for( int i = 1; i < faceSurfaceMeshes.size(); i++ ) {
333+
auto intersectionResult = this->m_adapter->ComputeIntersection( { faceSurfaceCombinedMesh }, { faceSurfaceMeshes[ i ] } );
334+
if( intersectionResult.size() == 1 ) {
335+
faceSurfaceCombinedMesh = intersectionResult[ 0 ];
336+
} else {
337+
// TODO: Log error
338+
isValidResult = false;
339+
break;
340+
}
341+
}
342+
if( isValidResult ) {
343+
resultMeshes.push_back( faceSurfaceCombinedMesh );
344+
}
345+
}
317346

318-
std::vector<TMesh> resultMeshes = { Helpers::CreateMesh( this->m_adapter, loops ) };
347+
resultMeshes.push_back( Helpers::CreateMesh( this->m_adapter, this->m_geometryConverter->ConvertFaces( faces ) ) );
319348

320349
const auto facetedBrep = dynamic_pointer_cast<IfcFacetedBrep>( manifoldSolidBrep );
321350
if( facetedBrep ) {

0 commit comments

Comments
 (0)