Namespaces | |
| namespace | detail |
Classes | |
| struct | ColorPCA |
| struct | ClusterParameters |
| struct | SmoothParameters |
Typedefs | |
| using | CGALKernel = cgalutils::Kernel |
| typedef CGAL::Aff_transformation_3< CGALKernel > | Affine_transformation_3 |
| typedef boost::graph_traits< CGALMesh >::halfedge_descriptor | halfedge_descriptor |
| typedef boost::graph_traits< CGALMesh >::edge_descriptor | edge_descriptor |
| typedef boost::graph_traits< CGALMesh >::vertex_descriptor | vertex_descriptor |
| typedef CGAL::AABB_face_graph_triangle_primitive< CGALMesh > | Primitive |
| typedef CGAL::AABB_traits_3< CGALKernel, Primitive > | Traits |
| typedef CGAL::AABB_tree< Traits > | Tree |
| typedef CGALMesh::template Property_map< vertex_descriptor, CGALKernel::Vector_3 > | VNMap |
| typedef std::array< double, 3 > | HSV |
| typedef std::array< double, 3 > | XYZ |
| typedef std::array< double, 3 > | LAB |
| using | WorkingDistFunc = double (*)(const ColorDouble&, const ColorDouble&) |
| typedef std::array< std::size_t, 3 > | Color |
| typedef std::vector< Color > | ColorList |
| typedef std::array< double, 3 > | ColorDouble |
| typedef std::array< std::size_t, 3 > | RGB |
| using | CGALMesh |
Enumerations | |
| enum struct | ColorDifferenceMethod : std::size_t { RGB = 0 , Lab = 1 } |
Functions | |
| static ColorDouble | convert_rgb_uint_to_rgb_double (const Color &color) |
| static void | normalize (CGALKernel::Vector_3 &vec) |
| static double | get_angle_between_vectors (const CGALKernel::Vector_3 &v1, const CGALKernel::Vector_3 &v2) |
| static void | calc_face_normals (const CGALMesh &mesh, std::vector< Eigen::Vector3d > &face_normals) |
| static bool | check_and_repair_self_intersect (CGALMesh &mesh, bool *is_self_intersect_status=nullptr) |
| static bool | save_polylines (const std::string &file_name, const std::vector< std::vector< CGALKernel::Point_3 > > &polylines) |
| static bool | smooth_region_topo_boundary (CGALMesh &mesh, std::vector< std::size_t > &face_labels, std::size_t max_iters=20) |
| static bool | smooth_region_geom_boundary (CGALMesh &mesh, std::vector< std::size_t > &face_labels, const SmoothParameters &smooth_parameters) |
| static HSV | convert_rgb_to_hsv (const RGB &rgb) |
| Convert an RGB color to the HSV color space. | |
| static RGB | convert_hsv_to_rgb (const HSV &hsv) |
| Convert an HSV color to the RGB color space. | |
| static XYZ | convert_rgb_to_xyz (const RGB &color_rgb) |
| static XYZ | convert_srgb01_to_xyz (double rs, double gs, double bs) |
| static LAB | convert_xyz_to_lab (const XYZ &xyz) |
| static LAB | convert_srgb01_to_lab (const ColorDouble &srgb01) |
| static LAB | convert_rgb_to_lab (const RGB &rgb) |
| static Color | convert_lab_to_rgb (const LAB &lab) |
| static double | ciede2000 (const std::array< double, 3 > &lab1, const std::array< double, 3 > &lab2) |
| CIEDE2000 color-difference computation. | |
| double | calc_rgb_color_difference_by_ciede2000 (const RGB &rgb1, const RGB &rgb2) |
| Compute the CIEDE2000 color difference between two RGB colors. | |
| double | calc_rgb_color_difference_by_ciede2000_srgb01 (const ColorDouble &rgb1, const ColorDouble &rgb2) |
| Compute the CIEDE2000 color difference between two sRGB colors (double precision, non-linear channels in [0,1]). | |
| static std::vector< ColorDouble > | farthest_point_sampling_init (const std::vector< ColorDouble > &working_colors, std::size_t k, WorkingDistFunc dist_func) |
| bool | remesh_mesh (TriMesh &mesh, std::vector< std::size_t > &face_labels, double target_edge_length_ratio) |
| Remesh the mesh while preserving color boundaries. | |
| bool | is_closed (const TriMesh &tri_mesh) |
| Check whether the mesh is closed (watertight). | |
| static bool | smooth_region_labels (TriMesh &tri_mesh, std::vector< std::size_t > &face_labels, const SmoothParameters &smooth_parameters) |
| bool | smooth_region (TriMesh &tri_mesh, std::vector< std::array< std::size_t, 3 > > &face_labels, const SmoothParameters &smooth_parameters=SmoothParameters()) |
| Smooth region boundaries (RGB color labels). | |
| bool | smooth_region (TriMesh &tri_mesh, std::vector< std::size_t > &face_labels, const SmoothParameters &smooth_parameters=SmoothParameters()) |
| Smooth region boundaries (integer labels). | |
| double | calc_rgb_color_difference_by_squared_rgb_double (const ColorDouble &c1, const ColorDouble &c2) |
| Compute the squared Euclidean distance between two RGB colors (double precision). | |
| double | calc_rgb_color_difference_by_squared_rgb (const RGB &rgb1, const RGB &rgb2) |
| Compute the squared Euclidean distance between two RGB colors. | |
| static std::vector< ColorDouble > | kmeans_core (const std::vector< ColorDouble > &working_colors, std::size_t k, std::size_t max_iter, WorkingDistFunc dist_func, const std::function< bool()> &cancel_cb=nullptr) |
| std::vector< Color > | cluster_k_means (const std::vector< Color > &colors, const ClusterParameters &cluster_parameters) |
| K-Means clustering algorithm that minimizes the sum of squared errors. | |
| std::vector< Color > | cluster_to_specified_colors (const std::vector< Color > &colors, const std::vector< Color > &specified_colors) |
| Cluster a color list to a set of specified cluster centers. | |
| static std::vector< ColorPCA > | sort_colors_by_pca (const std::vector< Color > &colors) |
| std::vector< Color > | cluster_adaptive (const std::vector< Color > &colors, const ClusterParameters &cluster_parameters) |
| Adaptive K-Means clustering that determines an appropriate number of clusters under a max color-distance constraint. | |
| static std::vector< std::vector< CGAL::SM_Face_index > > | get_connected_face_groups (const CGALMesh &mesh) |
| bool | get_components (const TriMesh &mesh, const std::vector< Vec2f > &vertex_uvs, std::vector< TriMesh > &component_meshes, std::vector< std::vector< Vec2f > > &component_vertex_uvs) |
| Split the mesh into connected components. | |
| bool | calc_nearest_color_id (const std::vector< RGB > &colors, const RGB &color, std::size_t &nearest_color_id) |
| Find the ID of the nearest color in a color list to a given color. | |
| bool | mesh_cluster (const TriMesh &mesh, const std::vector< RGB > &cluster_centers, std::vector< RGB > &map_face_to_rgb, std::vector< std::size_t > &map_face_to_cluster_id) |
| Cluster mesh face colors based on given cluster centers. | |
Variables | |
| static constexpr double | TOPO_SMOOTH_WEIGHT_THRESHOLD = 0.3 |
| const XYZ | D65_WHITE = {0.95047, 1.0, 1.08883} |
| struct Slic3r::tex2color::color_utils::ClusterParameters |
| Class Members | ||
|---|---|---|
| function< bool()> | cancel_callback | |
| size_t | cluster_k = 10 | |
| ColorDifferenceMethod | color_difference_method = ColorDifferenceMethod::Lab | |
| size_t | max_cluster_k = 32 | |
| double | max_color_distance = 25 | |
| size_t | max_iter = 50 | |
| typedef CGAL::Aff_transformation_3<CGALKernel> Slic3r::tex2color::color_utils::Affine_transformation_3 |
| typedef std::array<std::size_t, 3> Slic3r::tex2color::color_utils::Color |
| typedef std::array<double, 3> Slic3r::tex2color::color_utils::ColorDouble |
| typedef std::vector<Color> Slic3r::tex2color::color_utils::ColorList |
| typedef boost::graph_traits<CGALMesh>::edge_descriptor Slic3r::tex2color::color_utils::edge_descriptor |
| typedef boost::graph_traits<CGALMesh>::halfedge_descriptor Slic3r::tex2color::color_utils::halfedge_descriptor |
| typedef std::array<double, 3> Slic3r::tex2color::color_utils::HSV |
| typedef std::array<double, 3> Slic3r::tex2color::color_utils::LAB |
| typedef CGAL::AABB_face_graph_triangle_primitive<CGALMesh> Slic3r::tex2color::color_utils::Primitive |
| typedef std::array<std::size_t, 3> Slic3r::tex2color::color_utils::RGB |
| typedef CGAL::AABB_traits_3<CGALKernel, Primitive> Slic3r::tex2color::color_utils::Traits |
| typedef CGAL::AABB_tree<Traits> Slic3r::tex2color::color_utils::Tree |
| typedef boost::graph_traits<CGALMesh>::vertex_descriptor Slic3r::tex2color::color_utils::vertex_descriptor |
| typedef CGALMesh::template Property_map<vertex_descriptor, CGALKernel::Vector_3> Slic3r::tex2color::color_utils::VNMap |
| using Slic3r::tex2color::color_utils::WorkingDistFunc = double (*)(const ColorDouble&, const ColorDouble&) |
| typedef std::array<double, 3> Slic3r::tex2color::color_utils::XYZ |
|
strong |
|
static |
References Slic3r::cross().
| bool Slic3r::tex2color::color_utils::calc_nearest_color_id | ( | const std::vector< RGB > & | colors, |
| const RGB & | color, | ||
| std::size_t & | nearest_color_id ) |
Find the ID of the nearest color in a color list to a given color.
| [in] | colors | Color list. |
| [in] | color | Target color. |
| [out] | nearest_color_id | ID of the nearest color found. |
References calc_nearest_color_id(), calc_rgb_color_difference_by_ciede2000(), and Slic3r::Geometry::dist().
Referenced by calc_nearest_color_id(), and Slic3r::tex2color::quantize_vertex_colors().
| double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_ciede2000 | ( | const RGB & | rgb1, |
| const RGB & | rgb2 ) |
Compute the CIEDE2000 color difference between two RGB colors.
Currently the most accurate color-difference formula, recommended by CIE as the industry standard.
| [in] | rgb1 | First RGB color [R, G, B], range 0~255. |
| [in] | rgb2 | Second RGB color [R, G, B], range 0~255. |
References ciede2000(), and convert_rgb_to_lab().
Referenced by calc_nearest_color_id(), Slic3r::compute_delta_e(), and Slic3r::tex2color::ensure_all_cluster_centers_used().
| double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_ciede2000_srgb01 | ( | const ColorDouble & | rgb1, |
| const ColorDouble & | rgb2 ) |
Compute the CIEDE2000 color difference between two sRGB colors (double precision, non-linear channels in [0,1]).
Uses the same XYZ/Lab/dE00 pipeline as calc_rgb_color_difference_by_ciede2000 but without uint8 quantization or the intermediate x255 conversion; suitable for bisection, color blending, and other iterative scenarios. Note: ColorDouble here represents [R,G,B] in [0,1], which differs from the 0~255 scale used by other interfaces in this file. Callers should follow the naming convention.
| [in] | rgb1 | rgb2 sRGB non-linear channel values, recommended range [0,1]. |
References ciede2000(), and convert_srgb01_to_lab().
| double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_squared_rgb | ( | const RGB & | rgb1, |
| const RGB & | rgb2 ) |
Compute the squared Euclidean distance between two RGB colors.
| [in] | rgb1 | First RGB color [R, G, B], range 0~255. |
| [in] | rgb2 | Second RGB color [R, G, B], range 0~255. |
References calc_rgb_color_difference_by_squared_rgb_double(), and convert_rgb_uint_to_rgb_double().
| double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_squared_rgb_double | ( | const ColorDouble & | c1, |
| const ColorDouble & | c2 ) |
Compute the squared Euclidean distance between two RGB colors (double precision).
Referenced by calc_rgb_color_difference_by_squared_rgb(), cluster_adaptive(), and cluster_k_means().
|
static |
|
static |
CIEDE2000 color-difference computation.
Currently the most accurate color-difference formula, recommended by CIE as the industry standard.
References M_PI.
Referenced by calc_rgb_color_difference_by_ciede2000(), calc_rgb_color_difference_by_ciede2000_srgb01(), cluster_adaptive(), and cluster_k_means().
| std::vector< Color > Slic3r::tex2color::color_utils::cluster_adaptive | ( | const std::vector< Color > & | colors, |
| const ClusterParameters & | cluster_parameters ) |
Adaptive K-Means clustering that determines an appropriate number of clusters under a max color-distance constraint.
Automatically finds the optimal cluster count via binary search so that max_color_distance is satisfied.
| [in] | colors | Input color list. |
| [in] | cluster_parameters | Clustering parameters; cluster_k is ignored and determined automatically. |
References calc_rgb_color_difference_by_squared_rgb_double(), ciede2000(), cluster_adaptive(), Slic3r::tex2color::color_utils::ClusterParameters::color_difference_method, convert_rgb_to_lab(), Slic3r::tex2color::color_utils::ClusterParameters::max_cluster_k, Slic3r::tex2color::color_utils::ClusterParameters::max_color_distance, Slic3r::tex2color::color_utils::ClusterParameters::max_iter, Slic3r::range(), and RGB.
Referenced by cluster_adaptive(), and Slic3r::tex2color::quantize_vertex_colors().
| std::vector< Color > Slic3r::tex2color::color_utils::cluster_k_means | ( | const std::vector< Color > & | colors, |
| const ClusterParameters & | cluster_parameters ) |
K-Means clustering algorithm that minimizes the sum of squared errors.
Uses K-Means++ initialization to iteratively find the optimal cluster centers.
| [in] | colors | Input color list. |
| [in] | cluster_parameters | Clustering parameters including cluster count, max iterations, color-difference method, etc. |
References calc_rgb_color_difference_by_squared_rgb_double(), Slic3r::tex2color::color_utils::ClusterParameters::cancel_callback, ciede2000(), Slic3r::tex2color::color_utils::ClusterParameters::cluster_k, cluster_k_means(), Slic3r::tex2color::color_utils::ClusterParameters::color_difference_method, convert_lab_to_rgb(), convert_rgb_to_lab(), kmeans_core(), Slic3r::tex2color::color_utils::ClusterParameters::max_iter, and RGB.
Referenced by cluster_k_means(), and Slic3r::tex2color::quantize_vertex_colors().
| std::vector< Color > Slic3r::tex2color::color_utils::cluster_to_specified_colors | ( | const std::vector< Color > & | colors, |
| const std::vector< Color > & | specified_colors ) |
Cluster a color list to a set of specified cluster centers.
For each input color, find the nearest specified cluster center and replace it.
| [in] | colors | Input color list. |
| [in] | specified_colors | Specified cluster-center colors. |
References cluster_to_specified_colors(), and Slic3r::range().
Referenced by cluster_to_specified_colors().
Convert an HSV color to the RGB color space.
| hsv | Input HSV color [H, S, V], H in 0~360, S and V in 0~1. |
References D65_WHITE.
Referenced by cluster_k_means().
Convert an RGB color to the HSV color space.
| rgb | Input RGB color [R, G, B], range 0~255. |
References convert_rgb_to_xyz(), and convert_xyz_to_lab().
Referenced by calc_rgb_color_difference_by_ciede2000(), cluster_adaptive(), and cluster_k_means().
Referenced by convert_rgb_to_lab().
|
inlinestatic |
Referenced by calc_rgb_color_difference_by_squared_rgb().
|
static |
References convert_srgb01_to_xyz(), and convert_xyz_to_lab().
Referenced by calc_rgb_color_difference_by_ciede2000_srgb01().
|
static |
Referenced by convert_srgb01_to_lab().
References D65_WHITE, and Slic3r::f().
Referenced by convert_rgb_to_lab(), and convert_srgb01_to_lab().
|
static |
Referenced by kmeans_core().
|
static |
References EPSILON, M_PI, and normalize().
Referenced by smooth_region_geom_boundary().
| bool Slic3r::tex2color::color_utils::get_components | ( | const TriMesh & | mesh, |
| const std::vector< Vec2f > & | vertex_uvs, | ||
| std::vector< TriMesh > & | component_meshes, | ||
| std::vector< std::vector< Vec2f > > & | component_vertex_uvs ) |
Split the mesh into connected components.
Based on face connectivity, the mesh is split into independent components, each forming a standalone mesh. Texture coordinates for each component are preserved.
| [in] | mesh | Input mesh. |
| [in] | vertex_uvs | Vertex texture coordinates. |
| [out] | component_meshes | Output list of component meshes. |
| [out] | component_vertex_uvs | Output list of texture coordinates per component. |
References Slic3r::tex2color::cgalutils::convert_trimesh_to_cgal(), get_components(), and get_connected_face_groups().
Referenced by get_components().
|
static |
References get_connected_face_groups().
Referenced by get_components(), and get_connected_face_groups().
| bool Slic3r::tex2color::color_utils::is_closed | ( | const TriMesh & | tri_mesh | ) |
Check whether the mesh is closed (watertight).
A mesh is closed if it has no boundary edges, i.e. every edge is shared by exactly two faces.
| [in] | tri_mesh | Input mesh. |
References Slic3r::tex2color::cgalutils::convert_trimesh_to_cgal().
Referenced by Slic3r::tex2color::repair_cluster_smooth().
|
static |
References farthest_point_sampling_init(), and Slic3r::range().
Referenced by cluster_k_means().
| bool Slic3r::tex2color::color_utils::mesh_cluster | ( | const TriMesh & | mesh, |
| const std::vector< RGB > & | cluster_centers, | ||
| std::vector< RGB > & | map_face_to_rgb, | ||
| std::vector< std::size_t > & | map_face_to_cluster_id ) |
Cluster mesh face colors based on given cluster centers.
| [in] | mesh | Input mesh. |
| [in] | cluster_centers | Cluster-center RGB colors. |
| [in,out] | map_face_to_rgb | RGB color per face; updated to the nearest cluster center after clustering. |
| [out] | map_face_to_cluster_id | Cluster-center ID per face; updated to the nearest cluster center ID. |
References Slic3r::tex2color::cgalutils::convert_trimesh_to_cgal(), mesh_cluster(), and Slic3r::range().
Referenced by mesh_cluster().
|
static |
References EPSILON.
Referenced by get_angle_between_vectors().
| bool Slic3r::tex2color::color_utils::remesh_mesh | ( | TriMesh & | mesh, |
| std::vector< std::size_t > & | face_labels, | ||
| double | target_edge_length_ratio ) |
Remesh the mesh while preserving color boundaries.
Performs isotropic remeshing while protecting color boundaries. Edges whose two adjacent faces have different colors are marked as feature edges and will not be modified.
| [in,out] | mesh | Input mesh; modified in-place after remeshing. |
| [in,out] | face_labels | Face color labels; updated to match the new mesh. |
| [in] | target_edge_length_ratio | Ratio of target average edge length to input average edge length; >1 simplifies, <1 refines. |
References Slic3r::tex2color::color_utils::detail::average_edge_length_impl(), Slic3r::AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(), Slic3r::tex2color::cgalutils::convert_trimesh_to_cgal(), Slic3r::range(), and save_polylines().
|
static |
Referenced by remesh_mesh().
| bool Slic3r::tex2color::color_utils::smooth_region | ( | TriMesh & | tri_mesh, |
| std::vector< std::array< std::size_t, 3 > > & | face_labels, | ||
| const SmoothParameters & | smooth_parameters = SmoothParameters() ) |
Smooth region boundaries (RGB color labels).
Applies topological smoothing (label reassignment) and geometric smoothing (boundary vertex relocation).
| [in,out] | tri_mesh | Input mesh; modified in-place after smoothing. |
| [in,out] | face_labels | Face color labels (RGB format); updated after smoothing. |
| [in] | smooth_parameters | Smoothing control parameters. |
References smooth_region_labels().
| bool Slic3r::tex2color::color_utils::smooth_region | ( | TriMesh & | tri_mesh, |
| std::vector< std::size_t > & | face_labels, | ||
| const SmoothParameters & | smooth_parameters = SmoothParameters() ) |
Smooth region boundaries (integer labels).
Applies topological smoothing (label reassignment) and geometric smoothing (boundary vertex relocation).
| [in,out] | tri_mesh | Input mesh; modified in-place after smoothing. |
| [in,out] | face_labels | Integer face labels; updated after smoothing. |
| [in] | smooth_parameters | Smoothing control parameters. |
References smooth_region_labels().
|
static |
References Slic3r::angle(), get_angle_between_vectors(), and Slic3r::tex2color::color_utils::SmoothParameters::smooth_weight.
Referenced by smooth_region_labels().
|
static |
References Slic3r::tex2color::cgalutils::cgal_to_trimesh(), Slic3r::tex2color::cgalutils::convert_trimesh_to_cgal(), EPSILON, smooth_region_geom_boundary(), smooth_region_topo_boundary(), Slic3r::tex2color::color_utils::SmoothParameters::smooth_weight, and TOPO_SMOOTH_WEIGHT_THRESHOLD.
Referenced by smooth_region(), and smooth_region().
|
static |
Referenced by smooth_region_labels().
|
static |
References sort_colors_by_pca().
Referenced by sort_colors_by_pca().
| const XYZ Slic3r::tex2color::color_utils::D65_WHITE = {0.95047, 1.0, 1.08883} |
Referenced by convert_lab_to_rgb(), and convert_xyz_to_lab().
|
staticconstexpr |
Referenced by smooth_region_labels().