| 1678 | |
| 1679 | namespace { |
| 1680 | bool orthogonal_edge_length(const cgal_shape_t& shape, const cgal_direction_t& face_normal, std::pair<Kernel_::FT, Kernel_::FT>& distances) { |
| 1681 | static double inf = 1.e9; // std::numeric_limits<double>::infinity(); |
| 1682 | |
| 1683 | std::vector<double> lengths; |
| 1684 | |
| 1685 | distances = { +inf, -inf }; |
| 1686 | |
| 1687 | for (const auto& e : edges(shape)) { |
| 1688 | const auto& p0 = e.halfedge()->vertex()->point(); |
| 1689 | const auto& p1 = e.halfedge()->next()->vertex()->point(); |
| 1690 | auto p01 = p1 - p0; |
| 1691 | auto p01_length = std::sqrt(CGAL::to_double(p01.squared_length())); |
| 1692 | p01 /= p01_length; |
| 1693 | auto dot = std::abs(CGAL::to_double(p01 * face_normal)); |
| 1694 | if (dot > 1e-5) { |
| 1695 | if (dot < 0.9999) { |
| 1696 | return false; |
| 1697 | } else { |
| 1698 | lengths.push_back(p01_length); |
| 1699 | auto v = (p0 - CGAL::ORIGIN) * face_normal; |
| 1700 | if (v < distances.first) { |
| 1701 | distances.first = v; |
| 1702 | } |
| 1703 | if (v > distances.second) { |
| 1704 | distances.second = v; |
| 1705 | } |
| 1706 | v = (p1 - CGAL::ORIGIN) * face_normal; |
| 1707 | if (v < distances.first) { |
| 1708 | distances.first = v; |
| 1709 | } |
| 1710 | if (v > distances.second) { |
| 1711 | distances.second = v; |
| 1712 | } |
| 1713 | } |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | std::sort(lengths.begin(), lengths.end()); |
| 1718 | auto edge_len_diff = lengths.back() - lengths.front(); |
| 1719 | |
| 1720 | std::wcout << "edge_len_diff " << edge_len_diff << std::endl; |
| 1721 | |
| 1722 | if (edge_len_diff > 1e-5) { |
| 1723 | return false; |
| 1724 | } |
| 1725 | |
| 1726 | return true; |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | bool CgalKernel::process_as_2d_polygon(const std::list<std::list<std::pair<const IfcUtil::IfcBaseClass*, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) { |