28 BLI_assert(!curve_geometry_.nurbs_element_.curv_indices.is_empty());
41 this->create_nurbs(curve, import_params);
48 if (curve_geometry_.nurbs_element_.curv_indices.is_empty()) {
53 if (ob_name.empty() && !curve_geometry_.nurbs_element_.group_.empty()) {
54 ob_name = curve_geometry_.nurbs_element_.group_;
56 if (ob_name.empty()) {
70 this->create_nurbs(curve, import_params);
81 const int degree = std::max(1, std::min<int>(
element.degree,
element.curv_indices.size() - 1));
82 return degree + 1 > std::numeric_limits<int8_t>::max() ? std::numeric_limits<int8_t>::max() - 1 :
95 return std::max<int>(order - end_multiplicity, 1);
100 const NurbsElement &nurbs_geometry = curve_geometry_.
nurbs_element_;
116 nurbs_geometry.parm);
117 nurb->
flagu = this->detect_knot_mode(
118 import_params, degree, nurbs_geometry.curv_indices, nurbs_geometry.parm, multiplicity);
130 nurbs_geometry.curv_indices.index_range().drop_back(repeated_points));
133 for (
const int i :
indices.index_range()) {
153 const int8_t order = degree + 1;
154 return multiplicity.
first() == order && multiplicity.
last() == order;
162 constexpr float epsilon = 1
e-7;
163 const int8_t order = degree + 1;
169 if (multiplicity.
first() != multiplicity.
last()) {
178 if (multiplicity.
first() > order || multiplicity.
last() > order) {
191 if (multiplicity.
first() >= degree) {
200 const float head_span = knots[
i + 1] - knots[
i];
201 const float tail_span = knots_tail[
i + 1] - knots_tail[
i];
202 if (
abs(head_span - tail_span) > epsilon) {
211 const int8_t order = degree + 1;
212 if (multiplicity.
first() != order || multiplicity.
last() != order) {
229 constexpr float epsilon = 1
e-7;
234 const int clamped_offset = clamped * degree;
235 if (knots.
size() != multiplicity.
size() - 2 * clamped_offset) {
241 if (!unclamped_knots.
size()) {
246 const float uniform_delta = unclamped_knots[1] - unclamped_knots[0];
248 if (
abs((knots[
i] - knots[
i - 1]) - uniform_delta) < epsilon) {
255short CurveFromGeometry::detect_knot_mode(
const OBJImportParams &import_params,
void BKE_curve_init(Curve *cu, short curve_type)
ListBase * BKE_curve_nurbs_get(Curve *cu)
void BKE_nurb_knot_calc_u(Nurb *nu)
Curve * BKE_curve_add(Main *bmain, const char *name, int type)
void BKE_nurb_knot_alloc_u(Nurb *nu)
void BKE_nurb_points_add(Nurb *nu, int number)
Low-level operations for curves.
void * BKE_id_new_nomain(short type, const char *name)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define SET_FLAG_FROM_TEST(value, test, flag)
ATTR_WARN_UNUSED_RESULT const void * element
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
constexpr IndexRange drop_back(int64_t n) const
constexpr IndexRange drop_front(int64_t n) const
constexpr Span drop_front(int64_t n) const
constexpr Span take_back(int64_t n) const
constexpr Span drop_back(int64_t n) const
constexpr const T & first() const
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr IndexRange index_range() const
Curve * create_curve(const OBJImportParams &import_params)
Object * create_curve_object(Main *bmain, const OBJImportParams &import_params)
void * MEM_callocN(size_t len, const char *str)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
Vector< int > calculate_multiplicity_sequence(Span< float > knots)
static int8_t get_valid_nurbs_degree(const NurbsElement &element)
static bool detect_clamped_endpoint(const int8_t degree, const Span< int > multiplicity)
static int cyclic_repeated_points(const int8_t order, const int end_multiplicity)
static bool detect_knot_mode_cyclic(const int8_t degree, const Span< int > indices, const Span< float > knots, const Span< int > multiplicity)
void transform_object(Object *object, const OBJImportParams &import_params)
static bool detect_knot_mode_uniform(const int8_t degree, const Span< float > knots, const Span< int > multiplicity, bool clamped)
static bool detect_knot_mode_bezier(const int8_t degree, const Span< int > multiplicity)
std::string get_geometry_name(const std::string &full_name, char separator)
char collection_separator
NurbsElement nurbs_element_
Vector< float > vertex_weights
Vector< float3 > vertices