5#include "testing/testing.h"
18#define DO_TEXT_TESTS 0
19#define DO_RANDOM_TESTS 0
39 std::istringstream ss(spec);
42 std::istringstream hdrss(line);
43 int nverts, nedges, nfaces;
44 hdrss >> nverts >> nedges >> nfaces;
52 while (i < nverts && getline(ss, line)) {
53 std::istringstream iss(line);
62 while (i < nedges && getline(ss, line)) {
63 std::istringstream ess(line);
66 edges[i] = std::pair<int, int>(e0, e1);
70 while (i < nfaces && getline(ss, line)) {
71 std::istringstream fss(line);
83 if (std::is_same<mpq_class, T>::value) {
100 int n =
int(out_to_orig.size());
101 for (
int i = 0; i < n; ++i) {
102 for (
int orig : out_to_orig[i]) {
103 if (orig == orig_index) {
129template<
typename T>
static T
math_abs(
const T
v);
132template<> mpq_class
math_abs(
const mpq_class
v)
148 int nv =
int(out.vert.size());
149 for (
int i = 0; i < nv; ++i) {
152 if (
fabs(vx - x) <= 1
e-5 &&
fabs(vy - y) <= 1
e-5) {
163 int ne =
int(out.edge.size());
164 for (
int i = 0; i < ne; ++i) {
165 if ((out.edge[i].first == out_index_1 && out.edge[i].second == out_index_2) ||
166 (out.edge[i].first == out_index_2 && out.edge[i].second == out_index_1))
177 return out_edge_index <
int(out.edge_orig.size()) &&
178 out.edge_orig[out_edge_index].contains(in_edge_index);
186 int nf =
int(out.face.size());
187 int npolyv =
int(poly.size());
188 for (
int f = 0; f < nf; ++f) {
189 if (out.face[f].size() != poly.size()) {
192 for (
int cycle_start = 0; cycle_start < npolyv; ++cycle_start) {
194 for (
int k = 0; ok && k < npolyv; ++k) {
195 if (out.face[f][(cycle_start + k) % npolyv] != poly[k]) {
213 Array<int> tri{out_index_1, out_index_2, out_index_3};
220 return out_face_index <
int(out.face_orig.size()) &&
221 out.face_orig[out_face_index].contains(in_face_index);
228 os << r.
vert.size() <<
" verts, " << r.
edge.
size() <<
" edges, " << r.
face.size() <<
" faces\n";
230 for (
int i : r.
vert.index_range()) {
231 os <<
"v" << i <<
" = " << r.
vert[i] <<
"\n";
233 for (
int j : r.
vert_orig[i].index_range()) {
240 os <<
"e" << i <<
" = (" << r.
edge[i].
first <<
", " << r.
edge[i].second <<
")\n";
242 for (
int j : r.
edge_orig[i].index_range()) {
248 for (
int i : r.
face.index_range()) {
249 os <<
"f" << i <<
" = ";
250 for (
int j : r.
face[i].index_range()) {
251 os << r.
face[i][j] <<
" ";
255 for (
int j : r.
face_orig[i].index_range()) {
268 const Span<std::pair<int, int>> edges,
275 constexpr const char *drawfile =
"./cdt_test_draw.html";
277 constexpr const char *drawfile =
"/tmp/cdt_test_draw.html";
279 constexpr int max_draw_width = 1400;
280 constexpr int max_draw_height = 1000;
281 constexpr int thin_line = 1;
282 constexpr int vert_radius = 3;
283 constexpr bool draw_vert_labels =
false;
284 constexpr bool draw_edge_labels =
false;
286 if (
verts.is_empty()) {
292 for (
int i = 0; i < 2; ++i) {
302 double draw_margin = ((vmax.x - vmin.x) + (vmax.y - vmin.y)) * 0.05;
303 double minx = vmin.x - draw_margin;
304 double maxx = vmax.x + draw_margin;
305 double miny = vmin.y - draw_margin;
306 double maxy = vmax.y + draw_margin;
308 double width = maxx - minx;
309 double height = maxy - miny;
310 double aspect = height / width;
311 int view_width = max_draw_width;
312 int view_height =
int(view_width * aspect);
313 if (view_height > max_draw_height) {
314 view_height = max_draw_height;
315 view_width =
int(view_height / aspect);
317 double scale = view_width / width;
319#define SX(x) ((math_to_double(x) - minx) * scale)
320#define SY(y) ((maxy - math_to_double(y)) * scale)
324 f.open(drawfile, std::ios_base::app);
330 std::cout <<
"Could not open file " << drawfile <<
"\n";
334 f <<
"<div>" <<
label <<
"</div>\n<div>\n"
335 <<
"<svg version=\"1.1\" "
336 "xmlns=\"http://www.w3.org/2000/svg\" "
337 "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
338 "xml:space=\"preserve\"\n"
339 <<
"width=\"" << view_width <<
"\" height=\"" << view_height <<
"\">n";
342 f <<
"<polygon fill=\"azure\" stroke=\"none\"\n points=\"";
343 for (
int vi : fverts) {
345 f <<
SX(co[0]) <<
"," <<
SY(co[1]) <<
" ";
350 for (
const std::pair<int, int> &
e : edges) {
353 int strokew = thin_line;
354 f << R
"(<line fill="none" stroke="black" stroke-width=")" << strokew << "\" x1=\""
355 <<
SX(uco[0]) <<
"\" y1=\"" <<
SY(uco[1]) <<
"\" x2=\"" <<
SX(vco[0]) <<
"\" y2=\""
356 <<
SY(vco[1]) <<
"\">\n";
357 f <<
" <title>[" <<
e.first <<
"][" <<
e.second <<
"]</title>\n";
359 if (draw_edge_labels) {
360 f <<
"<text x=\"" <<
SX(0.5 * (uco[0] + vco[0])) <<
"\" y=\"" <<
SY(0.5 * (uco[1] + vco[1]))
361 << R
"(" font-size="small">)";
362 f << "[" <<
e.first <<
"][" <<
e.second <<
"]</text>\n";
368 f << R
"(<circle fill="black" cx=")" << SX(vco[0]) << "\" cy=\"" <<
SY(vco[1]) <<
"\" r=\""
369 << vert_radius <<
"\">\n";
370 f <<
" <title>[" << i <<
"]" << vco <<
"</title>\n";
372 if (draw_vert_labels) {
373 f <<
"<text x=\"" <<
SX(vco[0]) + vert_radius <<
"\" y=\"" <<
SY(vco[1]) - vert_radius
374 << R
"(" font-size="small">[)" << i << "]</text>\n";
400 EXPECT_NEAR(testco[0], refco[0], 1
e-5);
401 EXPECT_NEAR(testco[1], refco[1], 1
e-5);
421 const char *spec = R
"(1 0 0
430 if (out.vert.size() >= 1) {
437 const char *spec = R
"(2 0 0
449 EXPECT_NE(v0_out, -1);
450 EXPECT_NE(v1_out, -1);
451 EXPECT_NE(v0_out, v1_out);
452 if (out.vert.size() >= 1) {
465 const char *spec = R
"(3 0 0
479 EXPECT_TRUE(v0_out != -1 && v1_out != -1 && v2_out != -1);
480 EXPECT_TRUE(v0_out != v1_out && v0_out != v2_out && v1_out != v2_out);
484 EXPECT_TRUE(e0_out != -1 && e1_out != -1 && e2_out != -1);
485 EXPECT_TRUE(e0_out != e1_out && e0_out != e2_out && e1_out != e2_out);
496 const char *spec = R
"(4 3 0
514 EXPECT_TRUE(v0_out != -1 && v1_out != -1 && v2_out != -1 && v3_out != -1);
518 EXPECT_TRUE(e0_out != -1 && e1_out != -1 && e2_out != -1);
529 const char *spec = R
"(4 0 0
541 EXPECT_NE(e_diag_out, -1);
549 const char *spec = R
"(4 0 0
561 EXPECT_NE(e_diag_out, -1);
569 const char *spec = R
"(4 0 0
581 EXPECT_NE(e_diag_out, -1);
589 const char *spec = R
"(4 0 0
601 EXPECT_NE(e_diag_out, -1);
609 const char *spec = R
"(4 0 0
621 EXPECT_NE(e_diag_out, -1);
629 const char *spec = R
"(6 1 1
645 graph_draw<T>(
"LineInSquare - full", out.vert, out.edge, out.face);
651 graph_draw<T>(
"LineInSquare - constraints", out2.vert, out2.edge, out2.face);
657 graph_draw<T>(
"LineInSquare - inside with holes", out3.vert, out3.edge, out3.face);
663 graph_draw<T>(
"LineInSquare - valid bmesh with holes", out4.vert, out4.edge, out4.face);
669 const char *spec = R
"(10 1 2
690 graph_draw<T>(
"LineHoleInSquare - full", out.vert, out.edge, out.face);
696 graph_draw<T>(
"LineHoleInSquare - constraints", out2.vert, out2.edge, out2.face);
702 graph_draw<T>(
"LineHoleInSquare - inside with holes", out3.vert, out3.edge, out3.face);
708 graph_draw<T>(
"LineHoleInSquare - valid bmesh with holes", out4.vert, out4.edge, out4.face);
714 const char *spec = R
"(12 0 3
737 graph_draw<T>(
"NestedHoles - full", out.vert, out.edge, out.face);
743 graph_draw<T>(
"NestedHoles - constraints", out2.vert, out2.edge, out2.face);
749 graph_draw<T>(
"NestedHoles - inside with holes", out3.vert, out3.edge, out3.face);
755 graph_draw<T>(
"NestedHoles - valid bmesh with holes", out4.vert, out4.edge, out4.face);
761 const char *spec = R
"(4 2 0
779 EXPECT_TRUE(v0_out != -1 && v1_out != -1 && v2_out != -1 && v3_out != -1);
780 if (out.vert.size() == 5) {
781 int v_intersect = -1;
782 for (
int i = 0; i < 5; i++) {
783 if (!
ELEM(i, v0_out, v1_out, v2_out, v3_out)) {
788 EXPECT_NE(v_intersect, -1);
789 if (v_intersect != -1) {
801 const char *spec = R
"(5 1 1
821 EXPECT_TRUE(v0_out != -1 && v1_out != -1 && v2_out != -1 && v3_out != -1 && v4_out != -1);
822 if (out.face.size() == 3) {
824 EXPECT_NE(e0_out, -1);
826 EXPECT_NE(fe0_out, -1);
828 EXPECT_NE(fe1a_out, -1);
830 EXPECT_NE(fe1b_out, -1);
831 if (fe1a_out != 0 && fe1b_out != 0) {
833 EXPECT_TRUE(out.edge_orig[fe1a_out].size() == 1 && out.edge_orig[fe1a_out][0] == 11);
834 EXPECT_TRUE(out.edge_orig[fe1b_out].size() == 1 && out.edge_orig[fe1b_out][0] == 11);
837 EXPECT_NE(e_diag, -1);
839 EXPECT_EQ(out.edge_orig[e_diag].size(), 0);
850 const char *spec = R
"(7 5 0
877 const char *spec = R
"(12 9 0
906 if (out.vert.size() == 8 && out.edge.size() == 15 && out.face.size() == 8) {
908 for (
int i = 0; i < 12; ++i) {
910 EXPECT_NE(v_out[i], -1);
917 for (
int i = 0; i < 8; ++i) {
919 EXPECT_NE(e_out[i], -1);
926 EXPECT_TRUE(e_cross_1 != -1 && e_cross_2 != -1 && e_cross_3 != -1);
932 graph_draw<T>(
"TwoDiamondsCross", out.vert, out.edge, out.face);
939 const char *spec = R
"(27 21 0
1002 const char *spec = R
"(6 0 2
1018 if (out.vert.size() == 6 && out.edge.size() == 9 && out.face.size() == 4) {
1020 for (
int i = 0; i < 6; i++) {
1022 EXPECT_NE(v_out[i], -1);
1026 EXPECT_NE(f0_out, -1);
1027 EXPECT_NE(f1_out, -1);
1031 EXPECT_NE(e0_out, -1);
1032 EXPECT_NE(e1_out, -1);
1033 EXPECT_NE(e2_out, -1);
1047 const char *spec = R
"(6 0 2
1063 if (out.vert.size() == 10 && out.edge.size() == 18 && out.face.size() == 9) {
1065 for (
int i = 0; i < 6; i++) {
1123 const char *spec = R
"(12 0 3
1146 if (out.vert.size() == 14 && out.edge.size() == 33 && out.face.size() == 20) {
1148 for (
int i = 0; i < 12; i++) {
1150 EXPECT_NE(v_out[i], -1);
1154 T x = out.vert[v_int1][0] -
T(1);
1161 EXPECT_EQ(out.vert_orig[v_int1].size(), 0);
1162 EXPECT_EQ(out.vert_orig[v_int2].size(), 0);
1164 EXPECT_NE(f0_out, -1);
1167 EXPECT_NE(f1_out, -1);
1174 EXPECT_NE(f2_out, -1);
1179 graph_draw<T>(
"OverlapFaces - full", out.vert, out.edge, out.face);
1186 graph_draw<T>(
"OverlapFaces - inside", out2.vert, out2.edge, out2.face);
1192 graph_draw<T>(
"OverlapFaces - inside with holes", out3.vert, out3.edge, out3.face);
1198 graph_draw<T>(
"OverlapFaces - constraints", out4.vert, out4.edge, out4.face);
1204 graph_draw<T>(
"OverlapFaces - valid bmesh", out5.vert, out5.edge, out5.face);
1210 graph_draw<T>(
"OverlapFaces - valid bmesh with holes", out6.vert, out6.edge, out6.face);
1216 const char *spec = R
"(8 0 2
1235 graph_draw<T>(
"TwoSquaresOverlap", out.vert, out.edge, out.face);
1241 const char *spec = R
"(6 0 2
1257 if (out.vert.size() == 5 && out.edge.size() == 7 && out.face.size() == 3) {
1260 for (
int i = 0; i < 6; i++) {
1262 EXPECT_NE(v_out[i], -1);
1263 EXPECT_NE(v_out[i], v_int);
1268 int foff = out.face_edge_offset;
1284 EXPECT_NE(f02i, -1);
1288 EXPECT_NE(f24i, -1);
1292 EXPECT_NE(f10i, -1);
1297 graph_draw<T>(
"TwoFaceEdgeOverlap", out.vert, out.edge, out.face);
1303 const char *spec = R
"(6 0 2
1326 const char *spec = R
"(8 0 2
1331 0.14644660940672627 0.5
1332 0.5 0.14644660940672627
1333 0.8535533905932737 0.5
1334 0.5 0.8535533905932737
1345 graph_draw<T>(
"DiamondInSquare", out.vert, out.edge, out.face);
1351 const char *spec = R
"(8 8 0
1356 0.14644660940672627 0.5
1357 0.5 0.14644660940672627
1358 0.8535533905932737 0.5
1359 0.5 0.8535533905932737
1376 graph_draw<T>(
"DiamondInSquareWire", out.vert, out.edge, out.face);
1382 const char *spec = R
"(5 3 0
1403 const char *spec = R
"(3 0 2
1424 const char *spec = R
"(8 0 2
1440 graph_draw<T>(
"Square O - inside with holes", out1.vert, out1.edge, out1.face);
1446 graph_draw<T>(
"Square O - valid bmesh with holes", out2.vert, out2.edge, out2.face);
1560TEST(delaunay_d, TwoFaceEdgeOverlap)
1575TEST(delaunay_d, DiamondInSquareWire)
1596TEST(delaunay_m, Empty)
1601TEST(delaunay_m, OnePt)
1605TEST(delaunay_m, TwoPt)
1610TEST(delaunay_m, ThreePt)
1615TEST(delaunay_m, MixedPts)
1620TEST(delaunay_m, Quad0)
1625TEST(delaunay_m, Quad1)
1630TEST(delaunay_m, Quad2)
1635TEST(delaunay_m, Quad3)
1640TEST(delaunay_m, Quad4)
1645TEST(delaunay_m, LineInSquare)
1650TEST(delaunay_m, LineHoleInSquare)
1655TEST(delaunay_m, NestedHoles)
1660TEST(delaunay_m, CrossSegs)
1665TEST(delaunay_m, CutAcrossTri)
1670TEST(delaunay_m, DiamondCross)
1675TEST(delaunay_m, TwoDiamondsCross)
1680TEST(delaunay_m, ManyCross)
1685TEST(delaunay_m, TwoFace)
1690TEST(delaunay_m, TwoFace2)
1695TEST(delaunay_m, OverlapFaces)
1700TEST(delaunay_m, TwoSquaresOverlap)
1705TEST(delaunay_m, TwoFaceEdgeOverlap)
1710TEST(delaunay_m, TriInTri)
1715TEST(delaunay_m, DiamondInSquare)
1720TEST(delaunay_m, DiamondInSquareWire)
1725TEST(delaunay_m, RepeatEdge)
1730TEST(delaunay_m, RepeatTri)
1740 int arc_points_num,
int lets_per_line_num,
int lines_num,
CDT_output_type otype,
bool need_ids)
1742 constexpr bool print_timing =
true;
1765 const char *b_before_arcs = R
"(13 0 3
1785 constexpr int narcs = 4;
1786 int b_npts = b_before_arcs_in.vert.size() + narcs * arc_points_num;
1787 constexpr int b_nfaces = 3;
1788 Array<VecBase<T, 2>> b_vert(b_npts);
1789 Array<Vector<int>> b_face(b_nfaces);
1790 std::copy(b_before_arcs_in.vert.begin(), b_before_arcs_in.vert.end(), b_vert.begin());
1791 std::copy(b_before_arcs_in.face.begin(), b_before_arcs_in.face.end(), b_face.begin());
1792 if (arc_points_num > 0) {
1793 b_face[0].pop_last();
1794 for (
int arc = 0; arc < narcs; ++arc) {
1795 int arc_origin_vert;
1796 int arc_terminal_vert;
1800 arc_origin_vert = 1;
1801 arc_terminal_vert = 2;
1805 arc_origin_vert = 2;
1806 arc_terminal_vert = 3;
1810 arc_origin_vert = 7;
1811 arc_terminal_vert = 6;
1815 arc_origin_vert = 11;
1816 arc_terminal_vert = 10;
1822 VecBase<T, 2> start_co = b_vert[arc_origin_vert];
1823 VecBase<T, 2> end_co = b_vert[arc_terminal_vert];
1824 VecBase<T, 2> center_co = 0.5 * (start_co + end_co);
1827 double angle_delta =
M_PI / (arc_points_num + 1);
1828 int start_vert = b_before_arcs_in.vert.size() + arc * arc_points_num;
1829 Vector<int> &face = b_face[(arc <= 1) ? 0 : arc - 1];
1830 for (
int i = 0; i < arc_points_num; ++i) {
1831 VecBase<T, 2> delta;
1832 float ang = ccw ? (-
M_PI_2 + (i + 1) * angle_delta) : (
M_PI_2 - (i + 1) * angle_delta);
1833 delta[0] =
T(radius *
cos(ang));
1834 delta[1] =
T(radius *
sin(ang));
1835 b_vert[start_vert + i] = center_co + delta;
1836 face.append(start_vert + i);
1839 face.append(arc_terminal_vert);
1845 int tot_instances = lets_per_line_num * lines_num;
1846 if (tot_instances == 1) {
1851 in.vert = Array<VecBase<T, 2>>(tot_instances * b_vert.size());
1852 in.face = Array<Vector<int>>(tot_instances * b_face.size());
1856 T delta_y =
T(3.25);
1858 for (
int line = 0; line < lines_num; ++line) {
1859 for (
int let = 0; let < lets_per_line_num; ++let) {
1860 VecBase<T, 2> co_offset(cur_x, cur_y);
1861 int in_v_offset = instance * b_vert.size();
1862 for (
int v = 0;
v < b_vert.size(); ++
v) {
1863 in.vert[in_v_offset +
v] = b_vert[
v] + co_offset;
1865 int in_f_offset = instance * b_face.size();
1866 for (
int f : b_face.index_range()) {
1867 for (
int fv : b_face[f]) {
1868 in.face[in_f_offset + f].append(in_v_offset + fv);
1878 in.epsilon = b_before_arcs_in.epsilon;
1879 in.need_ids = need_ids;
1884 std::cout <<
"time = " << tend - tstart <<
"\n";
1892 std::string
label =
"Text arcpts=" + std::to_string(arc_points_num);
1893 if (lets_per_line_num > 1) {
1894 label +=
" linelen=" + std::to_string(lets_per_line_num);
1896 if (lines_num > 1) {
1897 label +=
" lines=" + std::to_string(lines_num);
1903 label +=
" otype=" + std::to_string(otype);
1909TEST(delaunay_d, TextB10)
1914TEST(delaunay_d, TextB10_noids)
1919TEST(delaunay_d, TextB10_inside)
1921 text_test<double>(10, 1, 1,
CDT_INSIDE,
true);
1924TEST(delaunay_d, TextB10_inside_noids)
1926 text_test<double>(10, 1, 1,
CDT_INSIDE,
false);
1929TEST(delaunay_d, TextB10_constraints)
1934TEST(delaunay_d, TextB10_constraints_noids)
1939TEST(delaunay_d, TextB10_constraints_valid_bmesh)
1944TEST(delaunay_d, TextB10_constraints_valid_bmesh_noids)
1949TEST(delaunay_d, TextB10_constraints_valid_bmesh_with_holes)
1954TEST(delaunay_d, TextB10_constraints_valid_bmesh_with_holes_noids)
1959TEST(delaunay_d, TextB200)
1964TEST(delaunay_d, TextB10_10_10)
1969TEST(delaunay_d, TextB10_10_10_noids)
1975TEST(delaunay_m, TextB10)
1980TEST(delaunay_m, TextB200)
1985TEST(delaunay_m, TextB10_10_10)
1990TEST(delaunay_m, TextB10_10_10_noids)
2006 RANDOM_TRI_BETWEEN_CIRCLES,
2010void rand_delaunay_test(
int test_kind,
2017 constexpr bool print_timing =
true;
2019 Array<double> times(max_lg_size + 1);
2022 for (
int lg_size = start_lg_size; lg_size <= max_lg_size; ++lg_size) {
2023 int size = 1 << lg_size;
2024 times[lg_size] = 0.0;
2025 if (size == 1 && test_kind != RANDOM_PTS) {
2029 for (
int rep = 0; rep < reps_per_size; ++rep) {
2034 std::string test_label;
2035 switch (test_kind) {
2038 test_label = std::to_string(npts) +
"Random points";
2044 test_label = std::to_string(nedges) +
"Random edges";
2050 test_label =
"Random poly with " + std::to_string(nedges) +
" edges";
2053 case RANDOM_TILTED_GRID: {
2063 test_label =
"Tilted grid " + std::to_string(npts) +
"x" + std::to_string(npts) +
2064 " (tilt=" + std::to_string(param) +
")";
2067 case RANDOM_CIRCLE: {
2073 test_label =
"Circle with " + std::to_string(npts) +
" points";
2076 case RANDOM_TRI_BETWEEN_CIRCLES: {
2083 test_label =
"Random " + std::to_string(nfaces) +
2084 " triangles between circles (inner radius=" + std::to_string(param) +
")";
2088 std::cout <<
"unknown delaunay test type\n";
2094 test_label +=
" (inside)";
2097 test_label +=
" (constraints)";
2100 test_label +=
" (valid bmesh)";
2105 in.vert = Array<VecBase<T, 2>>(npts);
2107 in.edge = Array<std::pair<int, int>>(nedges);
2110 in.face = Array<Vector<int>>(nfaces);
2114 switch (test_kind) {
2118 for (
int i = 0; i <
size; i++) {
2121 if (test_kind != RANDOM_PTS) {
2123 in.edge[i - 1].first = i - 1;
2124 in.edge[i - 1].second = i;
2128 if (test_kind == RANDOM_POLY) {
2129 in.edge[size - 1].first = size - 1;
2130 in.edge[size - 1].second = 0;
2134 case RANDOM_TILTED_GRID: {
2135 for (
int i = 0; i <
size; ++i) {
2136 for (
int j = 0; j <
size; ++j) {
2137 in.vert[i * size + j][0] =
T(i * param + j);
2138 in.vert[i * size + j][1] =
T(i);
2141 for (
int i = 0; i <
size; ++i) {
2143 in.edge[i].first = i *
size;
2144 in.edge[i].second = i * size + size - 1;
2146 in.edge[size + i].first = i;
2147 in.edge[size + i].second = (size - 1) * size + i;
2151 case RANDOM_CIRCLE: {
2153 double angle_delta = 2.0 *
M_PI /
size;
2154 for (
int i = 0; i <
size; i++) {
2155 in.vert[i][0] =
T(
cos(start_angle + i * angle_delta));
2156 in.vert[i][1] =
T(
sin(start_angle + i * angle_delta));
2157 in.face[0].append(i);
2161 case RANDOM_TRI_BETWEEN_CIRCLES: {
2162 for (
int i = 0; i <
size; i++) {
2170 in.vert[ia][0] =
T(
cos(angle1));
2171 in.vert[ia][1] =
T(
sin(angle1));
2172 in.vert[ib][0] =
T(
cos(angle2));
2173 in.vert[ib][1] =
T(
sin(angle2));
2174 in.vert[ic][0] =
T((param *
cos(angle3)));
2175 in.vert[ic][1] =
T((param *
sin(angle3)));
2177 in.face[i].append(ia);
2178 int orient =
orient2d(in.vert[ia], in.vert[ib], in.vert[ic]);
2180 in.face[i].append(ib);
2181 in.face[i].append(ic);
2184 in.face[i].append(ic);
2185 in.face[i].append(ib);
2195 EXPECT_NE(out.vert.size(), 0);
2203 std::cout <<
"\nsize,time\n";
2204 for (
int lg_size = 0; lg_size <= max_lg_size; lg_size++) {
2205 int size = 1 << lg_size;
2206 std::cout << size <<
"," << times[lg_size] <<
"\n";
2212TEST(delaunay_d, RandomPts)
2214 rand_delaunay_test<double>(RANDOM_PTS, 0, 7, 1, 0.0,
CDT_FULL);
2217TEST(delaunay_d, RandomSegs)
2219 rand_delaunay_test<double>(RANDOM_SEGS, 1, 7, 1, 0.0,
CDT_FULL);
2222TEST(delaunay_d, RandomPoly)
2224 rand_delaunay_test<double>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_FULL);
2227TEST(delaunay_d, RandomPolyConstraints)
2229 rand_delaunay_test<double>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_CONSTRAINTS);
2232TEST(delaunay_d, RandomPolyValidBmesh)
2237TEST(delaunay_d, Grid)
2239 rand_delaunay_test<double>(RANDOM_TILTED_GRID, 1, 6, 1, 0.0,
CDT_FULL);
2242TEST(delaunay_d, TiltedGridA)
2244 rand_delaunay_test<double>(RANDOM_TILTED_GRID, 1, 6, 1, 1.0,
CDT_FULL);
2247TEST(delaunay_d, TiltedGridB)
2249 rand_delaunay_test<double>(RANDOM_TILTED_GRID, 1, 6, 1, 0.01,
CDT_FULL);
2252TEST(delaunay_d, RandomCircle)
2254 rand_delaunay_test<double>(RANDOM_CIRCLE, 1, 7, 1, 0.0,
CDT_FULL);
2257TEST(delaunay_d, RandomTrisCircle)
2259 rand_delaunay_test<double>(RANDOM_TRI_BETWEEN_CIRCLES, 1, 6, 1, 0.25,
CDT_FULL);
2262TEST(delaunay_d, RandomTrisCircleB)
2264 rand_delaunay_test<double>(RANDOM_TRI_BETWEEN_CIRCLES, 1, 6, 1, 1
e-4,
CDT_FULL);
2268TEST(delaunay_m, RandomPts)
2270 rand_delaunay_test<mpq_class>(RANDOM_PTS, 0, 7, 1, 0.0,
CDT_FULL);
2273TEST(delaunay_m, RandomSegs)
2275 rand_delaunay_test<mpq_class>(RANDOM_SEGS, 1, 7, 1, 0.0,
CDT_FULL);
2278TEST(delaunay_m, RandomPoly)
2280 rand_delaunay_test<mpq_class>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_FULL);
2283TEST(delaunay_d, RandomPolyInside)
2285 rand_delaunay_test<double>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_INSIDE);
2288TEST(delaunay_m, RandomPolyInside)
2290 rand_delaunay_test<mpq_class>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_INSIDE);
2293TEST(delaunay_m, RandomPolyConstraints)
2295 rand_delaunay_test<mpq_class>(RANDOM_POLY, 1, 7, 1, 0.0,
CDT_CONSTRAINTS);
2298TEST(delaunay_m, RandomPolyValidBmesh)
2303TEST(delaunay_m, Grid)
2305 rand_delaunay_test<mpq_class>(RANDOM_TILTED_GRID, 1, 6, 1, 0.0,
CDT_FULL);
2308TEST(delaunay_m, TiltedGridA)
2310 rand_delaunay_test<mpq_class>(RANDOM_TILTED_GRID, 1, 6, 1, 1.0,
CDT_FULL);
2313TEST(delaunay_m, TiltedGridB)
2315 rand_delaunay_test<mpq_class>(RANDOM_TILTED_GRID, 1, 6, 1, 0.01,
CDT_FULL);
2318TEST(delaunay_m, RandomCircle)
2320 rand_delaunay_test<mpq_class>(RANDOM_CIRCLE, 1, 7, 1, 0.0,
CDT_FULL);
2323TEST(delaunay_m, RandomTrisCircle)
2325 rand_delaunay_test<mpq_class>(RANDOM_TRI_BETWEEN_CIRCLES, 1, 6, 1, 0.25,
CDT_FULL);
2328TEST(delaunay_m, RandomTrisCircleB)
2330 rand_delaunay_test<double>(RANDOM_TRI_BETWEEN_CIRCLES, 1, 6, 1, 1
e-4,
CDT_FULL);
@ CDT_CONSTRAINTS_VALID_BMESH
@ CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES
void expect_coord_near< double >(const double2 &testco, const double2 &refco)
void twodiamondscross_test()
void diamondinsquarewire_test()
void twofaceedgeoverlap_test()
void twosquaresoverlap_test()
void expect_coord_near(const VecBase< T, 2 > &testco, const VecBase< T, 2 > &refco)
void lineholeinsquare_test()
void diamondinsquare_test()
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
Math vector functions needed specifically for mesh intersect and boolean.
struct RNG * BLI_rng_new(unsigned int seed)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
double BLI_rng_get_double(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Platform independent time functions.
double BLI_time_now_seconds(void)
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
IndexRange index_range() const
Array< std::pair< int, int > > edge
Array< Vector< int > > face
Array< Vector< int > > vert_orig
Array< Vector< int > > face_orig
Array< VecBase< T, 2 > > vert
Array< Vector< int > > edge_orig
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float2 fabs(const float2 a)
T cos(const AngleRadianBase< T > &a)
std::ostream & operator<<(std::ostream &stream, EulerOrder order)
T sin(const AngleRadianBase< T > &a)
double math_to_double< double >(const double v)
int get_output_edge_index(const CDT_result< T > &out, int out_index_1, int out_index_2)
CDT_input< T > fill_input_from_string(const char *spec)
bool output_edge_has_input_id(const CDT_result< T > &out, int out_edge_index, int in_edge_index)
int get_output_tri_index(const CDT_result< T > &out, int out_index_1, int out_index_2, int out_index_3)
CDT_result< double > delaunay_2d_calc(const CDT_input< double > &input, CDT_output_type output_type)
int get_vertex_by_coord(const CDT_result< T > &out, double x, double y)
bool output_face_has_input_id(const CDT_result< T > &out, int out_face_index, int in_face_index)
void graph_draw(const std::string &label, const Span< VecBase< T, 2 > > verts, const Span< std::pair< int, int > > edges, const Span< Vector< int > > faces)
double math_to_double(const T)
int get_output_face_index(const CDT_result< T > &out, const Array< int > &poly)
static int get_orig_index(const Span< Vector< int > > out_to_orig, int orig_index)
TEST(BLI_string_utils, BLI_uniquename_cb)
int orient2d(const double2 &a, const double2 &b, const double2 &c)
VecBase< double, 2 > double2