]> OCCT Git - occt-copy.git/commitdiff
0023820: Wrong result of projection algorithm when a polygon geometry is projected...
authorsneeraj <Neeraj.Srinivasan@geometricglobal.com>
Thu, 7 Mar 2013 15:19:23 +0000 (20:49 +0530)
committersneeraj <Neeraj.Srinivasan@geometricglobal.com>
Thu, 7 Mar 2013 15:19:23 +0000 (20:49 +0530)
src/BRepAlgo/BRepAlgo_NormalProjection.cxx
src/ProjLib/ProjLib_CompProjectedCurve.cxx

index acb9e17b96254d96ebda0f3e6ae732af6199e814..03921efb61637e3e39e7f69b9fd95a6815f5c0ec 100755 (executable)
@@ -480,46 +480,55 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
            InitChron(chr_booltool);
 #endif
             if(!Degenerated){
-              BRepAlgo_BooleanOperations BoolTool;
-              BoolTool.Shapes2d(Faces->Value(j),prj);
-              BoolTool.Common();
-              Handle(TopOpeBRepBuild_HBuilder) HB;
-              TopTools_ListOfShape LS;
-              TopTools_ListIteratorOfListOfShape Iter; 
-              HB = BoolTool.Builder();
-              LS.Clear();
-              if (HB->IsSplit(prj, TopAbs_IN))
-                LS = HB->Splits(prj, TopAbs_IN);
-              Iter.Initialize(LS);
-              if(Iter.More()) {
-#ifdef DEBUG
-                  cout << " BooleanOperations :"  << Iter.More()<<" solutions " << endl; 
-#endif
-                 for(; Iter.More(); Iter.Next()) {
-                    BB.Add(myRes, Iter.Value());
-                    myAncestorMap.Bind(Iter.Value(), Edges->Value(i));
-                    myCorresp.Bind(Iter.Value(),Faces->Value(j));
-                 }
-              }
-
-              else {
-
-                BRepTopAdaptor_FClass2d classifier(TopoDS::Face(Faces->Value(j)),
-                                                   Precision::Confusion());
-                gp_Pnt2d Puv;
-                Standard_Real f = PCur2d->FirstParameter();
-                Standard_Real l = PCur2d->LastParameter();
-                Standard_Real pmil = (f + l )/2;
-                PCur2d->D0(pmil, Puv);
-                TopAbs_State state;
-                state = classifier.Perform(Puv);
-                if(state == TopAbs_IN || state  == TopAbs_ON) {
-                  BB.Add(myRes, prj);
-                  DescenList.Append(prj);
-                  myAncestorMap.Bind(prj, Edges->Value(i));   
-                  myCorresp.Bind(prj, Faces->Value(j));
-                }
-              }
+                       
+                // {Fix for Issue 0023820 ... introducing try-catch so that result of the previous iteration is kept
+                try
+                {
+                    BRepAlgo_BooleanOperations BoolTool;
+                    BoolTool.Shapes2d(Faces->Value(j),prj);
+                    BoolTool.Common();
+                    Handle(TopOpeBRepBuild_HBuilder) HB;
+                    TopTools_ListOfShape LS;
+                    TopTools_ListIteratorOfListOfShape Iter; 
+                    HB = BoolTool.Builder();
+                    LS.Clear();
+                    if (HB->IsSplit(prj, TopAbs_IN))
+                    LS = HB->Splits(prj, TopAbs_IN);
+                    Iter.Initialize(LS);
+
+                    if(Iter.More()) {
+    #ifdef DEBUG
+                        cout << " BooleanOperations :"  << Iter.More()<<" solutions " << endl; 
+    #endif
+                        for(; Iter.More(); Iter.Next()) {
+                            BB.Add(myRes, Iter.Value());
+                            myAncestorMap.Bind(Iter.Value(), Edges->Value(i));
+                            myCorresp.Bind(Iter.Value(),Faces->Value(j));
+                        }
+                    }
+                    else {
+
+                        BRepTopAdaptor_FClass2d classifier(TopoDS::Face(Faces->Value(j)),
+                                Precision::Confusion());
+                        gp_Pnt2d Puv;
+                        Standard_Real f = PCur2d->FirstParameter();
+                        Standard_Real l = PCur2d->LastParameter();
+                        Standard_Real pmil = (f + l )/2;
+                        PCur2d->D0(pmil, Puv);
+                        TopAbs_State state;
+                        state = classifier.Perform(Puv);
+
+                        if(state == TopAbs_IN || state  == TopAbs_ON) {
+                            BB.Add(myRes, prj);
+                            DescenList.Append(prj);
+                            myAncestorMap.Bind(prj, Edges->Value(i));   
+                            myCorresp.Bind(prj, Faces->Value(j));
+                        }
+                    }
+                }
+                catch (Standard_Failure) {
+                    continue;
+                }
             }
             else {
 #ifdef DEB
index 5d32f2514ae1943e6ed7a0adf023c0a0c592323b..7926653144d531a654f9320aed104ae74017e7fa 100755 (executable)
@@ -579,9 +579,24 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
   
   FirstU = myCurve->FirstParameter();
   LastU  = myCurve->LastParameter();
+
+  // {Fix for Issue 0023820 ... 
+  // Taking derivative of the curve in the parametric space of the curve
+  gp_Pnt Pt;
+  gp_Vec V;
+
+  myCurve->D1(FirstU, Pt, V);
+  Standard_Real VD1 = V.Magnitude();
+  // ... Fix for Issue 0023820}
+
   const Standard_Real MinStep = 0.01*(LastU - FirstU), 
                       MaxStep = 0.1*(LastU - FirstU);
-  SearchStep = 10*MinStep;
+  
+  // {Fix for Issue 0023820 ...
+  // The step is taken to be minimum of the two values given below.
+  // The 2nd variable gives the 1/10th of the rate of change of parameter
+  SearchStep = Min(10*MinStep, 0.1/VD1);
+  // ... Fix for Issue 0023820}
   Step = SearchStep;
   
   //Initialization of aPrjPS
@@ -833,19 +848,19 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point,
          if (t == LastU) {t = LastU + 1; break;}//return;
 
           //Computation of WalkStep
-         d2CurvOnSurf(Triple.X(), Triple.Y(), Triple.Z(), D1, D2, myCurve, mySurface);
-         MagnD1 = D1.Magnitude();
-         MagnD2 = D2.Magnitude();
-         if(MagnD2 < Precision::Confusion() ) WalkStep = MaxStep;
-         else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2));
-       
-         Step = WalkStep;
-         t += Step;
-         if (t > (LastU-MinStep/2) ) 
-         
-           Step =Step+LastU-t;
-           t = LastU;
-         }     
+      d2CurvOnSurf(Triple.X(), Triple.Y(), Triple.Z(), D1, D2, myCurve, mySurface);
+      MagnD1 = D1.Magnitude();
+      MagnD2 = D2.Magnitude();
+      if(MagnD2 < Precision::Confusion() ) WalkStep = MaxStep;   
+      else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2));
+    
+      Step = WalkStep;
+      t += Step;
+      if (t > (LastU-MinStep/2) ) 
+      { 
+        Step =Step+LastU-t;
+        t = LastU;
+      }        
           DecStep=Step;
       }
     }
@@ -1410,8 +1425,19 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
                           gp_Pnt2d(Tol, myTolV), 
                           gp_Pnt2d(Tl, mySurface->FirstVParameter()), 
                           gp_Pnt2d(Tr, mySurface->LastVParameter()));
-         TUdisc.Append(Solver.Solution().X());
-       }
+
+      // {Fix for Issue 0023820 ... 
+      // Continue and preserve the projection result of the previous iteration
+         try
+         {
+          TUdisc.Append(Solver.Solution().X());
+      }
+      catch (Standard_Failure)  
+      {
+          ; // just continue
+      }
+      // ... Fix for Issue 0023820}
+    }
       }
   }
   for(i = 2; i <= TUdisc.Length(); i++)
@@ -1464,8 +1490,17 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t,
                          gp_Pnt2d(Tol, myTolV), 
                          gp_Pnt2d(Tl, mySurface->FirstUParameter()), 
                          gp_Pnt2d(Tr, mySurface->LastUParameter()));
-                        TVdisc.Append(Solver.Solution().X());
-       }
+      
+         // We Want to preserve the previous projection result and continue
+         try
+      {
+           TVdisc.Append(Solver.Solution().X());
+      }
+      catch (Standard_Failure)
+      {
+      
+      }
+    }
       }
   }
   for(i = 2; i <= TVdisc.Length(); i++)