From 725f3ed94f3a5a761b979114dce27dab26a76547 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 20 May 2017 21:28:04 -0500 Subject: [PATCH] Converted more of TriangleMesh to doxygen comments, added documentation for make_* functions in TriangleMesh. --- xs/src/libslic3r/TriangleMesh.cpp | 6 +++--- xs/src/libslic3r/TriangleMesh.hpp | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index 429a5fff45..9e3c8bf1a8 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -738,7 +738,7 @@ template void TriangleMeshSlicer::slice(const std::vector &z, std::vector* layers) const { - /* + /** This method gets called with a list of unscaled Z coordinates and outputs a vector pointer having the same number of items as the original list. Each item is a vector of polygons created by slicing our mesh at the @@ -1160,14 +1160,14 @@ template void TriangleMeshSlicer::make_expolygons(const Polygons &loops, ExPolygons* slices) const { - /* + /** Input loops are not suitable for evenodd nor nonzero fill types, as we might get two consecutive concentric loops having the same winding order - and we have to respect such order. In that case, evenodd would create wrong inversions, and nonzero would ignore holes inside two concentric contours. So we're ordering loops and collapse consecutive concentric loops having the same winding order. - TODO: find a faster algorithm for this, maybe with some sort of binary search. + \todo find a faster algorithm for this, maybe with some sort of binary search. If we computed a "nesting tree" we could also just remove the consecutive loops having the same winding order, and remove the extra one(s) so that we could just supply everything to offset() instead of performing several union/diff calls. diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp index 271324282a..99a77f39ca 100644 --- a/xs/src/libslic3r/TriangleMesh.hpp +++ b/xs/src/libslic3r/TriangleMesh.hpp @@ -60,12 +60,23 @@ class TriangleMesh void extrude_tin(float offset); void require_shared_vertices(); void reverse_normals(); - + + /// Generate a mesh representing a cube with dimensions (x, y, z), with one corner at (0,0,0). static TriangleMesh make_cube(double x, double y, double z); + + /// Generate a mesh representing a cylinder of radius r and height h, with the base at (0,0,0). + /// param[in] r Radius + /// param[in] h Height + /// param[in] fa Facet angle. A smaller angle produces more facets. Default value is 2pi / 360. static TriangleMesh make_cylinder(double r, double h, double fa=(2*PI/360)); + + /// Generate a mesh representing a sphere of radius rho, centered about (0,0,0). + /// param[in] rho Distance from center to the shell of the sphere. + /// param[in] fa Facet angle. A smaller angle produces more facets. Default value is 2pi / 360. static TriangleMesh make_sphere(double rho, double fa=(2*PI/360)); stl_file stl; + /// Whether or not this mesh has been repaired. bool repaired; private: @@ -98,6 +109,8 @@ class IntersectionLine : public Line typedef std::vector IntersectionLines; typedef std::vector IntersectionLinePtrs; + +/// \brief Class for processing TriangleMesh objects. template class TriangleMeshSlicer { @@ -112,7 +125,11 @@ class TriangleMeshSlicer const float &min_z, const float &max_z, std::vector* lines, boost::mutex* lines_mutex = NULL) const; - void cut(float z, TriangleMesh* upper, TriangleMesh* lower) const; + /// \brief Splits the current mesh into two parts. + /// \param[in] z Coordinate plane to cut along. + /// \param[out] upper TriangleMesh object to add the mesh > z. NULL suppresses saving this. + /// \param[out] lower TriangleMesh object to save the mesh < z. NULL suppresses saving this. + void cut(float z, TriangleMesh* upper, TriangleMesh* lower) const private: typedef std::vector< std::vector > t_facets_edges;