Global change of API
This commit is contained in:
@@ -4,12 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Classifier.h>
|
||||
#include <CGAL/Classification/Point_set_neighborhood.h>
|
||||
#include <CGAL/Classification/Planimetric_grid.h>
|
||||
#include <CGAL/Classification/Feature_base.h>
|
||||
#include <CGAL/Classification/Feature/Eigen.h>
|
||||
|
||||
#include <CGAL/Classification.h>
|
||||
#include <CGAL/IO/read_ply_points.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
@@ -18,15 +13,19 @@ typedef Kernel::Iso_cuboid_3 Iso_cuboid_3;
|
||||
typedef std::vector<Point> Point_range;
|
||||
typedef CGAL::Identity_property_map<Point> Pmap;
|
||||
|
||||
typedef CGAL::Classifier<Point_range, Pmap> Classifier;
|
||||
namespace Classif = CGAL::Classification;
|
||||
|
||||
typedef CGAL::Classification::Point_set_neighborhood<Kernel, Point_range, Pmap> Neighborhood;
|
||||
typedef CGAL::Classification::Local_eigen_analysis<Kernel, Point_range, Pmap> Local_eigen_analysis;
|
||||
typedef Classif::Sum_of_weighted_features_predicate Classification_predicate;
|
||||
|
||||
typedef CGAL::Classification::Label_handle Label_handle;
|
||||
typedef CGAL::Classification::Feature_handle Feature_handle;
|
||||
typedef Classif::Point_set_neighborhood<Kernel, Point_range, Pmap> Neighborhood;
|
||||
typedef Classif::Local_eigen_analysis<Kernel, Point_range, Pmap> Local_eigen_analysis;
|
||||
|
||||
typedef CGAL::Classification::Feature::Sphericity<Kernel, Point_range, Pmap> Sphericity;
|
||||
typedef Classif::Label_handle Label_handle;
|
||||
typedef Classif::Feature_handle Feature_handle;
|
||||
typedef Classif::Label_set Label_set;
|
||||
typedef Classif::Feature_set Feature_set;
|
||||
|
||||
typedef Classif::Feature::Sphericity<Kernel, Point_range, Pmap> Sphericity;
|
||||
|
||||
|
||||
// User-defined feature that identifies a specific area of the 3D
|
||||
@@ -37,10 +36,12 @@ class My_feature : public CGAL::Classification::Feature_base
|
||||
const Point_range& range;
|
||||
double xmin, xmax, ymin, ymax;
|
||||
public:
|
||||
My_feature (const Point_range& range, // constructor should start with item range
|
||||
My_feature (const Point_range& range,
|
||||
double xmin, double xmax, double ymin, double ymax)
|
||||
: range (range), xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax)
|
||||
{ }
|
||||
{
|
||||
this->set_name ("my_feature");
|
||||
}
|
||||
|
||||
double value (std::size_t pt_index)
|
||||
{
|
||||
@@ -70,29 +71,36 @@ int main (int argc, char** argv)
|
||||
Neighborhood neighborhood (pts, Pmap());
|
||||
Local_eigen_analysis eigen (pts, Pmap(), neighborhood.k_neighbor_query(6));
|
||||
|
||||
Classifier classifier (pts, Pmap());
|
||||
|
||||
Label_set labels;
|
||||
Label_handle a = labels.add ("label_A");
|
||||
Label_handle b = labels.add ("label_B");
|
||||
|
||||
std::cerr << "Computing features" << std::endl;
|
||||
Feature_handle sphericity = classifier.add_feature<Sphericity> (eigen);
|
||||
Feature_set features;
|
||||
|
||||
Feature_handle sphericity = features.add<Sphericity> (pts, eigen);
|
||||
|
||||
// Feature that identifies points whose x coordinate is between -20
|
||||
// and 20 and whose y coordinate is between -15 and 15
|
||||
Feature_handle my_feature = classifier.add_feature<My_feature> (-20., 20., -15., 15.);
|
||||
|
||||
Feature_handle my_feature = features.add<My_feature> (pts, -20., 20., -15., 15.);
|
||||
|
||||
Classification_predicate predicate (labels, features);
|
||||
|
||||
std::cerr << "Setting weights" << std::endl;
|
||||
sphericity->set_weight(0.5);
|
||||
my_feature->set_weight(0.25);
|
||||
predicate.set_weight(sphericity, 0.5);
|
||||
predicate.set_weight(my_feature, 0.25);
|
||||
|
||||
std::cerr << "Setting up labels" << std::endl;
|
||||
Label_handle a = classifier.add_label ("label_A");
|
||||
a->set_feature_effect (sphericity, CGAL::Classification::Feature::FAVORING);
|
||||
a->set_feature_effect (my_feature, CGAL::Classification::Feature::FAVORING);
|
||||
predicate.set_effect (a, sphericity, Classification_predicate::FAVORING);
|
||||
predicate.set_effect (a, my_feature, Classification_predicate::FAVORING);
|
||||
predicate.set_effect (b, sphericity, Classification_predicate::PENALIZING);
|
||||
predicate.set_effect (b, my_feature, Classification_predicate::PENALIZING);
|
||||
|
||||
Label_handle b = classifier.add_label ("label_B");
|
||||
b->set_feature_effect (sphericity, CGAL::Classification::Feature::PENALIZING);
|
||||
b->set_feature_effect (my_feature, CGAL::Classification::Feature::PENALIZING);
|
||||
|
||||
classifier.run_with_graphcut (neighborhood.k_neighbor_query(12), 0.2);
|
||||
std::vector<std::size_t> label_indices;
|
||||
Classif::classify_with_graphcut<CGAL::Sequential_tag>
|
||||
(pts, Pmap(), Pmap(), labels, predicate,
|
||||
neighborhood.k_neighbor_query(12),
|
||||
0.5, 1, label_indices);
|
||||
|
||||
std::cerr << "All done" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user