-
Notifications
You must be signed in to change notification settings - Fork 2
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
Issue147 degree elevation #172
Conversation
cm314
commented
Jul 1, 2019
- fixes algorithm for degree elevation #147 and Decompose NURBS in Bezier-Segments #162
# Conflicts: # src/spl/physical_space.h
# Conflicts: # src/io/io_converter.cc # src/io/io_converter.h # src/io/vtk_writer.h # src/spl/parameter_space.h # src/spl/spline.h # src/spl/weighted_physical_space.h
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.
Why did you change stuff in the IGA part? Shouldn't be necessary for extending the core functionality of the SplineLib 🤔
Apart from this, numerous but only minor remarks made and (style) changes requested :)
Codecov Report
@@ Coverage Diff @@
## master #172 +/- ##
======================================
Coverage 100% 100%
======================================
Files 97 98 +1
Lines 7479 7773 +294
======================================
+ Hits 7479 7773 +294
Continue to review full report at Codecov.
|
…/SplineLib into issue147_degree_elevation
param_coords[i] = ParamCoord{((elm.GetUpperBound() - elm.GetLowerBound()).get() * itg_pnts[i] | ||
+ (elm.GetUpperBound() + elm.GetLowerBound()).get()) / 2.0}; | ||
param_coords[i] = ParamCoord{((elm.GetUpperBound() - elm.GetLowerBound()).get() * itg_pnts[i] + | ||
(elm.GetUpperBound() + elm.GetLowerBound()).get()) / 2.0}; |
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.
Please fix alignment of operands (bold): ... {((...).get() ... + (...).get()) / 2.0};
(spline_->GetKnotVector(i)->GetKnot(knot_span[i] + 1).get() | ||
- spline_->GetKnotVector(i)->GetKnot(knot_span[i]).get()) / 2; | ||
(spline_->GetKnotVector(i)->GetKnot(knot_span[i] + 1).get() - | ||
spline_->GetKnotVector(i)->GetKnot(knot_span[i]).get()) / 2; |
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.
Please fix alignment as described above.
@@ -1,4 +1,4 @@ | |||
Checks: '*,-android-*,-llvm-include-order,-fuchsia-overloaded-operator,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-constant-array-index' | |||
Checks: '*,-hicpp-braces-around-statements,-readability-braces-around-statements,-android-*,-llvm-include-order,-fuchsia-overloaded-operator,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-constant-array-index' |
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.
Are there any other effects that we might not want to have?
@@ -112,6 +112,14 @@ size_t baf::KnotVector::GetNumberOfKnots() const { | |||
return knots_.size(); | |||
} | |||
|
|||
int baf::KnotVector::GetNumberOfDifferentKnots() const { | |||
int number = 1; |
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.
Currently, you add 1 here, as you do not initialize with 0. I would consider to replace int number = 1
by int number_non_zero_knot_spans = 0
and add 1 when returning.
int baf::KnotVector::GetNumberOfDifferentKnots() const { | ||
int number = 1; | ||
for (size_t i = 1; i < knots_.size(); ++i) { | ||
if (knots_[i].get() > knots_[i - 1].get()) ++number; |
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.
++number_non_zero_knot_spans
for (size_t i = 1; i < knots_.size(); ++i) { | ||
if (knots_[i].get() > knots_[i - 1].get()) ++number; | ||
} | ||
return number; |
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.
return (number_non_zero_knot_spans + 1);
@@ -223,6 +202,23 @@ class ParameterSpace { | |||
} | |||
} | |||
|
|||
void RecreateBasisFunctions() { | |||
for (int current_dim = 0; current_dim < DIM; ++current_dim) { |
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.
Please rename current_dim
to current_dimension
. Same for following variables.
basis_functions_current_dim.reserve(knot_vector_current_dim->GetNumberOfKnots() - degree_current_dim.get() - 1); | ||
for (int current_basis_function = 0; | ||
current_basis_function < | ||
(static_cast<int>(knot_vector_current_dim->GetNumberOfKnots()) - degree_current_dim.get() - 1); |
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.
Can you remove the static cast? Could you do the line break after the minus operator?
@@ -77,7 +77,7 @@ class RandomSplineUtils { | |||
std::vector<double> weights; | |||
util::MultiIndexHandler<DIM> point_handler(number_of_points); | |||
for (int i = 0; i < point_handler.Get1DLength(); ++i, ++point_handler) { | |||
weights.emplace_back(util::Random::GetBinomialRandom<double>(0.1, 5, 0.1)); | |||
weights.emplace_back(util::Random::GetBinomialRandom<double>(0.1, 2, 0.1)); |
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.
Feel free to create a task for this :)
for (int i = static_cast<int>(GetKnotVector(dimension)->GetNumberOfDifferentKnots() - 2); i >= 0; --i) { | ||
new_bez_points[i] = DegreeElevateBezierSegment(GetBezierSegment(dimension, i), alpha, dimension); | ||
new_bez_points(static_cast<uint64_t>(this->GetKnotVector(dimension)->GetNumberOfDifferentKnots() - 1)); | ||
for (int current_new_bezier_point = GetKnotVector(dimension)->GetNumberOfDifferentKnots() - 2; |
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.
Should we emphasize that current_new_bezier_point
is not a point but just an index by renaming the variable?
} | ||
return alpha; | ||
} | ||
|
||
std::vector<int> ProduceBezierSegments(int dimension) { | ||
size_t position = GetKnotVector(dimension)->GetNumberOfKnots() - GetDegree(dimension).get() - 2; | ||
auto current_knot = GetDegree(dimension).get() + 1; |
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.
Index again?
src/spl/spline.h
Outdated
for (int k = 0; k < point_handler.Get1DLength(); ++k, ++point_handler) { | ||
auto index = point_handler[0]; | ||
auto pos = point_handler.Get1DIndex(); | ||
double new_weight = point_length == GetPointDim() ? 1.0 : |
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.
At a first glance it seems to me as if there are common operations for B-splines & NURBS during degree elevation. Thus, this functionality should be gathered in the base class spline
. However, calls to functions with different implementations for different spline types are always possible. In this case, a virtual method like ComputeWeightForDegreeElevation
might be appropriate?
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.
Thanks for your changes so far!
} | ||
|
||
void SetNewPoint(baf::ControlPoint new_point, double new_weight, std::array<int, DIM> indices) override { | ||
physical_space_->SetWeightedControlPoint(indices, new_point, new_weight); |
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.
If WeightedPhysicalSpace<DIM>::SetWeightedControlPoint
and PhysicalSpace<DIM>::SetControlPoint
really implement the same functionality only for physical spaces appropriate for NURBS and B-Splines, respectively, then they should be implementations of the same virtual
function! So our problem right now would only be the consequence of a flawed design of these more fundamental classes.
I'm closing this pull request now as I've connected all open conversations to issues and this branch is outdated. |