OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
TextureToColor.cpp File Reference
#include "TextureToColor.hpp"
#include <string>
#include <cstddef>
#include <limits>
#include <opencv2/core/mat.hpp>
#include <algorithm>
#include <memory>
#include <ratio>
#include <tbb/parallel_for.h>
#include <array>
#include <atomic>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <functional>
#include <boost/next_prior.hpp>
#include "Callbacks.hpp"
#include "CgalUtils.hpp"
#include "ColorUtils.hpp"
#include "TriMesh.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <filesystem>
#include <fstream>
#include "Repair.hpp"
#include "libslic3r/AABBTreeIndirect.hpp"
#include <boost/log/trivial.hpp>
#include <vector>
#include <utility>
#include <unordered_map>
Include dependency graph for TextureToColor.cpp:

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 |/
namespace  Slic3r::tex2color

Typedefs

using Slic3r::tex2color::FaceUVArray = std::array<Vec2f, 3>
using Slic3r::tex2color::VertexColor = std::array<float, 4>

Functions

static void Slic3r::tex2color::SaveToOFF (const std::string &path, const TriMesh &mesh, const std::vector< RGB > &face_colors)
static std::vector< std::size_t > Slic3r::tex2color::count_cluster_label_usage (const std::vector< std::size_t > &face_labels, std::size_t cluster_count)
static bool Slic3r::tex2color::discard_unused_cluster_centers (std::vector< RGB > &cluster_centers, std::vector< std::size_t > &face_labels, const char *stage_name)
static bool Slic3r::tex2color::ensure_all_cluster_centers_used (const std::vector< RGB > &source_face_colors, const std::vector< RGB > &cluster_centers, std::vector< std::size_t > &face_labels, const char *stage_name)
static RGB Slic3r::tex2color::get_pixel_color (float u, float v, const cv::Mat &texture)
static RGB Slic3r::tex2color::sample_face_color (const std::array< Vec2f, 3 > &uvs, const cv::Mat &texture)
static bool Slic3r::tex2color::linear_subdivision (TriMesh &mesh, std::vector< FaceUVArray > &uv_coords, const std::function< void(int)> &sub_progress=nullptr)
static bool Slic3r::tex2color::quantize_vertex_colors (const std::vector< VertexColor > &vertex_colors, const TextureToColorSettings &settings, AlgoCancelCallback cancel_callback, std::vector< RGB > &out_centers, std::vector< std::size_t > &out_vertex_cluster_ids)
static bool Slic3r::tex2color::adaptive_split_by_vertex_clusters (TriMesh &mesh, const std::vector< std::size_t > &vertex_cluster_ids, const std::vector< RGB > &cluster_centers, std::vector< RGB > &out_face_colors)
static bool Slic3r::tex2color::repair_cluster_smooth (TriMesh &mesh, std::vector< RGB > &face_colors, std::vector< RGB > &out_clustered_face_colors, const TextureToColorSettings &settings, AlgoProgressCallback progress_callback, AlgoCancelCallback cancel_callback, const char *log_prefix)
bool Slic3r::tex2color::TextureToColor (const TriMesh &texture_mesh, const std::vector< std::vector< Vec2f > > &uv_coords, const cv::Mat &texture, TriMesh &color_mesh, std::vector< std::array< std::size_t, 3 > > &face_colors, const TextureToColorSettings &settings=TextureToColorSettings(), AlgoProgressCallback progress_callback=nullptr, AlgoCancelCallback cancel_callback=nullptr)
 将纹理贴图转换为网格面片颜色, 并通过聚类和光顺生成可用于多色打印的着色网格
bool Slic3r::tex2color::ClusterAndSmooth (const TriMesh &mesh, const std::vector< std::array< std::size_t, 3 > > &input_face_colors, TriMesh &out_mesh, std::vector< std::array< std::size_t, 3 > > &out_face_colors, const TextureToColorSettings &settings=TextureToColorSettings(), AlgoProgressCallback progress_callback=nullptr, AlgoCancelCallback cancel_callback=nullptr, const std::vector< std::array< float, 4 > > &vertex_colors={})
 Turn pre-computed per-face colors into a clustered color mesh (no texture/UV).

Variables

static constexpr std::array< std::array< float, 3 >, 7 > Slic3r::tex2color::GAUSS_TRI_BARY
static constexpr std::array< float, 7 > Slic3r::tex2color::GAUSS_TRI_WEIGHT = {0.225f, 0.132394152f, 0.132394152f, 0.132394152f, 0.125939181f, 0.125939181f, 0.125939181f}