19 Array<int> offsets(all_positions.size() + 1, 0);
20 for (
const int curve : all_positions.index_range()) {
22 offsets[curve + 1] = offsets[curve] + curve_positions.
size();
27 curves.offsets_for_write().copy_from(offsets);
33 for (
const int curve : all_positions.index_range()) {
34 positions.
slice(points_by_curve[curve]).
copy_from(all_positions[curve]);
35 cyclic[curve] =
is_cyclic.contains(curve);
36 orders[curve] = order;
39 curves.tag_topology_changed();
63TEST(curves_editors, DuplicatePointsTwoSingle)
66 const Vector<float3> expected_positions = {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}};
74 EXPECT_TRUE(
curves.curves_num() == 2);
78 for (
const int point : expected_positions.
index_range()) {
79 EXPECT_TRUE(positions[point] == expected_positions[point]);
82 EXPECT_TRUE(positions[4] == expected_positions[1]);
83 EXPECT_TRUE(positions[5] == expected_positions[2]);
86TEST(curves_editors, DuplicatePointsFourThree)
90 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
92 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
100 EXPECT_TRUE(
curves.curves_num() == expected_positions.
size() + 3);
105 for (
const int curve : expected_positions.
index_range()) {
106 const Span<float3> expected_curve_positions = expected_positions[curve];
107 const IndexRange points = points_by_curve[curve];
108 for (
const int point : expected_curve_positions.
index_range()) {
109 EXPECT_TRUE(positions[points[point]] == expected_curve_positions[point]);
113 EXPECT_TRUE(positions[10] == expected_positions[0][0]);
114 EXPECT_TRUE(positions[11] == expected_positions[0][1]);
115 EXPECT_TRUE(positions[12] == expected_positions[1][0]);
116 EXPECT_TRUE(positions[13] == expected_positions[2][4]);
119TEST(curves_editors, DuplicatePointsTwoCyclic)
123 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
125 {{1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 1, 0}},
126 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
134 EXPECT_TRUE(
curves.curves_num() == expected_positions.
size() + 1);
139 for (
const int curve : expected_positions.
index_range()) {
140 const Span<float3> expected_curve_positions = expected_positions[curve];
141 const IndexRange points = points_by_curve[curve];
142 for (
const int point : expected_curve_positions.
index_range()) {
143 EXPECT_TRUE(positions[points[point]] == expected_curve_positions[point]);
147 EXPECT_TRUE(positions[14] == expected_positions[2][3]);
148 EXPECT_TRUE(positions[15] == expected_positions[2][0]);
151TEST(curves_editors, SplitPointsTwoSingle)
154 const Vector<float3> positions = {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}};
163 {{-1, 1, 0}, {1, 1, 0}}, {{-1.5, 0, 0}, {-1, 1, 0}}, {{1, 1, 0}, {1.5, 0, 0}}};
165 GTEST_ASSERT_EQ(new_curves.curves_num(), expected_positions.
size());
166 validate_positions(expected_positions, new_curves.points_by_curve(), new_curves.positions());
169TEST(curves_editors, SplitPointsFourThree)
173 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
175 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
184 {{-1.5, 0, 0}, {-1, 1, 0}},
185 {{-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
188 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
190 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
194TEST(curves_editors, SplitPointsTwoCyclic)
198 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
200 {{1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 1, 0}},
201 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
210 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
212 {{-1, 1, 0}, {1, 1, 0}},
213 {{1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 1, 0}},
214 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
216 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
218 Array<bool> expected_cyclic = {
false,
false,
false,
false,
false};
225TEST(curves_editors, SplitPointsTwoTouchCyclic)
229 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
231 {{1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 1, 0}},
232 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
241 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}},
243 {{1, 1, 0}, {1, -1, 0}},
244 {{1, -1, 0}, {-1, -1, 0}, {-1, 1, 0}, {1, 1, 0}},
245 {{-1.5, 0, 0}, {-1, 1, 0}, {1, 1, 0}, {1.5, 0, 0}, {1, -1, 0}}};
247 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
251TEST(curves_editors, SplitEverySecondCyclic)
283 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
287TEST(curves_editors, SplitAllSelectedButFirstCyclic)
308 {{-1, -1, 0}, {-1, 0, 0}, {-1, 1, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {1, -1, 0}},
309 {{1, -1, 0}, {0, -1, 0}, {-1, -1, 0}},
312 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
315 EXPECT_FALSE(new_curves.
cyclic()[0]);
316 EXPECT_FALSE(new_curves.
cyclic()[1]);
319TEST(curves_editors, SplitTwoOnSeamAndExtraCyclic)
338 {{-1, 1, 0}, {0, 1, 0}},
339 {{1, -1, 0}, {0, -1, 0}},
340 {{0, -1, 0}, {-1, -1, 0}, {-1, 0, 0}, {-1, 1, 0}},
341 {{0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {1, -1, 0}}};
343 GTEST_ASSERT_EQ(new_curves.
curves_num(), expected_positions.
size());
345 EXPECT_FALSE(new_curves.
cyclic()[0]);
346 EXPECT_FALSE(new_curves.
cyclic()[1]);
347 EXPECT_FALSE(new_curves.
cyclic()[2]);
348 EXPECT_FALSE(new_curves.
cyclic()[3]);