mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 02:21:02 +00:00
Use model-offset in IfcGeom::Kernel and add model-rotation
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#define IFCGEOM_H
|
||||
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
|
||||
static const double ALMOST_ZERO = 1.e-9;
|
||||
|
||||
@@ -37,6 +38,7 @@ inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance=ALMO
|
||||
#include <gp_GTrsf2d.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Trsf2d.hxx>
|
||||
#include <gp_Quaternion.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
@@ -222,6 +224,9 @@ private:
|
||||
double modelling_precision;
|
||||
double dimensionality;
|
||||
double layerset_first;
|
||||
gp_Vec offset = gp_Vec{0.0, 0.0, 0.0};
|
||||
gp_Quaternion rotation = gp_Quaternion{};
|
||||
gp_Trsf offset_and_rotation = gp_Trsf();
|
||||
|
||||
#ifndef NO_CACHE
|
||||
MAKE_TYPE_NAME(Cache) cache;
|
||||
@@ -264,6 +269,9 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set_offset(const std::array<double, 3>& offset);
|
||||
void set_rotation(const std::array<double, 4>& rotation);
|
||||
|
||||
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
|
||||
bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire);
|
||||
bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result);
|
||||
|
||||
@@ -505,6 +505,28 @@ namespace {
|
||||
usd.Build();
|
||||
return usd.Shape();
|
||||
}
|
||||
|
||||
gp_Trsf combine_offset_and_rotation(const gp_Vec &offset, const gp_Quaternion& rotation) {
|
||||
auto offset_transform = gp_Trsf{};
|
||||
offset_transform.SetTranslation(offset);
|
||||
|
||||
auto rotation_transform = gp_Trsf{};
|
||||
rotation_transform.SetRotation(rotation);
|
||||
|
||||
return rotation_transform * offset_transform;
|
||||
}
|
||||
}
|
||||
|
||||
void IfcGeom::Kernel::set_offset(const std::array<double, 3> &p_offset) {
|
||||
offset = gp_Vec(p_offset[0], p_offset[1], p_offset[2]);
|
||||
|
||||
offset_and_rotation = combine_offset_and_rotation(offset, rotation);
|
||||
}
|
||||
|
||||
void IfcGeom::Kernel::set_rotation(const std::array<double, 4> &p_rotation) {
|
||||
rotation = gp_Quaternion(p_rotation[0], p_rotation[1], p_rotation[2], p_rotation[3]);
|
||||
|
||||
offset_and_rotation = combine_offset_and_rotation(offset, rotation);
|
||||
}
|
||||
|
||||
bool IfcGeom::Kernel::create_solid_from_compound(const TopoDS_Shape& compound, TopoDS_Shape& shape) {
|
||||
|
||||
@@ -418,6 +418,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
|
||||
else break;
|
||||
} else break;
|
||||
}
|
||||
|
||||
trsf.PreMultiply(offset_and_rotation);
|
||||
|
||||
CACHE(IfcObjectPlacement,l,trsf)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -985,6 +985,8 @@ namespace IfcGeom {
|
||||
} else if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) {
|
||||
kernel.set_conversion_placement_rel_to(&IfcSchema::IfcSite::Class());
|
||||
}
|
||||
kernel.set_offset(settings.offset);
|
||||
kernel.set_rotation(settings.rotation);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef IFCGEOMITERATORSETTINGS_H
|
||||
#define IFCGEOMITERATORSETTINGS_H
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "ifc_geom_api.h"
|
||||
#include "../ifcparse/IfcException.h"
|
||||
#include "../ifcparse/IfcBaseClass.h"
|
||||
@@ -132,6 +134,11 @@ namespace IfcGeom
|
||||
}
|
||||
}
|
||||
|
||||
/// Optional offset that is applied to serialized objects, (0,0,0) by default.
|
||||
std::array<double,3> offset = std::array<double,3>{0.0, 0.0, 0.0};
|
||||
/// Optional rotation that is applied to serialized objects, (0,0,0,1) by default.
|
||||
std::array<double,4> rotation = std::array<double,4>{0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
protected:
|
||||
SettingField settings_;
|
||||
double deflection_tolerance_;
|
||||
|
||||
Reference in New Issue
Block a user