Fixes for compilation of cgal kernel

This commit is contained in:
Thomas Krijnen
2019-01-23 12:34:21 +01:00
parent a7a1ad129e
commit 30479ca0a6
15 changed files with 171 additions and 99 deletions
@@ -3,6 +3,9 @@
#define CgalKernel MAKE_TYPE_NAME(CgalKernel)
// @todo two distinct uses of the word Kernel is getting confusing
typedef Kernel Kernel_;
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
bool part_succes = false;
@@ -26,7 +29,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRepresentation* l, Convers
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal_shape_t &shape) {
const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
if (height < getValue(GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l);
return false;
}
@@ -49,10 +52,10 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal
std::list<cgal_face_t> face_list;
face_list.push_back(face);
for (std::vector<Kernel::Point_3>::const_iterator current_vertex = face.outer.begin();
for (std::vector<Kernel_::Point_3>::const_iterator current_vertex = face.outer.begin();
current_vertex != face.outer.end();
++current_vertex) {
std::vector<Kernel::Point_3>::const_iterator next_vertex = current_vertex;
std::vector<Kernel_::Point_3>::const_iterator next_vertex = current_vertex;
++next_vertex;
if (next_vertex == face.outer.end()) {
next_vertex = face.outer.begin();
@@ -65,14 +68,14 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal
}
cgal_face_t top_face;
for (std::vector<Kernel::Point_3>::const_reverse_iterator vertex = face.outer.rbegin();
for (std::vector<Kernel_::Point_3>::const_reverse_iterator vertex = face.outer.rbegin();
vertex != face.outer.rend();
++vertex) {
top_face.outer.push_back(*vertex+height*dir);
} face_list.push_back(top_face);
// Naive creation
cgal_shape_t polyhedron = CGAL::Polyhedron_3<Kernel>();
cgal_shape_t polyhedron = CGAL::Polyhedron_3<Kernel_>();
PolyhedronBuilder builder(&face_list);
polyhedron.delegate(builder);
@@ -91,7 +94,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCartesianPoint* l, cgal_point_t& point) {
std::vector<double> xyz = l->Coordinates();
if (xyz.size() == 3) {
point = Kernel::Point_3(xyz.size() ? (xyz[0]*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);
// std::cout << "Converted Point(" << point << ")" << std::endl;
@@ -104,7 +107,7 @@ 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 = Kernel::Vector_3(xyz.size() ? xyz[0] : 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)
@@ -114,15 +117,15 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_directi
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement2D* l, cgal_placement_t& trsf) {
// IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf)
cgal_point_t o;
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?
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 ( hasRef ) IfcGeom::CgalKernel::convert(l->RefDirection(),refDirection);
// TODO: From Thomas' email. Should be checked.
Kernel::Vector_3 y = CGAL::cross_product(Kernel::Vector_3(0.0, 0.0, 1.0), refDirection);
trsf = Kernel::Aff_transformation_3(refDirection.cartesian(0), y.cartesian(0), 0.0, o.cartesian(0),
Kernel_::Vector_3 y = CGAL::cross_product(Kernel_::Vector_3(0.0, 0.0, 1.0), refDirection);
trsf = Kernel_::Aff_transformation_3(refDirection.cartesian(0), y.cartesian(0), 0.0, o.cartesian(0),
refDirection.cartesian(1), y.cartesian(1), 0.0, o.cartesian(1),
0.0, y.cartesian(2), 1.0, 0.0);
@@ -133,8 +136,8 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement2D* l, cgal_
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 = Kernel::Vector_3(0,0,1);
cgal_direction_t refDirection = 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);
@@ -145,8 +148,8 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_
// std::cout << "Origin: " << o << std::endl;
// TODO: From Thomas' email. Should be checked.
Kernel::Vector_3 y = CGAL::cross_product(axis, refDirection);
trsf = Kernel::Aff_transformation_3(refDirection.cartesian(0), y.cartesian(0), axis.cartesian(0), o.cartesian(0),
Kernel_::Vector_3 y = CGAL::cross_product(axis, refDirection);
trsf = Kernel_::Aff_transformation_3(refDirection.cartesian(0), y.cartesian(0), axis.cartesian(0), o.cartesian(0),
refDirection.cartesian(1), y.cartesian(1), axis.cartesian(1), o.cartesian(1),
refDirection.cartesian(2), y.cartesian(2), axis.cartesian(2), o.cartesian(2));
@@ -163,8 +166,8 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_placement_t& trsf) {
// TODO: These macros don't work for the CGAL types. Need to check why.
// IN_CACHE(IfcObjectPlacement,l,cgal_placement_t,trsf)
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l->entity);
if ( ! l->as<IfcSchema::IfcLocalPlacement>() ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l);
return false;
}
@@ -180,7 +183,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_p
cgal_placement_t trsf2;
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) {
if ( relplacement->as<IfcSchema::IfcAxis2Placement3D>() ) {
IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
// std::cout << "trsf2" << std::endl;
@@ -201,7 +204,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_p
}
if ( current->hasPlacementRelTo() ) {
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
if ( relto->as<IfcSchema::IfcLocalPlacement>() )
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
else break;
} else break;
@@ -215,7 +218,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRectangleProfileDef* l, cg
const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT);
if ( x < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l);
return false;
}
@@ -229,10 +232,10 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRectangleProfileDef* l, cg
}
face = cgal_face_t();
face.outer.push_back(Kernel::Point_3(-x, -y, 0.0));
face.outer.push_back(Kernel::Point_3( x, -y, 0.0));
face.outer.push_back(Kernel::Point_3( x, y, 0.0));
face.outer.push_back(Kernel::Point_3(-x, y, 0.0));
face.outer.push_back(Kernel_::Point_3(-x, -y, 0.0));
face.outer.push_back(Kernel_::Point_3( x, -y, 0.0));
face.outer.push_back(Kernel_::Point_3( x, y, 0.0));
face.outer.push_back(Kernel_::Point_3(-x, y, 0.0));
return true;
}
+16 -13
View File
@@ -21,6 +21,9 @@
#define CgalKernel MAKE_TYPE_NAME(CgalKernel)
// @todo two distinct uses of the word Kernel is getting confusing
typedef Kernel Kernel_;
using namespace IfcUtil;
bool IfcGeom::CgalKernel::convert_shapes(const IfcBaseClass* l, ConversionResults& r) {
@@ -84,11 +87,11 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, Conv
const SurfaceStyle* indiv_style = get_style(l->Outer());
IfcSchema::IfcClosedShell::list::ptr voids(new IfcSchema::IfcClosedShell::list);
if (l->is(IfcSchema::Type::IfcFacetedBrepWithVoids)) {
if (l->as<IfcSchema::IfcFacetedBrepWithVoids>()) {
voids = l->as<IfcSchema::IfcFacetedBrepWithVoids>()->Voids();
}
#ifdef USE_IFC4
if (l->is(IfcSchema::Type::IfcAdvancedBrepWithVoids)) {
if (l->as<IfcSchema::IfcAdvancedBrepWithVoids>()) {
voids = l->as<IfcSchema::IfcAdvancedBrepWithVoids>()->Voids();
}
#endif
@@ -102,7 +105,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, Conv
// }
}
shape.push_back(ConversionResult(new CgalShape(s), indiv_style ? indiv_style : collective_style));
shape.push_back(ConversionResult(l->data().id(), new CgalShape(s), indiv_style ? indiv_style : collective_style));
return true;
}
return false;
@@ -121,7 +124,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcConnectedFaceSet* l, cgal_
} catch (...) {}
if (!success) {
Logger::Message(Logger::LOG_WARNING, "Failed to convert face:", (*it)->entity);
Logger::Message(Logger::LOG_WARNING, "Failed to convert face:", *it);
continue;
}
@@ -134,7 +137,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcConnectedFaceSet* l, cgal_
}
// Naive creation
cgal_shape_t polyhedron = CGAL::Polyhedron_3<Kernel>();
cgal_shape_t polyhedron = CGAL::Polyhedron_3<Kernel_>();
PolyhedronBuilder builder(&face_list);
polyhedron.delegate(builder);
@@ -169,11 +172,11 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcFace* l, cgal_face_t& face
for (IfcSchema::IfcFaceBound::list::it it = bounds->begin(); it != bounds->end(); ++it) {
IfcSchema::IfcFaceBound* bound = *it;
if (bound->is(IfcSchema::Type::IfcFaceOuterBound)) num_outer_bounds ++;
if (bound->as<IfcSchema::IfcFaceOuterBound>()) num_outer_bounds ++;
}
if (num_outer_bounds != 1) {
Logger::Message(Logger::LOG_ERROR, "Invalid configuration of boundaries for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid configuration of boundaries for:", l);
return false;
}
@@ -183,11 +186,11 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcFace* l, cgal_face_t& face
IfcSchema::IfcFaceBound* bound = *it;
IfcSchema::IfcLoop* loop = bound->Bound();
const bool is_interior = !bound->is(IfcSchema::Type::IfcFaceOuterBound);
const bool is_interior = !bound->as<IfcSchema::IfcFaceOuterBound>();
cgal_wire_t wire;
if (!convert_wire(loop, wire)) {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop);
return false;
}
@@ -212,7 +215,7 @@ 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 = 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);
@@ -222,7 +225,7 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcPolyLoop* l, cgal_wire_t&
// A loop should consist of at least three vertices
std::size_t original_count = polygon.size();
if (original_count < 3) {
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l);
return false;
}
@@ -232,11 +235,11 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcPolyLoop* l, cgal_wire_t&
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);
Logger::Message(Logger::LOG_WARNING, ss.str(), l);
}
if (count < 3) {
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l);
return false;
}
+2
View File
@@ -35,6 +35,8 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
#endif
*/
#define ALMOST_ZERO 1.e-9
#include "../../../ifcparse/macros.h"
#include "../../../ifcgeom/kernel_agnostic/AbstractKernel.h"