mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 09:02:06 +00:00
Measure: Port of BBS' improved version of measure gizmo
Co-authored-by: zhou.xu <zhou.xu@bambulab.com>
This commit is contained in:
@@ -67,6 +67,7 @@ public:
|
||||
static const ColorRGB YELLOW() { return { 1.0f, 1.0f, 0.0f }; }
|
||||
static const ColorRGB WHITE() { return { 1.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGB ORCA() { return {0.0f, 150.f / 255.0f, 136.0f / 255}; }
|
||||
static const ColorRGB WARNING() { return {241.0f / 255, 117.f / 255.0f, 78.0f / 255}; }
|
||||
|
||||
static const ColorRGB X() { return { 0.75f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB Y() { return { 0.0f, 0.75f, 0.0f }; }
|
||||
|
||||
@@ -13,7 +13,27 @@
|
||||
|
||||
namespace Slic3r {
|
||||
namespace Measure {
|
||||
bool get_point_projection_to_plane(const Vec3d &pt, const Vec3d &plane_origin, const Vec3d &plane_normal, Vec3d &intersection_pt)
|
||||
{
|
||||
auto normal = plane_normal.normalized();
|
||||
auto BA = plane_origin - pt;
|
||||
auto length = BA.dot(normal);
|
||||
intersection_pt = pt + length * normal;
|
||||
return true;
|
||||
}
|
||||
|
||||
Vec3d get_one_point_in_plane(const Vec3d &plane_origin, const Vec3d &plane_normal)
|
||||
{
|
||||
Vec3d dir(1, 0, 0);
|
||||
float eps = 1e-3;
|
||||
if (abs(plane_normal.dot(dir)) > 1 - eps) {
|
||||
dir = Vec3d(0, 1, 0);
|
||||
}
|
||||
auto new_pt = plane_origin + dir;
|
||||
Vec3d retult;
|
||||
get_point_projection_to_plane(new_pt, plane_origin, plane_normal, retult);
|
||||
return retult;
|
||||
}
|
||||
|
||||
constexpr double feature_hover_limit = 0.5; // how close to a feature the mouse must be to highlight it
|
||||
|
||||
@@ -33,7 +53,7 @@ static std::tuple<Vec3d, double, double> get_center_and_radius(const std::vector
|
||||
|
||||
double error = std::numeric_limits<double>::max();
|
||||
auto circle = Geometry::circle_ransac(out, iter, &error);
|
||||
|
||||
|
||||
return std::make_tuple(trafo.inverse() * Vec3d(circle.center.x(), circle.center.y(), z), circle.radius, error);
|
||||
}
|
||||
|
||||
@@ -69,16 +89,18 @@ public:
|
||||
bool features_extracted = false;
|
||||
};
|
||||
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point);
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d &point, const Transform3d &world_tran,bool only_select_plane);
|
||||
int get_num_of_planes() const;
|
||||
const std::vector<int>& get_plane_triangle_indices(int idx) const;
|
||||
std::vector<int>* get_plane_tri_indices(int idx);
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id);
|
||||
std::vector<SurfaceFeature>* get_plane_features_pointer(unsigned int plane_id);
|
||||
const indexed_triangle_set& get_its() const;
|
||||
|
||||
private:
|
||||
void update_planes();
|
||||
void extract_features(int plane_idx);
|
||||
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
std::vector<size_t> m_face_to_plane;
|
||||
indexed_triangle_set m_its;
|
||||
@@ -158,7 +180,7 @@ void MeasuringImpl::update_planes()
|
||||
m_planes.back().normal = normal_ptr->cast<double>();
|
||||
std::sort(m_planes.back().facets.begin(), m_planes.back().facets.end());
|
||||
}
|
||||
|
||||
|
||||
// Check that each facet is part of one of the planes.
|
||||
assert(std::none_of(m_face_to_plane.begin(), m_face_to_plane.end(), [](size_t val) { return val == size_t(-1); }));
|
||||
|
||||
@@ -175,7 +197,7 @@ void MeasuringImpl::update_planes()
|
||||
const auto& facets = planes[plane_id].facets;
|
||||
planes[plane_id].borders.clear();
|
||||
std::vector<std::array<bool, 3>> visited(facets.size(), {false, false, false});
|
||||
|
||||
|
||||
for (int face_id=0; face_id<int(facets.size()); ++face_id) {
|
||||
assert(face_to_plane[facets[face_id]] == plane_id);
|
||||
|
||||
@@ -193,7 +215,7 @@ void MeasuringImpl::update_planes()
|
||||
Halfedge_index he = sm.halfedge(Face_index(facets[face_id]));
|
||||
while (he.side() != edge_id)
|
||||
he = sm.next(he);
|
||||
|
||||
|
||||
// he is the first halfedge on the border. Now walk around and append the points.
|
||||
//const Halfedge_index he_orig = he;
|
||||
planes[plane_id].borders.emplace_back();
|
||||
@@ -202,7 +224,7 @@ void MeasuringImpl::update_planes()
|
||||
last_border.emplace_back(sm.point(sm.source(he)).cast<double>());
|
||||
//Vertex_index target = sm.target(he);
|
||||
const Halfedge_index he_start = he;
|
||||
|
||||
|
||||
Face_index fi = he.face();
|
||||
auto face_it = std::lower_bound(facets.begin(), facets.end(), int(fi));
|
||||
assert(face_it != facets.end());
|
||||
@@ -228,7 +250,7 @@ void MeasuringImpl::update_planes()
|
||||
he = sm.opposite(he);
|
||||
if (he.is_invalid())
|
||||
goto PLANE_FAILURE;
|
||||
|
||||
|
||||
Face_index fi = he.face();
|
||||
auto face_it = std::lower_bound(facets.begin(), facets.end(), int(fi));
|
||||
if (face_it == facets.end() || *face_it != int(fi)) // This indicates a broken mesh.
|
||||
@@ -265,11 +287,6 @@ void MeasuringImpl::update_planes()
|
||||
m_planes.shrink_to_fit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MeasuringImpl::extract_features(int plane_idx)
|
||||
{
|
||||
assert(! m_planes[plane_idx].features_extracted);
|
||||
@@ -490,7 +507,7 @@ void MeasuringImpl::extract_features(int plane_idx)
|
||||
Vec3d cog = Vec3d::Zero();
|
||||
size_t counter = 0;
|
||||
for (const std::vector<Vec3d>& b : plane.borders) {
|
||||
for (size_t i = 1; i < b.size(); ++i) {
|
||||
for (size_t i = 0; i < b.size(); ++i) {
|
||||
cog += b[i];
|
||||
++counter;
|
||||
}
|
||||
@@ -505,14 +522,7 @@ void MeasuringImpl::extract_features(int plane_idx)
|
||||
plane.features_extracted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const Vec3d& point)
|
||||
std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const Vec3d &point, const Transform3d &world_tran,bool only_select_plane)
|
||||
{
|
||||
if (face_idx >= m_face_to_plane.size())
|
||||
return std::optional<SurfaceFeature>();
|
||||
@@ -521,7 +531,7 @@ std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const
|
||||
|
||||
if (! plane.features_extracted)
|
||||
extract_features(m_face_to_plane[face_idx]);
|
||||
|
||||
|
||||
size_t closest_feature_idx = size_t(-1);
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
|
||||
@@ -530,40 +540,57 @@ std::optional<SurfaceFeature> MeasuringImpl::get_feature(size_t face_idx, const
|
||||
|
||||
assert(plane.surface_features.empty() || plane.surface_features.back().get_type() == SurfaceFeatureType::Plane);
|
||||
|
||||
for (size_t i=0; i<plane.surface_features.size() - 1; ++i) {
|
||||
// The -1 is there to prevent measuring distance to the plane itself,
|
||||
// which is needless and relatively expensive.
|
||||
res = get_measurement(plane.surface_features[i], point_sf);
|
||||
if (res.distance_strict) { // TODO: this should become an assert after all combinations are implemented.
|
||||
double dist = res.distance_strict->dist;
|
||||
if (dist < feature_hover_limit && dist < min_dist) {
|
||||
min_dist = std::min(dist, min_dist);
|
||||
closest_feature_idx = i;
|
||||
if (!only_select_plane) {
|
||||
for (size_t i = 0; i < plane.surface_features.size() - 1; ++i) {
|
||||
// The -1 is there to prevent measuring distance to the plane itself,
|
||||
// which is needless and relatively expensive.
|
||||
res = get_measurement(plane.surface_features[i], point_sf);
|
||||
if (res.distance_strict) { // TODO: this should become an assert after all combinations are implemented.
|
||||
double dist = res.distance_strict->dist;
|
||||
if (dist < feature_hover_limit && dist < min_dist) {
|
||||
min_dist = std::min(dist, min_dist);
|
||||
closest_feature_idx = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closest_feature_idx != size_t(-1)) {
|
||||
const SurfaceFeature& f = plane.surface_features[closest_feature_idx];
|
||||
if (f.get_type() == SurfaceFeatureType::Edge) {
|
||||
// If this is an edge, check if we are not close to the endpoint. If so,
|
||||
// we will include the endpoint as well. Close = 10% of the lenghth of
|
||||
// the edge, clamped between 0.025 and 0.5 mm.
|
||||
const auto& [sp, ep] = f.get_edge();
|
||||
double len_sq = (ep-sp).squaredNorm();
|
||||
double limit_sq = std::max(0.025*0.025, std::min(0.5*0.5, 0.1 * 0.1 * len_sq));
|
||||
if (closest_feature_idx != size_t(-1)) {
|
||||
const SurfaceFeature &f = plane.surface_features[closest_feature_idx];
|
||||
if (f.get_type() == SurfaceFeatureType::Edge) {
|
||||
// If this is an edge, check if we are not close to the endpoint. If so,
|
||||
// we will include the endpoint as well. Close = 10% of the lenghth of
|
||||
// the edge, clamped between 0.025 and 0.5 mm.
|
||||
const auto &[sp, ep] = f.get_edge();
|
||||
double len_sq = (ep - sp).squaredNorm();
|
||||
double limit_sq = std::max(0.025 * 0.025, std::min(0.5 * 0.5, 0.1 * 0.1 * len_sq));
|
||||
if ((point - sp).squaredNorm() < limit_sq) {
|
||||
SurfaceFeature local_f(sp);
|
||||
local_f.origin_surface_feature = std::make_shared<SurfaceFeature>(local_f);
|
||||
local_f.translate(world_tran);
|
||||
return std::make_optional(local_f);
|
||||
}
|
||||
|
||||
if ((point-sp).squaredNorm() < limit_sq)
|
||||
return std::make_optional(SurfaceFeature(sp));
|
||||
if ((point-ep).squaredNorm() < limit_sq)
|
||||
return std::make_optional(SurfaceFeature(ep));
|
||||
if ((point - ep).squaredNorm() < limit_sq) {
|
||||
SurfaceFeature local_f(ep);
|
||||
local_f.origin_surface_feature = std::make_shared<SurfaceFeature>(local_f);
|
||||
local_f.translate(world_tran);
|
||||
return std::make_optional(local_f);
|
||||
}
|
||||
}
|
||||
SurfaceFeature f_tran(f);
|
||||
f_tran.origin_surface_feature = std::make_shared<SurfaceFeature>(f);
|
||||
f_tran.translate(world_tran);
|
||||
return std::make_optional(f_tran);
|
||||
}
|
||||
return std::make_optional(f);
|
||||
}
|
||||
|
||||
// Nothing detected, return the plane as a whole.
|
||||
assert(plane.surface_features.back().get_type() == SurfaceFeatureType::Plane);
|
||||
return std::make_optional(plane.surface_features.back());
|
||||
auto cur_plane = const_cast<PlaneData*>(&plane);
|
||||
SurfaceFeature f_tran(cur_plane->surface_features.back());
|
||||
f_tran.origin_surface_feature = std::make_shared<SurfaceFeature>(cur_plane->surface_features.back());
|
||||
f_tran.translate(world_tran);
|
||||
return std::make_optional(f_tran);
|
||||
}
|
||||
|
||||
|
||||
@@ -583,6 +610,12 @@ const std::vector<int>& MeasuringImpl::get_plane_triangle_indices(int idx) const
|
||||
return m_planes[idx].facets;
|
||||
}
|
||||
|
||||
std::vector<int>* MeasuringImpl::get_plane_tri_indices(int idx)
|
||||
{
|
||||
assert(idx >= 0 && idx < int(m_planes.size()));
|
||||
return &m_planes[idx].facets;
|
||||
}
|
||||
|
||||
const std::vector<SurfaceFeature>& MeasuringImpl::get_plane_features(unsigned int plane_id)
|
||||
{
|
||||
assert(plane_id < m_planes.size());
|
||||
@@ -591,21 +624,18 @@ const std::vector<SurfaceFeature>& MeasuringImpl::get_plane_features(unsigned in
|
||||
return m_planes[plane_id].surface_features;
|
||||
}
|
||||
|
||||
std::vector<SurfaceFeature>* MeasuringImpl::get_plane_features_pointer(unsigned int plane_id) {
|
||||
assert(plane_id < m_planes.size());
|
||||
if (!m_planes[plane_id].features_extracted)
|
||||
extract_features(plane_id);
|
||||
return &m_planes[plane_id].surface_features;
|
||||
}
|
||||
|
||||
const indexed_triangle_set& MeasuringImpl::get_its() const
|
||||
{
|
||||
return this->m_its;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Measuring::Measuring(const indexed_triangle_set& its)
|
||||
: priv{std::make_unique<MeasuringImpl>(its)}
|
||||
{}
|
||||
@@ -614,9 +644,12 @@ Measuring::~Measuring() {}
|
||||
|
||||
|
||||
|
||||
std::optional<SurfaceFeature> Measuring::get_feature(size_t face_idx, const Vec3d& point) const
|
||||
std::optional<SurfaceFeature> Measuring::get_feature(size_t face_idx, const Vec3d &point, const Transform3d &world_tran, bool only_select_plane) const
|
||||
{
|
||||
return priv->get_feature(face_idx, point);
|
||||
if (face_idx == 7516 || face_idx == 7517) {
|
||||
std::cout << "";
|
||||
}
|
||||
return priv->get_feature(face_idx, point, world_tran, only_select_plane);
|
||||
}
|
||||
|
||||
|
||||
@@ -796,13 +829,7 @@ static AngleAndEdges angle_plane_plane(const std::tuple<int, Vec3d, Vec3d>& p1,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature& b, const Measuring* measuring)
|
||||
MeasurementResult get_measurement(const SurfaceFeature &a, const SurfaceFeature &b, bool deal_circle_result)
|
||||
{
|
||||
assert(a.get_type() != SurfaceFeatureType::Undef && b.get_type() != SurfaceFeatureType::Undef);
|
||||
|
||||
@@ -819,7 +846,7 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
if (f2.get_type() == SurfaceFeatureType::Point) {
|
||||
Vec3d diff = (f2.get_point() - f1.get_point());
|
||||
result.distance_strict = std::make_optional(DistAndPoints{diff.norm(), f1.get_point(), f2.get_point()});
|
||||
result.distance_xyz = diff.cwiseAbs();
|
||||
result.distance_xyz = diff;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else if (f2.get_type() == SurfaceFeatureType::Edge) {
|
||||
@@ -849,13 +876,18 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
result.distance_strict = std::make_optional(DistAndPoints{ radius, c, p_on_circle });
|
||||
}
|
||||
else {
|
||||
const Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
||||
const Vec3d proj = circle_plane.projection(f1.get_point());
|
||||
const double dist = std::sqrt(std::pow((proj - c).norm() - radius, 2.) +
|
||||
(f1.get_point() - proj).squaredNorm());
|
||||
if (deal_circle_result == false) {
|
||||
const Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
||||
const Vec3d proj = circle_plane.projection(f1.get_point());
|
||||
const double dist = std::sqrt(std::pow((proj - c).norm() - radius, 2.) + (f1.get_point() - proj).squaredNorm());
|
||||
|
||||
const Vec3d p_on_circle = c + radius * (proj - c).normalized();
|
||||
result.distance_strict = std::make_optional(DistAndPoints{ dist, f1.get_point(), p_on_circle }); // TODO
|
||||
const Vec3d p_on_circle = c + radius * (proj - c).normalized();
|
||||
result.distance_strict = std::make_optional(DistAndPoints{dist, f1.get_point(), p_on_circle});
|
||||
}
|
||||
else {
|
||||
const double dist = (f1.get_point() - c).norm();
|
||||
result.distance_strict = std::make_optional(DistAndPoints{dist, f1.get_point(), c});
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||
@@ -903,31 +935,31 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
result.angle = angle_edge_edge(f1.get_edge(), f2.get_edge());
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else if (f2.get_type() == SurfaceFeatureType::Circle) {
|
||||
const std::pair<Vec3d, Vec3d> e = f1.get_edge();
|
||||
const auto& [center, radius, normal] = f2.get_circle();
|
||||
const Vec3d e1e2 = (e.second - e.first);
|
||||
const Vec3d e1e2_unit = e1e2.normalized();
|
||||
const std::pair<Vec3d, Vec3d> e = f1.get_edge();
|
||||
const auto &[center, radius, normal] = f2.get_circle();
|
||||
const Vec3d e1e2 = (e.second - e.first);
|
||||
const Vec3d e1e2_unit = e1e2.normalized();
|
||||
|
||||
std::vector<DistAndPoints> distances;
|
||||
distances.emplace_back(*get_measurement(SurfaceFeature(e.first), f2).distance_strict);
|
||||
distances.emplace_back(*get_measurement(SurfaceFeature(e.second), f2).distance_strict);
|
||||
|
||||
const Eigen::Hyperplane<double, 3> plane(e1e2_unit, center);
|
||||
const Eigen::ParametrizedLine<double, 3> line = Eigen::ParametrizedLine<double, 3>::Through(e.first, e.second);
|
||||
const Vec3d inter = line.intersectionPoint(plane);
|
||||
const Vec3d e1inter = inter - e.first;
|
||||
if (e1inter.dot(e1e2) >= 0.0 && e1inter.norm() < e1e2.norm())
|
||||
distances.emplace_back(*get_measurement(SurfaceFeature(inter), f2).distance_strict);
|
||||
const Eigen::Hyperplane<double, 3> plane(e1e2_unit, center);
|
||||
const Eigen::ParametrizedLine<double, 3> line = Eigen::ParametrizedLine<double, 3>::Through(e.first, e.second);
|
||||
const Vec3d inter = line.intersectionPoint(plane);
|
||||
const Vec3d e1inter = inter - e.first;
|
||||
if (e1inter.dot(e1e2) >= 0.0 && e1inter.norm() < e1e2.norm()) distances.emplace_back(*get_measurement(SurfaceFeature(inter), f2).distance_strict);
|
||||
|
||||
auto it = std::min_element(distances.begin(), distances.end(),
|
||||
[](const DistAndPoints& item1, const DistAndPoints& item2) {
|
||||
return item1.dist < item2.dist;
|
||||
});
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{it->dist, it->from, it->to});
|
||||
auto it = std::min_element(distances.begin(), distances.end(), [](const DistAndPoints &item1, const DistAndPoints &item2) { return item1.dist < item2.dist; });
|
||||
if (deal_circle_result == false) {
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{it->dist, it->from, it->to});
|
||||
}
|
||||
else{
|
||||
const double dist = (it->from - center).norm();
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{dist, it->from, center});
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||
assert(measuring != nullptr);
|
||||
|
||||
const auto [from, to] = f1.get_edge();
|
||||
const auto [idx, normal, origin] = f2.get_plane();
|
||||
|
||||
@@ -944,9 +976,9 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{ it->dist, it->from, it->to });
|
||||
}
|
||||
else {
|
||||
const std::vector<SurfaceFeature>& plane_features = measuring->get_plane_features(idx);
|
||||
auto plane_features = f2.world_plane_features;
|
||||
std::vector<DistAndPoints> distances;
|
||||
for (const SurfaceFeature& sf : plane_features) {
|
||||
for (const SurfaceFeature& sf : *plane_features) {
|
||||
if (sf.get_type() == SurfaceFeatureType::Edge) {
|
||||
const auto m = get_measurement(sf, f1);
|
||||
if (!m.distance_infinite.has_value()) {
|
||||
@@ -975,7 +1007,7 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
const auto [c0, r0, n0] = f1.get_circle();
|
||||
const auto [c1, r1, n1] = f2.get_circle();
|
||||
|
||||
// The following code is an adaptation of the algorithm found in:
|
||||
// The following code is an adaptation of the algorithm found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/DistCircle3Circle3.h
|
||||
// and described in:
|
||||
// https://www.geometrictools.com/Documentation/DistanceToCircle3.pdf
|
||||
@@ -1120,7 +1152,7 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
}
|
||||
else {
|
||||
ClosestInfo& info = candidates[0];
|
||||
|
||||
|
||||
const double N0dD = n0.dot(D);
|
||||
const Vec3d normProj = N0dD * n0;
|
||||
const Vec3d compProj = D - normProj;
|
||||
@@ -1185,22 +1217,26 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
}
|
||||
}
|
||||
|
||||
info.sqrDistance = distance * distance + N0dD * N0dD;
|
||||
info.sqrDistance = distance * distance;
|
||||
}
|
||||
if (deal_circle_result == false) {
|
||||
result.distance_infinite = std::make_optional(
|
||||
DistAndPoints{std::sqrt(candidates[0].sqrDistance), candidates[0].circle0Closest, candidates[0].circle1Closest}); // TODO
|
||||
} else {
|
||||
const double dist = (c0 - c1).norm();
|
||||
result.distance_strict = std::make_optional(DistAndPoints{dist, c0, c1});
|
||||
}
|
||||
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{ std::sqrt(candidates[0].sqrDistance), candidates[0].circle0Closest, candidates[0].circle1Closest }); // TODO
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||
assert(measuring != nullptr);
|
||||
|
||||
const auto [center, radius, normal1] = f1.get_circle();
|
||||
const auto [idx2, normal2, origin2] = f2.get_plane();
|
||||
|
||||
const bool coplanar = are_parallel(normal1, normal2) && Eigen::Hyperplane<double, 3>(normal1, center).absDistance(origin2) < EPSILON;
|
||||
if (!coplanar) {
|
||||
const std::vector<SurfaceFeature>& plane_features = measuring->get_plane_features(idx2);
|
||||
auto plane_features = f2.world_plane_features;
|
||||
std::vector<DistAndPoints> distances;
|
||||
for (const SurfaceFeature& sf : plane_features) {
|
||||
for (const SurfaceFeature& sf : *plane_features) {
|
||||
if (sf.get_type() == SurfaceFeatureType::Edge) {
|
||||
const auto m = get_measurement(sf, f1);
|
||||
if (!m.distance_infinite.has_value()) {
|
||||
@@ -1218,6 +1254,13 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
});
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{ it->dist, it->from, it->to });
|
||||
}
|
||||
else {
|
||||
const Eigen::Hyperplane<double, 3> plane(normal2, origin2);
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{plane.absDistance(center), center, plane.projection(center)});
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.distance_strict = std::make_optional(DistAndPoints{0, center, origin2});
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -1229,23 +1272,159 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||
|
||||
if (are_parallel(normal1, normal2)) {
|
||||
// The planes are parallel, calculate distance.
|
||||
const Eigen::Hyperplane<double, 3> plane(normal1, pt1);
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{ plane.absDistance(pt2), pt2, plane.projection(pt2) }); // TODO
|
||||
const Eigen::Hyperplane<double, 3> plane(normal2, pt2);
|
||||
result.distance_infinite = std::make_optional(DistAndPoints{ plane.absDistance(pt1), pt1, plane.projection(pt1) });
|
||||
}
|
||||
else
|
||||
result.angle = angle_plane_plane(f1.get_plane(), f2.get_plane());
|
||||
}
|
||||
|
||||
|
||||
if (swap) {
|
||||
auto swap_dist_and_points = [](DistAndPoints& dp) {
|
||||
auto back = dp.to;
|
||||
dp.to = dp.from;
|
||||
dp.from = back;
|
||||
};
|
||||
if (result.distance_infinite.has_value()) {
|
||||
swap_dist_and_points(*result.distance_infinite);
|
||||
}
|
||||
if (result.distance_strict.has_value()) {
|
||||
swap_dist_and_points(*result.distance_strict);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool can_set_xyz_distance(const SurfaceFeature &a, const SurfaceFeature &b) {
|
||||
const bool swap = int(a.get_type()) > int(b.get_type());
|
||||
const SurfaceFeature &f1 = swap ? b : a;
|
||||
const SurfaceFeature &f2 = swap ? a : b;
|
||||
if (f1.get_type() == SurfaceFeatureType::Point){
|
||||
if (f2.get_type() == SurfaceFeatureType::Point) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (f1.get_type() == SurfaceFeatureType::Circle) {
|
||||
if (f2.get_type() == SurfaceFeatureType::Circle) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AssemblyAction get_assembly_action(const SurfaceFeature& a, const SurfaceFeature& b)
|
||||
{
|
||||
AssemblyAction action;
|
||||
const SurfaceFeature &f1 = a;
|
||||
const SurfaceFeature &f2 = b;
|
||||
if (f1.get_type() == SurfaceFeatureType::Plane) {
|
||||
action.can_set_feature_1_reverse_rotation = true;
|
||||
if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||
const auto [idx1, normal1, pt1] = f1.get_plane();
|
||||
const auto [idx2, normal2, pt2] = f2.get_plane();
|
||||
action.can_set_to_center_coincidence = true;
|
||||
action.can_set_feature_2_reverse_rotation = true;
|
||||
if (are_parallel(normal1, normal2)) {
|
||||
action.can_set_to_parallel = false;
|
||||
action.has_parallel_distance = true;
|
||||
action.can_around_center_of_faces = true;
|
||||
Vec3d proj_pt2;
|
||||
Measure::get_point_projection_to_plane(pt2, pt1, normal1, proj_pt2);
|
||||
action.parallel_distance = (pt2 - proj_pt2).norm();
|
||||
if ((pt2 - proj_pt2).dot(normal1) < 0) {
|
||||
action.parallel_distance = -action.parallel_distance;
|
||||
}
|
||||
action.angle_radian = 0;
|
||||
|
||||
} else {
|
||||
action.can_set_to_parallel = true;
|
||||
action.has_parallel_distance = false;
|
||||
action.can_around_center_of_faces = false;
|
||||
action.parallel_distance = 0;
|
||||
action.angle_radian = std::acos(std::clamp(normal2.dot(-normal1), -1.0, 1.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
void SurfaceFeature::translate(const Vec3d& displacement) {
|
||||
switch (get_type()) {
|
||||
case Measure::SurfaceFeatureType::Point: {
|
||||
m_pt1 = m_pt1 + displacement;
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Edge: {
|
||||
m_pt1 = m_pt1 + displacement;
|
||||
m_pt2 = m_pt2 + displacement;
|
||||
if (m_pt3.has_value()) { //extra_point()
|
||||
m_pt3 = *m_pt3 + displacement;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Plane: {
|
||||
//m_pt1 is normal;
|
||||
m_pt2 = m_pt2 + displacement;
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Circle: {
|
||||
m_pt1 = m_pt1 + displacement;
|
||||
// m_pt2 is normal;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceFeature::translate(const Transform3d &tran)
|
||||
{
|
||||
switch (get_type()) {
|
||||
case Measure::SurfaceFeatureType::Point: {
|
||||
m_pt1 = tran * m_pt1;
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Edge: {
|
||||
m_pt1 = tran * m_pt1;
|
||||
m_pt2 = tran * m_pt2;
|
||||
if (m_pt3.has_value()) { // extra_point()
|
||||
m_pt3 = tran * *m_pt3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Plane: {
|
||||
// m_pt1 is normal;
|
||||
Vec3d temp_pt1 = m_pt2 + m_pt1;
|
||||
temp_pt1 = tran * temp_pt1;
|
||||
m_pt2 = tran * m_pt2;
|
||||
m_pt1 = (temp_pt1 - m_pt2).normalized();
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Circle: {
|
||||
// m_pt1 is center;
|
||||
// m_pt2 is normal;
|
||||
auto local_normal = m_pt2;
|
||||
auto local_center = m_pt1;
|
||||
Vec3d temp_pt2 = local_normal + local_center;
|
||||
temp_pt2 = tran * temp_pt2;
|
||||
m_pt1 = tran * m_pt1;
|
||||
auto world_center = m_pt1;
|
||||
m_pt2 = (temp_pt2 - m_pt1).normalized();
|
||||
|
||||
|
||||
|
||||
} // namespace Measure
|
||||
auto calc_world_radius = [&local_center, &local_normal, &tran, &world_center](const Vec3d &pt, double &value) {
|
||||
Vec3d intersection_pt;
|
||||
get_point_projection_to_plane(pt, local_center, local_normal, intersection_pt);
|
||||
auto local_radius_pt = (intersection_pt - local_center).normalized() * value + local_center;
|
||||
auto radius_pt = tran * local_radius_pt;
|
||||
value = (radius_pt - world_center).norm();
|
||||
};
|
||||
//m_value is radius
|
||||
auto new_pt = get_one_point_in_plane(local_center, local_normal);
|
||||
calc_world_radius(new_pt, m_value);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}//namespace Measure
|
||||
} // namespace Slic3r
|
||||
|
||||
|
||||
@@ -6,18 +6,13 @@
|
||||
|
||||
#include "Point.hpp"
|
||||
|
||||
|
||||
struct indexed_triangle_set;
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class TriangleMesh;
|
||||
|
||||
namespace Measure {
|
||||
|
||||
|
||||
enum class SurfaceFeatureType : int {
|
||||
Undef = 0,
|
||||
Point = 1 << 0,
|
||||
@@ -26,22 +21,44 @@ enum class SurfaceFeatureType : int {
|
||||
Plane = 1 << 3
|
||||
};
|
||||
|
||||
class SurfaceFeature {
|
||||
bool get_point_projection_to_plane(const Vec3d &pt, const Vec3d &plane_origin, const Vec3d &plane_normal, Vec3d &intersection_pt);
|
||||
Vec3d get_one_point_in_plane(const Vec3d &plane_origin, const Vec3d &plane_normal);
|
||||
|
||||
class SurfaceFeature
|
||||
{
|
||||
public:
|
||||
SurfaceFeature(SurfaceFeatureType type, const Vec3d& pt1, const Vec3d& pt2, std::optional<Vec3d> pt3 = std::nullopt, double value = 0.0)
|
||||
: m_type(type), m_pt1(pt1), m_pt2(pt2), m_pt3(pt3), m_value(value) {}
|
||||
|
||||
explicit SurfaceFeature(const Vec3d& pt)
|
||||
SurfaceFeature(const Vec3d& pt)
|
||||
: m_type{SurfaceFeatureType::Point}, m_pt1{pt} {}
|
||||
|
||||
SurfaceFeature(const SurfaceFeature& sf){
|
||||
this->clone(sf);
|
||||
volume = sf.volume;
|
||||
plane_indices = sf.plane_indices;
|
||||
world_tran = sf.world_tran;
|
||||
world_plane_features = sf.world_plane_features;
|
||||
origin_surface_feature = sf.origin_surface_feature;
|
||||
}
|
||||
|
||||
void clone(const SurfaceFeature &sf)
|
||||
{
|
||||
m_type = sf.get_type();
|
||||
m_pt1 = sf.get_pt1();
|
||||
m_pt2 = sf.get_pt2();
|
||||
m_pt3 = sf.get_pt3();
|
||||
m_value = sf.get_value();
|
||||
}
|
||||
void translate(const Vec3d& displacement);
|
||||
void translate(const Transform3d& tran);
|
||||
// Get type of this feature.
|
||||
SurfaceFeatureType get_type() const { return m_type; }
|
||||
|
||||
// For points, return the point.
|
||||
Vec3d get_point() const { assert(m_type == SurfaceFeatureType::Point); return m_pt1; }
|
||||
|
||||
// For edges, return start and end.
|
||||
std::pair<Vec3d, Vec3d> get_edge() const { assert(m_type == SurfaceFeatureType::Edge); return std::make_pair(m_pt1, m_pt2); }
|
||||
std::pair<Vec3d, Vec3d> get_edge() const { assert(m_type == SurfaceFeatureType::Edge); return std::make_pair(m_pt1, m_pt2); }
|
||||
|
||||
// For circles, return center, radius and normal.
|
||||
std::tuple<Vec3d, double, Vec3d> get_circle() const { assert(m_type == SurfaceFeatureType::Circle); return std::make_tuple(m_pt1, m_value, m_pt2); }
|
||||
@@ -75,6 +92,17 @@ public:
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
void* volume{nullptr};
|
||||
std::vector<int>* plane_indices{nullptr};
|
||||
Transform3d world_tran;
|
||||
std::shared_ptr<std::vector<SurfaceFeature>> world_plane_features{nullptr};
|
||||
std::shared_ptr<SurfaceFeature> origin_surface_feature{nullptr};
|
||||
|
||||
Vec3d get_pt1() const{ return m_pt1; }
|
||||
Vec3d get_pt2() const { return m_pt2; }
|
||||
const std::optional<Vec3d>& get_pt3() const { return m_pt3; }
|
||||
double get_value() const { return m_value; }
|
||||
|
||||
private:
|
||||
SurfaceFeatureType m_type{ SurfaceFeatureType::Undef };
|
||||
Vec3d m_pt1{ Vec3d::Zero() };
|
||||
@@ -97,7 +125,7 @@ public:
|
||||
|
||||
// Given a face_idx where the mouse cursor points, return a feature that
|
||||
// should be highlighted (if any).
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point) const;
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point, const Transform3d & world_tran,bool only_select_plane) const;
|
||||
|
||||
// Return total number of planes.
|
||||
int get_num_of_planes() const;
|
||||
@@ -111,7 +139,7 @@ public:
|
||||
// Returns the mesh used for measuring
|
||||
const indexed_triangle_set& get_its() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
std::unique_ptr<MeasuringImpl> priv;
|
||||
};
|
||||
|
||||
@@ -152,7 +180,24 @@ struct MeasurementResult {
|
||||
};
|
||||
|
||||
// Returns distance/angle between two SurfaceFeatures.
|
||||
MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature& b, const Measuring* measuring = nullptr);
|
||||
MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature& b,bool deal_circle_result =false);
|
||||
bool can_set_xyz_distance(const SurfaceFeature &a, const SurfaceFeature &b);
|
||||
|
||||
struct AssemblyAction
|
||||
{
|
||||
bool can_set_to_parallel{false};
|
||||
bool can_set_to_center_coincidence{false};
|
||||
bool can_set_feature_1_reverse_rotation{false};
|
||||
bool can_set_feature_2_reverse_rotation{false};
|
||||
bool can_around_center_of_faces{false};
|
||||
bool has_parallel_distance{false};
|
||||
float parallel_distance;
|
||||
float angle_radian{0};
|
||||
Transform3d tran_for_parallel;
|
||||
Transform3d tran_for_center_coincidence;
|
||||
Transform3d tran_for_reverse_rotation;
|
||||
};
|
||||
AssemblyAction get_assembly_action(const SurfaceFeature &a, const SurfaceFeature &b);
|
||||
|
||||
inline Vec3d edge_direction(const Vec3d& from, const Vec3d& to) { return (to - from).normalized(); }
|
||||
inline Vec3d edge_direction(const std::pair<Vec3d, Vec3d>& e) { return edge_direction(e.first, e.second); }
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Slic3r {
|
||||
namespace Measure {
|
||||
|
||||
// Utility class used to calculate distance circle-circle
|
||||
// Adaptation of code found in:
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/Polynomial1.h
|
||||
|
||||
class Polynomial1
|
||||
@@ -174,7 +174,7 @@ inline Polynomial1 operator * (double scalar, const Polynomial1& p)
|
||||
}
|
||||
|
||||
// Utility class used to calculate distance circle-circle
|
||||
// Adaptation of code found in:
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/RootsPolynomial.h
|
||||
|
||||
class RootsPolynomial
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
return false;
|
||||
|
||||
if (tmin >= tmax)
|
||||
// Invalid ordering of interval endpoitns.
|
||||
// Invalid ordering of interval endpoitns.
|
||||
return false;
|
||||
|
||||
for (uint32_t i = 1; i <= maxIterations; ++i) {
|
||||
@@ -345,7 +345,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Adaptation of code found in:
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/Vector.h
|
||||
|
||||
// Construct a single vector orthogonal to the nonzero input vector. If
|
||||
|
||||
@@ -743,6 +743,7 @@ public:
|
||||
m_scene_raycaster.set_gizmos_on_top(value);
|
||||
}
|
||||
|
||||
float get_explosion_ratio() { return m_explosion_ratio; }
|
||||
void reset_explosion_ratio() { m_explosion_ratio = 1.0; }
|
||||
void on_change_color_mode(bool is_dark, bool reinit = true);
|
||||
const bool get_dark_mode_status() { return m_is_dark; }
|
||||
|
||||
@@ -1412,5 +1412,84 @@ GLModel::Geometry smooth_torus(unsigned int primary_resolution, unsigned int sec
|
||||
return data;
|
||||
}
|
||||
|
||||
GLModel::Geometry init_plane_data(const indexed_triangle_set& its, const std::vector<int>& triangle_indices, float normal_offset)
|
||||
{
|
||||
GLModel::Geometry init_data;
|
||||
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
|
||||
init_data.reserve_indices(3 * triangle_indices.size());
|
||||
init_data.reserve_vertices(3 * triangle_indices.size());
|
||||
unsigned int i = 0;
|
||||
for (int idx : triangle_indices) {
|
||||
Vec3f v0 = its.vertices[its.indices[idx][0]];
|
||||
Vec3f v1 = its.vertices[its.indices[idx][1]];
|
||||
Vec3f v2 = its.vertices[its.indices[idx][2]];
|
||||
const Vec3f n = (v1 - v0).cross(v2 - v0).normalized();
|
||||
if (std::abs(normal_offset) > 0.0) {
|
||||
v0 = v0 + n * normal_offset;
|
||||
v1 = v1 + n * normal_offset;
|
||||
v2 = v2 + n * normal_offset;
|
||||
}
|
||||
init_data.add_vertex(v0, n);
|
||||
init_data.add_vertex(v1, n);
|
||||
init_data.add_vertex(v2, n);
|
||||
init_data.add_triangle(i, i + 1, i + 2);
|
||||
i += 3;
|
||||
}
|
||||
|
||||
return init_data;
|
||||
}
|
||||
|
||||
GLModel::Geometry init_torus_data(unsigned int primary_resolution,
|
||||
unsigned int secondary_resolution,
|
||||
const Vec3f & center,
|
||||
float radius,
|
||||
float thickness,
|
||||
const Vec3f & model_axis,
|
||||
const Transform3f &world_trafo)
|
||||
{
|
||||
const unsigned int torus_sector_count = std::max<unsigned int>(4, primary_resolution);
|
||||
const unsigned int section_sector_count = std::max<unsigned int>(4, secondary_resolution);
|
||||
const float torus_sector_step = 2.0f * float(M_PI) / float(torus_sector_count);
|
||||
const float section_sector_step = 2.0f * float(M_PI) / float(section_sector_count);
|
||||
|
||||
GLModel::Geometry data;
|
||||
data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
|
||||
data.reserve_vertices(torus_sector_count * section_sector_count);
|
||||
data.reserve_indices(torus_sector_count * section_sector_count * 2 * 3);
|
||||
|
||||
// vertices
|
||||
const Transform3f local_to_world_matrix = world_trafo * Geometry::translation_transform(center.cast<double>()).cast<float>() *
|
||||
Eigen::Quaternion<float>::FromTwoVectors(Vec3f::UnitZ(), model_axis);
|
||||
for (unsigned int i = 0; i < torus_sector_count; ++i) {
|
||||
const float section_angle = torus_sector_step * i;
|
||||
const Vec3f radius_dir(std::cos(section_angle), std::sin(section_angle), 0.0f);
|
||||
const Vec3f local_section_center = radius * radius_dir;
|
||||
const Vec3f world_section_center = local_to_world_matrix * local_section_center;
|
||||
const Vec3f local_section_normal = local_section_center.normalized().cross(Vec3f::UnitZ()).normalized();
|
||||
const Vec3f world_section_normal = (Vec3f) (local_to_world_matrix.matrix().block(0, 0, 3, 3) * local_section_normal).normalized();
|
||||
const Vec3f base_v = thickness * radius_dir;
|
||||
for (unsigned int j = 0; j < section_sector_count; ++j) {
|
||||
const Vec3f v = Eigen::AngleAxisf(section_sector_step * j, world_section_normal) * base_v;
|
||||
data.add_vertex(world_section_center + v, (Vec3f) v.normalized());
|
||||
}
|
||||
}
|
||||
|
||||
// triangles
|
||||
for (unsigned int i = 0; i < torus_sector_count; ++i) {
|
||||
const unsigned int ii = i * section_sector_count;
|
||||
const unsigned int ii_next = ((i + 1) % torus_sector_count) * section_sector_count;
|
||||
for (unsigned int j = 0; j < section_sector_count; ++j) {
|
||||
const unsigned int j_next = (j + 1) % section_sector_count;
|
||||
const unsigned int i0 = ii + j;
|
||||
const unsigned int i1 = ii_next + j;
|
||||
const unsigned int i2 = ii_next + j_next;
|
||||
const unsigned int i3 = ii + j_next;
|
||||
data.add_triangle(i0, i1, i2);
|
||||
data.add_triangle(i0, i2, i3);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -247,7 +247,15 @@ namespace GUI {
|
||||
// the origin of the torus is in its center
|
||||
GLModel::Geometry smooth_torus(unsigned int primary_resolution, unsigned int secondary_resolution, float radius, float thickness);
|
||||
|
||||
} // namespace GUI
|
||||
GLModel::Geometry init_plane_data(const indexed_triangle_set &its, const std::vector<int> &triangle_indices,float normal_offset = 0.0f);
|
||||
GLModel::Geometry init_torus_data(unsigned int primary_resolution,
|
||||
unsigned int secondary_resolution,
|
||||
const Vec3f & center,
|
||||
float radius,
|
||||
float thickness,
|
||||
const Vec3f & model_axis,
|
||||
const Transform3f &world_trafo);
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_GLModel_hpp_
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "slic3r/GUI/GLModel.hpp"
|
||||
#include "slic3r/GUI/MeshUtils.hpp"
|
||||
#include "slic3r/GUI/SceneRaycaster.hpp"
|
||||
#include "slic3r/GUI/3DScene.hpp"
|
||||
|
||||
#include <cereal/archives/binary.hpp>
|
||||
|
||||
@@ -181,6 +182,13 @@ public:
|
||||
|
||||
virtual bool apply_clipping_plane() { return true; }
|
||||
|
||||
/// <summary>
|
||||
/// Implement when want to process mouse events in gizmo
|
||||
/// Click, Right click, move, drag, ...
|
||||
/// </summary>
|
||||
/// <param name="mouse_event">Keep information about mouse click</param>
|
||||
/// <returns>Return True when use the information and don't want to propagate it otherwise False.</returns>
|
||||
virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
|
||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||
|
||||
int get_hover_id() const { return m_hover_id; }
|
||||
@@ -209,14 +217,6 @@ public:
|
||||
/// </summary>
|
||||
virtual void data_changed(bool is_serializing){};
|
||||
|
||||
/// <summary>
|
||||
/// Implement when want to process mouse events in gizmo
|
||||
/// Click, Right click, move, drag, ...
|
||||
/// </summary>
|
||||
/// <param name="mouse_event">Keep information about mouse click</param>
|
||||
/// <returns>Return True when use the information and don't want to propagate it otherwise False.</returns>
|
||||
virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
|
||||
|
||||
void register_raycasters_for_picking() { register_grabbers_for_picking(); on_register_raycasters_for_picking(); }
|
||||
void unregister_raycasters_for_picking() { unregister_grabbers_for_picking(); on_unregister_raycasters_for_picking(); }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,16 +12,85 @@
|
||||
namespace Slic3r {
|
||||
|
||||
enum class ModelVolumeType : int;
|
||||
|
||||
namespace Measure { class Measuring; }
|
||||
|
||||
|
||||
namespace GUI {
|
||||
|
||||
enum class SLAGizmoEventType : unsigned char;
|
||||
enum class EMeasureMode : unsigned char {
|
||||
ONLY_MEASURE,
|
||||
ONLY_ASSEMBLY
|
||||
};
|
||||
enum class AssemblyMode : unsigned char {
|
||||
FACE_FACE,
|
||||
POINT_POINT,
|
||||
};
|
||||
static const Slic3r::ColorRGBA SELECTED_1ST_COLOR = {0.25f, 0.75f, 0.75f, 1.0f};
|
||||
static const Slic3r::ColorRGBA SELECTED_2ND_COLOR = {0.75f, 0.25f, 0.75f, 1.0f};
|
||||
static const Slic3r::ColorRGBA NEUTRAL_COLOR = {0.5f, 0.5f, 0.5f, 1.0f};
|
||||
static const Slic3r::ColorRGBA HOVER_COLOR = ColorRGBA::GREEN();
|
||||
|
||||
static const int POINT_ID = 100;
|
||||
static const int EDGE_ID = 200;
|
||||
static const int CIRCLE_ID = 300;
|
||||
static const int PLANE_ID = 400;
|
||||
static const int SEL_SPHERE_1_ID = 501;
|
||||
static const int SEL_SPHERE_2_ID = 502;
|
||||
|
||||
static const float TRIANGLE_BASE = 10.0f;
|
||||
static const float TRIANGLE_HEIGHT = TRIANGLE_BASE * 1.618033f;
|
||||
|
||||
static const std::string CTRL_STR =
|
||||
#ifdef __APPLE__
|
||||
"⌘"
|
||||
#else
|
||||
"Ctrl"
|
||||
#endif //__APPLE__
|
||||
;
|
||||
|
||||
class TransformHelper
|
||||
{
|
||||
struct Cache
|
||||
{
|
||||
std::array<int, 4> viewport;
|
||||
Matrix4d ndc_to_ss_matrix;
|
||||
Transform3d ndc_to_ss_matrix_inverse;
|
||||
};
|
||||
static Cache s_cache;
|
||||
|
||||
public:
|
||||
static Vec3d model_to_world(const Vec3d &model, const Transform3d &world_matrix);
|
||||
static Vec4d world_to_clip(const Vec3d &world, const Matrix4d &projection_view_matrix);
|
||||
static Vec3d clip_to_ndc(const Vec4d &clip);
|
||||
static Vec2d ndc_to_ss(const Vec3d &ndc, const std::array<int, 4> &viewport);
|
||||
static Vec4d model_to_clip(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix);
|
||||
static Vec3d model_to_ndc(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix);
|
||||
static Vec2d model_to_ss(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix, const std::array<int, 4> &viewport);
|
||||
static Vec2d world_to_ss(const Vec3d &world, const Matrix4d &projection_view_matrix, const std::array<int, 4> &viewport);
|
||||
static const Matrix4d & ndc_to_ss_matrix(const std::array<int, 4> &viewport);
|
||||
static const Transform3d ndc_to_ss_matrix_inverse(const std::array<int, 4> &viewport);
|
||||
|
||||
private:
|
||||
static void update(const std::array<int, 4> &viewport);
|
||||
};
|
||||
|
||||
class GLGizmoMeasure : public GLGizmoBase
|
||||
{
|
||||
protected:
|
||||
using PickRaycaster = SceneRaycasterItem;
|
||||
enum GripperType {
|
||||
UNDEFINE,
|
||||
POINT,
|
||||
EDGE,
|
||||
CIRCLE,
|
||||
CIRCLE_1,
|
||||
CIRCLE_2,
|
||||
PLANE,
|
||||
PLANE_1,
|
||||
PLANE_2,
|
||||
SPHERE_1,
|
||||
SPHERE_2,
|
||||
};
|
||||
|
||||
enum class EMode : unsigned char
|
||||
{
|
||||
FeatureSelection,
|
||||
@@ -69,30 +138,49 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
}
|
||||
};
|
||||
|
||||
struct VolumeCacheItem
|
||||
{
|
||||
const ModelObject* object{ nullptr };
|
||||
const ModelInstance* instance{ nullptr };
|
||||
const ModelVolume* volume{ nullptr };
|
||||
Transform3d world_trafo;
|
||||
//struct VolumeCacheItem
|
||||
//{
|
||||
// const ModelObject* object{ nullptr };
|
||||
// const ModelInstance* instance{ nullptr };
|
||||
// const ModelVolume* volume{ nullptr };
|
||||
// Transform3d world_trafo;
|
||||
|
||||
bool operator == (const VolumeCacheItem& other) const {
|
||||
return this->object == other.object && this->instance == other.instance && this->volume == other.volume &&
|
||||
this->world_trafo.isApprox(other.world_trafo);
|
||||
}
|
||||
};
|
||||
// bool operator == (const VolumeCacheItem& other) const {
|
||||
// return this->object == other.object && this->instance == other.instance && this->volume == other.volume &&
|
||||
// this->world_trafo.isApprox(other.world_trafo);
|
||||
// }
|
||||
//};
|
||||
|
||||
std::vector<VolumeCacheItem> m_volumes_cache;
|
||||
//std::vector<VolumeCacheItem> m_volumes_cache;
|
||||
|
||||
EMode m_mode{ EMode::FeatureSelection };
|
||||
Measure::MeasurementResult m_measurement_result;
|
||||
std::map<GLVolume*, std::shared_ptr<Measure::Measuring>> m_mesh_measure_map;
|
||||
std::shared_ptr<Measure::Measuring> m_curr_measuring{nullptr};
|
||||
|
||||
std::unique_ptr<Measure::Measuring> m_measuring; // PIMPL
|
||||
|
||||
//first feature
|
||||
PickingModel m_sphere;
|
||||
PickingModel m_cylinder;
|
||||
PickingModel m_circle;
|
||||
PickingModel m_plane;
|
||||
struct CircleGLModel
|
||||
{
|
||||
PickingModel circle;
|
||||
Measure::SurfaceFeature *last_circle_feature{nullptr};
|
||||
float inv_zoom{0};
|
||||
};
|
||||
CircleGLModel m_curr_circle;
|
||||
CircleGLModel m_feature_circle_first;
|
||||
CircleGLModel m_feature_circle_second;
|
||||
void init_circle_glmodel(GripperType gripper_type, const Measure::SurfaceFeature &feature, CircleGLModel &circle_gl_model, float inv_zoom);
|
||||
|
||||
struct PlaneGLModel {
|
||||
int plane_idx{0};
|
||||
PickingModel plane;
|
||||
};
|
||||
PlaneGLModel m_curr_plane;
|
||||
PlaneGLModel m_feature_plane_first;
|
||||
PlaneGLModel m_feature_plane_second;
|
||||
void init_plane_glmodel(GripperType gripper_type, const Measure::SurfaceFeature &feature, PlaneGLModel &plane_gl_model);
|
||||
|
||||
struct Dimensioning
|
||||
{
|
||||
GLModel line;
|
||||
@@ -101,40 +189,36 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
};
|
||||
Dimensioning m_dimensioning;
|
||||
|
||||
// Uses a standalone raycaster and not the shared one because of the
|
||||
// difference in how the mesh is updated
|
||||
std::unique_ptr<MeshRaycaster> m_raycaster;
|
||||
|
||||
std::vector<GLModel> m_plane_models_cache;
|
||||
std::map<int, std::shared_ptr<SceneRaycasterItem>> m_raycasters;
|
||||
std::map<GLVolume*, std::shared_ptr<PickRaycaster>> m_mesh_raycaster_map;
|
||||
std::map<GripperType, std::shared_ptr<PickRaycaster>> m_gripper_id_raycast_map;
|
||||
std::vector<GLVolume*> m_hit_different_volumes;
|
||||
std::vector<GLVolume*> m_hit_order_volumes;
|
||||
GLVolume* m_last_hit_volume;
|
||||
//std::vector<std::shared_ptr<GLModel>> m_plane_models_cache;
|
||||
unsigned int m_last_active_item_imgui{0};
|
||||
Vec3d m_buffered_distance;
|
||||
Vec3d m_distance;
|
||||
// used to keep the raycasters for point/center spheres
|
||||
std::vector<std::shared_ptr<SceneRaycasterItem>> m_selected_sphere_raycasters;
|
||||
//std::vector<std::shared_ptr<PickRaycaster>> m_selected_sphere_raycasters;
|
||||
std::optional<Measure::SurfaceFeature> m_curr_feature;
|
||||
std::optional<Vec3d> m_curr_point_on_feature_position;
|
||||
struct SceneRaycasterState
|
||||
{
|
||||
std::shared_ptr<SceneRaycasterItem> raycaster{ nullptr };
|
||||
bool state{true};
|
||||
|
||||
};
|
||||
std::vector<SceneRaycasterState> m_scene_raycasters;
|
||||
|
||||
// These hold information to decide whether recalculation is necessary:
|
||||
float m_last_inv_zoom{ 0.0f };
|
||||
std::optional<Measure::SurfaceFeature> m_last_circle;
|
||||
std::optional<Measure::SurfaceFeature> m_last_circle_feature;
|
||||
int m_last_plane_idx{ -1 };
|
||||
|
||||
bool m_mouse_left_down{ false }; // for detection left_up of this gizmo
|
||||
|
||||
Vec2d m_mouse_pos{ Vec2d::Zero() };
|
||||
bool m_mouse_left_down_mesh_deal{false};//for pick mesh
|
||||
|
||||
KeyAutoRepeatFilter m_shift_kar_filter;
|
||||
|
||||
SelectedFeatures m_selected_features;
|
||||
bool m_pending_scale{ false };
|
||||
int m_pending_scale{ 0 };
|
||||
bool m_set_center_coincidence{false};
|
||||
bool m_editing_distance{ false };
|
||||
bool m_is_editing_distance_first_frame{ true };
|
||||
|
||||
bool m_can_set_xyz_distance{false};
|
||||
void update_if_needed();
|
||||
|
||||
void disable_scene_raycasters();
|
||||
@@ -148,7 +232,6 @@ class GLGizmoMeasure : public GLGizmoBase
|
||||
|
||||
public:
|
||||
GLGizmoMeasure(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
|
||||
/// <summary>
|
||||
/// Apply rotation on select plane
|
||||
/// </summary>
|
||||
@@ -158,12 +241,12 @@ public:
|
||||
|
||||
void data_changed(bool is_serializing) override;
|
||||
|
||||
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||
virtual bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||
|
||||
bool wants_enter_leave_snapshots() const override { return true; }
|
||||
std::string get_gizmo_entering_text() const override { return _u8L("Entering Measure gizmo"); }
|
||||
std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Measure gizmo"); }
|
||||
std::string get_action_snapshot_name() const override { return _u8L("Measure gizmo editing"); }
|
||||
//std::string get_action_snapshot_name() const override { return _u8L("Measure gizmo editing"); }
|
||||
|
||||
protected:
|
||||
bool on_init() override;
|
||||
@@ -172,20 +255,56 @@ protected:
|
||||
void on_render() override;
|
||||
void on_set_state() override;
|
||||
|
||||
//virtual void on_render_for_picking() override;
|
||||
void show_selection_ui();
|
||||
void show_distance_xyz_ui();
|
||||
//void show_point_point_assembly();
|
||||
void init_render_input_window();
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
virtual void on_register_raycasters_for_picking() override;
|
||||
virtual void on_unregister_raycasters_for_picking() override;
|
||||
|
||||
void remove_selected_sphere_raycaster(int id);
|
||||
void update_measurement_result();
|
||||
|
||||
// Orca
|
||||
void show_tooltip_information(float caption_max, float x, float y);
|
||||
void reset_all_pick();
|
||||
void reset_gripper_pick(GripperType id,bool is_all = false);
|
||||
void register_single_mesh_pick();
|
||||
//void update_single_mesh_pick(GLVolume* v);
|
||||
|
||||
private:
|
||||
std::string format_double(double value);
|
||||
std::string format_vec3(const Vec3d &v);
|
||||
std::string surface_feature_type_as_string(Measure::SurfaceFeatureType type);
|
||||
std::string point_on_feature_type_as_string(Measure::SurfaceFeatureType type, int hover_id);
|
||||
std::string center_on_feature_type_as_string(Measure::SurfaceFeatureType type);
|
||||
bool is_feature_with_center(const Measure::SurfaceFeature &feature);
|
||||
Vec3d get_feature_offset(const Measure::SurfaceFeature &feature);
|
||||
|
||||
void reset_all_feature();
|
||||
void reset_feature1_render();
|
||||
void reset_feature2_render();
|
||||
void reset_feature1();
|
||||
void reset_feature2();
|
||||
bool is_two_volume_in_same_model_object();
|
||||
Measure::Measuring* get_measuring_of_mesh(GLVolume *v, Transform3d &tran);
|
||||
void update_world_plane_features(Measure::Measuring *cur_measuring, Measure::SurfaceFeature &feautre);
|
||||
void update_feature_by_tran(Measure::SurfaceFeature & feature);
|
||||
void set_distance(bool same_model_object, const Vec3d &displacement, bool take_shot = true);
|
||||
protected:
|
||||
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
||||
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
||||
std::map<std::string, wxString> m_desc;
|
||||
bool m_show_reset_first_tip{false};
|
||||
bool m_selected_wrong_feature_waring_tip{false};
|
||||
EMeasureMode m_measure_mode{EMeasureMode::ONLY_MEASURE};
|
||||
AssemblyMode m_assembly_mode{AssemblyMode::FACE_FACE};
|
||||
bool m_flip_volume_2{false};
|
||||
float m_space_size;
|
||||
float m_input_size_max;
|
||||
bool m_use_inches;
|
||||
bool m_only_select_plane{false};
|
||||
std::string m_units;
|
||||
mutable bool m_same_model_object;
|
||||
mutable unsigned int m_current_active_imgui_id;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
||||
@@ -61,7 +61,8 @@ std::vector<size_t> GLGizmosManager::get_selectable_idxs() const
|
||||
out.reserve(m_gizmos.size());
|
||||
if (m_parent.get_canvas_type() == GLCanvas3D::CanvasAssembleView) {
|
||||
for (size_t i = 0; i < m_gizmos.size(); ++i)
|
||||
if (m_gizmos[i]->get_sprite_id() == (unsigned int)MmuSegmentation)
|
||||
if (m_gizmos[i]->get_sprite_id() == (unsigned int) Measure ||
|
||||
m_gizmos[i]->get_sprite_id() == (unsigned int) MmuSegmentation)
|
||||
out.push_back(i);
|
||||
}
|
||||
else {
|
||||
@@ -158,7 +159,7 @@ void GLGizmosManager::switch_gizmos_icon_filename()
|
||||
case(EType::MeshBoolean):
|
||||
gizmo->set_icon_filename(m_is_dark ? "toolbar_meshboolean_dark.svg" : "toolbar_meshboolean.svg");
|
||||
break;
|
||||
case(EType::Measure):
|
||||
case (EType::Measure):
|
||||
gizmo->set_icon_filename(m_is_dark ? "toolbar_measure_dark.svg" : "toolbar_measure.svg");
|
||||
break;
|
||||
}
|
||||
@@ -342,6 +343,8 @@ bool GLGizmosManager::check_gizmos_closed_except(EType type) const
|
||||
|
||||
void GLGizmosManager::set_hover_id(int id)
|
||||
{
|
||||
// Measure handles hover by itself
|
||||
if (m_current == EType::Measure) { return; }
|
||||
if (!m_enabled || m_current == Undefined)
|
||||
return;
|
||||
|
||||
@@ -703,14 +706,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WXK_BACK:
|
||||
case WXK_DELETE:
|
||||
{
|
||||
if ((m_current == Cut || m_current == Measure) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
processed = true;
|
||||
|
||||
break;
|
||||
}
|
||||
//skip some keys when gizmo
|
||||
case 'A':
|
||||
case 'a':
|
||||
{
|
||||
@@ -737,14 +733,12 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
||||
//}
|
||||
|
||||
|
||||
//case WXK_BACK:
|
||||
//case WXK_DELETE:
|
||||
//{
|
||||
// if ((m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
// processed = true;
|
||||
|
||||
// break;
|
||||
//}
|
||||
case WXK_BACK:
|
||||
case WXK_DELETE: {
|
||||
if ((m_current == Cut || m_current == Measure) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
//case 'A':
|
||||
//case 'a':
|
||||
//{
|
||||
@@ -845,7 +839,6 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||
else if (keyCode == WXK_SHIFT)
|
||||
gizmo_event(SLAGizmoEventType::ShiftUp, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||
}
|
||||
|
||||
// if (processed)
|
||||
// m_parent.set_cursor(GLCanvas3D::Standard);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,9 @@ const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
||||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = COL_BUTTON_HOVERED;
|
||||
|
||||
//BBS
|
||||
|
||||
const ImVec4 ImGuiWrapper::COL_RED = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_GREEN = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_BLUE = ImVec4(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = ImVec4(0.122f, 0.557f, 0.918f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_GREEN_LIGHT = { 0.f, 156 / 255.f, 136 / 255.f, 0.25f }; // ORCA used on various places like text selection bg. Replaced with orca color
|
||||
const ImVec4 ImGuiWrapper::COL_HOVER = { 0.933f, 0.933f, 0.933f, 1.0f };
|
||||
@@ -856,6 +858,10 @@ bool ImGuiWrapper::radio_button(const wxString &label, bool active)
|
||||
return ImGui::RadioButton(label_utf8.c_str(), active);
|
||||
}
|
||||
|
||||
ImVec4 ImGuiWrapper::to_ImVec4(const ColorRGB &color) {
|
||||
return {color.r(), color.g(), color.b(), 1.0};
|
||||
}
|
||||
|
||||
bool ImGuiWrapper::input_double(const std::string &label, const double &value, const std::string &format)
|
||||
{
|
||||
return ImGui::InputDouble(label.c_str(), const_cast<double*>(&value), 0.0f, 0.0f, format.c_str(), ImGuiInputTextFlags_CharsDecimal);
|
||||
@@ -943,6 +949,19 @@ void ImGuiWrapper::text(const wxString &label)
|
||||
ImGuiWrapper::text(label_utf8.c_str());
|
||||
}
|
||||
|
||||
void ImGuiWrapper::warning_text(const char *label)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiWrapper::to_ImVec4(ColorRGB::WARNING()));
|
||||
this->text(label);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void ImGuiWrapper::warning_text(const wxString &all_text)
|
||||
{
|
||||
auto label_utf8 = into_u8(all_text);
|
||||
warning_text(label_utf8.c_str());
|
||||
}
|
||||
|
||||
void ImGuiWrapper::text_colored(const ImVec4& color, const char* label)
|
||||
{
|
||||
ImGui::TextColored(color, "%s", label);
|
||||
|
||||
@@ -134,6 +134,7 @@ public:
|
||||
bool button(const wxString& label, float width, float height);
|
||||
bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f)
|
||||
bool radio_button(const wxString &label, bool active);
|
||||
static ImVec4 to_ImVec4(const ColorRGB &color);
|
||||
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");
|
||||
bool input_double(const wxString &label, const double &value, const std::string &format = "%.3f");
|
||||
bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f");
|
||||
@@ -144,6 +145,8 @@ public:
|
||||
static void text(const char *label);
|
||||
static void text(const std::string &label);
|
||||
static void text(const wxString &label);
|
||||
void warning_text(const char *all_text);
|
||||
void warning_text(const wxString &all_text);
|
||||
static void text_colored(const ImVec4& color, const char* label);
|
||||
static void text_colored(const ImVec4& color, const std::string& label);
|
||||
static void text_colored(const ImVec4& color, const wxString& label);
|
||||
@@ -323,6 +326,9 @@ public:
|
||||
static const ImVec4 COL_BUTTON_ACTIVE;
|
||||
|
||||
//BBS add more colors
|
||||
static const ImVec4 COL_RED;
|
||||
static const ImVec4 COL_GREEN;
|
||||
static const ImVec4 COL_BLUE;
|
||||
static const ImVec4 COL_BLUE_LIGHT;
|
||||
static const ImVec4 COL_GREEN_LIGHT;
|
||||
static const ImVec4 COL_HOVER;
|
||||
|
||||
@@ -21,6 +21,9 @@ class SceneRaycasterItem
|
||||
Transform3d m_trafo;
|
||||
|
||||
public:
|
||||
SceneRaycasterItem(int id, const MeshRaycaster& raycaster)
|
||||
: m_id(id), m_raycaster(&raycaster), m_trafo(Transform3d::Identity()), m_use_back_faces(false)
|
||||
{}
|
||||
SceneRaycasterItem(int id, const MeshRaycaster& raycaster, const Transform3d& trafo, bool use_back_faces = false)
|
||||
: m_id(id), m_raycaster(&raycaster), m_trafo(trafo), m_use_back_faces(use_back_faces)
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user