mirror of https://github.com/CGAL/cgal
Move sizing map calculation to constructor
This commit is contained in:
parent
573cc53e0a
commit
1c597a07cf
|
|
@ -28,7 +28,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
const double tol = 0.001;
|
const double tol = 0.001;
|
||||||
const std::pair edge_min_max{0.001, 0.5};
|
const std::pair edge_min_max{0.001, 0.5};
|
||||||
PMP::Adaptive_sizing_field sizing_field(tol, edge_min_max, mesh);
|
PMP::Adaptive_sizing_field sizing_field(tol, edge_min_max, faces(mesh), mesh);
|
||||||
unsigned int nb_iter = 5;
|
unsigned int nb_iter = 5;
|
||||||
|
|
||||||
PMP::isotropic_remeshing(
|
PMP::isotropic_remeshing(
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,10 @@ public:
|
||||||
typedef typename boost::property_map<PolygonMesh,
|
typedef typename boost::property_map<PolygonMesh,
|
||||||
Vertex_property_tag>::type Vertex_sizing_map;
|
Vertex_property_tag>::type Vertex_sizing_map;
|
||||||
|
|
||||||
|
template <typename FaceRange>
|
||||||
Adaptive_sizing_field(const double tol
|
Adaptive_sizing_field(const double tol
|
||||||
, const std::pair<FT, FT>& edge_len_min_max
|
, const std::pair<FT, FT>& edge_len_min_max
|
||||||
|
, const FaceRange& face_range
|
||||||
, PolygonMesh& pmesh)
|
, PolygonMesh& pmesh)
|
||||||
: tol(tol)
|
: tol(tol)
|
||||||
, m_short(edge_len_min_max.first)
|
, m_short(edge_len_min_max.first)
|
||||||
|
|
@ -52,31 +54,7 @@ public:
|
||||||
, m_pmesh(pmesh)
|
, m_pmesh(pmesh)
|
||||||
{
|
{
|
||||||
m_vertex_sizing_map = get(Vertex_property_tag(), m_pmesh);
|
m_vertex_sizing_map = get(Vertex_property_tag(), m_pmesh);
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
FT sqlength(const vertex_descriptor va,
|
|
||||||
const vertex_descriptor vb) const
|
|
||||||
{
|
|
||||||
typename boost::property_map<PolygonMesh, CGAL::vertex_point_t>::const_type
|
|
||||||
vpmap = get(CGAL::vertex_point, m_pmesh);
|
|
||||||
return FT(CGAL::squared_distance(get(vpmap, va), get(vpmap, vb)));
|
|
||||||
}
|
|
||||||
|
|
||||||
FT sqlength(const halfedge_descriptor& h) const
|
|
||||||
{
|
|
||||||
return sqlength(target(h, m_pmesh), source(h, m_pmesh));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
FT get_sizing(const vertex_descriptor v) const {
|
|
||||||
CGAL_assertion(get(m_vertex_sizing_map, v));
|
|
||||||
return get(m_vertex_sizing_map, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FaceRange>
|
|
||||||
void calc_sizing_map(const FaceRange& face_range)
|
|
||||||
{
|
|
||||||
if (face_range.size() == faces(m_pmesh).size())
|
if (face_range.size() == faces(m_pmesh).size())
|
||||||
{
|
{
|
||||||
// calculate curvature from the whole mesh
|
// calculate curvature from the whole mesh
|
||||||
|
|
@ -97,6 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
template <typename FaceGraph>
|
template <typename FaceGraph>
|
||||||
void calc_sizing_map(FaceGraph& face_graph)
|
void calc_sizing_map(FaceGraph& face_graph)
|
||||||
{
|
{
|
||||||
|
|
@ -151,6 +130,48 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FT sqlength(const vertex_descriptor va,
|
||||||
|
const vertex_descriptor vb) const
|
||||||
|
{
|
||||||
|
typename boost::property_map<PolygonMesh, CGAL::vertex_point_t>::const_type
|
||||||
|
vpmap = get(CGAL::vertex_point, m_pmesh);
|
||||||
|
return FT(CGAL::squared_distance(get(vpmap, va), get(vpmap, vb)));
|
||||||
|
}
|
||||||
|
|
||||||
|
FT sqlength(const halfedge_descriptor& h) const
|
||||||
|
{
|
||||||
|
return sqlength(target(h, m_pmesh), source(h, m_pmesh));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
FT get_sizing(const vertex_descriptor v) const {
|
||||||
|
CGAL_assertion(get(m_vertex_sizing_map, v));
|
||||||
|
return get(m_vertex_sizing_map, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FaceRange>
|
||||||
|
void calc_sizing_map(const FaceRange& face_range)
|
||||||
|
{
|
||||||
|
if (face_range.size() == faces(m_pmesh).size())
|
||||||
|
{
|
||||||
|
// calculate curvature from the whole mesh
|
||||||
|
calc_sizing_map(m_pmesh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// expand face selection and calculate curvature from it
|
||||||
|
std::vector<face_descriptor> selection(face_range.begin(), face_range.end());
|
||||||
|
auto is_selected = get(CGAL::dynamic_face_property_t<bool>(), m_pmesh);
|
||||||
|
for (face_descriptor f : faces(m_pmesh)) put(is_selected, f, false);
|
||||||
|
for (face_descriptor f : face_range) put(is_selected, f, true);
|
||||||
|
CGAL::expand_face_selection(selection, m_pmesh, 1
|
||||||
|
, is_selected, std::back_inserter(selection));
|
||||||
|
CGAL::Face_filtered_graph<PolygonMesh> ffg(m_pmesh, selection);
|
||||||
|
|
||||||
|
calc_sizing_map(ffg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boost::optional<FT> is_too_long(const halfedge_descriptor h) const
|
boost::optional<FT> is_too_long(const halfedge_descriptor h) const
|
||||||
{
|
{
|
||||||
const FT sqlen = sqlength(h);
|
const FT sqlen = sqlength(h);
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ namespace internal {
|
||||||
halfedge_added(hnew_opp, status(opposite(he, mesh_)));
|
halfedge_added(hnew_opp, status(opposite(he, mesh_)));
|
||||||
|
|
||||||
//todo ip-add: already updating sizing here because of is_too_long checks below
|
//todo ip-add: already updating sizing here because of is_too_long checks below
|
||||||
if constexpr (!std::is_same<SizingFunction, Uniform_sizing_field<PM>>::value)
|
if constexpr (!std::is_same_v<SizingFunction, Uniform_sizing_field<PM>>)
|
||||||
sizing.update_sizing_map(vnew);
|
sizing.update_sizing_map(vnew);
|
||||||
|
|
||||||
//check sub-edges
|
//check sub-edges
|
||||||
|
|
|
||||||
|
|
@ -334,18 +334,12 @@ void isotropic_remeshing(const FaceRange& faces
|
||||||
t.reset(); t.start();
|
t.reset(); t.start();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//todo ip: move calc_sizing_map to the sizing function constructor
|
|
||||||
if constexpr (!std::is_same<SizingFunction, Uniform_sizing_field<PM>>::value)
|
|
||||||
sizing.calc_sizing_map(faces);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nb_iterations; ++i)
|
for (unsigned int i = 0; i < nb_iterations; ++i)
|
||||||
{
|
{
|
||||||
#ifdef CGAL_PMP_REMESHING_VERBOSE
|
#ifdef CGAL_PMP_REMESHING_VERBOSE
|
||||||
std::cout << " * Iteration " << (i + 1) << " *" << std::endl;
|
std::cout << " * Iteration " << (i + 1) << " *" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if (i < 2)
|
|
||||||
// sizing.calc_sizing_map();
|
|
||||||
if(do_split)
|
if(do_split)
|
||||||
remesher.split_long_edges(sizing);
|
remesher.split_long_edges(sizing);
|
||||||
if(do_collapse)
|
if(do_collapse)
|
||||||
|
|
|
||||||
|
|
@ -491,6 +491,7 @@ public Q_SLOTS:
|
||||||
std::pair<double, double> edge_min_max{min_length, max_length};
|
std::pair<double, double> edge_min_max{min_length, max_length};
|
||||||
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
||||||
, edge_min_max
|
, edge_min_max
|
||||||
|
, faces(*selection_item->polyhedron())
|
||||||
, *selection_item->polyhedron());
|
, *selection_item->polyhedron());
|
||||||
if (fpmap_valid)
|
if (fpmap_valid)
|
||||||
CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(*selection_item->polyhedron())
|
CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(*selection_item->polyhedron())
|
||||||
|
|
@ -573,6 +574,7 @@ public Q_SLOTS:
|
||||||
std::pair<double, double> edge_min_max{min_length, max_length};
|
std::pair<double, double> edge_min_max{min_length, max_length};
|
||||||
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
||||||
, edge_min_max
|
, edge_min_max
|
||||||
|
, faces(*selection_item->polyhedron())
|
||||||
, *selection_item->polyhedron());
|
, *selection_item->polyhedron());
|
||||||
if (fpmap_valid)
|
if (fpmap_valid)
|
||||||
CGAL::Polygon_mesh_processing::isotropic_remeshing(selection_item->selected_facets
|
CGAL::Polygon_mesh_processing::isotropic_remeshing(selection_item->selected_facets
|
||||||
|
|
@ -732,6 +734,7 @@ public Q_SLOTS:
|
||||||
std::pair<double, double> edge_min_max{min_length, max_length};
|
std::pair<double, double> edge_min_max{min_length, max_length};
|
||||||
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol
|
||||||
, edge_min_max
|
, edge_min_max
|
||||||
|
, faces(*poly_item->polyhedron())
|
||||||
, *poly_item->polyhedron());
|
, *poly_item->polyhedron());
|
||||||
if (fpmap_valid)
|
if (fpmap_valid)
|
||||||
CGAL::Polygon_mesh_processing::isotropic_remeshing(
|
CGAL::Polygon_mesh_processing::isotropic_remeshing(
|
||||||
|
|
@ -985,6 +988,7 @@ private:
|
||||||
std::pair<double, double> edge_min_max{min_length_, max_length_};
|
std::pair<double, double> edge_min_max{min_length_, max_length_};
|
||||||
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol_
|
PMP::Adaptive_sizing_field adaptive_sizing_field(error_tol_
|
||||||
, edge_min_max
|
, edge_min_max
|
||||||
|
, faces(*poly_item->polyhedron())
|
||||||
, *poly_item->polyhedron());
|
, *poly_item->polyhedron());
|
||||||
CGAL::Polygon_mesh_processing::isotropic_remeshing(
|
CGAL::Polygon_mesh_processing::isotropic_remeshing(
|
||||||
faces(*poly_item->polyhedron())
|
faces(*poly_item->polyhedron())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue