OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::BakeStageRecorder Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/TextureBake/TextureBakeDebug.hpp>

Collaboration diagram for Slic3r::BakeStageRecorder:

Public Member Functions

void enable (bool on)
bool enabled () const
void set_check_topology (bool on)
bool check_topology () const
void set_mesh_cap (size_t triangles)
size_t mesh_cap () const
void capture (const char *name, const TextureBake::TriSoup &soup, double ms, const std::string &detail={})
void capture (const char *name, const std::vector< Vec3f > &vertices, const std::vector< Vec3i32 > &indices, double ms, const std::string &detail={})
void capture_note (const char *name, double ms, const std::string &detail)
size_t mark () const
void rebase (size_t from, const Transform3d *to_local, bool flip_winding)
const std::vector< BakeStageSnapshot > & stages () const
std::vector< BakeStageSnapshot > take ()
void clear ()
bool empty () const
double total_ms () const
size_t dump_obj (const std::string &dir) const

Private Member Functions

void finish (BakeStageSnapshot &s)

Private Attributes

std::vector< BakeStageSnapshot > m_stages
bool m_enabled = false
bool m_check_topology = true
size_t m_mesh_cap = 4'000'000

Detailed Description

Member Function Documentation

◆ capture() [1/2]

void Slic3r::BakeStageRecorder::capture ( const char * name,
const std::vector< Vec3f > & vertices,
const std::vector< Vec3i32 > & indices,
double ms,
const std::string & detail = {} )
119{
120 if (!m_enabled)
121 return;
122 BakeStageSnapshot s;
123 s.name = name;
124 s.detail = detail;
125 s.ms = ms;
126 s.mesh.vertices = vertices;
127 s.mesh.indices = indices;
128 finish(s);
129}
bool m_enabled
Definition TextureBakeDebug.hpp:121
void finish(BakeStageSnapshot &s)
Definition TextureBakeDebug.cpp:65

References Slic3r::BakeStageSnapshot::detail, finish(), Slic3r::BakeStageMesh::indices, m_enabled, Slic3r::BakeStageSnapshot::mesh, Slic3r::BakeStageSnapshot::ms, Slic3r::BakeStageSnapshot::name, and Slic3r::BakeStageMesh::vertices.

Here is the call graph for this function:

◆ capture() [2/2]

void Slic3r::BakeStageRecorder::capture ( const char * name,
const TextureBake::TriSoup & soup,
double ms,
const std::string & detail = {} )
84{
85 if (!m_enabled)
86 return;
87
88 BakeStageSnapshot s;
89 s.name = name;
90 s.detail = detail;
91 s.ms = ms;
92
93 // The pipeline works on non-indexed soup, so welding here is what turns it back into something
94 // renderable. The geometry grid, matching to_indexed_triangle_set(), so the debug view shows the
95 // same sharing the bake's own output would have.
96 const size_t n = soup.pos.size();
97 TextureBake::QuantizedPointMap map(TextureBake::WELD_GRID_GEOMETRY, std::min(n, size_t(1) << 22));
98 std::vector<int> id(n);
99 s.mesh.vertices.reserve(n / 3);
100 for (size_t i = 0; i < n; ++i) {
101 id[i] = map.get_or_set(soup.pos[i], int(s.mesh.vertices.size()));
102 if (map.inserted())
103 s.mesh.vertices.push_back(soup.pos[i]);
104 }
105 s.mesh.indices.reserve(n / 3);
106 for (size_t t = 0; t + 2 < n; t += 3) {
107 // Corners that welded together carry no area; the bake's own conversion drops them too, so
108 // dropping them here keeps the stage count honest against what would be committed.
109 if (id[t] == id[t + 1] || id[t + 1] == id[t + 2] || id[t] == id[t + 2])
110 continue;
111 s.mesh.indices.emplace_back(id[t], id[t + 1], id[t + 2]);
112 }
113 finish(s);
114}
static constexpr double WELD_GRID_GEOMETRY
Definition TextureBakeIndex.hpp:25

References Slic3r::BakeStageSnapshot::detail, finish(), Slic3r::TextureBake::QuantizedPointMap::get_or_set(), Slic3r::BakeStageMesh::indices, Slic3r::TextureBake::QuantizedPointMap::inserted(), m_enabled, Slic3r::BakeStageSnapshot::mesh, Slic3r::BakeStageSnapshot::ms, Slic3r::BakeStageSnapshot::name, Slic3r::TextureBake::TriSoup::pos, Slic3r::BakeStageMesh::vertices, and Slic3r::TextureBake::WELD_GRID_GEOMETRY.

Referenced by Slic3r::build_texture_displacement_in_place(), Slic3r::GUI::GLGizmoTextureDisplacement::prepare_mesh(), and Slic3r::TextureBake::run_pipeline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ capture_note()

void Slic3r::BakeStageRecorder::capture_note ( const char * name,
double ms,
const std::string & detail )
132{
133 if (!m_enabled)
134 return;
135 BakeStageSnapshot s;
136 s.name = name;
137 s.detail = detail;
138 s.ms = ms;
139 s.topology_checked = false;
140 m_stages.push_back(std::move(s));
141}
std::vector< BakeStageSnapshot > m_stages
Definition TextureBakeDebug.hpp:120

References Slic3r::BakeStageSnapshot::detail, m_enabled, m_stages, Slic3r::BakeStageSnapshot::ms, Slic3r::BakeStageSnapshot::name, and Slic3r::BakeStageSnapshot::topology_checked.

◆ check_topology()

bool Slic3r::BakeStageRecorder::check_topology ( ) const
inline
81{ return m_check_topology; }
bool m_check_topology
Definition TextureBakeDebug.hpp:122

References m_check_topology.

◆ clear()

void Slic3r::BakeStageRecorder::clear ( )
inline
109{ m_stages.clear(); }

References m_stages.

◆ dump_obj()

size_t Slic3r::BakeStageRecorder::dump_obj ( const std::string & dir) const
inline
115{ return dump_bake_stages(m_stages, dir); }
size_t dump_bake_stages(const std::vector< BakeStageSnapshot > &stages, const std::string &dir)
Definition TextureBakeDebug.cpp:164

References Slic3r::dump_bake_stages(), and m_stages.

Here is the call graph for this function:

◆ empty()

bool Slic3r::BakeStageRecorder::empty ( ) const
inline
110{ return m_stages.empty(); }

References m_stages.

◆ enable()

void Slic3r::BakeStageRecorder::enable ( bool on)
inline
75{ m_enabled = on; }

References m_enabled.

Referenced by Slic3r::GUI::TextureDisplacementDebugJob::process().

Here is the caller graph for this function:

◆ enabled()

bool Slic3r::BakeStageRecorder::enabled ( ) const
inline
76{ return m_enabled; }

References m_enabled.

◆ finish()

void Slic3r::BakeStageRecorder::finish ( BakeStageSnapshot & s)
private
66{
67 s.triangles = s.mesh.indices.size();
68 s.vertices = s.mesh.vertices.size();
70 bake_stage_topology(s.mesh, s.open_edges, s.non_manifold_edges, s.degenerate);
71 s.topology_checked = m_check_topology;
72 if (s.triangles > m_mesh_cap) {
73 s.mesh_dropped = true;
74 s.mesh.vertices.clear();
75 s.mesh.vertices.shrink_to_fit();
76 s.mesh.indices.clear();
77 s.mesh.indices.shrink_to_fit();
78 }
79 m_stages.push_back(std::move(s));
80}
size_t m_mesh_cap
Definition TextureBakeDebug.hpp:123
void bake_stage_topology(const BakeStageMesh &mesh, size_t &open_edges, size_t &non_manifold_edges, size_t &degenerate)
Definition TextureBakeDebug.cpp:31

References Slic3r::bake_stage_topology(), Slic3r::BakeStageSnapshot::degenerate, Slic3r::BakeStageMesh::indices, m_check_topology, m_mesh_cap, m_stages, Slic3r::BakeStageSnapshot::mesh, Slic3r::BakeStageSnapshot::mesh_dropped, Slic3r::BakeStageSnapshot::non_manifold_edges, Slic3r::BakeStageSnapshot::open_edges, Slic3r::BakeStageSnapshot::topology_checked, Slic3r::BakeStageSnapshot::triangles, Slic3r::BakeStageMesh::vertices, and Slic3r::BakeStageSnapshot::vertices.

Referenced by capture(), and capture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mark()

size_t Slic3r::BakeStageRecorder::mark ( ) const
inline
99{ return m_stages.size(); }

References m_stages.

Referenced by Slic3r::build_texture_displacement(), and Slic3r::anonymous_namespace{TextureDisplacement.cpp}::build_texture_displacement_v2().

Here is the caller graph for this function:

◆ mesh_cap()

size_t Slic3r::BakeStageRecorder::mesh_cap ( ) const
inline
87{ return m_mesh_cap; }

References m_mesh_cap.

◆ rebase()

void Slic3r::BakeStageRecorder::rebase ( size_t from,
const Transform3d * to_local,
bool flip_winding )
144{
145 for (size_t i = from; i < m_stages.size(); ++i) {
146 BakeStageMesh &m = m_stages[i].mesh;
147 if (to_local != nullptr)
148 for (Vec3f &v : m.vertices)
149 v = (*to_local * v.cast<double>()).cast<float>();
150 if (flip_winding)
151 for (Vec3i32 &t : m.indices)
152 std::swap(t[1], t[2]);
153 }
154}
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
Eigen::Matrix< int32_t, 3, 1, Eigen::DontAlign > Vec3i32
Definition Point.hpp:59
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::cast(), Slic3r::BakeStageMesh::indices, m_stages, and Slic3r::BakeStageMesh::vertices.

Referenced by Slic3r::build_texture_displacement(), and Slic3r::anonymous_namespace{TextureDisplacement.cpp}::build_texture_displacement_v2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_check_topology()

void Slic3r::BakeStageRecorder::set_check_topology ( bool on)
inline
80{ m_check_topology = on; }

References m_check_topology.

Referenced by Slic3r::GUI::TextureDisplacementDebugJob::process().

Here is the caller graph for this function:

◆ set_mesh_cap()

void Slic3r::BakeStageRecorder::set_mesh_cap ( size_t triangles)
inline
86{ m_mesh_cap = triangles; }

References m_mesh_cap.

Referenced by Slic3r::GUI::TextureDisplacementDebugJob::process().

Here is the caller graph for this function:

◆ stages()

const std::vector< BakeStageSnapshot > & Slic3r::BakeStageRecorder::stages ( ) const
inline
107{ return m_stages; }

References m_stages.

◆ take()

std::vector< BakeStageSnapshot > Slic3r::BakeStageRecorder::take ( )
inline
108{ return std::move(m_stages); }

References m_stages.

Referenced by Slic3r::GUI::TextureDisplacementDebugJob::process().

Here is the caller graph for this function:

◆ total_ms()

double Slic3r::BakeStageRecorder::total_ms ( ) const
157{
158 double sum = 0.0;
159 for (const BakeStageSnapshot &s : m_stages)
160 sum += s.ms;
161 return sum;
162}

References m_stages.

Member Data Documentation

◆ m_check_topology

bool Slic3r::BakeStageRecorder::m_check_topology = true
private

◆ m_enabled

bool Slic3r::BakeStageRecorder::m_enabled = false
private

◆ m_mesh_cap

size_t Slic3r::BakeStageRecorder::m_mesh_cap = 4'000'000
private

Referenced by finish(), mesh_cap(), and set_mesh_cap().

◆ m_stages

std::vector<BakeStageSnapshot> Slic3r::BakeStageRecorder::m_stages
private

The documentation for this class was generated from the following files: