Blender V4.3
blender::length_parameterize Namespace Reference

Namespaces

namespace  tests
 

Classes

struct  SampleSegmentHint
 

Functions

int segments_num (const int points_num, const bool cyclic)
 
template<typename T >
void accumulate_lengths (const Span< T > values, const bool cyclic, MutableSpan< float > lengths)
 
template<typename T >
void interpolate_to_masked (const Span< T > src, const Span< int > indices, const Span< float > factors, const IndexMask &dst_mask, MutableSpan< T > dst)
 
template<typename T >
void interpolate (const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
 
void sample_at_length (const Span< float > accumulated_segment_lengths, const float sample_length, int &r_segment_index, float &r_factor, SampleSegmentHint *hint=nullptr)
 
void sample_uniform (Span< float > accumulated_segment_lengths, bool include_last_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
 
void sample_uniform_reverse (Span< float > accumulated_segment_lengths, bool include_first_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
 
void sample_at_lengths (Span< float > accumulated_segment_lengths, Span< float > sample_lengths, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
 

Function Documentation

◆ accumulate_lengths()

template<typename T >
void blender::length_parameterize::accumulate_lengths ( const Span< T > values,
const bool cyclic,
MutableSpan< float > lengths )

◆ interpolate()

◆ interpolate_to_masked()

template<typename T >
void blender::length_parameterize::interpolate_to_masked ( const Span< T > src,
const Span< int > indices,
const Span< float > factors,
const IndexMask & dst_mask,
MutableSpan< T > dst )
inline

◆ sample_at_length()

void blender::length_parameterize::sample_at_length ( const Span< float > accumulated_segment_lengths,
const float sample_length,
int & r_segment_index,
float & r_factor,
SampleSegmentHint * hint = nullptr )
inline
Parameters
accumulated_segment_lengthsLengths of individual segments added up. Each value describes the total length at the end of the segment following a point.
sample_lengthThe position to sample at.
r_segment_indexReturns the index of the segment that #sample_length is in.
r_factorReturns the position within the segment.

Definition at line 97 of file BLI_length_parameterize.hh.

References BLI_assert, and blender::math::safe_divide().

Referenced by blender::geometry::lookup_point_bezier(), blender::geometry::lookup_point_polygonal(), blender::geometry::lookup_point_uniform_spacing(), sample_at_lengths(), blender::nodes::node_geo_curve_sample_cc::sample_indices_and_factors_to_compressed(), blender::nodes::node_geo_curve_sample_cc::sample_indices_and_lengths(), sample_uniform(), and sample_uniform_reverse().

◆ sample_at_lengths()

void blender::length_parameterize::sample_at_lengths ( Span< float > accumulated_segment_lengths,
Span< float > sample_lengths,
MutableSpan< int > r_segment_indices,
MutableSpan< float > r_factors )

For each provided sample length, find the segment index and interpolation factor.

Parameters
accumulated_segment_lengthsThe accumulated lengths of the original elements being sampled. Could be calculated by accumulate_lengths.
sample_lengthsSampled locations in the #lengths array. Must be sorted and is expected to be within the range of the #lengths values.
r_segment_indicesThe index of the previous point at each sample.
r_factorsThe portion of the length in each segment at each sample.

Definition at line 69 of file length_parameterize.cc.

References blender::Span< T >::begin(), BLI_assert, count, blender::Span< T >::end(), blender::threading::parallel_for(), range, sample_at_length(), blender::MutableSpan< T >::size(), and blender::Span< T >::size().

Referenced by blender::ed::sculpt_paint::greasepencil::morph_points_to_curve(), blender::ed::sculpt_paint::move_last_point_and_resample(), blender::length_parameterize::tests::TEST(), and blender::length_parameterize::tests::TEST().

◆ sample_uniform()

void blender::length_parameterize::sample_uniform ( Span< float > accumulated_segment_lengths,
bool include_last_point,
MutableSpan< int > r_segment_indices,
MutableSpan< float > r_factors )

Find evenly spaced samples along the lengths.

Parameters
accumulated_segment_lengthsThe accumulated lengths of the original elements being sampled. Could be calculated by accumulate_lengths.
include_last_pointGenerally false for cyclic sequences and true otherwise.
r_segment_indicesThe index of the previous point at each sample.
r_factorsThe portion of the length in each segment at each sample.

Definition at line 11 of file length_parameterize.cc.

References blender::Span< T >::begin(), BLI_assert, count, blender::Span< T >::end(), blender::Span< T >::last(), blender::threading::parallel_for(), range, sample_at_length(), blender::MutableSpan< T >::size(), and blender::Span< T >::size().

Referenced by blender::geometry::resample_to_uniform(), blender::length_parameterize::tests::TEST(), blender::length_parameterize::tests::TEST(), blender::length_parameterize::tests::TEST(), blender::length_parameterize::tests::TEST(), blender::length_parameterize::tests::TEST(), blender::length_parameterize::tests::TEST(), and blender::length_parameterize::tests::TEST().

◆ sample_uniform_reverse()

void blender::length_parameterize::sample_uniform_reverse ( Span< float > accumulated_segment_lengths,
bool include_first_point,
MutableSpan< int > r_segment_indices,
MutableSpan< float > r_factors )

Find evenly spaced samples along the lengths, starting at the end.

Parameters
accumulated_segment_lengthsThe accumulated lengths of the original elements being sampled. Could be calculated by accumulate_lengths.
include_first_pointGenerally false for cyclic sequences and true otherwise.
r_segment_indicesThe index of the previous point at each sample.
r_factorsThe portion of the length in each segment at each sample.

Definition at line 40 of file length_parameterize.cc.

References blender::Span< T >::begin(), BLI_assert, count, blender::Span< T >::end(), blender::Span< T >::last(), blender::threading::parallel_for(), range, sample_at_length(), blender::MutableSpan< T >::size(), and blender::Span< T >::size().

◆ segments_num()

int blender::length_parameterize::segments_num ( const int points_num,
const bool cyclic )
inline

Return the size of the necessary lengths array for a group of points, taking into account the possible last cyclic segment.

Note
This is the same as bke::curves::segments_num.

Definition at line 22 of file BLI_length_parameterize.hh.

Referenced by accumulate_lengths(), blender::length_parameterize::tests::calculate_lengths(), and blender::ed::sculpt_paint::move_last_point_and_resample().