| 337 | } |
| 338 | |
| 339 | void LNLib::NurbsVolume::InsertKnot(const LN_NurbsVolume& volume, double insertKnot, int times, VolumeDirection direction, LN_NurbsVolume& result) |
| 340 | { |
| 341 | int degreeU = volume.DegreeU; |
| 342 | int degreeV = volume.DegreeV; |
| 343 | int degreeW = volume.DegreeW; |
| 344 | |
| 345 | std::vector<double> kvU = volume.KnotVectorU; |
| 346 | std::vector<double> kvV = volume.KnotVectorV; |
| 347 | std::vector<double> kvW = volume.KnotVectorW; |
| 348 | |
| 349 | std::vector<std::vector<std::vector<LNLib::XYZW>>> controlPoints = volume.ControlPoints; |
| 350 | |
| 351 | int n = controlPoints.size() - 1; |
| 352 | int m = controlPoints[0].size() - 1; |
| 353 | int l = controlPoints[0][0].size() - 1; |
| 354 | |
| 355 | result.DegreeU = degreeU; |
| 356 | result.DegreeV = degreeV; |
| 357 | result.DegreeW = degreeW; |
| 358 | |
| 359 | std::vector<std::vector<std::vector<LNLib::XYZW>>> newControlPoints; |
| 360 | if (direction == VolumeDirection::U) |
| 361 | { |
| 362 | newControlPoints.resize(n + times + 1, std::vector<std::vector<LNLib::XYZW>>(m + 1, std::vector<LNLib::XYZW>(l + 1))); |
| 363 | } |
| 364 | else if (direction == VolumeDirection::V) |
| 365 | { |
| 366 | newControlPoints.resize(n + 1, std::vector<std::vector<LNLib::XYZW>>(m + times + 1, std::vector<LNLib::XYZW>(l + 1))); |
| 367 | } |
| 368 | else if (direction == VolumeDirection::W) |
| 369 | { |
| 370 | newControlPoints.resize(n + 1, std::vector<std::vector<LNLib::XYZW>>(m + 1, std::vector<LNLib::XYZW>(l + times + 1))); |
| 371 | } |
| 372 | |
| 373 | if (direction == VolumeDirection::U) |
| 374 | { |
| 375 | result.KnotVectorV = kvV; |
| 376 | result.KnotVectorW = kvW; |
| 377 | |
| 378 | std::vector<double> newKvU; |
| 379 | |
| 380 | for (int sep = 0; sep <= l; sep++) |
| 381 | { |
| 382 | for (int col = 0; col <= m; col++) |
| 383 | { |
| 384 | std::vector<LNLib::XYZW> uControlPoints(n + 1); |
| 385 | for (int i = 0; i <= n; ++i) { |
| 386 | uControlPoints[i] = controlPoints[i][col][sep]; |
| 387 | } |
| 388 | |
| 389 | LNLib::LN_NurbsCurve curve; |
| 390 | curve.Degree = degreeU; |
| 391 | curve.KnotVector = kvU; |
| 392 | curve.ControlPoints = uControlPoints; |
| 393 | |
| 394 | LNLib::LN_NurbsCurve resultCurve; |
| 395 | LNLib::NurbsCurve::InsertKnot(curve, insertKnot, times, resultCurve); |
| 396 |
nothing calls this directly
no outgoing calls
no test coverage detected