Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Contour3D.hpp « SLA « libslic3r « src - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3380cd6ab018060f2ff595e121f96cb5adf12c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef SLA_CONTOUR3D_HPP
#define SLA_CONTOUR3D_HPP

#include <libslic3r/TriangleMesh.hpp>

namespace Slic3r {

// Used for quads (TODO: remove this, and convert quads to triangles in OpenVDBUtils)
using Vec4i = Eigen::Matrix<int, 4, 1, Eigen::DontAlign>;

namespace sla {

class IndexedMesh;

/// Dumb vertex mesh consisting of triangles (or) quads. Capable of merging with
/// other meshes of this type and converting to and from other mesh formats.
struct Contour3D {
    std::vector<Vec3d> points;
    std::vector<Vec3i> faces3;
    std::vector<Vec4i> faces4;
    
    Contour3D() = default;
    Contour3D(const TriangleMesh &trmesh);
    Contour3D(TriangleMesh &&trmesh);
    Contour3D(const IndexedMesh  &emesh);
    
    Contour3D& merge(const Contour3D& ctr);
    Contour3D& merge(const Pointf3s& triangles);
    
    // Write the index triangle structure to OBJ file for debugging purposes.
    void to_obj(std::ostream& stream);
    void from_obj(std::istream &stream);

    inline bool empty() const
    {
        return points.empty() || (faces4.empty() && faces3.empty());
    }
};

/// Mesh from an existing contour.
TriangleMesh to_triangle_mesh(const Contour3D& ctour);

/// Mesh from an evaporating 3D contour
TriangleMesh to_triangle_mesh(Contour3D&& ctour);

}} // namespace Slic3r::sla

#endif // CONTOUR3D_HPP