UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_bspl3_curve3d.hpp
1 // u3d_bspl3_curve3d.hpp
2 // $Id: u3d_bspl3_curve3d.hpp,v 1.4 2009/06/30 13:06:22 urij Exp $
3 #ifndef U3D_BSPL3_CURVE3D_
4 #define U3D_BSPL3_CURVE3D_
5 
6 #include <mth/u3d_bspl3_primitives.hpp>
7 #include <mth/u3d_point.hpp>
8 
13 {
14 public:
18 
21  U3dBspl3Curve3d(const U3dBspl3AbstractMatrix &bm, const U3dPointsAr &ps);
22 
24  U3dBspl3Curve3d(const U3dBspl3Curve3d &obj);
25 
28 
29 
32  void approximate(const U3dBspl3AbstractMatrix &bm, const U3dPointsAr &ps);
33 
35  void approximate(const U3dPointsAr &ps);
36 
37 
40  bool getPoint(double p, U3dPoint &point) const;
41 
44  bool getXYZp(double p, U3dPoint &point) const;
45 
48  bool getXYZpp(double p, U3dPoint &point) const;
49 
51  bool getCurvature(double p, double &c);
52 
54  int getControlPointsNum() const;
55 
58  bool getControlPoint(int ind, U3dPoint &point) const;
59 
62  U3dBspl3MatrixType getBMType() const;
63 
64 
67  void add(const U3dPoint &point, int id = -1);
68 
71  bool remove(int id);
72 
73 
75  bool isReady() const
76  {return m_is_ready;}
77 
78 
82  bool getLineSegments(double ds, std::vector<double> &segs) const;
83 
85  bool getLineDeviations(double p1, double p2, double p, U3dPoint &dev) const;
86 
89  bool getMaxLineDeviation(double p1, double p2, double &md) const;
90 
91 
93  void info() const;
94 
95 
97  static void update_index (int &i, int m, int bm) {
98  if (i <= bm)
99  i = 0;
100  else if (i >= m + bm - 1)
101  i = m - 1;
102  else
103  i -= bm;
104  }
105 
107  static int get_bp_num(U3dBspl3MatrixType type);
108 
110  static void find_element(double p, int n, int &nn, double &pp);
111 
112 protected:
113 
115  struct Bspl3dCurve
116  {
118  Bspl3dCurve() : x(0x0), y(0x0), z(0x0) {};
119 
121  void clear() {
122  delete x; delete y; delete z;
123  }
124 
127  };
128 
130  std::vector<Bspl3dCurve> m_bspls;
131 
134 
136  U3dPointsAr m_ps;
137 
140 
142  void clear();
143 
146  void construct_segment(int id, int n, int bpnum, Bspl3dCurve &curve);
147 
149  bool get_line_distance(double pp, int nn, U3dPoint kP, U3dPoint bP, double p1, U3dPoint &dist) const;
150 
152  bool construct_isect_line(double p1, double p2, U3dPoint &kP, U3dPoint &bP) const;
153 
155  void devs_update(double p, int n, U3dPoint &kP, U3dPoint &bP, double p1,
156  U3dPoint &dev, double &smx, double &smy, double &smz) const {
157  get_line_distance(p, n, kP, bP, p1, dev);
158  if (dev.getX() > smx)
159  smx = dev.getX();
160  if (dev.getY() > smy)
161  smy = dev.getY();
162  if (dev.getZ() > smz)
163  smz = dev.getZ();
164  }
165 
166 };
167 
168 #endif /* U3D_BSPL3_CURVE3D_ */
void construct_segment(int id, int n, int bpnum, Bspl3dCurve &curve)
int getControlPointsNum() const
static int get_bp_num(U3dBspl3MatrixType type)
Definition: u3d_bspl3_curve3d.hpp:12
bool m_is_ready
Definition: u3d_bspl3_curve3d.hpp:139
bool getCurvature(double p, double &c)
void approximate(const U3dBspl3AbstractMatrix &bm, const U3dPointsAr &ps)
Bspl3dCurve()
Definition: u3d_bspl3_curve3d.hpp:118
bool get_line_distance(double pp, int nn, U3dPoint kP, U3dPoint bP, double p1, U3dPoint &dist) const
bool getLineSegments(double ds, std::vector< double > &segs) const
bool getLineDeviations(double p1, double p2, double p, U3dPoint &dev) const
U3dBspl3Curve3d(const U3dBspl3AbstractMatrix &bm)
bool getXYZp(double p, U3dPoint &point) const
double getZ() const
Definition: u3d_point.hpp:141
Definition: u3d_bspl3_primitives.hpp:11
Definition: geometry.H:16
void add(const U3dPoint &point, int id=-1)
U3dBspl3AbstractMatrix * m_bm
Definition: u3d_bspl3_curve3d.hpp:133
static void update_index(int &i, int m, int bm)
Definition: u3d_bspl3_curve3d.hpp:97
void devs_update(double p, int n, U3dPoint &kP, U3dPoint &bP, double p1, U3dPoint &dev, double &smx, double &smy, double &smz) const
Definition: u3d_bspl3_curve3d.hpp:155
double getY() const
Definition: u3d_point.hpp:135
bool construct_isect_line(double p1, double p2, U3dPoint &kP, U3dPoint &bP) const
Definition: u3d_point.hpp:16
std::vector< Bspl3dCurve > m_bspls
Definition: u3d_bspl3_curve3d.hpp:130
U3dSimpleBspl3Curve * x
Definition: u3d_bspl3_curve3d.hpp:126
static void find_element(double p, int n, int &nn, double &pp)
void info() const
void clear()
Definition: u3d_bspl3_curve3d.hpp:121
bool isReady() const
Definition: u3d_bspl3_curve3d.hpp:75
Definition: u3d_bspl3_matrices.hpp:24
bool getPoint(double p, U3dPoint &point) const
bool getXYZpp(double p, U3dPoint &point) const
U3dBspl3MatrixType getBMType() const
U3dPointsAr m_ps
Definition: u3d_bspl3_curve3d.hpp:136
bool getMaxLineDeviation(double p1, double p2, double &md) const
Definition: u3d_bspl3_curve3d.hpp:115
double getX() const
Definition: u3d_point.hpp:129
bool getControlPoint(int ind, U3dPoint &point) const