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

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

Collaboration diagram for Slic3r::TriangleMesh:

Public Member Functions

 TriangleMesh ()=default
 TriangleMesh (const std::vector< Vec3f > &vertices, const std::vector< Vec3i32 > &faces)
 TriangleMesh (std::vector< Vec3f > &&vertices, const std::vector< Vec3i32 > &&faces)
 TriangleMesh (const indexed_triangle_set &M)
 TriangleMesh (indexed_triangle_set &&M, const RepairedMeshErrors &repaired_errors=RepairedMeshErrors())
void clear ()
bool from_stl (stl_file &stl, bool repair=true)
bool ReadSTLFile (const char *input_file, bool repair=true, ImportstlProgressFn stlFn=nullptr, int custom_header_length=80)
bool write_ascii (const char *output_file) const
bool write_binary (const char *output_file) const
float volume ()
void WriteOBJFile (const char *output_file) const
void scale (float factor)
void scale (const Vec3f &versor)
void translate (float x, float y, float z)
void translate (const Vec3f &displacement)
void rotate (float angle, const Axis &axis)
void rotate (float angle, const Vec3d &axis)
void rotate_x (float angle)
void rotate_y (float angle)
void rotate_z (float angle)
void mirror (const Axis axis)
void mirror_x ()
void mirror_y ()
void mirror_z ()
void transform (const Transform3d &t, bool fix_left_handed=false)
void transform (const Matrix3d &t, bool fix_left_handed=false)
void flip_triangles ()
void align_to_origin ()
void rotate (double angle, Point *center)
std::vector< TriangleMesh > split () const
void merge (const TriangleMesh &mesh)
ExPolygons horizontal_projection () const
Polygon convex_hull () const
BoundingBoxf3 bounding_box () const
BoundingBoxf3 transformed_bounding_box (const Transform3d &trafo) const
BoundingBoxf3 transformed_bounding_box (const Transform3d &trafo, double world_min_z) const
Vec3d size () const
Vec3d center () const
 Return the center of the related bounding box.
TriangleMesh convex_hull_3d () const
std::vector< ExPolygons > slice (const std::vector< double > &z) const
size_t facets_count () const
bool empty () const
bool repaired () const
bool is_splittable () const
size_t memsize () const
size_t release_optional ()
void restore_optional ()
const TriangleMeshStats & stats () const
void set_init_shift (const Vec3d &offset)
Vec3d get_init_shift () const

Public Attributes

indexed_triangle_set its

Private Attributes

TriangleMeshStats m_stats
Vec3d m_init_shift {0.0, 0.0, 0.0}

Detailed Description

Constructor & Destructor Documentation

◆ TriangleMesh() [1/5]

Slic3r::TriangleMesh::TriangleMesh ( )
default

Referenced by convex_hull_3d(), merge(), and split().

Here is the caller graph for this function:

◆ TriangleMesh() [2/5]

Slic3r::TriangleMesh::TriangleMesh ( const std::vector< Vec3f > & vertices,
const std::vector< Vec3i32 > & faces )
72 : its { faces, vertices }
73{
75}
TriangleMeshStats m_stats
Definition TriangleMesh.hpp:167
indexed_triangle_set its
Definition TriangleMesh.hpp:164
static void fill_initial_stats(const indexed_triangle_set &its, TriangleMeshStats &out)
Definition TriangleMesh.cpp:61

References Slic3r::fill_initial_stats(), its, and m_stats.

Here is the call graph for this function:

◆ TriangleMesh() [3/5]

Slic3r::TriangleMesh::TriangleMesh ( std::vector< Vec3f > && vertices,
const std::vector< Vec3i32 > && faces )
77 : its { std::move(faces), std::move(vertices) }
78{
80}

References Slic3r::fill_initial_stats(), its, and m_stats.

Here is the call graph for this function:

◆ TriangleMesh() [4/5]

Slic3r::TriangleMesh::TriangleMesh ( const indexed_triangle_set & M)
explicit
82 : its(its)
83{
85}

References Slic3r::fill_initial_stats(), its, and m_stats.

Here is the call graph for this function:

◆ TriangleMesh() [5/5]

Slic3r::TriangleMesh::TriangleMesh ( indexed_triangle_set && M,
const RepairedMeshErrors & repaired_errors = RepairedMeshErrors() )
explicit
87 : its(std::move(its))
88{
89 m_stats.repaired_errors = errors;
91}

References Slic3r::fill_initial_stats(), its, and m_stats.

Here is the call graph for this function:

Member Function Documentation

◆ align_to_origin()

void Slic3r::TriangleMesh::align_to_origin ( )
384{
385 this->translate(- m_stats.min(0), - m_stats.min(1), - m_stats.min(2));
386}
void translate(float x, float y, float z)
Definition TriangleMesh.cpp:297

References m_stats, and translate().

Here is the call graph for this function:

◆ bounding_box()

BoundingBoxf3 Slic3r::TriangleMesh::bounding_box ( ) const

◆ center()

Vec3d Slic3r::TriangleMesh::center ( ) const
inline

Return the center of the related bounding box.

140{ return this->bounding_box().center(); }
PointType center() const
Definition BoundingBox.cpp:237
BoundingBoxf3 bounding_box() const
Definition TriangleMesh.cpp:447

References bounding_box(), and Slic3r::BoundingBox3Base< PointType >::center().

Referenced by Slic3r::orientation::AutoOrienter::find_cooling_direction2(), and rotate().

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

◆ clear()

void Slic3r::TriangleMesh::clear ( )
inline
101{ this->its.clear(); this->m_stats.clear(); }

References its, and m_stats.

◆ convex_hull()

Polygon Slic3r::TriangleMesh::convex_hull ( ) const
437{
438 Points pp;
439 pp.reserve(this->its.vertices.size());
440 for (size_t i = 0; i < this->its.vertices.size(); ++ i) {
441 const stl_vertex &v = this->its.vertices[i];
442 pp.emplace_back(Point::new_scale(v(0), v(1)));
443 }
445}
static Point new_scale(coordf_t x, coordf_t y)
Definition Point.hpp:214
Polygon convex_hull(Points pts)
Definition ConvexHull.cpp:21
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73

References Slic3r::Geometry::convex_hull(), its, and Slic3r::Point::new_scale().

Referenced by Slic3r::GUI::Camera::calc_zoom_to_volumes_factor(), and Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_chull_rotations().

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

◆ convex_hull_3d()

TriangleMesh Slic3r::TriangleMesh::convex_hull_3d ( ) const
516{
517 TriangleMesh mesh(its_convex_hull(this->its));
518 // Quite often qhull produces non-manifold mesh.
519 // assert(mesh.stats().manifold());
520 return mesh;
521}
indexed_triangle_set its_convex_hull(const std::vector< Vec3f > &pts)
Definition TriangleMesh.cpp:1358

References TriangleMesh(), its, and Slic3r::its_convex_hull().

Referenced by Slic3r::sla::find_min_z_height_rotation(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_chull_rotations(), Slic3r::lay_on_face_planes(), Slic3r::GLVolumeCollection::load_object_auxiliary(), and Slic3r::GLVolumeCollection::load_real_wipe_tower_preview().

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

◆ empty()

◆ facets_count()

size_t Slic3r::TriangleMesh::facets_count ( ) const
inline
145{ assert(m_stats.number_of_facets == this->its.indices.size()); return m_stats.number_of_facets; }

References m_stats.

Referenced by construct_assemble_list(), empty(), Slic3r::lay_on_face_planes(), Slic3r::orientation::orient_for_cooling(), Slic3r::GUI::GLGizmoTextureDisplacement::painted_area_mm2(), Slic3r::SlicingAdaptive::prepare(), Slic3r::CLI::run(), Slic3r::ModelObject::split(), and Slic3r::GUI::GLGizmoTextureDisplacement::v2_recommendation().

Here is the caller graph for this function:

◆ flip_triangles()

void Slic3r::TriangleMesh::flip_triangles ( )
378{
380 m_stats.volume = - m_stats.volume;
381}
void its_flip_triangles(indexed_triangle_set &its)
Definition TriangleMesh.cpp:752

References its, Slic3r::its_flip_triangles(), and m_stats.

Referenced by Slic3r::_3MF_Importer::_generate_volumes(), Slic3r::_BBS_3MF_Importer::_generate_volumes_new(), Slic3r::load_drc(), and Slic3r::load_obj().

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

◆ from_stl()

bool Slic3r::TriangleMesh::from_stl ( stl_file & stl,
bool repair = true )
198{
199 if (repair)
201
202#if 0
203 m_stats.number_of_facets = stl.stats.number_of_facets;
204 m_stats.min = stl.stats.min;
205 m_stats.max = stl.stats.max;
206 m_stats.size = stl.stats.size;
207 m_stats.volume = stl.stats.volume;
208
209 auto facets_w_1_bad_edge = stl.stats.connected_facets_2_edge - stl.stats.connected_facets_3_edge;
210 auto facets_w_2_bad_edge = stl.stats.connected_facets_1_edge - stl.stats.connected_facets_2_edge;
211 auto facets_w_3_bad_edge = stl.stats.number_of_facets - stl.stats.connected_facets_1_edge;
212 m_stats.open_edges = stl.stats.backwards_edges + facets_w_1_bad_edge + facets_w_2_bad_edge * 2 + facets_w_3_bad_edge * 3;
213
214 m_stats.repaired_errors = { stl.stats.edges_fixed,
215 stl.stats.degenerate_facets,
216 stl.stats.facets_removed,
217 stl.stats.facets_reversed,
218 stl.stats.backwards_edges };
219
220 m_stats.number_of_parts = stl.stats.number_of_parts;
221#endif
222
223 stl_generate_shared_vertices(&stl, this->its);
224 fill_initial_stats(this->its, this->m_stats);
225 return true;
226}
static void trianglemesh_repair_on_import(stl_file &stl)
Definition TriangleMesh.cpp:95

References Slic3r::fill_initial_stats(), its, m_stats, and Slic3r::trianglemesh_repair_on_import().

Referenced by Slic3r::load_svg(), Slic3r::Step::mesh(), ReadSTLFile(), and Slic3r::GeometryEngine::tessellate().

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

◆ get_init_shift()

Vec3d Slic3r::TriangleMesh::get_init_shift ( ) const
inline
162{ return m_init_shift; }
Vec3d m_init_shift
Definition TriangleMesh.hpp:168

References m_init_shift.

Referenced by Slic3r::_BBS_3MF_Importer::_generate_volumes_new(), Slic3r::GUI::Plater::priv::reload_from_disk(), and Slic3r::GUI::Plater::priv::replace_volume_with_stl().

Here is the caller graph for this function:

◆ horizontal_projection()

ExPolygons Slic3r::TriangleMesh::horizontal_projection ( ) const
431{
432 return union_ex(project_mesh(this->its, Transform3d::Identity(), []() {}));
433}
void project_mesh(const indexed_triangle_set &mesh, const Transform3d &trafo, Polygons *out_top, Polygons *out_bottom, std::function< void()> throw_on_cancel)
Definition TriangleMeshSlicer.cpp:2435
Slic3r::ExPolygons union_ex(const Slic3r::Polygons &subject, PolyFillType fill_type)
Definition ClipperUtils.cpp:1011

References its, Slic3r::project_mesh(), and Slic3r::union_ex().

Referenced by Slic3r::GUI::BedShapePanel::load_stl().

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

◆ is_splittable()

bool Slic3r::TriangleMesh::is_splittable ( ) const

Calculates whether or not the mesh is splittable.

402{
403 return its_is_splittable(this->its);
404}
bool its_is_splittable(const Its &m)
Definition MeshSplitImpl.hpp:203

References its, and Slic3r::its_is_splittable().

Here is the call graph for this function:

◆ memsize()

size_t Slic3r::TriangleMesh::memsize ( ) const
531{
532 size_t memsize = 8 + this->its.memsize() + sizeof(this->m_stats);
533 return memsize;
534}
size_t memsize() const
Definition TriangleMesh.cpp:530

References its, m_stats, and memsize().

Referenced by memsize().

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

◆ merge()

void Slic3r::TriangleMesh::merge ( const TriangleMesh & mesh)
423{
424 its_merge(this->its, mesh.its);
425 m_stats = m_stats.merge(mesh.m_stats);
426}
void its_merge(indexed_triangle_set &A, const indexed_triangle_set &B)
Definition TriangleMesh.cpp:1448

References TriangleMesh(), its, Slic3r::its_merge(), and m_stats.

Referenced by Slic3r::GUI::PartPlate::calc_imex_ghosts(), Slic3r::GUI::Plater::combine_mesh_fff(), Slic3r::sla::cut_drainholes(), Slic3r::FaceDetector::detect_exterior_face(), Slic3r::GUI::ensure_belt_purge_tower(), Slic3r::GUI::Plater::export_stl(), Slic3r::GUI::DesignPanel::ghost_from_bodies(), Slic3r::sla::hollow_mesh(), Slic3r::lay_on_face_planes(), Slic3r::GLVolumeCollection::load_wipe_tower_preview(), and Slic3r::merge_solid_parts_inside_object().

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

◆ mirror()

void Slic3r::TriangleMesh::mirror ( const Axis axis)
328{
329 switch (axis) {
330 case X:
331 for (stl_vertex &v : its.vertices)
332 v.x() *= -1.f;
333 break;
334 case Y:
335 for (stl_vertex& v : this->its.vertices)
336 v.y() *= -1.0;
337 break;
338 case Z:
339 for (stl_vertex &v : this->its.vertices)
340 v.z() *= -1.0;
341 break;
342 default:
343 assert(false);
344 return;
345 };
346 its_flip_triangles(this->its);
347 int iaxis = int(axis);
348 std::swap(m_stats.min[iaxis], m_stats.max[iaxis]);
349 m_stats.min[iaxis] *= -1.0;
350 m_stats.max[iaxis] *= -1.0;
351}
@ Y
Definition libslic3r.h:142
@ Z
Definition libslic3r.h:143
@ X
Definition libslic3r.h:141

References its, Slic3r::its_flip_triangles(), m_stats, Slic3r::X, Slic3r::Y, and Slic3r::Z.

Referenced by mirror_x(), mirror_y(), and mirror_z().

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

◆ mirror_x()

void Slic3r::TriangleMesh::mirror_x ( )
inline
118{ this->mirror(X); }
void mirror(const Axis axis)
Definition TriangleMesh.cpp:327

References mirror(), and Slic3r::X.

Here is the call graph for this function:

◆ mirror_y()

void Slic3r::TriangleMesh::mirror_y ( )
inline
119{ this->mirror(Y); }

References mirror(), and Slic3r::Y.

Here is the call graph for this function:

◆ mirror_z()

void Slic3r::TriangleMesh::mirror_z ( )
inline
120{ this->mirror(Z); }

References mirror(), and Slic3r::Z.

Here is the call graph for this function:

◆ ReadSTLFile()

bool Slic3r::TriangleMesh::ReadSTLFile ( const char * input_file,
bool repair = true,
ImportstlProgressFn stlFn = nullptr,
int custom_header_length = 80 )
229{
230 stl_file stl;
231 if (!stl_open(&stl, input_file, stlFn, custom_header_length))
232 return false;
233 return from_stl(stl, repair);
234}
bool from_stl(stl_file &stl, bool repair=true)
Definition TriangleMesh.cpp:197

References from_stl().

Referenced by construct_assemble_list(), Slic3r::GUI::anonymous_namespace{McpControl.cpp}::import_mesh(), Slic3r::load_stl(), and Slic3r::GUI::DesignPanel::on_import_mesh().

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

◆ release_optional()

size_t Slic3r::TriangleMesh::release_optional ( )
inline
155{ return 0; }

◆ repaired()

bool Slic3r::TriangleMesh::repaired ( ) const

◆ restore_optional()

void Slic3r::TriangleMesh::restore_optional ( )
inline
157{}

◆ rotate() [1/3]

void Slic3r::TriangleMesh::rotate ( double angle,
Point * center )
389{
390 if (angle != 0.) {
391 Vec2f c = center->cast<float>();
392 this->translate(-c(0), -c(1), 0);
393 its_rotate_z(this->its, (float)angle);
394 this->translate(c(0), c(1), 0);
395 }
396}
Vec3d center() const
Return the center of the related bounding box.
Definition TriangleMesh.hpp:140
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64

References Slic3r::angle(), center(), its, and translate().

Here is the call graph for this function:

◆ rotate() [2/3]

void Slic3r::TriangleMesh::rotate ( float angle,
const Axis & axis )
303{
304 if (angle != 0.f) {
306 switch (axis) {
307 case X: its_rotate_x(this->its, angle); break;
308 case Y: its_rotate_y(this->its, angle); break;
309 case Z: its_rotate_z(this->its, angle); break;
310 default: assert(false); return;
311 }
312 update_bounding_box(this->its, this->m_stats);
313 }
314}
T rad2deg(T angle)
Definition Geometry.hpp:310
static void update_bounding_box(const indexed_triangle_set &its, TriangleMeshStats &out)
Definition TriangleMesh.cpp:53

References Slic3r::angle(), its, m_stats, Slic3r::Geometry::rad2deg(), Slic3r::update_bounding_box(), Slic3r::X, Slic3r::Y, and Slic3r::Z.

Referenced by Slic3r::orientation::orient_for_cooling(), rotate_x(), rotate_y(), and rotate_z().

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

◆ rotate() [3/3]

void Slic3r::TriangleMesh::rotate ( float angle,
const Vec3d & axis )
317{
318 if (angle != 0.f) {
319 Vec3d axis_norm = axis.normalized();
320 Transform3d m = Transform3d::Identity();
321 m.rotate(Eigen::AngleAxisd(angle, axis_norm));
322 its_transform(its, m);
323 update_bounding_box(this->its, this->m_stats);
324 }
325}
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96

References Slic3r::angle(), its, m_stats, and Slic3r::update_bounding_box().

Here is the call graph for this function:

◆ rotate_x()

void Slic3r::TriangleMesh::rotate_x ( float angle)
inline
114{ this->rotate(angle, X); }
void rotate(float angle, const Axis &axis)
Definition TriangleMesh.cpp:302

References Slic3r::angle(), rotate(), and Slic3r::X.

Referenced by Slic3r::orientation::AutoOrienter::find_cooling_direction2().

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

◆ rotate_y()

void Slic3r::TriangleMesh::rotate_y ( float angle)
inline
115{ this->rotate(angle, Y); }

References Slic3r::angle(), rotate(), and Slic3r::Y.

Referenced by Slic3r::orientation::AutoOrienter::find_cooling_direction2().

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

◆ rotate_z()

void Slic3r::TriangleMesh::rotate_z ( float angle)
inline
116{ this->rotate(angle, Z); }

References Slic3r::angle(), rotate(), and Slic3r::Z.

Referenced by Slic3r::orientation::AutoOrienter::find_cooling_direction2().

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

◆ scale() [1/2]

void Slic3r::TriangleMesh::scale ( const Vec3f & versor)
264{
265 // Scale extents.
266 auto s = versor.array();
267 m_stats.min.array() *= s;
268 m_stats.max.array() *= s;
269 // Scale size.
270 m_stats.size.array() *= s;
271 // Scale volume.
272 if (m_stats.volume > 0.0)
273 m_stats.volume *= s(0) * s(1) * s(2);
274 if (versor.x() == versor.y() && versor.x() == versor.z()) {
275 float s = versor.x();
276 for (stl_vertex &v : this->its.vertices)
277 v *= s;
278 } else {
279 for (stl_vertex &v : this->its.vertices) {
280 v.x() *= versor.x();
281 v.y() *= versor.y();
282 v.z() *= versor.z();
283 }
284 }
285}

References its, and m_stats.

◆ scale() [2/2]

void Slic3r::TriangleMesh::scale ( float factor)
259{
260 this->scale(Vec3f(factor, factor, factor));
261}
void scale(float factor)
Definition TriangleMesh.cpp:258
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65

References scale().

Referenced by scale(), and Slic3r::ModelVolume::scale_geometry_after_creation().

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

◆ set_init_shift()

void Slic3r::TriangleMesh::set_init_shift ( const Vec3d & offset)
inline
161{ m_init_shift = offset; }
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References m_init_shift, and Slic3r::offset().

Referenced by Slic3r::apply_painted_mesh_to_volume(), and Slic3r::ModelVolume::center_geometry_after_creation().

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

◆ size()

Vec3d Slic3r::TriangleMesh::size ( ) const
inline
138{ return m_stats.size.cast<double>(); }

References m_stats.

◆ slice()

std::vector< ExPolygons > Slic3r::TriangleMesh::slice ( const std::vector< double > & z) const
524{
525 // convert doubles to floats
526 std::vector<float> z_f(z.begin(), z.end());
527 return slice_mesh_ex(this->its, z_f, 0.0004f);
528}
std::vector< ExPolygons > slice_mesh_ex(const indexed_triangle_set &mesh, const std::vector< float > &zs, const MeshSlicingParamsEx &params, std::function< void()> throw_on_cancel)
Definition TriangleMeshSlicer.cpp:2142

References its, and Slic3r::slice_mesh_ex().

Here is the call graph for this function:

◆ split()

std::vector< TriangleMesh > Slic3r::TriangleMesh::split ( ) const
407{
408 std::vector<indexed_triangle_set> itss = its_split(this->its);
409 std::vector<TriangleMesh> out;
410 out.reserve(itss.size());
411 for (indexed_triangle_set &m : itss) {
412 // The TriangleMesh constructor shall fill in the mesh statistics including volume.
413 out.emplace_back(std::move(m));
414 if (TriangleMesh &triangle_mesh = out.back(); triangle_mesh.volume() < 0)
415 // Some source mesh parts may be incorrectly oriented. Correct them.
416 triangle_mesh.flip_triangles();
417
418 }
419 return out;
420}
void its_split(const Its &m, OutputIt out_it)
Definition MeshSplitImpl.hpp:143

References TriangleMesh(), its, and Slic3r::its_split().

Referenced by Slic3r::ModelObject::split(), and Slic3r::ModelVolume::split().

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

◆ stats()

◆ transform() [1/2]

void Slic3r::TriangleMesh::transform ( const Matrix3d & t,
bool fix_left_handed = false )
366{
367 its_transform(its, m);
368 double det = m.block(0, 0, 3, 3).determinant();
369 if (fix_left_handed && det < 0.) {
371 det = -det;
372 }
373 m_stats.volume *= det;
374 update_bounding_box(this->its, this->m_stats);
375}

References its, Slic3r::its_flip_triangles(), m_stats, and Slic3r::update_bounding_box().

Here is the call graph for this function:

◆ transform() [2/2]

void Slic3r::TriangleMesh::transform ( const Transform3d & t,
bool fix_left_handed = false )
354{
355 its_transform(its, t);
356 double det = t.matrix().block(0, 0, 3, 3).determinant();
357 if (fix_left_handed && det < 0.) {
359 det = -det;
360 }
361 m_stats.volume *= det;
362 update_bounding_box(this->its, this->m_stats);
363}

References its, Slic3r::its_flip_triangles(), m_stats, and Slic3r::update_bounding_box().

Referenced by Slic3r::_3MF_Importer::_generate_volumes(), Slic3r::GUI::ObjectList::boolean(), Slic3r::GUI::PartPlate::calc_imex_ghosts(), Slic3r::GUI::Plater::combine_mesh_fff(), Slic3r::PrintObject::contour_z(), Slic3r::FaceDetector::detect_exterior_face(), Slic3r::GUI::Plater::export_stl(), Slic3r::GUI::DesignPanel::ghost_from_bodies(), Slic3r::lay_on_face_planes(), Slic3r::GLVolumeCollection::load_object_auxiliary(), Slic3r::merge_solid_parts_inside_object(), Slic3r::ModelObject::merge_volumes(), Slic3r::GUI::GLGizmoMeshBoolean::on_render_input_window(), Slic3r::GUI::DesignPanel::place_on_face(), Slic3r::SlicingAdaptive::prepare(), Slic3r::process_volume_cut(), Slic3r::ModelObject::raw_mesh(), Slic3r::GUI::DesignPanel::rebuild_disp_meshes(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::TriangleSelector::remap_painting(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_height_range(), and Slic3r::ModelInstance::transform_mesh().

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

◆ transformed_bounding_box() [1/2]

BoundingBoxf3 Slic3r::TriangleMesh::transformed_bounding_box ( const Transform3d & trafo) const
457{
458 BoundingBoxf3 bbox;
459 for (const stl_vertex &v : this->its.vertices)
460 bbox.merge(trafo * v.cast<double>());
461 return bbox;
462}

References its, and Slic3r::BoundingBox3Base< PointType >::merge().

Referenced by Slic3r::ModelInstance::calc_print_volume_state(), Slic3r::distribute_modifiers_from_object(), Slic3r::process_modifier_cut(), Slic3r::CLI::run(), and Slic3r::GUI::Plater::show_object_info().

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

◆ transformed_bounding_box() [2/2]

BoundingBoxf3 Slic3r::TriangleMesh::transformed_bounding_box ( const Transform3d & trafo,
double world_min_z ) const
465{
466 // 1) Allocate transformed vertices with their position with respect to print bed surface.
467 std::vector<char> sides;
468 size_t num_above = 0;
469 Eigen::AlignedBox<float, 3> bbox;
470 Transform3f trafo = trafod.cast<float>();
471 sides.reserve(its.vertices.size());
472 for (const stl_vertex &v : this->its.vertices) {
473 const stl_vertex pt = trafo * v;
474 const int sign = pt.z() > world_min_z ? 1 : pt.z() < world_min_z ? -1 : 0;
475 sides.emplace_back(sign);
476 if (sign >= 0) {
477 // Vertex above or on print bed surface. Test whether it is inside the build volume.
478 ++ num_above;
479 bbox.extend(pt);
480 }
481 }
482
483 // 2) Calculate intersections of triangle edges with the build surface.
484 if (num_above < its.vertices.size()) {
485 // Not completely above the build surface and status may still change by testing edges intersecting the build platform.
486 for (const stl_triangle_vertex_indices &tri : its.indices) {
487 const int s[3] = { sides[tri(0)], sides[tri(1)], sides[tri(2)] };
488 if (std::min(s[0], std::min(s[1], s[2])) < 0 && std::max(s[0], std::max(s[1], s[2])) > 0) {
489 // Some edge of this triangle intersects the build platform. Calculate the intersection.
490 int iprev = 2;
491 for (int iedge = 0; iedge < 3; ++ iedge) {
492 if (s[iprev] * s[iedge] == -1) {
493 // edge intersects the build surface. Calculate intersection point.
494 const stl_vertex p1 = trafo * its.vertices[tri(iprev)];
495 const stl_vertex p2 = trafo * its.vertices[tri(iedge)];
496 // Edge crosses the z plane. Calculate intersection point with the plane.
497 const float t = (world_min_z - p1.z()) / (p2.z() - p1.z());
498 bbox.extend(Vec3f(p1.x() + (p2.x() - p1.x()) * t, p1.y() + (p2.y() - p1.y()) * t, world_min_z));
499 }
500 iprev = iedge;
501 }
502 }
503 }
504 }
505
506 BoundingBoxf3 out;
507 if (! bbox.isEmpty()) {
508 out.min = bbox.min().cast<double>();
509 out.max = bbox.max().cast<double>();
510 out.defined = true;
511 };
512 return out;
513}
Eigen::Transform< float, 3, Eigen::Affine, Eigen::DontAlign > Transform3f
Definition Point.hpp:95

References Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::defined, its, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, and Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min.

◆ translate() [1/2]

void Slic3r::TriangleMesh::translate ( const Vec3f & displacement)
288{
289 if (displacement.x() != 0.f || displacement.y() != 0.f || displacement.z() != 0.f) {
290 for (stl_vertex& v : this->its.vertices)
291 v += displacement;
292 m_stats.min += displacement;
293 m_stats.max += displacement;
294 }
295}

References its, and m_stats.

◆ translate() [2/2]

void Slic3r::TriangleMesh::translate ( float x,
float y,
float z )
298{
299 this->translate(Vec3f(x, y, z));
300}

References translate().

Referenced by align_to_origin(), Slic3r::apply_painted_mesh_to_volume(), Slic3r::ModelVolume::center_geometry_after_creation(), Slic3r::GUI::Plater::export_stl(), Slic3r::orientation::AutoOrienter::find_cooling_direction2(), Slic3r::GLVolumeCollection::load_wipe_tower_preview(), Slic3r::process_connector_cut(), rotate(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::slice_two_color_cube_and_export(), and translate().

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

◆ volume()

float Slic3r::TriangleMesh::volume ( )
247{
248 if (m_stats.volume == -1)
249 m_stats.volume = its_volume(this->its);
250 return m_stats.volume;
251}
float its_volume(const indexed_triangle_set &its)
Definition TriangleMesh.cpp:1479

References its, Slic3r::its_volume(), and m_stats.

Referenced by Slic3r::_3MF_Importer::_generate_volumes(), Slic3r::_BBS_3MF_Importer::_generate_volumes_new(), Slic3r::load_drc(), and Slic3r::load_obj().

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

◆ write_ascii()

bool Slic3r::TriangleMesh::write_ascii ( const char * output_file) const
237{
238 return its_write_stl_ascii(output_file, "", this->its);
239}
bool its_write_stl_ascii(const char *file, const char *label, const std::vector< stl_triangle_vertex_indices > &indices, const std::vector< stl_vertex > &vertices)
Definition TriangleMesh.cpp:1766

References its, and Slic3r::its_write_stl_ascii().

Referenced by Slic3r::store_stl().

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

◆ write_binary()

bool Slic3r::TriangleMesh::write_binary ( const char * output_file) const
242{
243 return its_write_stl_binary(output_file, "", this->its);
244}
bool its_write_stl_binary(const char *file, const char *label, const std::vector< stl_triangle_vertex_indices > &indices, const std::vector< stl_vertex > &vertices)
Definition TriangleMesh.cpp:1793

References its, and Slic3r::its_write_stl_binary().

Referenced by Slic3r::store_stl().

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

◆ WriteOBJFile()

void Slic3r::TriangleMesh::WriteOBJFile ( const char * output_file) const
254{
255 its_write_obj(this->its, output_file);
256}

References its.

Referenced by Slic3r::store_obj().

Here is the caller graph for this function:

Member Data Documentation

◆ its

indexed_triangle_set Slic3r::TriangleMesh::its

Referenced by TriangleMesh(), TriangleMesh(), TriangleMesh(), TriangleMesh(), Slic3r::_BBS_3MF_Exporter::_add_mesh_to_object_stream(), Slic3r::MeshBoolean::cgal::_mesh_boolean_do(), Slic3r::apply_painted_mesh_to_volume(), Slic3r::build_texture_displacement(), Slic3r::ModelInstance::calc_print_volume_state(), Slic3r::GUI::Camera::calc_zoom_to_volumes_factor(), clear(), Slic3r::GUI::GLGizmoTextureDisplacement::collect_paint_region(), convex_hull(), convex_hull_3d(), Slic3r::anonymous_namespace{bbs_3mf.cpp}::create_fix(), Slic3r::GUI::CameraUtils::create_hull2d(), anonymous_namespace{EmbossJob.cpp}::create_mesh(), anonymous_namespace{EmbossJob.cpp}::create_sources(), Slic3r::sla::cut_drainholes(), Slic3r::GUI::GLGizmoTextureDisplacement::cut_island(), Slic3r::FaceDetector::detect_exterior_face(), Slic3r::MeshBoolean::mcut::do_boolean(), Slic3r::MeshBoolean::cgal::does_self_intersect(), Slic3r::GUI::TextureDisplacementBakeJob::finalize(), Slic3r::orientation::AutoOrienter::find_cooling_direction2(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::find_ground_level(), Slic3r::sla::find_min_z_height_rotation(), Slic3r::GUI::GLGizmoBrimEars::first_layer_slicer(), flip_triangles(), from_stl(), Slic3r::sla::generate_interior_verbose(), Slic3r::SLAPrint::Steps::generate_pad(), Slic3r::GUI::Selection::get_bounding_box_in_reference_system(), Slic3r::GUI::Selection::get_bounding_sphere(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_chull_rotations(), Slic3r::ModelObject::get_instance_max_z(), Slic3r::ModelObject::get_instance_min_z(), Slic3r::csg::get_mesh(), Slic3r::csg::get_mesh(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_misalginment_score(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_supportedness_onfloor_score(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_supportedness_score(), Slic3r::sla::anonymous_namespace{Rotfinder.cpp}::get_triangle_vertices(), Slic3r::ModelVolume::has_texture_uv(), horizontal_projection(), Slic3r::GUI::anonymous_namespace{McpControl.cpp}::import_mesh(), Slic3r::GUI::GLModel::init_from(), Slic3r::PaintCLI::inspect_to_json(), Slic3r::ModelInstance::intersects_bed_exclude_region(), is_splittable(), Slic3r::WipeTower::its_make_rib_brim(), Slic3r::WipeTower::its_make_rib_tower(), Slic3r::lay_on_face_planes(), Slic3r::GUI::GLGizmoTextureDisplacement::layer_projection_frame(), cereal::load(), Slic3r::GLVolumeCollection::load_real_wipe_tower_preview(), main(), Slic3r::GUI::GLGizmoTextureDisplacement::mark_seam_path(), Slic3r::GUI::GLGizmoTextureDisplacement::masks_after_subdivision(), memsize(), merge(), Slic3r::MeshBoolean::mcut::merge_mcut_meshes(), mirror(), Slic3r::GUI::GLCanvas3D::CenterOfMass::model_markers(), Slic3r::csg::model_to_csgmesh(), Slic3r::GUI::GLGizmoTextureDisplacement::model_uv_corners(), Slic3r::GUI::DesignPanel::on_import_mesh(), Slic3r::orientation::orient_for_cooling(), Slic3r::GUI::GLGizmoTextureDisplacement::painted_area_mm2(), Slic3r::SlicingAdaptive::prepare(), Slic3r::GUI::GLGizmoTextureDisplacement::prepare_mesh(), Slic3r::CadDocument::preview(), Slic3r::process_volume_cut(), Slic3r::GUI::GLGizmoTextureDisplacement::queue_preview_job(), Slic3r::GUI::queue_texture_displacement_debug(), Slic3r::Model::read_from_file(), Slic3r::GUI::DesignCanvas::rebuild_bodies(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_island_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_other_paint_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_paint_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_painted_colors(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_seam_anchor_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_seam_hover_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_seam_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_subdivide_preview(), Slic3r::GUI::GLGizmoTextureDisplacement::rebuild_wireframe_overlay(), Slic3r::GUI::DesignPanel::refresh_preview(), Slic3r::TriangleSelector::remap_painting(), Slic3r::GUI::anonymous_namespace{GLGizmoTextureDisplacement.cpp}::remap_texture_paint_spatial(), Slic3r::sla::remove_inside_triangles(), Slic3r::repair_mesh(), rotate(), rotate(), rotate(), cereal::save(), scale(), Slic3r::GUI::GLGizmoTextureDisplacement::seam_edge_at(), Slic3r::GUI::GLGizmoTextureDisplacement::seam_vertex_at(), Slic3r::GUI::GLGizmoFdmSupports::select_facets_by_angle(), Slic3r::GUI::GLGizmoTextureDisplacement::select_visible_faces(), Slic3r::GUI::GLGizmoTextureDisplacement::select_whole_model(), Slic3r::GUI::DesignSketchTool::set_solid_pick(), slice(), Slic3r::SLAPrint::Steps::slice_model(), Slic3r::slice_volume(), Slic3r::GUI::GLGizmoTextureDisplacement::smooth_model(), Slic3r::TriangleMeshDeal::smooth_triangle_mesh(), split(), Slic3r::GUI::TextureImportDialog::start_computation(), Slic3r::store_drc(), Slic3r::GeometryEngine::surface_deviation(), Slic3r::tessellate_bodies(), Slic3r::GUI::texture_displacement_bake_volume(), transform(), transform(), transformed_bounding_box(), transformed_bounding_box(), translate(), Slic3r::MeshBoolean::cgal::triangle_mesh_to_cgal(), Slic3r::MeshBoolean::cgal::triangle_mesh_to_cgal(), Slic3r::MeshBoolean::triangle_mesh_to_eigen(), Slic3r::MeshBoolean::mcut::triangle_mesh_to_mcut(), Slic3r::GLVolume::SinkingContours::update(), Slic3r::GUI::GLGizmoTextureDisplacement::update_adjust_anchor(), Slic3r::GUI::GLGizmoTextureDisplacement::update_from_model_object(), Slic3r::GUI::GLGizmoTextureDisplacement::update_uv_editor(), Slic3r::GUI::GLGizmoTextureDisplacement::v2_recommendation(), volume(), write_ascii(), write_binary(), and WriteOBJFile().

◆ m_init_shift

Vec3d Slic3r::TriangleMesh::m_init_shift {0.0, 0.0, 0.0}
private
168{0.0, 0.0, 0.0};

Referenced by get_init_shift(), and set_init_shift().

◆ m_stats


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