mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +00:00
Merge pull request #9 from kenohori/cgal
Fix issue with opening placements
This commit is contained in:
@@ -37,8 +37,6 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcMappedItem* l, ConversionR
|
|||||||
IfcSchema::IfcCartesianTransformationOperator* transform = l->MappingTarget();
|
IfcSchema::IfcCartesianTransformationOperator* transform = l->MappingTarget();
|
||||||
if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
|
if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
|
||||||
IfcGeom::CgalKernel::convert((IfcSchema::IfcCartesianTransformationOperator3DnonUniform*)transform,gtrsf);
|
IfcGeom::CgalKernel::convert((IfcSchema::IfcCartesianTransformationOperator3DnonUniform*)transform,gtrsf);
|
||||||
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
|
||||||
return false;
|
|
||||||
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2DnonUniform) ) {
|
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2DnonUniform) ) {
|
||||||
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
||||||
return false;
|
return false;
|
||||||
@@ -46,8 +44,6 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcMappedItem* l, ConversionR
|
|||||||
cgal_placement_t trsf;
|
cgal_placement_t trsf;
|
||||||
IfcGeom::CgalKernel::convert((IfcSchema::IfcCartesianTransformationOperator3D*)transform,trsf);
|
IfcGeom::CgalKernel::convert((IfcSchema::IfcCartesianTransformationOperator3D*)transform,trsf);
|
||||||
gtrsf = trsf;
|
gtrsf = trsf;
|
||||||
// Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
|
||||||
// return false;
|
|
||||||
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2D) ) {
|
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2D) ) {
|
||||||
cgal_placement_t trsf_2d;
|
cgal_placement_t trsf_2d;
|
||||||
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
||||||
@@ -239,11 +235,12 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal
|
|||||||
// std::cout << "Before: " << hole_polyhedron.size_of_vertices() << " vertices and " << hole_polyhedron.size_of_facets() << " facets" << std::endl;
|
// std::cout << "Before: " << hole_polyhedron.size_of_vertices() << " vertices and " << hole_polyhedron.size_of_facets() << " facets" << std::endl;
|
||||||
CGAL::Polygon_mesh_processing::stitch_borders(hole_polyhedron);
|
CGAL::Polygon_mesh_processing::stitch_borders(hole_polyhedron);
|
||||||
if (!hole_polyhedron.is_valid()) {
|
if (!hole_polyhedron.is_valid()) {
|
||||||
std::cout << "Invalid hole polyhedron!" << std::endl;
|
// std::cout << "Invalid hole polyhedron!" << std::endl;
|
||||||
std::ofstream fresult;
|
// std::ofstream fresult;
|
||||||
fresult.open("/Users/ken/Desktop/invalid.off");
|
// fresult.open("/Users/ken/Desktop/invalid.off");
|
||||||
fresult << hole_polyhedron << std::endl;
|
// fresult << hole_polyhedron << std::endl;
|
||||||
fresult.close();
|
// fresult.close();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &vertex : vertices(hole_polyhedron)) {
|
for (auto &vertex : vertices(hole_polyhedron)) {
|
||||||
@@ -258,6 +255,19 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal
|
|||||||
shape -= CGAL::Nef_polyhedron_3<Kernel>(hole_polyhedron);
|
shape -= CGAL::Nef_polyhedron_3<Kernel>(hole_polyhedron);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::cout << "trsf" << std::endl;
|
||||||
|
// for (int i = 0; i < 3; ++i) {
|
||||||
|
// for (int j = 0; j < 4; ++j) {
|
||||||
|
// std::cout << trsf.cartesian(i, j) << " ";
|
||||||
|
// } std::cout << std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// shape.convert_to_polyhedron(polyhedron);
|
||||||
|
// std::ofstream fresult;
|
||||||
|
// fresult.open("/Users/ken/Desktop/extrusion.off");
|
||||||
|
// fresult << polyhedron << std::endl;
|
||||||
|
// fresult.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,9 +210,30 @@ bool IfcGeom::CgalKernel::convert_openings(const IfcSchema::IfcProduct* entity,
|
|||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::cout << "entity_trsf" << std::endl;
|
||||||
|
// for (int i = 0; i < 3; ++i) {
|
||||||
|
// for (int j = 0; j < 4; ++j) {
|
||||||
|
// std::cout << entity_trsf.cartesian(i, j) << " ";
|
||||||
|
// } std::cout << std::endl;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// std::cout << "opening_trsf before" << std::endl;
|
||||||
|
// for (int i = 0; i < 3; ++i) {
|
||||||
|
// for (int j = 0; j < 4; ++j) {
|
||||||
|
// std::cout << opening_trsf.cartesian(i, j) << " ";
|
||||||
|
// } std::cout << std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
// Move the opening into the coordinate system of the IfcProduct
|
// Move the opening into the coordinate system of the IfcProduct
|
||||||
opening_trsf = opening_trsf * entity_trsf.inverse();
|
opening_trsf = opening_trsf * entity_trsf.inverse();
|
||||||
|
|
||||||
|
// std::cout << "opening_trsf after" << std::endl;
|
||||||
|
// for (int i = 0; i < 3; ++i) {
|
||||||
|
// for (int j = 0; j < 4; ++j) {
|
||||||
|
// std::cout << opening_trsf.cartesian(i, j) << " ";
|
||||||
|
// } std::cout << std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
IfcSchema::IfcProductRepresentation* prodrep = fes->Representation();
|
IfcSchema::IfcProductRepresentation* prodrep = fes->Representation();
|
||||||
IfcSchema::IfcRepresentation::list::ptr reps = prodrep->Representations();
|
IfcSchema::IfcRepresentation::list::ptr reps = prodrep->Representations();
|
||||||
|
|
||||||
@@ -223,12 +244,21 @@ bool IfcGeom::CgalKernel::convert_openings(const IfcSchema::IfcProduct* entity,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < opening_shapes.size(); ++ i ) {
|
for ( unsigned int i = 0; i < opening_shapes.size(); ++ i ) {
|
||||||
cgal_shape_t opening_shape(((CgalShape*)opening_shapes[i].Shape())->shape());
|
cgal_placement_t gtrsf;
|
||||||
if (opening_shapes[i].Placement()) {
|
if (opening_shapes[i].Placement()) {
|
||||||
cgal_placement_t gtrsf = *(CgalPlacement*)opening_shapes[i].Placement();
|
gtrsf = *(CgalPlacement*)opening_shapes[i].Placement();
|
||||||
gtrsf = gtrsf * opening_trsf;
|
}
|
||||||
opening_shape.transform(gtrsf);
|
gtrsf = gtrsf * opening_trsf;
|
||||||
} opening_shapelist.push_back(opening_shape);
|
cgal_shape_t opening_shape(((CgalShape*)opening_shapes[i].Shape())->shape());
|
||||||
|
opening_shape.transform(gtrsf);
|
||||||
|
opening_shapelist.push_back(opening_shape);
|
||||||
|
|
||||||
|
// std::cout << "gtrsf" << std::endl;
|
||||||
|
// for (int i = 0; i < 3; ++i) {
|
||||||
|
// for (int j = 0; j < 4; ++j) {
|
||||||
|
// std::cout << gtrsf.cartesian(i, j) << " ";
|
||||||
|
// } std::cout << std::endl;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -246,7 +276,25 @@ bool IfcGeom::CgalKernel::convert_openings(const IfcSchema::IfcProduct* entity,
|
|||||||
cgal_shape_t brep_cut_result(entity_shape);
|
cgal_shape_t brep_cut_result(entity_shape);
|
||||||
|
|
||||||
for (auto &opening: opening_shapelist) {
|
for (auto &opening: opening_shapelist) {
|
||||||
|
|
||||||
|
// CGAL::Polyhedron_3<Kernel> polyhedron;
|
||||||
|
// brep_cut_result.convert_to_polyhedron(polyhedron);
|
||||||
|
// std::ofstream fresult;
|
||||||
|
// fresult.open("/Users/ken/Desktop/before.off");
|
||||||
|
// fresult << polyhedron << std::endl;
|
||||||
|
// fresult.close();
|
||||||
|
//
|
||||||
|
// opening.convert_to_polyhedron(polyhedron);
|
||||||
|
// fresult.open("/Users/ken/Desktop/opening.off");
|
||||||
|
// fresult << polyhedron << std::endl;
|
||||||
|
// fresult.close();
|
||||||
|
|
||||||
brep_cut_result -= opening;
|
brep_cut_result -= opening;
|
||||||
|
|
||||||
|
// brep_cut_result.convert_to_polyhedron(polyhedron);
|
||||||
|
// fresult.open("/Users/ken/Desktop/after.off");
|
||||||
|
// fresult << polyhedron << std::endl;
|
||||||
|
// fresult.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (brep_cut_result.is_valid()) {
|
if (brep_cut_result.is_valid()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user