Gizmo measure modified to accept single full instance selection, to combine the volumes meshes into a single mesh and pass it to the back end after transform it in world coordinates
Changes embedded into tech ENABLE_GIZMO_MEASURE_WORLD_COORDINATES Fixed conflicts during rebase to master
This commit is contained in:
parent
33949734e3
commit
fc2f0bad6e
9 changed files with 347 additions and 13 deletions
|
@ -47,6 +47,9 @@ public:
|
|||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point) const;
|
||||
std::vector<std::vector<int>> get_planes_triangle_indices() const;
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id) const;
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& get_mesh() const;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
private:
|
||||
void update_planes();
|
||||
|
@ -54,7 +57,11 @@ private:
|
|||
|
||||
std::vector<PlaneData> m_planes;
|
||||
std::vector<size_t> m_face_to_plane;
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
TriangleMesh m_mesh;
|
||||
#else
|
||||
const indexed_triangle_set& m_its;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
|
||||
|
@ -63,7 +70,11 @@ private:
|
|||
|
||||
|
||||
MeasuringImpl::MeasuringImpl(const indexed_triangle_set& its)
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
: m_mesh(its)
|
||||
#else
|
||||
: m_its{its}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
{
|
||||
update_planes();
|
||||
extract_features();
|
||||
|
@ -76,10 +87,17 @@ void MeasuringImpl::update_planes()
|
|||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const size_t num_of_facets = m_mesh.its.indices.size();
|
||||
m_face_to_plane.resize(num_of_facets, size_t(-1));
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(m_mesh.its);
|
||||
const std::vector<Vec3i> face_neighbors = its_face_neighbors(m_mesh.its);
|
||||
#else
|
||||
const size_t num_of_facets = m_its.indices.size();
|
||||
m_face_to_plane.resize(num_of_facets, size_t(-1));
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(m_its);
|
||||
const std::vector<Vec3i> face_neighbors = its_face_neighbors(m_its);
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
|
@ -128,7 +146,11 @@ void MeasuringImpl::update_planes()
|
|||
assert(std::none_of(m_face_to_plane.begin(), m_face_to_plane.end(), [](size_t val) { return val == size_t(-1); }));
|
||||
|
||||
// Now we will walk around each of the planes and save vertices which form the border.
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
SurfaceMesh sm(m_mesh.its);
|
||||
#else
|
||||
SurfaceMesh sm(m_its);
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
for (int plane_id=0; plane_id < int(m_planes.size()); ++plane_id) {
|
||||
const auto& facets = m_planes[plane_id].facets;
|
||||
m_planes[plane_id].borders.clear();
|
||||
|
@ -510,6 +532,12 @@ const std::vector<SurfaceFeature>& MeasuringImpl::get_plane_features(unsigned in
|
|||
return m_planes[plane_id].surface_features;
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& MeasuringImpl::get_mesh() const
|
||||
{
|
||||
return this->m_mesh;
|
||||
}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
|
||||
|
||||
|
@ -551,6 +579,13 @@ const std::vector<SurfaceFeature>& Measuring::get_plane_features(unsigned int pl
|
|||
return priv->get_plane_features(plane_id);
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
const TriangleMesh& Measuring::get_mesh() const
|
||||
{
|
||||
return priv->get_mesh();
|
||||
}
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
const AngleAndEdges AngleAndEdges::Dummy = { 0.0, Vec3d::Zero(), { Vec3d::Zero(), Vec3d::Zero() }, { Vec3d::Zero(), Vec3d::Zero() }, 0.0, true };
|
||||
|
||||
static AngleAndEdges angle_edge_edge(const std::pair<Vec3d, Vec3d>& e1, const std::pair<Vec3d, Vec3d>& e2)
|
||||
|
@ -1149,6 +1184,7 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
|||
return result;
|
||||
}
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void DistAndPoints::transform(const Transform3d& trafo) {
|
||||
from = trafo * from;
|
||||
to = trafo * to;
|
||||
|
@ -1169,6 +1205,7 @@ void AngleAndEdges::transform(const Transform3d& trafo) {
|
|||
const double average_scale = 0.5 * (new_e1.norm() / old_e1.norm() + new_e2.norm() / old_e2.norm());
|
||||
radius = average_scale * radius;
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -87,9 +87,11 @@ class MeasuringImpl;
|
|||
|
||||
class Measuring {
|
||||
public:
|
||||
// Construct the measurement object on a given its. The its must remain
|
||||
// valid and unchanged during the whole lifetime of the object.
|
||||
explicit Measuring(const indexed_triangle_set& its);
|
||||
// Construct the measurement object on a given its.
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// The its must remain valid and unchanged during the whole lifetime of the object.
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
explicit Measuring(const indexed_triangle_set& its);
|
||||
~Measuring();
|
||||
|
||||
// Return a reference to a list of all features identified on the its.
|
||||
|
@ -108,6 +110,11 @@ public:
|
|||
// Returns the surface features of the plane with the given index
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id) const;
|
||||
|
||||
#if ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
// Returns the mesh used for measuring
|
||||
const TriangleMesh& get_mesh() const;
|
||||
#endif // ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
private:
|
||||
std::unique_ptr<MeasuringImpl> priv;
|
||||
};
|
||||
|
@ -119,7 +126,9 @@ struct DistAndPoints {
|
|||
Vec3d from;
|
||||
Vec3d to;
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo);
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
struct AngleAndEdges {
|
||||
|
@ -132,7 +141,9 @@ struct AngleAndEdges {
|
|||
double radius;
|
||||
bool coplanar;
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo);
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
|
||||
static const AngleAndEdges Dummy;
|
||||
};
|
||||
|
@ -151,6 +162,7 @@ struct MeasurementResult {
|
|||
return angle.has_value() || distance_infinite.has_value() || distance_strict.has_value() || distance_xyz.has_value();
|
||||
}
|
||||
|
||||
#if !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
void transform(const Transform3d& trafo) {
|
||||
if (angle.has_value())
|
||||
angle->transform(trafo);
|
||||
|
@ -161,6 +173,7 @@ struct MeasurementResult {
|
|||
distance_xyz = (distance_strict->to - distance_strict->from).cwiseAbs();
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_MEASURE_WORLD_COORDINATES
|
||||
};
|
||||
|
||||
// Returns distance/angle between two SurfaceFeatures.
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
// Enable picking using raytracing
|
||||
#define ENABLE_RAYCAST_PICKING (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
#define ENABLE_RAYCAST_PICKING_DEBUG (0 && ENABLE_RAYCAST_PICKING)
|
||||
// Enable gizmo measure combining volumes meshes and passing them to the backend in world coordinates
|
||||
#define ENABLE_GIZMO_MEASURE_WORLD_COORDINATES (1 && ENABLE_2_5_0_ALPHA1)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue