mirror of https://github.com/CGAL/cgal
Create a vertex property map that will contain sizing info (WIP)
Also, update target length checks
This commit is contained in:
parent
7326fb52ce
commit
5c4e6ed7b5
|
|
@ -20,8 +20,8 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
const std::pair<double, double> edge_min_max{0.1, 0.4};
|
||||
const double tol = 0.1;
|
||||
//todo ip - update
|
||||
const std::pair<double, double> edge_min_max{0.1, 0.12};
|
||||
unsigned int nb_iter = 3;
|
||||
|
||||
std::cout << "Start remeshing of " << filename
|
||||
|
|
@ -30,7 +30,6 @@ int main(int argc, char* argv[])
|
|||
PMP::isotropic_remeshing(
|
||||
faces(mesh),
|
||||
edge_min_max,
|
||||
tol,
|
||||
mesh,
|
||||
PMP::parameters::number_of_iterations(nb_iter)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,17 +34,22 @@ public:
|
|||
typedef typename Base::Point_3 Point_3;
|
||||
typedef typename Base::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename Base::vertex_descriptor vertex_descriptor;
|
||||
typedef typename CGAL::dynamic_vertex_property_t<FT> Vertex_property_tag;
|
||||
typedef typename boost::property_map<PolygonMesh,
|
||||
Vertex_property_tag>::type VertexSizingMap;
|
||||
|
||||
Adaptive_sizing_field(const std::pair<FT, FT>& edge_len_min_max
|
||||
, const FT& tolerance
|
||||
, const PolygonMesh& pmesh)
|
||||
Adaptive_sizing_field(const std::pair<FT, FT>& edge_len_min_max
|
||||
, PolygonMesh& pmesh)
|
||||
: m_sq_short( CGAL::square(edge_len_min_max.first))
|
||||
, m_sq_long( CGAL::square(edge_len_min_max.second))
|
||||
, tol(tolerance)
|
||||
, m_pmesh(pmesh)
|
||||
{
|
||||
// calculate and store curvature and sizing field here in constructor?
|
||||
// todo what about updating it?
|
||||
//todo ip: initialize sizing map with default values
|
||||
//todo ip: might end up using directly the property map of the curvature calculation (if mutable)?
|
||||
vertex_sizing_map_ = get(Vertex_property_tag(), m_pmesh);
|
||||
for(vertex_descriptor v : vertices(m_pmesh)){
|
||||
put(vertex_sizing_map_, v, m_sq_long);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -62,10 +67,24 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void calc_sizing_map()
|
||||
{
|
||||
//todo ip
|
||||
// calculate curvature
|
||||
|
||||
// loop over curvature property field and calculate the target mesh size for a vertex
|
||||
// don't forget to store squared length
|
||||
|
||||
}
|
||||
|
||||
boost::optional<FT> is_too_long(const halfedge_descriptor& h) const
|
||||
{
|
||||
const FT sqlen = sqlength(h);
|
||||
if(sqlen > m_sq_long)
|
||||
FT sqtarg_len = std::min(get(vertex_sizing_map_, source(h, m_pmesh)),
|
||||
get(vertex_sizing_map_, target(h, m_pmesh)));
|
||||
CGAL_assertion(get(vertex_sizing_map_, source(h, m_pmesh)));
|
||||
CGAL_assertion(get(vertex_sizing_map_, target(h, m_pmesh)));
|
||||
if(sqlen > sqtarg_len)
|
||||
return sqlen;
|
||||
else
|
||||
return boost::none;
|
||||
|
|
@ -75,7 +94,11 @@ public:
|
|||
const vertex_descriptor& vb) const
|
||||
{
|
||||
const FT sqlen = sqlength(va, vb);
|
||||
if (sqlen > m_sq_long)
|
||||
FT sqtarg_len = std::min(get(vertex_sizing_map_, va),
|
||||
get(vertex_sizing_map_, vb));
|
||||
CGAL_assertion(get(vertex_sizing_map_, va));
|
||||
CGAL_assertion(get(vertex_sizing_map_, vb));
|
||||
if (sqlen > sqtarg_len)
|
||||
return sqlen;
|
||||
else
|
||||
return boost::none;
|
||||
|
|
@ -84,7 +107,11 @@ public:
|
|||
boost::optional<FT> is_too_short(const halfedge_descriptor& h) const
|
||||
{
|
||||
const FT sqlen = sqlength(h);
|
||||
if (sqlen < m_sq_long)
|
||||
FT sqtarg_len = std::min(get(vertex_sizing_map_, source(h, m_pmesh)),
|
||||
get(vertex_sizing_map_, target(h, m_pmesh)));
|
||||
CGAL_assertion(get(vertex_sizing_map_, source(h, m_pmesh)));
|
||||
CGAL_assertion(get(vertex_sizing_map_, target(h, m_pmesh)));
|
||||
if (sqlen < sqtarg_len)
|
||||
return sqlen;
|
||||
else
|
||||
return boost::none;
|
||||
|
|
@ -98,12 +125,18 @@ public:
|
|||
get(vpmap, source(h, m_pmesh)));
|
||||
}
|
||||
|
||||
void update_sizing_map(const vertex_descriptor& vnew)
|
||||
{
|
||||
//todo ip: calculate curvature for the vertex
|
||||
//dummy
|
||||
put(vertex_sizing_map_, vnew, m_sq_short);
|
||||
}
|
||||
|
||||
private:
|
||||
FT m_sq_short;
|
||||
FT m_sq_long;
|
||||
FT tol;
|
||||
const PolygonMesh& m_pmesh;
|
||||
//todo add property map containing sizing field form m_pmesh here
|
||||
PolygonMesh& m_pmesh;
|
||||
VertexSizingMap vertex_sizing_map_;
|
||||
};
|
||||
|
||||
}//end namespace Polygon_mesh_processing
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ public:
|
|||
get(vpmap, source(h, m_pmesh)));
|
||||
}
|
||||
|
||||
void update_sizing_map(const vertex_descriptor& vnew) const {} //todo ip- rewrite to remove this?
|
||||
|
||||
private:
|
||||
FT m_sq_short;
|
||||
FT m_sq_long;
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ namespace internal {
|
|||
//if an edge is longer than the given threshold `high`, the edge
|
||||
//is split at its midpoint and the two adjacent triangles are bisected (2-4 split)"
|
||||
template<typename SizingFunction>
|
||||
void split_long_edges(const SizingFunction& sizing)
|
||||
void split_long_edges(SizingFunction& sizing)
|
||||
{
|
||||
#ifdef CGAL_PMP_REMESHING_VERBOSE
|
||||
std::cout << "Split long edges..." << std::endl;
|
||||
|
|
@ -536,6 +536,8 @@ namespace internal {
|
|||
//move refinement point
|
||||
vertex_descriptor vnew = target(hnew, mesh_);
|
||||
put(vpmap_, vnew, refinement_point);
|
||||
//todo ip-add
|
||||
sizing.update_sizing_map(vnew);
|
||||
#ifdef CGAL_PMP_REMESHING_VERY_VERBOSE
|
||||
std::cout << " Refinement point : " << refinement_point << std::endl;
|
||||
#endif
|
||||
|
|
@ -1080,6 +1082,7 @@ namespace internal {
|
|||
|
||||
Point proj = trees[patch_id_to_index_map[get_patch_id(face(halfedge(v, mesh_), mesh_))]]->closest_point(get(vpmap_, v));
|
||||
put(vpmap_, v, proj);
|
||||
//todo ip - also update sizing field here?
|
||||
}
|
||||
CGAL_assertion(!input_mesh_is_valid_ || is_valid_polygon_mesh(mesh_));
|
||||
#ifdef CGAL_PMP_REMESHING_DEBUG
|
||||
|
|
@ -1108,6 +1111,7 @@ namespace internal {
|
|||
continue;
|
||||
//note if v is constrained, it has not moved
|
||||
put(vpmap_, v, proj(v));
|
||||
//todo ip: also update sizing field here?
|
||||
}
|
||||
CGAL_assertion(is_valid(mesh_));
|
||||
#ifdef CGAL_PMP_REMESHING_DEBUG
|
||||
|
|
@ -2010,6 +2014,7 @@ private:
|
|||
VertexIsConstrainedMap vcmap_;
|
||||
FaceIndexMap fimap_;
|
||||
CGAL_assertion_code(bool input_mesh_is_valid_;)
|
||||
//todo ip: maybe make sizing field member (reference) here? easier to handle updates
|
||||
|
||||
};//end class Incremental_remesher
|
||||
}//end namespace internal
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ template<typename PolygonMesh
|
|||
, typename SizingFunction
|
||||
, typename NamedParameters>
|
||||
void isotropic_remeshing(const FaceRange& faces
|
||||
, const SizingFunction& sizing
|
||||
, SizingFunction& sizing
|
||||
, PolygonMesh& pmesh
|
||||
, const NamedParameters& np);
|
||||
|
||||
|
|
@ -224,14 +224,14 @@ template<typename PolygonMesh
|
|||
, typename NamedParameters = parameters::Default_named_parameters>
|
||||
void isotropic_remeshing(const FaceRange& faces
|
||||
, const std::pair<double, double>& edge_len_min_max //todo add defaults?
|
||||
, const double& tolerance //todo add defaults?
|
||||
, PolygonMesh& pmesh
|
||||
, const NamedParameters& np = parameters::default_values())
|
||||
{
|
||||
typedef Adaptive_sizing_field<PolygonMesh> Adaptive_sizing;
|
||||
Adaptive_sizing sizing(edge_len_min_max, pmesh);
|
||||
isotropic_remeshing<PolygonMesh, FaceRange, Adaptive_sizing, NamedParameters>(
|
||||
faces,
|
||||
Adaptive_sizing(edge_len_min_max, tolerance, pmesh),
|
||||
sizing,
|
||||
pmesh,
|
||||
np);
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ template<typename PolygonMesh
|
|||
, typename SizingFunction
|
||||
, typename NamedParameters>
|
||||
void isotropic_remeshing(const FaceRange& faces
|
||||
, const SizingFunction& sizing
|
||||
, SizingFunction& sizing
|
||||
, PolygonMesh& pmesh
|
||||
, const NamedParameters& np)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue