mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
First step at reorganizing
This commit is contained in:
+9
-18
@@ -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})
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<int, TopoDS_Shape> 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<const IfcSchema::IfcPolyLoop*> duplicates_;
|
||||
std::map<int, int> vertex_mapping_;
|
||||
std::map<std::pair<int, int>, 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
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#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);
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#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*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
#include "../../../ifcgeom/kernels/opencascade/IfcGeom.h"
|
||||
|
||||
#define Kernel MAKE_TYPE_NAME(Kernel)
|
||||
#define Kernel POSTFIX_SCHEMA(Kernel)
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "IfcGeom.h"
|
||||
#include "IfcGeomShapeType.h"
|
||||
|
||||
#define Kernel MAKE_TYPE_NAME(Kernel)
|
||||
#define Kernel POSTFIX_SCHEMA(Kernel)
|
||||
|
||||
using namespace IfcUtil;
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifdef BIND
|
||||
#undef BIND
|
||||
#endif
|
||||
|
||||
#define BIND(T) ifcopenshell::geometry::taxonomy::item* convert(const IfcSchema::T*);
|
||||
|
||||
#include "mapping.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"
|
||||
@@ -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 <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* *
|
||||
* 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);
|
||||
@@ -0,0 +1,96 @@
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
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<double, 16> 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 <size_t N>
|
||||
struct cartesian_base : public item {
|
||||
std::array<double, N> 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<line, circle, ellipse, bspline> curve;
|
||||
|
||||
struct edge : public item {
|
||||
boost::variant<point3, double> start, end;
|
||||
boost::optional<curve> basis;
|
||||
|
||||
virtual item* clone() const { return new edge(*this); }
|
||||
};
|
||||
|
||||
struct boundary : public item {
|
||||
std::vector<edge> edges;
|
||||
|
||||
virtual item* clone() const { return new boundary(*this); }
|
||||
};
|
||||
|
||||
struct face : public item {
|
||||
boundary outer;
|
||||
std::vector<boundary> 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); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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<std::string, std::string> MAKE_TYPE_NAME(argument_name_map);
|
||||
std::map<std::string, std::string> 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<std::string> format_attribute(const Argument* argument, IfcUtil:
|
||||
} else if (e->declaration().is(IfcSchema::IfcLocalPlacement::Class())) {
|
||||
IfcSchema::IfcLocalPlacement* placement = e->as<IfcSchema::IfcLocalPlacement>();
|
||||
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<std::string, std::string>::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<IfcSchema::IfcProject>();
|
||||
if (projects->size() != 1) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user