diff --git a/src/ifcgeom/IfcGeomHelpers.cpp b/src/ifcgeom/IfcGeomHelpers.cpp index 0b6df4d931..24c95ebbdf 100644 --- a/src/ifcgeom/IfcGeomHelpers.cpp +++ b/src/ifcgeom/IfcGeomHelpers.cpp @@ -163,15 +163,38 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcVector* l, gp_Vec& v) { } bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf& trsf) { - IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf) - gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1);gp_Dir refDirection; - IfcGeom::Kernel::convert(l->Location(),o); - bool hasRef = l->hasRefDirection(); - if ( l->hasAxis() ) IfcGeom::Kernel::convert(l->Axis(),axis); - if ( hasRef ) IfcGeom::Kernel::convert(l->RefDirection(),refDirection); - gp_Ax3 ax3; - if ( hasRef ) ax3 = gp_Ax3(o,axis,refDirection); - else ax3 = gp_Ax3(o,axis); + IN_CACHE(IfcAxis2Placement3D, l, gp_Trsf, trsf) + + gp_Pnt o; + gp_Dir axis(0, 0, 1); + gp_Dir refDirection; + + IfcGeom::Kernel::convert(l->Location(), o); + const bool hasAxis = l->hasAxis(); + const bool hasRef = l->hasRefDirection(); + + if (hasAxis != hasRef) { + Logger::Warning("Axis and RefDirection should be specified together", l); + } + + if (hasAxis) { + IfcGeom::Kernel::convert(l->Axis(), axis); + } + + if (hasRef) { + IfcGeom::Kernel::convert(l->RefDirection(), refDirection); + } else { + if (!axis.IsParallel(gp::DX(), 1.e-5)) { + refDirection = gp::DX(); + } else { + refDirection = gp::DZ(); + } + gp_Vec Xvec = axis.Dot(refDirection) * axis; + gp_Vec Xaxis = refDirection.XYZ() - Xvec.XYZ(); + refDirection = Xaxis; + } + + gp_Ax3 ax3(o, axis, refDirection); if (!axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) { trsf.SetTransformation(ax3, gp::XOY()); diff --git a/src/ifcgeom/IfcRepresentationShapeItem.h b/src/ifcgeom/IfcRepresentationShapeItem.h index 58a77c4c5b..588e85a916 100644 --- a/src/ifcgeom/IfcRepresentationShapeItem.h +++ b/src/ifcgeom/IfcRepresentationShapeItem.h @@ -47,7 +47,7 @@ namespace IfcGeom { const gp_GTrsf& Placement() const { return placement; } bool hasStyle() const { return style != 0; } const SurfaceStyle& Style() const { return *style; } - void setStyle(const SurfaceStyle* style) { this->style = style; } + void setStyle(const SurfaceStyle* newStyle) { style = newStyle; } int ItemId() const { return id; } }; typedef std::vector IfcRepresentationShapeItems; diff --git a/src/ifcgeom_schema_agnostic/IfcGeomFilter.h b/src/ifcgeom_schema_agnostic/IfcGeomFilter.h index bc86cc295b..c29a6c8f3d 100644 --- a/src/ifcgeom_schema_agnostic/IfcGeomFilter.h +++ b/src/ifcgeom_schema_agnostic/IfcGeomFilter.h @@ -139,8 +139,7 @@ namespace IfcGeom { } bool operator()(IfcUtil::IfcBaseEntity* prod) const { - // @note bind1st() and mem_fun() deprecated in C++11, use bind() and mem_fn() when migrating to C++11. - return filter::match(prod, std::bind1st(std::mem_fun(&attribute_filter::match), this)); + return filter::match(prod, std::bind(&attribute_filter::match, this, std::placeholders::_1)); } void update_description() { @@ -172,7 +171,7 @@ namespace IfcGeom { } bool operator()(IfcUtil::IfcBaseEntity* prod) const { - return filter::match(prod, std::bind1st(std::mem_fun(&layer_filter::match), this)); + return filter::match(prod, std::bind(&layer_filter::match, this, std::placeholders::_1)); } struct wildcards_match { @@ -215,7 +214,7 @@ namespace IfcGeom { } bool operator()(IfcUtil::IfcBaseEntity* prod) const { - return filter::match(prod, std::bind1st(std::mem_fun(&entity_filter::match), this)); + return filter::match(prod, std::bind(&entity_filter::match, this, std::placeholders::_1)); } void update_description() {