| 1534 | #endif |
| 1535 | |
| 1536 | bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) { |
| 1537 | // @todo can also be for other boolean operations, just depth/matrix operands are different |
| 1538 | if (br->operation != taxonomy::boolean_result::SUBTRACTION) { |
| 1539 | return false; |
| 1540 | } |
| 1541 | |
| 1542 | typedef std::pair<Eigen::Matrix4d*, taxonomy::extrusion::ptr> extrusion_pair; |
| 1543 | // @todo delete extrusion_pair.first |
| 1544 | |
| 1545 | auto& ops = br->children; |
| 1546 | |
| 1547 | std::vector<extrusion_pair> extrusions; |
| 1548 | std::transform(ops.begin(), ops.end(), std::back_inserter(extrusions), [](taxonomy::ptr op) { |
| 1549 | static std::pair<Eigen::Matrix4d*, taxonomy::extrusion::ptr> nptr = { nullptr, nullptr }; |
| 1550 | Eigen::Matrix4d* m4 = nullptr; |
| 1551 | if (auto ex = taxonomy::dcast<taxonomy::extrusion>(op)) { |
| 1552 | return std::make_pair(m4, ex); |
| 1553 | } |
| 1554 | auto cl = taxonomy::dcast<taxonomy::collection>(op); |
| 1555 | if (!cl) return nptr; |
| 1556 | if ((cl)->children.size() != 1) return nptr; |
| 1557 | m4 = new Eigen::Matrix4d(cl->matrix->ccomponents()); |
| 1558 | if (cl->children[0]->kind() == taxonomy::COLLECTION) { |
| 1559 | cl = taxonomy::cast<taxonomy::collection>(cl->children[0]); |
| 1560 | if ((cl)->children.size() != 1) { |
| 1561 | delete m4; |
| 1562 | return nptr; |
| 1563 | } |
| 1564 | (*m4) = (*m4) * cl->matrix->ccomponents(); |
| 1565 | } |
| 1566 | if (cl->children[0]->kind() != taxonomy::EXTRUSION) { |
| 1567 | delete m4; |
| 1568 | return nptr; |
| 1569 | } |
| 1570 | auto ex = taxonomy::cast<taxonomy::extrusion>(cl->children[0]); |
| 1571 | return std::make_pair(m4, ex); |
| 1572 | }); |
| 1573 | |
| 1574 | if (std::find_if(extrusions.begin(), extrusions.end(), [](extrusion_pair& p) { |
| 1575 | return p.second == nullptr; |
| 1576 | }) != extrusions.end()) { |
| 1577 | return false; |
| 1578 | } |
| 1579 | |
| 1580 | // op[i].matrix[2,0:3] = <0 0 1> |
| 1581 | Eigen::Vector3d Z(0., 0., 1.); |
| 1582 | if (std::find_if(extrusions.begin(), extrusions.end(), [&Z](extrusion_pair& p) { |
| 1583 | // @todo factor in p.first; |
| 1584 | auto ex = p.second; |
| 1585 | auto& m = ex->matrix->ccomponents(); |
| 1586 | return std::abs(1. - std::abs(m.col(2).head<3>().dot(Z))) > 1.e-5; |
| 1587 | }) != extrusions.end()) { |
| 1588 | return false; |
| 1589 | } |
| 1590 | |
| 1591 | // | op[i].matrix[2,0:3] . op[i].direction | = 1 |
| 1592 | if (std::find_if(extrusions.begin(), extrusions.end(), [](extrusion_pair& p) { |
| 1593 | auto ex = p.second; |
nothing calls this directly
no test coverage detected