Points&Forces (survey)
Software tools facilitating the task of surveying architecture
Go to the documentation of this file.
1 /*
2  Copyright 2010-2011 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 _WE_CURVE_H_
17 #define _WE_CURVE_H_
19 #include "a_point.h"
20 #include "a_segment.h"
22 #include <iostream>
23 #include <vector>
24 #include <deque>
34 class a_curve
35 {
36  public:
37  a_curve(double da = 1e-6);
38  a_curve(const a_curve&);
39  virtual ~a_curve();
41  // a_curve& construct_axis() {return this->construct_z_axis().construct_y_axis().construct_x_axis();}
44  void addpoint(a_point * pt) {x_.push_back(pt); initialised_=false; n_pts_++;}
45  // void addpoint(a_point * pt) {x_.push_back(pt); initialised_=false; this->init();}
47  int size() const {return x_.size();}
48  a_point * operator[](int i) const {return x_[i];}
49  std::deque<a_point *>& x() {return x_;}
51  virtual a_point operator()(double a) const = 0;
53  virtual a_point dx_axis(double a) const;
55  virtual a_point dy_axis(double a) const;
57  virtual a_point dz_axis(double a) const;
58  /*change the orientation of the z axis*/
59  void invert() {orient_ = -1; this->construct_axis();}
60  bool is_closed() const;
62  void set_horiz(const a_point& p) {horiz_ = p;}
63  a_point get_horiz() const {return horiz_;}
65  // a_curve& invert();
66  a_curve& translate(const a_point & p);
67  a_curve& translate(double x, double y, double z);
68  a_point origin() const {return *x_[0];}
69  a_curve& origin(a_point & p);
70  a_curve& origin(double x, double y, double z);
71  a_point centre() const;
72  a_curve& flatten();
73  a_curve& flatten2D();
74  a_curve& place3D(a_point& origin, a_point& x_axis, a_point& y_axis);
75  a_point x_axis() const {return x_axis_;}
76  a_point y_axis() const {return y_axis_;}
77  a_point z_axis() const {return z_axis_;}
78  double da() const {return da_;}
79  void da(double da) {da_ = da;}
81  double dist(const a_point &, int & ref) const;
82  double dist2(const a_point &, int & ref, double & m) const;
83  double dist_last(const a_point &, int & ref) const;
84  double dist(const a_curve &, int & ref1, int & ref2) const;
85  double dist_last(const a_curve &, int & ref1, int & ref2) const;
86  double dist2(const a_curve &, int & ref1, int & ref2, double& m1, double& m2) const;
87  a_segment shortest(const a_curve & fn, int & ref1, int & ref2, double& m1, double& m2) const;
90  friend std::istream& operator>> (std::istream& i, a_curve& m);
92  friend std::ostream& operator<< (std::ostream& o, const a_curve& m);
95  class range_error {};
99  protected:
101  std::deque<a_point *> x_;
102  double da_; //an 'infinitesimal' value
103  int n_pts_;
104  a_point x_axis_;
105  a_point y_axis_;
106  a_point z_axis_;
107  int orient_;
108  a_point horiz_;
114  virtual a_curve& init();
115 };
117 #endif
exception class
Definition: a_curve.h:95
sampled parametric function class (interface)
Definition: a_curve.h:35
a_curve & construct_y_axis()
Definition: a_curve.cxx:236
a_point y_axis_
Definition: a_curve.h:105
double dist_last(const a_point &, int &ref) const
Definition: a_curve.cxx:338
a_curve & flatten()
Definition: a_curve.cxx:193
void addpoint(a_point *pt)
Definition: a_curve.h:44
double dist2(const a_point &, int &ref, double &m) const
Definition: a_curve.cxx:316
a_curve & construct_z_axis()
Definition: a_curve.cxx:249
virtual a_point dx_axis(double a) const
Definition: a_curve.cxx:139
std::deque< a_point * > & x()
Definition: a_curve.h:49
virtual a_point operator()(double a) const =0
a_curve(double da=1e-6)
Definition: a_curve.cxx:26
void set_horiz(const a_point &p)
Definition: a_curve.h:62
double da_
Definition: a_curve.h:102
friend std::istream & operator>>(std::istream &i, a_curve &m)
Definition: a_curve.cxx:479
a_point z_axis_
Definition: a_curve.h:106
void da(double da)
Definition: a_curve.h:79
double da() const
Definition: a_curve.h:78
a_curve & flatten2D()
Definition: a_curve.cxx:207
virtual a_point dz_axis(double a) const
Definition: a_curve.cxx:67
virtual a_curve & init()
Definition: a_curve.cxx:56
int size() const
Definition: a_curve.h:47
virtual a_point dy_axis(double a) const
Definition: a_curve.cxx:116
int orient_
Definition: a_curve.h:107
a_point horiz_
Definition: a_curve.h:108
bool initialised_
Definition: a_curve.h:100
double dist(const a_point &, int &ref) const
Definition: a_curve.cxx:299
void invert()
Definition: a_curve.h:59
a_point * operator[](int i) const
Definition: a_curve.h:48
a_segment shortest(const a_curve &fn, int &ref1, int &ref2, double &m1, double &m2) const
Definition: a_curve.cxx:393
virtual ~a_curve()
Definition: a_curve.cxx:49
friend std::ostream & operator<<(std::ostream &o, const a_curve &m)
Definition: a_curve.cxx:493
a_point z_axis() const
Definition: a_curve.h:77
a_point y_axis() const
Definition: a_curve.h:76
a_point x_axis_
Definition: a_curve.h:104
a_curve & place3D(a_point &origin, a_point &x_axis, a_point &y_axis)
Definition: a_curve.cxx:219
a_point get_horiz() const
Definition: a_curve.h:63
a_curve & construct_x_axis()
Definition: a_curve.cxx:230
a_curve & construct_axis()
Definition: a_curve.cxx:267
a_point origin() const
Definition: a_curve.h:68
bool is_closed() const
Definition: a_curve.cxx:109
a_curve & translate(const a_point &p)
Definition: a_curve.cxx:179
a_point x_axis() const
Definition: a_curve.h:75
int n_pts_
Definition: a_curve.h:103
std::deque< a_point * > x_
Definition: a_curve.h:101
a_point centre() const
Definition: a_curve.cxx:158
Definition: stlb2stla.cxx:21