Skip to content

Instantly share code, notes, and snippets.

@MaelRL
Created October 30, 2023 15:27
Show Gist options
  • Save MaelRL/ddb3db8a2ddd7ae5319e68655f255bdd to your computer and use it in GitHub Desktop.
Save MaelRL/ddb3db8a2ddd7ae5319e68655f255bdd to your computer and use it in GitHub Desktop.
diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_3.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_3.h
index 94694034cdd..66956bebdd2 100644
--- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_3.h
+++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_3.h
@@ -240,6 +240,36 @@ private:
return c->circumcenter(geom_traits());
}
+ bool do_intersect(const Cell_handle c) const
+ {
+ if(c->domain_intersection != Domain_intersection::UNKNOWN)
+ {
+ std::cout << "cached do_intersect" << std::endl;
+ return (c->domain_intersection == Domain_intersection::YES);
+ }
+
+ bool res = m_oracle.do_intersect(Tetrahedron_with_outside_info<Geom_traits>(c, geom_traits()));
+ c->domain_intersection = (res ? Domain_intersection::YES : Domain_intersection::NO);
+ return res;
+ }
+
+ bool is_CC_in_offset(const Cell_handle c) const
+ {
+ if(c->is_cc_in_offset != Is_CC_in_offset::UNKNOWN)
+ {
+ std::cout << "cached is_CC_in" << std::endl;
+ return (c->is_cc_in_offset == Is_CC_in_offset::YES);
+ }
+
+ const Point_3& cc = circumcenter(c);
+ typename Geom_traits::Construct_ball_3 ball = geom_traits().construct_ball_3_object();
+ const Ball_3 cc_offset_ball = ball(cc, m_sq_offset);
+ const bool res = m_oracle.do_intersect(cc_offset_ball);
+ c->is_cc_in_offset = (res ? Is_CC_in_offset::YES : Is_CC_in_offset::NO);
+
+ return res;
+ }
+
public:
template <typename OutputMesh,
typename InputNamedParameters = parameters::Default_named_parameters,
@@ -466,16 +496,10 @@ private:
{
CGAL_precondition(!m_tr.is_infinite(ch));
- const Tetrahedron_with_outside_info<Geom_traits> tet(ch, geom_traits());
- if(m_oracle.do_intersect(tet))
+ if(do_intersect(ch))
return Cell_label::INSIDE;
- const Point_3& ch_cc = circumcenter(ch);
- typename Geom_traits::Construct_ball_3 ball = geom_traits().construct_ball_3_object();
- const Ball_3 ch_cc_offset_ball = ball(ch_cc, m_sq_offset);
- const bool is_cc_in_offset = m_oracle.do_intersect(ch_cc_offset_ball);
-
- return is_cc_in_offset ? Cell_label::INSIDE : Cell_label::OUTSIDE;
+ return is_CC_in_offset(ch) ? Cell_label::INSIDE : Cell_label::OUTSIDE;
}
// Create a cavity using seeds rather than starting from the infinity.
@@ -902,8 +926,7 @@ private:
typename Geom_traits::Construct_scaled_vector_3 scale = geom_traits().construct_scaled_vector_3_object();
const Point_3& neighbor_cc = circumcenter(neighbor);
- const Ball_3 neighbor_cc_offset_ball = ball(neighbor_cc, m_sq_offset);
- const bool is_neighbor_cc_in_offset = m_oracle.do_intersect(neighbor_cc_offset_ball);
+ const bool is_neighbor_cc_in_offset = is_CC_in_offset(neighbor);
#ifdef CGAL_AW3_DEBUG_STEINER_COMPUTATION
std::cout << "Compute_steiner_point(" << &*ch << ", " << &*neighbor << ")" << std::endl;
@@ -948,8 +971,7 @@ private:
}
}
- Tetrahedron_with_outside_info<Geom_traits> tet(neighbor, geom_traits());
- if(m_oracle.do_intersect(tet))
+ if(do_intersect(neighbor))
{
// steiner point is the closest point on input from cell centroid with offset
const Point_3 closest_pt = m_oracle.closest_point(neighbor_cc);
diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_triangulation_cell_base_3.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_triangulation_cell_base_3.h
index efaeb82d330..1a80c1c6384 100644
--- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_triangulation_cell_base_3.h
+++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Alpha_wrap_triangulation_cell_base_3.h
@@ -30,6 +30,21 @@ enum class Cell_label
MANIFOLD
};
+enum class Domain_intersection
+{
+ UNKNOWN,
+ YES,
+ NO
+};
+
+enum class Is_CC_in_offset
+{
+ UNKNOWN,
+ YES,
+ NO
+};
+
+
template < typename GT,
typename Cb = CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<GT> >
class Alpha_wrap_triangulation_cell_base_3
@@ -72,6 +87,9 @@ public:
{}
public:
+ Domain_intersection domain_intersection = Domain_intersection::UNKNOWN;
+ Is_CC_in_offset is_cc_in_offset = Is_CC_in_offset::UNKNOWN;
+
Cell_label label() const { return m_label; }
void set_label(const Cell_label label) { m_label = label; }
bool is_inside() const { return m_label == Cell_label::INSIDE; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment