Points&Forces (survey)
Software tools facilitating the task of surveying architecture
Go to the documentation of this file.
1 /*
2  Copyright 2010-2020 Pierre SMARS (smars@yuntech.edu.tw)
3  This program is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 2 of the License, or
6  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  GNU General Public License for more details.
13  You should have received a copy of the GNU General Public License
14  along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #ifndef _SHAPE_H_
17 #define _SHAPE_H_
19 // .NAME a_shape
20 // .SECTION Author
21 // Pierre Smars
22 #include <vector>
23 #include <string>
24 #include <time.h>
25 #include "a_base.h"
26 #include "a_point.h"
27 #include <vnl/vnl_vector.h>
28 #include <vnl/vnl_least_squares_function.h>
31 class a_shape: public a_base
32 {
33  public:
34  a_shape(int n_parameters): P_(0.99), verbose_(false) {verysmall_=1000.;para_.set_size(n_parameters);srand(time(NULL));};
35  virtual ~a_shape();
36  virtual const std::string classname() const {return "a_shape";}
37  static const std::string help();
38  //a point reasonably belongs to the shape if its distance from the shape is smaller than verysmall_
39  void P(const double P) {P_=P;}
40  double P() const {return P_;}
41  unsigned int npara() const {return para_.size();}
42  virtual a_point closest_point(const a_point p) const = 0;
43  //distance between a point and the shape
44  virtual double dist_point(const a_point p) const = 0;
45  //a reasonable guess based from the point cloud
46  virtual void random_hint(const std::vector<a_point>& pts) = 0;
47  //sum of the distance for all points of the cloud
48  double dist_cloud(const std::vector<a_point>& pts);
49  double average_dist_cloud(const std::vector<a_point>& pts);
50  double rms_dist_cloud(const std::vector<a_point>& pts);
51  int threshold_cloud(const std::vector<a_point>& pts, std::vector<a_point>& pts2);
52  //reasonable guess maximising the number of fits
53  int best_fitting_cloud(const std::vector<a_point>& pts, std::vector<a_point>& pts2);
54  void fit_cloud(const std::vector<a_point>& pts, vnl_least_squares_function& fn);
55  virtual void fit_cloud(std::vector<a_point>& pts, short nl=1) = 0;
56  vnl_vector<double> getparameters() const {return para_;}
57  void para(const int i, const double val) {para_[i] = val;}
58  //: input/output
59  // friend std::istream& operator>> (std::istream& i, a_shape& s);
60  void export_inliers(const std::vector<a_point>& pts);
61  void export_outliers(const std::vector<a_point>& pts);
62  void verbose(bool v) {verbose_=v;}
63  virtual void init_dist() {}
64  friend std::ostream& operator<< (std::ostream& o, const a_shape& s);
66  protected:
67  double P_; //probability to get a sample of 100% inliers (used to calculate the minimum number of RANSAC samples)
68  vnl_vector<double> para_;
69  bool verbose_;
70 };
72 #endif
Definition: a_shape.h:32
double rms_dist_cloud(const std::vector< a_point > &pts)
Definition: a_shape.cxx:53
vnl_vector< double > para_
Definition: a_shape.h:68
double dist_cloud(const std::vector< a_point > &pts)
Definition: a_shape.cxx:39
void export_outliers(const std::vector< a_point > &pts)
Definition: a_shape.cxx:165
virtual void random_hint(const std::vector< a_point > &pts)=0
int threshold_cloud(const std::vector< a_point > &pts, std::vector< a_point > &pts2)
Definition: a_shape.cxx:65
unsigned int npara() const
Definition: a_shape.h:41
bool verbose_
Definition: a_shape.h:69
virtual void fit_cloud(std::vector< a_point > &pts, short nl=1)=0
double P() const
Definition: a_shape.h:40
double average_dist_cloud(const std::vector< a_point > &pts)
Definition: a_shape.cxx:48
void P(const double P)
Definition: a_shape.h:39
a_shape(int n_parameters)
Definition: a_shape.h:34
friend std::ostream & operator<<(std::ostream &o, const a_shape &s)
Definition: a_shape.cxx:193
void fit_cloud(const std::vector< a_point > &pts, vnl_least_squares_function &fn)
Definition: a_shape.cxx:126
static const std::string help()
Definition: a_shape.cxx:21
void para(const int i, const double val)
Definition: a_shape.h:57
virtual a_point closest_point(const a_point p) const =0
double P_
Definition: a_shape.h:67
virtual double dist_point(const a_point p) const =0
virtual ~a_shape()
Definition: a_shape.cxx:34
vnl_vector< double > getparameters() const
Definition: a_shape.h:56
int best_fitting_cloud(const std::vector< a_point > &pts, std::vector< a_point > &pts2)
Definition: a_shape.cxx:82
virtual const std::string classname() const
Definition: a_shape.h:36
void verbose(bool v)
Definition: a_shape.h:62
virtual void init_dist()
Definition: a_shape.h:63
void export_inliers(const std::vector< a_point > &pts)
Definition: a_shape.cxx:143
double v(const uint32_t step, const uint32_t n)
Definition: generate.cxx:42