59 #ifndef MB_TRIANGLEBSP_HH 60 #define MB_TRIANGLEBSP_HH 65 #include "BSPTreeNode.hh" 66 #include "TriangleBSPCoreT.hh" 67 #include "BSPImplT.hh" 72 template <
class BSPTraits>
77 typedef typename Base::Scalar Scalar;
79 const Scalar& _infinity = std::numeric_limits<Scalar>::infinity()) : Base(_traits, _infinity) {}
89 typedef typename Mesh::Scalar Scalar;
91 typedef typename Mesh::FaceHandle Handle;
92 typedef std::vector<Handle> Handles;
93 typedef typename Handles::iterator HandleIter;
99 inline void points(
const Handle _h, Point& _p0, Point& _p1, Point& _p2)
const 101 typename Mesh::CFVIter fv_it(mesh_.cfv_iter(_h));
102 _p0 = mesh_.point(*fv_it);
104 _p1 = mesh_.point(*fv_it);
106 _p2 = mesh_.point(*fv_it);
109 Scalar sqrdist(
const Handle _h,
const Point& _p)
const 112 points(_h, p0, p1, p2);
120 Point p0, p1, p2, bb_min, bb_max;
121 bb_min.vectorize(std::numeric_limits<typename Point::value_type>::infinity());
122 bb_max.vectorize(-std::numeric_limits<typename Point::value_type>::infinity());
123 std::list<Point> vertices;
125 for (it_h = _node->begin(); it_h != _node->end(); ++it_h) {
126 points(*it_h, p0, p1, p2);
135 vertices.push_back(p0);
136 vertices.push_back(p1);
137 vertices.push_back(p2);
139 bb_min = _node->bb_min;
140 bb_max = _node->bb_max;
143 Point bb = bb_max - bb_min;
144 Scalar length = bb[0];
147 length = bb[(axis = 1)];
149 length = bb[(axis = 2)];
165 size_t size = vertices.size();
166 typename std::list<Point>::iterator it_v;
167 it_v = vertices.begin();
168 std::advance(it_v, size / 2);
173 void calculateBoundingBoxRoot(Node* _node)
176 Point p0, p1, p2, bb_min, bb_max;
177 bb_min.vectorize(FLT_MAX);
178 bb_max.vectorize(-FLT_MAX);
179 for (it = _node->begin(); it != _node->end(); ++it) {
180 points(*it, p0, p1, p2);
188 _node->bb_min = bb_min;
189 _node->bb_max = bb_max;
196 struct x_sort {
bool operator()(
const Point& first,
const Point& second) {
return (first[0] < second[0]); } };
197 struct y_sort {
bool operator()(
const Point& first,
const Point& second) {
return (first[1] < second[1]); } };
198 struct z_sort {
bool operator()(
const Point& first,
const Point& second) {
return (first[2] < second[2]); } };
205 template <
class Mesh>
212 typedef typename Traits::Scalar Scalar;
214 const Scalar& _infinity = std::numeric_limits<Scalar>::infinity()) : Base(Traits(_mesh), _infinity) {}
218 #endif // MB_TRIANGLEBSP_HH defined
void points(const Handle _h, Point &_p0, Point &_p1, Point &_p2) const
Returns the points belonging to the face handle _h.
void calculateBoundingBox(Node *_node, Point &median, int &axis)
Vec::value_type distPointTriangleSquaredStable(const Vec &_p, const Vec &_v0, const Vec &_v1, const Vec &_v2, Vec &_nearestPoint)
squared distance from point _p to triangle (_v0, _v1, _v2)
Kernel::Point Point
Coordinate type.