mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-31 23:42:04 +08:00
Replaced iterator-based constructor with one that takes either vector or array.
Refactored TriangleMesh constructor to use raw pointer (C-style semantics) and pointer vector/array.
This commit is contained in:
parent
ee208ddc73
commit
f0ba8a2340
@ -12,7 +12,7 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") {
|
|||||||
GIVEN( "A 20mm cube, built from constexpr std::array" ) {
|
GIVEN( "A 20mm cube, built from constexpr std::array" ) {
|
||||||
constexpr std::array<Pointf3, 8> vertices { Pointf3(20,20,0), Pointf3(20,0,0), Pointf3(0,0,0), Pointf3(0,20,0), Pointf3(20,20,20), Pointf3(0,20,20), Pointf3(0,0,20), Pointf3(20,0,20) };
|
constexpr std::array<Pointf3, 8> vertices { Pointf3(20,20,0), Pointf3(20,0,0), Pointf3(0,0,0), Pointf3(0,20,0), Pointf3(20,20,20), Pointf3(0,20,20), Pointf3(0,0,20), Pointf3(20,0,20) };
|
||||||
constexpr std::array<Point3, 12> facets { Point3(0,1,2), Point3(0,2,3), Point3(4,5,6), Point3(4,6,7), Point3(0,4,7), Point3(0,7,1), Point3(1,7,6), Point3(1,6,2), Point3(2,6,5), Point3(2,5,3), Point3(4,0,3), Point3(4,3,5) };
|
constexpr std::array<Point3, 12> facets { Point3(0,1,2), Point3(0,2,3), Point3(4,5,6), Point3(4,6,7), Point3(0,4,7), Point3(0,7,1), Point3(1,7,6), Point3(1,6,2), Point3(2,6,5), Point3(2,5,3), Point3(4,0,3), Point3(4,3,5) };
|
||||||
auto cube {TriangleMesh(vertices.cbegin(), vertices.cend(), facets.cbegin(), facets.cend())};
|
auto cube {TriangleMesh(vertices, facets)};
|
||||||
cube.repair();
|
cube.repair();
|
||||||
|
|
||||||
THEN( "Volume is appropriate for 20mm square cube.") {
|
THEN( "Volume is appropriate for 20mm square cube.") {
|
||||||
|
@ -28,7 +28,8 @@ TriangleMesh::TriangleMesh()
|
|||||||
stl_initialize(&this->stl);
|
stl_initialize(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& facets )
|
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& facets ) : TriangleMesh(points.data(), facets.data(), facets.size()) {}
|
||||||
|
TriangleMesh::TriangleMesh(const Pointf3* points, const Point3* facets, size_t n_facets)
|
||||||
: repaired(false)
|
: repaired(false)
|
||||||
{
|
{
|
||||||
stl_initialize(&this->stl);
|
stl_initialize(&this->stl);
|
||||||
@ -37,7 +38,7 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
|
|||||||
stl.stats.type = inmemory;
|
stl.stats.type = inmemory;
|
||||||
|
|
||||||
// count facets and allocate memory
|
// count facets and allocate memory
|
||||||
stl.stats.number_of_facets = facets.size();
|
stl.stats.number_of_facets = n_facets;
|
||||||
stl.stats.original_num_facets = stl.stats.number_of_facets;
|
stl.stats.original_num_facets = stl.stats.number_of_facets;
|
||||||
stl_allocate(&stl);
|
stl_allocate(&stl);
|
||||||
|
|
||||||
|
@ -36,11 +36,13 @@ class TriangleMesh
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriangleMesh();
|
TriangleMesh();
|
||||||
|
TriangleMesh(const Pointf3* points, const Point3* facets, size_t n_facets);
|
||||||
TriangleMesh(const Pointf3s &points, const std::vector<Point3> &facets);
|
TriangleMesh(const Pointf3s &points, const std::vector<Point3> &facets);
|
||||||
|
|
||||||
/// Templated constructor that takes a pair of iterators to build a TriangleMesh.
|
/// Templated constructor to adapt containers that offer .data() and .size()
|
||||||
template <typename Iter_vert, typename Iter_fac>
|
template <typename Vertex_Cont, typename Facet_Cont>
|
||||||
TriangleMesh(Iter_vert p_begin, Iter_vert p_end, Iter_fac f_begin, Iter_fac f_end) : TriangleMesh(Pointf3s(p_begin, p_end), Point3s(f_begin, f_end)) {}
|
TriangleMesh(const Vertex_Cont& vertices, const Facet_Cont& facets) : TriangleMesh(vertices.data(), facets.data(), facets.size()) {}
|
||||||
|
|
||||||
TriangleMesh(const TriangleMesh &other);
|
TriangleMesh(const TriangleMesh &other);
|
||||||
TriangleMesh& operator= (TriangleMesh other);
|
TriangleMesh& operator= (TriangleMesh other);
|
||||||
void swap(TriangleMesh &other);
|
void swap(TriangleMesh &other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user