28 return v / sqrt(v.squared_length());
38 if (CGAL::cross_product(pta_ptb,
CGAL_Vector3(pta, some_point)) == CGAL::NULL_VECTOR)
46 std::deque<CGAL_Point3> vertices;
47 vertices.push_back(pta - ortho * h / 2 + ortho2 * w / 2);
48 vertices.push_back(pta - ortho * h / 2 + ortho2 * w / 2 + pta_ptb);
49 vertices.push_back(pta - ortho * h / 2 - ortho2 * w / 2);
50 vertices.push_back(pta + ortho * h / 2 + ortho2 * w / 2);
59 if (CGAL::do_intersect(*a.handle(), b.bbox()))
61 intersected->push_back(a.handle() - start_index);
69 float length,
float width,
float height)
71 std::deque<CGAL_TBox> boxes;
73 for (CGAL_Triangles::iterator it = triangle_soup.begin(); it != triangle_soup.end(); it++)
75 boxes.push_back(
CGAL_TBox(it->bbox(), it));
81 query_triangle.push_back(
CGAL_Triangle(query_box[0], query_box[1], query_box[2]));
82 std::deque<CGAL_TBox> query_tboxes;
83 CGAL::Bbox_3 box = query_triangle.begin()->bbox();
86 double epsilon = 0.0001;
87 double x_dim = abs(box.xmax() - box.xmin());
88 double y_dim = abs(box.ymax() - box.ymin());
89 double z_dim = abs(box.zmax() - box.zmin());
91 assert(abs(x_dim - length) < epsilon &&
92 "The dimension X of CGAL query box doesn't match query parameter.");
93 assert(abs(y_dim - width) < epsilon &&
"The dimension Y CGAL query box doesn't match query parameter.");
94 assert(abs(z_dim - height) < epsilon &&
95 "The dimension Z of CGAL query box doesn't match query parameter.");
96 query_tboxes.push_back(
CGAL_TBox(box, query_triangle.begin()));
101 std::deque<size_t> intersected;
106 std::placeholders::_1, std::placeholders::_2);
107 CGAL::box_intersection_d(boxes.begin(), boxes.end(), query_tboxes.begin(), query_tboxes.end(),
111 std::sort(intersected.begin(), intersected.end());
112 auto last = std::unique(intersected.begin(), intersected.end());
113 intersected.erase(last, intersected.end());
121 assert(
poly.size() > 2);
122 assert(
poly.is_simple() &&
"The polygon need to be simple - no 8 shape");
143 assert(
poly_vh.size() ==
poly.size() &&
"Inconsistency btw points and vertices vectors.");
150 assert(triangles.size() == 0 &&
"triangles output arguments expected to be empty");
151 for (CDT::Finite_faces_iterator it =
cdt.finite_faces_begin(); it !=
cdt.finite_faces_end(); ++it)
156 switch (
poly.bounded_side(center))
158 case CGAL::ON_UNBOUNDED_SIDE:
159 case CGAL::ON_BOUNDARY:
161 case CGAL::ON_BOUNDED_SIDE:
162 triangles.push_back(
cdt.triangle(it));
171 assert(triangles.size() == 0 &&
"triangles output arguments expected to be empty");
172 for (CDT::Finite_faces_iterator it =
cdt.finite_faces_begin(); it !=
cdt.finite_faces_end(); ++it)
177 switch (
poly.bounded_side(center))
179 case CGAL::ON_UNBOUNDED_SIDE:
180 case CGAL::ON_BOUNDARY:
182 case CGAL::ON_BOUNDED_SIDE:
184 for (
unsigned i = 0; i < 3; ++i)
186 tri[i] = it->vertex(i)->info().i;
188 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...