OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GLVolume::SinkingContours Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.hpp>

Collaboration diagram for Slic3r::GLVolume::SinkingContours:

Public Member Functions

 SinkingContours (GLVolume &volume)
void render ()

Private Member Functions

void update ()

Private Attributes

GLVolume & m_parent
GUI::GLModel m_model
BoundingBoxf3 m_old_box
Vec3d m_shift { Vec3d::Zero() }

Static Private Attributes

static const float HalfWidth = 0.25f

Detailed Description

Constructor & Destructor Documentation

◆ SinkingContours()

Slic3r::GLVolume::SinkingContours::SinkingContours ( GLVolume & volume)
inline
159: m_parent(volume) {}
GLVolume & m_parent
Definition 3DScene.hpp:153

References Slic3r::GLVolume::GLVolume(), and m_parent.

Here is the call graph for this function:

Member Function Documentation

◆ render()

void Slic3r::GLVolume::SinkingContours::render ( )
131{
132 update();
133
134 GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
135 if (shader == nullptr)
136 return;
137
138 const GUI::Camera& camera = GUI::wxGetApp().plater()->get_camera();
139 shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::assemble_transform(m_shift));
140 shader->set_uniform("projection_matrix", camera.get_projection_matrix());
141 m_model.render();
142}
Vec3d m_shift
Definition 3DScene.hpp:156
void update()
Definition 3DScene.cpp:144
GUI::GLModel m_model
Definition 3DScene.hpp:154
@ Camera
Definition Shortcuts.hpp:72
void assemble_transform(Transform3d &transform, const Vec3d &translation, const Vec3d &rotation, const Vec3d &scale, const Vec3d &mirror)
Definition Geometry.cpp:319

References Slic3r::Geometry::assemble_transform(), Slic3r::GUI::Camera::get_projection_matrix(), Slic3r::GUI::Camera::get_view_matrix(), m_model, m_shift, Slic3r::GLShaderProgram::set_uniform(), and update().

Here is the call graph for this function:

◆ update()

void Slic3r::GLVolume::SinkingContours::update ( )
private
145{
146 const int object_idx = m_parent.object_idx();
147 const Model& model = GUI::wxGetApp().plater()->model();
148
149 if (0 <= object_idx && object_idx < int(model.objects.size()) && m_parent.is_sinking() && !m_parent.is_below_printbed()) {
150 const BoundingBoxf3& box = m_parent.transformed_convex_hull_bounding_box();
151 if (!m_old_box.size().isApprox(box.size()) || m_old_box.min.z() != box.min.z()) {
152 m_old_box = box;
153 m_shift = Vec3d::Zero();
154
155 const TriangleMesh& mesh = model.objects[object_idx]->volumes[m_parent.volume_idx()]->mesh();
156
157 m_model.reset();
158 GUI::GLModel::Geometry init_data;
160 init_data.color = ColorRGBA::WHITE();
161 unsigned int vertices_counter = 0;
162 MeshSlicingParams slicing_params;
163 slicing_params.trafo = m_parent.world_matrix();
164 const Polygons polygons = union_(slice_mesh(mesh.its, 0.0f, slicing_params));
165 for (const ExPolygon& expoly : diff_ex(expand(polygons, float(scale_(HalfWidth))), shrink(polygons, float(scale_(HalfWidth))))) {
166 const std::vector<Vec3d> triangulation = triangulate_expolygon_3d(expoly);
167 init_data.reserve_vertices(init_data.vertices_count() + triangulation.size());
168 init_data.reserve_indices(init_data.indices_count() + triangulation.size());
169 for (const Vec3d& v : triangulation) {
170 init_data.add_vertex((Vec3f)(v.cast<float>() + 0.015f * Vec3f::UnitZ())); // add a small positive z to avoid z-fighting
171 ++vertices_counter;
172 if (vertices_counter % 3 == 0)
173 init_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
174 }
175 }
176 m_model.init_from(std::move(init_data));
177 }
178 else
179 m_shift = box.center() - m_old_box.center();
180 }
181 else
182 m_model.reset();
183}
static const ColorRGBA WHITE()
Definition Color.hpp:142
BoundingBoxf3 m_old_box
Definition 3DScene.hpp:155
static const float HalfWidth
Definition 3DScene.hpp:152
GUI::GLModel model
Definition 3DScene.hpp:250
int object_idx() const
Definition 3DScene.hpp:344
#define scale_(val)
Definition libslic3r.h:106
Slic3r::Polygons union_(const Slic3r::Polygons &subject)
Definition ClipperUtils.cpp:801
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Slic3r::ExPolygons diff_ex(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:831
Slic3r::Polygons expand(const Slic3r::Polygon &polygon, const float delta, JoinType joinType=DefaultJoinType, double miterLimit=DefaultMiterLimit)
Definition ClipperUtils.hpp:397
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
std::vector< Vec3d > triangulate_expolygon_3d(const ExPolygon &poly, coordf_t z, bool flip)
Definition Tesselate.cpp:204
Slic3r::Polygons shrink(const Slic3r::Polygons &polygons, const float delta, JoinType joinType=DefaultJoinType, double miterLimit=DefaultMiterLimit)
Definition ClipperUtils.hpp:406
std::vector< Polygons > slice_mesh(const indexed_triangle_set &mesh, const std::vector< float > &zs, const MeshSlicingParams &params, std::function< void()> throw_on_cancel)
Definition TriangleMeshSlicer.cpp:1997

References Slic3r::GUI::GLModel::Geometry::add_triangle(), Slic3r::GUI::GLModel::Geometry::add_vertex(), Slic3r::BoundingBox3Base< PointType >::center(), Slic3r::GUI::GLModel::Geometry::color, Slic3r::diff_ex(), Slic3r::expand(), Slic3r::GUI::GLModel::Geometry::format, HalfWidth, Slic3r::GUI::GLModel::Geometry::indices_count(), Slic3r::TriangleMesh::its, m_model, m_old_box, m_parent, m_shift, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::GLVolume::model, Slic3r::GLVolume::object_idx(), Slic3r::GUI::GLModel::Geometry::P3, Slic3r::GUI::GLModel::Geometry::reserve_indices(), Slic3r::GUI::GLModel::Geometry::reserve_vertices(), scale_, Slic3r::shrink(), Slic3r::BoundingBox3Base< PointType >::size(), Slic3r::slice_mesh(), Slic3r::MeshSlicingParams::trafo, Slic3r::GUI::GLModel::Geometry::Triangles, Slic3r::triangulate_expolygon_3d(), Slic3r::union_(), Slic3r::GUI::GLModel::Geometry::vertices_count(), and Slic3r::ColorRGBA::WHITE().

Referenced by render().

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

Member Data Documentation

◆ HalfWidth

const float Slic3r::GLVolume::SinkingContours::HalfWidth = 0.25f
staticprivate

Referenced by update().

◆ m_model

GUI::GLModel Slic3r::GLVolume::SinkingContours::m_model
private

Referenced by render(), and update().

◆ m_old_box

BoundingBoxf3 Slic3r::GLVolume::SinkingContours::m_old_box
private

Referenced by update().

◆ m_parent

GLVolume& Slic3r::GLVolume::SinkingContours::m_parent
private

Referenced by SinkingContours(), and update().

◆ m_shift

Vec3d Slic3r::GLVolume::SinkingContours::m_shift { Vec3d::Zero() }
private
156{ Vec3d::Zero() };

Referenced by render(), and update().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.cpp