|
29 | 29 | //function : AddPointIntoLine |
30 | 30 | //purpose : |
31 | 31 | //======================================================================= |
32 | | -static inline void AddPointIntoLine(Handle(IntSurf_LineOn2S) theLine, |
| 32 | +static inline void AddPointIntoLine(Handle(IntSurf_LineOn2S)& theLine, |
33 | 33 | const Standard_Real* const theArrPeriods, |
34 | 34 | IntSurf_PntOn2S &thePoint, |
35 | 35 | IntPatch_Point* theVertex = 0) |
@@ -252,6 +252,69 @@ void IntPatch_ALineToWLine::SetTolOpenDomain(const Standard_Real aTol) |
252 | 252 | return myTolOpenDomain; |
253 | 253 | } |
254 | 254 |
|
| 255 | +//======================================================================= |
| 256 | +//function : CorrectEndPoint |
| 257 | +//purpose : |
| 258 | +//======================================================================= |
| 259 | +void IntPatch_ALineToWLine::CorrectEndPoint(Handle(IntSurf_LineOn2S)& theLine, |
| 260 | + const Standard_Integer theIndex) const |
| 261 | +{ |
| 262 | + const Standard_Real aTol = 1.e-5; |
| 263 | + const Standard_Real aSqTol = 1.e-10; |
| 264 | + |
| 265 | + //Perform linear extrapolation from two previous points |
| 266 | + Standard_Integer anIndFirst, anIndSecond; |
| 267 | + if (theIndex == 1) |
| 268 | + { |
| 269 | + anIndFirst = 3; |
| 270 | + anIndSecond = 2; |
| 271 | + } |
| 272 | + else |
| 273 | + { |
| 274 | + anIndFirst = theIndex - 2; |
| 275 | + anIndSecond = theIndex - 1; |
| 276 | + } |
| 277 | + IntSurf_PntOn2S aPntOn2S = theLine->Value(theIndex); |
| 278 | + |
| 279 | + for (Standard_Integer ii = 1; ii <= 2; ii++) |
| 280 | + { |
| 281 | + Standard_Boolean anIsOnFirst = (ii == 1); |
| 282 | + |
| 283 | + const IntSurf_Quadric& aQuad = (ii == 1)? myQuad1 : myQuad2; |
| 284 | + if (aQuad.TypeQuadric() == GeomAbs_Cone) |
| 285 | + { |
| 286 | + const gp_Cone aCone = aQuad.Cone(); |
| 287 | + const gp_Pnt anApex = aCone.Apex(); |
| 288 | + if (anApex.SquareDistance (aPntOn2S.Value()) > aSqTol) |
| 289 | + continue; |
| 290 | + } |
| 291 | + else if (aQuad.TypeQuadric() == GeomAbs_Sphere) |
| 292 | + { |
| 293 | + Standard_Real aU, aV; |
| 294 | + aPntOn2S.ParametersOnSurface(anIsOnFirst, aU, aV); |
| 295 | + if (Abs(aV - M_PI/2) > aTol && |
| 296 | + Abs(aV + M_PI/2) > aTol) |
| 297 | + continue; |
| 298 | + } |
| 299 | + else |
| 300 | + continue; |
| 301 | + |
| 302 | + gp_Pnt2d PrevPrevP2d = theLine->Value(anIndFirst).ValueOnSurface(anIsOnFirst); |
| 303 | + gp_Pnt2d PrevP2d = theLine->Value (anIndSecond).ValueOnSurface(anIsOnFirst); |
| 304 | + gp_Dir2d aDir = gp_Vec2d(PrevPrevP2d, PrevP2d); |
| 305 | + Standard_Real aX0 = PrevPrevP2d.X(), aY0 = PrevPrevP2d.Y(); |
| 306 | + Standard_Real aXend, aYend; |
| 307 | + aPntOn2S.ParametersOnSurface(anIsOnFirst, aXend, aYend); |
| 308 | + |
| 309 | + if (Abs(aDir.Y()) < gp::Resolution()) |
| 310 | + continue; |
| 311 | + |
| 312 | + Standard_Real aNewXend = aDir.X()/aDir.Y() * (aYend - aY0) + aX0; |
| 313 | + |
| 314 | + theLine->SetUV (theIndex, anIsOnFirst, aNewXend, aYend); |
| 315 | + } |
| 316 | +} |
| 317 | + |
255 | 318 | //======================================================================= |
256 | 319 | //function : GetSectionRadius |
257 | 320 | //purpose : |
@@ -331,24 +394,27 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
331 | 394 | #if 0 |
332 | 395 | //To draw ALine as a wire DRAW-object use the following code. |
333 | 396 | { |
334 | | - static int zzz = 0; |
335 | | - zzz++; |
| 397 | + static int ind = 0; |
| 398 | + ind++; |
336 | 399 |
|
337 | | - bool flShow = /*(zzz == 1)*/false; |
| 400 | + bool flShow = true; |
338 | 401 |
|
339 | 402 | if (flShow) |
340 | 403 | { |
341 | 404 | std::cout << " +++ DUMP ALine (begin) +++++" << std::endl; |
342 | | - Standard_Integer aI = 0; |
343 | | - const Standard_Real aStep = (theLPar - theFPar) / 9999.0; |
344 | | - for (Standard_Real aPrm = theFPar; aPrm < theLPar; aPrm += aStep) |
| 405 | + const Standard_Integer NbSamples = 20; |
| 406 | + const Standard_Real aStep = (theLPar - theFPar) / NbSamples; |
| 407 | + char* name = new char[100]; |
| 408 | + |
| 409 | + for (Standard_Integer ii = 0; ii <= NbSamples; ii++) |
345 | 410 | { |
| 411 | + Standard_Real aPrm = theFPar + ii * aStep; |
346 | 412 | const gp_Pnt aPP(theALine->Value(aPrm)); |
347 | | - std::cout << "vertex v" << ++aI << " " << aPP.X() << " " << aPP.Y() << " " << aPP.Z() << std::endl; |
348 | | - } |
| 413 | + std::cout << "vertex v" << ii << " " << aPP.X() << " " << aPP.Y() << " " << aPP.Z() << std::endl; |
349 | 414 |
|
350 | | - gp_Pnt aPP(theALine->Value(theLPar)); |
351 | | - std::cout << "vertex v" << ++aI << " " << aPP.X() << " " << aPP.Y() << " " << aPP.Z() << std::endl; |
| 415 | + sprintf(name, "p%d_%d", ii, ind); |
| 416 | + Draw::Set(name, aPP); |
| 417 | + } |
352 | 418 | std::cout << " --- DUMP ALine (end) -----" << std::endl; |
353 | 419 | } |
354 | 420 | } |
@@ -435,6 +501,8 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
435 | 501 |
|
436 | 502 | Standard_Integer aNewVertID = 0; |
437 | 503 | aLinOn2S = new IntSurf_LineOn2S; |
| 504 | + Standard_Boolean anIsFirstDegenerated = Standard_False, |
| 505 | + anIsLastDegenerated = Standard_False; |
438 | 506 |
|
439 | 507 | const Standard_Real aStepMin = 0.1*aStep, aStepMax = 10.0*aStep; |
440 | 508 |
|
@@ -467,6 +535,9 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
467 | 535 | { |
468 | 536 | // We cannot compute 2D-parameters of |
469 | 537 | // aPOn2S correctly. |
| 538 | + |
| 539 | + if (anIsLastDegenerated) //the current last point is wrong |
| 540 | + aLinOn2S->RemovePoint (aLinOn2S->NbPoints()); |
470 | 541 |
|
471 | 542 | isPointValid = Standard_False; |
472 | 543 | } |
@@ -591,6 +662,27 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
591 | 662 | AddPointIntoLine(aLinOn2S, anArrPeriods, aPOn2S); |
592 | 663 | aPrevLPoint = aPOn2S; |
593 | 664 | } |
| 665 | + else |
| 666 | + { |
| 667 | + //add point, set correxponding status: to be corrected later |
| 668 | + Standard_Boolean ToAdd = Standard_False; |
| 669 | + if (aLinOn2S->NbPoints() == 0) |
| 670 | + { |
| 671 | + anIsFirstDegenerated = Standard_True; |
| 672 | + ToAdd = Standard_True; |
| 673 | + } |
| 674 | + else if (aLinOn2S->NbPoints() > 1) |
| 675 | + { |
| 676 | + anIsLastDegenerated = Standard_True; |
| 677 | + ToAdd = Standard_True; |
| 678 | + } |
| 679 | + |
| 680 | + if (ToAdd) |
| 681 | + { |
| 682 | + AddPointIntoLine(aLinOn2S, anArrPeriods, aPOn2S); |
| 683 | + aPrevLPoint = aPOn2S; |
| 684 | + } |
| 685 | + } |
594 | 686 |
|
595 | 687 | continue; |
596 | 688 | } |
@@ -630,6 +722,15 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
630 | 722 |
|
631 | 723 | aPrePointExist = IsPoleOrSeam(myS1, myS2, aPrefIso, aLinOn2S, aVtx, |
632 | 724 | anArrPeriods, aTol, aSingularSurfaceID); |
| 725 | + if (aPrePointExist == IntPatch_SPntPole || |
| 726 | + aPrePointExist == IntPatch_SPntPoleSeamU) |
| 727 | + { |
| 728 | + //set correxponding status: to be corrected later |
| 729 | + if (aLinOn2S->NbPoints() == 1) |
| 730 | + anIsFirstDegenerated = Standard_True; |
| 731 | + else |
| 732 | + anIsLastDegenerated = Standard_True; |
| 733 | + } |
633 | 734 |
|
634 | 735 | const Standard_Real aCurVertParam = aVtx.ParameterOnLine(); |
635 | 736 | if(aPrePointExist != IntPatch_SPntNone) |
@@ -702,6 +803,15 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, |
702 | 803 | continue; |
703 | 804 | } |
704 | 805 |
|
| 806 | + //Correct first and last points if needed |
| 807 | + if (aLinOn2S->NbPoints() >= 3) |
| 808 | + { |
| 809 | + if (anIsFirstDegenerated) |
| 810 | + CorrectEndPoint (aLinOn2S, 1); |
| 811 | + if (anIsLastDegenerated) |
| 812 | + CorrectEndPoint (aLinOn2S, aLinOn2S->NbPoints()); |
| 813 | + } |
| 814 | + |
705 | 815 | //----------------------------------------------------------------- |
706 | 816 | //-- W L i n e c r e a t i o n --- |
707 | 817 | //----------------------------------------------------------------- |
|
0 commit comments