mirror of https://github.com/CGAL/cgal
Merge pull request #1266 from sloriot/Property_map-several_fixes
Property map fixes
This commit is contained in:
commit
df87b929fa
|
|
@ -5,6 +5,7 @@
|
|||
#include <vector>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Construct_theta_graph_2.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
|
@ -89,7 +90,7 @@ int main(int argc, char ** argv)
|
|||
boost::dijkstra_shortest_paths(g,
|
||||
v0,
|
||||
boost::weight_map(get(&Edge_property::euclidean_length, g)).
|
||||
distance_map(&distances[0]) );
|
||||
distance_map(CGAL::make_property_map(distances)) );
|
||||
|
||||
std::cout << "distances are:" << std::endl;
|
||||
for (unsigned int i=0; i < n; ++i) {
|
||||
|
|
|
|||
|
|
@ -266,10 +266,10 @@ private:
|
|||
{
|
||||
if (first == last) return 0;
|
||||
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Point> points;
|
||||
std::vector<typename Tds::Vertex::Info> infos;
|
||||
std::ptrdiff_t index = 0;
|
||||
std::size_t index = 0;
|
||||
for (InputIterator it = first; it != last; ++it)
|
||||
{
|
||||
Tuple_or_pair value = *it;
|
||||
|
|
@ -278,7 +278,8 @@ private:
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits, Point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits, Pmap> Search_traits;
|
||||
|
||||
size_type n = number_of_vertices();
|
||||
|
||||
|
|
@ -287,7 +288,7 @@ private:
|
|||
if (n != 0) is_large_point_set = false;
|
||||
|
||||
std::set<Vertex_handle> dummy_points;
|
||||
typename std::vector<std::ptrdiff_t>::iterator pbegin = indices.begin();
|
||||
typename std::vector<std::size_t>::iterator pbegin = indices.begin();
|
||||
|
||||
if (is_large_point_set)
|
||||
{
|
||||
|
|
@ -320,14 +321,16 @@ private:
|
|||
CGAL_assertion(is_1_cover());
|
||||
|
||||
// Insert the points
|
||||
spatial_sort(indices.begin(), indices.end(), Search_traits(&(points[0]), geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points), geom_traits()));
|
||||
|
||||
Face_handle f;
|
||||
Locate_type lt;
|
||||
int li;
|
||||
|
||||
Face_handle hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator it = pbegin, end = indices.end();
|
||||
for (typename std::vector<std::size_t>::const_iterator it = pbegin, end = indices.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
f = locate(points[*it], lt, li, f);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ int main(int argc, char*argv[])
|
|||
// simplification by clustering using erase-remove idiom
|
||||
double cell_size = 0.05;
|
||||
std::vector<std::size_t>::iterator end;
|
||||
end = CGAL::grid_simplify_point_set(indices.begin(), indices.end(), &(points[0]),cell_size);
|
||||
end = CGAL::grid_simplify_point_set(indices.begin(),
|
||||
indices.end(),
|
||||
CGAL::make_property_map(points),
|
||||
cell_size);
|
||||
|
||||
std::size_t k = end - indices.begin();
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,6 @@ write_off_points_and_normals(
|
|||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
|
|
@ -81,9 +77,8 @@ write_off_points_and_normals(
|
|||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point p = get(point_pmap, *it);
|
||||
Vector n = get(normal_pmap, *it);
|
||||
stream << p << " " << n << std::endl;
|
||||
stream << get(point_pmap, *it) << " "
|
||||
<< get(normal_pmap, *it) << std::endl;
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
|
|
@ -162,9 +157,6 @@ write_off_points(
|
|||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& ) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
|
|
@ -180,10 +172,7 @@ write_off_points(
|
|||
|
||||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point p = get(point_pmap, *it);
|
||||
stream << p << std::endl;
|
||||
}
|
||||
stream << get(point_pmap, *it) << std::endl;
|
||||
|
||||
return ! stream.fail();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@ write_ply_points_and_normals(
|
|||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
|
|
@ -89,9 +85,8 @@ write_ply_points_and_normals(
|
|||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point p = get(point_pmap, *it);
|
||||
Vector n = get(normal_pmap, *it);
|
||||
stream << p << " " << n << std::endl;
|
||||
stream << get(point_pmap, *it) << " "
|
||||
<< get(normal_pmap, *it) << std::endl;
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
|
|
|
|||
|
|
@ -61,10 +61,6 @@ write_xyz_points_and_normals(
|
|||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
|
|
@ -76,9 +72,8 @@ write_xyz_points_and_normals(
|
|||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point p = get(point_pmap, *it);
|
||||
Vector n = get(normal_pmap, *it);
|
||||
stream << p << " " << n << std::endl;
|
||||
stream << get(point_pmap, *it) << " "
|
||||
<< get(normal_pmap, *it) << std::endl;
|
||||
}
|
||||
|
||||
return ! stream.fail();
|
||||
|
|
@ -157,9 +152,6 @@ write_xyz_points(
|
|||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
||||
if(!stream)
|
||||
|
|
@ -170,11 +162,7 @@ write_xyz_points(
|
|||
|
||||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point p = get(point_pmap, *it);
|
||||
|
||||
stream << p << std::endl;
|
||||
}
|
||||
stream << get(point_pmap, *it) << std::endl;
|
||||
|
||||
return ! stream.fail();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,17 +138,16 @@ struct Normal_of_point_with_normal_pmap
|
|||
|
||||
typedef Point_with_normal key_type;
|
||||
typedef Vector value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& reference;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
|
||||
/// Access a property map element
|
||||
reference operator[](key_type& pwn) const { return pwn.normal(); }
|
||||
value_type& operator[](key_type& pwn) const { return pwn.normal(); }
|
||||
|
||||
typedef Normal_of_point_with_normal_pmap<Gt> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k.normal();}
|
||||
friend reference get(const Self&, key_type& k) {return k.normal();}
|
||||
friend reference get(const Self&,const key_type& k) {return k.normal();}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k.normal()=v;}
|
||||
/// @};}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -413,10 +413,8 @@ bilateral_smooth_point_set(
|
|||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename CGAL::Point_with_normal_3<Kernel> Pwn;
|
||||
typedef typename std::vector<Pwn,CGAL_PSP3_DEFAULT_ALLOCATOR<Pwn> > Pwns;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
typedef typename Kernel::FT FT;
|
||||
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
|
@ -433,8 +431,8 @@ bilateral_smooth_point_set(
|
|||
Pwns pwns;
|
||||
for(ForwardIterator it = first; it != beyond; ++it)
|
||||
{
|
||||
const Point& p = get(point_pmap, *it);
|
||||
const Vector& n = get(normal_pmap, *it);
|
||||
typename boost::property_traits<PointPMap>::reference p = get(point_pmap, *it);
|
||||
typename boost::property_traits<NormalPMap>::reference n = get(normal_pmap, *it);
|
||||
CGAL_point_set_processing_precondition(n.squared_length() > 1e-10);
|
||||
|
||||
pwns.push_back(Pwn(p, n));
|
||||
|
|
@ -564,7 +562,7 @@ bilateral_smooth_point_set(
|
|||
ForwardIterator it = first;
|
||||
for(unsigned int i = 0 ; it != beyond; ++it, ++i)
|
||||
{
|
||||
const Point& p = get(point_pmap, *it);
|
||||
typename boost::property_traits<PointPMap>::reference p = get(point_pmap, *it);
|
||||
sum_move_error += CGAL::squared_distance(p, update_pwns[i].position());
|
||||
put (point_pmap, *it, update_pwns[i].position());
|
||||
put (normal_pmap, *it, update_pwns[i].normal());
|
||||
|
|
|
|||
|
|
@ -177,10 +177,7 @@ compute_average_spacing(
|
|||
// Note: We have to convert each input iterator to Point_3.
|
||||
std::vector<Point> kd_tree_points;
|
||||
for(InputIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
kd_tree_points.push_back(get(point_pmap, *it));
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
||||
// iterate over input points, compute and output normal
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ private:
|
|||
|
||||
double m_epsilon;
|
||||
PointPMap point_pmap;
|
||||
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
public:
|
||||
|
||||
Less_epsilon_points_3 (double epsilon, PointPMap p_pmap)
|
||||
|
|
@ -62,20 +62,9 @@ public:
|
|||
|
||||
bool operator() (const Point_3& a, const Point_3& b) const
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
||||
// Round points to multiples of m_epsilon, then compare.
|
||||
Point a_n = get(point_pmap,a);
|
||||
Point b_n = get(point_pmap,b);
|
||||
|
||||
Point rounded_a(round_epsilon(a_n.x(), m_epsilon),
|
||||
round_epsilon(a_n.y(), m_epsilon),
|
||||
round_epsilon(a_n.z(), m_epsilon));
|
||||
Point rounded_b(round_epsilon(b_n.x(), m_epsilon),
|
||||
round_epsilon(b_n.y(), m_epsilon),
|
||||
round_epsilon(b_n.z(), m_epsilon));
|
||||
|
||||
return (rounded_a < rounded_b);
|
||||
return round_epsilon( get(point_pmap,a), m_epsilon ) <
|
||||
round_epsilon( get(point_pmap,b), m_epsilon );
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -85,6 +74,13 @@ private:
|
|||
{
|
||||
return std::floor(value/epsilon) * epsilon;
|
||||
}
|
||||
|
||||
static inline Point round_epsilon(const Point& p, double epsilon)
|
||||
{
|
||||
return Point( round_epsilon(p.x(), epsilon),
|
||||
round_epsilon(p.y(), epsilon),
|
||||
round_epsilon(p.z(), epsilon) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ namespace CGAL {
|
|||
unsigned int nb_pts = 0;
|
||||
while(begin != end)
|
||||
{
|
||||
const Point& point = get(point_pmap, *begin);
|
||||
typename boost::property_traits<PointPMap>::reference point =
|
||||
get(point_pmap, *begin);
|
||||
x += point.x (); y += point.y (); z += point.z ();
|
||||
++ nb_pts;
|
||||
++ begin;
|
||||
|
|
@ -77,15 +78,13 @@ namespace CGAL {
|
|||
{
|
||||
typedef typename std::list<Input_type>::iterator Iterator;
|
||||
typedef typename K::FT FT;
|
||||
typedef typename K::Point_3 Point;
|
||||
|
||||
FT dist_min = (std::numeric_limits<FT>::max)();
|
||||
|
||||
typename std::list<Input_type>::iterator point_min;
|
||||
for (Iterator it = cluster.begin (); it != cluster.end (); ++ it)
|
||||
{
|
||||
const Point& point = get(point_pmap, *it);
|
||||
FT dist = CGAL::squared_distance (point, centroid);
|
||||
FT dist = CGAL::squared_distance (get(point_pmap, *it), centroid);
|
||||
if (dist < dist_min)
|
||||
{
|
||||
dist_min = dist;
|
||||
|
|
|
|||
|
|
@ -211,10 +211,7 @@ jet_estimate_normals(
|
|||
// Note: We have to convert each input iterator to Point_3.
|
||||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
kd_tree_points.push_back(get(point_pmap, *it));
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
||||
memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20);
|
||||
|
|
|
|||
|
|
@ -205,10 +205,7 @@ jet_smooth_point_set(
|
|||
// Note: We have to convert each input iterator to Point_3.
|
||||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
kd_tree_points.push_back(get(point_pmap, *it));
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
||||
// Iterates over input points and mutates them.
|
||||
|
|
@ -237,7 +234,7 @@ jet_smooth_point_set(
|
|||
{
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
const Point& p = get(point_pmap, *it);
|
||||
typename boost::property_traits<PointPMap>::reference p = get(point_pmap, *it);
|
||||
put(point_pmap, *it ,
|
||||
internal::jet_smooth_point<Kernel, SvdTraits>(
|
||||
p,tree,k,degree_fitting,degree_monge) );
|
||||
|
|
|
|||
|
|
@ -149,16 +149,16 @@ struct Propagate_normal_orientation
|
|||
template <class Edge>
|
||||
void operator()(Edge& edge, const MST_graph& mst_graph)
|
||||
{
|
||||
typedef typename boost::property_traits<NormalPMap>::value_type Vector;
|
||||
typedef typename boost::property_traits<NormalPMap>::reference Vector_ref;
|
||||
typedef typename MST_graph::vertex_descriptor vertex_descriptor;
|
||||
|
||||
// Gets source normal
|
||||
vertex_descriptor source_vertex = source(edge, mst_graph);
|
||||
const Vector source_normal = get(mst_graph.m_normal_pmap, *(mst_graph[source_vertex].input_point) );
|
||||
Vector_ref source_normal = get(mst_graph.m_normal_pmap, *(mst_graph[source_vertex].input_point) );
|
||||
const bool source_normal_is_oriented = mst_graph[source_vertex].is_oriented;
|
||||
// Gets target normal
|
||||
vertex_descriptor target_vertex = target(edge, mst_graph);
|
||||
const Vector& target_normal = get( mst_graph.m_normal_pmap, *(mst_graph[target_vertex].input_point) );
|
||||
Vector_ref target_normal = get( mst_graph.m_normal_pmap, *(mst_graph[target_vertex].input_point) );
|
||||
bool& target_normal_is_oriented = ((MST_graph&)mst_graph)[target_vertex].is_oriented;
|
||||
if ( ! target_normal_is_oriented )
|
||||
{
|
||||
|
|
@ -208,6 +208,7 @@ mst_find_source(
|
|||
|
||||
// Input points types
|
||||
typedef typename boost::property_traits<NormalPMap>::value_type Vector;
|
||||
typedef typename boost::property_traits<NormalPMap>::reference Vector_ref;
|
||||
|
||||
// Precondition: at least one element in the container
|
||||
CGAL_point_set_processing_precondition(first != beyond);
|
||||
|
|
@ -225,7 +226,7 @@ mst_find_source(
|
|||
}
|
||||
|
||||
// Orients its normal towards +Z axis
|
||||
const Vector& normal = get(normal_pmap,*top_point);
|
||||
Vector_ref normal = get(normal_pmap,*top_point);
|
||||
const Vector Z(0, 0, 1);
|
||||
if (Z * normal < 0) {
|
||||
CGAL_TRACE(" Flip top point normal\n");
|
||||
|
|
@ -268,8 +269,8 @@ create_riemannian_graph(
|
|||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// Input points types
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename boost::property_traits<NormalPMap>::value_type Vector;
|
||||
typedef typename boost::property_traits<PointPMap>::reference Point_ref;
|
||||
typedef typename boost::property_traits<NormalPMap>::reference Vector_ref;
|
||||
|
||||
// Types for K nearest neighbors search structure
|
||||
typedef Point_vertex_handle_3<ForwardIterator> Point_vertex_handle_3;
|
||||
|
|
@ -302,7 +303,7 @@ create_riemannian_graph(
|
|||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
|
||||
Point point = get(point_pmap, *it);
|
||||
Point_ref point = get(point_pmap, *it);
|
||||
Point_vertex_handle_3 point_wrapper(point.x(), point.y(), point.z(), it);
|
||||
kd_tree_points.push_back(point_wrapper);
|
||||
}
|
||||
|
|
@ -334,14 +335,14 @@ create_riemannian_graph(
|
|||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
std::size_t it_index = get(index_pmap,it);
|
||||
Vector it_normal_vector = get(normal_pmap,*it);
|
||||
Vector_ref it_normal_vector = get(normal_pmap,*it);
|
||||
|
||||
// Gather set of (k+1) neighboring points.
|
||||
// Perform k+1 queries (as in point set, the query point is
|
||||
// output first). Search may be aborted if k is greater
|
||||
// than number of input points.
|
||||
|
||||
Point point = get(point_pmap, *it);
|
||||
Point_ref point = get(point_pmap, *it);
|
||||
Point_vertex_handle_3 point_wrapper(point.x(), point.y(), point.z(), it);
|
||||
Neighbor_search search(*tree, point_wrapper, k+1);
|
||||
Search_iterator search_iterator = search.begin();
|
||||
|
|
@ -366,7 +367,7 @@ create_riemannian_graph(
|
|||
// Computes edge weight = 1 - | normal1 * normal2 |
|
||||
// where normal1 and normal2 are the normal at the edge extremities.
|
||||
|
||||
Vector neighbor_normal_vector = get(normal_pmap,*neighbor);
|
||||
Vector_ref neighbor_normal_vector = get(normal_pmap,*neighbor);
|
||||
double weight = 1.0 - std::abs(it_normal_vector * neighbor_normal_vector);
|
||||
if (weight < 0)
|
||||
weight = 0; // safety check
|
||||
|
|
|
|||
|
|
@ -198,10 +198,7 @@ pca_estimate_normals(
|
|||
// Note: We have to convert each input iterator to Point_3.
|
||||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
kd_tree_points.push_back(get(point_pmap, *it));
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
||||
memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ radial_orient_normals(
|
|||
typedef typename std::iterator_traits<ForwardIterator>::value_type Enriched_point;
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename boost::property_traits<NormalPMap>::value_type Vector;
|
||||
typedef typename boost::property_traits<PointPMap>::reference Point_ref;
|
||||
typedef typename boost::property_traits<NormalPMap>::reference Vector_ref;
|
||||
typedef typename Kernel::FT FT;
|
||||
|
||||
// Precondition: at least one element in the container.
|
||||
|
|
@ -83,7 +85,7 @@ radial_orient_normals(
|
|||
int nb_points = 0;
|
||||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
Point_ref point = get(point_pmap, *it);
|
||||
sum = sum + (point - CGAL::ORIGIN);
|
||||
nb_points++;
|
||||
}
|
||||
|
|
@ -94,13 +96,13 @@ radial_orient_normals(
|
|||
std::deque<Enriched_point> oriented_points, unoriented_points;
|
||||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
Point_ref point = get(point_pmap, *it);
|
||||
|
||||
// Radial vector towards exterior of the point set
|
||||
Vector vec1 = point - barycenter;
|
||||
|
||||
// Point's normal
|
||||
Vector vec2 = get(normal_pmap, *it);
|
||||
Vector_ref vec2 = get(normal_pmap, *it);
|
||||
|
||||
// -> ->
|
||||
// Orients vec2 parallel to vec1
|
||||
|
|
|
|||
|
|
@ -162,10 +162,7 @@ remove_outliers(
|
|||
// Note: We have to convert each input iterator to Point_3.
|
||||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point point = get(point_pmap, *it);
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
kd_tree_points.push_back( get(point_pmap, *it) );
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
||||
// iterate over input points and add them to multimap sorted by distance to k
|
||||
|
|
|
|||
|
|
@ -512,11 +512,7 @@ wlop_simplify_and_regularize_point_set(
|
|||
// Initiate a KD-tree search for original points
|
||||
std::vector<Kd_tree_element> original_treeElements;
|
||||
for (it = first_original_iter, i=0 ; it != beyond ; ++it, ++i)
|
||||
{
|
||||
const Point& p0 = get(point_pmap, *it);
|
||||
|
||||
original_treeElements.push_back(Kd_tree_element(p0, i));
|
||||
}
|
||||
original_treeElements.push_back( Kd_tree_element(get(point_pmap, *it), i) );
|
||||
Kd_Tree original_kd_tree(original_treeElements.begin(),
|
||||
original_treeElements.end());
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ int main()
|
|||
|
||||
|
||||
CGAL::jet_estimate_normals<CGAL::Sequential_tag>(indices.begin(), indices.end(),
|
||||
&(points[0]),
|
||||
&(normals[0]),
|
||||
CGAL::make_property_map(points),
|
||||
CGAL::make_property_map(normals),
|
||||
12);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
// VC++ does not consider put and get for plain pointers
|
||||
// when identifying the best match for overloads
|
||||
|
||||
using ::put;
|
||||
using ::get;
|
||||
|
||||
/// \cond SKIP_DOXYGEN
|
||||
|
||||
|
||||
|
|
@ -287,13 +281,73 @@ struct Property_map_to_unary_function{
|
|||
: map(m)
|
||||
{}
|
||||
|
||||
template <class KeyType>
|
||||
result_type
|
||||
operator()(const argument_type& a) const
|
||||
operator()(const KeyType& a) const
|
||||
{
|
||||
return get(map,a);
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Utility class providing shortcuts to property maps based on raw pointers
|
||||
template <class T>
|
||||
struct Pointer_property_map{
|
||||
typedef boost::iterator_property_map< T*,
|
||||
boost::typed_identity_property_map<std::size_t>,
|
||||
T,
|
||||
T&> type; ///< mutable `LvaluePropertyMap`
|
||||
typedef boost::iterator_property_map< const T*,
|
||||
boost::typed_identity_property_map<std::size_t>,
|
||||
T,
|
||||
const T&> const_type; ///< non-mutable `LvaluePropertyMap`
|
||||
};
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Starting from boost 1.55, the use of raw pointers as property maps has been deprecated.
|
||||
/// This function is a shortcut to the recommanded replacement:
|
||||
/// `boost::make_iterator_property_map(<pointer>, boost::typed_identity_property_map<std::size_t>())`
|
||||
/// Note that the property map is a mutable `LvaluePropertyMap` with `std::size_t` as key.
|
||||
template <class T>
|
||||
inline
|
||||
typename Pointer_property_map<T>::type
|
||||
make_property_map(T* pointer)
|
||||
{
|
||||
return typename Pointer_property_map<T>::type(pointer);
|
||||
}
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// equivalent to `make_property_map(&v[0])`
|
||||
/// Note that `v` must not be modified while using the property map created
|
||||
template <class T>
|
||||
inline
|
||||
typename Pointer_property_map<T>::type
|
||||
make_property_map(std::vector<T>& v)
|
||||
{
|
||||
return make_property_map(&v[0]);
|
||||
}
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Non-mutable version
|
||||
template <class T>
|
||||
inline
|
||||
typename Pointer_property_map<T>::const_type
|
||||
make_property_map(const T* pointer)
|
||||
{
|
||||
return typename Pointer_property_map<T>::const_type(pointer);
|
||||
}
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// equivalent to `make_property_map(&v[0])`
|
||||
/// Note that `v` must not be modified while using the property map created
|
||||
template <class T>
|
||||
inline
|
||||
typename Pointer_property_map<T>::const_type
|
||||
make_property_map(const std::vector<T>& v)
|
||||
{
|
||||
return make_property_map(&v[0]);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_POINT_SET_PROPERTY_MAP_H
|
||||
|
|
|
|||
|
|
@ -582,18 +582,20 @@ public:
|
|||
IndicesIterator indices_first,
|
||||
IndicesIterator indices_beyond )
|
||||
{
|
||||
typedef std::vector<std::ptrdiff_t> Vertex_indices;
|
||||
typedef std::vector<std::size_t> Vertex_indices;
|
||||
typedef std::vector<Vertex_handle> Vertices;
|
||||
|
||||
Vertex_indices vertex_indices;
|
||||
vertex_indices.resize(points.size());
|
||||
|
||||
std::copy(boost::counting_iterator<std::ptrdiff_t>(0),
|
||||
boost::counting_iterator<std::ptrdiff_t>(points.size()),
|
||||
std::copy(boost::counting_iterator<std::size_t>(0),
|
||||
boost::counting_iterator<std::size_t>(points.size()),
|
||||
std::back_inserter(vertex_indices));
|
||||
|
||||
size_type n = this->number_of_vertices();
|
||||
Spatial_sort_traits_adapter_2<Gt,const Point_2*> sort_traits(&(points[0]));
|
||||
Spatial_sort_traits_adapter_2<Gt,
|
||||
typename Pointer_property_map<Point_2>::const_type >
|
||||
sort_traits(make_property_map(points));
|
||||
|
||||
spatial_sort(vertex_indices.begin(), vertex_indices.end(), sort_traits);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
//using a pointer as a special property map type
|
||||
typedef
|
||||
CGAL::Spatial_sort_traits_adapter_3<Kernel,Point_3*> Search_traits_3;
|
||||
typedef CGAL::Spatial_sort_traits_adapter_3<Kernel,
|
||||
CGAL::Pointer_property_map<Point_3>::type > Search_traits_3;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -20,16 +19,18 @@ int main()
|
|||
points.push_back(Point_3(744,4154,43));
|
||||
points.push_back(Point_3(74,44,1));
|
||||
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
indices.reserve(points.size());
|
||||
|
||||
std::copy(boost::counting_iterator<std::ptrdiff_t>(0),
|
||||
boost::counting_iterator<std::ptrdiff_t>(points.size()),
|
||||
std::copy(boost::counting_iterator<std::size_t>(0),
|
||||
boost::counting_iterator<std::size_t>(points.size()),
|
||||
std::back_inserter(indices));
|
||||
|
||||
CGAL::spatial_sort( indices.begin(),indices.end(),Search_traits_3(&(points[0])) );
|
||||
CGAL::spatial_sort( indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits_3(CGAL::make_property_map(points)) );
|
||||
|
||||
for (std::vector<std::ptrdiff_t>::iterator it=indices.begin();it!=indices.end();++it)
|
||||
for (std::vector<std::size_t>::iterator it=indices.begin();it!=indices.end();++it)
|
||||
std::cout << points[*it] << "\n";
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
|
|
|
|||
|
|
@ -305,10 +305,10 @@ private:
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = this->number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Point> points;
|
||||
std::vector<typename Tds::Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair value=*it;
|
||||
points.push_back( top_get_first(value) );
|
||||
|
|
@ -316,13 +316,16 @@ private:
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()));
|
||||
|
||||
Vertex_handle v_hint;
|
||||
Face_handle hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it){
|
||||
v_hint = insert(points[*it], hint);
|
||||
|
|
|
|||
|
|
@ -336,10 +336,10 @@ private:
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = this->number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Point> points;
|
||||
std::vector<typename Tds::Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair value=*it;
|
||||
points.push_back( top_get_first(value) );
|
||||
|
|
@ -347,13 +347,16 @@ private:
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()));
|
||||
|
||||
Vertex_handle v_hint;
|
||||
Face_handle hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it){
|
||||
v_hint = insert(points[*it], hint);
|
||||
|
|
|
|||
|
|
@ -401,10 +401,10 @@ private:
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Weighted_point> points;
|
||||
std::vector<typename Triangulation_data_structure::Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair pair = *it;
|
||||
points.push_back( top_get_first(pair) );
|
||||
|
|
@ -412,13 +412,16 @@ private:
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Weighted_point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Weighted_point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_2<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()));
|
||||
|
||||
Face_handle hint;
|
||||
Vertex_handle v_hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#define CGAL_INTERNAL_TRIANGULATION_2_IMSERT_CONSTRAINTS_H
|
||||
|
||||
#include <CGAL/Spatial_sort_traits_adapter_2.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
|
@ -41,7 +42,7 @@ namespace CGAL {
|
|||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Geom_traits Geom_traits;
|
||||
typedef typename T::Point Point;
|
||||
typedef std::vector<std::ptrdiff_t> Vertex_indices;
|
||||
typedef std::vector<std::size_t> Vertex_indices;
|
||||
typedef std::vector<Vertex_handle> Vertices;
|
||||
|
||||
Vertex_indices vertex_indices;
|
||||
|
|
@ -52,7 +53,10 @@ namespace CGAL {
|
|||
std::back_inserter(vertex_indices));
|
||||
|
||||
typename T::size_type n = t.number_of_vertices();
|
||||
CGAL::Spatial_sort_traits_adapter_2<Geom_traits, const Point*> sort_traits(&(points[0]),t.geom_traits());
|
||||
CGAL::Spatial_sort_traits_adapter_2<
|
||||
Geom_traits,
|
||||
typename Pointer_property_map<Point>::const_type >
|
||||
sort_traits(make_property_map(points),t.geom_traits());
|
||||
|
||||
spatial_sort(vertex_indices.begin(), vertex_indices.end(), sort_traits);
|
||||
|
||||
|
|
|
|||
|
|
@ -429,10 +429,10 @@ private:
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Point> points;
|
||||
std::vector<typename Triangulation_data_structure::Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair value=*it;
|
||||
points.push_back( top_get_first(value) );
|
||||
|
|
@ -440,9 +440,12 @@ private:
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()));
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
if(this->is_parallel()){
|
||||
|
|
@ -482,7 +485,7 @@ private:
|
|||
#endif
|
||||
{
|
||||
Vertex_handle hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it) {
|
||||
hint = insert(points[*it], hint);
|
||||
|
|
@ -999,7 +1002,7 @@ protected:
|
|||
DT & m_dt;
|
||||
const std::vector<Point> & m_points;
|
||||
const std::vector<Info> & m_infos;
|
||||
const std::vector<std::ptrdiff_t> & m_indices;
|
||||
const std::vector<std::size_t> & m_indices;
|
||||
tbb::enumerable_thread_specific<Vertex_handle> & m_tls_hint;
|
||||
|
||||
public:
|
||||
|
|
@ -1007,7 +1010,7 @@ protected:
|
|||
Insert_point_with_info(DT & dt,
|
||||
const std::vector<Point> & points,
|
||||
const std::vector<Info> & infos,
|
||||
const std::vector<std::ptrdiff_t> & indices,
|
||||
const std::vector<std::size_t> & indices,
|
||||
tbb::enumerable_thread_specific<Vertex_handle> & tls_hint)
|
||||
: m_dt(dt), m_points(points), m_infos(infos), m_indices(indices),
|
||||
m_tls_hint(tls_hint)
|
||||
|
|
|
|||
|
|
@ -376,10 +376,10 @@ namespace CGAL {
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Weighted_point> points;
|
||||
std::vector<typename Triangulation_data_structure::Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair pair = *it;
|
||||
points.push_back( top_get_first(pair) );
|
||||
|
|
@ -387,9 +387,12 @@ namespace CGAL {
|
|||
indices.push_back(index++);
|
||||
}
|
||||
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Weighted_point*> Search_traits;
|
||||
typedef typename Pointer_property_map<Weighted_point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
spatial_sort( indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()) );
|
||||
spatial_sort( indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()) );
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
if (this->is_parallel())
|
||||
{
|
||||
|
|
@ -438,7 +441,7 @@ namespace CGAL {
|
|||
#endif // CGAL_LINKED_WITH_TBB
|
||||
{
|
||||
Cell_handle hint;
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
|
|
@ -1307,7 +1310,7 @@ namespace CGAL {
|
|||
RT & m_rt;
|
||||
const std::vector<Weighted_point> & m_points;
|
||||
const std::vector<Info> & m_infos;
|
||||
const std::vector<std::ptrdiff_t> & m_indices;
|
||||
const std::vector<std::size_t> & m_indices;
|
||||
tbb::enumerable_thread_specific<Vertex_handle> & m_tls_hint;
|
||||
|
||||
public:
|
||||
|
|
@ -1315,7 +1318,7 @@ namespace CGAL {
|
|||
Insert_point_with_info(RT & rt,
|
||||
const std::vector<Weighted_point> & points,
|
||||
const std::vector<Info> & infos,
|
||||
const std::vector<std::ptrdiff_t> & indices,
|
||||
const std::vector<std::size_t> & indices,
|
||||
tbb::enumerable_thread_specific<Vertex_handle> & tls_hint)
|
||||
: m_rt(rt), m_points(points), m_infos(infos), m_indices(indices),
|
||||
m_tls_hint(tls_hint)
|
||||
|
|
|
|||
|
|
@ -193,27 +193,29 @@ private:
|
|||
std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last)
|
||||
{
|
||||
size_type n = number_of_vertices();
|
||||
std::vector<std::ptrdiff_t> indices;
|
||||
std::vector<std::size_t> indices;
|
||||
std::vector<Point> points;
|
||||
std::vector<typename Vertex::Info> infos;
|
||||
std::ptrdiff_t index=0;
|
||||
std::size_t index=0;
|
||||
for (InputIterator it=first;it!=last;++it){
|
||||
Tuple_or_pair value=*it;
|
||||
points.push_back( top_get_first(value) );
|
||||
infos.push_back ( top_get_second(value) );
|
||||
indices.push_back(index++);
|
||||
}
|
||||
typedef typename Pointer_property_map<Point>::type Pmap;
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Pmap> Search_traits;
|
||||
|
||||
typedef Spatial_sort_traits_adapter_3<Geom_traits,Point*> Search_traits;
|
||||
|
||||
spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits()));
|
||||
spatial_sort(indices.begin(),
|
||||
indices.end(),
|
||||
Search_traits(make_property_map(points),geom_traits()));
|
||||
|
||||
|
||||
// hints[i] is the vertex of the previously inserted point in level i.
|
||||
// Thanks to spatial sort, they are better hints than what the hierarchy
|
||||
// would give us.
|
||||
Vertex_handle hints[maxlevel];
|
||||
for (typename std::vector<std::ptrdiff_t>::const_iterator
|
||||
for (typename std::vector<std::size_t>::const_iterator
|
||||
it = indices.begin(), end = indices.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue