From 467ebb68a3e0f04ddc087890418a59e0f3f36225 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 4 Aug 2019 09:36:31 +0200 Subject: [PATCH] First step at reorganizing --- cmake/CMakeLists.txt | 27 ++-- src/ifcgeom/abstract_mapping.h | 15 ++ src/ifcgeom/kernels/opencascade/IfcGeom.h | 26 ++-- .../kernels/opencascade/IfcGeomCurves.cpp | 2 +- .../kernels/opencascade/IfcGeomFaces.cpp | 2 +- .../kernels/opencascade/IfcGeomFunctions.cpp | 8 +- .../kernels/opencascade/IfcGeomHelpers.cpp | 2 +- .../opencascade/IfcGeomSerialisation.cpp | 4 +- .../kernels/opencascade/IfcGeomShapes.cpp | 2 +- .../kernels/opencascade/IfcGeomWires.cpp | 2 +- .../kernels/opencascade/IfcRegister.cpp | 2 +- src/ifcgeom/schema/bind_convert_decl.i | 7 + src/ifcgeom/schema/bind_convert_impl.i | 15 ++ src/ifcgeom/schema/mapping.cpp | 30 ++++ src/ifcgeom/schema/mapping.h | 22 +++ src/ifcgeom/schema/mapping.i | 130 ++++++++++++++++++ src/ifcgeom/taxonomy.h | 96 +++++++++++++ src/ifcparse/macros.h | 6 +- .../schema_dependent/XmlSerializer.cpp | 18 +-- .../schema_dependent/XmlSerializer.h | 4 +- 20 files changed, 363 insertions(+), 57 deletions(-) create mode 100644 src/ifcgeom/abstract_mapping.h create mode 100644 src/ifcgeom/schema/bind_convert_decl.i create mode 100644 src/ifcgeom/schema/bind_convert_impl.i create mode 100644 src/ifcgeom/schema/mapping.cpp create mode 100644 src/ifcgeom/schema/mapping.h create mode 100644 src/ifcgeom/schema/mapping.i create mode 100644 src/ifcgeom/taxonomy.h diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0722a38b04..a65f8054fe 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -631,9 +631,10 @@ TARGET_LINK_LIBRARIES(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_ if (BUILD_IFCGEOM) foreach(kernel ${GEOMETRY_KERNELS}) + string(TOUPPER ${kernel} KERNEL_UPPER) -file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/schema_agnostic/${kernel}/*.h) -file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/schema_agnostic/${kernel}/*.cpp) +file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h) +file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernels/${kernel}/*.cpp) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) add_library(IfcGeom_${kernel} STATIC ${IFCGEOM_FILES}) @@ -644,30 +645,20 @@ endforeach() foreach(schema ${SCHEMA_VERSIONS}) -file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernel_agnostic/*.h) -file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernel_agnostic/*.cpp) -set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) +file(GLOB IFCGEOM_I_FILES ../src/ifcgeom/schema/*.i) +file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/schema/*.h) +file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/schema/*.cpp) +set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES} ${IFCGEOM_I_FILES}) add_library(IfcGeom_ifc${schema} STATIC ${IFCGEOM_FILES}) set_target_properties(IfcGeom_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") target_link_libraries(IfcGeom_ifc${schema} IfcParse) list(APPEND IfcGeom_libraries IfcGeom_ifc${schema}) -foreach(kernel ${GEOMETRY_KERNELS}) -file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h) -file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernels/${kernel}/*.cpp) -set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) - -add_library(IfcGeom_${kernel}_ifc${schema} STATIC ${IFCGEOM_FILES}) -set_target_properties(IfcGeom_${kernel}_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") -target_link_libraries(IfcGeom_${kernel}_ifc${schema} IfcGeom_${kernel} IfcGeom_ifc${schema}) -list(APPEND IfcGeom_libraries IfcGeom_${kernel}_ifc${schema}) endforeach() -endforeach() - -file(GLOB SCHEMA_AGNOSTIC_H_FILES ../src/ifcgeom/schema_agnostic/*.h) -file(GLOB SCHEMA_AGNOSTIC_CPP_FILES ../src/ifcgeom/schema_agnostic/*.cpp) +file(GLOB SCHEMA_AGNOSTIC_H_FILES ../src/ifcgeom/*.h) +file(GLOB SCHEMA_AGNOSTIC_CPP_FILES ../src/ifcgeom/*.cpp) set(SCHEMA_AGNOSTIC_FILES ${SCHEMA_AGNOSTIC_H_FILES} ${SCHEMA_AGNOSTIC_CPP_FILES}) add_library(IfcGeom ${SCHEMA_AGNOSTIC_FILES}) diff --git a/src/ifcgeom/abstract_mapping.h b/src/ifcgeom/abstract_mapping.h new file mode 100644 index 0000000000..1a89e3fa03 --- /dev/null +++ b/src/ifcgeom/abstract_mapping.h @@ -0,0 +1,15 @@ +#include "../ifcparse/IfcBaseClass.h" +#include "../ifcgeom/taxonomy.h" + +namespace ifcopenshell { + +namespace geometry { + + class abstract_mapping { + public: + virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*) = 0; + }; + +} + +} \ No newline at end of file diff --git a/src/ifcgeom/kernels/opencascade/IfcGeom.h b/src/ifcgeom/kernels/opencascade/IfcGeom.h index 596ddc6fa2..d0575a5de2 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeom.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeom.h @@ -107,13 +107,13 @@ namespace IfcGeom { : geometry_exception("Too many faces for operation") {} }; -class IFC_GEOM_API MAKE_TYPE_NAME(Cache) { +class IFC_GEOM_API POSTFIX_SCHEMA(Cache) { public: #include "IfcRegisterCreateCache.h" std::map Shape; }; -class IFC_GEOM_API MAKE_TYPE_NAME(Kernel) : public IfcGeom::MAKE_TYPE_NAME(AbstractKernel) { +class IFC_GEOM_API POSTFIX_SCHEMA(Kernel) : public IfcGeom::POSTFIX_SCHEMA(AbstractKernel) { private: /* @@ -125,7 +125,7 @@ private: */ class faceset_helper { private: - MAKE_TYPE_NAME(Kernel)* kernel_; + POSTFIX_SCHEMA(Kernel)* kernel_; std::set duplicates_; std::map vertex_mapping_; std::map, TopoDS_Edge> edges_; @@ -154,7 +154,7 @@ private: } } public: - faceset_helper(MAKE_TYPE_NAME(Kernel)* kernel, const IfcSchema::IfcConnectedFaceSet* l); + faceset_helper(POSTFIX_SCHEMA(Kernel)* kernel, const IfcSchema::IfcConnectedFaceSet* l); ~faceset_helper(); @@ -220,24 +220,24 @@ private: }; #ifndef NO_CACHE - MAKE_TYPE_NAME(Cache) cache; + POSTFIX_SCHEMA(Cache) cache; #endif faceset_helper* faceset_helper_; public: - MAKE_TYPE_NAME(Kernel)() - : IfcGeom::MAKE_TYPE_NAME(AbstractKernel)("opencascade") + POSTFIX_SCHEMA(Kernel)() + : IfcGeom::POSTFIX_SCHEMA(AbstractKernel)("opencascade") , faceset_helper_(nullptr) {} - MAKE_TYPE_NAME(Kernel)(const MAKE_TYPE_NAME(Kernel)& other) - : IfcGeom::MAKE_TYPE_NAME(AbstractKernel)("opencascade") + POSTFIX_SCHEMA(Kernel)(const POSTFIX_SCHEMA(Kernel)& other) + : IfcGeom::POSTFIX_SCHEMA(AbstractKernel)("opencascade") { *this = other; } - MAKE_TYPE_NAME(Kernel)& operator=(const MAKE_TYPE_NAME(Kernel)& other) { + POSTFIX_SCHEMA(Kernel)& operator=(const POSTFIX_SCHEMA(Kernel)& other) { setValue(GV_DEFLECTION_TOLERANCE, other.getValue(GV_DEFLECTION_TOLERANCE)); setValue(GV_MAX_FACES_TO_ORIENT, other.getValue(GV_MAX_FACES_TO_ORIENT)); setValue(GV_LENGTH_UNIT, other.getValue(GV_LENGTH_UNIT)); @@ -333,7 +333,7 @@ public: // for large files. SurfaceStyles need to be kept at all costs, as they // are read later on when serializing Collada files. #ifndef NO_CACHE - cache = MAKE_TYPE_NAME(Cache)(); + cache = POSTFIX_SCHEMA(Cache)(); #endif } @@ -368,8 +368,8 @@ public: }; -IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(tesselate_)(const TopoDS_Shape& shape, double deflection); -IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& shape, bool advanced); +IfcUtil::IfcBaseClass* POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection); +IfcUtil::IfcBaseClass* POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced); } #endif diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomCurves.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomCurves.cpp index 8d79b14a60..728fa4eabc 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomCurves.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomCurves.cpp @@ -83,7 +83,7 @@ #include #endif -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) { const double r = l->Radius() * getValue(GV_LENGTH_UNIT); diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomFaces.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomFaces.cpp index b4387d1b72..58cd6dda47 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomFaces.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomFaces.cpp @@ -106,7 +106,7 @@ #include #endif -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) namespace { /* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/ diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomFunctions.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomFunctions.cpp index 6d06c33fa9..afbc7b2588 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomFunctions.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomFunctions.cpp @@ -167,9 +167,9 @@ #endif namespace { - struct MAKE_TYPE_NAME(factory_t) { + struct POSTFIX_SCHEMA(factory_t) { IfcGeom::Kernel* operator()(IfcParse::IfcFile* file) const { - IfcGeom::MAKE_TYPE_NAME(Kernel)* k = new IfcGeom::MAKE_TYPE_NAME(Kernel); + IfcGeom::POSTFIX_SCHEMA(Kernel)* k = new IfcGeom::POSTFIX_SCHEMA(Kernel); if (file) { double unit_magnitude = 1.; @@ -222,11 +222,11 @@ namespace { void MAKE_INIT_FN(KernelImplementation_opencascade_)(IfcGeom::impl::KernelFactoryImplementation* mapping) { static const std::string schema_name = STRINGIFY(IfcSchema); - MAKE_TYPE_NAME(factory_t) factory; + POSTFIX_SCHEMA(factory_t) factory; mapping->bind(schema_name, "opencascade", factory); } -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) namespace { void copy_operand(const TopTools_ListOfShape& l, TopTools_ListOfShape& r) { diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomHelpers.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomHelpers.cpp index 2710933042..4be6bae286 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomHelpers.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomHelpers.cpp @@ -77,7 +77,7 @@ #include "../../../ifcgeom/kernels/opencascade/IfcGeom.h" -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) namespace { diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomSerialisation.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomSerialisation.cpp index 181b4b3fc8..def77c5064 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomSerialisation.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomSerialisation.cpp @@ -493,7 +493,7 @@ int convert_to_ifc(const TopoDS_Shape& s, U*& item, bool advanced) { return faces->size(); } -IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& shape, bool advanced) { +IfcUtil::IfcBaseClass* IfcGeom::POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced) { #ifndef USE_IFC4 advanced = false; #endif @@ -604,7 +604,7 @@ IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& s return new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps); } -IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(tesselate_)(const TopoDS_Shape& shape, double deflection) { +IfcUtil::IfcBaseClass* IfcGeom::POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection) { BRepMesh_IncrementalMesh(shape, deflection); IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list); diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp index 60d2ac89ae..5001639a6d 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp @@ -105,7 +105,7 @@ #include -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) { const double height = l->Depth() * getValue(GV_LENGTH_UNIT); diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomWires.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomWires.cpp index a2a56ce4c5..383691072c 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomWires.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomWires.cpp @@ -97,7 +97,7 @@ #include "../../../ifcgeom/kernels/opencascade/IfcGeom.h" -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) namespace { // Returns the other vertex of an edge diff --git a/src/ifcgeom/kernels/opencascade/IfcRegister.cpp b/src/ifcgeom/kernels/opencascade/IfcRegister.cpp index b0574c2008..35b6baedcf 100644 --- a/src/ifcgeom/kernels/opencascade/IfcRegister.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcRegister.cpp @@ -20,7 +20,7 @@ #include "IfcGeom.h" #include "IfcGeomShapeType.h" -#define Kernel MAKE_TYPE_NAME(Kernel) +#define Kernel POSTFIX_SCHEMA(Kernel) using namespace IfcUtil; diff --git a/src/ifcgeom/schema/bind_convert_decl.i b/src/ifcgeom/schema/bind_convert_decl.i new file mode 100644 index 0000000000..3f2fc443d2 --- /dev/null +++ b/src/ifcgeom/schema/bind_convert_decl.i @@ -0,0 +1,7 @@ +#ifdef BIND +#undef BIND +#endif + +#define BIND(T) ifcopenshell::geometry::taxonomy::item* convert(const IfcSchema::T*); + +#include "mapping.i" diff --git a/src/ifcgeom/schema/bind_convert_impl.i b/src/ifcgeom/schema/bind_convert_impl.i new file mode 100644 index 0000000000..abc10ab4f0 --- /dev/null +++ b/src/ifcgeom/schema/bind_convert_impl.i @@ -0,0 +1,15 @@ +#ifdef BIND +#undef BIND +#endif + +#define BIND(T) \ + if (l->declaration().is(IfcSchema::T::Class())) { \ + try { \ + return map((IfcSchema::T*)l); \ + } catch (const std::exception& e) { \ + Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l); \ + } \ + return false; \ + } + +#include "mapping.i" diff --git a/src/ifcgeom/schema/mapping.cpp b/src/ifcgeom/schema/mapping.cpp new file mode 100644 index 0000000000..f87fa8ef86 --- /dev/null +++ b/src/ifcgeom/schema/mapping.cpp @@ -0,0 +1,30 @@ +/******************************************************************************** +* * +* This file is part of IfcOpenShell. * +* * +* IfcOpenShell is free software: you can redistribute it and/or modify * +* it under the terms of the Lesser GNU General Public License as published by * +* the Free Software Foundation, either version 3.0 of the License, or * +* (at your option) any later version. * +* * +* IfcOpenShell is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* Lesser GNU General Public License for more details. * +* * +* You should have received a copy of the Lesser GNU General Public License * +* along with this program. If not, see . * +* * +********************************************************************************/ + +#include "mapping.h" + +#include "../../ifcparse/IfcLogger.h" + +using namespace IfcUtil; + +ifcopenshell::geometry::taxonomy::item* ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)::map(const IfcBaseClass* l) { +#include "bind_convert_impl.i" + Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l); + return nullptr; +} diff --git a/src/ifcgeom/schema/mapping.h b/src/ifcgeom/schema/mapping.h new file mode 100644 index 0000000000..99d97be600 --- /dev/null +++ b/src/ifcgeom/schema/mapping.h @@ -0,0 +1,22 @@ +#include "../abstract_mapping.h" +#include "../../ifcparse/macros.h" + +#define INCLUDE_SCHEMA(x) STRINGIFY(../../ifcparse/x.h) +#include INCLUDE_SCHEMA(IfcSchema) +#undef INCLUDE_SCHEMA +#define INCLUDE_SCHEMA(x) STRINGIFY(../../ifcparse/x-definitions.h) +#include INCLUDE_SCHEMA(IfcSchema) +#undef INCLUDE_SCHEMA + +namespace ifcopenshell { + +namespace geometry { + + class POSTFIX_SCHEMA(mapping) : public abstract_mapping { + virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*); +#include "bind_convert_decl.i" + }; + +} + +} \ No newline at end of file diff --git a/src/ifcgeom/schema/mapping.i b/src/ifcgeom/schema/mapping.i new file mode 100644 index 0000000000..1dc894d273 --- /dev/null +++ b/src/ifcgeom/schema/mapping.i @@ -0,0 +1,130 @@ +/******************************************************************************** +* * +* This file is part of IfcOpenShell. * +* * +* IfcOpenShell is free software: you can redistribute it and/or modify * +* it under the terms of the Lesser GNU General Public License as published by * +* the Free Software Foundation, either version 3.0 of the License, or * +* (at your option) any later version. * +* * +* IfcOpenShell is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* Lesser GNU General Public License for more details. * +* * +* You should have received a copy of the Lesser GNU General Public License * +* along with this program. If not, see . * +* * +********************************************************************************/ + +/******************************************************************************** + * * + * This file registers function prototypes for all supported IFC geometrical * + * entities. For entities of type CLASS an std::map is also created to cache * + * the output of the conversion functions * + * * + ********************************************************************************/ + +BIND(IfcShellBasedSurfaceModel); +BIND(IfcFaceBasedSurfaceModel); +BIND(IfcRepresentation); +BIND(IfcMappedItem); +// IfcFacetedBrep included +// IfcAdvancedBrep included +// IfcFacetedBrepWithVoids included +// IfcAdvancedBrepWithVoids included +BIND(IfcManifoldSolidBrep); +BIND(IfcGeometricSet); + +#ifdef SCHEMA_HAS_IfcCylindricalSurface +BIND(IfcCylindricalSurface); +#endif +#ifdef SCHEMA_HAS_IfcAdvancedBrep +BIND(IfcAdvancedBrep); +#endif +// FIXME: Surfaces should have a shape type of their own +#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots +BIND(IfcBSplineSurfaceWithKnots); +#endif +#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet +BIND(IfcTriangulatedFaceSet); +#endif +#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered +BIND(IfcExtrudedAreaSolidTapered); +#endif +BIND(IfcExtrudedAreaSolid); +BIND(IfcRevolvedAreaSolid); +BIND(IfcConnectedFaceSet); +BIND(IfcBooleanResult); +BIND(IfcPolygonalBoundedHalfSpace); +BIND(IfcHalfSpaceSolid); +BIND(IfcSurfaceOfLinearExtrusion); +BIND(IfcSurfaceOfRevolution); +BIND(IfcBlock); +BIND(IfcRectangularPyramid); +BIND(IfcRightCircularCylinder); +BIND(IfcRightCircularCone); +BIND(IfcSphere); +BIND(IfcCsgSolid); +BIND(IfcCurveBoundedPlane); +BIND(IfcRectangularTrimmedSurface); +BIND(IfcSurfaceCurveSweptAreaSolid); +BIND(IfcSweptDiskSolid); + +BIND(IfcArbitraryProfileDefWithVoids); +BIND(IfcArbitraryClosedProfileDef); +BIND(IfcRoundedRectangleProfileDef); +BIND(IfcRectangleHollowProfileDef); +BIND(IfcRectangleProfileDef); +BIND(IfcTrapeziumProfileDef) +BIND(IfcCShapeProfileDef); +// IfcAsymmetricIShapeProfileDef included +BIND(IfcIShapeProfileDef); +BIND(IfcLShapeProfileDef); +BIND(IfcTShapeProfileDef); +BIND(IfcUShapeProfileDef); +BIND(IfcZShapeProfileDef); +BIND(IfcCircleHollowProfileDef); +BIND(IfcCircleProfileDef); +BIND(IfcEllipseProfileDef); +BIND(IfcCenterLineProfileDef); +BIND(IfcCompositeProfileDef); +BIND(IfcDerivedProfileDef); +// IfcFaceSurface included +// IfcAdvancedFace included in case of IFC4 +BIND(IfcFace); + +BIND(IfcEdgeCurve); +BIND(IfcSubedge); +BIND(IfcOrientedEdge); +BIND(IfcEdge); +BIND(IfcEdgeLoop); +BIND(IfcPolyline); +BIND(IfcPolyLoop); +BIND(IfcCompositeCurve); +BIND(IfcTrimmedCurve); +BIND(IfcArbitraryOpenProfileDef); +#ifdef SCHEMA_HAS_IfcIndexedPolyCurve +BIND(IfcIndexedPolyCurve) +#endif + +BIND(IfcCircle); +BIND(IfcEllipse); +BIND(IfcLine); +#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots +// IfcRationalBSplineCurveWithKnots included +BIND(IfcBSplineCurveWithKnots); +#endif + +BIND(IfcCartesianPoint); +BIND(IfcDirection); +BIND(IfcAxis2Placement2D); +BIND(IfcAxis2Placement3D); +BIND(IfcAxis1Placement); +BIND(IfcCartesianTransformationOperator2DnonUniform); +BIND(IfcCartesianTransformationOperator3DnonUniform); +BIND(IfcCartesianTransformationOperator2D); +BIND(IfcCartesianTransformationOperator3D); +BIND(IfcObjectPlacement); +BIND(IfcVector); +BIND(IfcPlane); \ No newline at end of file diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h new file mode 100644 index 0000000000..10eb3b8704 --- /dev/null +++ b/src/ifcgeom/taxonomy.h @@ -0,0 +1,96 @@ +#include + +namespace ifcopenshell { + +namespace geometry { + +namespace taxonomy { + +struct item { + int instance_id; + virtual item* clone() const = 0; +}; + +struct matrix4 : public item { + enum tag_t { + IDENTITY, AFFINE_WO_SCALE, AFFINE_W_UNIFORM_SCALE, AFFINE_W_NONUNIFORM_SCALE, OTHER + }; + tag_t tag; + std::array components; + matrix4() : components({1. ,0., 0., 0., 0., 1., 0., 0., 0., 0., 1. ,0., 0., 0., 0., 1.}), tag(IDENTITY) {} + + virtual item* clone() const { return new matrix4(*this); } +}; + +struct geom_item : public item { + // geometry::style surface_style; + matrix4 matrix; +}; + +template +struct cartesian_base : public item { + std::array components; +}; + +struct point3 : public cartesian_base<3> { + virtual item* clone() const { return new point3(*this); } +}; + +struct direction3 : public cartesian_base<3> { + virtual item* clone() const { return new direction3(*this); } +}; + +struct line : public item { + virtual item* clone() const { return new line(*this); } +}; + +struct circle : public item { + virtual item* clone() const { return new circle(*this); } +}; + +struct ellipse : public item { + virtual item* clone() const { return new ellipse(*this); } +}; + +struct bspline : public item { + virtual item* clone() const { return new bspline(*this); } +}; + +typedef boost::variant curve; + +struct edge : public item { + boost::variant start, end; + boost::optional basis; + + virtual item* clone() const { return new edge(*this); } +}; + +struct boundary : public item { + std::vector edges; + + virtual item* clone() const { return new boundary(*this); } +}; + +struct face : public item { + boundary outer; + std::vector inner; + + virtual item* clone() const { return new face(*this); } +}; + +struct sweep : public item { + face basis; +}; + +struct extrusion : public sweep { + direction3 direction; + double depth; + + virtual item* clone() const { return new extrusion(*this); } +}; + +} + +} + +} diff --git a/src/ifcparse/macros.h b/src/ifcparse/macros.h index 8db482967b..9552139bf5 100644 --- a/src/ifcparse/macros.h +++ b/src/ifcparse/macros.h @@ -20,9 +20,9 @@ #ifndef IFCOPENSHELL_MACROS_H #define IFCOPENSHELL_MACROS_H -#define MAKE_TYPE_NAME__(a, b) a ## b -#define MAKE_TYPE_NAME_(a, b) MAKE_TYPE_NAME__(a, b) -#define MAKE_TYPE_NAME(t) MAKE_TYPE_NAME_(t, IfcSchema) +#define POSTFIX_SCHEMA__(a, b) a ## _ ## b +#define POSTFIX_SCHEMA_(a, b) POSTFIX_SCHEMA__(a, b) +#define POSTFIX_SCHEMA(t) POSTFIX_SCHEMA_(t, IfcSchema) #define STRINGIFY_(x) #x #define STRINGIFY(x) STRINGIFY_(x) diff --git a/src/serializers/schema_dependent/XmlSerializer.cpp b/src/serializers/schema_dependent/XmlSerializer.cpp index 6a3a719fc1..d47c184555 100644 --- a/src/serializers/schema_dependent/XmlSerializer.cpp +++ b/src/serializers/schema_dependent/XmlSerializer.cpp @@ -35,9 +35,9 @@ using boost::property_tree::ptree; #include "XmlSerializer.h" namespace { - struct MAKE_TYPE_NAME(factory_t) { + struct POSTFIX_SCHEMA(factory_t) { XmlSerializer* operator()(IfcParse::IfcFile* file, const std::string& xml_filename) const { - MAKE_TYPE_NAME(XmlSerializer)* s = new MAKE_TYPE_NAME(XmlSerializer)(file, xml_filename); + POSTFIX_SCHEMA(XmlSerializer)* s = new POSTFIX_SCHEMA(XmlSerializer)(file, xml_filename); s->setFile(file); return s; } @@ -46,14 +46,14 @@ namespace { void MAKE_INIT_FN(XmlSerializer)(XmlSerializerFactory::Factory* mapping) { static const std::string schema_name = STRINGIFY(IfcSchema); - MAKE_TYPE_NAME(factory_t) factory; + POSTFIX_SCHEMA(factory_t) factory; mapping->bind(schema_name, factory); } namespace { // TODO: Make this a member of XmlSerializer? -std::map MAKE_TYPE_NAME(argument_name_map); +std::map POSTFIX_SCHEMA(argument_name_map); // Format an IFC attribute and maybe returns as string. Only literal scalar // values are converted. Things like entity instances and lists are omitted. @@ -127,7 +127,7 @@ boost::optional format_attribute(const Argument* argument, IfcUtil: } else if (e->declaration().is(IfcSchema::IfcLocalPlacement::Class())) { IfcSchema::IfcLocalPlacement* placement = e->as(); gp_Trsf trsf; - IfcGeom::MAKE_TYPE_NAME(Kernel) kernel; + IfcGeom::POSTFIX_SCHEMA(Kernel) kernel; if (kernel.convert(placement, trsf)) { std::stringstream stream; @@ -163,8 +163,8 @@ ptree& format_entity_instance(IfcUtil::IfcBaseEntity* instance, ptree& child, pt std::string argument_name = instance->declaration().attribute_by_index(i)->name(); std::map::const_iterator argument_name_it; - argument_name_it = MAKE_TYPE_NAME(argument_name_map).find(argument_name); - if (argument_name_it != MAKE_TYPE_NAME(argument_name_map).end()) { + argument_name_it = POSTFIX_SCHEMA(argument_name_map).find(argument_name); + if (argument_name_it != POSTFIX_SCHEMA(argument_name_map).end()) { argument_name = argument_name_it->second; } const IfcUtil::ArgumentType argument_type = instance->data().getArgument(i)->type(); @@ -360,8 +360,8 @@ void format_quantities(IfcSchema::IfcPhysicalQuantity::list::ptr quantities, ptr } // ~unnamed namespace -void MAKE_TYPE_NAME(XmlSerializer)::finalize() { - MAKE_TYPE_NAME(argument_name_map).insert(std::make_pair("GlobalId", "id")); +void POSTFIX_SCHEMA(XmlSerializer)::finalize() { + POSTFIX_SCHEMA(argument_name_map).insert(std::make_pair("GlobalId", "id")); IfcSchema::IfcProject::list::ptr projects = file->instances_by_type(); if (projects->size() != 1) { diff --git a/src/serializers/schema_dependent/XmlSerializer.h b/src/serializers/schema_dependent/XmlSerializer.h index c6508850d1..9e55d7f1f6 100644 --- a/src/serializers/schema_dependent/XmlSerializer.h +++ b/src/serializers/schema_dependent/XmlSerializer.h @@ -26,12 +26,12 @@ #define INCLUDE_PARENT_PARENT_DIR(x) STRINGIFY(../../ifcparse/x.h) #include INCLUDE_PARENT_PARENT_DIR(IfcSchema) -class MAKE_TYPE_NAME(XmlSerializer) : public XmlSerializer { +class POSTFIX_SCHEMA(XmlSerializer) : public XmlSerializer { private: IfcParse::IfcFile* file; public: - MAKE_TYPE_NAME(XmlSerializer)(IfcParse::IfcFile* file, const std::string& xml_filename) + POSTFIX_SCHEMA(XmlSerializer)(IfcParse::IfcFile* file, const std::string& xml_filename) : XmlSerializer(0, "") { this->file = file;