Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2021-07-18 22:10:34 +0300
committerHoward Trickey <howard.trickey@gmail.com>2021-07-18 22:10:34 +0300
commit72d1ddfc9ce44afcf39226aa035249e2c29c1f5e (patch)
tree243190fd32cac2d8765937e2a2f4e7fefe454f28 /source/blender/blenlib/tests
parent4ed029fc02b022cb5ff28ed3ce70992c450d2be5 (diff)
Make it optional to track input->output mapping in delaunay_2d_calc.
Some uses of delaunay_2d_calc don't need to know the original verts, edges, and faces that correspond to output elements. This change adds a "need_ids" value to the CDT input spec, default true, which tracks the input ids only when true. The python api mathutils.geometry.delaunay_2d_cdt gets an optional final bool argument that is the value of need_ids. If the argument is not supplied, it is true by default, so this won't break old uses of the API. On a sample text test, not tracking ids save about 30% of the runtime. For most inputs the difference will not be so dramatic: it only really kicks in if there are a lot of holes.
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 9356201063b..bc6b7e9fe4e 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -1763,7 +1763,8 @@ TEST(delaunay_d, CintTwoFace)
#if DO_TEXT_TESTS
template<typename T>
-void text_test(int num_arc_points, int num_lets_per_line, int num_lines, CDT_output_type otype)
+void text_test(
+ int num_arc_points, int num_lets_per_line, int num_lines, CDT_output_type otype, bool need_ids)
{
constexpr bool print_timing = true;
/*
@@ -1902,12 +1903,18 @@ void text_test(int num_arc_points, int num_lets_per_line, int num_lines, CDT_out
}
}
in.epsilon = b_before_arcs_in.epsilon;
+ in.need_ids = need_ids;
double tstart = PIL_check_seconds_timer();
CDT_result<T> out = delaunay_2d_calc(in, otype);
double tend = PIL_check_seconds_timer();
if (print_timing) {
std::cout << "time = " << tend - tstart << "\n";
}
+ if (!need_ids) {
+ EXPECT_EQ(out.vert_orig.size(), 0);
+ EXPECT_EQ(out.edge_orig.size(), 0);
+ EXPECT_EQ(out.face_orig.size(), 0);
+ }
if (DO_DRAW) {
std::string label = "Text arcpts=" + std::to_string(num_arc_points);
if (num_lets_per_line > 1) {
@@ -1922,33 +1929,43 @@ void text_test(int num_arc_points, int num_lets_per_line, int num_lines, CDT_out
TEST(delaunay_d, TextB10)
{
- text_test<double>(10, 1, 1, CDT_INSIDE_WITH_HOLES);
+ text_test<double>(10, 1, 1, CDT_INSIDE_WITH_HOLES, true);
}
TEST(delaunay_d, TextB200)
{
- text_test<double>(200, 1, 1, CDT_INSIDE_WITH_HOLES);
+ text_test<double>(200, 1, 1, CDT_INSIDE_WITH_HOLES, true);
}
TEST(delaunay_d, TextB10_10_10)
{
- text_test<double>(10, 10, 10, CDT_INSIDE_WITH_HOLES);
+ text_test<double>(10, 10, 10, CDT_INSIDE_WITH_HOLES, true);
+}
+
+TEST(delaunay_d, TextB10_10_10_noids)
+{
+ text_test<double>(10, 10, 10, CDT_INSIDE_WITH_HOLES, false);
}
# ifdef WITH_GMP
TEST(delaunay_m, TextB10)
{
- text_test<mpq_class>(10, 1, 1, CDT_INSIDE_WITH_HOLES);
+ text_test<mpq_class>(10, 1, 1, CDT_INSIDE_WITH_HOLES, true);
}
TEST(delaunay_m, TextB200)
{
- text_test<mpq_class>(200, 1, 1, CDT_INSIDE_WITH_HOLES);
+ text_test<mpq_class>(200, 1, 1, CDT_INSIDE_WITH_HOLES, true);
}
TEST(delaunay_m, TextB10_10_10)
{
- text_test<mpq_class>(10, 10, 10, CDT_INSIDE_WITH_HOLES);
+ text_test<mpq_class>(10, 10, 10, CDT_INSIDE_WITH_HOLES, true);
+}
+
+TEST(delaunay_m, TextB10_10_10_noids)
+{
+ text_test<mpq_class>(10, 10, 10, CDT_INSIDE_WITH_HOLES, false);
}
# endif