OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GLMmSegmentationGizmo3DScene Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp>

Collaboration diagram for Slic3r::GUI::GLMmSegmentationGizmo3DScene:

Public Member Functions

 GLMmSegmentationGizmo3DScene ()=delete
 GLMmSegmentationGizmo3DScene (size_t triangle_indices_buffers_count)
virtual ~GLMmSegmentationGizmo3DScene ()
bool has_VBOs (size_t triangle_indices_idx) const
void release_geometry ()
void finalize_vertices ()
void finalize_triangle_indices ()
void clear ()
void render (size_t triangle_indices_idx) const

Public Attributes

std::vector< float > vertices
std::vector< TrianglePatch > triangle_patches
std::vector< size_t > triangle_indices_sizes
unsigned int vertices_VAO_id { 0 }
unsigned int vertices_VBO_id {0}
std::vector< unsigned int > triangle_indices_VBO_ids

Detailed Description

Constructor & Destructor Documentation

◆ GLMmSegmentationGizmo3DScene() [1/2]

Slic3r::GUI::GLMmSegmentationGizmo3DScene::GLMmSegmentationGizmo3DScene ( )
delete

◆ GLMmSegmentationGizmo3DScene() [2/2]

Slic3r::GUI::GLMmSegmentationGizmo3DScene::GLMmSegmentationGizmo3DScene ( size_t triangle_indices_buffers_count)
inlineexplicit
27 {
28 }

◆ ~GLMmSegmentationGizmo3DScene()

virtual Slic3r::GUI::GLMmSegmentationGizmo3DScene::~GLMmSegmentationGizmo3DScene ( )
inlinevirtual
void release_geometry()
Definition GLGizmoMmuSegmentation.cpp:845

References release_geometry().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void Slic3r::GUI::GLMmSegmentationGizmo3DScene::clear ( )
inline
48 {
49 this->vertices.clear();
50 // BBS
51 this->triangle_indices_VBO_ids.clear();
52 this->triangle_indices_sizes.clear();
53
54 for (TrianglePatch& patch : this->triangle_patches)
55 patch.triangle_indices.clear();
56 this->triangle_patches.clear();
57 }
std::vector< float > vertices
Definition GLGizmoMmuSegmentation.hpp:61
std::vector< TrianglePatch > triangle_patches
Definition GLGizmoMmuSegmentation.hpp:65
std::vector< size_t > triangle_indices_sizes
Definition GLGizmoMmuSegmentation.hpp:69
std::vector< unsigned int > triangle_indices_VBO_ids
Definition GLGizmoMmuSegmentation.hpp:75

References triangle_indices_sizes, triangle_indices_VBO_ids, triangle_patches, and vertices.

Referenced by release_geometry().

Here is the caller graph for this function:

◆ finalize_triangle_indices()

void Slic3r::GUI::GLMmSegmentationGizmo3DScene::finalize_triangle_indices ( )
959{
960 triangle_indices_VBO_ids.resize(this->triangle_patches.size());
961 triangle_indices_sizes.resize(this->triangle_patches.size());
962 assert(std::all_of(triangle_indices_VBO_ids.cbegin(), triangle_indices_VBO_ids.cend(), [](const auto &ti_VBO_id) { return ti_VBO_id == 0; }));
963
964 for (size_t buffer_idx = 0; buffer_idx < this->triangle_patches.size(); ++buffer_idx) {
965 std::vector<int>& triangle_indices = this->triangle_patches[buffer_idx].triangle_indices;
966 triangle_indices_sizes[buffer_idx] = triangle_indices.size();
967 if (!triangle_indices.empty()) {
968 glsafe(::glGenBuffers(1, &this->triangle_indices_VBO_ids[buffer_idx]));
970 glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, triangle_indices.size() * sizeof(int), triangle_indices.data(), GL_STATIC_DRAW));
972 triangle_indices.clear();
973 }
974 }
975}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
#define glGenBuffers
Definition gl.h:3769
#define glBindBuffer
Definition gl.h:3267
#define glBufferData
Definition gl.h:3339
#define GL_STATIC_DRAW
Definition gl.h:1633
#define GL_ELEMENT_ARRAY_BUFFER
Definition gl.h:636

References GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW, glBindBuffer, glBufferData, glGenBuffers, glsafe, triangle_indices_sizes, triangle_indices_VBO_ids, and triangle_patches.

◆ finalize_vertices()

void Slic3r::GUI::GLMmSegmentationGizmo3DScene::finalize_vertices ( )
923{
924#if !SLIC3R_OPENGL_ES
925 if (OpenGLManager::get_gl_info().is_core_profile()) {
926#endif // !SLIC3R_OPENGL_ES
927 assert(this->vertices_VAO_id == 0);
928#if !SLIC3R_OPENGL_ES
929 }
930#endif // !SLIC3R_OPENGL_ES
931 assert(this->vertices_VBO_id == 0);
932 if (!this->vertices.empty()) {
933#if !SLIC3R_OPENGL_ES
934 if (OpenGLManager::get_gl_info().is_core_profile()) {
935#endif // !SLIC3R_OPENGL_ES
938#if !SLIC3R_OPENGL_ES
939 }
940#endif // !SLIC3R_OPENGL_ES
941
944 glsafe(::glBufferData(GL_ARRAY_BUFFER, this->vertices.size() * sizeof(float), this->vertices.data(), GL_STATIC_DRAW));
946 this->vertices.clear();
947
948#if !SLIC3R_OPENGL_ES
949 if (OpenGLManager::get_gl_info().is_core_profile()) {
950#endif // !SLIC3R_OPENGL_ES
952#if !SLIC3R_OPENGL_ES
953 }
954#endif // !SLIC3R_OPENGL_ES
955 }
956}
unsigned int vertices_VAO_id
Definition GLGizmoMmuSegmentation.hpp:73
unsigned int vertices_VBO_id
Definition GLGizmoMmuSegmentation.hpp:74
static const GLInfo & get_gl_info()
Definition OpenGLManager.hpp:106
#define glBindVertexArray
Definition gl.h:3307
#define GL_ARRAY_BUFFER
Definition gl.h:238
#define glGenVertexArrays
Definition gl.h:3791

References Slic3r::GUI::OpenGLManager::get_gl_info(), GL_ARRAY_BUFFER, GL_STATIC_DRAW, glBindBuffer, glBindVertexArray, glBufferData, glGenBuffers, glGenVertexArrays, glsafe, vertices, vertices_VAO_id, and vertices_VBO_id.

Here is the call graph for this function:

◆ has_VBOs()

bool Slic3r::GUI::GLMmSegmentationGizmo3DScene::has_VBOs ( size_t triangle_indices_idx) const
inlinenodiscard
33 {
34 assert(triangle_indices_idx < this->triangle_patches.size());
35 return this->triangle_indices_VBO_ids[triangle_indices_idx] != 0;
36 }

References triangle_indices_VBO_ids, and triangle_patches.

◆ release_geometry()

void Slic3r::GUI::GLMmSegmentationGizmo3DScene::release_geometry ( )
845 {
846 if (this->vertices_VBO_id) {
848 this->vertices_VBO_id = 0;
849 }
850 for(auto &triangle_indices_VBO_id : triangle_indices_VBO_ids) {
851 glsafe(::glDeleteBuffers(1, &triangle_indices_VBO_id));
852 triangle_indices_VBO_id = 0;
853 }
854#if !SLIC3R_OPENGL_ES
855 if (OpenGLManager::get_gl_info().is_core_profile()) {
856#endif // !SLIC3R_OPENGL_ES
857 if (this->vertices_VAO_id > 0) {
859 this->vertices_VAO_id = 0;
860 }
861#if !SLIC3R_OPENGL_ES
862 }
863#endif // !SLIC3R_OPENGL_ES
864
865 this->clear();
866}
void clear()
Definition GLGizmoMmuSegmentation.hpp:47
#define glDeleteVertexArrays
Definition gl.h:3591
#define glDeleteBuffers
Definition gl.h:3563

References clear(), Slic3r::GUI::OpenGLManager::get_gl_info(), glDeleteBuffers, glDeleteVertexArrays, glsafe, triangle_indices_VBO_ids, vertices_VAO_id, and vertices_VBO_id.

Referenced by ~GLMmSegmentationGizmo3DScene().

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

◆ render()

void Slic3r::GUI::GLMmSegmentationGizmo3DScene::render ( size_t triangle_indices_idx) const
869{
870 assert(triangle_indices_idx < this->triangle_indices_VBO_ids.size());
871 assert(this->triangle_patches.size() == this->triangle_indices_VBO_ids.size());
872#if !SLIC3R_OPENGL_ES
873 if (OpenGLManager::get_gl_info().is_core_profile()) {
874#endif // !SLIC3R_OPENGL_ES
875 assert(this->vertices_VAO_id != 0);
876#if !SLIC3R_OPENGL_ES
877 }
878#endif // !SLIC3R_OPENGL_ES
879 assert(this->vertices_VBO_id != 0);
880 assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0);
881
882 GLShaderProgram* shader = wxGetApp().get_current_shader();
883 if (shader == nullptr)
884 return;
885
886#if !SLIC3R_OPENGL_ES
887 if (OpenGLManager::get_gl_info().is_core_profile()) {
888#endif // !SLIC3R_OPENGL_ES
890#if !SLIC3R_OPENGL_ES
891 }
892#endif // !SLIC3R_OPENGL_ES
893 // the following binding is needed to set the vertex attributes
895 const GLint position_id = shader->get_attrib_location("v_position");
896 if (position_id != -1) {
897 glsafe(::glVertexAttribPointer(position_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (GLvoid*)0));
899 }
900
901 // Render using the Vertex Buffer Objects.
902 if (this->triangle_indices_VBO_ids[triangle_indices_idx] != 0 &&
903 this->triangle_indices_sizes[triangle_indices_idx] > 0) {
905 glsafe(::glDrawElements(GL_TRIANGLES, GLsizei(this->triangle_indices_sizes[triangle_indices_idx]), GL_UNSIGNED_INT, nullptr));
907 }
908
909 if (position_id != -1)
911
913#if !SLIC3R_OPENGL_ES
914 if (OpenGLManager::get_gl_info().is_core_profile()) {
915#endif // !SLIC3R_OPENGL_ES
917#if !SLIC3R_OPENGL_ES
918 }
919#endif // !SLIC3R_OPENGL_ES
920}
#define glDisableVertexAttribArray
Definition gl.h:3613
void GLvoid
Definition gl.h:2057
int GLint
Definition gl.h:2062
#define GL_TRIANGLES
Definition gl.h:1887
#define GL_UNSIGNED_INT
Definition gl.h:1940
#define GL_FLOAT
Definition gl.h:660
#define glEnableVertexAttribArray
Definition gl.h:3673
#define glDrawElements
Definition gl.h:3633
#define glVertexAttribPointer
Definition gl.h:5315
int GLsizei
Definition gl.h:2065
#define GL_FALSE
Definition gl.h:648

References Slic3r::GLShaderProgram::get_attrib_location(), Slic3r::GUI::OpenGLManager::get_gl_info(), GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_FALSE, GL_FLOAT, GL_TRIANGLES, GL_UNSIGNED_INT, glBindBuffer, glBindVertexArray, glDisableVertexAttribArray, glDrawElements, glEnableVertexAttribArray, glsafe, glVertexAttribPointer, triangle_indices_sizes, triangle_indices_VBO_ids, triangle_patches, vertices_VAO_id, and vertices_VBO_id.

Here is the call graph for this function:

Member Data Documentation

◆ triangle_indices_sizes

std::vector<size_t> Slic3r::GUI::GLMmSegmentationGizmo3DScene::triangle_indices_sizes

◆ triangle_indices_VBO_ids

std::vector<unsigned int> Slic3r::GUI::GLMmSegmentationGizmo3DScene::triangle_indices_VBO_ids

◆ triangle_patches

std::vector<TrianglePatch> Slic3r::GUI::GLMmSegmentationGizmo3DScene::triangle_patches

◆ vertices

std::vector<float> Slic3r::GUI::GLMmSegmentationGizmo3DScene::vertices

Referenced by clear(), and finalize_vertices().

◆ vertices_VAO_id

unsigned int Slic3r::GUI::GLMmSegmentationGizmo3DScene::vertices_VAO_id { 0 }
73{ 0 };

Referenced by finalize_vertices(), release_geometry(), and render().

◆ vertices_VBO_id

unsigned int Slic3r::GUI::GLMmSegmentationGizmo3DScene::vertices_VBO_id {0}
74{0};

Referenced by finalize_vertices(), release_geometry(), and render().


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