heap alloc for eigen types for alignment issues

This commit is contained in:
Thomas Krijnen
2020-06-11 20:48:35 +02:00
parent 185b4ef9fa
commit 109131961f
15 changed files with 203 additions and 94 deletions
@@ -7,8 +7,8 @@ void ifcopenshell::geometry::CgalShape::Triangulate(const settings& settings, co
// Copy is made because triangulate_faces() does not accept a const argument
cgal_shape_t s = shape_;
if (!place.components.isIdentity()) {
const auto& m = place.components;
if (!place.components->isIdentity()) {
const auto& m = *place.components;
// @todo check
const cgal_placement_t trsf(
+6 -5
View File
@@ -183,17 +183,18 @@ bool CgalKernel::convert(const taxonomy::face* face, cgal_face_t& result) {
}
namespace {
// @todo obsolete?
bool convert_curve(CgalKernel* kernel, const taxonomy::item* curve, cgal_wire_t& builder) {
if (curve->kind() == taxonomy::EDGE) {
auto e = (taxonomy::edge*) curve;
if (true || e->basis == nullptr) {
if (builder.empty()) {
const auto& p = boost::get<taxonomy::point3>(e->start);
cgal_point_t pnt(p.components(0), p.components(1), p.components(2));
cgal_point_t pnt((*p.components)(0), (*p.components)(1), (*p.components)(2));
builder.push_back(pnt);
}
const auto& p = boost::get<taxonomy::point3>(e->end);
cgal_point_t pnt(p.components(0), p.components(1), p.components(2));
cgal_point_t pnt((*p.components)(0), (*p.components)(1), (*p.components)(2));
builder.push_back(pnt);
} else if (e->basis->kind() == taxonomy::CIRCLE) {
// @todo
@@ -308,7 +309,7 @@ bool CgalKernel::convert(const taxonomy::extrusion* extrusion, cgal_shape_t &sha
}
// std::cout << "Face vertices: " << face.outer.size() << std::endl;
auto fs = extrusion->direction.components;
auto fs = *extrusion->direction.components;
cgal_direction_t dir(fs(0), fs(1), fs(2));
// std::cout << "Direction: " << dir << std::endl;
@@ -584,7 +585,7 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
namespace {
bool convert_placement(const ifcopenshell::geometry::taxonomy::matrix4& place, cgal_placement_t& trsf) {
const auto& m = place.components;
const auto& m = *place.components;
// @todo check
trsf = cgal_placement_t(
@@ -623,7 +624,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ifcopenshell::
for (auto it = cr.begin(); it != cr.end(); ++it) {
const cgal_shape_t& entity_shape_unlocated(((CgalShape*)it->Shape())->shape());
cgal_shape_t entity_shape(entity_shape_unlocated);
if (!it->Placement().components.isIdentity()) {
if (!it->Placement().components->isIdentity()) {
cgal_placement_t trsf;
convert_placement(it->Placement(), trsf);
for (auto &vertex : vertices(entity_shape)) {
@@ -134,8 +134,8 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion* extrusion, TopoDS_Sha
auto trsf = gtrsf.Trsf();
*/
auto fs = extrusion->direction.components.data();
gp_Dir dir(fs[0], fs[1], fs[2]);
const auto& fs = *extrusion->direction.components;
gp_Dir dir(fs(0), fs(1), fs(2));
shape.Nullify();
@@ -559,17 +559,17 @@ namespace {
}
curve_creation_visitor_result_type operator()(const taxonomy::line& l) {
const auto& m = l.matrix.components;
const auto& m = *l.matrix.components;
return result = Handle(Geom_Curve)(new Geom_Line(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(0))));
}
curve_creation_visitor_result_type operator()(const taxonomy::circle& c) {
const auto& m = c.matrix.components;
const auto& m = *c.matrix.components;
return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)), convert_xyz2<gp_Dir>(m.col(0))), c.radius));
}
curve_creation_visitor_result_type operator()(const taxonomy::ellipse& e) {
const auto& m = e.matrix.components;
const auto& m = *e.matrix.components;
return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)), convert_xyz2<gp_Dir>(m.col(0))), e.radius, e.radius2));
}
@@ -2251,7 +2251,7 @@ bool OpenCascadeKernel::flatten_shape_list(const ifcopenshell::geometry::Convers
}
TopoDS_Shape OpenCascadeKernel::apply_transformation(const TopoDS_Shape& s, const taxonomy::matrix4& t) {
if (t.components.isIdentity()) {
if (t.components->isIdentity()) {
return s;
} else {
gp_GTrsf trsf;
@@ -2294,7 +2294,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::face* face, ifcopenshell::g
}
// @todo boundary
const auto& m = ((taxonomy::geom_item*)face->basis)->matrix.components;
const auto& m = *((taxonomy::geom_item*)face->basis)->matrix.components;
gp_Pln pln(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)));
const gp_Pnt pnt = pln.Location().Translated(face->orientation.get_value_or(false) ? -pln.Axis().Direction() : pln.Axis().Direction());
TopoDS_Shape shape = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln), pnt).Solid();