xc
HalfSpace3d.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 //HalfSpace3d.h
22 
23 #ifndef HALFSPACE3D_H
24 #define HALFSPACE3D_H
25 
26 
27 #include "utility/geom/d2/Plane.h"
28 #include "utility/utils/stl/TripletMap.h"
29 
30 
31 
33 //
42 class HalfSpace3d : public GeomObj3d
43  {
44  Plane lim;
45  public:
46  HalfSpace3d(const Plane &p= Plane());
47  HalfSpace3d(const Plane &, const Pos3d &);
48  virtual bool operator==(const HalfSpace3d &) const;
49 
50  const Plane &getBoundaryPlane(void) const;
51  void setBoundaryPlane(const Plane &);
52 
53  virtual GeomObj *getCopy(void) const
54  { return new HalfSpace3d(*this); }
55  inline void swap(void)
56  { lim.swap(); }
57  HalfSpace3d getSwap(void) const;
58  virtual GEOM_FT GetMax(unsigned short int) const
59  { return NAN; }
60  virtual GEOM_FT GetMin(unsigned short int) const
61  { return NAN; }
62  Vector3d NormalExterior(void) const;
63  Vector3d NormalInterior(void) const;
64  inline const Plane &getPlane(void) const
65  { return lim; }
66 
67  virtual bool In(const Pos3d &, const double &tol= 0.0) const;
68  virtual bool In(const Line3d &, const double &tol= 0.0) const;
69  virtual bool In(const Ray3d &, const double &tol= 0.0) const;
70  virtual bool In(const Segment3d &, const double &tol= 0.0) const;
71  virtual bool In(const Polyline3d &, const double &tol= 0.0) const;
72  inline bool intersects(const HalfSpace3d &hs) const
73  { return lim.intersects(hs.lim); }
74  bool intersects(const Line3d &) const;
75  bool intersects(const Ray3d &) const;
76  bool intersects(const Segment3d &) const;
77  bool intersects(const Polyline3d &) const;
78  GEOM_FT distSigno(const Pos3d &) const;
79  GEOM_FT distSigno2(const Pos3d &p) const;
80  virtual GEOM_FT dist(const Pos3d &p) const;
81  virtual GEOM_FT dist2(const Pos3d &p) const;
82 
83  GEOM_FT getAngle(const HalfSpace3d &) const;
84  GEOM_FT getAngle(const Plane &) const;
85  GEOM_FT getAngle(const Vector3d &) const;
86 
87  Line3d getLima(const HalfSpace3d &) const;
88 
89  virtual unsigned short int Dimension(void) const;
90  virtual GEOM_FT getLength(void) const;
91  virtual GEOM_FT getArea(void) const;
92  virtual GEOM_FT getVolume(void) const;
93  virtual Pos3d getCenterOfMass(void) const;
94  virtual GEOM_FT Ix(void) const;
95  virtual GEOM_FT Iy(void) const;
96  virtual GEOM_FT Pxy(void) const;
97  virtual GEOM_FT Iz(void) const;
98 
99  Ray3d clip(const Line3d &) const;
100  Ray3d clip(const Ray3d &) const;
101  Segment3d clip(const Segment3d &) const;
102  std::deque<Polyline3d> clip(const Polyline3d &, const GEOM_FT &tol= 0.0) const;
103  boost::python::list clipPy(const Polyline3d &, const GEOM_FT &tol= 0.0) const;
104 
105  void Print(std::ostream &os) const;
106  };
107 
108 inline GEOM_FT dist(const Pos3d &p,const HalfSpace3d &r)
109  { return r.dist(p); }
110 inline GEOM_FT dist(const HalfSpace3d &r,const Pos3d &p)
111  { return dist(p,r); }
112 inline bool operator!=(const HalfSpace3d &r1,const HalfSpace3d &r2)
113  { return !(r1==r2); }
114 
115 TripletMap<Pos3d> intersection_points(const std::deque<HalfSpace3d> &);
116 TripletMap<Pos3d> polyhedron_vertices(const std::deque<HalfSpace3d> &, const double &tol= 1e-10);
117 std::deque<Line3d> intersection_lines(const std::deque<HalfSpace3d> &);
118 std::deque<Vector3d> vectores_normales(const std::deque<HalfSpace3d> &);
119 
120 GEOM_FT angle(const HalfSpace3d &,const HalfSpace3d &);
121 GEOM_FT angle(const Vector3d &,const HalfSpace3d &);
122 GEOM_FT angle(const HalfSpace3d &,const Vector3d &);
123 
124 #endif
bool intersects(const Plane &) const
Returns true if intersection exists.
Definition: Plane.cc:365
virtual unsigned short int Dimension(void) const
brief Return the dimension of the object 0, 1, 2 or 3.
Definition: HalfSpace3d.cc:327
Mapa tipo «tensor disperso».
Definition: TripletMap.h:42
virtual GEOM_FT Iz(void) const
Return el moment of inertia with respect to the center of mass in local coordinates.
Definition: HalfSpace3d.cc:355
Segment en tres dimensiones.
Definition: Segment3d.h:41
boost::python::list clipPy(const Polyline3d &, const GEOM_FT &tol=0.0) const
Return the polyline chunks that result from clipping the given polyline with this half space...
Definition: HalfSpace3d.cc:284
void Print(std::ostream &os) const
Imprime el half space.
Definition: HalfSpace3d.cc:369
virtual GEOM_FT dist2(const Pos3d &p) const
Return the squared distance from the point to the half plane.
Definition: HalfSpace3d.cc:300
virtual bool operator==(const HalfSpace3d &) const
Comparison operator.
Definition: HalfSpace3d.cc:46
Polyline in a three-dimensional space.
Definition: Polyline3d.h:37
Line3d getLima(const HalfSpace3d &) const
Return la arista de the intersection entre half spaces.
Definition: HalfSpace3d.cc:316
Plane in a three-dimensional space.
Definition: Plane.h:49
Ray3d clip(const Line3d &) const
Returns the part of the line that is inside the half-space.
Definition: HalfSpace3d.cc:192
Ray in a three-dimensional space.
Definition: Ray3d.h:36
virtual GEOM_FT GetMin(unsigned short int) const
Return the minimum value of the i-th coordinate.
Definition: HalfSpace3d.h:60
GEOM_FT distSigno(const Pos3d &) const
Return the signed distance from the point to the half plane.
Definition: HalfSpace3d.cc:288
virtual GEOM_FT Iy(void) const
Return el moment of inertia with respect to the center of mass in local coordinates.
Definition: HalfSpace3d.cc:347
const Plane & getBoundaryPlane(void) const
Return the plane that defined de half space boundary.
Definition: HalfSpace3d.cc:69
HalfSpace3d getSwap(void) const
Returns the complementary half space.
Definition: HalfSpace3d.cc:61
Vector3d NormalInterior(void) const
Return a vector normal to the boundary plane oriented outside-in.
Definition: HalfSpace3d.cc:365
virtual GEOM_FT dist(const Pos3d &p) const
Return the distance from the point to the half plane.
Definition: HalfSpace3d.cc:296
GEOM_FT distSigno2(const Pos3d &p) const
Return the signed squared distance from the point to the half plane.
Definition: HalfSpace3d.cc:292
GEOM_FT getAngle(const HalfSpace3d &) const
Return el the angle with the half space argument.
Definition: HalfSpace3d.cc:304
virtual GEOM_FT GetMax(unsigned short int) const
Return the maximum value of the i-th coordinate.
Definition: HalfSpace3d.h:58
Posición en tres dimensiones.
Definition: Pos3d.h:44
Line in a three-dimensional space.
Definition: Line3d.h:62
virtual GEOM_FT getVolume(void) const
Return the object volume.
Definition: HalfSpace3d.cc:337
virtual GEOM_FT getArea(void) const
Return the object area.
Definition: HalfSpace3d.cc:334
HalfSpace3d(const Plane &p=Plane())
Default constructor.
Definition: HalfSpace3d.cc:31
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
Vector3d NormalExterior(void) const
Return a vector normal to the boundary plane oriented inside-out.
Definition: HalfSpace3d.cc:360
virtual GEOM_FT getLength(void) const
Return the length of the object.
Definition: HalfSpace3d.cc:331
Vector en tres dimensiones.
Definition: Vector3d.h:39
virtual GEOM_FT Ix(void) const
Return el moment of inertia with respect to the center of mass in local coordinates.
Definition: HalfSpace3d.cc:343
virtual GEOM_FT Pxy(void) const
Return el product of inertia.
Definition: HalfSpace3d.cc:351
Clase base para los objetos en tres dimensiones.
Definition: GeomObj3d.h:43
virtual bool In(const Pos3d &, const double &tol=0.0) const
Return true if the point is inside the half-space.
Definition: HalfSpace3d.cc:77