55 #ifndef KJB_FIND_SHAPES_H
56 #define KJB_FIND_SHAPES_H
76 const Vector& point_on_plane,
97 const Vector& plane1_params,
98 const Vector& plane2_params,
100 double distTolerance=1.0
121 const Vector& plane1_params,
122 const Vector& plane2_params
123 )
throw (Illegal_argument, KJB_error);
131 void find_planes(
const Polymesh& p, std::vector<Polymesh_Plane>& plane);
139 const std::vector<Polymesh_Plane>& planes
149 std::vector<Circle_in_3d>& circles,
150 std::vector<std::vector<Vector> >&
points
161 const std::vector<kjb::Polygon>& faces,
172 const std::vector<kjb::Polygon>& faces,
173 const Int_vector& mask,
175 std::vector<Right_Triangle_Pair>& rectangles
185 const std::vector<Right_Triangle_Pair>& rectangles,
196 const Int_vector& cylMask,
197 const Int_vector& rectMask,
198 const std::vector<Right_Triangle_Pair>& rectangles,
203 double lengthTolerance,
204 double& smallestAngle,
205 double& largestAngle,
207 std::vector<int>& cyl_indices,
210 Vector& edge_pt1_adj,
220 const std::vector<Right_Triangle_Pair>& rectangles,
221 std::vector<std::vector<int> >& cyl_indices,
222 std::vector<double>& cylSumAngles,
223 std::vector<std::vector<Vector> >& cylEdgePoints
235 const Int_vector& rectMask,
236 const std::vector<Right_Triangle_Pair>& rectangles,
237 const std::vector<int>& cyl_indices,
238 std::vector<Vector>& top_points,
239 std::vector<Vector>& bottom_points
247 const std::vector<Vector>&
points,
257 const std::vector<Vector>&
points,
258 const Vector& centroid,
267 std::vector<Vector>&
points,
268 const Vector& plane_params,
269 const Vector& centroid,
270 std::vector<Vector>& projected_points
278 const std::vector<Vector>&
points,
279 const Vector& plane_params,
280 std::vector<Vector>& translated_points,
281 std::vector<Matrix>& transformMatrices
291 const std::vector<Matrix>& transformMatrices,
292 Vector& translated_point
302 const Int_vector& rectMask,
303 const std::vector<Right_Triangle_Pair>& rectangles,
304 const std::vector<int>& cyl_indices,
306 const std::vector<Vector>& cylEdgePoints,
307 Cylinder_section& cyl
318 std::vector<Polymesh_Plane>& plane,
319 std::vector<Cylinder_section>& cyl
328 std::vector<Polymesh_Plane>& plane
337 std::vector<Polymesh_Plane>& plane
346 std::vector<Polymesh_Plane>& plane
356 std::vector<Polymesh_Plane>& plane
void find_planes(const Polymesh &p, std::vector< Polymesh_Plane > &plane)
Finds all of the planes in a polymesh and stores each set of coefficients along with the correspondin...
Definition: gr_find_shapes.cpp:385
void render_planes(const Polymesh &p, const std::vector< Polymesh_Plane > &planes)
Renders each plane in a polymesh with a different color.
Definition: gr_find_shapes.cpp:472
void create_rectangle_mask(const Polymesh &p, const std::vector< Right_Triangle_Pair > &rectangles, Int_vector &rectMask)
Creates an Int_vector mask representing the faces in a polymesh that are part of a rectangle...
Definition: gr_find_shapes.cpp:1044
double get_angle_between_two_vectors(const Vector &plane1_params, const Vector &plane2_params)
Calculates the smaller angle between the normal vectors of two planes. The angle returned is in radia...
Definition: gr_find_shapes.cpp:337
void translate_xy_point_to_3d_plane(const Vector &point, const std::vector< Matrix > &transformMatrices, Vector &translated_point)
Definition: gr_find_shapes.cpp:3027
REAL * point
Definition: triangle.c:537
void find_adjacent_rectangles(const Polymesh &p, const Int_vector &cylMask, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, int startIndex, int rectIndex, int prevAdjFace, double width, double lengthTolerance, double &smallestAngle, double &largestAngle, double &sumAngles, std::vector< int > &cyl_indices, Vector &edge_pt1, Vector &edge_pt2, Vector &edge_pt1_adj, Vector &edge_pt_adj)
Determines which rectangles are adjacent to eachother and if a group of adjacent rectangles form part...
Definition: gr_find_shapes.cpp:1109
void fit_plane_to_3d_points(const std::vector< Vector > &points, const Vector ¢roid, Vector &plane_params)
Uses singular value decomposition (SVD) to fit a plane to a set of 3D points.
Definition: gr_find_shapes.cpp:2726
void find_rectangles(const std::vector< kjb::Polygon > &faces, const Int_vector &mask, const Polymesh &p, std::vector< Right_Triangle_Pair > &rectangles)
Finds all pairs of right triangles in a polymesh that are coplanar, adjacent along their hypotenuses...
Definition: gr_find_shapes.cpp:856
void fit_cylinder(const Polymesh &p, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, const std::vector< int > &cyl_indices, double cylAngle, const std::vector< Vector > &cylEdgePoints, Cylinder_section &cyl)
Determines the parameters of the cylinder formed by a set of faces in the polymesh.
Definition: gr_find_shapes.cpp:3089
void find_rectangles_to_render(const Polymesh &p, std::vector< Polymesh_Plane > &plane)
Renders each pair of faces that forms a rectangle a different color.
Definition: gr_find_shapes.cpp:3584
void find_top_and_bottom_points_of_cylinder(const Polymesh &p, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, const std::vector< int > &cyl_indices, std::vector< Vector > &top_points, std::vector< Vector > &bottom_points)
Determines which points make up the 'top' and which points make up the 'bottom' of the cylinder speci...
Definition: gr_find_shapes.cpp:2250
Cylinder_section: a section of a geometric cylinder.
void translate_3d_plane_to_xy_plane(const std::vector< Vector > &points, const Vector &plane_params, std::vector< Vector > &translated_points, std::vector< Matrix > &transformMatrices)
Definition: gr_find_shapes.cpp:2862
void find_cylinders_to_render_and_fit(char *faceFile, char *cylFile, const Polymesh &p, std::vector< Polymesh_Plane > &plane, std::vector< Cylinder_section > &cyl)
Definition: gr_find_shapes.cpp:3417
void find_cylinders(const Polymesh &p, const std::vector< Right_Triangle_Pair > &rectangles, std::vector< std::vector< int > > &cyl_indices, std::vector< double > &cylSumAngles, std::vector< std::vector< Vector > > &cylEdgePoints)
Determines which groups of faces in the polymesh form cylinders.
Definition: gr_find_shapes.cpp:1400
void find_right_triangles_to_render(const Polymesh &p, std::vector< Polymesh_Plane > &plane)
Renders each face that is a right triangle in a different color.
Definition: gr_find_shapes.cpp:3647
void find_adjacent_right_triangles_to_render(const Polymesh &p, std::vector< Polymesh_Plane > &plane)
Renders each face that is a right triangle and adjacent to another face that is also a right triangle...
Definition: gr_find_shapes.cpp:3697
void get_plane_parameters(const Vector &normal, const Vector &point_on_plane, Vector &plane_params)
Finds the coefficients of the plane of the form ax + by + cz + d = 0 given the normal vector and a po...
Definition: gr_find_shapes.cpp:88
void find_right_triangles(const std::vector< kjb::Polygon > &faces, Int_vector &mask)
Creates an Int_vector mask representing the faces in a polymesh that are right triangles.
Definition: gr_find_shapes.cpp:828
void find_centroid_of_3d_points(const std::vector< Vector > &points, Vector ¢roid)
Finds the center of a set of 3D points.
Definition: gr_find_shapes.cpp:2673
bool check_if_4_points_are_coplanar(const Vector &p1, const Vector &p2, const Vector &p3, const Vector &p4, double tolerance)
Checks if 4 points are coplanar.
Definition: gr_find_shapes.cpp:277
void find_cylinders_to_render(const Polymesh &p, std::vector< Polymesh_Plane > &plane)
Renders each set of faces that forms a cylinder a different color.
Definition: gr_find_shapes.cpp:3520
This class contains a Vector of plane parameters, a list of the face indices that lie in the plane...
struct memorypool points
Definition: triangle.c:637
bool check_if_faces_are_coplanar(const Vector &plane1_params, const Vector &plane2_params, double tolerance, double distTolerance=1.0)
Checks if two faces in a polymesh are coplanar.
Definition: gr_find_shapes.cpp:195
void find_all_circles_in_polymesh(Polymesh &p, std::vector< Circle_in_3d > &circles, std::vector< std::vector< Vector > > &points)
Finds all of the circles and the points that lie on them in the polymesh.
Definition: gr_find_shapes.cpp:563
void project_points_onto_plane(std::vector< Vector > &points, const Vector &plane_params, const Vector ¢roid, std::vector< Vector > &projected_points)
Projects 3D points onto the best-fit 3D plane.
Definition: gr_find_shapes.cpp:2781