25 |
#define UNION_HPP |
#define UNION_HPP |
26 |
|
|
27 |
#include <Object.hpp> |
#include <Object.hpp> |
28 |
|
#include <list> |
29 |
|
|
30 |
/*! |
/*! |
31 |
\class Union |
\class Union |
38 |
: public Shape |
: public Shape |
39 |
{ |
{ |
40 |
private: |
private: |
41 |
|
typedef std::list<ReferenceCounting<Object> > ObjectList; |
42 |
|
|
43 |
|
public: |
44 |
|
typedef std::list<ReferenceCounting<Object> >::iterator iterator; |
45 |
|
typedef std::list<ReferenceCounting<Object> >::const_iterator const_iterator; |
46 |
|
|
47 |
|
private: |
48 |
//! The list of Shapes contained in the union. |
//! The list of Shapes contained in the union. |
49 |
std::vector<ReferenceCounting<Shape> > __shape; |
ObjectList __objects; |
50 |
|
|
51 |
//! Returns \p true if the point \a p is inside the Union. |
//! Returns \p true if the point \a p is inside the Union. |
52 |
inline const bool inShape (const TinyVector<3>& p) const; |
inline const bool inShape (const TinyVector<3>& p) const; |
54 |
//! Prints the Union informations using the stream \a s. |
//! Prints the Union informations using the stream \a s. |
55 |
std::ostream& put(std::ostream& s) const; |
std::ostream& put(std::ostream& s) const; |
56 |
|
|
57 |
/*! |
public: |
|
Compute the distance to the face of the Union. |
|
|
\warning Not implemented. |
|
|
*/ |
|
|
inline const TinyVector<3> _distance(const Vertex& V) const |
|
|
{ |
|
|
fferr(2) << '\n' << __FILE__ << ':' << __LINE__ |
|
|
<< ':' << "Not implemented\n"; |
|
|
std::exit(1); |
|
58 |
|
|
59 |
return V; |
const const_iterator begin() const |
60 |
}; |
{ |
61 |
|
return __objects.begin(); |
62 |
|
} |
63 |
|
|
64 |
public: |
iterator begin() |
65 |
|
{ |
66 |
|
return __objects.begin(); |
67 |
|
} |
68 |
|
|
|
/*! |
|
|
Computes the vector \f$ \overrightarrow{WV} \f$ where \em W the closest |
|
|
point of the surface of the Union to a given \a \em V and which norm is |
|
|
1. If W is not on an edge or a corner WV is the external normal to the |
|
|
Union. |
|
|
*/ |
|
|
inline const TinyVector<3> normal(const Vertex& V) const; |
|
69 |
|
|
70 |
//! Adds the Object \a O inside the Union. |
const const_iterator end() const |
71 |
inline void AddObject(const Object& O); |
{ |
72 |
|
return __objects.end(); |
73 |
|
} |
74 |
|
|
75 |
//! Adds the Shape \a S inside the Union. |
iterator end() |
76 |
inline void AddObject(ReferenceCounting<Shape> S); |
{ |
77 |
|
return __objects.end(); |
78 |
|
} |
79 |
|
|
80 |
//! Returns the Number of Objects contained in the Union. |
//! Adds the Object \a O inside the Union. |
81 |
inline const size_t NbObjects() const |
inline void push_back(ReferenceCounting<Object> O) |
82 |
{ |
{ |
83 |
return __shape.size(); |
__objects.push_back(O); |
84 |
} |
} |
85 |
|
|
86 |
//! Default constructor. |
//! Default constructor. |
87 |
Union(); |
Union(); |
88 |
|
|
|
//! Constructs and Union using an Object \a O. |
|
|
Union(const Object& O); |
|
|
|
|
89 |
//! Copy constructor. |
//! Copy constructor. |
90 |
Union(const Union& U); |
Union(const Union& U); |
91 |
|
|
97 |
|
|
98 |
}; |
}; |
99 |
|
|
|
//! Adds the Object \a O inside the Union. |
|
|
void Union::AddObject(const Object& O) |
|
|
{ |
|
|
__shape.push_back(O.shape()); |
|
|
} |
|
|
|
|
|
//! Adds the Shape \a S inside the Union. |
|
|
void Union::AddObject(ReferenceCounting<Shape> S) |
|
|
{ |
|
|
__shape.push_back(S); |
|
|
} |
|
|
|
|
100 |
//! Returns \p true if the point \a p is inside the Union. |
//! Returns \p true if the point \a p is inside the Union. |
101 |
inline const bool Union::inShape (const TinyVector<3>& p) const |
inline const bool Union::inShape (const TinyVector<3>& p) const |
102 |
{ |
{ |
103 |
for (size_t i=0; i<NbObjects(); i++) { |
for (Union::const_iterator i=__objects.begin(); |
104 |
if(((*__shape[i]).inside(p))) { |
i != __objects.end(); ++i) { |
105 |
|
if((*(*i)).inside(p)) { |
106 |
return true; |
return true; |
107 |
} |
} |
108 |
} |
} |
110 |
return false; |
return false; |
111 |
} |
} |
112 |
|
|
|
/*! Computes the vector \f$ \overrightarrow{WV} \f$ where \em W the closest |
|
|
point of the surface of the Union to a given \a \em V and which norm is |
|
|
1. If W is not on an edge or a corner WV is the external normal to the |
|
|
Union. |
|
|
\warning not implemented. |
|
|
*/ |
|
|
inline const TinyVector<3> Union::normal(const Vertex& V) const |
|
|
{ |
|
|
fferr(2) << __FILE__ << ':' << __LINE__ |
|
|
<< ':' << "Not implemented\n"; |
|
|
std::exit(1); |
|
|
return V; |
|
|
} |
|
|
|
|
|
|
|
113 |
#endif // UNION_HPP |
#endif // UNION_HPP |
114 |
|
|