OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::PaintCLI Namespace Reference

Namespaces

namespace  anonymous_namespace{PaintCLI.cpp}

Functions

void inspect_to_json (const Model &model, const std::vector< std::string > &source_paths, std::ostream &out)

Function Documentation

◆ inspect_to_json()

void Slic3r::PaintCLI::inspect_to_json ( const Model & model,
const std::vector< std::string > & source_paths,
std::ostream & out )
139{
140 json root;
141 root["sources"] = source_paths;
142 root["frame"] = "mesh_local";
143 root["note"] = "Coordinates are mesh-local (each volume's own frame). "
144 "Paint gizmos operate in this frame.";
145
146 json objects = json::array();
147 size_t total_objects = 0, total_volumes = 0, total_painted = 0, total_facets = 0;
148
149 for (size_t oi = 0; oi < model.objects.size(); ++oi) {
150 const ModelObject *mo = model.objects[oi];
151 if (!mo) continue;
152 ++total_objects;
153
154 json obj;
155 obj["index"] = oi;
156 obj["name"] = mo->name;
157
158 json volumes = json::array();
159 for (size_t vi = 0; vi < mo->volumes.size(); ++vi) {
160 const ModelVolume *mv = mo->volumes[vi];
161 if (!mv) continue;
162 ++total_volumes;
163
164 const indexed_triangle_set &its = mv->mesh().its;
165 json vol;
166 vol["index"] = vi;
167 vol["name"] = mv->name;
168 vol["n_facets"] = its.indices.size();
169 vol["is_model_part"] = mv->is_model_part();
170 vol["bbox_mesh_local"] = bbox_to_json(bounding_box(its));
171
172 size_t vol_painted = 0;
173 json paints;
174 paints["supports"] = inspect_layer(*mv, mv->supported_facets,
175 supports_states(), vol_painted);
176 paints["seam"] = inspect_layer(*mv, mv->seam_facets,
177 supports_states(), vol_painted);
178 paints["mmu_segmentation"] = inspect_layer(*mv, mv->mmu_segmentation_facets,
179 mmu_states(), vol_painted);
180 paints["fuzzy_skin"] = inspect_layer(*mv, mv->fuzzy_skin_facets,
181 fuzzy_states(), vol_painted);
182 vol["paints"] = std::move(paints);
183 vol["painted_facets_total"] = vol_painted;
184
185 if (vol_painted > 0) ++total_painted;
186 total_facets += vol_painted;
187
188 volumes.push_back(std::move(vol));
189 }
190 obj["volumes"] = std::move(volumes);
191 objects.push_back(std::move(obj));
192 }
193 root["objects"] = std::move(objects);
194 root["summary"] = {
195 { "objects", total_objects },
196 { "volumes", total_volumes },
197 { "volumes_with_paint", total_painted },
198 { "painted_facets_total", total_facets },
199 };
200
201 // Object names and file paths are arbitrary bytes, and dump() throws on invalid
202 // UTF-8 by default. Replace such sequences with U+FFFD so the output is always
203 // valid JSON rather than an exception out of the CLI.
204 out << root.dump(2, ' ', false, json::error_handler_t::replace) << std::endl;
205}
Definition Model.hpp:382
std::string name
Definition Model.hpp:384
ModelVolumePtrs volumes
Definition Model.hpp:393
Definition Model.hpp:832
const TriangleMesh & mesh() const
Definition Model.hpp:892
bool is_model_part() const
Definition Model.hpp:1025
FacetsAnnotation mmu_segmentation_facets
Definition Model.hpp:913
FacetsAnnotation fuzzy_skin_facets
Definition Model.hpp:916
FacetsAnnotation supported_facets
Definition Model.hpp:907
FacetsAnnotation seam_facets
Definition Model.hpp:910
std::string name
Definition Model.hpp:834
ModelObjectPtrs objects
Definition Model.hpp:1702
indexed_triangle_set its
Definition TriangleMesh.hpp:164
BoundingBoxf3 bounding_box(const TriangleMesh &m)
Definition TriangleMesh.hpp:391
nlohmann::json json
Definition AssembleList.cpp:42

References Slic3r::bounding_box(), Slic3r::ModelVolume::fuzzy_skin_facets, Slic3r::ModelVolume::is_model_part(), Slic3r::TriangleMesh::its, Slic3r::ModelVolume::mesh(), Slic3r::ModelVolume::mmu_segmentation_facets, Slic3r::ModelObject::name, Slic3r::ModelVolume::name, Slic3r::Model::objects, Slic3r::ModelVolume::seam_facets, Slic3r::ModelVolume::supported_facets, and Slic3r::ModelObject::volumes.

Referenced by Slic3r::CLI::run().

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