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

Typedefs

using json = nlohmann::json

Functions

static json to_json (const Vec3d &v)
static json to_json (const BoundingBoxf3 &bb)
void inspect_to_json (const Model &model, const std::vector< std::string > &source_paths, std::ostream &out, size_t max_planes)

Typedef Documentation

◆ json

using Slic3r::MeshInspect::json = nlohmann::json

Function Documentation

◆ inspect_to_json()

void Slic3r::MeshInspect::inspect_to_json ( const Model & model,
const std::vector< std::string > & source_paths,
std::ostream & out,
size_t max_planes )
31{
32 json objects = json::array();
33 for (const ModelObject *mo : model.objects) {
34 json obj = { { "name", mo->name },
35 { "triangle_count", mo->facets_count() },
36 { "instance_count", mo->instances.size() },
37 { "bbox_object", to_json(mo->raw_mesh_bounding_box()) } };
38 if (!mo->instances.empty()) {
39 const std::vector<LayOnFacePlane> planes = lay_on_face_planes(*mo, mo->instances.front()->get_matrix_no_offset());
40 json planes_json = json::array();
41 for (size_t i = 0; i < std::min(planes.size(), max_planes); ++i)
42 planes_json.push_back({ { "normal", to_json(planes[i].normal) },
43 { "area_mm2", std::round(double(planes[i].area) * 1000.) / 1000. },
44 { "center", to_json(planes[i].center) } });
45 obj["bbox_world"] = to_json(mo->instance_bounding_box(0));
46 obj["instance_offset"] = to_json(mo->instances.front()->get_offset());
47 obj["plane_count"] = planes.size();
48 obj["planes"] = std::move(planes_json);
49 }
50 objects.push_back(std::move(obj));
51 }
52
53 const json root = {
54 { "sources", source_paths },
55 { "note", "Lengths in mm. bbox_object and the plane normals and centers are in object coordinates: the parts as "
56 "currently transformed, without the instance transformation. --ground-face-normal and "
57 "--ground-face-point take values in these coordinates. area_mm2 uses instance 0's scale, "
58 "bbox_world is instance 0 on the plate." },
59 { "objects", std::move(objects) },
60 };
61 // Object names and file paths are arbitrary bytes, and dump() throws on invalid UTF-8 by default.
62 // Replace such sequences with U+FFFD so the output is always valid JSON.
63 out << root.dump(2, ' ', false, json::error_handler_t::replace) << std::endl;
64}
Definition Model.hpp:382
std::string name
Definition Model.hpp:384
ModelInstancePtrs instances
Definition Model.hpp:390
const BoundingBoxf3 & raw_mesh_bounding_box() const
Definition Model.cpp:1739
size_t facets_count() const
Definition Model.cpp:2075
BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate=false) const
Definition Model.cpp:1778
ModelObjectPtrs objects
Definition Model.hpp:1702
nlohmann::json json
Definition MeshInspect.cpp:21
static json to_json(const Vec3d &v)
Definition MeshInspect.cpp:23
std::vector< LayOnFacePlane > lay_on_face_planes(const ModelObject &object, const Transform3d &inst_matrix)
Definition LayOnFace.cpp:21

References Slic3r::ModelObject::facets_count(), Slic3r::ModelObject::instance_bounding_box(), Slic3r::ModelObject::instances, Slic3r::lay_on_face_planes(), Slic3r::ModelObject::name, Slic3r::Model::objects, Slic3r::ModelObject::raw_mesh_bounding_box(), and to_json().

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

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

◆ to_json() [1/2]

json Slic3r::MeshInspect::to_json ( const BoundingBoxf3 & bb)
static
26{
27 return { { "min", to_json(bb.min) }, { "max", to_json(bb.max) }, { "size", to_json(bb.size()) } };
28}
PointType size() const
Definition BoundingBox.cpp:187

References Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::BoundingBox3Base< PointType >::size(), and to_json().

Here is the call graph for this function:

◆ to_json() [2/2]

json Slic3r::MeshInspect::to_json ( const Vec3d & v)
static
23{ return json::array({ v.x(), v.y(), v.z() }); }

Referenced by inspect_to_json(), and to_json().

Here is the caller graph for this function: