Blender  V3.3
Namespaces | Classes | Functions
blender::length_parameterize Namespace Reference

Namespaces

 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_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()

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

◆ 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.
Note
#sample_length must not be outside of any segment.

Definition at line 97 of file BLI_length_parameterize.hh.

References blender::Span< T >::begin(), BLI_assert, blender::Span< T >::end(), blender::Span< T >::last(), blender::math::safe_divide(), and blender::Span< T >::size().

Referenced by sample_at_lengths(), blender::nodes::node_geo_curve_sample_cc::sample_indices_and_lengths(), and sample_uniform().

◆ 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 35 of file length_parameterize.cc.

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

Referenced by blender::geometry::interpolate_position_with_interpolation(), blender::ed::sculpt_paint::move_last_point_and_resample(), 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 8 of file length_parameterize.cc.

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

Referenced by blender::length_parameterize::tests::TEST().

◆ 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(), and blender::length_parameterize::tests::calculate_lengths().