mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Nothing is a pointer now. Initialisation is easier…
This commit is contained in:
@@ -30,9 +30,9 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid*, cgal_s
|
||||
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCartesianPoint* l, cgal_point_t& point) {
|
||||
std::vector<double> xyz = l->Coordinates();
|
||||
if (xyz.size() == 3) {
|
||||
point = new Kernel::Point_3(xyz.size() ? (xyz[0]*getValue(GV_LENGTH_UNIT)) : 0.0f,
|
||||
xyz.size() > 1 ? (xyz[1]*getValue(GV_LENGTH_UNIT)) : 0.0f,
|
||||
xyz.size() > 2 ? (xyz[2]*getValue(GV_LENGTH_UNIT)) : 0.0f);
|
||||
point = Kernel::Point_3(xyz.size() ? (xyz[0]*getValue(GV_LENGTH_UNIT)) : 0.0f,
|
||||
xyz.size() > 1 ? (xyz[1]*getValue(GV_LENGTH_UNIT)) : 0.0f,
|
||||
xyz.size() > 2 ? (xyz[2]*getValue(GV_LENGTH_UNIT)) : 0.0f);
|
||||
return true;
|
||||
} else {
|
||||
throw std::runtime_error("Point without 3 coordinates");
|
||||
@@ -42,9 +42,9 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCartesianPoint* l, cgal_po
|
||||
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_direction_t& dir) {
|
||||
// IN_CACHE(IfcDirection,l,cgal_direction_t,dir)
|
||||
std::vector<double> xyz = l->DirectionRatios();
|
||||
dir = new Kernel::Vector_3(xyz.size() ? xyz[0] : 0.0f,
|
||||
xyz.size() > 1 ? xyz[1] : 0.0f,
|
||||
xyz.size() > 2 ? xyz[2] : 0.0f);
|
||||
dir = Kernel::Vector_3(xyz.size() ? xyz[0] : 0.0f,
|
||||
xyz.size() > 1 ? xyz[1] : 0.0f,
|
||||
xyz.size() > 2 ? xyz[2] : 0.0f);
|
||||
// CACHE(IfcDirection,l,dir)
|
||||
return true;
|
||||
}
|
||||
@@ -52,17 +52,17 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_directi
|
||||
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_placement_t& trsf) {
|
||||
// IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf)
|
||||
cgal_point_t o;
|
||||
cgal_direction_t axis = new Kernel::Vector_3(0,0,1);
|
||||
cgal_direction_t refDirection = new Kernel::Vector_3(1,0,0); // TODO: Put identity for now. Check?
|
||||
cgal_direction_t axis = Kernel::Vector_3(0,0,1);
|
||||
cgal_direction_t refDirection = Kernel::Vector_3(1,0,0); // TODO: Put identity for now. Check?
|
||||
IfcGeom::CgalKernel::convert(l->Location(),o);
|
||||
bool hasRef = l->hasRefDirection();
|
||||
if ( l->hasAxis() ) IfcGeom::CgalKernel::convert(l->Axis(),axis);
|
||||
if ( hasRef ) IfcGeom::CgalKernel::convert(l->RefDirection(),refDirection);
|
||||
|
||||
// TODO: From Thomas' email. Should be checked.
|
||||
trsf = new Kernel::Aff_transformation_3(refDirection->cartesian(0), axis->cartesian(0)*refDirection->cartesian(0), axis->cartesian(0), o->cartesian(0),
|
||||
refDirection->cartesian(1), axis->cartesian(1)*refDirection->cartesian(1), axis->cartesian(1), o->cartesian(1),
|
||||
refDirection->cartesian(2), axis->cartesian(2)*refDirection->cartesian(2), axis->cartesian(2), o->cartesian(2));
|
||||
trsf = Kernel::Aff_transformation_3(refDirection.cartesian(0), axis.cartesian(0)*refDirection.cartesian(0), axis.cartesian(0), o.cartesian(0),
|
||||
refDirection.cartesian(1), axis.cartesian(1)*refDirection.cartesian(1), axis.cartesian(1), o.cartesian(1),
|
||||
refDirection.cartesian(2), axis.cartesian(2)*refDirection.cartesian(2), axis.cartesian(2), o.cartesian(2));
|
||||
|
||||
// CACHE(IfcAxis2Placement3D,l,trsf)
|
||||
return true;
|
||||
@@ -81,13 +81,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_p
|
||||
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
|
||||
if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) {
|
||||
IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
std::cout << "trsf " << trsf->m(i, j) << std::endl;
|
||||
}
|
||||
}
|
||||
// std::cout << "trsf2" << trsf2 << std::endl;
|
||||
*trsf = *trsf * *trsf2; // TODO: I think it's fine, but maybe should it be the other way around?
|
||||
trsf = trsf * trsf2; // TODO: I think it's fine, but maybe should it be the other way around?
|
||||
}
|
||||
if ( current->hasPlacementRelTo() ) {
|
||||
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace IfcGeom {
|
||||
|
||||
virtual double Value(int i, int j) const {
|
||||
// Get cell from placement as 4x3 matrix as implemented in OCCT. We'll have to check exact semantics.
|
||||
return CGAL::to_double(trsf_->cartesian(i, j));
|
||||
return CGAL::to_double(trsf_.cartesian(i, j));
|
||||
}
|
||||
virtual void Multiply(const ConversionResultPlacement* other) {
|
||||
// Multiply matrix as implemented in OCCT. We'll have to check exact semantics.
|
||||
@@ -74,4 +74,4 @@ namespace IfcGeom {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -146,9 +146,9 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcConnectedFaceSet* l, cgal_
|
||||
// }
|
||||
// }
|
||||
|
||||
cgal_shape_t polyhedron = new CGAL::Polyhedron_3<Kernel>();
|
||||
cgal_shape_t polyhedron = CGAL::Polyhedron_3<Kernel>();
|
||||
PolyhedronBuilder builder(&face_list);
|
||||
polyhedron->delegate(builder);
|
||||
polyhedron.delegate(builder);
|
||||
|
||||
shape = polyhedron;
|
||||
return true;
|
||||
@@ -181,7 +181,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcFace* l, cgal_face_t& face
|
||||
return false;
|
||||
}
|
||||
|
||||
cgal_face_t mf = new CgalFace();
|
||||
cgal_face_t mf;
|
||||
|
||||
for (IfcSchema::IfcFaceBound::list::it it = bounds->begin(); it != bounds->end(); ++it) {
|
||||
IfcSchema::IfcFaceBound* bound = *it;
|
||||
@@ -192,14 +192,13 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcFace* l, cgal_face_t& face
|
||||
cgal_wire_t wire;
|
||||
if (!convert_wire(loop, wire)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop->entity);
|
||||
delete mf;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_interior) {
|
||||
mf->outer = wire;
|
||||
mf.outer = wire;
|
||||
} else {
|
||||
mf->inner.push_back(wire);
|
||||
mf.inner.push_back(wire);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,15 +210,15 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcPolyLoop* l, cgal_wire_t&
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points = l->Polygon();
|
||||
|
||||
// Parse and store the points in a sequence
|
||||
cgal_wire_t polygon = new std::vector<Kernel::Point_3>();
|
||||
cgal_wire_t polygon = std::vector<Kernel::Point_3>();
|
||||
for(IfcSchema::IfcCartesianPoint::list::it it = points->begin(); it != points->end(); ++ it) {
|
||||
cgal_point_t pnt;
|
||||
IfcGeom::CgalKernel::convert(*it, pnt);
|
||||
polygon->push_back(*pnt);
|
||||
polygon.push_back(pnt);
|
||||
}
|
||||
|
||||
// A loop should consist of at least three vertices
|
||||
std::size_t original_count = polygon->size();
|
||||
std::size_t original_count = polygon.size();
|
||||
if (original_count < 3) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l->entity);
|
||||
return false;
|
||||
@@ -228,7 +227,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcPolyLoop* l, cgal_wire_t&
|
||||
// TODO: Remove repeated points (and points that are too close to one another?)
|
||||
// remove_duplicate_points_from_loop(polygon, true);
|
||||
|
||||
std::size_t count = polygon->size();
|
||||
std::size_t count = polygon.size();
|
||||
if (original_count - count != 0) {
|
||||
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
|
||||
Logger::Message(Logger::LOG_WARNING, ss.str(), l->entity);
|
||||
|
||||
@@ -44,19 +44,18 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
||||
|
||||
typedef Kernel::Aff_transformation_3 *cgal_placement_t;
|
||||
typedef Kernel::Point_3 *cgal_point_t;
|
||||
typedef Kernel::Vector_3 *cgal_direction_t;
|
||||
typedef std::vector<Kernel::Point_3> *cgal_curve_t;
|
||||
typedef std::vector<Kernel::Point_3> *cgal_wire_t;
|
||||
typedef Kernel::Aff_transformation_3 cgal_placement_t;
|
||||
typedef Kernel::Point_3 cgal_point_t;
|
||||
typedef Kernel::Vector_3 cgal_direction_t;
|
||||
typedef std::vector<Kernel::Point_3> cgal_curve_t;
|
||||
typedef std::vector<Kernel::Point_3> cgal_wire_t;
|
||||
|
||||
struct CgalFace {
|
||||
struct cgal_face_t {
|
||||
cgal_wire_t outer;
|
||||
std::vector<cgal_wire_t> inner;
|
||||
};
|
||||
|
||||
typedef CgalFace *cgal_face_t;
|
||||
typedef CGAL::Polyhedron_3<Kernel> *cgal_shape_t;
|
||||
typedef CGAL::Polyhedron_3<Kernel> cgal_shape_t;
|
||||
|
||||
struct PolyhedronBuilder : public CGAL::Modifier_base<CGAL::Polyhedron_3<Kernel>::HalfedgeDS> {
|
||||
private:
|
||||
@@ -73,7 +72,7 @@ public:
|
||||
|
||||
for (auto const &face: *face_list) {
|
||||
facet_vertices.push_back(std::list<std::size_t>());
|
||||
for (auto const &point: *face->outer) {
|
||||
for (auto const &point: face.outer) {
|
||||
if (points_map.count(point) == 0) {
|
||||
facet_vertices.back().push_back(points_map.size());
|
||||
points_map[point] = points_map.size();
|
||||
|
||||
Reference in New Issue
Block a user