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
path: root/tests
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-09-20 06:39:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-09-20 06:40:30 +0300
commita2d246c5c0b6abffc1f12f288bfe275121fb943e (patch)
treee4a473dd8d6e25764f2e0699d2c627fa657fdf70 /tests
parent77dccbf4811e454a37621464abddd15ec10032b5 (diff)
BLI_polyfill2d_test: script to generate test data
Diffstat (limited to 'tests')
-rw-r--r--tests/gtests/blenlib/BLI_polyfill2d_test.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_polyfill2d_test.cc b/tests/gtests/blenlib/BLI_polyfill2d_test.cc
index ca3a67bd0a7..df98ead4cb9 100644
--- a/tests/gtests/blenlib/BLI_polyfill2d_test.cc
+++ b/tests/gtests/blenlib/BLI_polyfill2d_test.cc
@@ -329,6 +329,43 @@ static void polyfill_to_obj(
/* -------------------------------------------------------------------- */
/* tests */
+/**
+ * Script to generate the data below:
+ *
+ * \code{.py}
+ * # This example assumes we have a mesh object in edit-mode
+ *
+ * import bpy
+ * import bmesh
+ *
+ * obj = bpy.context.edit_object
+ * me = obj.data
+ * bm = bmesh.from_edit_mesh(me)
+ *
+ * def clean_float(num):
+ * if int(num) == num:
+ * return str(int(num))
+ * prec = 1
+ * while True:
+ * text = f"{num:.{prec}f}"
+ * if float(text) == num:
+ * return text
+ * prec += 1
+ *
+ * for f in bm.faces:
+ * if f.select:
+ * print(f"\t// data for face: {f.index}")
+ * print("\tconst float poly[][2] = {", end="")
+ * coords = [[clean_float(num) for num in l.vert.co[0:2]] for l in f.loops]
+ * print("\t ", end="")
+ * for i, (x, y) in enumerate(coords):
+ * if (i % 2) == 0:
+ * print("\n\t ", end="")
+ * print(f"{{{x}, {y}}}", end=",")
+ * print("\n\t};")
+ * \endcode
+ */
+
#define POLY_TRI_COUNT(len) ((len) - 2)