xc
Polyline3d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //Polyline3d.
22 
23 #ifndef POLYLINE3D_H
24 #define POLYLINE3D_H
25 
26 #include "../pos_vec/Pos3d.h"
27 #include "../lists/PolyPos.h"
28 #include "Linear3d.h"
29 #include "Segment3d.h"
30 
31 class Pos3dList;
32 class HalfSpace3d;
33 
35 //
37 class Polyline3d : public Linear3d, public GeomObj::list_Pos3d
38  {
39  public:
40  Polyline3d(void);
41  explicit Polyline3d(const GeomObj::list_Pos3d &);
42  explicit Polyline3d(const Pos3dList &);
43  explicit Polyline3d(const boost::python::list &);
44 
45  virtual bool operator==(const Polyline3d &) const;
46  virtual GeomObj *getCopy(void) const
47  { return new Polyline3d(*this); }
48  virtual void Move(const Vector3d &);
49  const GeomObj::list_Pos3d &getVertices(void) const;
50  const GeomObj::list_Pos3d &getVertexList(void) const;
51  boost::python::list getVertexListPy(void) const;
52  inline size_t getNumVertices(void) const
53  { return GeomObj::list_Pos3d::size(); }
54  size_t getNumSegments(void) const;
55  void setVertices(const boost::python::list &);
56 
57 /* inline virtual void GiraX(double ang) */
58 /* { Ref3d::GiraX(ang); TrfPoints(); } */
59 /* inline virtual void GiraY(double ang) */
60 /* { Ref3d::GiraY(ang); TrfPoints(); } */
61 /* inline virtual void GiraZ(double ang) */
62 /* { Ref3d::GiraZ(ang); TrfPoints(); } */
63  const Pos3d *appendVertex(const Pos3d &);
64  const Pos3d *appendVertexLeft(const Pos3d &);
65  virtual bool In(const Pos3d &p, const double &tol= 0.0) const;
66  virtual GEOM_FT dist2(const Pos3d &p) const;
67  GEOM_FT dist(const Pos3d &p) const;
68 
69  virtual GEOM_FT Ix(void) const;
70  virtual GEOM_FT Iy(void) const;
71  virtual GEOM_FT Iz(void) const;
72 
73  GEOM_FT getCurvatureAtVertex(const_iterator) const;
74  GEOM_FT getCurvatureAtLength(const GEOM_FT &) const;
75  Vector3d getCurvatureVectorAtVertex(const_iterator) const;
76  std::vector<Vector3d> getCurvatureVectorAtVertices(void) const;
77  Vector3d getCurvatureVectorAtLength(const GEOM_FT &) const;
78  Pos3d getPointAtLength(const GEOM_FT &) const;
79  Vector3d getIVectorAtLength(const GEOM_FT &) const;
80  Vector3d getJVectorAtLength(const GEOM_FT &) const;
81  Vector3d getKVectorAtLength(const GEOM_FT &) const;
82 
83  VectorPos3d Divide(int num_partes) const;
84  boost::python::list DividePy(int num_partes) const;
85  VectorPos3d Divide(const std::vector<double> &) const;
86  boost::python::list DividePy(const boost::python::list &) const;
87 
89  virtual GEOM_FT getLength(void) const
90  { return GeomObj::list_Pos3d::getLength(); }
91  virtual GEOM_FT getLengthUpTo(const Pos3d &) const;
92  inline GEOM_FT getLambda(const Pos3d &p) const
93  { return getLengthUpTo(p); }
94  virtual GEOM_FT GetMax(unsigned short int i) const;
95  virtual GEOM_FT GetMin(unsigned short int i) const;
96  Polyline3d GetMayores(unsigned short int i,const GEOM_FT &d) const;
97  Polyline3d GetMenores(unsigned short int i,const GEOM_FT &d) const;
98 
99  Segment3d getSegment(const list_Pos3d::const_iterator &) const;
100  Segment3d getSegment(const size_t &) const;
101  std::vector<Segment3d> getSegments(void) const;
102  const_iterator getNearestSegmentIter(const Pos3d &) const;
103  int getNearestSegmentIndex(const Pos3d &) const;
104  Segment3d getNearestSegment(const Pos3d &) const;
105  Pos3d Projection(const Pos3d &) const;
106 
107 
108  std::deque<const_iterator> getIntersectionIters(const Plane &) const;
109  list_Pos3d getIntersection(const Plane &) const;
110  std::deque<Polyline3d> clip(const HalfSpace3d &, const GEOM_FT &tol= 0.0) const;
111  boost::python::list clipPy(const HalfSpace3d &, const GEOM_FT &tol= 0.0) const;
112  void insertVertex(const Pos3d &, const GEOM_FT &tol= 1e-6);
113  Polyline3d getChunk(const Pos3d &,const short int &, const GEOM_FT &) const;
114  Polyline3d getLeftChunk(const Pos3d &, const GEOM_FT &tol) const;
115  Polyline3d getRightChunk(const Pos3d &, const GEOM_FT &tol) const;
116  boost::python::list split(const Pos3d &) const;
117  Pos3d getCenterOfMass(void) const
119 
120  iterator getFarthestPointFromSegment(iterator it1, iterator it2, GEOM_FT &pMaxDist);
121 
122  boost::python::dict getPyDict(void) const;
123  void setPyDict(const boost::python::dict &);
124 
125  void Print(std::ostream &stream) const;
126  };
127 
128 #endif
129 
130 
131 
132 
133 
134 
Polyline3d getRightChunk(const Pos3d &, const GEOM_FT &tol) const
Return the polyline chunk that goes the nearest vertex to to p to its end.
Definition: Polyline3d.cc:952
virtual GEOM_FT dist2(const Pos3d &p) const
Return the squared distance to the polyline.
Definition: Polyline3d.cc:184
Vector3d getJVectorAtLength(const GEOM_FT &) const
Return the J vector of the segment that lies at the point at a distance "s" measured along the polyli...
Definition: Polyline3d.cc:764
Segment en tres dimensiones.
Definition: Segment3d.h:41
const GeomObj::list_Pos3d & getVertexList(void) const
Return the list of the vertices.
Definition: Polyline3d.cc:81
Base class for position lists.
Definition: PolyPos.h:35
Pos3d Projection(const Pos3d &) const
Return the projection of the given point into the polyline.
Definition: Polyline3d.cc:267
GEOM_FT dist(const Pos3d &p) const
Return the distance from the point to the segment.
Definition: Polyline3d.cc:202
pos getCenterOfMass(void) const
Return the center of mass del polígono.
Definition: PolyPos.h:353
const Pos3d * appendVertexLeft(const Pos3d &)
Append a vertex to the beginning of the polyline.
Definition: Polyline3d.cc:104
virtual GEOM_FT Iy(void) const
Return the moment of inertia about the y axis.
Definition: Polyline3d.cc:509
virtual GEOM_FT getLength(void) const
Return the length of the object.
Definition: Polyline3d.h:89
int getNearestSegmentIndex(const Pos3d &) const
Return the index of the nearest 3D segment.
Definition: Polyline3d.cc:236
virtual GEOM_FT Iz(void) const
Return the moment of inertia about the z axis.
Definition: Polyline3d.cc:517
Polyline3d(void)
Default constructor.
Definition: Polyline3d.cc:32
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: Polyline3d.cc:1029
Segment3d getSegment(const list_Pos3d::const_iterator &) const
Return the segment pointed by the iterator.
Definition: Polyline3d.cc:119
const_iterator getNearestSegmentIter(const Pos3d &) const
Return the nearest segment to the argument.
Definition: Polyline3d.cc:206
Polyline in a three-dimensional space.
Definition: Polyline3d.h:37
Plane in a three-dimensional space.
Definition: Plane.h:49
std::vector< Vector3d > getCurvatureVectorAtVertices(void) const
Return the approximate curvature of the polyline at each of its vertices.
Definition: Polyline3d.cc:638
Segment3d getNearestSegment(const Pos3d &) const
Return the nearest 3D segment.
Definition: Polyline3d.cc:244
Polyline3d GetMayores(unsigned short int i, const GEOM_FT &d) const
Return a Polyline3d with the vertices whose i-th coordinate is greater than d.
Definition: Polyline3d.cc:445
const Pos3d * appendVertex(const Pos3d &)
Append a vertex to the polyline.
Definition: Polyline3d.cc:97
GEOM_FT getCurvatureAtVertex(const_iterator) const
Return the approximate curvature of the polyline at the vertex pointed by the iterator argument...
Definition: Polyline3d.cc:528
std::deque< const_iterator > getIntersectionIters(const Plane &) const
Return the iterators to the origin vertices of the polyline segments where the intersection with the ...
Definition: Polyline3d.cc:297
virtual bool operator==(const Polyline3d &) const
Comparison operator.
Definition: Polyline3d.cc:48
virtual GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i-th coordinate.
Definition: Polyline3d.cc:422
List of 3D positions.
Definition: Pos3dList.h:36
Polyline3d getChunk(const Pos3d &, const short int &, const GEOM_FT &) const
Assuming that p is a vertex of the polyline Return the chunk: from the beginning to p if sgn < 0 from...
Definition: Polyline3d.cc:906
Pos3d getPointAtLength(const GEOM_FT &) const
Return the the point at a distance "s" measured along the polyline from its origin.
Definition: Polyline3d.cc:730
Base class for the objects involving a single dimension in a three-dimensional space.
Definition: Linear3d.h:33
Vector3d getCurvatureVectorAtLength(const GEOM_FT &) const
Return the approximate curvature vector of the polyline at the the point at a distance "s" measured a...
Definition: Polyline3d.cc:689
Vector3d getCurvatureVectorAtVertex(const_iterator) const
Return the approximate curvature of the polyline at the vertex pointed by the iterator argument...
Definition: Polyline3d.cc:597
void insertVertex(const Pos3d &, const GEOM_FT &tol=1e-6)
Insert the point argurment as vertex by splitting the nearest segment.
Definition: Polyline3d.cc:890
Vector3d getIVectorAtLength(const GEOM_FT &) const
Return the I vector of the segment that lies at the point at a distance "s" measured along the polyli...
Definition: Polyline3d.cc:748
GEOM_FT getCurvatureAtLength(const GEOM_FT &) const
Return the approximate curvature of the polyline at the the point at a distance "s" measured along th...
Definition: Polyline3d.cc:564
VectorPos3d Divide(int num_partes) const
Return the points that results from the segment division.
Definition: Polyline3d.cc:812
boost::python::list DividePy(int num_partes) const
Return a Python list containing the points that results from the segment division.
Definition: Polyline3d.cc:829
Polyline3d GetMenores(unsigned short int i, const GEOM_FT &d) const
Return a Polyline3d with the vertices whose i-th coordinate is smaller than d.
Definition: Polyline3d.cc:455
std::deque< Polyline3d > clip(const HalfSpace3d &, const GEOM_FT &tol=0.0) const
Return the polyline chunks that result from clipping this polyline with the given half space...
Definition: Polyline3d.cc:338
virtual GEOM_FT GetMin(unsigned short int i) const
Return the minimum value of the i-th coordinate.
Definition: Polyline3d.cc:433
virtual GEOM_FT getLengthUpTo(const Pos3d &) const
Return the length along the polyline upto the given point.
Definition: Polyline3d.cc:275
Posición en tres dimensiones.
Definition: Pos3d.h:44
list_Pos3d getIntersection(const Plane &) const
Return the points of intersection of the polyline with the argument.
Definition: Polyline3d.cc:316
GEOM_FT getLength(void) const
Return the length of the PolyPos.
Definition: PolyPos.h:169
GEOM_FT getLambda(const Pos3d &p) const
Return the lambda parameter for the given point: p= getFromPoint()+lambda*VDir()
Definition: Polyline3d.h:92
boost::python::list split(const Pos3d &) const
Return the two polylines that result from splitting this one on the point nearest to the argument...
Definition: Polyline3d.cc:957
virtual void Move(const Vector3d &)
Moves the polyline.
Definition: Polyline3d.cc:159
iterator getFarthestPointFromSegment(iterator it1, iterator it2, GEOM_FT &pMaxDist)
Definition: Polyline3d.cc:992
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: Polyline3d.cc:1020
Vector de posiciones en tres dimensiones [(x1,y1,z1),(x1,y2,z2),...].
Definition: VectorPos3d.h:32
The points of the half space are those that line at the back of the plane, this being understood as t...
Definition: HalfSpace3d.h:42
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
void setVertices(const boost::python::list &)
Set the polyline vertices from the given Python list.
Definition: Polyline3d.cc:72
Vector3d getKVectorAtLength(const GEOM_FT &) const
Return the K vector of the segment that lies at the point at a distance "s" measured along the polyli...
Definition: Polyline3d.cc:802
Polyline3d getLeftChunk(const Pos3d &, const GEOM_FT &tol) const
Return the polyline chunk that goes from its beginning to the nearest vertex to p.
Definition: Polyline3d.cc:946
virtual GEOM_FT Ix(void) const
Return the moment of inertia about the x axis.
Definition: Polyline3d.cc:501
virtual bool In(const Pos3d &p, const double &tol=0.0) const
Return true if the point is in the polyline.
Definition: Polyline3d.cc:166
Vector en tres dimensiones.
Definition: Vector3d.h:39
boost::python::list getVertexListPy(void) const
Return a Python list containing the positions of the polygon vertices.
Definition: Polyline3d.cc:86
const GeomObj::list_Pos3d & getVertices(void) const
Return the list of the vertices.
Definition: Polyline3d.cc:63
std::vector< Segment3d > getSegments(void) const
Return a vector containing the consecutive segments of the polyline.
Definition: Polyline3d.cc:139