Minor cleanups, 4x1 and 4x2 geom lib, granular schema macros

This commit is contained in:
Thomas Krijnen
2019-06-26 13:50:46 +02:00
parent 73f7c34c8d
commit 839b5a2699
36 changed files with 15869 additions and 2590 deletions
+4 -1
View File
@@ -80,6 +80,9 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
#define INCLUDE_PARENT_DIR(x) STRINGIFY(../ifcparse/x.h)
#include INCLUDE_PARENT_DIR(IfcSchema)
#undef INCLUDE_PARENT_DIR
#define INCLUDE_PARENT_DIR(x) STRINGIFY(../ifcparse/x-definitions.h)
#include INCLUDE_PARENT_DIR(IfcSchema)
namespace IfcGeom {
class IFC_GEOM_API geometry_exception : public std::exception {
@@ -357,7 +360,7 @@ public:
const SurfaceStyle* get_style(const IfcSchema::IfcMaterial*);
template <typename T> std::pair<IfcSchema::IfcSurfaceStyle*, T*> _get_surface_style(const IfcSchema::IfcStyledItem* si) {
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
IfcEntityList::ptr style_assignments = si->Styles();
for (IfcEntityList::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
if (!(*kt)->declaration().is(IfcSchema::IfcPresentationStyleAssignment::Class())) {
+4 -4
View File
@@ -77,12 +77,12 @@
#include <TopLoc_Location.hxx>
#ifdef USE_IFC4
#include "../ifcgeom/IfcGeom.h"
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
#include <Geom_BSplineCurve.hxx>
#endif
#include "../ifcgeom/IfcGeom.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) {
@@ -143,7 +143,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLine* l, Handle(Geom_Curve)& c
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineCurveWithKnots* l, Handle(Geom_Curve)& curve) {
const bool is_rational = l->declaration().is(IfcSchema::IfcRationalBSplineCurveWithKnots::Class());
+17 -17
View File
@@ -97,15 +97,15 @@
#include <BRepLib_FindSurface.hxx>
#ifdef USE_IFC4
#include "../ifcgeom/IfcGeom.h"
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
#include <Geom_BSplineSurface.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#endif
#include "../ifcgeom/IfcGeom.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
namespace {
@@ -472,7 +472,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleProfileDef* l, TopoDS
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -495,7 +495,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRoundedRectangleProfileDef* l,
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -529,7 +529,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -575,7 +575,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -620,7 +620,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -659,7 +659,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -692,7 +692,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -767,7 +767,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -815,7 +815,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -904,7 +904,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -926,7 +926,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -958,7 +958,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleHollowProfileDef* l, Top
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -996,7 +996,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_S
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -1124,7 +1124,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* l, TopoDS_Shape& face)
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) {
boost::shared_ptr< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
+2 -6
View File
@@ -1587,11 +1587,7 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem
// Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements?
IfcSchema::IfcObjectDefinition* obdef = product->as<IfcSchema::IfcObjectDefinition>();
for (;;) {
#ifdef USE_IFC4
IfcSchema::IfcRelAggregates::list::ptr decomposes = obdef->Decomposes();
#else
IfcSchema::IfcRelDecomposes::list::ptr decomposes = obdef->Decomposes();
#endif
auto decomposes = obdef->Decomposes();
if (decomposes->size() != 1) break;
IfcSchema::IfcObjectDefinition* rel_obdef = (*decomposes->begin())->RelatingObject();
if ( rel_obdef->declaration().is(IfcSchema::IfcElement::Class()) && !rel_obdef->declaration().is(IfcSchema::IfcOpeningElement::Class()) ) {
@@ -2175,7 +2171,7 @@ bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std
gp_Trsf extrusion_position;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = extrusion->hasPosition();
#endif
if (has_position) {
+35 -27
View File
@@ -119,7 +119,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -166,7 +166,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
return !shape.IsNull();
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolidTapered* l, TopoDS_Shape& shape) {
const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
if (height < getValue(GV_PRECISION)) {
@@ -180,7 +180,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolidTapered* l, T
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -280,7 +280,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, T
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -315,7 +315,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -344,7 +344,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_S
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -376,7 +376,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, IfcRepre
if (l->declaration().is(IfcSchema::IfcFacetedBrepWithVoids::Class())) {
voids = l->as<IfcSchema::IfcFacetedBrepWithVoids>()->Voids();
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcAdvancedBrepWithVoids
if (l->declaration().is(IfcSchema::IfcAdvancedBrepWithVoids::Class())) {
voids = l->as<IfcSchema::IfcAdvancedBrepWithVoids>()->Voids();
}
@@ -545,27 +545,27 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
TopTools_ListOfShape second_operand_shapes;
for (auto& operand2 : second_operands) {
for (auto& op2 : second_operands) {
TopoDS_Shape s2;
bool shape2_processed = false;
bool is_halfspace = operand2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class());
bool is_unbounded_halfspace = is_halfspace && !operand2->declaration().is(IfcSchema::IfcPolygonalBoundedHalfSpace::Class());
bool is_halfspace = op2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class());
bool is_unbounded_halfspace = is_halfspace && !op2->declaration().is(IfcSchema::IfcPolygonalBoundedHalfSpace::Class());
has_halfspace_operand |= is_halfspace;
{
if (shape_type(operand2) == ST_SHAPELIST) {
if (shape_type(op2) == ST_SHAPELIST) {
IfcRepresentationShapeItems items2;
shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true);
} else if (shape_type(operand2) == ST_SHAPE) {
shape2_processed = convert_shape(operand2, s2);
shape2_processed = convert_shapes(op2, items2) && flatten_shape_list(items2, s2, true);
} else if (shape_type(op2) == ST_SHAPE) {
shape2_processed = convert_shape(op2, s2);
if (shape2_processed) {
TopoDS_Solid temp_solid;
s2 = ensure_fit_for_subtraction(s2, temp_solid);
}
} else {
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2);
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", op2);
}
}
@@ -583,14 +583,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
}
if (!shape2_processed) {
Logger::Message(Logger::LOG_ERROR, "Failed to convert SecondOperand:", operand2);
Logger::Message(Logger::LOG_ERROR, "Failed to convert SecondOperand:", op2);
continue;
}
if (operand2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class())) {
if (op2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class())) {
const double second_operand_volume = shape_volume(s2);
if (second_operand_volume <= ALMOST_ZERO) {
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", operand2);
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", op2);
}
}
@@ -950,7 +950,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -1152,7 +1152,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcCylindricalSurface
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_Shape& face) {
gp_Trsf trsf;
@@ -1167,10 +1167,18 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_
return true;
}
#endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep
bool IfcGeom::Kernel::convert(const IfcSchema::IfcAdvancedBrep* l, TopoDS_Shape& shape) {
return convert(l->Outer(), shape);
}
#endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS_Shape& shape) {
IfcSchema::IfcCartesianPointList3D* point_list = l->Coordinates();
const std::vector< std::vector<double> > coordinates = point_list->CoordList();
@@ -1231,18 +1239,18 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
bool valid_shell = false;
// @todo Do this more efficiently by creating proper half-edge pairs.
BRepOffsetAPI_Sewing builder;
builder.SetTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
builder.SetMaxTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
builder.SetMinTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
BRepOffsetAPI_Sewing sewing_builder;
sewing_builder.SetTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
sewing_builder.SetMaxTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
sewing_builder.SetMinTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
for (std::vector<TopoDS_Face>::const_iterator it = faces.begin(); it != faces.end(); ++it) {
builder.Add(*it);
sewing_builder.Add(*it);
}
try {
builder.Perform();
shape = builder.SewedShape();
sewing_builder.Perform();
shape = sewing_builder.SewedShape();
valid_shell = BRepCheck_Analyzer(shape).IsValid();
} catch(...) {}
+1 -1
View File
@@ -849,7 +849,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSubedge* l, TopoDS_Wire& resul
}
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wire& result) {
+11 -3
View File
@@ -52,12 +52,20 @@ SHAPES(IfcMappedItem);
SHAPES(IfcManifoldSolidBrep);
SHAPES(IfcGeometricSet);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcCylindricalSurface
SHAPE(IfcCylindricalSurface);
#endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep
SHAPE(IfcAdvancedBrep);
#endif
// FIXME: Surfaces should have a shape type of their own
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
SHAPE(IfcBSplineSurfaceWithKnots);
#endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
SHAPE(IfcTriangulatedFaceSet);
#endif
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
SHAPE(IfcExtrudedAreaSolidTapered);
#endif
SHAPE(IfcPlane);
@@ -114,14 +122,14 @@ WIRE(IfcPolyLoop);
WIRE(IfcCompositeCurve);
WIRE(IfcTrimmedCurve);
WIRE(IfcArbitraryOpenProfileDef);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
WIRE(IfcIndexedPolyCurve)
#endif
CURVE(IfcCircle);
CURVE(IfcEllipse);
CURVE(IfcLine);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
// IfcRationalBSplineCurveWithKnots included
CURVE(IfcBSplineCurveWithKnots);
#endif