| 858 | } |
| 859 | |
| 860 | bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil::IfcBaseEntity * entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes) |
| 861 | { |
| 862 | #ifdef IFOPSH_SIMPLE_KERNEL |
| 863 | return false; |
| 864 | #else |
| 865 | CGAL::Nef_nary_union_3<CGAL::Nef_polyhedron_3<Kernel_>> second_operand_collector; |
| 866 | size_t second_operand_collector_size = 0; |
| 867 | |
| 868 | std::list<std::pair<const IfcUtil::IfcBaseClass*, std::list<cgal_shape_t>>> operands; |
| 869 | |
| 870 | std::list<const IfcUtil::IfcBaseClass*> second_operand_instances; |
| 871 | std::list<cgal_shape_t> first_operands, second_operands; |
| 872 | std::list<CGAL::Nef_polyhedron_3<Kernel_>> first_operands_nef, second_operands_nef; |
| 873 | |
| 874 | for (auto& shp : entity_shapes) { |
| 875 | cgal_shape_t entity_shape = *std::static_pointer_cast<CgalShape>(shp.Shape()); |
| 876 | const auto& m = shp.Placement()->ccomponents(); |
| 877 | if (!m.isIdentity()) { |
| 878 | cgal_placement_t trsf; |
| 879 | convert_placement(m, trsf); |
| 880 | for (auto &vertex : vertices(entity_shape)) { |
| 881 | vertex->point() = vertex->point().transform(trsf); |
| 882 | } |
| 883 | } |
| 884 | first_operands.push_back(entity_shape); |
| 885 | |
| 886 | |
| 887 | CGAL::Nef_polyhedron_3<Kernel_> a; |
| 888 | if (!preprocess_boolean_operand(entity, {}, {}, {}, entity_shape, a, PP_NONE /*PP_UNIFY_PLANES_INTERNALLY*/)) { |
| 889 | return false; |
| 890 | } |
| 891 | |
| 892 | first_operands_nef.push_back(a); |
| 893 | } |
| 894 | |
| 895 | std::list<Kernel_::Plane_3> all_operand_planes; |
| 896 | |
| 897 | for (auto& op : openings) { |
| 898 | auto opening_trsf = op.second; |
| 899 | Eigen::Matrix4d relative = entity_trsf.ccomponents().inverse() * opening_trsf.ccomponents(); |
| 900 | opening_trsf = relative; |
| 901 | |
| 902 | ConversionResults opening_shapes; |
| 903 | AbstractKernel::convert(op.first, opening_shapes); |
| 904 | |
| 905 | for (unsigned int i = 0; i < opening_shapes.size(); ++i) { |
| 906 | cgal_shape_t entity_shape_unlocated = *std::static_pointer_cast<CgalShape>(opening_shapes[i].Shape()); |
| 907 | cgal_shape_t entity_shape(entity_shape_unlocated); |
| 908 | auto gtrsf = opening_shapes[i].Placement(); |
| 909 | // @todo check |
| 910 | Eigen::Matrix4d m = opening_trsf.ccomponents() * gtrsf->ccomponents(); |
| 911 | if (!m.isIdentity()) { |
| 912 | cgal_placement_t trsf; |
| 913 | convert_placement(m, trsf); |
| 914 | for (auto &vertex : vertices(entity_shape)) { |
| 915 | vertex->point() = vertex->point().transform(trsf); |
| 916 | } |
| 917 | } |
no test coverage detected