From 5b0511379bbf6db41cbafe8de20aef9dac46e01a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 27 Feb 2026 11:06:45 +0100 Subject: [PATCH] IfcAxis1Placement.Axis is optional #7728 --- src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp | 11 ++++++++++- src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp | 10 +++++++++- src/ifcgeom/mapping/IfcToroidalSurface.cpp | 15 +++++---------- src/ifcgeom/mapping/mapping.cpp | 4 ++++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp index 8b2fe01272..f6a9fc861c 100644 --- a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp @@ -43,11 +43,20 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) { angle = ang; } + taxonomy::direction3::ptr axis; + if (inst->Axis()->Axis()) { + axis = taxonomy::cast(map(inst->Axis()->Axis())); + } else { + // IfcAxis1Placement.Axis is optional, and defaults to (0, 0, 1) if not provided. + axis = taxonomy::make(0, 0, 1); + } + + return taxonomy::make( matrix, taxonomy::cast(map(inst->SweptArea())), taxonomy::cast(map(inst->Axis()->Location())), - taxonomy::cast(map(inst->Axis()->Axis())), + axis, angle ); diff --git a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp index f83c4ecf03..c5fe21b58b 100644 --- a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp @@ -31,11 +31,19 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) { matrix = taxonomy::cast(map(inst->Position())); } + taxonomy::direction3::ptr axis; + if (inst->AxisPosition()->Axis()) { + axis = taxonomy::cast(map(inst->AxisPosition()->Axis())); + } else { + // IfcAxis1Placement.Axis is optional, and defaults to (0, 0, 1) if not provided. + axis = taxonomy::make(0, 0, 1); + } + return taxonomy::make( matrix, taxonomy::cast(map(inst->SweptCurve())), taxonomy::cast(map(inst->AxisPosition()->Location())), - taxonomy::cast(map(inst->AxisPosition()->Axis())), + axis, boost::none ); } diff --git a/src/ifcgeom/mapping/IfcToroidalSurface.cpp b/src/ifcgeom/mapping/IfcToroidalSurface.cpp index ce17a37dbc..d73e90bb1b 100644 --- a/src/ifcgeom/mapping/IfcToroidalSurface.cpp +++ b/src/ifcgeom/mapping/IfcToroidalSurface.cpp @@ -24,16 +24,11 @@ using namespace ifcopenshell::geometry; #ifdef SCHEMA_HAS_IfcToroidalSurface taxonomy::ptr mapping::map_impl(const IfcSchema::IfcToroidalSurface* inst) { - return nullptr; - - /* - gp_Trsf trsf; - IfcGeom::Kernel::convert(inst->Position(), trsf); - - // IfcElementarySurface.Position has unit scale factor - face = BRepBuilderAPI_MakeFace(new Geom_ToroidalSurface(gp::XOY(), inst->MajorRadius() * length_unit_, inst->MinorRadius() * length_unit_), getValue(GV_PRECISION)).Face().Moved(trsf); - return true; - */ + auto c = taxonomy::make(); + c->radius1 = inst->MajorRadius() * length_unit_; + c->radius2 = inst->MinorRadius() * length_unit_; + c->matrix = taxonomy::cast(map(inst->Position())); + return c; } #endif diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index f98bfe232d..edfdd3a13b 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -691,6 +691,10 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle* style) { } taxonomy::ptr mapping::map(const IfcBaseInterface* inst) { + if (inst == nullptr) { + Logger::Error("Warning nullptr passed to map() function"); + return nullptr; + } auto iden = inst->as()->identity(); if (use_caching_) { std::lock_guard guard(cache_guard_);