Work towards v1.0 data model with encapsulated weak_ptr as basis for instances

This commit is contained in:
Thomas Krijnen
2026-01-04 10:40:02 +01:00
parent f09ca658f1
commit 7098beb819
210 changed files with 28269 additions and 26471 deletions
+17 -17
View File
@@ -21,38 +21,38 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve& inst) {
auto loop = taxonomy::make<taxonomy::loop>();
taxonomy::piecewise_function::spans_t spans;
#ifdef SCHEMA_HAS_IfcSegment
// 4x3
IfcSchema::IfcSegment::list::ptr segments = inst->Segments();
std::vector<IfcSchema::IfcSegment> segments = inst.Segments();
#else
IfcSchema::IfcCompositeCurveSegment::list::ptr segments = inst->Segments();
std::vector<IfcSchema::IfcCompositeCurveSegment> segments = inst.Segments();
#endif
for (auto& segment : *segments) {
if (segment->as<IfcSchema::IfcCompositeCurveSegment>() && segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()) {
for (auto& segment : segments) {
if (segment.as<IfcSchema::IfcCompositeCurveSegment>() && segment.as<IfcSchema::IfcCompositeCurveSegment>().ParentCurve().as<IfcSchema::IfcLine>()) {
Logger::Notice("Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment);
double u0 = 0.0;
double u1 = segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()->Dir()->Magnitude() * length_unit_;
double u1 = segment.as<IfcSchema::IfcCompositeCurveSegment>().ParentCurve().as<IfcSchema::IfcLine>().Dir().Magnitude() * length_unit_;
if (u1 < settings_.get<settings::Precision>().get()) {
Logger::Warning("Segment length below tolerance", segment);
}
auto e = taxonomy::make<taxonomy::edge>();
e->basis = map(segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve());
e->basis = map(segment.as<IfcSchema::IfcCompositeCurveSegment>().ParentCurve());
e->start = u0;
e->end = u1;
e->curve_sense.reset(segment->as<IfcSchema::IfcCompositeCurveSegment>()->SameSense());
e->curve_sense.emplace(segment.as<IfcSchema::IfcCompositeCurveSegment>().SameSense());
loop->children.push_back(e);
}
else if (segment->as<IfcSchema::IfcCompositeCurveSegment>()) {
auto crv = map(segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve());
else if (segment.as<IfcSchema::IfcCompositeCurveSegment>()) {
auto crv = map(segment.as<IfcSchema::IfcCompositeCurveSegment>().ParentCurve());
if (crv) {
if (!segment->as<IfcSchema::IfcCompositeCurveSegment>()->SameSense()) {
if (!segment.as<IfcSchema::IfcCompositeCurveSegment>().SameSense()) {
crv->reverse();
}
if (crv->kind() == taxonomy::EDGE) {
@@ -62,7 +62,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
for (auto& s : taxonomy::cast<taxonomy::loop>(crv)->children) {
loop->children.push_back(s);
}
} else if ((crv->kind() == taxonomy::CIRCLE || crv->kind() == taxonomy::ELLIPSE) && segments->size() == 1) {
} else if ((crv->kind() == taxonomy::CIRCLE || crv->kind() == taxonomy::ELLIPSE) && segments.size() == 1) {
// A circle or ellipse segment is a full circle/ellipse, only possible when it is the only segment
std::shared_ptr<taxonomy::edge> e = std::make_shared<taxonomy::edge>();
e->basis = crv;
@@ -76,9 +76,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
}
}
#ifdef SCHEMA_HAS_IfcCurveSegment
else if (segment->as<IfcSchema::IfcCurveSegment>()) {
else if (segment.as<IfcSchema::IfcCurveSegment>()) {
// @todo check that we don't get a mixture of implicit and explicit definitions
auto crv = map(segment->as<IfcSchema::IfcCurveSegment>());
auto crv = map(segment.as<IfcSchema::IfcCurveSegment>());
if (crv && crv->kind() == taxonomy::LOOP) {
for (auto& s : taxonomy::cast<taxonomy::loop>(crv)->children) {
loop->children.push_back(s);
@@ -95,8 +95,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
}
if (spans.empty()) {
aggregate_of_instance::ptr profile = inst->file_->getInverse(inst->id(), &IfcSchema::IfcProfileDef::Class(), -1);
const bool force_close = profile && profile->size() > 0;
std::vector<express::Entity> profile = inst.data()->file()->getInverse(inst.id(), &IfcSchema::IfcProfileDef::Class(), -1);
const bool force_close = !profile.empty();
loop->closed = force_close;
loop->instance = inst;
return loop;
@@ -182,7 +182,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi
TopTools_ListIteratorOfListOfShape it(converted_segments);
aggregate_of_instance::ptr profile = inst->data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
std::vector<express::Base> profile = inst.data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
const bool force_close = profile && profile->size() > 0;
util::wire_builder bld(getValue(GV_PRECISION), l);