OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
3DScene.cpp File Reference
#include <array>
#include <algorithm>
#include <functional>
#include <cmath>
#include <glad/gl.h>
#include "3DScene.hpp"
#include "GLShader.hpp"
#include "GUI_App.hpp"
#include "GUI_Colors.hpp"
#include "Plater.hpp"
#include "BitmapCache.hpp"
#include "Camera.hpp"
#include "libslic3r/BuildVolume.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/Print.hpp"
#include "libslic3r/SLAPrint.hpp"
#include "libslic3r/Slicing.hpp"
#include "libslic3r/Format/STL.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/GCode/WipeTower.hpp"
#include "libslic3r/GCode/WipeTowerEstimate.hpp"
#include "libslic3r/Tesselate.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/TriangleMeshSlicer.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Technologies.hpp"
#include <optional>
#include "slic3r/GUI/OpenGLManager.hpp"
#include "libslic3r/Config.hpp"
#include <memory>
#include "slic3r/GUI/MeshUtils.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <math.h>
#include "libslic3r/ObjectID.hpp"
#include "libslic3r/libslic3r.h"
#include <map>
#include <set>
#include <iterator>
#include "libslic3r/Color.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "libslic3r/Line.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/Exception.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <boost/log/trivial.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <Eigen/Dense>
#include <vector>
#include <utility>
#include <string>

Go to the source code of this file.

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/

Functions

void glAssertRecentCallImpl (const char *file_name, unsigned int line, const char *function_name)
Slic3r::ColorRGBA adjust_color_for_rendering (const Slic3r::ColorRGBA &colors)
ColorRGBA Slic3r::color_from_model_volume (const ModelVolume &model_volume)
GLVolumeWithIdAndZList Slic3r::volumes_to_render (const GLVolumePtrs &volumes, GLVolumeCollection::ERenderType type, const Transform3d &view_matrix, std::function< bool(const GLVolume &)> filter_func)
static void Slic3r::thick_lines_to_geometry (const Lines &lines, const std::vector< double > &widths, const std::vector< double > &heights, bool closed, double top_z, GUI::GLModel::Geometry &geometry)
static void Slic3r::thick_lines_to_geometry (const Lines3 &lines, const std::vector< double > &widths, const std::vector< double > &heights, bool closed, GUI::GLModel::Geometry &geometry)

Variables

float FullyTransparentMaterialThreshold = 0.1f
float FullTransparentModdifiedToFixAlpha = 0.3f
float FULL_BLACK_THRESHOLD = 0.2f
static constexpr int OUTLINE_DEPTH_TEX_UNIT = 5

Function Documentation

◆ adjust_color_for_rendering()

Slic3r::ColorRGBA adjust_color_for_rendering ( const Slic3r::ColorRGBA & colors)
113{
114 // a clear color keeps its hue, at the least opacity that still shows it
115 const float alpha = std::max(colors.a(), FullyTransparentMaterialThreshold);
116 if (colors.r() < FULL_BLACK_THRESHOLD && colors.g() < FULL_BLACK_THRESHOLD && colors.b() < FULL_BLACK_THRESHOLD) {
117 // black, lifted so that the shading shows, the more the more translucent: a dark translucent
118 // surface shows nothing through itself
119 const float grey = FULL_BLACK_THRESHOLD + 0.3f * (1.0f - alpha);
120 return {grey, grey, grey, alpha};
121 }
122 return {colors.r(), colors.g(), colors.b(), alpha};
123}
float FULL_BLACK_THRESHOLD
Definition 3DScene.cpp:107
float FullyTransparentMaterialThreshold
Definition 3DScene.cpp:101
float a() const
Definition Color.hpp:108
float b() const
Definition Color.hpp:107
float r() const
Definition Color.hpp:105
float g() const
Definition Color.hpp:106

References Slic3r::ColorRGBA::a(), Slic3r::ColorRGBA::b(), FULL_BLACK_THRESHOLD, FullyTransparentMaterialThreshold, Slic3r::ColorRGBA::g(), and Slic3r::ColorRGBA::r().

Referenced by Slic3r::GUI::SelectMachineDialog::adjust_color_for_render(), Slic3r::GUI::SyncAmsInfoDialog::adjust_color_for_render(), libvgcode::convert_filament_colors(), Slic3r::GLWipeTowerVolume::render(), Slic3r::GUI::TriangleSelectorPatch::render(), Slic3r::GUI::GCodeViewer::render_all_plates_stats(), Slic3r::GUI::GLGizmoTextureDisplacement::render_painted_colors(), Slic3r::GUI::GLCanvas3D::render_thumbnail_internal(), Slic3r::GLVolume::set_render_color(), and Slic3r::GLVolume::simple_render().

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

◆ glAssertRecentCallImpl()

void glAssertRecentCallImpl ( const char * file_name,
unsigned int line,
const char * function_name )
75{
76#if defined(NDEBUG)
77 // In release mode, only show OpenGL errors if sufficiently high loglevel.
79 return;
80#endif // NDEBUG
81
82 GLenum err = glGetError();
83 if (err == GL_NO_ERROR)
84 return;
85 const char* sErr = 0;
86 switch (err) {
87 case GL_INVALID_ENUM: sErr = "Invalid Enum"; break;
88 case GL_INVALID_VALUE: sErr = "Invalid Value"; break;
89 // be aware that GL_INVALID_OPERATION is generated if glGetError is executed between the execution of glBegin and the corresponding execution of glEnd
90 case GL_INVALID_OPERATION: sErr = "Invalid Operation"; break;
91 case GL_STACK_OVERFLOW: sErr = "Stack Overflow"; break;
92 case GL_STACK_UNDERFLOW: sErr = "Stack Underflow"; break;
93 case GL_OUT_OF_MEMORY: sErr = "Out Of Memory"; break;
94 default: sErr = "Unknown"; break;
95 }
96 BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
97 assert(false);
98}
#define GL_INVALID_VALUE
Definition gl.h:904
#define glGetError
Definition gl.h:3849
#define GL_INVALID_OPERATION
Definition gl.h:903
#define GL_STACK_OVERFLOW
Definition gl.h:1630
unsigned int GLenum
Definition gl.h:2054
#define GL_NO_ERROR
Definition gl.h:1217
#define GL_OUT_OF_MEMORY
Definition gl.h:1251
#define GL_INVALID_ENUM
Definition gl.h:899
#define GL_STACK_UNDERFLOW
Definition gl.h:1631
unsigned get_logging_level()
Definition utils.cpp:221

References Slic3r::get_logging_level(), GL_INVALID_ENUM, GL_INVALID_OPERATION, GL_INVALID_VALUE, GL_NO_ERROR, GL_OUT_OF_MEMORY, GL_STACK_OVERFLOW, GL_STACK_UNDERFLOW, and glGetError.

Referenced by glAssertRecentCall().

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

Variable Documentation

◆ FULL_BLACK_THRESHOLD

float FULL_BLACK_THRESHOLD = 0.2f

◆ FullTransparentModdifiedToFixAlpha

float FullTransparentModdifiedToFixAlpha = 0.3f

◆ FullyTransparentMaterialThreshold

float FullyTransparentMaterialThreshold = 0.1f

◆ OUTLINE_DEPTH_TEX_UNIT

int OUTLINE_DEPTH_TEX_UNIT = 5
staticconstexpr