43 return v / sqrt(v.squared_length());
53 if (CGAL::cross_product(pta_ptb,
CGAL_Vector3(pta, some_point)) == CGAL::NULL_VECTOR)
61 std::deque<CGAL_Point3> vertices;
62 vertices.push_back(pta - ortho * h / 2 + ortho2 * w / 2);
63 vertices.push_back(pta - ortho * h / 2 + ortho2 * w / 2 + pta_ptb);
64 vertices.push_back(pta - ortho * h / 2 - ortho2 * w / 2);
65 vertices.push_back(pta + ortho * h / 2 + ortho2 * w / 2);
74 if (CGAL::do_intersect(*a.handle(), b.bbox()))
76 intersected->push_back(a.handle() - start_index);
84 float length,
float width,
float height)
86 std::deque<CGAL_TBox> boxes;
88 for (CGAL_Triangles::iterator it = triangle_soup.begin(); it != triangle_soup.end(); it++)
90 boxes.push_back(
CGAL_TBox(it->bbox(), it));
96 query_triangle.push_back(
CGAL_Triangle(query_box[0], query_box[1], query_box[2]));
97 std::deque<CGAL_TBox> query_tboxes;
98 CGAL::Bbox_3 box = query_triangle.begin()->bbox();
101 double epsilon = 0.0001;
102 double x_dim = abs(box.xmax() - box.xmin());
103 double y_dim = abs(box.ymax() - box.ymin());
104 double z_dim = abs(box.zmax() - box.zmin());
106 assert(abs(x_dim - length) < epsilon &&
107 "The dimension X of CGAL query box doesn't match query parameter.");
108 assert(abs(y_dim - width) < epsilon &&
"The dimension Y CGAL query box doesn't match query parameter.");
109 assert(abs(z_dim - height) < epsilon &&
110 "The dimension Z of CGAL query box doesn't match query parameter.");
111 query_tboxes.push_back(
CGAL_TBox(box, query_triangle.begin()));
116 std::deque<size_t> intersected;
121 std::placeholders::_1, std::placeholders::_2);
122 CGAL::box_intersection_d(boxes.begin(), boxes.end(), query_tboxes.begin(), query_tboxes.end(),
126 std::sort(intersected.begin(), intersected.end());
127 auto last = std::unique(intersected.begin(), intersected.end());
128 intersected.erase(last, intersected.end());
136 assert(
poly.size() > 2);
137 assert(
poly.is_simple() &&
"The polygon need to be simple - no 8 shape");
158 assert(
poly_vh.size() ==
poly.size() &&
"Inconsistency btw points and vertices vectors.");
165 assert(triangles.size() == 0 &&
"triangles output arguments expected to be empty");
166 for (CDT::Finite_faces_iterator it =
cdt.finite_faces_begin(); it !=
cdt.finite_faces_end(); ++it)
171 switch (
poly.bounded_side(center))
173 case CGAL::ON_UNBOUNDED_SIDE:
174 case CGAL::ON_BOUNDARY:
176 case CGAL::ON_BOUNDED_SIDE:
177 triangles.push_back(
cdt.triangle(it));
186 assert(triangles.size() == 0 &&
"triangles output arguments expected to be empty");
187 for (CDT::Finite_faces_iterator it =
cdt.finite_faces_begin(); it !=
cdt.finite_faces_end(); ++it)
192 switch (
poly.bounded_side(center))
194 case CGAL::ON_UNBOUNDED_SIDE:
195 case CGAL::ON_BOUNDARY:
197 case CGAL::ON_BOUNDED_SIDE:
199 for (
unsigned i = 0; i < 3; ++i)
201 tri[i] = it->vertex(i)->info().i;
203 triangles.push_back(tri);
Plan defined by its equation : ax+by+cz+d=0.
OVector3D _vecK
Vector K for the Z axis.
OPoint3D _origin
The origin point.
PolygonTriangulator(const CGAL_Polygon &poly_)
Constructor from a CGAL_Polygon.
const Vertex_handle & vertex_handle(unsigned i) const
Return the ith vertex handle.
virtual ~PolygonTriangulator()
Destructor.
const CGAL_Polygon & poly
Reference to the CGAL_Polygon to triangulate.
CDT::Vertex_handle Vertex_handle
boost::array< unsigned, 3 > Tri_indices
void exportTrianglesIndices(std::deque< Tri_indices > &triangles) const
Exports the triangles inside the polygon.
void exportTriangles(std::deque< CDT::Triangle > &triangles) const
Exports the triangles inside the polygon.
Vertex_handles_container poly_vh
Polygon vertex handles.
CGAL_Vector3 normalize(CGAL_Vector3 v)
normalize vector v
CGAL::Triangle_3< CGAL_Gt > CGAL_Triangle
CGAL_Plane to_cgal(const OPlan &oplan)
Convert a OPlan to CGAL_Plane.
CGAL::Point_3< CGAL_Gt > CGAL_Point3
CGAL::Vector_3< CGAL_Gt > CGAL_Vector3
CGAL::Point_2< CGAL_Gt > CGAL_Point2
CGAL::Box_intersection_d::Box_with_handle_d< double, 3, CGAL_Triangles::iterator > CGAL_TBox
std::deque< CGAL_Triangle > CGAL_Triangles
std::deque< CGAL_Point3 > build_box(float w, float h, CGAL_Point3 pta, CGAL_Point3 ptb)
return 4 points defining a 3D parallelepiped
CGAL::Plane_3< CGAL_Gt > CGAL_Plane
CGAL::Polygon_2< CGAL_Gt > CGAL_Polygon
void intersection_report(std::deque< size_t > *intersected, CGAL_Triangles::iterator start_index, const CGAL_TBox &a, const CGAL_TBox &b)
std::deque< size_t > intersected_triangles(CGAL_Triangles &triangle_soup, std::deque< CGAL_Point3 > query_box, float length, float width, float height)
Find the triangles from triangle_soup that are intersected by the 3D box including the points of quer...