16#include "testing/testing.h"
54 std::unique_ptr<IOBJCurve> curve_wrapper(
new OBJCurves(curve, identity,
"test"));
68 curves.offsets_for_write()[0] = 0;
70 curves.cyclic_for_write()[0] = cyclic;
71 curves.positions_for_write().copy_from(points);
79 curves.nurbs_orders_for_write()[0] = order;
81 curves.nurbs_weights_for_write().copy_from(weights);
92 curves.nurbs_orders_for_write()[0] = order;
94 curves.nurbs_weights_for_write().fill(1.0f);
106 const KnotsMode *expected_mode =
nullptr,
107 const bool *expected_cyclic =
nullptr)
111 std::string out_file_path = tempdir +
BLI_path_basename(
"io_obj/tmp_6f5273f4.obj");
115 ASSERT_TRUE(src_curve.
cyclic()[0] == cyclic);
121 ASSERT_TRUE(
result.size() == 1);
122 result_curve = &
result[0].get_curves()->geometry.wrap();
126 EXPECT_EQ(result_curve->
cyclic()[0], expected_cyclic ? *expected_cyclic : cyclic);
130 expected_points = expected_points.size() ? expected_points : points;
131 ASSERT_EQ(expected_points.size(), result_points.
size());
132 EXPECT_NEAR_ARRAY_ND(
133 expected_points.data(), result_points.
data(), expected_points.size(), 3, 1
e-4);
142 float3{2.0f, -2.0f, 4.0f},
143 float3{3.0f, -3.0f, 6.0f},
144 float3{4.0f, -4.0f, 8.0f},
145 float3{5.0f, -5.0f, 10.0f},
146 float3{6.0f, -6.0f, 12.0f},
147 float3{7.0f, -7.0f, 14.0f},
148 float3{1.0f / 4.0f, -2.0f, 3.0f / 6.0f},
149 float3{1.0f / 6.0f, -3.0f, 3.0f / 9.0f},
150 float3{1.0f / 8.0f, -4.0f, 3.0f / 12.0f},
151 float3{1.0f / 5.0f, -5.0f, 3.0f / 11.0f},
152 float3{1.0f / 3.0f, -6.0f, 3.0f / 10.0f},
153 float3{1.0f / 2.0f, -7.0f, 3.0f / 9.0f}};
164 const bool cyclic =
false;
171 run_nurbs_test(positions, order, mode, cyclic, src,
result, positions, &expected_mode);
180 std::array<int, 7> expected_mult;
181 std::fill(expected_mult.begin(), expected_mult.end(), 1);
182 EXPECT_EQ_SPAN<int>(multiplicity, expected_mult);
193 run_nurbs_test(positions, order, mode,
false, src,
result);
204 run_nurbs_test(positions, order, mode,
false, src,
result);
215 run_nurbs_test(positions, order, mode,
false, src,
result);
226 run_nurbs_test(positions, order, mode,
false, src,
result);
239 run_nurbs_test(positions, order, mode,
true, src,
result, positions, &expected_mode);
250 run_nurbs_test(positions, order, mode,
true, src,
result);
261 run_nurbs_test(positions, order, mode,
true, src,
result);
278 run_nurbs_test(positions, order, mode,
false, src,
result);
289 run_nurbs_test(positions, order, mode,
false, src,
result);
300 run_nurbs_test(positions, order, mode,
false, src,
result);
311 run_nurbs_test(positions, order, mode,
false, src,
result, positions.
slice(0, 7));
324 run_nurbs_test(positions, order, mode,
false, src,
result);
330 run_nurbs_test(positions.
slice(0, 9), order, mode,
false, src,
result);
338 run_nurbs_test(positions.
slice(0, 12), order, mode,
false, src,
result, positions.
slice(0, 9));
344 run_nurbs_test(positions.
slice(0, 11), order, mode,
false, src,
result, positions.
slice(0, 9));
350 run_nurbs_test(positions.
slice(0, 10), order, mode,
false, src,
result, positions.
slice(0, 9));
362 run_nurbs_test(positions.
slice(0, 12), order, mode,
true, src,
result);
373 run_nurbs_test(positions, order, mode,
true, src,
result);
383 expected.
append(positions[0]);
384 const bool expect_cyclic =
false;
391 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
401 expected.
append(positions[0]);
402 const bool expect_cyclic =
false;
409 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
419 expected.
append(positions[0]);
420 const bool expect_cyclic =
false;
427 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
437 expected.
append(positions[0]);
438 const bool expect_cyclic =
false;
445 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
468 run_nurbs_test(positions, order, mode,
true, src,
result, expected, &expect_mode);
480 expected.
last() = positions[1];
482 const bool expect_cyclic =
false;
488 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
500 expected.
last() = positions[1];
502 const bool expect_cyclic =
false;
508 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
520 expected.
last() = positions[1];
522 const bool expect_cyclic =
false;
528 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
540 expected.
last() = positions[1];
542 const bool expect_cyclic =
false;
548 positions, order, mode,
true, src,
result, expected, &expect_mode, &expect_cyclic);
565 run_nurbs_test(positions, order, mode,
true, src,
result, expected, &expect_mode);
Low-level operations for curves.
constexpr Span slice(int64_t start, int64_t size) const
constexpr const T * data() const
constexpr const T & first() const
constexpr int64_t size() const
void append(const T &value)
const T & last(const int64_t n=0) const
MutableSpan< T > as_mutable_span()
VArray< int8_t > nurbs_orders() const
VArray< bool > cyclic() const
Span< float3 > positions() const
VArray< int8_t > nurbs_knots_modes() const
Vector< bke::GeometrySet > read_curves(OBJImportParams params)
static bke::CurvesGeometry create_rational_nurbs(Span< float3 > points, Span< float > weights, bool cyclic, int8_t order, KnotsMode mode)
static bke::CurvesGeometry create_nurbs(Span< float3 > points, bool cyclic, int8_t order, KnotsMode mode)
void write_curves(const bke::CurvesGeometry &curve, OBJExportParams params)
void write_curves(const std::unique_ptr< IOBJCurve > &curve, OBJExportParams params)
void write_curves(const Span< std::unique_ptr< IOBJCurve > > curves, OBJExportParams params)
static bke::CurvesGeometry create_curves(Span< float3 > points, bool cyclic)
void run_nurbs_test(const Span< float3 > points, const int8_t order, const KnotsMode mode, const bool cyclic, bke::CurvesGeometry &src_curve, const bke::CurvesGeometry *&result_curve, Span< float3 > expected_points=Span< float3 >(), const KnotsMode *expected_mode=nullptr, const bool *expected_cyclic=nullptr)
OBJCurves(const bke::CurvesGeometry &curve, const float4x4 &transform, const std::string &name)
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
Vector< int > calculate_multiplicity_sequence(Span< float > knots)
void calculate_knots(int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan< float > knots)
int knots_num(int points_num, int8_t order, bool cyclic)
void export_objects(const OBJExportParams &export_params, const Span< std::unique_ptr< OBJMesh > > meshes, const Span< std::unique_ptr< IOBJCurve > > curves, const char *filepath)
static OBJImportParams default_import_params(const std::string &filepath)
static OBJExportParams default_export_params(const std::string &filepath)
TEST_F(OBJExportTest, filter_objects_curves_as_mesh)
const std::array< float3, 13 > position_array
void importer_geometry(const OBJImportParams &import_params, Vector< bke::GeometrySet > &geometries)
const Span< float3 > position_data
char * STRNCPY(char(&dst)[N], const char *src)
MatBase< float, 4, 4 > float4x4
@ NURBS_KNOT_MODE_ENDPOINT_BEZIER
@ NURBS_KNOT_MODE_ENDPOINT
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
const char * BKE_tempdir_base() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
VecBase< float, 3 > float3
void BKE_tempdir_init(const char *userdir)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static MatBase identity()