2017-12-20 16:38:55 +01:00
|
|
|
#ifndef ITERATOR_KERNEL_H
|
|
|
|
|
#define ITERATOR_KERNEL_H
|
|
|
|
|
|
2017-12-22 13:51:11 +01:00
|
|
|
#include "../ifcparse/IfcFile.h"
|
2022-06-15 13:41:13 +02:00
|
|
|
#include "../ifcgeom_schema_agnostic/IfcGeomIteratorSettings.h"
|
|
|
|
|
#include "../ifcgeom_schema_agnostic/IfcRepresentationShapeItem.h"
|
2017-12-22 13:51:11 +01:00
|
|
|
|
2021-05-11 22:29:16 +02:00
|
|
|
#ifdef HAS_SCHEMA_2x3
|
2018-03-04 10:44:09 +01:00
|
|
|
#include "../ifcparse/Ifc2x3.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4
|
2018-03-04 10:44:09 +01:00
|
|
|
#include "../ifcparse/Ifc4.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4x1
|
2020-06-15 12:48:30 +02:00
|
|
|
#include "../ifcparse/Ifc4x1.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4x2
|
2020-06-15 12:48:30 +02:00
|
|
|
#include "../ifcparse/Ifc4x2.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4x3_rc1
|
2020-06-15 12:48:30 +02:00
|
|
|
#include "../ifcparse/Ifc4x3_rc1.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4x3_rc2
|
2021-02-14 12:43:27 +01:00
|
|
|
#include "../ifcparse/Ifc4x3_rc2.h"
|
2021-05-11 22:29:16 +02:00
|
|
|
#endif
|
2021-07-03 21:42:37 -07:00
|
|
|
#ifdef HAS_SCHEMA_4x3_rc3
|
|
|
|
|
#include "../ifcparse/Ifc4x3_rc3.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAS_SCHEMA_4x3_rc4
|
|
|
|
|
#include "../ifcparse/Ifc4x3_rc4.h"
|
|
|
|
|
#endif
|
2018-03-04 10:44:09 +01:00
|
|
|
|
2017-12-22 13:51:11 +01:00
|
|
|
#include <boost/function.hpp>
|
|
|
|
|
|
|
|
|
|
#include <TopExp_Explorer.hxx>
|
2022-06-14 15:02:54 +02:00
|
|
|
#include <gp_Ax2.hxx>
|
|
|
|
|
#include <gp_Ax3.hxx>
|
|
|
|
|
#include <gp_Trsf2d.hxx>
|
|
|
|
|
#include <gp_GTrsf2d.hxx>
|
|
|
|
|
#include <gp_Trsf.hxx>
|
|
|
|
|
#include <gp_GTrsf.hxx>
|
2017-12-22 13:51:11 +01:00
|
|
|
|
2022-06-15 13:41:13 +02:00
|
|
|
static const double ALMOST_ZERO = 1.e-9;
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance = ALMOST_ZERO) {
|
|
|
|
|
return fabs(a - b) < tolerance;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-16 13:49:11 +01:00
|
|
|
namespace IfcGeom {
|
2018-03-04 10:44:09 +01:00
|
|
|
|
2017-12-22 13:51:11 +01:00
|
|
|
class BRepElement;
|
|
|
|
|
|
2017-12-20 16:38:55 +01:00
|
|
|
class Kernel {
|
2017-12-22 13:51:11 +01:00
|
|
|
private:
|
|
|
|
|
Kernel* implementation_;
|
|
|
|
|
|
2022-03-22 22:30:27 +01:00
|
|
|
protected:
|
|
|
|
|
Kernel() {};
|
|
|
|
|
|
2017-12-20 16:38:55 +01:00
|
|
|
public:
|
|
|
|
|
// Tolerances and settings for various geometrical operations:
|
|
|
|
|
enum GeomValue {
|
|
|
|
|
// Specifies the deflection of the mesher
|
|
|
|
|
// Default: 0.001m / 1mm
|
|
|
|
|
GV_DEFLECTION_TOLERANCE,
|
|
|
|
|
// Specifies the minimal area of a face to be included in an IfcConnectedFaceset
|
|
|
|
|
// Read-only
|
|
|
|
|
GV_MINIMAL_FACE_AREA,
|
2018-09-07 14:42:15 +02:00
|
|
|
// Specifies the threshold distance under which cartesian points are deemed equal
|
2019-05-24 14:29:21 +02:00
|
|
|
// Read-only
|
2017-12-20 16:38:55 +01:00
|
|
|
GV_POINT_EQUALITY_TOLERANCE,
|
2019-05-24 14:29:21 +02:00
|
|
|
// Specifies maximum number of faces for a shell to be reoriented.
|
|
|
|
|
// Default: -1
|
|
|
|
|
GV_MAX_FACES_TO_ORIENT,
|
2017-12-20 16:38:55 +01:00
|
|
|
// The length unit used the creation of TopoDS_Shapes, primarily affects the
|
|
|
|
|
// interpretation of IfcCartesianPoints and IfcVector magnitudes
|
|
|
|
|
// DefaultL 1.0
|
|
|
|
|
GV_LENGTH_UNIT,
|
|
|
|
|
// The plane angle unit used for the creation of TopoDS_Shapes, primarily affects
|
|
|
|
|
// the interpretation of IfcParamaterValues of IfcTrimmedCurves
|
|
|
|
|
// Default: -1.0 (= not set, fist try degrees, then radians)
|
|
|
|
|
GV_PLANEANGLE_UNIT,
|
|
|
|
|
// The precision used in boolean operations, setting this value too low results
|
|
|
|
|
// in artefacts and potentially modelling failures
|
|
|
|
|
// Default: 0.00001 (obtained from IfcGeometricRepresentationContext if available)
|
|
|
|
|
GV_PRECISION,
|
|
|
|
|
// Whether to process shapes of type Face or higher (1) Wire or lower (-1) or all (0)
|
2020-06-07 20:23:00 +02:00
|
|
|
GV_DIMENSIONALITY,
|
2021-02-05 14:03:13 -06:00
|
|
|
GV_LAYERSET_FIRST,
|
2021-02-05 14:00:23 -06:00
|
|
|
GV_DISABLE_BOOLEAN_RESULT,
|
2021-02-06 10:26:17 -06:00
|
|
|
GV_NO_WIRE_INTERSECTION_CHECK,
|
|
|
|
|
GV_PRECISION_FACTOR,
|
2021-02-08 14:06:05 -06:00
|
|
|
GV_NO_WIRE_INTERSECTION_TOLERANCE,
|
2022-01-09 15:15:29 +01:00
|
|
|
GV_DEBUG_BOOLEAN,
|
|
|
|
|
GV_BOOLEAN_ATTEMPT_2D
|
2017-12-20 16:38:55 +01:00
|
|
|
};
|
2017-12-22 13:51:11 +01:00
|
|
|
|
2022-04-26 11:46:21 +02:00
|
|
|
IFC_PARSE_API Kernel(IfcParse::IfcFile* file_);
|
2017-12-20 16:38:55 +01:00
|
|
|
|
|
|
|
|
virtual ~Kernel() {}
|
2017-12-22 13:51:11 +01:00
|
|
|
|
|
|
|
|
virtual void setValue(GeomValue var, double value) {
|
|
|
|
|
implementation_->setValue(var, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual double getValue(GeomValue var) const {
|
|
|
|
|
return implementation_->getValue(var);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-11 15:00:59 +02:00
|
|
|
virtual BRepElement* convert(
|
2017-12-22 13:51:11 +01:00
|
|
|
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
|
|
|
|
|
IfcUtil::IfcBaseClass* product)
|
|
|
|
|
{
|
|
|
|
|
return implementation_->convert(settings, representation, product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) {
|
|
|
|
|
return implementation_->convert(item);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-19 14:05:19 +02:00
|
|
|
virtual bool convert_placement(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) {
|
|
|
|
|
return implementation_->convert_placement(item, trsf);
|
2018-03-04 10:44:09 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-26 11:46:21 +02:00
|
|
|
IFC_PARSE_API static int count(const TopoDS_Shape&, TopAbs_ShapeEnum, bool unique = false);
|
|
|
|
|
IFC_PARSE_API static int surface_genus(const TopoDS_Shape&);
|
2018-03-04 10:44:09 +01:00
|
|
|
|
2022-04-26 11:46:21 +02:00
|
|
|
IFC_PARSE_API static bool is_manifold(const TopoDS_Shape& a);
|
|
|
|
|
IFC_PARSE_API static IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity*, bool include_openings = true);
|
|
|
|
|
IFC_PARSE_API static std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
|
2022-06-14 15:02:54 +02:00
|
|
|
|
|
|
|
|
// For axis placements detect equality early in order for the
|
|
|
|
|
// relatively computionaly expensive gp_Trsf calculation to be skipped
|
|
|
|
|
IFC_PARSE_API static bool axis_equal(const gp_Ax3& a, const gp_Ax3& b, double tolerance) {
|
|
|
|
|
if (!a.Location().IsEqual(b.Location(), tolerance)) return false;
|
|
|
|
|
// Note that the tolerance below is angular, above is linear. Since architectural
|
|
|
|
|
// objects are about 1m'ish in scale, it should be somewhat equivalent. Besides,
|
|
|
|
|
// this is mostly a filter for NULL or default values in the placements.
|
|
|
|
|
if (!a.Direction().IsEqual(b.Direction(), tolerance)) return false;
|
|
|
|
|
if (!a.XDirection().IsEqual(b.XDirection(), tolerance)) return false;
|
|
|
|
|
if (!a.YDirection().IsEqual(b.YDirection(), tolerance)) return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IFC_PARSE_API static bool axis_equal(const gp_Ax2d& a, const gp_Ax2d& b, double tolerance) {
|
|
|
|
|
if (!a.Location().IsEqual(b.Location(), tolerance)) return false;
|
|
|
|
|
if (!a.Direction().IsEqual(b.Direction(), tolerance)) return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IFC_PARSE_API static bool is_identity(const gp_Trsf2d& t, double tolerance);
|
|
|
|
|
IFC_PARSE_API static bool is_identity(const gp_GTrsf2d& t, double tolerance);
|
|
|
|
|
IFC_PARSE_API static bool is_identity(const gp_Trsf& t, double tolerance);
|
|
|
|
|
IFC_PARSE_API static bool is_identity(const gp_GTrsf& t, double tolerance);
|
|
|
|
|
|
|
|
|
|
IFC_PARSE_API static gp_Trsf combine_offset_and_rotation(const gp_Vec &offset, const gp_Quaternion& rotation);
|
2017-12-20 16:38:55 +01:00
|
|
|
};
|
2017-12-22 13:51:11 +01:00
|
|
|
|
|
|
|
|
namespace impl {
|
|
|
|
|
typedef boost::function1<Kernel*, IfcParse::IfcFile*> kernel_fn;
|
|
|
|
|
|
|
|
|
|
class KernelFactoryImplementation : public std::map<std::string, kernel_fn> {
|
|
|
|
|
public:
|
|
|
|
|
KernelFactoryImplementation();
|
|
|
|
|
void bind(const std::string& schema_name, kernel_fn);
|
|
|
|
|
Kernel* construct(const std::string& schema_name, IfcParse::IfcFile*);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
KernelFactoryImplementation& kernel_implementations();
|
|
|
|
|
}
|
2022-06-11 15:48:04 +02:00
|
|
|
|
|
|
|
|
namespace util {
|
|
|
|
|
bool is_nested_compound_of_solid(const TopoDS_Shape& s, int depth = 0);
|
|
|
|
|
}
|
2022-06-14 15:02:54 +02:00
|
|
|
|
|
|
|
|
class IFC_GEOM_API geometry_exception : public std::exception {
|
|
|
|
|
protected:
|
|
|
|
|
std::string message;
|
|
|
|
|
public:
|
|
|
|
|
geometry_exception(const std::string& m)
|
|
|
|
|
: message(m) {}
|
|
|
|
|
virtual ~geometry_exception() throw () {}
|
|
|
|
|
virtual const char* what() const throw() {
|
|
|
|
|
return message.c_str();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class IFC_GEOM_API too_many_faces_exception : public geometry_exception {
|
|
|
|
|
public:
|
|
|
|
|
too_many_faces_exception()
|
|
|
|
|
: geometry_exception("Too many faces for operation") {}
|
|
|
|
|
};
|
2017-12-20 16:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|