STP_BV.h
Go to the documentation of this file.
1 #ifndef __STP_BV_H
2 # define __STP_BV_H
3 
4 # pragma once
5 # include <list>
6 # include <map>
7 # include <sch/STP-BV/STP_Feature.h>
9 # include <sch/sch_api.h>
10 # include <vector>
11 
12 # ifdef WITH_BOOST_1_36
14 # endif
15 # include <boost/serialization/split_member.hpp>
16 
17 namespace sch
18 {
19 
21 {
24 };
25 
26 struct Geometry
27 {
29  {
32  SPHERE
33  };
34 
37  Scalar radius; // for spheres only
40  std::vector<Vector3> vertex;
41  std::vector<Vector3> normal;
42 
43  Geometry(GeometryType t) : type(t), color(0, 0, 0), radius(0), center(0, 0, 0), rotation(1, 0, 0, 0, 1, 0, 0, 0, 1) {}
44 };
45 
51 typedef struct s_toruslinkedBV
52 {
53  int buffer[4];
54  template<class Archive>
55  void serialize(Archive & ar, const unsigned int /*version*/)
56  {
57  ar & buffer;
58  }
60 
66 typedef struct s_Triangle
67 {
78  s_Triangle(const Point3 & vertex1, const Point3 & vertex2, const Point3 & vertex3);
79 
80  template<class Archive>
81  void serialize(Archive & ar, const unsigned int /*version*/)
82  {
83  ar & m_vertex1 & m_vertex2 & m_vertex3;
84  }
85 
90 
98 typedef struct s_SphereApproxim
99 {
107  s_SphereApproxim(std::vector<Point3> & vertices, int step, const Point3 & sphereCenter, double sphereRadius);
108 
114  void operator()(const Triangle & vertices, const int & currentStep) const;
115 
116  template<class Archive>
117  void serialize(Archive & ar, const unsigned int /*version*/)
118  {
120  }
121 
122  std::vector<Point3> & m_vertices;
123  int m_step;
127 
135 typedef struct s_PointsComparator
136 {
141 
147  void setData(const Point3 & axis, const std::vector<Point3> & points);
148 
154  bool operator()(unsigned int id1, unsigned int id2) const;
155 
156  template<class Archive>
157  void serialize(Archive & ar, const unsigned int /*version*/)
158  {
159  ar & m_axis & m_points;
160  }
161 
163  std::vector<Point3> m_points;
165 
167 {
168 public:
171 
172  SCH_API virtual ~STP_BV(void);
173 
174  SCH_API virtual STP_BV & operator=(const STP_BV &);
175 
176  SCH_API virtual STP_BV * clone() const;
177 
178  SCH_API virtual Point3 l_Support(const Vector3 & v, int & lastFeature) const;
179 
180  SCH_API virtual S_ObjectType getType() const;
181 
187  SCH_API virtual void constructFromFile(const std::string & filename);
188  SCH_API virtual void constructFromFileWithGL(const std::string & filename)
189  {
190  constructFromFile(filename);
191  }
192 
197  SCH_API virtual void loadFromBinary(const std::string & filename);
198 
203  SCH_API virtual void saveToBinary(const std::string & filename);
204 
211  SCH_API void saveTreeInFile(const std::string & treefilename, ArchiveType type = TEXT_ARCHIVE);
212 
217  SCH_API void addPatch(STP_Feature * patch);
218 
223  SCH_API void printSupportTree(std::string filename) const;
224 
229  SCH_API virtual Scalar supportH(const Vector3 & v) const;
230 
235  SCH_API virtual Point3 supportNaive(const Vector3 & v) const;
240  SCH_API virtual Point3 supportFarthestNeighbour(const Vector3 & v, int & lastFeature) const;
246  SCH_API virtual Point3 supportFarthestNeighbourPrime(const Vector3 & v, int & lastFeature) const;
252  SCH_API virtual Point3 supportHybrid(const Vector3 & v, int & lastFeature) const;
258  SCH_API virtual Point3 supportFirstNeighbour(const Vector3 & v, int & lastFeature) const;
264  SCH_API virtual Point3 supportFirstNeighbourPrime(const Vector3 & v, int & lastFeature) const;
265 
273  SCH_API virtual bool ray_cast(const Point3 & source, const Point3 & target, Scalar & param, Vector3 & normal) const;
274 
280 
281  const std::vector<sch::Geometry> & getGeometries() const;
282 
283  template<class Archive>
284  void load(Archive & ar, const unsigned int /*version*/)
285  {
286  ar & boost::serialization::base_object<S_ObjectNormalized>(*this);
287  ar & m_patches;
288  ar & m_patchesSize;
290  }
291 
292  template<class Archive>
293  void save(Archive & ar, const unsigned int /*version*/) const
294  {
295  ar & boost::serialization::base_object<S_ObjectNormalized>(*this);
296  ar & m_patches;
297  ar & m_patchesSize;
298  }
299 
301  {
302  return _R;
303  }
304 
306  {
307  return _r;
308  }
309 
310  BOOST_SERIALIZATION_SPLIT_MEMBER()
311 
312 protected:
319  SCH_API void loadTreeFromFile(const std::string & treefilename, ArchiveType type = TEXT_ARCHIVE);
320 
330  const Point3 & p2,
331  const Point3 & center,
332  int step,
333  std::vector<Point3> & res) const;
334 
345  const Point3 & p2,
346  Vector3 axis,
347  int step,
348  std::vector<Point3> & res,
349  Matrix3x3 & homo);
350 
360  const Point3 & l1p2,
361  const Point3 & l2p1,
362  const Point3 & l2p2) const;
363 
369  SCH_API Point3 computeCenter(const std::vector<Point3> & points);
370 
376 
377  std::vector<STP_Feature *> m_patches;
378 
383 
384  std::vector<Geometry> geometries_;
385 };
386 } // namespace sch
387 
388 #endif
389 
Definition: STP_BV.h:167
SCH_API void loadTreeFromFile(const std::string &treefilename, ArchiveType type=TEXT_ARCHIVE)
Load the tree structure of the object from a file.
virtual SCH_API Point3 supportFarthestNeighbour(const Vector3 &v, int &lastFeature) const
SCH_API int getFeaturesNumber() const
returns the vertex number in the STP-BV
virtual SCH_API Point3 supportFarthestNeighbourPrime(const Vector3 &v, int &lastFeature) const
SCH_API void computeConePointsBetween(const Point3 &p1, const Point3 &p2, Vector3 axis, int step, std::vector< Point3 > &res, Matrix3x3 &homo)
Computes the points of.
virtual SCH_API Point3 supportHybrid(const Vector3 &v, int &lastFeature) const
SCH_API void printSupportTree(std::string filename) const
Print the support tree in a file.
SCH_API Point3 computeCenter(const std::vector< Point3 > &points)
Computes the center of a surface defined by a list of points.
int m_patchesSize
Definition: STP_BV.h:381
void save(Archive &ar, const unsigned int) const
Definition: STP_BV.h:293
SCH_API void addPatch(STP_Feature *patch)
Adds a bouding volume to the object.
virtual SCH_API Point3 l_Support(const Vector3 &v, int &lastFeature) const
gives the support point for a given vector in local cordinates and a given last feature....
virtual SCH_API S_ObjectType getType() const
must be overloaded to return the type
virtual SCH_API Scalar supportH(const Vector3 &v) const
STP_Feature ** m_fastPatches
Definition: STP_BV.h:379
SCH_API STP_BV(const STP_BV &)
SCH_API STP_BV(void)
SCH_API void updateFastPatches()
Updates the dynamical array fastPatches. Must be called after each patches modification.
Scalar getBigRadius() const
Definition: STP_BV.h:300
virtual SCH_API void constructFromFile(const std::string &filename)
Constructs the object from a file describing its STP_BV decomposition.
std::vector< STP_Feature * > m_patches
Definition: STP_BV.h:377
virtual SCH_API bool ray_cast(const Point3 &source, const Point3 &target, Scalar &param, Vector3 &normal) const
I don't know.
SCH_API Point3 computeLinesCommonPoint(const Point3 &l1p1, const Point3 &l1p2, const Point3 &l2p1, const Point3 &l2p2) const
Computes the intersection of two segments.
SCH_API void computeArcPointsBetween(const Point3 &p1, const Point3 &p2, const Point3 &center, int step, std::vector< Point3 > &res) const
Computes the points of an arc.
virtual SCH_API void constructFromFileWithGL(const std::string &filename)
Definition: STP_BV.h:188
void load(Archive &ar, const unsigned int)
Definition: STP_BV.h:284
Scalar _r
Definition: STP_BV.h:382
Scalar _R
Definition: STP_BV.h:382
SCH_API void saveTreeInFile(const std::string &treefilename, ArchiveType type=TEXT_ARCHIVE)
virtual SCH_API STP_BV * clone() const
Returns a copy of this S_Object.
const std::vector< sch::Geometry > & getGeometries() const
virtual SCH_API void saveToBinary(const std::string &filename)
Save the object to a binary archive.
virtual SCH_API void loadFromBinary(const std::string &filename)
Load the object from a binary archive.
STP_Feature ** m_lastPatches
Definition: STP_BV.h:380
virtual SCH_API STP_BV & operator=(const STP_BV &)
virtual SCH_API ~STP_BV(void)
virtual SCH_API Point3 supportFirstNeighbour(const Vector3 &v, int &lastFeature) const
virtual SCH_API Point3 supportFirstNeighbourPrime(const Vector3 &v, int &lastFeature) const
gives the support for a vector using the First neighbour method.
virtual SCH_API Point3 supportNaive(const Vector3 &v) const
std::vector< Geometry > geometries_
Definition: STP_BV.h:384
Scalar getSmallRadius() const
Definition: STP_BV.h:305
Definition: STP_Feature.h:103
Definition: S_ObjectNormalized.h:16
S_ObjectType
type of a solid object. Don't use it to cast !
Definition: S_Object.h:234
Definition: CD_Pair.h:12
struct sch::s_Triangle Triangle
struct sch::s_toruslinkedBV toruslinkedBV
double Scalar
Definition: SCH_Types.h:23
struct sch::s_SphereApproxim SphereApproxim
struct sch::s_PointsComparator PointsComparator
ArchiveType
Definition: STP_BV.h:21
@ BINARY_ARCHIVE
Definition: STP_BV.h:22
@ TEXT_ARCHIVE
Definition: STP_BV.h:23
#define SCH_API
Definition: sch_api.h:13
Definition: STP_BV.h:27
Matrix3x3 rotation
Definition: STP_BV.h:39
std::vector< Vector3 > normal
Definition: STP_BV.h:41
GeometryType type
Definition: STP_BV.h:35
Scalar radius
Definition: STP_BV.h:37
std::vector< Vector3 > vertex
Definition: STP_BV.h:40
GeometryType
Definition: STP_BV.h:29
@ SPHERE
Definition: STP_BV.h:32
@ LINE
Definition: STP_BV.h:30
@ TRIANGLE
Definition: STP_BV.h:31
Geometry(GeometryType t)
Definition: STP_BV.h:43
Point3 color
Definition: STP_BV.h:36
Point3 center
Definition: STP_BV.h:38
Functor.
Definition: STP_BV.h:136
bool operator()(unsigned int id1, unsigned int id2) const
operator parenthesis
Point3 m_axis
Definition: STP_BV.h:162
s_PointsComparator()
Default constructor.
void serialize(Archive &ar, const unsigned int)
Definition: STP_BV.h:157
void setData(const Point3 &axis, const std::vector< Point3 > &points)
Constructor.
std::vector< Point3 > m_points
Definition: STP_BV.h:163
Functor.
Definition: STP_BV.h:99
Scalar m_sphereRadius
Definition: STP_BV.h:125
void operator()(const Triangle &vertices, const int &currentStep) const
operator parenthesis
Point3 m_sphereCenter
Definition: STP_BV.h:124
int m_step
Definition: STP_BV.h:123
void serialize(Archive &ar, const unsigned int)
Definition: STP_BV.h:117
s_SphereApproxim(std::vector< Point3 > &vertices, int step, const Point3 &sphereCenter, double sphereRadius)
Constructor.
std::vector< Point3 > & m_vertices
Definition: STP_BV.h:122
Defines a triangle.
Definition: STP_BV.h:67
s_Triangle()
Default constructor.
Definition: STP_BV.h:71
Point3 m_vertex1
Definition: STP_BV.h:86
Point3 m_vertex3
Definition: STP_BV.h:88
Point3 m_vertex2
Definition: STP_BV.h:87
void serialize(Archive &ar, const unsigned int)
Definition: STP_BV.h:81
s_Triangle(const Point3 &vertex1, const Point3 &vertex2, const Point3 &vertex3)
Constructor.
Stores the IDs of the BV to which a torus is linked.
Definition: STP_BV.h:52
int buffer[4]
Definition: STP_BV.h:53
void serialize(Archive &ar, const unsigned int)
Definition: STP_BV.h:55