Skip to content

Commit

Permalink
repairing EPECK support in KSP
Browse files Browse the repository at this point in the history
  • Loading branch information
soesau committed Feb 24, 2025
1 parent 4f9bf70 commit 24a3112
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 32 deletions.
8 changes: 0 additions & 8 deletions Kinetic_space_partition/include/CGAL/KSP/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,6 @@ void dump_polygon(const std::vector<typename K::Point_3>& pts, const std::string
saver.export_polygon_soup_3(pts2, filename);
}

void dump_polygon(const std::vector<CGAL::Epick::Point_3>& pts, const std::string& filename) {
Saver<CGAL::Epick> saver;
std::vector<std::vector<CGAL::Epick::Point_3> > pts2;
pts2.push_back(pts);

saver.export_polygon_soup_3(pts2, filename);
}

void dump_polygona(const std::vector<CGAL::Epick::Point_3>& pts, const std::string& filename) {
Saver<CGAL::Epick> saver;
std::vector<std::vector<CGAL::Epick::Point_3> > pts2;
Expand Down
12 changes: 7 additions & 5 deletions Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class Data_structure {
}
};

// ToDo:: check all kind of iterators/circulators
using PEdge_around_pvertex_iterator = boost::transform_iterator<Halfedge_to_pedge, CGAL::Halfedge_around_target_iterator<Mesh> >;
using PEdges_around_pvertex = CGAL::Iterator_range<PEdge_around_pvertex_iterator>;

Expand Down Expand Up @@ -1390,16 +1389,19 @@ class Data_structure {
return support_plane(support_plane_idx).to_2d(segment_3);
}

/*
IkSegment_2 to_2d(const std::size_t support_plane_idx, const IkSegment_3& segment_3) const {
template <class IK = Intersection_kernel>
auto to_2d(const std::size_t support_plane_idx, const IkSegment_3& segment_3) const
-> std::enable_if_t<!std::is_same_v<Kernel, IK>, IkSegment_2> {
return support_plane(support_plane_idx).to_2d(segment_3);
}*/
}

Point_2 to_2d(const std::size_t support_plane_idx, const Point_3& point_3) const {
return support_plane(support_plane_idx).to_2d(point_3);
}

IkPoint_2 to_2d(const std::size_t support_plane_idx, const IkPoint_3& point_3) const {
template <class IK = Intersection_kernel>
auto to_2d(const std::size_t support_plane_idx, const IkPoint_3& point_3) const
-> std::enable_if_t<!std::is_same_v<Kernel, IK>, IkPoint_2> {
return support_plane(support_plane_idx).to_2d(point_3);
}

Expand Down
4 changes: 2 additions & 2 deletions Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class Initializer {

typename Intersection_graph::Kinetic_interval& kinetic_interval = m_data.igraph().kinetic_interval(e, sp_idx);
crossing_iedges.push_back(e);
if (emin > s || std::isinf(min_speed)) {
if (emin > s || std::isinf(CGAL::to_double(min_speed))) {
typename Intersection_kernel::FT bary_edge_exact = (emin - s) / (t - s);
FT bary_edge = from_exact((emin - s) / (t - s));
CGAL_assertion(bary_edge_exact >= 0);
Expand All @@ -505,7 +505,7 @@ class Initializer {
kinetic_interval.push_back(std::pair<FT, FT>(0, 0));
}

if (t > emax || std::isinf(max_speed)) {
if (t > emax || std::isinf(CGAL::to_double(max_speed))) {
typename Intersection_kernel::FT bary_edge_exact = (emax - s) / (t - s);
FT bary_edge = from_exact((emax - s) / (t - s));
CGAL_assertion(0 <= bary_edge_exact && bary_edge_exact <= 1);
Expand Down
28 changes: 13 additions & 15 deletions Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Support_plane {
for (const auto& pair : points) {
const auto& point = pair.first;
directions.push_back(typename Intersection_kernel::Vector_2(to_exact(m_data->centroid), point));
const FT length = CGAL::sqrt(CGAL::abs(from_exact(directions.back() * directions.back())));
const FT length = CGAL::approximate_sqrt(CGAL::abs(from_exact(directions.back() * directions.back())));
sum_length += length;
num += 1;
}
Expand Down Expand Up @@ -676,8 +676,9 @@ class Support_plane {
m_data->plane.to_2d(Point_3(0, 0, 0) + vec));
}

template<typename = typename std::enable_if<identical_kernel>::type >
const typename Intersection_kernel::Point_2 to_2d(const typename Intersection_kernel::Point_3& point) const {
template<class IK = Intersection_kernel>
auto to_2d(const typename Intersection_kernel::Point_3& point) const
->std::enable_if_t<!std::is_same_v<Kernel, IK>, const typename Intersection_kernel::Point_2> {
return m_data->exact_plane.to_2d(point);
}

Expand All @@ -687,8 +688,9 @@ class Support_plane {
m_data->plane.to_2d(line.point() + line.to_vector()));
}

template<typename = typename std::enable_if<identical_kernel>::type >
const typename Intersection_kernel::Line_2 to_2d(const typename Intersection_kernel::Line_3& line) const {
template <typename IK = Intersection_kernel>
auto to_2d(const typename Intersection_kernel::Line_3& line) const
-> std::enable_if_t<!std::is_same_v<Kernel, IK>, const typename Intersection_kernel::Line_2> {
return typename Intersection_kernel::Line_2(
m_data->exact_plane.to_2d(line.point()),
m_data->exact_plane.to_2d(line.point() + line.to_vector()));
Expand All @@ -700,25 +702,21 @@ class Support_plane {
m_data->plane.to_2d(segment.target()));
}

template<typename = typename std::enable_if<identical_kernel>::type >
const typename Intersection_kernel::Segment_2 to_2d(const typename Intersection_kernel::Segment_3& segment) const {
template <typename IK = Intersection_kernel>
auto to_2d(const typename Intersection_kernel::Segment_3& segment) const
-> std::enable_if_t<!std::is_same_v<Kernel, IK>, const typename Intersection_kernel::Segment_2> {
return typename Intersection_kernel::Segment_2(
m_data->exact_plane.to_2d(segment.source()),
m_data->exact_plane.to_2d(segment.target()));
}

const Vector_3 to_3d(const Vector_2& vec) const {
return Vector_3(
m_data->plane.to_3d(Point_2(FT(0), FT(0))),
m_data->plane.to_3d(Point_2(FT(0), FT(0)) + vec));
}

const Point_3 to_3d(const Point_2& point) const {
return m_data->plane.to_3d(point);
}

template<typename = typename std::enable_if<identical_kernel>::type >
const typename Intersection_kernel::Point_3 to_3d(const typename Intersection_kernel::Point_2& point) const {
template <typename IK = Intersection_kernel>
auto to_3d(const typename Intersection_kernel::Point_2& point) const
->std::enable_if_t<!std::is_same_v<Kernel, IK>, const typename Intersection_kernel::Point_3> {
return m_data->exact_plane.to_3d(point);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ class Kinetic_space_partition_3 {
using NP_helper = Point_set_processing_3_np_helper<PointRange, NamedParameters>;
using PointMap = typename NP_helper::Point_map;

static_assert(std::is_same_v<typename NP_helper::Geom_traits, Kernel>);

PointMap point_map = NP_helper::get_point_map(np);

To_exact to_exact;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ class Kinetic_surface_reconstruction_3 {
n = m_lcc.beta(n, 1);
} while (n != dh);

KSP_3::internal::dump_polygon(face, fn);
KSP_3::internal::dump_polygon<Kernel>(face, fn);
}

void write_edge(typename LCC::Dart_descriptor dh, const std::string& fn) {
Expand Down Expand Up @@ -1707,7 +1707,7 @@ class Kinetic_surface_reconstruction_3 {
m_face_area_lcc.resize(m_faces_lcc.size(), 0);

for (std::size_t i = 0; i < m_faces_lcc.size(); i++)
m_face_area_lcc[i] = m_face_area_lcc[i] * 2.0 * m_total_inliers / total_area;
m_face_area_lcc[i] = m_face_area_lcc[i] * FT(2.0) * FT(m_total_inliers) / total_area;
}

FT area(typename LCC::Dart_descriptor face_dart, Plane_3 &pl, std::vector<typename Kernel::Triangle_3> *tris = nullptr) {
Expand Down

0 comments on commit 24a3112

Please sign in to comment.