Files
IfcOpenShell/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp
T
2017-02-01 15:57:25 -06:00

43 lines
1.4 KiB
C++

#include "../../../ifcparse/IfcParse.h"
#include "CgalKernel.h"
#include "CgalConversionResult.h"
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
bool part_succes = false;
if (items->size()) {
for (IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++it) {
IfcSchema::IfcRepresentationItem* representation_item = *it;
if (shape_type(representation_item) == ST_SHAPELIST) {
part_succes |= convert_shapes(*it, shapes);
} else {
cgal_shape_t s;
if (convert_shape(representation_item, s)) {
shapes.push_back(ConversionResult(new CgalShape(s), get_style(representation_item)));
part_succes |= true;
}
}
}
}
return part_succes;
}
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid*, cgal_shape_t&) {
throw std::runtime_error("Not implemented IfcExtrudedAreaSolid");
}
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCartesianPoint* l, cgal_point_t& point) {
std::vector<double> xyz = l->Coordinates();
// for (const double &coordinate: xyz) std::cout << coordinate << " ";
// std::cout << std::endl;
if (xyz.size() == 3) {
point = new Kernel::Point_3(xyz[0], xyz[1], xyz[2]);
// std::cout << *point << std::endl;
return true;
} else {
point = new Kernel::Point_3();
return false;
}
}