Fix test
+ Comment debug output + Add was_canceled in cut surface
This commit is contained in:
parent
6d4830823e
commit
8343e81053
@ -91,18 +91,19 @@ inline AABBTreeIndirect::Tree<2, typename LineType::Scalar> build_aabb_tree_over
|
||||
// Finding a closest line, its closest point and squared distance to the closest point
|
||||
// Returns squared distance to the closest point or -1 if the input is empty.
|
||||
// or no closer point than max_sq_dist
|
||||
template<typename LineType, typename TreeType, typename VectorType, typename Scalar = typename VectorType::Scalar>
|
||||
inline typename Scalar squared_distance_to_indexed_lines(const std::vector<LineType> &lines,
|
||||
const TreeType &tree,
|
||||
const VectorType &point,
|
||||
size_t &hit_idx_out,
|
||||
Eigen::PlainObjectBase<VectorType> &hit_point_out,
|
||||
Scalar max_sqr_dist = std::numeric_limits<Scalar>::infinity())
|
||||
template<typename LineType, typename TreeType, typename VectorType>
|
||||
inline typename VectorType::Scalar squared_distance_to_indexed_lines(
|
||||
const std::vector<LineType> &lines,
|
||||
const TreeType &tree,
|
||||
const VectorType &point,
|
||||
size_t &hit_idx_out,
|
||||
Eigen::PlainObjectBase<VectorType> &hit_point_out,
|
||||
typename VectorType::Scalar max_sqr_dist = std::numeric_limits<typename VectorType::Scalar>::infinity())
|
||||
{
|
||||
if (tree.empty()) return Scalar(-1);
|
||||
if (tree.empty()) return VectorType::Scalar(-1);
|
||||
auto distancer = detail::IndexedLinesDistancer<LineType, TreeType, VectorType>{lines, tree, point};
|
||||
return AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive(
|
||||
distancer, size_t(0), Scalar(0), max_sqr_dist, hit_idx_out, hit_point_out);
|
||||
distancer, size_t(0), VectorType::Scalar(0), max_sqr_dist, hit_idx_out, hit_point_out);
|
||||
}
|
||||
|
||||
// Returns all lines within the given radius limit
|
||||
|
@ -20,7 +20,7 @@
|
||||
/// patches/patch{O}.off
|
||||
/// result.obj - Merged result its
|
||||
/// result_contours/{O}.obj - visualization of contours for result patches
|
||||
#define DEBUG_OUTPUT_DIR std::string("C:/data/temp/cutSurface/")
|
||||
//#define DEBUG_OUTPUT_DIR std::string("C:/data/temp/cutSurface/")
|
||||
|
||||
using namespace Slic3r;
|
||||
#include "ExPolygonsIndex.hpp"
|
||||
@ -1058,7 +1058,7 @@ priv::CutMesh priv::to_cgal(const ExPolygons &shapes,
|
||||
for (const Polygon &hole : shape.holes)
|
||||
insert_contour(hole);
|
||||
}
|
||||
assert(!exist_duplicit_point(result));
|
||||
assert(!exist_duplicit_vertex(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3209,8 +3209,6 @@ std::vector<bool> priv::select_patches(const ProjectionDistances &best_distances
|
||||
for (uint32_t patch_index : used_shape_patches) {
|
||||
ExPolygon patch_area = to_expoly(patches[patch_index], projection);
|
||||
//*/
|
||||
// add save offset extension to cover numerical mistake made by back projection to 2d
|
||||
const float extend_delta = 5.f;
|
||||
ExPolygons patch_areas = offset_ex(patch_area, extend_delta);
|
||||
fill.insert(fill.end(), patch_areas.begin(), patch_areas.end());
|
||||
/*/
|
||||
|
@ -43,7 +43,6 @@ Point to_point(const stbtt__point &point);
|
||||
bool remove_same_neighbor(Slic3r::Points &points);
|
||||
bool remove_same_neighbor(Slic3r::Polygons &polygons);
|
||||
bool remove_same_neighbor(ExPolygons &expolygons);
|
||||
bool divide_segments_for_close_point(ExPolygons &expolygons, double distance = .6);
|
||||
|
||||
// NOTE: expolygons can't contain same_neighbor
|
||||
Points collect_close_points(const ExPolygons &expolygons, double distance = .6);
|
||||
@ -173,13 +172,13 @@ Points priv::collect_close_points(const ExPolygons &expolygons, double distance)
|
||||
return res;
|
||||
}
|
||||
|
||||
bool priv::divide_segments_for_close_point(ExPolygons &expolygons, double distance)
|
||||
bool Emboss::divide_segments_for_close_point(ExPolygons &expolygons, double distance)
|
||||
{
|
||||
if (expolygons.empty()) return false;
|
||||
if (distance < 0.) return false;
|
||||
|
||||
// ExPolygons can't contain same neigbours
|
||||
remove_same_neighbor(expolygons);
|
||||
priv::remove_same_neighbor(expolygons);
|
||||
|
||||
// IMPROVE: use int(insted of double) lines and tree
|
||||
const ExPolygonsIndices ids(expolygons);
|
||||
|
@ -177,6 +177,17 @@ public:
|
||||
/// <returns>True when shapes is good otherwise False</returns>
|
||||
static bool heal_shape(ExPolygons &shape, unsigned max_iteration = 10);
|
||||
|
||||
/// <summary>
|
||||
/// Divide line segments in place near to point
|
||||
/// (which could lead to self intersection due to preccision)
|
||||
/// Remove same neighbors
|
||||
/// Note: Possible part of heal shape
|
||||
/// </summary>
|
||||
/// <param name="expolygons">Expolygon to edit</param>
|
||||
/// <param name="distance">(epsilon)Euclidean distance from point to line which divide line</param>
|
||||
/// <returns>True when some division was made otherwise false</returns>
|
||||
static bool divide_segments_for_close_point(ExPolygons &expolygons, double distance);
|
||||
|
||||
/// <summary>
|
||||
/// Use data from font property to modify transformation
|
||||
/// </summary>
|
||||
|
@ -356,7 +356,7 @@ void UseSurfaceJob::process(Ctl &ctl) {
|
||||
const TextConfiguration &tc = m_input.text_configuration;
|
||||
const char *text = tc.text.c_str();
|
||||
const FontProp &fp = tc.style.prop;
|
||||
ExPolygons shapes = Emboss::text2shapes(m_input.font_file, text, fp);
|
||||
ExPolygons shapes = Emboss::text2shapes(m_input.font_file, text, fp, was_canceled);
|
||||
if (shapes.empty() || shapes.front().contour.empty())
|
||||
throw priv::EmbossJobException(
|
||||
_u8L("Font doesn't have any shape for given text.").c_str());
|
||||
|
@ -283,9 +283,9 @@ TEST_CASE("Heal of points close to line", "[Emboss]")
|
||||
Polygon polygon = polygons.front();
|
||||
polygon.points.pop_back();// NSVG put first point as last one when polygon is closed
|
||||
ExPolygons expoly({ExPolygon(polygon)});
|
||||
Emboss::heal_shape(expoly);
|
||||
CHECK(Emboss::divide_segments_for_close_point(expoly, .6));
|
||||
//{ SVG svg("C:/data/temp/healed.svg"); svg.draw(expoly);}
|
||||
CHECK(expoly.size() == 3);
|
||||
CHECK(to_points(expoly).size() >= (to_points(polygon).size() + 2));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert text with glyph cache to model", "[Emboss]")
|
||||
|
Loading…
Reference in New Issue
Block a user