mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 05:46:51 +00:00
Major update: taxonomy shared pointers, collection type safety, work towards hashing
This commit is contained in:
@@ -23,19 +23,19 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAnnotationFillArea* inst) {
|
||||
auto loop = map(inst->OuterBoundary());
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAnnotationFillArea* inst) {
|
||||
auto loop = taxonomy::cast<taxonomy::loop>(map(inst->OuterBoundary()));
|
||||
if (loop) {
|
||||
auto face = new taxonomy::face;
|
||||
((taxonomy::loop*)loop)->external = true;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
loop->external = true;
|
||||
face->children = { loop };
|
||||
|
||||
if (inst->InnerBoundaries()) {
|
||||
IfcSchema::IfcCurve::list::ptr inner_boundaries = *inst->InnerBoundaries();
|
||||
for (auto& v : *inner_boundaries) {
|
||||
auto inner_loop = map(v);
|
||||
auto inner_loop = taxonomy::cast<taxonomy::loop>(map(v));
|
||||
if (inner_loop) {
|
||||
((taxonomy::loop*)inner_loop)->external = false;
|
||||
inner_loop->external = false;
|
||||
face->children.push_back(inner_loop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,20 +23,20 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcArbitraryClosedProfileDef* inst) {
|
||||
auto loop = map(inst->OuterCurve());
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryClosedProfileDef* inst) {
|
||||
auto loop = taxonomy::cast<taxonomy::loop>(map(inst->OuterCurve()));
|
||||
if (loop) {
|
||||
auto face = new taxonomy::face;
|
||||
((taxonomy::loop*)loop)->external = true;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
loop->external = true;
|
||||
face->children = { loop };
|
||||
|
||||
if (inst->as<IfcSchema::IfcArbitraryProfileDefWithVoids>()) {
|
||||
auto with_voids = inst->as<IfcSchema::IfcArbitraryProfileDefWithVoids>();
|
||||
auto voids = with_voids->InnerCurves();
|
||||
for (auto& v : *voids) {
|
||||
auto inner_loop = map(v);
|
||||
auto inner_loop = taxonomy::cast<taxonomy::loop>(map(v));
|
||||
if (inner_loop) {
|
||||
((taxonomy::loop*)inner_loop)->external = false;
|
||||
inner_loop->external = false;
|
||||
face->children.push_back(inner_loop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcArbitraryOpenProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryOpenProfileDef* inst) {
|
||||
return map(inst->Curve());
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
|
||||
Eigen::Vector3d P, axis(0, 0, 1), ref;
|
||||
{
|
||||
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
|
||||
P = *v.components_;
|
||||
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
|
||||
P = *v->components_;
|
||||
}
|
||||
const bool hasAxis = inst->Axis();
|
||||
if (hasAxis) {
|
||||
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->Axis()));
|
||||
axis = *v.components_;
|
||||
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
|
||||
axis = *v->components_;
|
||||
}
|
||||
|
||||
// @todo not sure what to do with ref, we're probably never reading it,
|
||||
@@ -43,5 +43,5 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
|
||||
ref = Eigen::Vector3d(1, 0, 0).cross(axis).normalized();
|
||||
}
|
||||
|
||||
return new taxonomy::matrix4(P, axis, ref);
|
||||
return taxonomy::make<taxonomy::matrix4>(P, axis, ref);
|
||||
}
|
||||
|
||||
@@ -23,16 +23,16 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
|
||||
Eigen::Vector3d P, axis(0, 0, 1), V(1, 0, 0);
|
||||
{
|
||||
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
|
||||
P = *v.components_;
|
||||
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
|
||||
P = *v->components_;
|
||||
}
|
||||
const bool hasRef = !!inst->RefDirection();
|
||||
if (hasRef) {
|
||||
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
V = *v.components_;
|
||||
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
V = *v->components_;
|
||||
}
|
||||
return new taxonomy::matrix4(P, axis, V);
|
||||
return taxonomy::make<taxonomy::matrix4>(P, axis, V);
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
|
||||
Eigen::Vector3d o, axis(0, 0, 1), refDirection, X(1, 0, 0);
|
||||
{
|
||||
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
|
||||
o = *v.components_;
|
||||
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
|
||||
o = *v->components_;
|
||||
}
|
||||
const bool hasAxis = !!inst->Axis();
|
||||
const bool hasRef = !!inst->RefDirection();
|
||||
@@ -37,13 +37,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
|
||||
}
|
||||
|
||||
if (hasAxis) {
|
||||
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->Axis()));
|
||||
axis = *v.components_;
|
||||
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
|
||||
axis = *v->components_;
|
||||
}
|
||||
|
||||
if (hasRef) {
|
||||
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
refDirection = *v.components_;
|
||||
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
|
||||
refDirection = *v->components_;
|
||||
} else {
|
||||
if (acos(axis.dot(X)) > 1.e-5) {
|
||||
refDirection = { 1., 0., 0. };
|
||||
@@ -54,5 +54,5 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
|
||||
auto Xaxis = refDirection - Xvec;
|
||||
refDirection = Xaxis;
|
||||
}
|
||||
return new taxonomy::matrix4(o, axis, refDirection);
|
||||
return taxonomy::make<taxonomy::matrix4>(o, axis, refDirection);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots* inst) {
|
||||
auto bc = new taxonomy::bspline_curve;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots* inst) {
|
||||
auto bc = taxonomy::make<taxonomy::bspline_curve>();
|
||||
|
||||
const IfcSchema::IfcCartesianPoint::list::ptr cps = inst->ControlPointsList();
|
||||
std::vector<taxonomy::point3> points;
|
||||
std::transform(cps->begin(), cps->end(), std::back_inserter(points), [this](IfcSchema::IfcCartesianPoint* cp) { return as<taxonomy::point3>(map(cp)); });
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
std::transform(cps->begin(), cps->end(), std::back_inserter(points), [this](IfcSchema::IfcCartesianPoint* cp) { return taxonomy::cast<taxonomy::point3>(map(cp)); });
|
||||
bc->control_points = points;
|
||||
|
||||
bc->multiplicities = inst->KnotMultiplicities();
|
||||
|
||||
@@ -25,13 +25,13 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots* inst) {
|
||||
auto bs = new taxonomy::bspline_surface;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots* inst) {
|
||||
auto bs = taxonomy::make<taxonomy::bspline_surface>();
|
||||
|
||||
auto cps = inst->ControlPointsList();
|
||||
std::transform(cps->begin(), cps->end(), std::back_inserter(bs->control_points), [this](const std::vector<IfcSchema::IfcCartesianPoint*>& inner) {
|
||||
std::vector<taxonomy::point3> ps;
|
||||
std::transform(inner.begin(), inner.end(), std::back_inserter(ps), [this](IfcSchema::IfcCartesianPoint* cp) { return as<taxonomy::point3>(map(cp)); });
|
||||
std::vector<taxonomy::point3::ptr> ps;
|
||||
std::transform(inner.begin(), inner.end(), std::back_inserter(ps), [this](IfcSchema::IfcCartesianPoint* cp) { return taxonomy::cast<taxonomy::point3>(map(cp)); });
|
||||
return ps;
|
||||
});
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBlock* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBlock* inst) {
|
||||
const double dx = inst->XLength() * length_unit_;
|
||||
const double dy = inst->YLength() * length_unit_;
|
||||
const double dz = inst->ZLength() * length_unit_;
|
||||
|
||||
auto solid = create_box(dx, dy, dz);
|
||||
solid->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
solid->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
|
||||
return solid;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBooleanResult* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBooleanResult* inst) {
|
||||
IfcSchema::IfcBooleanOperand* operand1 = inst->FirstOperand();
|
||||
IfcSchema::IfcBooleanOperand* operand2 = inst->SecondOperand();
|
||||
bool has_halfspace_operand = false;
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBoundingBox* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBoundingBox* inst) {
|
||||
const double dx = inst->XDim() * length_unit_;
|
||||
const double dy = inst->YDim() * length_unit_;
|
||||
const double dz = inst->ZDim() * length_unit_;
|
||||
|
||||
taxonomy::point3 corner = as<taxonomy::point3>(map(inst->Corner()));
|
||||
auto solid = create_box(corner.ccomponents().x(), corner.ccomponents().y(), corner.ccomponents().z(), dx, dy, dz);
|
||||
taxonomy::point3::ptr corner = taxonomy::cast<taxonomy::point3>(map(inst->Corner()));
|
||||
auto solid = create_box(corner->ccomponents().x(), corner->ccomponents().y(), corner->ccomponents().z(), dx, dy, dz);
|
||||
|
||||
return solid;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
|
||||
#include <vector>
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
|
||||
const double y = inst->Depth() / 2.0f * length_unit_;
|
||||
const double x = inst->Width() / 2.0f * length_unit_;
|
||||
const double d1 = inst->WallThickness() * length_unit_;
|
||||
@@ -47,13 +47,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianPoint* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianPoint* inst) {
|
||||
std::vector<double> xyz = inst->Coordinates();
|
||||
return new taxonomy::point3(
|
||||
return taxonomy::make<taxonomy::point3>(
|
||||
xyz.size() >= 1 ? xyz[0] * length_unit_ : 0.,
|
||||
xyz.size() >= 2 ? xyz[1] * length_unit_ : 0.,
|
||||
xyz.size() >= 3 ? xyz[2] * length_unit_ : 0.
|
||||
|
||||
@@ -21,21 +21,21 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator2D* inst) {
|
||||
auto m = new taxonomy::matrix4;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator2D* inst) {
|
||||
auto m = taxonomy::make<taxonomy::matrix4>();
|
||||
|
||||
Eigen::Vector4d origin, axis1(1.0, 0.0, 0.0, 0.0), axis2(0.0, 1.0, 0.0, 0.0), axis3(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
taxonomy::point3 O = as<taxonomy::point3>(map(inst->LocalOrigin()));
|
||||
origin << *O.components_, 1.0;
|
||||
taxonomy::point3::ptr O = taxonomy::cast<taxonomy::point3>(map(inst->LocalOrigin()));
|
||||
origin << *O->components_, 1.0;
|
||||
|
||||
if (inst->Axis1()) {
|
||||
taxonomy::direction3 ax1 = as<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis1 << *ax1.components_, 0.0;
|
||||
taxonomy::direction3::ptr ax1 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis1 << *ax1->components_, 0.0;
|
||||
}
|
||||
if (inst->Axis2()) {
|
||||
taxonomy::direction3 ax2 = as<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis2 << *ax2.components_, 0.0;
|
||||
taxonomy::direction3::ptr ax2 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis2 << *ax2->components_, 0.0;
|
||||
}
|
||||
|
||||
double scale1, scale2;
|
||||
|
||||
@@ -21,30 +21,30 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator3D* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator3D* inst) {
|
||||
|
||||
Eigen::Vector4d origin;
|
||||
Eigen::Vector4d axis1(1., 0., 0., 0.);
|
||||
Eigen::Vector4d axis2(0., 1., 0., 0.);
|
||||
Eigen::Vector4d axis3(0., 0., 1., 0.);
|
||||
|
||||
taxonomy::point3 O = as<taxonomy::point3>(map(inst->LocalOrigin()));
|
||||
origin << *O.components_, 1.0;
|
||||
taxonomy::point3::ptr O = taxonomy::cast<taxonomy::point3>(map(inst->LocalOrigin()));
|
||||
origin << *O->components_, 1.0;
|
||||
|
||||
if (inst->Axis1()) {
|
||||
taxonomy::direction3 ax1 = as<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis1 << *ax1.components_, 0.0;
|
||||
taxonomy::direction3::ptr ax1 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
|
||||
axis1 << *ax1->components_, 0.0;
|
||||
}
|
||||
if (inst->Axis2()) {
|
||||
taxonomy::direction3 ax2 = as<taxonomy::direction3>(map(inst->Axis2()));
|
||||
axis2 << *ax2.components_, 0.0;
|
||||
taxonomy::direction3::ptr ax2 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis2()));
|
||||
axis2 << *ax2->components_, 0.0;
|
||||
}
|
||||
if (inst->Axis3()) {
|
||||
taxonomy::direction3 ax3 = as<taxonomy::direction3>(map(inst->Axis3()));
|
||||
axis3 << *ax3.components_, 0.0;
|
||||
taxonomy::direction3::ptr ax3 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis3()));
|
||||
axis3 << *ax3->components_, 0.0;
|
||||
}
|
||||
|
||||
auto m4 = new taxonomy::matrix4(origin.head<3>(), axis3.head<3>(), axis1.head<3>());
|
||||
auto m4 = taxonomy::make<taxonomy::matrix4>(origin.head<3>(), axis3.head<3>(), axis1.head<3>());
|
||||
if (m4->ccomponents().col(1).dot(axis2) < 0.) {
|
||||
m4->components().col(1) *= -1.;
|
||||
}
|
||||
|
||||
@@ -21,16 +21,21 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef* inst) {
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
const double d = inst->Thickness() * length_unit_ / 2.;
|
||||
auto f = new taxonomy::face;
|
||||
auto ofc = new taxonomy::offset_curve;
|
||||
auto f = taxonomy::make<taxonomy::face>();
|
||||
auto ofc = taxonomy::make<taxonomy::offset_curve>();
|
||||
ofc->basis = map(inst->Curve());
|
||||
ofc->offset = d;
|
||||
f->children.push_back(ofc);
|
||||
// @todo
|
||||
// f->children.push_back(ofc);
|
||||
return f;
|
||||
*/
|
||||
|
||||
// @todo we still need to handle this in the l
|
||||
// @todo we still need to handle this in the geometry libraries
|
||||
|
||||
/*
|
||||
TopoDS_Wire wire;
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#define ALMOST_ZERO 1.e-7;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircle* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle* inst) {
|
||||
const double r = inst->Radius() * length_unit_;
|
||||
if (r < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", inst);
|
||||
@@ -31,8 +31,8 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircle* inst) {
|
||||
}
|
||||
|
||||
IfcSchema::IfcAxis2Placement* placement = inst->Position();
|
||||
auto c = new taxonomy::circle;
|
||||
auto c = taxonomy::make<taxonomy::circle>();
|
||||
c->radius = r;
|
||||
c->matrix = as<taxonomy::matrix4>(map(placement));
|
||||
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(placement));
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
|
||||
std::vector<double> radii = { inst->Radius() * length_unit_ };
|
||||
|
||||
if (inst->as<IfcSchema::IfcCircleHollowProfileDef>()) {
|
||||
@@ -31,13 +31,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
|
||||
radii.push_back(radii.front() - t);
|
||||
}
|
||||
|
||||
auto f = new taxonomy::face;
|
||||
auto f = taxonomy::make<taxonomy::face>();
|
||||
|
||||
for (auto it = radii.begin(); it != radii.end(); ++it) {
|
||||
const double r = *it;
|
||||
const bool exterior = it == radii.begin();
|
||||
|
||||
auto c = new taxonomy::circle;
|
||||
auto c = taxonomy::make<taxonomy::circle>();
|
||||
c->radius = r;
|
||||
|
||||
bool has_position = true;
|
||||
@@ -45,18 +45,15 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
taxonomy::matrix4 m = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
if (m.components_) {
|
||||
c->matrix = *m.components_;
|
||||
}
|
||||
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
auto e = new taxonomy::edge;
|
||||
auto e = taxonomy::make<taxonomy::edge>();
|
||||
e->basis = c;
|
||||
e->start = 0.;
|
||||
e->end = 2 * boost::math::constants::pi<double>();
|
||||
|
||||
auto l = new taxonomy::loop;
|
||||
auto l = taxonomy::make<taxonomy::loop>();
|
||||
l->children = { e };
|
||||
l->external = exterior;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
auto loop = new taxonomy::loop;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcSegment
|
||||
// 4x3
|
||||
@@ -49,7 +49,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
Logger::Warning("Segment length below tolerance", segment);
|
||||
}
|
||||
|
||||
auto e = new taxonomy::edge;
|
||||
auto e = taxonomy::make<taxonomy::edge>();
|
||||
e->basis = map(curve);
|
||||
e->start = u0;
|
||||
e->end = u1;
|
||||
@@ -60,14 +60,14 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
auto crv = map(segment->ParentCurve());
|
||||
if (crv) {
|
||||
if (crv->kind() == taxonomy::EDGE) {
|
||||
((taxonomy::edge*)crv)->orientation_2.reset(segment->SameSense());
|
||||
loop->children.push_back(crv);
|
||||
auto ecrv = taxonomy::cast<taxonomy::edge>(crv);
|
||||
ecrv->orientation_2.reset(segment->SameSense());
|
||||
loop->children.push_back(ecrv);
|
||||
} else if (crv->kind() == taxonomy::LOOP) {
|
||||
if (!segment->SameSense()) {
|
||||
crv->reverse();
|
||||
}
|
||||
auto curve_segments = ((taxonomy::loop*)crv)->children_as<taxonomy::edge>();
|
||||
for (auto& s : curve_segments) {
|
||||
for (auto& s : taxonomy::cast<taxonomy::loop>(crv)->children) {
|
||||
loop->children.push_back(s);
|
||||
}
|
||||
// @todo delete crv without children
|
||||
@@ -95,7 +95,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
|
||||
#define _USE_MATH_DEFINES
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
|
||||
|
||||
|
||||
TopTools_ListOfShape converted_segments;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeProfileDef* inst) {
|
||||
// @todo double check that this is actually supported
|
||||
IfcSchema::IfcProfileDef::list::ptr profiles = inst->Profiles();
|
||||
return map_to_collection<>(this, profiles);
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcConnectedFaceSet* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcConnectedFaceSet* inst) {
|
||||
auto shell = map_to_collection<taxonomy::shell>(this, inst->CfsFaces());
|
||||
if (shell == nullptr) {
|
||||
if (!shell) {
|
||||
return nullptr;
|
||||
}
|
||||
shell->closed = inst->declaration().is(IfcSchema::IfcClosedShell::Class());
|
||||
|
||||
@@ -25,7 +25,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcCraneRailAShapeProfileDef
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef* inst) {
|
||||
double oh = inst->OverallHeight() * length_unit_;
|
||||
double bw2 = inst->BaseWidth2() * length_unit_;
|
||||
double hw = inst->HeadWidth() * length_unit_;
|
||||
@@ -37,13 +37,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef*
|
||||
double bd2 = inst->BaseDepth2() * length_unit_;
|
||||
double bd3 = inst->BaseDepth3() * length_unit_;
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCsgSolid* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCsgSolid* inst) {
|
||||
return map(inst->TreeRootExpression());
|
||||
}
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCurveBoundedPlane* inst) {
|
||||
taxonomy::plane pl = as<taxonomy::plane>(map(inst->BasisSurface()));
|
||||
auto f = new taxonomy::face;
|
||||
f->children.push_back(map(inst->OuterBoundary()));
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveBoundedPlane* inst) {
|
||||
taxonomy::plane::ptr pl = taxonomy::cast<taxonomy::plane>(map(inst->BasisSurface()));
|
||||
auto f = taxonomy::make<taxonomy::face>();
|
||||
f->children.push_back(taxonomy::cast<taxonomy::loop>(map(inst->OuterBoundary())));
|
||||
|
||||
IfcSchema::IfcCurve::list::ptr boundaries = inst->InnerBoundaries();
|
||||
|
||||
for (IfcSchema::IfcCurve::list::it it = boundaries->begin(); it != boundaries->end(); ++it) {
|
||||
f->children.push_back(map(*it));
|
||||
f->children.push_back(taxonomy::cast<taxonomy::loop>(map(*it)));
|
||||
}
|
||||
f->matrix = pl.matrix;
|
||||
f->matrix = pl->matrix;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcCylindricalSurface
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCylindricalSurface* inst) {
|
||||
auto c = new taxonomy::cylinder;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCylindricalSurface* inst) {
|
||||
auto c = taxonomy::make<taxonomy::cylinder>();
|
||||
c->radius = inst->Radius() * length_unit_;
|
||||
c->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcDerivedProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDerivedProfileDef* inst) {
|
||||
auto it = map(inst->ParentProfile());
|
||||
taxonomy::matrix4 m = as<taxonomy::matrix4>(map(inst->Operator()));
|
||||
((taxonomy::geom_item*)it)->matrix.components() *= m.ccomponents();
|
||||
taxonomy::matrix4::ptr m = taxonomy::cast<taxonomy::matrix4>(map(inst->Operator()));
|
||||
taxonomy::cast<taxonomy::geom_item>(it)->matrix->components() *= m->ccomponents();
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcDirection* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDirection* inst) {
|
||||
auto coords = inst->DirectionRatios();
|
||||
return new taxonomy::direction3(
|
||||
return taxonomy::make<taxonomy::direction3>(
|
||||
coords.size() >= 1 ? coords[0] : 0.,
|
||||
coords.size() >= 2 ? coords[1] : 0.,
|
||||
coords.size() >= 3 ? coords[2] : 0.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdge* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge* inst) {
|
||||
if (!inst->EdgeStart()->declaration().is(IfcSchema::IfcVertexPoint::Class()) || !inst->EdgeEnd()->declaration().is(IfcSchema::IfcVertexPoint::Class())) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
|
||||
return nullptr;
|
||||
@@ -34,10 +34,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdge* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto e = new taxonomy::edge;
|
||||
auto e = taxonomy::make<taxonomy::edge>();
|
||||
|
||||
e->start = as<taxonomy::point3>(map(pnt1));
|
||||
e->end = as<taxonomy::point3>(map(pnt2));
|
||||
e->start = taxonomy::cast<taxonomy::point3>(map(pnt1));
|
||||
e->end = taxonomy::cast<taxonomy::point3>(map(pnt2));
|
||||
|
||||
if (inst->as<IfcSchema::IfcEdgeCurve>()) {
|
||||
e->basis = map(inst->as<IfcSchema::IfcEdgeCurve>()->EdgeGeometry());
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdgeLoop* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdgeLoop* inst) {
|
||||
return map_to_collection<taxonomy::loop>(this, inst->EdgeList());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
|
||||
double x = inst->SemiAxis1() * length_unit_;
|
||||
double y = inst->SemiAxis2() * length_unit_;
|
||||
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
|
||||
@@ -30,19 +30,21 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto el = new taxonomy::ellipse;
|
||||
el->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
auto el = taxonomy::make<taxonomy::ellipse>();
|
||||
el->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
|
||||
// Open Cascade does not allow ellipses of which the minor radius
|
||||
// is greater than the major radius. Hence, in this case, the
|
||||
// ellipse is rotated. Note that special care is taken
|
||||
// when creating a trimmed curve off of an ellipse like this.
|
||||
if (y > x) {
|
||||
el->matrix.components() <<
|
||||
-el->matrix.ccomponents().col(1),
|
||||
el->matrix.ccomponents().col(0),
|
||||
el->matrix.ccomponents().col(2),
|
||||
el->matrix.ccomponents().col(3);
|
||||
// @todo is a copy necesary here or can this be done in place?
|
||||
auto m4_copy = *el->matrix;
|
||||
el->matrix->components() <<
|
||||
-m4_copy.components().col(1),
|
||||
m4_copy.components().col(0),
|
||||
m4_copy.components().col(2),
|
||||
m4_copy.components().col(3);
|
||||
std::swap(x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
|
||||
double rx = inst->SemiAxis1() * length_unit_;
|
||||
double ry = inst->SemiAxis2() * length_unit_;
|
||||
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
|
||||
@@ -32,19 +32,19 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
|
||||
|
||||
const bool rotated = ry > rx;
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
if (ry > rx) {
|
||||
// @todo is a copy necesary here or can this be done in place?
|
||||
auto m4_copy = m4;
|
||||
m4.components() <<
|
||||
auto m4_copy = *m4;
|
||||
m4->components() <<
|
||||
-m4_copy.components().col(1),
|
||||
m4_copy.components().col(0),
|
||||
m4_copy.components().col(2),
|
||||
@@ -52,10 +52,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
|
||||
std::swap(rx, ry);
|
||||
}
|
||||
|
||||
auto fc = new taxonomy::face;
|
||||
auto lp = new taxonomy::loop;
|
||||
auto ed = new taxonomy::edge;
|
||||
auto el = new taxonomy::ellipse;
|
||||
auto fc = taxonomy::make<taxonomy::face>();
|
||||
auto lp = taxonomy::make<taxonomy::loop>();
|
||||
auto ed = taxonomy::make<taxonomy::edge>();
|
||||
auto el = taxonomy::make<taxonomy::ellipse>();
|
||||
el->radius = rx;
|
||||
el->radius2 = ry;
|
||||
ed->basis = el;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
|
||||
const double height = inst->Depth() * length_unit_;
|
||||
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", inst);
|
||||
@@ -33,13 +33,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
|
||||
#endif
|
||||
}
|
||||
|
||||
taxonomy::matrix4 matrix;
|
||||
taxonomy::matrix4::ptr matrix;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
|
||||
has_position = inst->Position() != nullptr;
|
||||
#endif
|
||||
if (has_position) {
|
||||
matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
#ifdef PERMISSIVE_EXTRUSION
|
||||
@@ -49,10 +49,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
|
||||
}
|
||||
#endif
|
||||
|
||||
return new taxonomy::extrusion(
|
||||
return taxonomy::make<taxonomy::extrusion>(
|
||||
matrix,
|
||||
as<taxonomy::face>(map(inst->SweptArea())),
|
||||
as<taxonomy::direction3>(map(inst->ExtrudedDirection())),
|
||||
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
|
||||
taxonomy::cast<taxonomy::direction3>(map(inst->ExtrudedDirection())),
|
||||
height
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,25 +24,25 @@ using namespace ifcopenshell::geometry;
|
||||
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
|
||||
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
|
||||
const double height = inst->Depth() * length_unit_;
|
||||
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", inst);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::direction3 dir = as<taxonomy::direction3>(map(inst->ExtrudedDirection()));
|
||||
Eigen::Affine3d af3d(Eigen::Translation3d(height * dir.ccomponents()));
|
||||
taxonomy::direction3::ptr dir = taxonomy::cast<taxonomy::direction3>(map(inst->ExtrudedDirection()));
|
||||
Eigen::Affine3d af3d(Eigen::Translation3d(height * dir->ccomponents()));
|
||||
Eigen::Matrix4d end_profile = af3d.matrix();
|
||||
|
||||
auto loft = new taxonomy::loft;
|
||||
auto loft = taxonomy::make<taxonomy::loft>();
|
||||
loft->children = {
|
||||
map(inst->SweptArea()),
|
||||
map(inst->EndSweptArea())
|
||||
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
|
||||
taxonomy::cast<taxonomy::face>(map(inst->EndSweptArea()))
|
||||
};
|
||||
|
||||
auto old = ((taxonomy::geom_item*)loft->children.back())->matrix.ccomponents();
|
||||
((taxonomy::geom_item*)loft->children.back())->matrix.components() = old * end_profile;
|
||||
auto old = loft->children.back()->matrix->ccomponents();
|
||||
loft->children.back()->matrix->components() = old * end_profile;
|
||||
|
||||
return loft;
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
|
||||
taxonomy::face* face = new taxonomy::face;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace* inst) {
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto bounds = inst->Bounds();
|
||||
for (auto& bound : *bounds) {
|
||||
if (auto r = map(bound->Bound())) {
|
||||
if (auto r = taxonomy::cast<taxonomy::loop>(map(bound->Bound()))) {
|
||||
if (!bound->Orientation()) {
|
||||
r->reverse();
|
||||
}
|
||||
if (bound->declaration().is(IfcSchema::IfcFaceOuterBound::Class())) {
|
||||
((taxonomy::loop*)r)->external = true;
|
||||
r->external = true;
|
||||
/*
|
||||
// Make a copy in case we need immutability later for e.g. caching
|
||||
auto s = r->clone();
|
||||
@@ -43,7 +43,9 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
|
||||
}
|
||||
}
|
||||
if (face->children.empty()) {
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete face;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return face;
|
||||
@@ -76,7 +78,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
|
||||
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* l, TopoDS_Shape& result) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace* l, TopoDS_Shape& result) {
|
||||
IfcSchema::IfcFaceBound::list::ptr bounds = inst->Bounds();
|
||||
|
||||
util::face_definition fd;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFaceBasedSurfaceModel* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFaceBasedSurfaceModel* inst) {
|
||||
// @todo check styles?
|
||||
return map_to_collection(this, inst->FbsmFaces());
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcGeometricSet* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGeometricSet* inst) {
|
||||
return map_to_collection(this, inst->Elements());
|
||||
}
|
||||
|
||||
@@ -21,18 +21,20 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
|
||||
IfcSchema::IfcSurface* surface = inst->BaseSurface();
|
||||
if (!surface->declaration().is(IfcSchema::IfcPlane::Class())) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface);
|
||||
return nullptr;
|
||||
}
|
||||
auto p = new taxonomy::plane;
|
||||
p->matrix = as<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
|
||||
auto f = new taxonomy::face;
|
||||
auto p = taxonomy::make<taxonomy::plane>();
|
||||
p->matrix = taxonomy::cast<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
|
||||
auto f = taxonomy::make<taxonomy::face>();
|
||||
f->orientation.reset(!inst->AgreementFlag());
|
||||
f->basis = p;
|
||||
auto s = new taxonomy::solid;
|
||||
s->children.push_back(f);
|
||||
return s;
|
||||
auto sh = taxonomy::make<taxonomy::shell>();
|
||||
sh->children.push_back(f);
|
||||
auto so = taxonomy::make<taxonomy::solid>();
|
||||
so->children.push_back(sh);
|
||||
return so;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
|
||||
const bool doFillet1 = !!inst->FilletRadius();
|
||||
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
|
||||
const bool doFlangeEdgeRadius = !!inst->FlangeEdgeRadius();
|
||||
@@ -85,13 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
|
||||
IfcSchema::IfcCartesianPointList* point_list = inst->Points();
|
||||
std::vector< std::vector<double> > coordinates;
|
||||
@@ -33,10 +33,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
coordinates = point_list->as<IfcSchema::IfcCartesianPointList3D>()->CoordList();
|
||||
}
|
||||
|
||||
std::vector<taxonomy::point3> points;
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
points.reserve(coordinates.size());
|
||||
for (auto& coords : coordinates) {
|
||||
points.push_back(taxonomy::point3(
|
||||
points.push_back(taxonomy::make<taxonomy::point3>(
|
||||
coords.size() < 1 ? 0. : coords[0] * length_unit_,
|
||||
coords.size() < 2 ? 0. : coords[1] * length_unit_,
|
||||
coords.size() < 3 ? 0. : coords[2] * length_unit_));
|
||||
@@ -44,7 +44,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
|
||||
int max_index = (int) points.size();
|
||||
|
||||
auto loop = new taxonomy::loop;
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
|
||||
if(inst->Segments()) {
|
||||
aggregate_of_instance::ptr segments = *inst->Segments();
|
||||
@@ -53,14 +53,14 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
|
||||
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
|
||||
std::vector<int> indices = *line;
|
||||
taxonomy::point3 previous;
|
||||
taxonomy::point3::ptr previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
const taxonomy::point3& current = points[*jt - 1];
|
||||
auto current = points[*jt - 1];
|
||||
if (jt != indices.begin()) {
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
@@ -80,9 +80,9 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
const auto& b = points[indices[1] - 1];
|
||||
const auto& c = points[indices[2] - 1];
|
||||
|
||||
auto circ = taxonomy::circle::from_3_points(a.ccomponents(), b.ccomponents(), c.ccomponents());
|
||||
auto circ = taxonomy::circle::from_3_points(a->ccomponents(), b->ccomponents(), c->ccomponents());
|
||||
if (circ) {
|
||||
auto e = new taxonomy::edge(a, c);
|
||||
auto e = taxonomy::make<taxonomy::edge>(a, c);
|
||||
e->basis = circ;
|
||||
loop->children.push_back(e);
|
||||
} else {
|
||||
@@ -95,7 +95,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
|
||||
} else if (points.begin() < points.end()) {
|
||||
auto previous = points.begin();
|
||||
for (auto current = previous+1; current < points.end(); ++current){
|
||||
loop->children.push_back(new taxonomy::edge(*previous, *current));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(*previous, *current));
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
|
||||
const bool hasSlope = !!inst->LegSlope();
|
||||
const bool doEdgeFillet = !!inst->EdgeRadius();
|
||||
const bool doFillet = !!inst->FilletRadius();
|
||||
@@ -85,13 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
|
||||
xy = (a1*c2 - a2*c1) / det;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLine* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLine* inst) {
|
||||
// @todo test with trimmed curve on non-normalized direction
|
||||
auto l = new taxonomy::line;
|
||||
taxonomy::point3 pnt = as<taxonomy::point3>(map(inst->Pnt()));
|
||||
taxonomy::direction3 dir = as<taxonomy::direction3>(map(inst->Dir()));
|
||||
l->matrix = taxonomy::matrix4(pnt.ccomponents(), dir.ccomponents());
|
||||
auto l = taxonomy::make<taxonomy::line>();
|
||||
auto pnt = taxonomy::cast<taxonomy::point3>(map(inst->Pnt()));
|
||||
auto dir = taxonomy::cast<taxonomy::direction3>(map(inst->Dir()));
|
||||
l->matrix = taxonomy::make<taxonomy::matrix4>(pnt->ccomponents(), dir->ccomponents());
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -21,16 +21,15 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLocalPlacement* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLocalPlacement* inst) {
|
||||
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)inst;
|
||||
auto m4 = new taxonomy::matrix4;
|
||||
auto m4 = taxonomy::make<taxonomy::matrix4>();
|
||||
for (;;) {
|
||||
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
|
||||
// @todo this type check is wrong and unnecessary?
|
||||
if (relplacement->as<IfcSchema::IfcAxis2Placement3D>()) {
|
||||
taxonomy::matrix4 trsf2 = as<taxonomy::matrix4>(map(relplacement));
|
||||
// @todo check
|
||||
m4->components() = trsf2.ccomponents() * m4->ccomponents();
|
||||
m4->components() = taxonomy::cast<taxonomy::matrix4>(map(relplacement))->ccomponents() * m4->ccomponents();
|
||||
}
|
||||
if (current->PlacementRelTo()) {
|
||||
IfcSchema::IfcObjectPlacement* parent = current->PlacementRelTo();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
|
||||
IfcSchema::IfcClosedShell::list::ptr voids(new IfcSchema::IfcClosedShell::list);
|
||||
if (inst->declaration().is(IfcSchema::IfcFacetedBrepWithVoids::Class())) {
|
||||
voids = inst->as<IfcSchema::IfcFacetedBrepWithVoids>()->Voids();
|
||||
@@ -32,13 +32,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
|
||||
}
|
||||
#endif
|
||||
|
||||
taxonomy::solid* solid;
|
||||
taxonomy::solid::ptr solid;
|
||||
if (voids->size()) {
|
||||
solid = map_to_collection<taxonomy::solid>(this, voids);
|
||||
} else {
|
||||
solid = new taxonomy::solid;
|
||||
solid = taxonomy::make<taxonomy::solid>();
|
||||
}
|
||||
solid->children.insert(solid->children.begin(), map(inst->Outer()));
|
||||
solid->children.insert(solid->children.begin(), taxonomy::cast<taxonomy::shell>(map(inst->Outer())));
|
||||
|
||||
return solid;
|
||||
}
|
||||
|
||||
@@ -21,28 +21,27 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcMappedItem* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMappedItem* inst) {
|
||||
IfcSchema::IfcCartesianTransformationOperator* transform = inst->MappingTarget();
|
||||
auto qqq = (taxonomy::matrix4*)map(transform);
|
||||
taxonomy::matrix4 gtrsf = *qqq;
|
||||
taxonomy::matrix4::ptr gtrsf = taxonomy::cast<taxonomy::matrix4>(map(transform));
|
||||
IfcSchema::IfcRepresentationMap* rmap = inst->MappingSource();
|
||||
IfcSchema::IfcAxis2Placement* placement = rmap->MappingOrigin();
|
||||
taxonomy::matrix4 trsf2 = *(taxonomy::matrix4*)(map(placement));
|
||||
Eigen::Matrix4d res = gtrsf.ccomponents() * trsf2.ccomponents();
|
||||
taxonomy::matrix4::ptr trsf2 = taxonomy::cast<taxonomy::matrix4>(map(placement));
|
||||
Eigen::Matrix4d res = gtrsf->ccomponents() * trsf2->ccomponents();
|
||||
|
||||
// @todo immutable for caching?
|
||||
// @todo allow for multiple levels of matrix?
|
||||
auto shapes = map(rmap->MappedRepresentation());
|
||||
auto shapes = taxonomy::cast<taxonomy::geom_item>(map(rmap->MappedRepresentation()));
|
||||
if (shapes == nullptr) {
|
||||
return shapes;
|
||||
}
|
||||
|
||||
auto collection = new taxonomy::collection;
|
||||
auto collection = taxonomy::make<taxonomy::collection>();
|
||||
collection->children.push_back(shapes);
|
||||
collection->matrix = res;
|
||||
collection->matrix = taxonomy::make<taxonomy::matrix4>(res);
|
||||
|
||||
if (shapes != nullptr) {
|
||||
for (auto& c : ((taxonomy::collection*)shapes)->children) {
|
||||
for (auto& c : taxonomy::cast<taxonomy::collection>(shapes)->children) {
|
||||
// @todo previously style was also copied.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcOrientedEdge* inst) {
|
||||
auto e = map(inst->EdgeElement());
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOrientedEdge* inst) {
|
||||
auto e = taxonomy::cast<taxonomy::edge>(map(inst->EdgeElement()));
|
||||
if (!inst->Orientation()) {
|
||||
e->reverse();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPlane* inst) {
|
||||
auto p = new taxonomy::plane;
|
||||
p->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPlane* inst) {
|
||||
auto p = taxonomy::make<taxonomy::plane>();
|
||||
p->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points = inst->Polygon();
|
||||
|
||||
// Parse and store the points in a sequence
|
||||
std::vector<taxonomy::point3> polygon;
|
||||
std::vector<taxonomy::point3::ptr> polygon;
|
||||
polygon.reserve(points->size());
|
||||
std::transform(points->begin(), points->end(), std::back_inserter(polygon), [this](const IfcSchema::IfcCartesianPoint* p) {
|
||||
return as<taxonomy::point3>(map(p));
|
||||
return taxonomy::cast<taxonomy::point3>(map(p));
|
||||
});
|
||||
|
||||
// A loop should consist of at least three vertices
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace* inst) {
|
||||
auto s = (taxonomy::solid*)map_impl((IfcSchema::IfcHalfSpaceSolid*) inst);
|
||||
auto f = (taxonomy::face*)s->children[0];
|
||||
f->children = { map(inst->PolygonalBoundary()) };
|
||||
f->matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace* inst) {
|
||||
auto s = taxonomy::cast<taxonomy::solid>(map_impl((IfcSchema::IfcHalfSpaceSolid*) inst));
|
||||
auto f = s->children[0]->children[0];
|
||||
f->children = { taxonomy::cast<taxonomy::loop>(map(inst->PolygonalBoundary())) };
|
||||
f->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcPolygonalFaceSet
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
|
||||
IfcSchema::IfcCartesianPointList3D* point_list = inst->Coordinates();
|
||||
auto coordinates = point_list->CoordList();
|
||||
auto polygonal_faces = inst->Faces();
|
||||
|
||||
std::vector<taxonomy::point3> points;
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
points.reserve(coordinates.size());
|
||||
for (auto& coords : coordinates) {
|
||||
points.push_back(taxonomy::point3(
|
||||
points.push_back(taxonomy::make<taxonomy::point3>(
|
||||
coords.size() < 1 ? 0. : coords[0] * length_unit_,
|
||||
coords.size() < 2 ? 0. : coords[1] * length_unit_,
|
||||
coords.size() < 3 ? 0. : coords[2] * length_unit_));
|
||||
@@ -39,57 +39,59 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
|
||||
|
||||
int max_index = (int)points.size();
|
||||
|
||||
auto shell = new taxonomy::shell;
|
||||
auto shell = taxonomy::make<taxonomy::shell>();
|
||||
|
||||
for (auto& f : *polygonal_faces) {
|
||||
auto fa = new taxonomy::face;
|
||||
auto fa = taxonomy::make<taxonomy::face>();
|
||||
shell->children.push_back(fa);
|
||||
|
||||
{
|
||||
auto loop = new taxonomy::loop;
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
fa->children = { loop };
|
||||
loop->external = true;
|
||||
auto indices = f->CoordIndex();
|
||||
taxonomy::point3 previous;
|
||||
taxonomy::point3::ptr previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
const taxonomy::point3& current = points[(*jt) - 1];
|
||||
auto current = points[(*jt) - 1];
|
||||
if (jt != indices.begin()) {
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
if (!indices.empty()) {
|
||||
const taxonomy::point3& current = points[indices.front() - 1];
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
auto current = points[indices.front() - 1];
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
}
|
||||
|
||||
if (f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()) {
|
||||
auto indices = f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()->InnerCoordIndices();
|
||||
|
||||
{
|
||||
auto loop = new taxonomy::loop;
|
||||
fa->children.push_back(loop);
|
||||
loop->external = false;
|
||||
auto indices = f->CoordIndex();
|
||||
taxonomy::point3 previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
taxonomy::point3::ptr previous;
|
||||
for (auto& li : indices) {
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
fa->children.push_back(loop);
|
||||
loop->external = false;
|
||||
|
||||
for (std::vector<int>::const_iterator jt = li.begin(); jt != li.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
auto current = points[(*jt) - 1];
|
||||
if (jt != li.begin()) {
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
const taxonomy::point3& current = points[(*jt) - 1];
|
||||
if (jt != indices.begin()) {
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
if (!li.empty()) {
|
||||
auto current = points[li.front() - 1];
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
if (!indices.empty()) {
|
||||
const taxonomy::point3& current = points[indices.front() - 1];
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points = inst->Points();
|
||||
|
||||
// Parse and store the points in a sequence
|
||||
std::vector<taxonomy::point3> polygon;
|
||||
std::vector<taxonomy::point3::ptr> polygon;
|
||||
polygon.reserve(points->size());
|
||||
std::transform(points->begin(), points->end(), std::back_inserter(polygon), [this](const IfcSchema::IfcCartesianPoint* p) {
|
||||
return as<taxonomy::point3>(map(p));
|
||||
return taxonomy::cast<taxonomy::point3>(map(p));
|
||||
});
|
||||
|
||||
const bool closed_by_proximity = polygon.size() >= 3 && (*polygon.front().components_ - *polygon.back().components_).norm() < conv_settings_.getValue(ConversionSettings::GV_PRECISION);
|
||||
const bool closed_by_proximity = polygon.size() >= 3 && (*polygon.front()->components_ - *polygon.back()->components_).norm() < conv_settings_.getValue(ConversionSettings::GV_PRECISION);
|
||||
if (closed_by_proximity) {
|
||||
polygon.resize(polygon.size() - 1);
|
||||
polygon.push_back(polygon.front());
|
||||
|
||||
@@ -4,11 +4,11 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
using namespace IfcGeom;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcProduct* inst) {
|
||||
// @todo decide on this, what happens in the product mapping?
|
||||
// currently things like openings, layers and materials are processed in the converter
|
||||
auto c = new taxonomy::collection;
|
||||
c->matrix = as<taxonomy::matrix4>(map(inst->ObjectPlacement()));
|
||||
auto c = taxonomy::make<taxonomy::collection>();
|
||||
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->ObjectPlacement()));
|
||||
return c;
|
||||
|
||||
/*
|
||||
@@ -30,7 +30,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
|
||||
}
|
||||
|
||||
auto c = new taxonomy::collection;
|
||||
c->matrix = as<taxonomy::matrix4>(map(inst->ObjectPlacement()));
|
||||
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->ObjectPlacement()));
|
||||
|
||||
const auto single_material = get_single_material_association(inst);
|
||||
if (single_material) {
|
||||
@@ -53,8 +53,8 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
|
||||
operands->push(body);
|
||||
operands->push(openings);
|
||||
auto n = map_to_collection<taxonomy::boolean_result>(this, operands);
|
||||
std::for_each(n->children.begin() + 1, n->children.end(), [&ci](taxonomy::item* i) {
|
||||
((taxonomy::geom_item*)i)->matrix.components() = ci * ((taxonomy::geom_item*)i)->matrix.ccomponents();
|
||||
std::for_each(n->children.begin() + 1, n->children.end(), [&ci](taxonomy::ptr i) {
|
||||
((taxonomy::geom_ptr)i)->matrix.components() = ci * ((taxonomy::geom_ptr)i)->matrix.ccomponents();
|
||||
});
|
||||
n->operation = taxonomy::boolean_result::SUBTRACTION;
|
||||
// @todo one indirection too many
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* inst) {
|
||||
const double x = inst->XDim() / 2.0f * length_unit_;
|
||||
const double y = inst->YDim() / 2.0f * length_unit_;
|
||||
const double d = inst->WallThickness() * length_unit_;
|
||||
@@ -41,13 +41,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
auto s1 = profile_helper(m4, {
|
||||
@@ -69,7 +69,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef*
|
||||
}
|
||||
|
||||
s1->children.push_back(s2->children[0]);
|
||||
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete s2;
|
||||
#endif
|
||||
|
||||
return s1;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
|
||||
const double x = inst->XDim() / 2.0f * length_unit_;
|
||||
const double y = inst->YDim() / 2.0f * length_unit_;
|
||||
|
||||
@@ -34,13 +34,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,107 +21,107 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
|
||||
const double dx = inst->XLength() * length_unit_;
|
||||
const double dy = inst->YLength() * length_unit_;
|
||||
const double dz = inst->Height() * length_unit_;
|
||||
|
||||
auto solid = new taxonomy::solid;
|
||||
auto shell = new taxonomy::shell;
|
||||
auto solid = taxonomy::make<taxonomy::solid>();
|
||||
auto shell = taxonomy::make<taxonomy::shell>();
|
||||
solid->children.push_back(shell);
|
||||
|
||||
// Base
|
||||
{
|
||||
auto face = new taxonomy::face;
|
||||
auto loop = new taxonomy::loop;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
face->children.push_back(loop);
|
||||
loop->external = true;
|
||||
shell->children.push_back(face);
|
||||
|
||||
std::array<taxonomy::point3, 4> points{
|
||||
taxonomy::point3(0, 0, 0),
|
||||
taxonomy::point3(dx, 0, 0),
|
||||
taxonomy::point3(dx, dy, 0),
|
||||
taxonomy::point3(0, dy, 0)
|
||||
std::array<taxonomy::point3::ptr, 4> points{
|
||||
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
||||
taxonomy::make<taxonomy::point3>(0, dy, 0)
|
||||
};
|
||||
|
||||
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
|
||||
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
|
||||
loop->children.push_back(new taxonomy::edge(points[2], points[3]));
|
||||
loop->children.push_back(new taxonomy::edge(points[3], points[0]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[3]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[3], points[0]));
|
||||
}
|
||||
|
||||
// Lateral faces
|
||||
{
|
||||
auto face = new taxonomy::face;
|
||||
auto loop = new taxonomy::loop;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
face->children.push_back(loop);
|
||||
loop->external = true;
|
||||
shell->children.push_back(face);
|
||||
|
||||
std::array<taxonomy::point3, 3> points{
|
||||
taxonomy::point3(0, 0, 0),
|
||||
taxonomy::point3(0, dy, 0),
|
||||
taxonomy::point3(0.5*dx, 0.5*dy, dz)
|
||||
std::array<taxonomy::point3::ptr, 3> points{
|
||||
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(0, dy, 0),
|
||||
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
||||
};
|
||||
|
||||
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
|
||||
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
|
||||
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
|
||||
}
|
||||
|
||||
{
|
||||
auto face = new taxonomy::face;
|
||||
auto loop = new taxonomy::loop;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
face->children.push_back(loop);
|
||||
loop->external = true;
|
||||
shell->children.push_back(face);
|
||||
|
||||
std::array<taxonomy::point3, 3> points{
|
||||
taxonomy::point3(0, dy, 0),
|
||||
taxonomy::point3(dx, dy, 0),
|
||||
taxonomy::point3(0.5*dx, 0.5*dy, dz)
|
||||
std::array<taxonomy::point3::ptr, 3> points{
|
||||
taxonomy::make<taxonomy::point3>(0, dy, 0),
|
||||
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
||||
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
||||
};
|
||||
|
||||
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
|
||||
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
|
||||
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
|
||||
}
|
||||
|
||||
{
|
||||
auto face = new taxonomy::face;
|
||||
auto loop = new taxonomy::loop;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
face->children.push_back(loop);
|
||||
loop->external = true;
|
||||
shell->children.push_back(face);
|
||||
|
||||
std::array<taxonomy::point3, 3> points{
|
||||
taxonomy::point3(dx, dy, 0),
|
||||
taxonomy::point3(dx, 0, 0),
|
||||
taxonomy::point3(0.5*dx, 0.5*dy, dz)
|
||||
std::array<taxonomy::point3::ptr, 3> points{
|
||||
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
||||
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
||||
};
|
||||
|
||||
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
|
||||
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
|
||||
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
|
||||
}
|
||||
|
||||
{
|
||||
auto face = new taxonomy::face;
|
||||
auto loop = new taxonomy::loop;
|
||||
auto face = taxonomy::make<taxonomy::face>();
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
face->children.push_back(loop);
|
||||
loop->external = true;
|
||||
shell->children.push_back(face);
|
||||
|
||||
std::array<taxonomy::point3, 3> points{
|
||||
taxonomy::point3(dx, 0, 0),
|
||||
taxonomy::point3(0, 0, 0),
|
||||
taxonomy::point3(0.5*dx, 0.5*dy, dz)
|
||||
std::array<taxonomy::point3::ptr, 3> points{
|
||||
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
||||
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
||||
};
|
||||
|
||||
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
|
||||
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
|
||||
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
|
||||
}
|
||||
|
||||
return solid;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface* inst) {
|
||||
// @todo we'll need to add support for p-curves at some point, but not now.
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
|
||||
const bool use_body = !this->settings_.get(IfcGeom::IteratorSettings::INCLUDE_CURVES);
|
||||
|
||||
auto items = map_to_collection(this, inst->Items());
|
||||
@@ -41,19 +41,19 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
|
||||
// @todo
|
||||
// if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) {
|
||||
|
||||
return filter_in_place(items, [&use_body](taxonomy::item* i) {
|
||||
return filter_in_place(items, [&use_body](taxonomy::ptr i) {
|
||||
// @todo just filter loops for now.
|
||||
return (i->kind() != taxonomy::LOOP) == use_body;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = inst->Items();
|
||||
bool part_succes = false;
|
||||
if ( items->size() ) {
|
||||
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
|
||||
IfcSchema::IfcRepresentationItem* representation_item = *it;
|
||||
IfcSchema::IfcRepresentationptr representation_item = *it;
|
||||
if ( shape_type(representation_item) == ST_SHAPELIST ) {
|
||||
part_succes |= convert_shapes(*it, shapes);
|
||||
} else {
|
||||
|
||||
@@ -23,31 +23,31 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) {
|
||||
const double ang = inst->Angle() * angle_unit_;
|
||||
|
||||
as<taxonomy::face>(map(inst->SweptArea()));
|
||||
taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
|
||||
|
||||
boost::optional<double> angle;
|
||||
|
||||
taxonomy::matrix4 matrix;
|
||||
taxonomy::matrix4::ptr matrix;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
|
||||
has_position = inst->Position() != nullptr;
|
||||
#endif
|
||||
if (has_position) {
|
||||
matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
if (ang < boost::math::constants::pi<double>() * 2. - 1.e-5) {
|
||||
angle = ang;
|
||||
}
|
||||
|
||||
return new taxonomy::revolve(
|
||||
return taxonomy::make<taxonomy::revolve>(
|
||||
matrix,
|
||||
as<taxonomy::face>(map(inst->SweptArea())),
|
||||
as<taxonomy::point3>(map(inst->Axis()->Location())),
|
||||
as<taxonomy::direction3>(map(inst->Axis()->Axis())),
|
||||
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
|
||||
taxonomy::cast<taxonomy::point3>(map(inst->Axis()->Location())),
|
||||
taxonomy::cast<taxonomy::direction3>(map(inst->Axis()->Axis())),
|
||||
angle
|
||||
);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRightCircularCone* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone* inst) {
|
||||
// @todo
|
||||
return nullptr;
|
||||
/*
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRightCircularCylinder* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder* inst) {
|
||||
// @todo
|
||||
return nullptr;
|
||||
/*
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef* inst) {
|
||||
const double x = inst->XDim() / 2.0f * length_unit_;
|
||||
const double y = inst->YDim() / 2.0f * length_unit_;
|
||||
const double r = inst->RoundingRadius() * length_unit_;
|
||||
@@ -35,13 +35,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcShellBasedSurfaceModel* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcShellBasedSurfaceModel* inst) {
|
||||
return map_to_collection(this, inst->SbsmBoundary());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSphere* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphere* inst) {
|
||||
// @todo
|
||||
return nullptr;
|
||||
/*
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcSphericalSurface
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSphericalSurface* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphericalSurface* inst) {
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
/*
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSubedge* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSubedge* inst) {
|
||||
// @todo
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcSurfaceCurve
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceCurve* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurve* inst) {
|
||||
// @todo take into account PCurves.
|
||||
return map(inst->Curve3D());
|
||||
}
|
||||
|
||||
@@ -21,19 +21,19 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* inst) {
|
||||
taxonomy::face f = as<taxonomy::face>(map(inst->SweptArea()));
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* inst) {
|
||||
taxonomy::face::ptr f = taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
|
||||
|
||||
taxonomy::matrix4 matrix;
|
||||
taxonomy::matrix4::ptr matrix;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
|
||||
has_position = inst->Position() != nullptr;
|
||||
#endif
|
||||
if (has_position) {
|
||||
matrix = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
auto scs = new taxonomy::surface_curve_sweep(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
|
||||
auto scs = taxonomy::make<taxonomy::surface_curve_sweep>(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
|
||||
scs->matrix = matrix;
|
||||
|
||||
return scs;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion* inst) {
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) {
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace {
|
||||
}
|
||||
*/
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
|
||||
auto loop = map(inst->Directrix());
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
|
||||
auto loop = taxonomy::cast<taxonomy::loop>(map(inst->Directrix()));
|
||||
|
||||
// Start- EndParam became optional in IFC4
|
||||
#ifdef SCHEMA_IfcSweptDiskSolid_StartParam_IS_OPTIONAL
|
||||
@@ -68,7 +68,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
|
||||
if (inst->as<IfcSchema::IfcSweptDiskSolidPolygonal>()) {
|
||||
auto fr = inst->as<IfcSchema::IfcSweptDiskSolidPolygonal>()->FilletRadius();
|
||||
if (fr && *fr > tol) {
|
||||
fillet_loop((taxonomy::loop*)loop, *fr);
|
||||
fillet_loop(loop, *fr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -80,30 +80,30 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
|
||||
radii.push_back(*inst->InnerRadius() * length_unit_);
|
||||
}
|
||||
|
||||
taxonomy::face f;
|
||||
auto f = taxonomy::make<taxonomy::face>();
|
||||
|
||||
{
|
||||
for (auto it = radii.begin(); it != radii.end(); ++it) {
|
||||
const double r = *it;
|
||||
const bool exterior = it == radii.begin();
|
||||
|
||||
auto c = new taxonomy::circle;
|
||||
auto c = taxonomy::make<taxonomy::circle>();
|
||||
c->radius = r;
|
||||
|
||||
auto e = new taxonomy::edge;
|
||||
auto e = taxonomy::make<taxonomy::edge>();
|
||||
e->basis = c;
|
||||
e->start = 0.;
|
||||
e->end = 2 * boost::math::constants::pi<double>();
|
||||
|
||||
auto l = new taxonomy::loop;
|
||||
auto l = taxonomy::make<taxonomy::loop>();
|
||||
l->children = { e };
|
||||
l->external = exterior;
|
||||
|
||||
f.children.push_back(l);
|
||||
f->children.push_back(l);
|
||||
}
|
||||
}
|
||||
|
||||
return new taxonomy::surface_curve_sweep(taxonomy::matrix4(), f, nullptr, loop);
|
||||
return taxonomy::make<taxonomy::surface_curve_sweep>(taxonomy::make<taxonomy::matrix4>(), f, nullptr, loop);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
|
||||
const bool doFlangeEdgeFillet = !!inst->FlangeEdgeRadius();
|
||||
const bool doWebEdgeFillet = !!inst->WebEdgeRadius();
|
||||
const bool doFillet = !!inst->FilletRadius();
|
||||
@@ -99,13 +99,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
|
||||
xy = y - d2;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcToroidalSurface
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcToroidalSurface* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcToroidalSurface* inst) {
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst) {
|
||||
const double x1 = inst->BottomXDim() / 2. * length_unit_;
|
||||
const double w = inst->TopXDim() * length_unit_;
|
||||
const double dx = inst->TopXOffset() * length_unit_;
|
||||
@@ -40,13 +40,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -23,15 +23,15 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet* inst) {
|
||||
IfcSchema::IfcCartesianPointList3D* point_list = inst->Coordinates();
|
||||
auto coordinates = point_list->CoordList();
|
||||
std::vector<std::vector<int>> indices_list = inst->CoordIndex();
|
||||
|
||||
std::vector<taxonomy::point3> points;
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
points.reserve(coordinates.size());
|
||||
for (auto& coords : coordinates) {
|
||||
points.push_back(taxonomy::point3(
|
||||
points.push_back(taxonomy::make<taxonomy::point3>(
|
||||
coords.size() < 1 ? 0. : coords[0] * length_unit_,
|
||||
coords.size() < 2 ? 0. : coords[1] * length_unit_,
|
||||
coords.size() < 3 ? 0. : coords[2] * length_unit_));
|
||||
@@ -39,24 +39,24 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet* inst)
|
||||
|
||||
int max_index = (int)points.size();
|
||||
|
||||
auto shell = new taxonomy::shell;
|
||||
auto shell = taxonomy::make<taxonomy::shell>();
|
||||
|
||||
for (auto& indices : indices_list) {
|
||||
auto fa = new taxonomy::face;
|
||||
auto fa = taxonomy::make<taxonomy::face>();
|
||||
shell->children.push_back(fa);
|
||||
|
||||
{
|
||||
auto loop = new taxonomy::loop;
|
||||
auto loop = taxonomy::make<taxonomy::loop>();
|
||||
fa->children = { loop };
|
||||
loop->external = true;
|
||||
taxonomy::point3 previous;
|
||||
taxonomy::point3::ptr previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw IfcParse::IfcException("IfcTriangulatedFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
const taxonomy::point3& current = points[(*jt) - 1];
|
||||
const taxonomy::point3::ptr& current = points[(*jt) - 1];
|
||||
if (jt != indices.begin()) {
|
||||
loop->children.push_back(new taxonomy::edge(previous, current));
|
||||
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
static const double pi = boost::math::constants::pi<double>();
|
||||
|
||||
IfcSchema::IfcCurve* basis_curve = inst->BasisCurve();
|
||||
bool isConic = basis_curve->declaration().is(IfcSchema::IfcConic::Class());
|
||||
double parameterFactor = isConic ? angle_unit_ : length_unit_;
|
||||
|
||||
auto tc = new taxonomy::edge;
|
||||
auto tc = taxonomy::make<taxonomy::edge>();
|
||||
tc->basis = map(inst->BasisCurve());
|
||||
|
||||
bool trim_cartesian = inst->MasterRepresentation() != IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER;
|
||||
@@ -40,7 +40,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
// reversed orientation handling happens in geometry kernel
|
||||
unsigned sense_agreement = 0;
|
||||
double flts[2];
|
||||
taxonomy::point3 pnts[2];
|
||||
taxonomy::point3::ptr pnts[2];
|
||||
bool has_flts[2] = {false,false};
|
||||
bool has_pnts[2] = {false,false};
|
||||
|
||||
@@ -49,7 +49,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
for ( aggregate_of_instance::it it = trims1->begin(); it != trims1->end(); it ++ ) {
|
||||
IfcUtil::IfcBaseClass* i = *it;
|
||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
||||
pnts[sense_agreement] = as<taxonomy::point3>(map(i));
|
||||
pnts[sense_agreement] = taxonomy::cast<taxonomy::point3>(map(i));
|
||||
has_pnts[sense_agreement] = true;
|
||||
} else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) {
|
||||
const double value = *((IfcSchema::IfcParameterValue*)i);
|
||||
@@ -61,7 +61,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
for ( aggregate_of_instance::it it = trims2->begin(); it != trims2->end(); it ++ ) {
|
||||
IfcUtil::IfcBaseClass* i = *it;
|
||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
||||
pnts[1 - sense_agreement] = as<taxonomy::point3>(map(i));
|
||||
pnts[1 - sense_agreement] = taxonomy::cast<taxonomy::point3>(map(i));
|
||||
has_pnts[1-sense_agreement] = true;
|
||||
} else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) {
|
||||
const double value = *((IfcSchema::IfcParameterValue*)i);
|
||||
@@ -75,7 +75,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
trim_cartesian &= has_pnts[0] && has_pnts[1];
|
||||
bool trim_cartesian_failed = !trim_cartesian;
|
||||
if (trim_cartesian) {
|
||||
if ((pnts[0].ccomponents() - pnts[1].ccomponents()).norm() < (2 * tol)) {
|
||||
if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) {
|
||||
Logger::Message(Logger::LOG_WARNING, "Skipping segment with length below tolerance level:", inst);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -104,12 +104,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
|
||||
}
|
||||
|
||||
double radius = 1.0;
|
||||
if (tc->basis->kind() == taxonomy::CIRCLE) {
|
||||
auto typed_curve = (taxonomy::circle*) tc->basis;
|
||||
radius = typed_curve->radius;
|
||||
} else if (tc->basis->kind() == taxonomy::ELLIPSE) {
|
||||
auto typed_curve = (taxonomy::ellipse*) tc->basis;
|
||||
radius = (typed_curve->radius + typed_curve->radius2) / 2.;
|
||||
if (auto typed_circle = taxonomy::dcast<taxonomy::circle>(tc->basis)) {
|
||||
radius = typed_circle->radius;
|
||||
} else if (auto typed_ellipse = taxonomy::dcast<taxonomy::ellipse>(tc->basis)) {
|
||||
radius = (typed_ellipse->radius + typed_ellipse->radius2) / 2.;
|
||||
}
|
||||
|
||||
// Fix from @sanderboer to compare using model tolerance, see #744
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) {
|
||||
const bool doEdgeFillet = !!inst->EdgeRadius();
|
||||
const bool doFillet = !!inst->FilletRadius();
|
||||
const bool hasSlope = !!inst->FlangeSlope();
|
||||
@@ -58,13 +58,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcVector* inst) {
|
||||
auto d = (taxonomy::direction3*) map(inst->Orientation());
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcVector* inst) {
|
||||
auto d = taxonomy::cast<taxonomy::direction3>(map(inst->Orientation()));
|
||||
d->components() *= inst->Magnitude() * length_unit_;
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
|
||||
|
||||
#include "../profile_helper.h"
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) {
|
||||
const double x = inst->FlangeWidth() * length_unit_;
|
||||
const double y = inst->Depth() / 2.0f * length_unit_;
|
||||
const double dx = inst->WebThickness() / 2.0f * length_unit_;
|
||||
@@ -49,13 +49,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
taxonomy::matrix4 m4;
|
||||
taxonomy::matrix4::ptr m4;
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
||||
has_position = !!inst->Position();
|
||||
#endif
|
||||
if (has_position) {
|
||||
m4 = as<taxonomy::matrix4>(map(inst->Position()));
|
||||
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
||||
}
|
||||
|
||||
return profile_helper(m4, {
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
#undef BIND
|
||||
#endif
|
||||
|
||||
#define BIND(T) ifcopenshell::geometry::taxonomy::item* map_impl(const IfcSchema::T*);
|
||||
#define BIND(T) ifcopenshell::geometry::taxonomy::ptr map_impl(const IfcSchema::T*);
|
||||
|
||||
#include "mapping.i"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define BIND(T) \
|
||||
if (inst->as<IfcSchema::T>()) { \
|
||||
try { \
|
||||
taxonomy::item* item = map_impl(inst->as<IfcSchema::T>()); \
|
||||
taxonomy::ptr item = map_impl(inst->as<IfcSchema::T>()); \
|
||||
if (item != nullptr) { \
|
||||
item->instance = inst; \
|
||||
try { \
|
||||
@@ -15,7 +15,7 @@
|
||||
) { \
|
||||
auto style = find_style(inst->as<IfcSchema::IfcRepresentationItem>()); \
|
||||
if (style) { \
|
||||
((taxonomy::geom_item*)item)->surface_style = (taxonomy::style*) map(style); \
|
||||
taxonomy::cast<taxonomy::geom_item>(item)->surface_style = taxonomy::cast<taxonomy::style>(map(style)); \
|
||||
} \
|
||||
} \
|
||||
} catch (const std::exception& e) { \
|
||||
|
||||
@@ -69,15 +69,15 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem
|
||||
IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap();
|
||||
if (maps->size() == 1) {
|
||||
IfcSchema::IfcRepresentationMap* rmap = *maps->begin();
|
||||
taxonomy::matrix4 origin = as<taxonomy::matrix4>(map(rmap->MappingOrigin()));
|
||||
if (origin.is_identity()) {
|
||||
taxonomy::matrix4::ptr origin = taxonomy::cast<taxonomy::matrix4>(map(rmap->MappingOrigin()));
|
||||
if (origin->is_identity()) {
|
||||
IfcSchema::IfcMappedItem::list::ptr items = rmap->MapUsage();
|
||||
for (IfcSchema::IfcMappedItem::list::it it = items->begin(); it != items->end(); ++it) {
|
||||
IfcSchema::IfcMappedItem* item = *it;
|
||||
if (item->StyledByItem()->size() != 0) continue;
|
||||
|
||||
taxonomy::matrix4 target = as<taxonomy::matrix4>(map(item->MappingTarget()));
|
||||
if (!target.is_identity()) {
|
||||
taxonomy::matrix4::ptr target = taxonomy::cast<taxonomy::matrix4>(map(item->MappingTarget()));
|
||||
if (!target->is_identity()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -278,11 +278,11 @@ IfcSchema::IfcRepresentation* mapping::representation_mapped_to(const IfcSchema:
|
||||
if (item->declaration().is(IfcSchema::IfcMappedItem::Class())) {
|
||||
if (item->StyledByItem()->size() == 0) {
|
||||
IfcSchema::IfcMappedItem* mapped_item = item->as<IfcSchema::IfcMappedItem>();
|
||||
taxonomy::matrix4 target = as<taxonomy::matrix4>(map(mapped_item->MappingTarget()));
|
||||
if (target.is_identity()) {
|
||||
taxonomy::matrix4::ptr target = taxonomy::cast<taxonomy::matrix4>(map(mapped_item->MappingTarget()));
|
||||
if (target->is_identity()) {
|
||||
IfcSchema::IfcRepresentationMap* rmap = mapped_item->MappingSource();
|
||||
taxonomy::matrix4 origin = as<taxonomy::matrix4>(map(rmap->MappingOrigin()));
|
||||
if (origin.is_identity()) {
|
||||
taxonomy::matrix4::ptr origin = taxonomy::cast<taxonomy::matrix4>(map(rmap->MappingOrigin()));
|
||||
if (origin->is_identity()) {
|
||||
representation_mapped_to = rmap->MappedRepresentation();
|
||||
}
|
||||
}
|
||||
@@ -406,7 +406,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcMaterial* material) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
|
||||
IfcSchema::IfcMaterialDefinitionRepresentation::list::ptr defs = material->HasRepresentation();
|
||||
for (IfcSchema::IfcMaterialDefinitionRepresentation::list::it jt = defs->begin(); jt != defs->end(); ++jt) {
|
||||
IfcSchema::IfcRepresentation::list::ptr reps = (*jt)->Representations();
|
||||
@@ -419,7 +419,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcMaterial* material) {
|
||||
}
|
||||
}
|
||||
|
||||
taxonomy::style* material_style = new taxonomy::style;
|
||||
taxonomy::style::ptr material_style = taxonomy::make<taxonomy::style>();
|
||||
return material_style;
|
||||
|
||||
// @todo
|
||||
@@ -427,7 +427,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcMaterial* material) {
|
||||
// return &(style_cache[material->data().id()] = material_style);
|
||||
}
|
||||
|
||||
taxonomy::item* mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
||||
auto style_pair = get_surface_style<IfcSchema::IfcSurfaceStyleShading>(inst);
|
||||
|
||||
IfcSchema::IfcSurfaceStyle* style = style_pair.first;
|
||||
@@ -439,7 +439,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
||||
|
||||
static taxonomy::colour white = taxonomy::colour(1., 1., 1.);
|
||||
|
||||
taxonomy::style* surface_style = new taxonomy::style;
|
||||
taxonomy::style::ptr surface_style = taxonomy::make<taxonomy::style>();
|
||||
|
||||
surface_style->instance = style;
|
||||
if (style->Name()) {
|
||||
@@ -489,7 +489,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
||||
}
|
||||
|
||||
|
||||
taxonomy::item* mapping::map(const IfcBaseInterface* inst) {
|
||||
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
||||
// std::wcout << inst->data().toString().c_str() << std::endl;
|
||||
#include "bind_convert_impl.i"
|
||||
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", inst);
|
||||
@@ -745,29 +745,33 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* curve = map(axis_representation);
|
||||
auto* product_node = map(product);
|
||||
auto curve = map(axis_representation);
|
||||
auto product_node = taxonomy::cast<taxonomy::geom_item>(map(product));
|
||||
|
||||
auto& m4 = ((taxonomy::geom_item*) product_node)->matrix;
|
||||
auto c2 = flatten((taxonomy::collection*)curve);
|
||||
auto& m4 = product_node->matrix;
|
||||
auto c2 = flatten(taxonomy::cast<taxonomy::collection>(curve));
|
||||
if (c2->children.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete curve;
|
||||
delete product_node;
|
||||
#endif
|
||||
|
||||
auto c = c2->children[0];
|
||||
|
||||
auto ofc = new taxonomy::offset_curve;
|
||||
auto Z = taxonomy::make<taxonomy::direction3>(0, 0, 1);;
|
||||
|
||||
auto ofc = taxonomy::make<taxonomy::offset_curve>();
|
||||
ofc->offset = -offset;
|
||||
ofc->reference = taxonomy::direction3(0, 0, 1);
|
||||
ofc->basis = c2->children[0]->clone();
|
||||
ofc->reference = Z;
|
||||
ofc->basis = c2->children[0];
|
||||
ofc->matrix = m4;
|
||||
info.layers.push_back(ofc);
|
||||
|
||||
for (IfcSchema::IfcMaterialLayer::list::it it = material_layers->begin(); it != material_layers->end(); ++it) {
|
||||
info.styles.push_back(as<taxonomy::style>(map((*it)->Material())));
|
||||
info.styles.push_back(*taxonomy::cast<taxonomy::style>(map((*it)->Material())));
|
||||
|
||||
double thickness = (*it)->LayerThickness() * this->length_unit_;
|
||||
|
||||
@@ -780,20 +784,22 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
|
||||
offset += thickness;
|
||||
|
||||
if (fabs(offset) < 1.e-7) {
|
||||
auto ofc = c->clone();
|
||||
((taxonomy::geom_item*)ofc)->matrix = m4;
|
||||
auto ofc = c;
|
||||
c->matrix = m4;
|
||||
info.layers.push_back(ofc);
|
||||
} else {
|
||||
auto ofc = new taxonomy::offset_curve;
|
||||
auto ofc = taxonomy::make<taxonomy::offset_curve>();
|
||||
ofc->offset = -offset;
|
||||
ofc->reference = taxonomy::direction3(0, 0, 1);
|
||||
ofc->basis = c2->children[0]->clone();
|
||||
ofc->reference = Z;
|
||||
ofc->basis = c2;
|
||||
ofc->matrix = m4;
|
||||
info.layers.push_back(ofc);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete c2;
|
||||
#endif
|
||||
|
||||
if (positive) {
|
||||
std::reverse(info.thicknesses.begin(), info.thicknesses.end());
|
||||
@@ -810,23 +816,23 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
|
||||
|
||||
IfcSchema::IfcExtrudedAreaSolid* extrusion = *extrusions->begin();
|
||||
|
||||
taxonomy::matrix4 extrusion_position;
|
||||
taxonomy::matrix4::ptr extrusion_position;
|
||||
|
||||
bool has_position = true;
|
||||
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
|
||||
has_position = extrusion->Position() != nullptr;
|
||||
#endif
|
||||
if (has_position) {
|
||||
auto m4 = (taxonomy::matrix4*) map(extrusion->Position());
|
||||
auto m4 = taxonomy::cast<taxonomy::matrix4>(map(extrusion->Position()));
|
||||
if (!m4) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Failed to convert placement for extrusion of:", product);
|
||||
return false;
|
||||
} else {
|
||||
extrusion_position = *m4;
|
||||
extrusion_position = m4;
|
||||
}
|
||||
}
|
||||
|
||||
taxonomy::direction3* extrusion_direction = (taxonomy::direction3*) map(extrusion->ExtrudedDirection());
|
||||
taxonomy::direction3::ptr extrusion_direction = taxonomy::cast<taxonomy::direction3>(map(extrusion->ExtrudedDirection()));
|
||||
|
||||
if (!extrusion_direction) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Failed to convert direction for extrusion of:", product);
|
||||
@@ -837,14 +843,14 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
|
||||
// reference_surface = new Geom_Plane(extrusion_position.TranslationPart(), extrusion_direction);
|
||||
|
||||
{
|
||||
auto pln = new taxonomy::plane;
|
||||
auto pln = taxonomy::make<taxonomy::plane>();
|
||||
pln->matrix = extrusion_position;
|
||||
|
||||
info.layers.push_back(pln);
|
||||
}
|
||||
|
||||
for (IfcSchema::IfcMaterialLayer::list::it it = material_layers->begin(); it != material_layers->end(); ++it) {
|
||||
info.styles.push_back(as<taxonomy::style>(map((*it)->Material())));
|
||||
info.styles.push_back(*taxonomy::cast<taxonomy::style>(map((*it)->Material())));
|
||||
|
||||
double thickness = (*it)->LayerThickness() * this->length_unit_;
|
||||
|
||||
@@ -856,12 +862,12 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
|
||||
|
||||
offset += thickness;
|
||||
|
||||
taxonomy::matrix4 offset_matrix;
|
||||
offset_matrix.components()(2, 3) = offset;
|
||||
offset_matrix.components()(3, 3) = 1.;
|
||||
offset_matrix.components() *= extrusion_position.components();
|
||||
auto offset_matrix = taxonomy::make<taxonomy::matrix4>();
|
||||
offset_matrix->components()(2, 3) = offset;
|
||||
offset_matrix->components()(3, 3) = 1.;
|
||||
offset_matrix->components() *= extrusion_position->components();
|
||||
|
||||
auto pln = new taxonomy::plane;
|
||||
auto pln = taxonomy::make<taxonomy::plane>();
|
||||
pln->matrix = offset_matrix;
|
||||
|
||||
info.layers.push_back(pln);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace geometry {
|
||||
initialize_units_();
|
||||
apply_settings();
|
||||
}
|
||||
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseInterface*);
|
||||
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*);
|
||||
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters);
|
||||
virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
|
||||
virtual void initialize_settings();
|
||||
@@ -56,103 +56,45 @@ namespace geometry {
|
||||
#include "bind_convert_decl.i"
|
||||
};
|
||||
|
||||
|
||||
// Hacks around not wanting to use if constexpr
|
||||
template <typename T>
|
||||
class loop_to_face_upgrade {
|
||||
public:
|
||||
loop_to_face_upgrade(taxonomy::item*) {}
|
||||
|
||||
operator bool() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
operator taxonomy::face() const {
|
||||
throw taxonomy::topology_error();
|
||||
}
|
||||
|
||||
operator T() const {
|
||||
throw taxonomy::topology_error();
|
||||
}
|
||||
template <typename U>
|
||||
struct element_type {
|
||||
typedef taxonomy::item type;
|
||||
};
|
||||
|
||||
template <>
|
||||
class loop_to_face_upgrade<taxonomy::face> {
|
||||
private:
|
||||
boost::optional<taxonomy::face> face_;
|
||||
public:
|
||||
loop_to_face_upgrade(taxonomy::item* item) {
|
||||
taxonomy::loop* loop = dynamic_cast<taxonomy::loop*>(item);
|
||||
if (loop) {
|
||||
loop->external = true;
|
||||
|
||||
face_.emplace();
|
||||
face_->instance = loop->instance;
|
||||
face_->matrix = loop->matrix;
|
||||
face_->children = { loop->clone() };
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return face_.is_initialized();
|
||||
}
|
||||
|
||||
operator taxonomy::face() const {
|
||||
return *face_;
|
||||
}
|
||||
struct element_type<taxonomy::boolean_result> {
|
||||
typedef taxonomy::geom_item type;
|
||||
};
|
||||
|
||||
// A RAII-based mechanism to cast the conversion results
|
||||
// from map() into the right type expected by the higher
|
||||
// level typology items. An exception is thrown if the
|
||||
// types do not match or the result was nullptr. A copy
|
||||
// will be assigned to the higher level topology member
|
||||
// and the original pointer will be deleted.
|
||||
|
||||
// This class is also able to uplift some topology items
|
||||
// to higher level types, such as a loop to a face, which
|
||||
// is why the cast operator does not return a reference.
|
||||
template <typename T>
|
||||
class as {
|
||||
private:
|
||||
taxonomy::item* item_;
|
||||
|
||||
public:
|
||||
as(taxonomy::item* item) : item_(item) {}
|
||||
operator T() const {
|
||||
if (!item_) {
|
||||
throw taxonomy::topology_error("item was nullptr");
|
||||
}
|
||||
T* t = dynamic_cast<T*>(item_);
|
||||
if (t) {
|
||||
return T(*t);
|
||||
} else {
|
||||
{
|
||||
loop_to_face_upgrade<T> upgrade(item_);
|
||||
if (upgrade) {
|
||||
return upgrade;
|
||||
}
|
||||
}
|
||||
throw taxonomy::topology_error("item does not match type");
|
||||
}
|
||||
}
|
||||
~as() {
|
||||
delete item_;
|
||||
}
|
||||
template <>
|
||||
struct element_type<taxonomy::collection> {
|
||||
typedef taxonomy::geom_item type;
|
||||
};
|
||||
template <>
|
||||
struct element_type<taxonomy::shell> {
|
||||
typedef taxonomy::face type;
|
||||
};
|
||||
template <>
|
||||
struct element_type<taxonomy::loop> {
|
||||
typedef taxonomy::edge type;
|
||||
};
|
||||
template <>
|
||||
struct element_type<taxonomy::solid> {
|
||||
typedef taxonomy::shell type;
|
||||
};
|
||||
|
||||
template <typename U = taxonomy::collection, typename T>
|
||||
U* map_to_collection(POSTFIX_SCHEMA(mapping)* m, const T& ts) {
|
||||
auto c = new U;
|
||||
typename U::ptr map_to_collection(POSTFIX_SCHEMA(mapping)* m, const T& ts) {
|
||||
auto c = taxonomy::make<U>();
|
||||
if (ts->size()) {
|
||||
for (auto it = ts->begin(); it != ts->end(); ++it) {
|
||||
if (auto r = m->map(*it)) {
|
||||
c->children.push_back(r);
|
||||
c->children.push_back(taxonomy::cast<typename element_type<U>::type>(r));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c->children.empty()) {
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete c;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return c;
|
||||
|
||||
Reference in New Issue
Block a user