-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Use CubicBezierSampler
to sample curves
#479
Conversation
@@ -49,6 +49,11 @@ class Point3d | |||
|
|||
using value_type = T; | |||
|
|||
Point3d(T x, T y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need new constructors of Point3d
and Segment3d
.
{ | ||
} | ||
|
||
CubicBezierSampler() = delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper class template does not need default and copy constructors.
|
||
static size_t sample_to(bezier_type const & c, segment_pad_type & segment, size_t nlocus); | ||
|
||
std::shared_ptr<segment_pad_type> m_segments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal segment pad.
}; /* end class CubicBezierSampler */ | ||
|
||
template <typename T> | ||
size_t CubicBezierSampler<T>::calc_nlocus(Bezier3d<T> const & c, T length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calculate number of locus based on p0-p3.
} | ||
|
||
template <typename T> | ||
size_t CubicBezierSampler<T>::sample_to(bezier_type const & c, segment_pad_type & segments, size_t nlocus) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a naive sampling algorithm to add segments to a container.
} | ||
spad->set(iseg, lastp, tp3); | ||
++iseg; | ||
sample_to(c, *m_segments, nlocus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add sampled segments to the internal pad.
template <typename T> | ||
std::shared_ptr<SegmentPad<T>> CubicBezierSampler<T>::operator()(bezier_type const & curve, size_t nlocus, bool inplace) | ||
{ | ||
std::shared_ptr<segment_pad_type> segments = inplace ? m_segments : segment_pad_type::construct(m_segments->ndim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow switching between a new or internal pad.
@YenPeiChen07 @j8xixo12 please take a look |
Make a (new) common helper class template
CubicBezierSampler
to sample for a single cubic Bezier curve or a sequence of cubic Bezier curves inCurvePad
.