Clean SMS code (whitespace, indentation, variable names, clumsy for loops, etc)

This commit is contained in:
Mael Rouxel-Labbé 2019-05-09 09:31:35 +02:00
parent 4747f8ccaf
commit 6d8d0b564c
29 changed files with 579 additions and 633 deletions

View File

@ -10,14 +10,14 @@ which returns `true` when the relation between the initial and current number of
\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts.
\cgalModels `StopPredicate`
\sa `CGAL::Surface_mesh_simplification::Count_stop_predicate<TriangleMesh>`
*/
template< typename TriangleMesh >
class Count_ratio_stop_predicate {
class Count_ratio_stop_predicate
{
public:
/// \name Creation
@ -37,11 +37,10 @@ Count_ratio_stop_predicate<TriangleMesh>(double ratio);
Returns ` (((double)current_count / (double)initial_count) < ratio)`.
All other parameters are ignored (but exist since this is a generic policy).
*/
bool operator()(FT const& current_cost
, const Profile& edge_profile
, size_type initial_count
, size_type current_count
) const;
bool operator()(const FT& current_cost,
const Profile& edge_profile,
size_type initial_count,
size_type current_count) const;
/// @}

View File

@ -1,4 +1,3 @@
namespace CGAL {
namespace Surface_mesh_simplification {
@ -35,11 +34,10 @@ Count_stop_predicate<TriangleMesh>(size_type threshold);
/*!
Returns `(current_count < threshold)`. All other parameters are ignored (but exist since this is a generic policy).
*/
bool operator()(FT const& current_cost
, const Profile& edge_profile
, size_type initial_count
, size_type current_count
) const;
bool operator()(const FT& current_cost,
const Profile& edge_profile,
size_type initial_count,
size_type current_count) const;
/// @}

View File

@ -1,4 +1,3 @@
namespace CGAL {
namespace Surface_mesh_simplification {
@ -10,12 +9,12 @@ which computes the collapse cost as the squared length of the edge.
\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts.
\cgalModels `GetCost`
*/
template< typename TriangleMesh >
class Edge_length_cost {
class Edge_length_cost
{
public:
/// \name Creation
@ -39,8 +38,8 @@ The `placement` argument is ignored.
*/
template <typename Profile, typename T>
optional<typename Profile::FT> operator()(const Profile& profile
, T const& placement) const;
optional<typename Profile::FT> operator()(const Profile& profile,
const T& placement) const;
/// @}

View File

@ -15,7 +15,8 @@ This predicate is meant to be used with `Edge_length_cost`.
*/
template< typename FT >
class Edge_length_stop_predicate {
class Edge_length_stop_predicate
{
public:
/// \name Creation
@ -35,11 +36,10 @@ Edge_length_stop_predicate<TriangleMesh>(FT threshold);
Returns `(CGAL::squared_distance(edge_profile.p0(),edge_profile.p1()) > threshold*threshold)`.
All other parameters are ignored (but exist since this is a generic policy).
*/
bool operator()(FT const&
, const Profile& edge_profile
, size_type
, size_type
) const;
bool operator()(const FT&,
const Profile& edge_profile,
size_type,
size_type) const;
/// @}

View File

@ -1,4 +1,3 @@
namespace CGAL {
namespace Surface_mesh_simplification {
/*!
@ -26,7 +25,7 @@ public:
Initializes the policy with the given <I>weighting unit factor</I>.
See \ref SurfaceMeshSimplificationLindstromTurkStrategy for details on the meaning of this factor.
*/
LindstromTurk_cost<TriangleMesh>(FT const& factor = FT(0.5));
LindstromTurk_cost<TriangleMesh>(const FT& factor = FT(0.5));
/// @}
@ -39,8 +38,8 @@ the new `placement` computed for it.
*/
template <typename Profile>
optional<typename Profile::FT>
operator()(const Profile& profile
, boost::optional<typename Profile::Point> const& placement) const;
operator()(const Profile& profile,
const boost::optional<typename Profile::Point>& placement) const
/// @}

View File

@ -1,4 +1,3 @@
namespace CGAL {
namespace Surface_mesh_simplification {
@ -28,7 +27,7 @@ public:
Initializes the policy with the given <I>weighting unit factor</I>.
See \ref SurfaceMeshSimplificationLindstromTurkStrategy for details on the meaning of this factor.
*/
LindstromTurk_placement<TriangleMesh>(FT const& factor = FT(0.5));
LindstromTurk_placement<TriangleMesh>(const FT& factor = FT(0.5));
/// @}

View File

@ -1,4 +1,3 @@
/*!
\ingroup PkgSurfaceMeshSimplificationConcepts
\cgalConcept
@ -8,7 +7,6 @@ The concept `EdgeCollapseSimplificationVisitor` describes the requirements for t
The several callbacks given as member functions in the visitor are called from certain places in the algorithm implementation.
*/
class EdgeCollapseSimplificationVisitor {
public:
@ -40,7 +38,6 @@ An integer type representing the number of edges
*/
typedef unspecified_type size_type;
/// @}
/// \name Operations
@ -68,7 +65,8 @@ Called during the <I>collecting phase</I> (when a cost is assigned to the edges)
for each edge collected.
*/
void OnCollected(const Profile& profile, boost::optional<FT> cost);
void OnCollected(const Profile& profile,
boost::optional<FT> cost);
/*!
Called during the <I>processing phase</I> (when edges are collapsed),
@ -85,11 +83,10 @@ the edge will not be collapsed.
the number of edges.
*/
void OnSelected(const Profile& profile
, boost::optional<FT> cost
, size_type initial_count
, size_type current_count
);
void OnSelected(const Profile& profile,
boost::optional<FT> cost,
size_type initial_count,
size_type current_count);
/*!
Called when an edge is about to be collapsed and replaced by a vertex
@ -99,14 +96,14 @@ If `placement` is absent (meaning that it could not be computed)
the edge will not be collapsed.
*/
void OnCollapsing(const Profile& profile
, boost::optional<Point> placement
);
void OnCollapsing(const Profile& profile,
boost::optional<Point> placement);
/*!
Called when an edge has been collapsed and replaced by the vertex `vd`
*/
void OnCollapsed(Profile const&, Profile::const vertex_descriptor vd) {}
void OnCollapsed(const Profile&,
const Profile::vertex_descriptor vd) {}
/*!
Called for each selected edge which cannot be
@ -120,4 +117,3 @@ void OnNonCollapsable(const Profile& profile);
/// @}
}; /* end EdgeCollapseSimplificationVisitor */

View File

@ -1,4 +1,3 @@
/*!
\ingroup PkgSurfaceMeshSimplificationConcepts
\cgalConcept
@ -10,7 +9,6 @@ This profile is used by the stop, cost and placement policies.
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_profile<TriangleMesh>`
*/
class EdgeProfile {
public:
@ -76,12 +74,12 @@ halfedge_descriptor v1_v0() const;
/*!
The point of vertex ` v0`.
*/
Point const& p0() const;
const Point& p0() const;
/*!
The point of vertex ` v1`.
*/
Point const& p1() const;
const Point& p1() const;
/*!
If ` v0v1` belongs to a finite face (is not a border edge)

View File

@ -1,4 +1,3 @@
/*!
\ingroup PkgSurfaceMeshSimplificationConcepts
\cgalConcept
@ -18,11 +17,10 @@ or can be intentionally returned to prevent the edge from being collapsed.
\cgalHasModel `CGAL::Surface_mesh_simplification::LindstromTurk_cost<TriangleMesh>`
*/
class GetCost {
class GetCost
{
public:
/// \name Operations
/// @{
@ -32,8 +30,8 @@ using the calculated placement.
\tparam Profile must be a model of `EdgeProfile`.
*/
template <class Profile>
boost::optional<typename Profile::FT> operator()(const Profile& edge_profile
, boost::optional<typename Profile::Point> const& placement) const;
boost::optional<typename Profile::FT> operator()(const Profile& edge_profile,
const boost::optional<typename Profile::Point>& placement) const;
/// @}

View File

@ -1,4 +1,3 @@
/*!
\ingroup PkgSurfaceMeshSimplificationConcepts
\cgalConcept
@ -10,7 +9,6 @@ The concept `StopPredicate` describes the requirements for the predicate which i
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate<FT>`
*/
class StopPredicate {
public:
@ -55,13 +53,11 @@ If the return value is `true` the simplification terminates before processing th
otherwise it continues normally.
*/
bool operator()(FT const& current_cost
, const Profile& profile
, size_type initial_count
, size_type current_count
) const;
bool operator()(const FT& current_cost,
const Profile& profile,
size_type initial_count,
size_type current_count) const;
/// @}
}; /* end StopPredicate */

View File

@ -36,11 +36,9 @@ struct Constrained_edge_map
: mConstraints(aConstraints)
{}
reference operator[](key_type const& e) const { return is_constrained(e); }
reference operator[](const key_type& e) const { return is_constrained(e); }
bool is_constrained(key_type const& e) const {
return mConstraints.is_defined(e);
}
bool is_constrained(const key_type& e) const { return mConstraints.is_defined(e); }
private:
const CGAL::Unique_hash_map<key_type,bool>& mConstraints;

View File

@ -25,7 +25,6 @@ namespace SMS = CGAL::Surface_mesh_simplification;
typedef SMS::Edge_profile<Surface_mesh> Profile;
// The following is a Visitor that keeps track of the simplification process.
// In this example the progress is printed real-time and a few statistics are
// recorded (and printed in the end).
@ -33,12 +32,8 @@ typedef SMS::Edge_profile<Surface_mesh> Profile;
struct Stats
{
Stats()
: collected(0)
, processed(0)
, collapsed(0)
, non_collapsable(0)
, cost_uncomputable(0)
, placement_uncomputable(0)
: collected(0), processed(0), collapsed(0),
non_collapsable(0), cost_uncomputable(0), placement_uncomputable(0)
{}
std::size_t collected;
@ -54,23 +49,22 @@ struct My_visitor : SMS::Edge_collapse_visitor_base<Surface_mesh>
My_visitor(Stats* s) : stats(s){}
// Called during the collecting phase for each edge collected.
void OnCollected(Profile const&, boost::optional<double> const&)
void OnCollected(const Profile&, const boost::optional<double>&)
{
++ stats->collected;
++(stats->collected);
std::cerr << "\rEdges collected: " << stats->collected << std::flush;
}
// Called during the processing phase for each edge selected.
// If cost is absent the edge won't be collapsed.
void OnSelected(const Profile&
,boost::optional<double> cost
,std::size_t initial
,std::size_t current
)
void OnSelected(const Profile&,
boost::optional<double> cost,
std::size_t initial,
std::size_t current)
{
++ stats->processed;
++(stats->processed);
if(!cost)
++ stats->cost_uncomputable;
++(stats->cost_uncomputable);
if(current == initial)
std::cerr << "\n" << std::flush;
@ -79,39 +73,38 @@ struct My_visitor : SMS::Edge_collapse_visitor_base<Surface_mesh>
// Called during the processing phase for each edge being collapsed.
// If placement is absent the edge is left uncollapsed.
void OnCollapsing(const Profile&
,boost::optional<Point> placement
)
void OnCollapsing(const Profile&,
boost::optional<Point> placement)
{
if(!placement)
++ stats->placement_uncomputable;
++(stats->placement_uncomputable);
}
// Called for each edge which failed the so called link-condition,
// that is, which cannot be collapsed because doing so would
// turn the surface mesh into a non-manifold.
void OnNonCollapsable(Profile const&)
void OnNonCollapsable(const Profile&)
{
++ stats->non_collapsable;
++(stats->non_collapsable);
}
// Called after each edge has been collapsed
void OnCollapsed(Profile const&, vertex_descriptor)
void OnCollapsed(const Profile&, vertex_descriptor)
{
++ stats->collapsed;
++(stats->collapsed);
}
Stats* stats;
};
int main(int argc, char** argv)
{
Surface_mesh surface_mesh;
std::ifstream is(argv[1]);
is >> surface_mesh;
if(!CGAL::is_triangle_mesh(surface_mesh)){
if(!CGAL::is_triangle_mesh(surface_mesh))
{
std::cerr << "Input geometry is not triangulated." << std::endl;
return EXIT_FAILURE;
}
@ -129,11 +122,7 @@ int main(int argc, char** argv)
// On the other hand, we pass here explicit cost and placement
// function which differ from the default policies, ommited in
// the previous example.
int r = SMS::edge_collapse
(surface_mesh
,stop
,CGAL::parameters::visitor(vis)
);
int r = SMS::edge_collapse(surface_mesh, stop, CGAL::parameters::visitor(vis));
std::cout << "\nEdges collected: " << stats.collected
<< "\nEdges proccessed: " << stats.processed

View File

@ -163,7 +163,7 @@ private:
template<class R>
inline
MatrixC33<R> direct_product(Vector_3<R> const& u, Vector_3<R> const& v)
MatrixC33<R> direct_product(const Vector_3<R>& u, const Vector_3<R>& v)
{
return MatrixC33<R>(v * u.x(),
v * u.y(),

View File

@ -18,11 +18,10 @@
// Author(s) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_COLLAPSE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_COLLAPSE_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_EDGE_COLLAPSE_H
#include <CGAL/license/Surface_mesh_simplification.h>
#include <CGAL/Surface_mesh_simplification/Detail/Common.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
#include <CGAL/boost/graph/Euler_operations.h>
@ -245,7 +244,8 @@ private:
std::string edge_to_string(const halfedge_descriptor aEdge) const
{
vertex_descriptor p,q; boost::tie(p,q) = get_vertices(aEdge);
vertex_descriptor p, q;
boost::tie(p,q) = get_vertices(aEdge);
return boost::str(boost::format("{E%1% %2%->%3%}%4%") % get(Edge_index_map, aEdge) % vertex_to_string(p) % vertex_to_string(q) % (is_border(aEdge) ? " (BORDER)" : (is_border(opposite(aEdge, mSurface)) ? " (~BORDER)": "")));
}
@ -947,7 +947,6 @@ are_shared_triangles_valid(const Point& p0, const Point& p1, const Point& p2, co
return rR;
}
// Returns the directed halfedge connecting v0 to v1, if exists.
template<class M, class SP, class VIM, class VPM, class EIM, class ECTM, class CF, class PF, class V>
typename EdgeCollapse<M,SP,VIM,VPM,EIM,ECTM,CF,PF,V>::halfedge_descriptor

View File

@ -75,9 +75,9 @@ public:
Vector n1 = Traits().construct_cross_product_vector_3_object()(eqp,eqr);
Vector n2 = Traits().construct_cross_product_vector_3_object()(eq2p,eq2r);
if(! is_positive(Traits().compute_scalar_product_3_object()(n1, n2))){
if(!is_positive(Traits().compute_scalar_product_3_object()(n1, n2)))
return boost::optional<typename Profile::Point>();
}
++it;
}
}

View File

@ -45,23 +45,18 @@ public:
optional<typename Profile::Point> operator()(const Profile& aProfile) const
{
typedef typename Profile::TM TM;
typedef typename CGAL::Halfedge_around_target_iterator<TM> in_edge_iterator;
typedef typename boost::graph_traits<TM>::halfedge_descriptor halfedge_descriptor;
in_edge_iterator eb, ee;
for(boost::tie(eb,ee) = halfedges_around_target(aProfile.v0(),aProfile.surface_mesh());
eb != ee; ++ eb)
for(halfedge_descriptor h : halfedges_around_target(aProfile.v0(), aProfile.surface_mesh()))
{
if(get(Edge_is_constrained_map, edge(*eb,aProfile.surface_mesh())))
return get(aProfile.vertex_point_map(),
aProfile.v0());
if(get(Edge_is_constrained_map, edge(h, aProfile.surface_mesh())))
return get(aProfile.vertex_point_map(), aProfile.v0());
}
for(boost::tie(eb,ee) = halfedges_around_target(aProfile.v1(),aProfile.surface_mesh());
eb != ee; ++ eb)
for(halfedge_descriptor h : halfedges_around_target(aProfile.v1(), aProfile.surface_mesh()))
{
if(get(Edge_is_constrained_map, edge(*eb,aProfile.surface_mesh())))
return get(aProfile.vertex_point_map(),
aProfile.v1());
if(get(Edge_is_constrained_map, edge(h, aProfile.surface_mesh())))
return get(aProfile.vertex_point_map(), aProfile.v1());
}
return static_cast<const BasePlacement*>(this)->operator()(aProfile);

View File

@ -18,7 +18,7 @@
// Author(s) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H
#include <CGAL/license/Surface_mesh_simplification.h>

View File

@ -18,7 +18,7 @@
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_DETAIL_LINDSTROM_TURK_CORE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_DETAIL_LINDSTROM_TURK_CORE_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_DETAIL_LINDSTROM_TURK_CORE_H
#include <CGAL/license/Surface_mesh_simplification.h>
@ -28,6 +28,7 @@
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_params.h>
#include <limits>
#include <vector>
// This should be in
@ -77,7 +78,7 @@ public:
typedef typename Profile::halfedge_descriptor_vector::const_iterator const_border_edge_iterator;
public:
LindstromTurkCore(Params const& aParams, const Profile& aProfile);
LindstromTurkCore(const Params& aParams, const Profile& aProfile);
Optional_point compute_placement();
Optional_FT compute_cost(const Optional_point& p);
@ -111,12 +112,13 @@ private :
void add_boundary_preservation_constraints(const Boundary_data_vector& aBdry);
void add_volume_preservation_constraints(const Triangle_data_vector& aTriangles);
void add_boundary_and_volume_optimization_constraints(const Boundary_data_vector& aBdry, const Triangle_data_vector& aTriangles);
void add_boundary_and_volume_optimization_constraints(const Boundary_data_vector& aBdry,
const Triangle_data_vector& aTriangles);
void add_shape_optimization_constraints(const vertex_descriptor_vector& aLink);
FT compute_boundary_cost(const Vector& v, const Boundary_data_vector& aBdry);
FT compute_volume_cost(const Vector& v, const Triangle_data_vector& aTriangles);
FT compute_shape_cost(Point const& p, const vertex_descriptor_vector& aLink);
FT compute_shape_cost(const Point& p, const vertex_descriptor_vector& aLink);
Point get_point(const vertex_descriptor v) const
{
@ -156,12 +158,12 @@ private :
static bool is_finite(const Matrix& m) { return is_finite(m.r0()) && is_finite(m.r1()) && is_finite(m.r2()); }
template<class T>
static optional<T> filter_infinity (T const& n) { return is_finite(n) ? optional<T>(n) : optional<T>(); }
static optional<T> filter_infinity(const T& n) { return is_finite(n) ? optional<T>(n) : optional<T>(); }
TM& surface() const { return mProfile.surface(); }
private:
Params const& mParams;
const Params& mParams;
const Profile& mProfile;
void add_constraint_if_alpha_compatible(const Vector& Ai, const FT& bi);
@ -183,7 +185,7 @@ private:
template<class TM, class K>
LindstromTurkCore<TM,K>::
LindstromTurkCore(Params const& aParams, const Profile& aProfile)
LindstromTurkCore(const Params& aParams, const Profile& aProfile)
:
mParams(aParams),
mProfile(aProfile),
@ -209,9 +211,8 @@ LindstromTurkCore<TM,K>::
extract_boundary_data()
{
mBdry_data.reserve(mProfile.border_edges().size());
for(const_border_edge_iterator it = mProfile.border_edges().begin(), eit = mProfile.border_edges().end(); it != eit; ++ it)
for(halfedge_descriptor border_edge : mProfile.border_edges())
{
halfedge_descriptor border_edge = *it;
halfedge_descriptor face_edge = opposite(border_edge, surface());
vertex_descriptor sv = source(face_edge, surface());
@ -236,10 +237,9 @@ LindstromTurkCore<TM,K>::
extract_triangle_data()
{
mTriangle_data.reserve(mProfile.triangles().size());
for(const_triangle_iterator it = mProfile.triangles().begin(), eit = mProfile.triangles().end(); it != eit; ++ it)
{
Triangle const& tri = *it;
for(const Triangle& tri : mProfile.triangles())
{
const Point& p0 = get_point(tri.v0);
const Point& p1 = get_point(tri.v1);
const Point& p2 = get_point(tri.v2);
@ -447,12 +447,9 @@ add_boundary_and_volume_optimization_constraints(const Boundary_data_vector& aBd
Vector c = NULL_VECTOR;
// Volume optimization
for(typename Triangle_data_vector::const_iterator it = aTriangles.begin(), eit = aTriangles.end(); it != eit; ++it)
for(const Triangle_data& lTri : aTriangles)
{
Triangle_data const& lTri = *it;
H += direct_product(lTri.NormalV, lTri.NormalV);
c = c - (lTri.NormalL * lTri.NormalV);
}
@ -503,9 +500,8 @@ add_shape_optimization_constraints(const vertex_descriptor_vector& aLink)
0.0, 0.0, s);
Vector c = NULL_VECTOR;
for(typename vertex_descriptor_vector::const_iterator it = aLink.begin(), eit = aLink.end(); it != eit; ++it)
c = c + (ORIGIN - get_point(*it));
for(const vertex_descriptor v : aLink)
c = c + (ORIGIN - get_point(v));
CGAL_SMS_LT_TRACE(1," Adding shape optimization constraint. Shape vector: " << xyz_to_string(c));
@ -537,11 +533,9 @@ compute_volume_cost(const Vector& v,
{
FT rCost(0);
for(typename Triangle_data_vector::const_iterator it = aTriangles.begin(), eit = aTriangles.end(); it != eit; ++it)
for(const Triangle_data& lTri : aTriangles)
{
Triangle_data const& lTri = *it;
FT lF = lTri.NormalV * v - lTri.NormalL;
rCost += (lF * lF);
}
@ -555,9 +549,8 @@ compute_shape_cost(const Point& p,
const vertex_descriptor_vector& aLink)
{
FT rCost(0);
for(typename vertex_descriptor_vector::const_iterator it = aLink.begin(), eit = aLink.end(); it != eit; ++it)
rCost += squared_distance(p,get_point(*it));
for(const vertex_descriptor v : aLink)
rCost += squared_distance(p, get_point(v));
return rCost;
}
@ -593,7 +586,8 @@ add_constraint_if_alpha_compatible(const Vector& Ai,
FT sd01 = d01 * d01;
FT max = sla0 * slai * mSquared_cos_alpha;
CGAL_SMS_LT_TRACE(3," Second constraint. d01: " << n_to_string(d01) << " sla0:" << n_to_string(sla0) << " sd01:" << n_to_string(sd01) << " max:" << n_to_string(max));
CGAL_SMS_LT_TRACE(3, " Second constraint. d01: " << n_to_string(d01) << " sla0:" << n_to_string(sla0)
<< " sd01:" << n_to_string(sd01) << " max:" << n_to_string(max));
if(sd01 > max)
lAddIt = false;
@ -603,13 +597,13 @@ add_constraint_if_alpha_compatible(const Vector& Ai,
Vector N = cross_product(mConstraints_A.r0(),mConstraints_A.r1());
FT dc012 = N * Ai;
FT slc01 = N * N;
FT sdc012 = dc012 * dc012;
FT min = slc01 * slai * mSquared_sin_alpha;
CGAL_SMS_LT_TRACE(3, " Third constraint. N: " << xyz_to_string(N) << " dc012:" << n_to_string(dc012) << " slc01:" << n_to_string(slc01)
CGAL_SMS_LT_TRACE(3, " Third constraint. N: " << xyz_to_string(N)
<< " dc012:" << n_to_string(dc012) << " slc01:" << n_to_string(slc01)
<< " sdc012:" << n_to_string(sdc012) << " min:" << n_to_string(min));
if(sdc012 <= min)
@ -655,7 +649,7 @@ add_constraint_if_alpha_compatible(const Vector& Ai,
}
template<class V>
int index_of_max_component (V const& v)
int index_of_max_component(const V& v)
{
typedef typename Kernel_traits<V>::Kernel::FT FT;
@ -727,7 +721,6 @@ add_constraint_from_gradient(const Matrix& H,
CGAL_assertion(Q0 != NULL_VECTOR);
Vector Q1 = cross_product(A0, Q0);
Vector A1 = H * Q0;
Vector A2 = H * Q1;

View File

@ -18,7 +18,7 @@
// Author(s) : Sebastien Loriot <sebastien.loriot@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_LENGTH_STOP_PREDICATE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_LENGTH_STOP_PREDICATE_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_LENGTH_STOP_PREDICATE_H
#include <CGAL/license/Surface_mesh_simplification.h>
#include <CGAL/squared_distance_3.h>

View File

@ -34,7 +34,7 @@ class LindstromTurk_cost
public:
typedef TM_ TM;
LindstromTurk_cost(LindstromTurk_params const& aParams = LindstromTurk_params())
LindstromTurk_cost(const LindstromTurk_params& aParams = LindstromTurk_params())
: mParams(aParams)
{}

View File

@ -18,7 +18,7 @@
// Author(s) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_PLACEMENT_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_PLACEMENT_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_LINDSTROMTURK_PLACEMENT_H
#include <CGAL/license/Surface_mesh_simplification.h>
@ -34,7 +34,7 @@ class LindstromTurk_placement
public:
typedef TM_ TM;
LindstromTurk_placement(LindstromTurk_params const& aParams = LindstromTurk_params())
LindstromTurk_placement(const LindstromTurk_params& aParams = LindstromTurk_params())
: mParams(aParams)
{}

View File

@ -18,7 +18,7 @@
// Author(s) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H
#include <CGAL/license/Surface_mesh_simplification.h>
@ -27,32 +27,24 @@
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
namespace CGAL {
namespace Surface_mesh_simplification
{
namespace Surface_mesh_simplification {
template<class TM_>
class Midpoint_placement
{
public:
typedef TM_ TM;
Midpoint_placement()
{}
Midpoint_placement() {}
template <typename Profile>
optional<typename Profile::Point> operator()(const Profile& aProfile) const
{
return optional<typename Profile::Point>(midpoint(aProfile.p0(), aProfile.p1()));
}
};
} // namespace Surface_mesh_simplification
} // namespace CGAL
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H //
// EOF //
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_MIDPOINT_PLACEMENT_H

View File

@ -18,7 +18,7 @@
// Author(s) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_COLLAPSE_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_COLLAPSE_H 1
#define CGAL_SURFACE_MESH_SIMPLIFICATION_EDGE_COLLAPSE_H
#include <CGAL/license/Surface_mesh_simplification.h>
@ -73,21 +73,21 @@ struct Dummy_visitor
template<class Profile>
void OnStopConditionReached(const Profile&) const {}
template<class Profile, class OFT>
void OnCollected(Profile const&, const OFT&) const {}
void OnCollected(const Profile&, const OFT&) const {}
template<class Profile, class OFT, class Size_type>
void OnSelected(Profile const&, const OFT&, Size_type, Size_type) const {}
void OnSelected(const Profile&, const OFT&, Size_type, Size_type) const {}
template<class Profile, class OPoint>
void OnCollapsing(const Profile&, const OPoint&) const {}
template<class Profile, class VH>
void OnCollapsed(const Profile&, VH) const {}
template<class Profile>
void OnNonCollapsable(Profile const&) const {}
void OnNonCollapsable(const Profile&) const {}
};
template<class TM, class ShouldStop, class P, class T, class R>
int edge_collapse(TM& aSurface,
const ShouldStop& aShould_stop,
cgal_bgl_named_params<P,T,R> const& aParams)
const cgal_bgl_named_params<P,T,R>& aParams)
{
using boost::choose_param;
using boost::choose_const_pmap;
@ -108,8 +108,8 @@ int edge_collapse(TM& aSurface,
template<class TM, class ShouldStop, class GT, class P, class T, class R>
int edge_collapse(TM& aSurface,
ShouldStop const& aShould_stop,
cgal_bgl_named_params<P,T,R> const& aParams)
const ShouldStop& aShould_stop,
const cgal_bgl_named_params<P,T,R>& aParams)
{
using boost::choose_param;
using boost::choose_const_pmap;

View File

@ -81,7 +81,8 @@ protected:
mMap.insert(make_pair(v->id(),mVIdx++));
}
void add_triangle(Builder& aBuilder, Profile::Triangle const& aTri)
void add_triangle(Builder& aBuilder,
const Profile::Triangle& aTri)
{
aBuilder.begin_facet();
aBuilder.add_vertex_to_facet(mMap[aTri.v0->id()]);
@ -204,12 +205,14 @@ void write (SurfaceSP aSurface, string aName)
}
template<class T>
string opt2str (boost::optional<T> const& o)
string opt2str (const boost::optional<T>& o)
{
ostringstream ss;
if(o)
ss << *o;
else ss << "<none>";
else
ss << "<none>";
return ss.str();
}
@ -220,13 +223,13 @@ string float2str (N n)
}
template<class P>
string point2str (P const& p)
string point2str (const P& p)
{
return boost::str(boost::format("(%+05.19g %+05.19g %+05.19g)") % to_double(p.x()) % to_double(p.y()) % to_double(p.z()));
}
template<class P>
string optpoint2str (boost::optional<P> const& p)
string optpoint2str (const boost::optional<P>& p)
{
ostringstream ss;
if(p)
@ -236,7 +239,7 @@ string optpoint2str (boost::optional<P> const& p)
return ss.str();
}
template<class N>
string optfloat2str (boost::optional<N> const& n)
string optfloat2str (const boost::optional<N>& n)
{
ostringstream ss;
if(n)
@ -247,7 +250,7 @@ string optfloat2str (boost::optional<N> const& n)
}
template<class V>
string vertex2str (V const& v)
string vertex2str (const V& v)
{
ostringstream ss;
ss << "[V" << v->id() << point2str(v->point()) << "]";
@ -255,14 +258,14 @@ string vertex2str (V const& v)
}
template<class E>
string edge2str (E const& e)
string edge2str (const E& e)
{
ostringstream ss;
ss << "{E" << e->id() << vertex2str(e->opposite()->vertex()) << "->" << vertex2str(e->vertex()) << "}";
return ss.str();
}
template<class T> ostream& operator << (ostream& os, boost::optional<T> const& o) { return os << opt2str(o); }
template<class T> ostream& operator << (ostream& os, const boost::optional<T>& o) { return os << opt2str(o); }
string normalize_EOL (string line)
{
@ -308,19 +311,19 @@ public :
CHECK(aSurface.is_valid());
}
virtual void OnCollected(const Profile& aProfile, boost::optional<FT> const& aCost) const
virtual void OnCollected(const Profile& aProfile, const boost::optional<FT>& aCost) const
{
TEST_TRACE(str (format("Collecting %1% : cost=%2%") % edge2str(aProfile.v0_v1()) % optfloat2str(aCost)));
}
virtual void OnCollapsing(const Profile& aProfile, boost::optional<Point> const& aP) const
virtual void OnCollapsing(const Profile& aProfile, const boost::optional<Point>& aP) const
{
TEST_TRACE(str (format("S %1% - Collapsing %2% : placement=%3%") % mStep % edge2str(aProfile.v0_v1()) % optpoint2str(aP)));
//mBefore = create_edge_link(aProfile);
}
virtual void OnCollapsed(const Profile& aProfile, Vertex_handle const& aV) const
virtual void OnCollapsed(const Profile& aProfile, const Vertex_handle& aV) const
{
// Some collapse can result in self-intersections in any case, so we can't mark it as a failure
if(false && Is_self_intersecting(aProfile.surface()))
@ -345,12 +348,10 @@ private:
cerr << " Assertion failed: " << pred << endl;
cerr << " " << msg << endl;
throw runtime_error("");
}
private:
string mTestCase;
mutable int mStep;
mutable SurfaceSP mBefore;
@ -433,14 +434,13 @@ bool Test (string aName)
cerr << "Unable to open test file " << aName << endl;
}
}
catch (std::exception const& x)
catch (const std::exception& x)
{
string what(x.what());
if(what.length() > 0)
cerr << "Exception caught: " << what << endl;
}
return rSucceeded;
}
@ -519,9 +519,4 @@ void postcondition_fail(const char* expr, const char* file, int line)
}
}
#endif
// EOF //

View File

@ -21,6 +21,7 @@ struct Intersect_facets
|| h->next()->opposite()->facet() == c->handle()
|| h->next()->next()->opposite()->facet() == c->handle())
return;
// check for shared vertex --> maybe intersection, maybe not
Halfedge_const_handle g = c->handle()->halfedge();
Halfedge_const_handle v;
@ -48,6 +49,7 @@ struct Intersect_facets
v = g->next()->next();
}
}
if(v != Halfedge_const_handle()) {
// found shared vertex:
assert(h->vertex() == v->vertex());
@ -75,6 +77,7 @@ struct Intersect_facets
}
return;
}
// check for geometric intersection
Triangle t1(h->vertex()->point(),
h->next()->vertex()->point(),
@ -82,6 +85,7 @@ struct Intersect_facets
Triangle t2(g->vertex()->point(),
g->next()->vertex()->point(),
g->next()->next()->vertex()->point());
if(CGAL::do_intersect(t1, t2)) {
//cerr << "Triangles intersect:\n T1: " << t1 << "\n T2 :"
// << t2 << endl;
@ -91,8 +95,7 @@ struct Intersect_facets
}
};
bool Is_self_intersecting(Surface const& s)
bool Is_self_intersecting(const Surface& s)
{
std::vector<Box> boxes;
boxes.reserve(s.size_of_facets());