fix: ruled/extrude surface u/v parameter swap in grid layout
CI / Build & Test (push) Failing after 32s
CI / Release Build (push) Failing after 34s

This commit is contained in:
茂之钳
2026-07-24 10:34:16 +00:00
parent b7af37f7ff
commit d84688720f
2 changed files with 28 additions and 26 deletions
+15 -19
View File
@@ -360,30 +360,26 @@ NurbsSurface extrude_curve(const NurbsCurve& curve,
Vector3D dir_n = direction.normalized();
Vector3D offset = dir_n * length;
std::vector<std::vector<Point3D>> grid(2);
std::vector<std::vector<double>> w(2);
grid[0] = cp;
grid[1].reserve(n);
w[0] = weights;
w[1].reserve(n);
// Build control grid as grid[u][v]: u=curve direction, v=extrusion direction
std::vector<std::vector<Point3D>> grid(n);
std::vector<std::vector<double>> w(n);
for (int i = 0; i < n; ++i) {
grid[1].push_back(Point3D(
cp[i].x() + offset.x(),
cp[i].y() + offset.y(),
cp[i].z() + offset.z()
));
w[1].push_back(i < static_cast<int>(weights.size()) ? weights[i] : 1.0);
grid[i] = {
cp[i],
Point3D(cp[i].x() + offset.x(),
cp[i].y() + offset.y(),
cp[i].z() + offset.z())
};
double wi = i < static_cast<int>(weights.size()) ? weights[i] : 1.0;
w[i] = {wi, wi};
}
// v-knots: linear degree-1 in extrusion direction
// u-knots: inherit from curve
return NurbsSurface(grid,
{0.0, 0.0, 1.0, 1.0}, // v-direction knots (degree 1)
curve.knots(), // u-direction knots
curve.knots(), // ku — u-direction knots from profile curve
{0.0, 0.0, 1.0, 1.0}, // kv — v-direction knots (linear extrusion)
w,
1, // degree_v = 1 (linear extrusion)
curve.degree()); // degree_u = curve's degree
curve.degree(), // du — curve degree in u-direction
1); // dv — linear in v-direction
}
} // namespace vde::curves
+13 -7
View File
@@ -78,15 +78,21 @@ Vector3D NurbsSurface::normal(double u, double v) const {
}
NurbsSurface NurbsSurface::ruled(const NurbsCurve& c1, const NurbsCurve& c2) {
std::vector<std::vector<Point3D>> grid(2);
// Build grid[u_index][v_index]: u along curve1->curve2, v along curves
const auto& cp1 = c1.control_points();
const auto& cp2 = c2.control_points();
grid[0] = cp1;
grid[1] = cp2;
std::vector<std::vector<double>> w(2);
w[0] = c1.weights();
w[1] = c2.weights();
return NurbsSurface(grid, {0,0,1,1}, c1.knots(), w, 1, c1.degree());
int n = static_cast<int>(cp1.size());
const auto& w1 = c1.weights();
const auto& w2 = c2.weights();
std::vector<std::vector<Point3D>> grid(n);
std::vector<std::vector<double>> w(n);
for (int i = 0; i < n; ++i) {
grid[i] = {cp1[i], cp2[i]};
double wi = i < static_cast<int>(w1.size()) ? w1[i] : 1.0;
double wij = i < static_cast<int>(w2.size()) ? w2[i] : 1.0;
w[i] = {wi, wij};
}
return NurbsSurface(grid, c1.knots(), {0,0,1,1}, w, c1.degree(), 1);
}
NurbsSurface NurbsSurface::revolve(const NurbsCurve& profile,