mirror of https://github.com/CGAL/cgal
Use the new IO functions in Point_set_3 / PSP_3 examples
This commit is contained in:
parent
52d50f7d79
commit
24d2ee9c75
|
|
@ -1,7 +1,8 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Point_set_3/IO.h>
|
||||
#include <CGAL/draw_point_set_3.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
|
|
@ -12,14 +13,12 @@ typedef CGAL::Point_set_3<Point> Point_set;
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
std::ifstream f (argc > 1 ? argv[1] : "data/oni.xyz");
|
||||
const char* filename = argc > 1 ? argv[1] : "data/oni.xyz";
|
||||
Point_set point_set;
|
||||
|
||||
// Reading input in XYZ format
|
||||
if (!f || !CGAL::read_point_set(f, point_set))
|
||||
if(!CGAL::read_point_set(filename, point_set))
|
||||
{
|
||||
std::cerr<<"Can't read input file "
|
||||
<<(argc > 1 ? argv[1] : "data/oni.xyz")<< std::endl;
|
||||
std::cerr << "Can't read input file " << filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@ typedef CGAL::Point_set_3<Point> Point_set;
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
std::ifstream f (argc > 1 ? argv[1] : "data/camel.off");
|
||||
const char* filename = argc > 1 ? argv[1] : "data/camel.off";
|
||||
|
||||
Point_set point_set;
|
||||
point_set.add_normal_map();
|
||||
// Reading input in OFF format
|
||||
if (!f || !CGAL::read_point_set(f, point_set.index_back_inserter(), // OutputIterator
|
||||
CGAL::parameters::point_map(point_set.point_push_map())
|
||||
.normal_map(point_set.normal_push_map())))
|
||||
{
|
||||
std::cerr << "Can't read input file " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::read_point_set(filename, point_set.index_back_inserter(),
|
||||
CGAL::parameters::point_map(point_set.point_push_map())
|
||||
.normal_map(point_set.normal_push_map())))
|
||||
{
|
||||
std::cerr << "Can't read input file " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ int main (int, char**)
|
|||
for (std::size_t i = 0; i < nb_pts; ++ i)
|
||||
point_set.insert (*(generator ++));
|
||||
|
||||
|
||||
// Add normal property and estimate normal values
|
||||
point_set.add_normal_map();
|
||||
CGAL::jet_estimate_normals<CGAL::Sequential_tag>
|
||||
|
|
@ -44,7 +43,6 @@ int main (int, char**)
|
|||
point_set.parameters(). // Named parameters provided by Point_set_3
|
||||
degree_fitting(2)); // additional named parameter specific to jet_estimate_normals
|
||||
|
||||
|
||||
// Simplify point set
|
||||
CGAL::grid_simplify_point_set
|
||||
(point_set,
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@ void print_point_set (const Point_set& point_set)
|
|||
boost::tie (intensity, boost::tuples::ignore) = point_set.property_map<FT>("intensity");
|
||||
|
||||
std::cerr << "Content of point set:" << std::endl;
|
||||
for (Point_set::const_iterator it = point_set.begin();
|
||||
it != point_set.end(); ++ it)
|
||||
for (Point_set::const_iterator it = point_set.begin(); it != point_set.end(); ++ it)
|
||||
{
|
||||
std::cerr << "* Point " << point_set.point(*it) // or point_set[it]
|
||||
<< " with color [" << (int)(color[*it][0])
|
||||
<< " " << (int)(color[*it][1])
|
||||
<< " " << (int)(color[*it][2])
|
||||
<< "] and intensity " << intensity[*it]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
Point_set point_set;
|
||||
|
|
@ -51,26 +51,26 @@ int main (int, char**)
|
|||
|
||||
point_set.reserve (10); // For memory optimization
|
||||
for (std::size_t i = 0; i < 10; ++ i)
|
||||
{
|
||||
Point_set::iterator it = point_set.insert (Point (double(i), double(i), double(i)));
|
||||
Color c = {{ (unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)) }};
|
||||
color[*it] = c;
|
||||
intensity[*it] = rand() / (double)(RAND_MAX);
|
||||
}
|
||||
{
|
||||
Point_set::iterator it = point_set.insert (Point (double(i), double(i), double(i)));
|
||||
Color c = {{ (unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)) }};
|
||||
color[*it] = c;
|
||||
intensity[*it] = rand() / (double)(RAND_MAX);
|
||||
}
|
||||
|
||||
print_point_set (point_set);
|
||||
|
||||
// Remove points with intensity less than 0.5
|
||||
Point_set::iterator it = point_set.begin();
|
||||
while (it != point_set.end())
|
||||
{
|
||||
if (intensity[*it] < 0.5)
|
||||
point_set.remove(it);
|
||||
else
|
||||
++ it;
|
||||
}
|
||||
{
|
||||
if (intensity[*it] < 0.5)
|
||||
point_set.remove(it);
|
||||
else
|
||||
++ it;
|
||||
}
|
||||
|
||||
print_point_set (point_set); // point set is filtered
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Point_set_3/IO.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
|
@ -19,9 +19,10 @@ int main (int argc, char** argv)
|
|||
|
||||
Point_set point_set;
|
||||
|
||||
if (!f || !CGAL::read_PLY (f, point_set)) // same as `f >> point_set`
|
||||
if(!CGAL::read_PLY (f, point_set)) // same as `f >> point_set`
|
||||
{
|
||||
std::cerr << "Can't read input file " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Shows which properties are defined
|
||||
|
|
|
|||
|
|
@ -14,35 +14,31 @@ typedef CGAL::Point_set_3<Point> Point_set;
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
const char* fname (argc > 1 ? argv[1] : "data/oni.xyz");
|
||||
const char* fname = argc > 1 ? argv[1] : "data/oni.xyz";
|
||||
|
||||
Point_set point_set;
|
||||
|
||||
// Reading input in XYZ format
|
||||
if (!CGAL::read_point_set(fname, point_set))
|
||||
{
|
||||
std::cerr << "Can't read input file " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::read_point_set(fname, point_set))
|
||||
{
|
||||
std::cerr << "Can't read input file " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (point_set.has_normal_map())
|
||||
{
|
||||
// Normalization + inversion of normal vectors
|
||||
for (Point_set::iterator it = point_set.begin(); it != point_set.end(); ++ it)
|
||||
{
|
||||
// Normalization + inversion of normal vectors
|
||||
for (Point_set::iterator it = point_set.begin(); it != point_set.end(); ++ it)
|
||||
{
|
||||
Vector n = point_set.normal(*it);
|
||||
n = - n / std::sqrt (n * n);
|
||||
point_set.normal(*it) = n;
|
||||
}
|
||||
Vector n = point_set.normal(*it);
|
||||
n = - n / std::sqrt (n * n);
|
||||
point_set.normal(*it) = n;
|
||||
}
|
||||
}
|
||||
|
||||
// Writing result in OFF format
|
||||
std::ofstream out("normalized_normals.off");
|
||||
out.precision(17);
|
||||
if (!out || !CGAL::write_OFF (out, point_set))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::write_OFF("normalized_normals.off", point_set, CGAL::parameters::stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ void print_point_set (const Point_set& ps, const char* msg)
|
|||
{
|
||||
Point_set::Property_map<int> intensity;
|
||||
bool has_intensity;
|
||||
boost::tie (intensity, has_intensity)
|
||||
= ps.property_map<int>("intensity");
|
||||
boost::tie (intensity, has_intensity) = ps.property_map<int>("intensity");
|
||||
|
||||
std::cerr << msg << std::endl;
|
||||
for (Point_set::const_iterator it = ps.begin(); it != ps.end(); ++ it)
|
||||
|
|
@ -47,7 +46,6 @@ void print_point_set (const Point_set& ps, const char* msg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
Point_set ps1, ps2;
|
||||
|
|
|
|||
|
|
@ -210,13 +210,13 @@ descriptor
|
|||
- a tuple consisting of a property map, a functor to construct the
|
||||
objects wanted and multiple %PLY/%LAS property descriptors
|
||||
|
||||
Output functions `write_ply_points_with_properties()` and
|
||||
`write_las_points_with_properties()` work similarly.
|
||||
Output functions `write_PLY_with_properties()` and
|
||||
`write_LAS_with_properties()` work similarly.
|
||||
|
||||
\subsubsection Point_set_processing_3Example_ply_write PLY Writing Example
|
||||
|
||||
The following example shows how to call
|
||||
`write_ply_points_with_properties()` to write a point set with points,
|
||||
`write_PLY_with_properties()` to write a point set with points,
|
||||
RGB colors and intensity. Notice that in order to write a complex
|
||||
object, users need to provide an overload of `CGAL::Output_rep`.
|
||||
|
||||
|
|
|
|||
|
|
@ -20,41 +20,41 @@ typedef CGAL::Parallel_if_available_tag Concurrency_tag;
|
|||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* fname = (argc>1)?argv[1]:"data/sphere_20k.xyz";
|
||||
// Reads a .xyz point set file in points.
|
||||
// As the point is the second element of the tuple (that is with index 1)
|
||||
// we use a property map that accesses the 1st element of the tuple.
|
||||
const char* fname = (argc>1)?argv[1]:"data/sphere_20k.xyz";
|
||||
|
||||
std::vector<IndexedPointWithColorTuple> points;
|
||||
if (!CGAL::read_points(
|
||||
fname, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Reads a .xyz point set file in points.
|
||||
// As the point is the second element of the tuple (that is with index 1)
|
||||
// we use a property map that accesses the 1st element of the tuple.
|
||||
|
||||
// Initialize index and RGB color fields in tuple.
|
||||
// As the index and RGB color are respectively the first and third-fifth elements
|
||||
// of the tuple we use a get function from the property map that accesses the 0
|
||||
// and 2-4th elements of the tuple.
|
||||
for(unsigned int i = 0; i < points.size(); i++)
|
||||
{
|
||||
points[i].get<0>() = i; // set index value of tuple to i
|
||||
std::vector<IndexedPointWithColorTuple> points;
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1, IndexedPointWithColorTuple>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
points[i].get<2>() = 0; // set RGB color to black
|
||||
points[i].get<3>() = 0;
|
||||
points[i].get<4>() = 0;
|
||||
}
|
||||
// Initialize index and RGB color fields in tuple.
|
||||
// As the index and RGB color are respectively the first and third-fifth elements
|
||||
// of the tuple we use a get function from the property map that accesses the 0
|
||||
// and 2-4th elements of the tuple.
|
||||
for(unsigned int i = 0; i < points.size(); i++)
|
||||
{
|
||||
points[i].get<0>() = i; // set index value of tuple to i
|
||||
|
||||
// Computes average spacing.
|
||||
const unsigned int nb_neighbors = 6; // 1 ring
|
||||
FT average_spacing = CGAL::compute_average_spacing<Concurrency_tag>(
|
||||
points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>()));
|
||||
points[i].get<2>() = 0; // set RGB color to black
|
||||
points[i].get<3>() = 0;
|
||||
points[i].get<4>() = 0;
|
||||
}
|
||||
|
||||
std::cout << "Average spacing: " << average_spacing << std::endl;
|
||||
// Computes average spacing.
|
||||
const unsigned int nb_neighbors = 6; // 1 ring
|
||||
FT average_spacing = CGAL::compute_average_spacing<Concurrency_tag>(
|
||||
points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>()));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
std::cout << "Average spacing: " << average_spacing << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ typedef CGAL::Parallel_if_available_tag Concurrency_tag;
|
|||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* input_filename = (argc>1)?argv[1]:"data/fin90_with_PCA_normals.xyz";
|
||||
const char* output_filename = (argc>2)?argv[2]:"data/fin90_with_PCA_normals_bilateral_smoothed.xyz";
|
||||
const char* input_filename = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz";
|
||||
const char* output_filename = (argc>2) ? argv[2] : "data/fin90_with_PCA_normals_bilateral_smoothed.xyz";
|
||||
|
||||
// Reads a .xyz point set file in points[] * with normals *.
|
||||
std::vector<PointVectorPair> points;
|
||||
if (!CGAL::read_points(input_filename, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
if(!CGAL::read_points(input_filename, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -42,26 +42,23 @@ int main(int argc, char*argv[])
|
|||
// The bigger the smoother the result will be
|
||||
int iter_number = 3; // number of times the projection is applied
|
||||
|
||||
for (int i = 0; i < iter_number; ++i)
|
||||
for(int i = 0; i < iter_number; ++i)
|
||||
{
|
||||
/* double error = */
|
||||
CGAL::bilateral_smooth_point_set <Concurrency_tag>(
|
||||
points,
|
||||
k,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
sharpness_angle (sharpness_angle));
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
|
||||
.sharpness_angle (sharpness_angle));
|
||||
}
|
||||
|
||||
//// Save point set.
|
||||
std::ofstream out(output_filename);
|
||||
out.precision(17);
|
||||
if (!out || !CGAL::write_XYZ(out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
if(!CGAL::write_XYZ(output_filename, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
|
||||
.stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,35 +60,29 @@ struct Progress_to_std_cerr_callback
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int N = (argc > 1) ? boost::lexical_cast<int>(argv[1]) : 1000;
|
||||
|
||||
// Generate N points on a sphere of radius 100.
|
||||
std::vector<Point> points;
|
||||
points.reserve (N);
|
||||
points.reserve(N);
|
||||
Generator generator(100.);
|
||||
std::copy_n (generator, N, std::back_inserter(points));
|
||||
std::copy_n(generator, N, std::back_inserter(points));
|
||||
|
||||
// Compute average spacing
|
||||
FT average_spacing = CGAL::compute_average_spacing<Concurrency_tag>
|
||||
(points, 6,
|
||||
CGAL::parameters::callback
|
||||
(Progress_to_std_cerr_callback("Computing average spacing")));
|
||||
CGAL::parameters::callback(Progress_to_std_cerr_callback("Computing average spacing")));
|
||||
|
||||
// Simplify on a grid with a size of twice the average spacing
|
||||
points.erase(CGAL::grid_simplify_point_set
|
||||
(points, 2. * average_spacing,
|
||||
CGAL::parameters::callback
|
||||
(Progress_to_std_cerr_callback("Grid simplification"))),
|
||||
points.erase(CGAL::grid_simplify_point_set(points, 2. * average_spacing,
|
||||
CGAL::parameters::callback(Progress_to_std_cerr_callback("Grid simplification"))),
|
||||
points.end());
|
||||
|
||||
// Smooth simplified point set
|
||||
CGAL::jet_smooth_point_set<Concurrency_tag>
|
||||
(points, 6,
|
||||
CGAL::parameters::callback
|
||||
(Progress_to_std_cerr_callback("Jet smoothing")));
|
||||
CGAL::jet_smooth_point_set<Concurrency_tag>(points, 6,
|
||||
CGAL::parameters::callback(Progress_to_std_cerr_callback("Jet smoothing")));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <CGAL/Real_timer.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Point_3 = Kernel::Point_3;
|
||||
|
|
@ -16,12 +17,12 @@ using Point_set = CGAL::Point_set_3<Point_3>;
|
|||
int main (int argc, char** argv)
|
||||
{
|
||||
// Read input file
|
||||
std::ifstream ifile ((argc > 1) ? argv[1] : "data/hippo1.ply", std::ios_base::binary);
|
||||
std::ifstream ifile((argc > 1) ? argv[1] : "data/hippo1.ply", std::ios_base::binary);
|
||||
Point_set points;
|
||||
ifile >> points;
|
||||
|
||||
// Add a cluster map
|
||||
Point_set::Property_map<int> cluster_map = points.add_property_map<int> ("cluster", -1).first;
|
||||
Point_set::Property_map<int> cluster_map = points.add_property_map<int>("cluster", -1).first;
|
||||
|
||||
// Compute average spacing
|
||||
double spacing = CGAL::compute_average_spacing<CGAL::Parallel_if_available_tag> (points, 12);
|
||||
|
|
@ -34,9 +35,9 @@ int main (int argc, char** argv)
|
|||
CGAL::Real_timer t;
|
||||
t.start();
|
||||
std::size_t nb_clusters
|
||||
= CGAL::cluster_point_set (points, cluster_map,
|
||||
points.parameters().neighbor_radius(spacing).
|
||||
adjacencies (std::back_inserter (adjacencies)));
|
||||
= CGAL::cluster_point_set(points, cluster_map,
|
||||
points.parameters().neighbor_radius(spacing)
|
||||
.adjacencies(std::back_inserter(adjacencies)));
|
||||
t.stop();
|
||||
std::cerr << "Found " << nb_clusters << " clusters with " << adjacencies.size()
|
||||
<< " adjacencies in " << t.time() << " seconds" << std::endl;
|
||||
|
|
@ -45,7 +46,7 @@ int main (int argc, char** argv)
|
|||
Point_set::Property_map<unsigned char> red = points.add_property_map<unsigned char>("red", 0).first;
|
||||
Point_set::Property_map<unsigned char> green = points.add_property_map<unsigned char>("green", 0).first;
|
||||
Point_set::Property_map<unsigned char> blue = points.add_property_map<unsigned char>("blue", 0).first;
|
||||
for (Point_set::Index idx : points)
|
||||
for(Point_set::Index idx : points)
|
||||
{
|
||||
// One color per cluster
|
||||
CGAL::Random rand (cluster_map[idx]);
|
||||
|
|
@ -54,8 +55,8 @@ int main (int argc, char** argv)
|
|||
blue[idx] = rand.get_int(64, 192);
|
||||
}
|
||||
|
||||
std::ofstream ofile ("out.ply", std::ios_base::binary);
|
||||
CGAL::set_binary_mode (ofile);
|
||||
std::ofstream ofile("out.ply", std::ios_base::binary);
|
||||
CGAL::set_binary_mode(ofile);
|
||||
ofile << points;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -20,15 +20,15 @@ typedef CGAL::Parallel_if_available_tag Concurrency_tag;
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* input_filename = (argc>1)?argv[1]:"data/before_upsample.xyz";
|
||||
const char* output_filename = (argc>2)?argv[2]:"data/before_upsample_UPSAMPLED.xyz";
|
||||
const char* input_filename = (argc>1) ? argv[1] : "data/before_upsample.xyz";
|
||||
const char* output_filename = (argc>2) ? argv[2] : "data/before_upsample_UPSAMPLED.xyz";
|
||||
|
||||
// Reads a .xyz point set file in points[], *with normals*.
|
||||
std::vector<PointVectorPair> points;
|
||||
if (!CGAL::read_points(input_filename,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
if(!CGAL::read_points(input_filename,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -52,14 +52,11 @@ int main(int argc, char* argv[])
|
|||
number_of_output_points(number_of_output_points));
|
||||
|
||||
// Saves point set.
|
||||
std::ofstream out(output_filename);
|
||||
out.precision(17);
|
||||
if (!out || !CGAL::write_XYZ(out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
if(!CGAL::write_points(output_filename, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
|
||||
.stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
// Types
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
|
|
@ -19,38 +18,39 @@ typedef std::vector<PointVectorPair> PointList;
|
|||
|
||||
typedef std::array<double,6> Covariance;
|
||||
|
||||
int main (int , char**) {
|
||||
// Reads a .xyz point set file in points[].
|
||||
std::list<PointVectorPair> points;
|
||||
if (!CGAL::read_points("data/fandisk.off",
|
||||
int main (int , char**)
|
||||
{
|
||||
// Reads a .xyz point set file in points[].
|
||||
std::list<PointVectorPair> points;
|
||||
if(!CGAL::read_points("data/fandisk.off",
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/fandisk.off" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/fandisk.off" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Estimates covariance matrices per points.
|
||||
double R = 0.2,
|
||||
r = 0.1;
|
||||
std::vector<Covariance> cov;
|
||||
CGAL::First_of_pair_property_map<PointVectorPair> point_map;
|
||||
// Estimates covariance matrices per points.
|
||||
double R = 0.2,
|
||||
r = 0.1;
|
||||
std::vector<Covariance> cov;
|
||||
CGAL::First_of_pair_property_map<PointVectorPair> point_map;
|
||||
|
||||
CGAL::compute_vcm(points, cov, R, r,
|
||||
CGAL::parameters::point_map (point_map).geom_traits (Kernel()));
|
||||
CGAL::compute_vcm(points, cov, R, r,
|
||||
CGAL::parameters::point_map (point_map).geom_traits (Kernel()));
|
||||
|
||||
// Find the points on the edges.
|
||||
// Note that this step is not expensive and can be done several time to get better results
|
||||
double threshold = 0.16;
|
||||
std::ofstream output("points_on_edges.xyz");
|
||||
int i = 0;
|
||||
for(const PointVectorPair& p : points)
|
||||
{
|
||||
if (CGAL::vcm_is_on_feature_edge(cov[i], threshold))
|
||||
output << p.first << "\n";
|
||||
++i;
|
||||
}
|
||||
// Find the points on the edges.
|
||||
// Note that this step is not expensive and can be done several time to get better results
|
||||
double threshold = 0.16;
|
||||
std::ofstream output("points_on_edges.xyz");
|
||||
int i = 0;
|
||||
for(const PointVectorPair& p : points)
|
||||
{
|
||||
if(CGAL::vcm_is_on_feature_edge(cov[i], threshold))
|
||||
output << p.first << "\n";
|
||||
++i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/grid_simplify_point_set.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
|
||||
|
|
@ -13,8 +14,8 @@ int main(int argc, char*argv[])
|
|||
{
|
||||
// Reads a .xyz point set file in points[].
|
||||
std::vector<Point> points;
|
||||
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
const char* fname = (argc>1) ? argv[1] : "data/oni.xyz";
|
||||
if(!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -22,12 +23,10 @@ int main(int argc, char*argv[])
|
|||
|
||||
// simplification by clustering using erase-remove idiom
|
||||
double cell_size = 0.001;
|
||||
points.erase(CGAL::grid_simplify_point_set(points, cell_size),
|
||||
points.end());
|
||||
points.erase(CGAL::grid_simplify_point_set(points, cell_size), points.end());
|
||||
|
||||
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
|
||||
std::vector<Point>(points).swap(points);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/grid_simplify_point_set.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
|
|
@ -15,11 +16,12 @@ int main(int argc, char*argv[])
|
|||
// Reads a .xyz point set file in points[].
|
||||
std::vector<Point> points;
|
||||
std::vector<Vector> normals;
|
||||
const char* fname = (argc>1)?argv[1]:"data/fin90_with_PCA_normals.xyz";
|
||||
const char* fname = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz";
|
||||
std::ifstream stream(fname);
|
||||
Point p;
|
||||
Vector v;
|
||||
while(stream >> p >> v){
|
||||
while(stream >> p >> v)
|
||||
{
|
||||
points.push_back(p);
|
||||
normals.push_back(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,23 +15,24 @@ typedef Kernel::Point_3 Point;
|
|||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
// Reads a .xyz point set file in points[].
|
||||
// Reads a point set file in points[].
|
||||
std::vector<Point> points;
|
||||
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
if(!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "Read " << points.size () << " point(s)" << std::endl;
|
||||
|
||||
CGAL::Timer task_timer; task_timer.start();
|
||||
|
||||
// simplification by clustering using erase-remove idiom
|
||||
points.erase (CGAL::hierarchy_simplify_point_set (points,
|
||||
CGAL::parameters::size(100). // Max cluster size
|
||||
maximum_variation(0.01)), // Max surface variation
|
||||
points.end ());
|
||||
points.erase(CGAL::hierarchy_simplify_point_set(points,
|
||||
CGAL::parameters::size(100)// Max cluster size
|
||||
.maximum_variation(0.01)), // Max surface variation
|
||||
points.end());
|
||||
|
||||
std::size_t memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
||||
|
|
@ -39,9 +40,7 @@ int main(int argc, char*argv[])
|
|||
<< task_timer.time() << " seconds, "
|
||||
<< (memory>>20) << " Mib allocated." << std::endl;
|
||||
|
||||
std::ofstream f ("out.xyz");
|
||||
f.precision(17);
|
||||
CGAL::write_XYZ (f, points);
|
||||
CGAL::write_points("out.xyz", points, CGAL::parameters::stream_precision(17));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,3 @@ int main(void)
|
|||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@
|
|||
//----------------------------------------------------------
|
||||
// normal_estimation file_in file_out [options]
|
||||
|
||||
// CGAL
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
// This package
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
#include <CGAL/pca_estimate_normals.h>
|
||||
#include <CGAL/jet_estimate_normals.h>
|
||||
#include <CGAL/vcm_estimate_normals.h>
|
||||
#include <CGAL/mst_orient_normals.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
|
||||
// CGAL
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
#include <utility> // defines std::pair
|
||||
#include <vector>
|
||||
|
|
@ -29,7 +29,6 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
@ -69,7 +68,6 @@ void run_pca_estimate_normals(PointList& points, // input points + output normal
|
|||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map (CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
|
||||
|
||||
std::size_t memory = CGAL::Memory_sizer().virtual_size();
|
||||
std::cerr << "done: " << task_timer.time() << " seconds, "
|
||||
<< (memory>>20) << " Mb allocated"
|
||||
|
|
@ -247,21 +245,8 @@ int main(int argc, char * argv[])
|
|||
std::cerr << "Open " << input_filename << " for reading..." << std::endl;
|
||||
|
||||
// If OFF file format
|
||||
bool success = false;
|
||||
std::string extension = input_filename.substr(input_filename.find_last_of('.'));
|
||||
if (extension == ".off" || extension == ".OFF")
|
||||
{
|
||||
success = CGAL::read_points(input_filename.c_str(), std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
// If XYZ file format
|
||||
else if (extension == ".xyz" || extension == ".XYZ" ||
|
||||
extension == ".pwn" || extension == ".PWN")
|
||||
{
|
||||
success = CGAL::read_points(input_filename.c_str(), std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
if (!success)
|
||||
if(!CGAL::read_points(input_filename.c_str(), std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -278,7 +263,7 @@ int main(int argc, char * argv[])
|
|||
// Check requirements
|
||||
//***************************************
|
||||
|
||||
if (nb_points == 0)
|
||||
if(nb_points == 0)
|
||||
{
|
||||
std::cerr << "Error: empty file" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -306,25 +291,13 @@ int main(int argc, char * argv[])
|
|||
|
||||
std::cerr << "Write file " << output_filename << std::endl << std::endl;
|
||||
|
||||
// If XYZ file format
|
||||
/*std::string*/ extension = output_filename.substr(output_filename.find_last_of('.'));
|
||||
if (extension == ".xyz" || extension == ".XYZ" ||
|
||||
extension == ".pwn" || extension == ".PWN")
|
||||
if(!CGAL::write_points(output_filename, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
|
||||
.stream_precision(17)))
|
||||
{
|
||||
std::ofstream stream(output_filename.c_str());
|
||||
stream.precision(17);
|
||||
if (!stream || !CGAL::write_XYZ(stream, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot write file " << output_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error: cannot write file " << output_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
std::cerr << "Error: cannot write file " << output_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Returns accumulated fatal error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/compute_average_spacing.h>
|
||||
#include <CGAL/pca_estimate_normals.h>
|
||||
#include <CGAL/mst_orient_normals.h>
|
||||
|
|
@ -22,58 +23,58 @@ typedef CGAL::Parallel_if_available_tag Concurrency_tag;
|
|||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* fname = (argc>1)?argv[1]:"data/sphere_1k.xyz";
|
||||
// Reads a .xyz point set file in points[].
|
||||
std::list<PointVectorPair> points;
|
||||
if (!CGAL::read_points(fname,
|
||||
const char* fname = (argc>1) ? argv[1] : "data/sphere_1k.xyz";
|
||||
|
||||
// Reads a .xyz point set file in points[].
|
||||
std::list<PointVectorPair> points;
|
||||
if(!CGAL::read_points(fname,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Estimates normals direction.
|
||||
// Note: pca_estimate_normals() requiresa range of points
|
||||
// as well as property maps to access each point's position and normal.
|
||||
const int nb_neighbors = 18; // K-nearest neighbors = 3 rings
|
||||
// Estimates normals direction.
|
||||
// Note: pca_estimate_normals() requiresa range of points
|
||||
// as well as property maps to access each point's position and normal.
|
||||
const int nb_neighbors = 18; // K-nearest neighbors = 3 rings
|
||||
|
||||
if (argc > 2 && std::strcmp(argv[2], "-r") == 0) // Use a fixed neighborhood radius
|
||||
{
|
||||
// First compute a spacing using the K parameter
|
||||
double spacing
|
||||
if (argc > 2 && std::strcmp(argv[2], "-r") == 0) // Use a fixed neighborhood radius
|
||||
{
|
||||
// First compute a spacing using the K parameter
|
||||
double spacing
|
||||
= CGAL::compute_average_spacing<Concurrency_tag>
|
||||
(points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
(points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()));
|
||||
|
||||
// Then, estimate normals with a fixed radius
|
||||
CGAL::pca_estimate_normals<Concurrency_tag>
|
||||
// Then, estimate normals with a fixed radius
|
||||
CGAL::pca_estimate_normals<Concurrency_tag>
|
||||
(points,
|
||||
0, // when using a neighborhood radius, K=0 means no limit on the number of neighbors returns
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
|
||||
neighbor_radius(2. * spacing)); // use 2*spacing as neighborhood radius
|
||||
}
|
||||
else // Use a fixed number of neighbors
|
||||
{
|
||||
CGAL::pca_estimate_normals<Concurrency_tag>
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
|
||||
.neighbor_radius(2. * spacing)); // use 2*spacing as neighborhood radius
|
||||
}
|
||||
else // Use a fixed number of neighbors
|
||||
{
|
||||
CGAL::pca_estimate_normals<Concurrency_tag>
|
||||
(points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
}
|
||||
|
||||
// Orients normals.
|
||||
// Note: mst_orient_normals() requires a range of points
|
||||
// as well as property maps to access each point's position and normal.
|
||||
std::list<PointVectorPair>::iterator unoriented_points_begin =
|
||||
// Orients normals.
|
||||
// Note: mst_orient_normals() requires a range of points
|
||||
// as well as property maps to access each point's position and normal.
|
||||
std::list<PointVectorPair>::iterator unoriented_points_begin =
|
||||
CGAL::mst_orient_normals(points, nb_neighbors,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()));
|
||||
|
||||
// Optional: delete points with an unoriented normal
|
||||
// if you plan to call a reconstruction algorithm that expects oriented normals.
|
||||
points.erase(unoriented_points_begin, points.end());
|
||||
// Optional: delete points with an unoriented normal
|
||||
// if you plan to call a reconstruction algorithm that expects oriented normals.
|
||||
points.erase(unoriented_points_begin, points.end());
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ struct MyLess {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// In this example we have a function that only operates on the point part.
|
||||
// It sorts them lexicographically.
|
||||
|
||||
|
|
@ -54,7 +53,6 @@ void process_point_set(Iterator beg, Iterator end, PointPMap pmap)
|
|||
std::sort(beg,end,less);
|
||||
}
|
||||
|
||||
|
||||
// We can call it just with points. Then interally we use a property map
|
||||
// that maps point iterators on points.
|
||||
|
||||
|
|
@ -67,8 +65,6 @@ void process_point_set(Iterator beg, Iterator end)
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Here comes a function that changes the orientation and the normal
|
||||
|
||||
template <typename Iterator, typename OrientationPMap, typename NormalPMap >
|
||||
|
|
@ -84,8 +80,6 @@ void orient_normals(Iterator beg, Iterator end, OrientationPMap orient_pmap, Nor
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
CGAL::set_pretty_mode(std::cout);
|
||||
|
|
@ -93,30 +87,23 @@ int main()
|
|||
// Here we run it on plain points. No need for a property map
|
||||
{
|
||||
std::vector<Point_3> points;
|
||||
|
||||
process_point_set(points.begin(), points.end());
|
||||
}
|
||||
|
||||
|
||||
// Here we run it on points with normal vectors stored in a std::pair.
|
||||
// We use a property map that accesses pair::first.
|
||||
{
|
||||
std::vector<PointVectorPair> points;
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
for(int i = 0; i < 10; i++)
|
||||
points.push_back(std::make_pair(Point_3(9-i,0,0), Vector_3(i,0,0)));
|
||||
}
|
||||
|
||||
process_point_set(points.begin(),
|
||||
points.end(),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>());
|
||||
process_point_set(points.begin(), points.end(), CGAL::First_of_pair_property_map<PointVectorPair>());
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
for(int i = 0; i < 10; i++)
|
||||
std::cout << points[i].first << "\t" << points[i].second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Here we run it on tuples. To see the interest I made up my own
|
||||
// data type = index, followed by the point, followed by a Boolean
|
||||
// that tells us whether the normal is oriented or not, followed by the normal vector.
|
||||
|
|
@ -128,31 +115,27 @@ int main()
|
|||
typedef boost::tuple<int, Point_3, bool, Vector_3> IndexedPointWithOrientableNormalTuple;
|
||||
std::vector<IndexedPointWithOrientableNormalTuple> points;
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
double x = (i%2)?i:-i;
|
||||
points.push_back(boost::make_tuple(i,Point_3(9-i,0,0), false, Vector_3(x,0,0)));
|
||||
}
|
||||
|
||||
process_point_set(points.begin(),
|
||||
points.end(),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithOrientableNormalTuple>());
|
||||
process_point_set(points.begin(), points.end(), CGAL::Nth_of_tuple_property_map<1,IndexedPointWithOrientableNormalTuple>());
|
||||
|
||||
std::cout << boost::tuples::set_open('[') << boost::tuples::set_close(']') << boost::tuples::set_delimiter(',');
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
std::cout << points[i] << std::endl;
|
||||
}
|
||||
for(int i = 0; i < 10; i++)
|
||||
std::cout << points[i] << std::endl;
|
||||
|
||||
//We keep the sequence in order, but determine the normal and if it is different from zero set the Boolean to true
|
||||
orient_normals(points.begin(),
|
||||
points.end(),
|
||||
orient_normals(points.begin(), points.end(),
|
||||
CGAL::make_nth_of_tuple_property_map<2>(IndexedPointWithOrientableNormalTuple()),
|
||||
CGAL::make_nth_of_tuple_property_map<3>(IndexedPointWithOrientableNormalTuple()));
|
||||
|
||||
std::cout << "\nAfter orient_normals\n";
|
||||
for(int i = 0; i < 10; i++){
|
||||
std::cout << points[i] << std::endl;
|
||||
}
|
||||
for(int i = 0; i < 10; i++)
|
||||
std::cout << points[i] << std::endl;
|
||||
}
|
||||
|
||||
// same test with std::tuple
|
||||
|
|
@ -160,17 +143,16 @@ int main()
|
|||
typedef std::tuple<int, Point_3, bool, Vector_3> IndexedPointWithOrientableNormalTuple;
|
||||
std::vector<IndexedPointWithOrientableNormalTuple> points;
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
double x = (i%2)?i:-i;
|
||||
points.push_back(std::make_tuple(i,Point_3(9-i,0,0), false, Vector_3(x,0,0)));
|
||||
}
|
||||
|
||||
process_point_set(points.begin(),
|
||||
points.end(),
|
||||
process_point_set(points.begin(), points.end(),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithOrientableNormalTuple>());
|
||||
|
||||
orient_normals(points.begin(),
|
||||
points.end(),
|
||||
orient_normals(points.begin(), points.end(),
|
||||
CGAL::make_nth_of_tuple_property_map<2>(IndexedPointWithOrientableNormalTuple()),
|
||||
CGAL::make_nth_of_tuple_property_map<3>(IndexedPointWithOrientableNormalTuple()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/random_simplify_point_set.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_xyz_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
|
@ -13,10 +14,11 @@ typedef Kernel::Point_3 Point;
|
|||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
|
||||
// Reads a .xyz point set file in points[].
|
||||
const char* fname = (argc>1) ? argv[1] : "data/oni.xyz";
|
||||
|
||||
// Reads a point set file in points[].
|
||||
std::vector<Point> points;
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
if(!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -24,22 +26,15 @@ int main(int argc, char*argv[])
|
|||
|
||||
// Randomly simplifies using erase-remove idiom
|
||||
const double removed_percentage = 97.0; // percentage of points to remove
|
||||
points.erase(CGAL::random_simplify_point_set(points, removed_percentage),
|
||||
points.end());
|
||||
points.erase(CGAL::random_simplify_point_set(points, removed_percentage), points.end());
|
||||
|
||||
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
|
||||
std::vector<Point>(points).swap(points);
|
||||
|
||||
// Saves point set.
|
||||
std::ofstream out((argc>2)?argv[2]:"Three_lady_copy.xyz");
|
||||
out.precision(17);
|
||||
if (!out ||
|
||||
!CGAL::write_XYZ(
|
||||
out, points))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
const std::string output_filename = (argc>2) ? argv[2] : "Three_lady_copy.xyz";
|
||||
if(!CGAL::write_points(output_filename, points, CGAL::parameters::stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/read_las_points.h>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
@ -21,24 +22,20 @@ int main(int argc, char*argv[])
|
|||
std::vector<PointWithColor> points; // store points
|
||||
std::ifstream in(fname, std::ios_base::binary);
|
||||
|
||||
if (!in ||
|
||||
!CGAL::read_LAS_with_properties
|
||||
(in,
|
||||
std::back_inserter (points),
|
||||
CGAL::make_las_point_reader (CGAL::First_of_pair_property_map<PointWithColor>()),
|
||||
std::make_tuple
|
||||
(CGAL::Second_of_pair_property_map<PointWithColor>(),
|
||||
CGAL::Construct_array(),
|
||||
CGAL::LAS_property::R(),
|
||||
CGAL::LAS_property::G(),
|
||||
CGAL::LAS_property::B(),
|
||||
CGAL::LAS_property::I())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::read_LAS_with_properties(in, std::back_inserter (points),
|
||||
CGAL::make_las_point_reader(CGAL::First_of_pair_property_map<PointWithColor>()),
|
||||
std::make_tuple(CGAL::Second_of_pair_property_map<PointWithColor>(),
|
||||
CGAL::Construct_array(),
|
||||
CGAL::LAS_property::R(),
|
||||
CGAL::LAS_property::G(),
|
||||
CGAL::LAS_property::B(),
|
||||
CGAL::LAS_property::I())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < points.size(); ++ i)
|
||||
for(std::size_t i = 0; i < points.size(); ++ i)
|
||||
std::cout << points[i].first << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
@ -23,41 +24,36 @@ typedef CGAL::Nth_of_tuple_property_map<3, PNCI> Intensity_map;
|
|||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* fname = (argc>1) ? argv[1] : "data/colors.ply";
|
||||
// Reads a .ply point set file with normal vectors and colors
|
||||
|
||||
// Reads a .ply point set file with normal vectors and colors
|
||||
std::vector<PNCI> points; // store points
|
||||
std::ifstream in(fname);
|
||||
|
||||
if (!in ||
|
||||
!CGAL::read_PLY_with_properties
|
||||
(in,
|
||||
std::back_inserter (points),
|
||||
CGAL::make_ply_point_reader (Point_map()),
|
||||
std::make_pair (Intensity_map(),
|
||||
CGAL::PLY_property<int>("intensity")),
|
||||
std::make_tuple (Color_map(),
|
||||
CGAL::Construct_array(),
|
||||
CGAL::PLY_property<unsigned char>("red"),
|
||||
CGAL::PLY_property<unsigned char>("green"),
|
||||
CGAL::PLY_property<unsigned char>("blue")),
|
||||
CGAL::make_ply_normal_reader (Normal_map())
|
||||
))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::read_PLY_with_properties(in, std::back_inserter(points),
|
||||
CGAL::make_ply_point_reader(Point_map()),
|
||||
std::make_pair(Intensity_map(), CGAL::PLY_property<int>("intensity")),
|
||||
std::make_tuple(Color_map(),
|
||||
CGAL::Construct_array(),
|
||||
CGAL::PLY_property<unsigned char>("red"),
|
||||
CGAL::PLY_property<unsigned char>("green"),
|
||||
CGAL::PLY_property<unsigned char>("blue")),
|
||||
CGAL::make_ply_normal_reader(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Display points read
|
||||
for (std::size_t i = 0; i < points.size (); ++ i)
|
||||
{
|
||||
const Point& p = get<0>(points[i]);
|
||||
const Vector& n = get<1>(points[i]);
|
||||
const Color& c = get<2>(points[i]);
|
||||
int I = get<3>(points[i]);
|
||||
std::cerr << "Point (" << p << ") with normal (" << n
|
||||
<< "), color (" << int(c[0]) << " " << int(c[1]) << " " << int(c[2])
|
||||
<< ") and intensity " << I << std::endl;
|
||||
}
|
||||
for(std::size_t i = 0; i < points.size (); ++ i)
|
||||
{
|
||||
const Point& p = get<0>(points[i]);
|
||||
const Vector& n = get<1>(points[i]);
|
||||
const Color& c = get<2>(points[i]);
|
||||
int I = get<3>(points[i]);
|
||||
std::cerr << "Point (" << p
|
||||
<< ") with normal (" << n
|
||||
<< "), color (" << int(c[0]) << " " << int(c[1]) << " " << int(c[2])
|
||||
<< ") and intensity " << I << std::endl;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/read_xyz_points.h>
|
||||
#include <CGAL/IO/write_xyz_points.h>
|
||||
|
||||
#include <utility> // defines std::pair
|
||||
|
|
@ -24,10 +24,10 @@ int main(int argc, char*argv[])
|
|||
// over points and as well as property maps to access each
|
||||
// point position and normal.
|
||||
std::vector<Pwn> points;
|
||||
if (!CGAL::read_points(fname,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map (CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
if(!CGAL::read_XYZ(fname,
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -36,16 +36,11 @@ int main(int argc, char*argv[])
|
|||
// Saves point set.
|
||||
// Note: write_XYZ() requires property maps to access each
|
||||
// point position and normal.
|
||||
std::ofstream out("oni_copy.xyz");
|
||||
out.precision(17);
|
||||
if (!out ||
|
||||
!CGAL::write_XYZ(
|
||||
out, points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
if(!CGAL::write_XYZ("oni_copy.xyz", points,
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<Pwn>())
|
||||
.stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,21 +21,21 @@ namespace params = CGAL::parameters;
|
|||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
const char* fname1 = (argc>1)?argv[1]:"data/hippo1.ply";
|
||||
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
|
||||
const char* fname1 = (argc>1) ? argv[1] : "data/hippo1.ply";
|
||||
const char* fname2 = (argc>2) ? argv[2] : "data/hippo2.ply";
|
||||
|
||||
std::vector<Pwn> pwns1, pwns2;
|
||||
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname1 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map (Point_map()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname2 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -45,33 +45,29 @@ int main(int argc, const char** argv)
|
|||
// std::pair<K::Aff_transformation_3, double> res =
|
||||
CGAL::OpenGR::compute_registration_transformation(pwns1, pwns2,
|
||||
params::point_map(Point_map())
|
||||
.normal_map(Normal_map())
|
||||
.number_of_samples(200)
|
||||
.maximum_running_time(60)
|
||||
.accuracy(0.01),
|
||||
.normal_map(Normal_map())
|
||||
.number_of_samples(200)
|
||||
.maximum_running_time(60)
|
||||
.accuracy(0.01),
|
||||
params::point_map(Point_map())
|
||||
.normal_map(Normal_map()));
|
||||
.normal_map(Normal_map()));
|
||||
|
||||
// OR call the registration method Super4PCS from OpenGR and apply the transformation to pwn2
|
||||
double score =
|
||||
CGAL::OpenGR::register_point_sets(pwns1, pwns2,
|
||||
params::point_map(Point_map())
|
||||
.normal_map(Normal_map())
|
||||
.number_of_samples(200)
|
||||
.maximum_running_time(60)
|
||||
.accuracy(0.01),
|
||||
.normal_map(Normal_map())
|
||||
.number_of_samples(200)
|
||||
.maximum_running_time(60)
|
||||
.accuracy(0.01),
|
||||
params::point_map(Point_map())
|
||||
.normal_map(Normal_map()));
|
||||
.normal_map(Normal_map()));
|
||||
|
||||
std::ofstream out("pwns2_aligned.ply");
|
||||
if (!out ||
|
||||
!CGAL::write_PLY(
|
||||
out, pwns2,
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
{
|
||||
if(!CGAL::write_points("pwns2_aligned.ply", pwns2,
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())
|
||||
.stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "Registration score: " << score << ".\n"
|
||||
<< "Transformed version of " << fname2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_ply_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/Aff_transformation_3.h>
|
||||
|
||||
|
|
@ -24,21 +25,21 @@ namespace params = CGAL::parameters;
|
|||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
const char* fname1 = (argc>1)?argv[1]:"data/hippo1.ply";
|
||||
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
|
||||
const char* fname1 = (argc>1) ? argv[1] : "data/hippo1.ply";
|
||||
const char* fname2 = (argc>2) ? argv[2] : "data/hippo2.ply";
|
||||
|
||||
std::vector<Pwn> pwns1, pwns2;
|
||||
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map (Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname1 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map (Point_map()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname2 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -51,8 +52,7 @@ int main(int argc, const char** argv)
|
|||
CGAL::OpenGR::compute_registration_transformation
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map()),
|
||||
params::point_map(Point_map()).normal_map(Normal_map()))
|
||||
);
|
||||
params::point_map(Point_map()).normal_map(Normal_map())));
|
||||
|
||||
std::cerr << "Computing registration transformation using PointMatcher ICP, "
|
||||
<< "taking transformation computed by OpenGR Super4PCS as initial transformation.." << std::endl;
|
||||
|
|
@ -62,15 +62,11 @@ int main(int argc, const char** argv)
|
|||
CGAL::pointmatcher::register_point_sets
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map()),
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.transformation(res));
|
||||
params::point_map(Point_map()).normal_map(Normal_map()).transformation(res));
|
||||
|
||||
std::ofstream out("pwns2_aligned.ply");
|
||||
if (!out ||
|
||||
!CGAL::write_PLY(
|
||||
out, pwns2,
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
if(!CGAL::write_points("pwns2_aligned.ply", pwns2,
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ int main(int argc, const char** argv)
|
|||
const char* fname2 = (argc>2)?argv[2]:"data/hippo2.ply";
|
||||
|
||||
std::vector<Pwn> pwns1, pwns2;
|
||||
if (!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map (CGAL::First_of_pair_property_map<Pwn>()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname1, std::back_inserter(pwns1),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname1 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map (Point_map()).
|
||||
normal_map (Normal_map())))
|
||||
if(!CGAL::read_points(fname2, std::back_inserter(pwns2),
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname2 << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -89,64 +89,59 @@ int main(int argc, const char** argv)
|
|||
|
||||
// EITHER call the ICP registration method pointmatcher to get the transformation to apply to pwns2
|
||||
std::pair<K::Aff_transformation_3, bool> res =
|
||||
CGAL::pointmatcher::compute_registration_transformation
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_1_filters)
|
||||
.matcher(matcher)
|
||||
.outlier_filters(outlier_filters)
|
||||
.error_minimizer(error_minimizer)
|
||||
.transformation_checkers(transformation_checkers)
|
||||
.inspector(inspector)
|
||||
.logger(logger),
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_2_filters)
|
||||
.transformation(identity_transform) /* initial transform for pwns2.
|
||||
* default value is already identity transform.
|
||||
* a proper initial transform could be given, for example,
|
||||
* a transform returned from a coarse registration algorithm.
|
||||
* */
|
||||
);
|
||||
CGAL::pointmatcher::compute_registration_transformation
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_1_filters)
|
||||
.matcher(matcher)
|
||||
.outlier_filters(outlier_filters)
|
||||
.error_minimizer(error_minimizer)
|
||||
.transformation_checkers(transformation_checkers)
|
||||
.inspector(inspector)
|
||||
.logger(logger),
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_2_filters)
|
||||
.transformation(identity_transform) /* initial transform for pwns2.
|
||||
* default value is already identity transform.
|
||||
* a proper initial transform could be given, for example,
|
||||
* a transform returned from a coarse registration algorithm.
|
||||
* */
|
||||
);
|
||||
|
||||
// OR call the ICP registration method from pointmatcher and apply the transformation to pwn2
|
||||
bool converged =
|
||||
CGAL::pointmatcher::register_point_sets
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_1_filters)
|
||||
.matcher(matcher)
|
||||
.outlier_filters(outlier_filters)
|
||||
.error_minimizer(error_minimizer)
|
||||
.transformation_checkers(transformation_checkers)
|
||||
.inspector(inspector)
|
||||
.logger(logger),
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_2_filters)
|
||||
.transformation(res.first) /* pass the above computed transformation as initial transformation.
|
||||
* as a result, the registration will require less iterations to converge.
|
||||
* */
|
||||
CGAL::pointmatcher::register_point_sets
|
||||
(pwns1, pwns2,
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_1_filters)
|
||||
.matcher(matcher)
|
||||
.outlier_filters(outlier_filters)
|
||||
.error_minimizer(error_minimizer)
|
||||
.transformation_checkers(transformation_checkers)
|
||||
.inspector(inspector)
|
||||
.logger(logger),
|
||||
params::point_map(Point_map()).normal_map(Normal_map())
|
||||
.point_set_filters(point_set_2_filters)
|
||||
.transformation(res.first) /* pass the above computed transformation as initial transformation.
|
||||
* as a result, the registration will require less iterations to converge.
|
||||
* */
|
||||
);
|
||||
|
||||
if (converged)
|
||||
if(converged)
|
||||
{
|
||||
std::cerr << "Success" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Failure" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::ofstream out("pwns2_aligned.ply");
|
||||
if (!out ||
|
||||
!CGAL::write_PLY(
|
||||
out, pwns2,
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
{
|
||||
if(!CGAL::write_points("pwns2_aligned.ply", pwns2,
|
||||
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map())))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "Transformed version of " << fname2
|
||||
<< " written to pwn2_aligned.ply.\n";
|
||||
std::cout << "Transformed version of " << fname2 << " written to pwn2_aligned.ply.\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/compute_average_spacing.h>
|
||||
#include <CGAL/remove_outliers.h>
|
||||
|
|
@ -15,11 +16,12 @@ typedef Kernel::Point_3 Point;
|
|||
int main(int argc, char*argv[])
|
||||
{
|
||||
const char* fname = (argc>1)?argv[1]:"data/oni.xyz";
|
||||
// Reads a .xyz point set file in points[].
|
||||
|
||||
// Reads a point set file in points[].
|
||||
// The Identity_property_map property map can be omitted here as it is the default value.
|
||||
std::vector<Point> points;
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point>())))
|
||||
if(!CGAL::read_points(fname, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::Identity_property_map<Point>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -30,8 +32,7 @@ int main(int argc, char*argv[])
|
|||
const int nb_neighbors = 24; // considers 24 nearest neighbor points
|
||||
|
||||
// Estimate scale of the point set with average spacing
|
||||
const double average_spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>
|
||||
(points, nb_neighbors);
|
||||
const double average_spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>(points, nb_neighbors);
|
||||
|
||||
//////////////////
|
||||
// FIRST OPTION //
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/estimate_scale.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/estimate_scale.h>
|
||||
#include <CGAL/jet_smooth_point_set.h>
|
||||
#include <CGAL/grid_simplify_point_set.h>
|
||||
|
|
@ -21,7 +21,6 @@ typedef Kernel::Point_3 Point_3;
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
|
||||
const char* fname = (argc>1)?argv[1]:"data/sphere_20k.xyz";
|
||||
|
||||
CGAL::Timer task_timer;
|
||||
|
|
@ -29,11 +28,11 @@ int main (int argc, char** argv)
|
|||
std::vector<Point_3> points;
|
||||
|
||||
// read input
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: can't read input file" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!CGAL::read_points(fname, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: can't read input file" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// estimate k scale
|
||||
task_timer.start();
|
||||
|
|
@ -41,8 +40,7 @@ int main (int argc, char** argv)
|
|||
task_timer.stop();
|
||||
|
||||
// Example: use estimated k as scale for jet smoothing
|
||||
CGAL::jet_smooth_point_set<Concurrency_tag>
|
||||
(points, static_cast<unsigned int>(k_scale));
|
||||
CGAL::jet_smooth_point_set<Concurrency_tag>(points, static_cast<unsigned int>(k_scale));
|
||||
|
||||
// estimate range scale
|
||||
task_timer.start();
|
||||
|
|
@ -50,9 +48,7 @@ int main (int argc, char** argv)
|
|||
task_timer.stop();
|
||||
|
||||
// Example: use estimated range for grid simplification
|
||||
points.erase (CGAL::grid_simplify_point_set (points, range_scale),
|
||||
points.end());
|
||||
|
||||
points.erase(CGAL::grid_simplify_point_set(points, range_scale), points.end());
|
||||
|
||||
// print some informations on runtime
|
||||
std::size_t memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
|
@ -63,7 +59,6 @@ int main (int argc, char** argv)
|
|||
std::cout << " * Global K scale: " << k_scale << std::endl;
|
||||
std::cout << " * Global range scale: " << range_scale << std::endl;
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_xyz_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <CGAL/Shape_detection/Efficient_RANSAC.h>
|
||||
|
||||
#include <CGAL/structure_point_set.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
@ -32,12 +31,12 @@ int main (int argc, char** argv)
|
|||
// Loading point set from a file.
|
||||
|
||||
if (!CGAL::read_points((argc>1 ? argv[1] : "data/cube.pwn"),
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
std::back_inserter(points),
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file cube.pwn" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
std::cerr << "Error: cannot read file cube.pwn" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cerr << points.size() << " point(s) read." << std::endl;
|
||||
|
|
@ -52,22 +51,22 @@ int main (int argc, char** argv)
|
|||
|
||||
Pwn_vector structured_pts;
|
||||
|
||||
CGAL::structure_point_set (points,
|
||||
planes,
|
||||
std::back_inserter (structured_pts),
|
||||
0.015, // epsilon for structuring points
|
||||
CGAL::parameters::point_map (Point_map()).
|
||||
normal_map (Normal_map()).
|
||||
plane_map (CGAL::Shape_detection::Plane_map<Traits>()).
|
||||
plane_index_map (CGAL::Shape_detection::Point_to_shape_index_map<Traits>(points, planes)));
|
||||
CGAL::structure_point_set(points,
|
||||
planes,
|
||||
std::back_inserter(structured_pts),
|
||||
0.015, // epsilon for structuring points
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())
|
||||
.plane_map(CGAL::Shape_detection::Plane_map<Traits>())
|
||||
.plane_index_map(CGAL::Shape_detection::Point_to_shape_index_map<Traits>(points, planes)));
|
||||
|
||||
std::cerr << structured_pts.size ()
|
||||
<< " structured point(s) generated." << std::endl;
|
||||
|
||||
std::ofstream out ("out.pwn");
|
||||
CGAL::write_XYZ (out, structured_pts,
|
||||
CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()));
|
||||
out.close();
|
||||
CGAL::write_points("out.pwn", structured_pts,
|
||||
CGAL::parameters::point_map(Point_map())
|
||||
.normal_map(Normal_map())
|
||||
.stream_precision(17));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/wlop_simplify_and_regularize_point_set.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_xyz_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
|
@ -22,10 +23,9 @@ int main(int argc, char** argv)
|
|||
// Reads a .xyz point set file in points[]
|
||||
std::vector<Point> points;
|
||||
|
||||
if (!CGAL::read_points(input_filename, std::back_inserter(points)))
|
||||
if(!CGAL::read_points(input_filename, std::back_inserter(points)))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -40,17 +40,8 @@ int main(int argc, char** argv)
|
|||
CGAL::parameters::select_percentage(retain_percentage).
|
||||
neighbor_radius (neighbor_radius));
|
||||
|
||||
std::ofstream out(output_filename);
|
||||
out.precision(17);
|
||||
if (!out || !CGAL::write_XYZ(
|
||||
out, output))
|
||||
{
|
||||
if(!CGAL::write_points(output_filename, output, CGAL::parameters::stream_precision(17)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/write_ply_points.h>
|
||||
|
||||
|
|
@ -21,23 +22,24 @@ typedef CGAL::Nth_of_tuple_property_map<2, PCI> Intensity_map;
|
|||
|
||||
// Define how a color should be stored
|
||||
namespace CGAL {
|
||||
template< class F >
|
||||
struct Output_rep< ::Color, F > {
|
||||
const ::Color& c;
|
||||
static const bool is_specialized = true;
|
||||
Output_rep (const ::Color& c) : c(c)
|
||||
{ }
|
||||
std::ostream& operator() (std::ostream& out) const
|
||||
{
|
||||
if (is_ascii(out))
|
||||
out << int(c[0]) << " " << int(c[1]) << " " << int(c[2]) << " " << int(c[3]);
|
||||
else
|
||||
out.write(reinterpret_cast<const char*>(&c), sizeof(c));
|
||||
return out;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template< class F >
|
||||
struct Output_rep< ::Color, F > {
|
||||
const ::Color& c;
|
||||
static const bool is_specialized = true;
|
||||
Output_rep (const ::Color& c) : c(c)
|
||||
{ }
|
||||
std::ostream& operator() (std::ostream& out) const
|
||||
{
|
||||
if (is_ascii(out))
|
||||
out << int(c[0]) << " " << int(c[1]) << " " << int(c[2]) << " " << int(c[3]);
|
||||
else
|
||||
out.write(reinterpret_cast<const char*>(&c), sizeof(c));
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
|
|
@ -54,15 +56,14 @@ int main(int, char**)
|
|||
std::ofstream f("out.ply", std::ios::binary);
|
||||
CGAL::set_binary_mode(f); // The PLY file will be written in the binary format
|
||||
|
||||
CGAL::write_PLY_with_properties
|
||||
(f, points,
|
||||
CGAL::make_ply_point_writer (Point_map()),
|
||||
std::make_tuple(Color_map(),
|
||||
CGAL::PLY_property<unsigned char>("red"),
|
||||
CGAL::PLY_property<unsigned char>("green"),
|
||||
CGAL::PLY_property<unsigned char>("blue"),
|
||||
CGAL::PLY_property<unsigned char>("alpha")),
|
||||
std::make_pair (Intensity_map(), CGAL::PLY_property<int>("intensity")));
|
||||
CGAL::write_PLY_with_properties(f, points,
|
||||
CGAL::make_ply_point_writer (Point_map()),
|
||||
std::make_tuple(Color_map(),
|
||||
CGAL::PLY_property<unsigned char>("red"),
|
||||
CGAL::PLY_property<unsigned char>("green"),
|
||||
CGAL::PLY_property<unsigned char>("blue"),
|
||||
CGAL::PLY_property<unsigned char>("alpha")),
|
||||
std::make_pair(Intensity_map(), CGAL::PLY_property<int>("intensity")));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
// STL includes.
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
// CGAL includes.
|
||||
#include <CGAL/array.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
|
@ -16,6 +7,15 @@
|
|||
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set.h>
|
||||
|
||||
// STL includes.
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
// Type declarations.
|
||||
using Kernel = CGAL::Simple_cartesian<double>;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#include <CGAL/IO/OFF.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/IO/write_off_points.h>
|
||||
#include <CGAL/IO/write_xyz_points.h>
|
||||
#include <CGAL/IO/write_points.h>
|
||||
|
||||
#include <CGAL/Iterator_range.h>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue