0024899: Time of computation of intersection points with help of class BRepIntCurveSu...
authorgka <gka@opencascade.com>
Thu, 15 May 2014 13:52:43 +0000 (17:52 +0400)
committerapn <apn@opencascade.com>
Thu, 15 May 2014 13:53:14 +0000 (17:53 +0400)
Sorting by intersection of bounding boxes of faces with line or box built for curve was added.
Recursive call method Find() was replaced on sequential call.
Added method Init  to initialize algorithm by separate curve for intersection of shape by multiple curves.
Added possibility to intersect shape by multiple curves in DRAW command.

Added test case bugs/modalg_5/bug24899

src/BRepFill/BRepFill_MultiLine.cxx
src/BRepFill/BRepFill_TrimSurfaceTool.cxx
src/BRepIntCurveSurface/BRepIntCurveSurface.cdl
src/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cdl
src/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx
src/BRepTest/BRepTest_OtherCommands.cxx
src/LocOpe/LocOpe_CurveShapeIntersector.cxx
tests/bugs/modalg_5/bug24899 [new file with mode: 0644]

index 2da32eb..b3d785f 100644 (file)
@@ -40,7 +40,7 @@
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <ElCLib.hxx>
-
+#include <GeomAdaptor_Curve.hxx>
 
 #include <GeomAdaptor_Surface.hxx>
 #include <GeomAbs_SurfaceType.hxx>
index 888127a..ca9815f 100644 (file)
@@ -59,6 +59,7 @@
 #include <TopExp.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <TopExp_Explorer.hxx>
 
 #ifdef DRAW
 #include <DrawTrSurf.hxx>
@@ -434,7 +435,7 @@ Standard_Boolean BRepFill_TrimSurfaceTool::IsOnFace
 
   // eval if is on face 1
 //  modified by NIZHNY-EAP Fri Jan 21 09:49:09 2000 ___BEGIN___
-  Inter.Init(myFace1, Line, 1e-6);//Precision::PConfusion());
+  Inter.Init(myFace1, Line,1e-6);//Precision::PConfusion());
   if (Inter.More()) return Standard_True;
   
   // eval if is on face 2
index 4cd58e9..34f3e93 100644 (file)
@@ -37,7 +37,9 @@ uses
      TopAbs, 
      TopExp,
      StdFail,
-     gp
+     gp,
+     Bnd,
+     TopTools
 
 is
 
index 5ccab97..ba73675 100644 (file)
 
 class Inter from BRepIntCurveSurface 
 
-       ---Purpose: Computes the intersection between a face and a curve
+       ---Purpose: Computes the intersection between a face and a
+       --          curve. To intersect one curve with shape method
+       --          Init(Shape, curve, tTol) should be used.  To
+       --          intersect a few curves with specified shape it is
+       --          necessary to load shape one time using method
+       --          Load(shape, tol) and find intersection points for
+       --          each curve using method Init(curve).  For
+       --          iteration by intersection points method More() and
+       --          Next() should be used.  
        --          
+       --- Example:
+       ---  Inter.Load(shape, tol); 
+       ---  for( i =1; i <= nbCurves;i++) 
+       ---   { 
+       ---    Inter.Init(curve); 
+       ---    for(  ;Inter.More(); Inter.Next()) 
+       ---    {
+       ---     .......
+       ---    }
+       ---   }
 
 uses  
 --modified by NIZNHY-PKV Sun Dec 15 16:52:33 2002  f 
@@ -34,7 +52,11 @@ uses
      Lin                 from gp,
      Pnt                 from gp,
      TransitionOnCurve   from IntCurveSurface,
-     Face                from TopoDS
+     Face                from TopoDS,
+     Box                 from Bnd,
+     SequenceOfShape     from TopTools,
+     HArray1OfBox        from Bnd,
+     HCurve               from GeomAdaptor
     
      
 raises 
@@ -47,118 +69,110 @@ is
        --- Purpose: Empty constructor;
        
     Init(me : in out;
-        Sh : Shape from TopoDS;
-        Cu : Curve from GeomAdaptor;
-        Tol: Real  from Standard)
+        theShape : Shape from TopoDS;
+            theCurve : Curve from GeomAdaptor;
+            theTol: Real  from Standard);
            
        --- Purpose: Load the Shape, the curve  and initialize the
        --           tolerance used for the classification.
-       is static;
+       
     
     Init(me : in out;
-        Sh : Shape from TopoDS;
-        L  : Lin   from gp;
-        Tol: Real  from Standard)
+        theShape : Shape from TopoDS;
+            theLine  : Lin   from gp;
+            theTol: Real  from Standard);
            
        --- Purpose: Load the Shape, the curve  and initialize the
        --           tolerance used for the classification.
-       is static;
-    
-    More(me) 
+       
 
-       --- Purpose: returns True if there is a current face.
-       returns Boolean from Standard
-       is static;
+    Load(me : in out; theShape : Shape from TopoDS; theTol: Real  from Standard);
+    --- Purpose: Load the Shape,   and initialize the
+         --           tolerance used for the classification.
+
+    Init(me : in out; theCurve : Curve from GeomAdaptor);
+    --- Purpose: Method to find intersections of specified curve with loaded shape.
+         
     
+    More(me) returns Boolean from Standard;
+       --- Purpose: returns True if there is a current face.
+           
                                             
-    Next(me: in out)
-
-       --- Purpose: Sets the explorer to the next face.
-       is static;
+    Next(me: in out);
+       --- Purpose: Sets the next intersection point to check.
+       
        
-    Find(me: in out) 
+    Find(me: in out) is protected;
        ---Purpose: Internal function
-       is static protected;
-
-    Point(me)
        
-       ---Purpose: returns the current Intersection point.
-       
-       returns IntersectionPoint from IntCurveSurface
-       raises NotDone from StdFail
-       is static;       
 
-    Pnt(me) 
+    Point(me) returns IntersectionPoint from IntCurveSurface
+         ---Purpose: returns the current Intersection point.
+       raises NotDone from StdFail;
+     
+
+    Pnt(me) returns Pnt from gp
        ---Purpose: returns the current geometric Point
        ---C++: return const & 
-       returns Pnt from gp
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
+       
        
 
-    U(me) 
+    U(me) returns Real from Standard
        ---Purpose: returns the U parameter of the current point 
        --          on the current face.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+         raises NotDone from StdFail;
+
 
-    V(me) 
+    V(me) returns Real from Standard
        ---Purpose: returns the V parameter of the current point 
        --          on the current face.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
+       
 
-    W(me) 
+    W(me) returns Real from Standard
        ---Purpose: returns the  parameter of the current point 
        --          on the curve.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+         raises NotDone from StdFail;
 
-    State(me)
 
-       ---Purpose: returns the current state  (IN or ON)
-       returns State from TopAbs
-       raises NotDone from StdFail
-       is static;
+    State(me) returns State from TopAbs
+         ---Purpose: returns the current state  (IN or ON)
+       raises NotDone from StdFail;
 
-    Transition(me) 
-    
+
+    Transition(me) returns TransitionOnCurve   from IntCurveSurface
        ---Purpose: returns the transition of the line on the surface (IN or OUT or UNKNOWN)
-       returns TransitionOnCurve   from IntCurveSurface
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
        
-    Face(me)
-    
+       
+    Face(me) returns Face from TopoDS;
        ---Purpose: returns the current face.
-        ---C++: return const &
-       returns Face from TopoDS
-       is static;
+      ---C++: return const &
+       
+        FindPoint(me : in out) returns Boolean from Standard is protected;
+    ---Purpose: Method chec found intersection point
 
+    Clear(me : in out) is protected;
+    ---Purpose: Method to clear fields of class
 
 fields
 
-    empty          : Boolean           from Standard;
-    curveisaline   : Boolean           from Standard;
-    tolerance      : Real              from Standard;
-    line           : Lin               from gp;
-    curve          : Curve             from GeomAdaptor;
+    myTolerance      : Real              from Standard;
+    myCurve          : HCurve             from GeomAdaptor;
+       
+    myIntcs          : HInter             from IntCurveSurface;
     
-    explorer       : Explorer          from TopExp;
-    classifier     : FaceClassifier    from BRepClass;
-    --intcs          : ICSInter          from BRepIntCurveSurface;
-    intcs          : HInter             from IntCurveSurface;
+    myCurrentindex   : Integer           from Standard;
+    myCurrentnbpoints: Integer           from Standard;  
+    myFastClass       :  TopolTool  from  BRepTopAdaptor; 
     
-    currentindex   : Integer           from Standard;
-    currentnbpoints: Integer           from Standard;
---modified by NIZNHY-PKV Sun Dec 15 16:51:34 2002  f     
-    FastClass       :  TopolTool  from  BRepTopAdaptor; 
-    SurfForFastClass:  HSurface  from BRepAdaptor;  
-    currentstate    :  State  from  TopAbs; 
-    currentU        :  Real  from  Standard;
-    currentV        :  Real  from  Standard;
---modified by NIZNHY-PKV Sun Dec 15 16:52:15 2002  t    
+    myCurrentstate    :  State  from  TopAbs; 
+    myCurrentU        :  Real  from  Standard;
+    myCurrentV        :  Real  from  Standard;
+    myCurveBox      : Box from Bnd;
+    myIndFace       : Integer from Standard;
+    myFaces         : SequenceOfShape from TopTools;
+    myFaceBoxes     : HArray1OfBox from Bnd;
+
 end Inter from BRepIntCurveSurface;
index 69abd17..e11dda2 100644 (file)
 #include <GeomAdaptor_HCurve.hxx>
 #include <BRepTopAdaptor_TopolTool.hxx>
 #include <BRepAdaptor_HSurface.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <BndLib_Add3dCurve.hxx>
 
-//modified by NIZNHY-PKV Sun Dec 15 16:57:10 2002 f
-/*
-static Standard_Real currentU,currentV;
-TopAbs_State currentstate;
-static Handle(BRepTopAdaptor_TopolTool) FastClass
-       = new  BRepTopAdaptor_TopolTool();
-
-static Handle(BRepAdaptor_HSurface) SurfForFastClass
-       = new  BRepAdaptor_HSurface();
-*/
-//modified by NIZNHY-PKV Sun Dec 15 16:57:14 2002 t
 
 //===========================================================================
 //function :BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inte
 //purpose  : 
 //===========================================================================
 BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inter()
-     : empty(Standard_True) 
 {
-//modified by NIZNHY-PKV Sun Dec 15 16:58:10 2002 f
-  FastClass = new  BRepTopAdaptor_TopolTool();
-  SurfForFastClass = new  BRepAdaptor_HSurface();
-//modified by NIZNHY-PKV Sun Dec 15 16:58:13 2002 t
-}
-
-void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
-                                    const GeomAdaptor_Curve& acurve,
-                                    const Standard_Real tol) { 
-  empty = Standard_False;
-  curveisaline = Standard_False;
-  curve = acurve;
-  explorer.Init(ashape,TopAbs_FACE);
-  currentnbpoints = 0;
-  tolerance = tol;
-  Find();
+  myFastClass = new  BRepTopAdaptor_TopolTool();
+  Clear();
 }
 
-void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
-                                    const gp_Lin&       aline,
-                                    const Standard_Real tol) { 
-  empty = Standard_False;
-  curveisaline = Standard_True;
-  line = aline;
-  Handle(Geom_Line) geomline = new Geom_Line(aline);
-  curve.Load(geomline);
-  explorer.Init(ashape,TopAbs_FACE);
-  currentnbpoints = 0;
-  tolerance = tol;
-  Find();
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
+                                    const GeomAdaptor_Curve& theCurve,
+                                    const Standard_Real theTol) 
+{ 
+  Load(theShape, theTol);
+  Init(theCurve);
+}
+
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
+                                    const gp_Lin&       theLine,
+                                    const Standard_Real theTol) 
+{ 
+  Handle(Geom_Line) geomline = new Geom_Line(theLine);
+  GeomAdaptor_Curve aCurve(geomline);
+  Load(theShape, theTol);
+  Init(aCurve);
+  
+}
+
+//===========================================================================
+//function :Clear
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Clear()
+{  
+  myCurrentindex = 0;
+  myCurrentnbpoints = 0;
+  myIndFace = 0;
+  myCurrentstate = TopAbs_UNKNOWN;
+  myCurrentU = 0;
+  myCurrentV = 0;
+
 }
 
-Standard_Boolean BRepIntCurveSurface_Inter::More() const {
-  return(explorer.More());
+//===========================================================================
+//function :Load
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Load(const TopoDS_Shape& theShape ,const Standard_Real theTol)
+{
+  Clear();
+  myFaces.Clear();
+  myFaceBoxes.Nullify();
+  myTolerance = theTol;
+  TopExp_Explorer explorer(theShape,TopAbs_FACE);
+  for( ; explorer.More(); explorer.Next())
+    myFaces.Append(explorer.Current());
+
 }
 
-void BRepIntCurveSurface_Inter::Next() { 
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const GeomAdaptor_Curve& theCurve )
+{
+  Clear();
+  myCurveBox.SetVoid();
+  Standard_Real aFirst =  theCurve.FirstParameter();
+  Standard_Real aLast =   theCurve.LastParameter();
+  myCurve = new GeomAdaptor_HCurve(theCurve );
+  if( !Precision::IsInfinite(aFirst) && !Precision::IsInfinite(aLast) )
+    BndLib_Add3dCurve::Add(myCurve->Curve(),0., myCurveBox);
   Find();
 }
 
-void BRepIntCurveSurface_Inter::Find() { 
+//===========================================================================
+//function :More
+//purpose  : 
+//===========================================================================
+Standard_Boolean BRepIntCurveSurface_Inter::More() const 
+{
+  return (myIndFace <= myFaces.Length()  );
+}
+
+//===========================================================================
+//function :Next
+//purpose  : 
+//===========================================================================
+void BRepIntCurveSurface_Inter::Next() 
+{ 
+  if(myCurrentnbpoints)
+    myCurrentindex++;
+  Find();
+}
 
-  static Standard_Real UMin = 0.0;
-  static Standard_Real UMax = 0.0;
-  static Standard_Real VMin = 0.0;
-  static Standard_Real VMax = 0.0;
-  static Standard_Real PeriodU = 0.0;
-  static Standard_Real PeriodV = 0.0;
+//===========================================================================
+//function :Find
+//purpose  : 
+//===========================================================================
+void BRepIntCurveSurface_Inter::Find() 
+{ 
+  if(myCurrentnbpoints && myCurrentindex <= myCurrentnbpoints && FindPoint())
+    return;
   
-  if(currentnbpoints) { 
-    while(currentindex < currentnbpoints) { 
-      currentindex++;
-      Standard_Real U = intcs.Point(currentindex).U();
-      Standard_Real V = intcs.Point(currentindex).V();
-      //-------------------------------------------------------
-      //-- Try to reframe point U,V in the face UV
-      //-- 
-      if(PeriodU) { 
-       while(U>UMin) 
-         U-=PeriodU;
-      }
-      if(PeriodV) { 
-       while(V>VMin)
-         V-=PeriodV;
-      }
-//    Standard_Real UInit = U;
-      Standard_Real VInit = V;
-      do { //-- Loop on U  
-       V = VInit;
-       do { //-- Loop on V
-         gp_Pnt2d Puv(U,V);
-         //--- 
-         //-- classifier.Perform(TopoDS::Face(explorer.Current()),Puv,tolerance);
-         currentstate = FastClass->Classify(Puv,tolerance); //-- MODIF
-         //-- TopAbs_State currentstate = classifier.State();
-
-         if(currentstate == TopAbs_ON || currentstate == TopAbs_IN) { 
-           currentU = U;
-           currentV = V;       
-           return;     
-         }
-         V+=PeriodV;       
-       }
-       while(PeriodV && V< VMax);
-       U+=PeriodU;
-      }
-      while(PeriodU && U<UMax);
+  myCurrentnbpoints = 0;
+  myCurrentindex = 0;
+
+  Standard_Integer i = myIndFace +1;
+  for( ; i <= myFaces.Length(); i++)
+  {
+    TopoDS_Shape aCurface= myFaces(i);       
+    if( myFaceBoxes.IsNull())
+      myFaceBoxes = new Bnd_HArray1OfBox(1, myFaces.Length());
+    Bnd_Box& aFaceBox  = myFaceBoxes->ChangeValue(i);
+    if( aFaceBox.IsVoid())
+    {
+      BRepBndLib::Add(aCurface, aFaceBox);
+      aFaceBox.SetGap(myTolerance);//Precision::Confusion());
     }
-    explorer.Next();
+    Standard_Boolean isOut = ( myCurve->GetType() == GeomAbs_Line ? aFaceBox.IsOut(myCurve->Line()) :
+      ( !myCurveBox.IsVoid() ? aFaceBox.IsOut(myCurveBox ) : Standard_False ) );
+    if(isOut )
+      continue;
+    Handle(BRepAdaptor_HSurface) aSurfForFastClass = new BRepAdaptor_HSurface(TopoDS::Face(aCurface));
+    myIntcs.Perform(myCurve,aSurfForFastClass);
+    myCurrentnbpoints = myIntcs.NbPoints();
+    if( !myCurrentnbpoints)
+      continue;
+
+    myFastClass->Initialize(aSurfForFastClass);
+    myIndFace = i;
+    if(FindPoint())
+      return; 
+    myCurrentnbpoints = 0;
+  }
+
+  if(!myCurrentnbpoints && i > myFaces.Length())
+  {
+    myIndFace = i;
+    return;
   }
+}
+
+//===========================================================================
+//function :FindPoint
+//purpose  : 
+//===========================================================================
+Standard_Boolean BRepIntCurveSurface_Inter::FindPoint()
+{
+  Standard_Integer j =  (!myCurrentindex ?  1 : myCurrentindex);
   
-  if(explorer.More()) { 
-    //---------------------------------------------
-    BRepAdaptor_Surface brepadaptsurf;
-    
-    TopoDS_Face face=TopoDS::Face(explorer.Current());
-    face.Orientation(TopAbs_FORWARD);
-    
-    brepadaptsurf.Initialize(face,Standard_True);
-    //----------------------------------------------
-    //-- Update variables PeriodU,PeriodV
-    //--
-
-    SurfForFastClass->ChangeSurface().Initialize(face); //-- MODIF
-//    SurfForFastClass->ChangeSurface().Initialize(TopoDS::Face(face)); //-- MODIF
-    FastClass->Initialize(SurfForFastClass); //-- MODIF
-    if( brepadaptsurf.Surface().IsUPeriodic()) { 
-      PeriodU = brepadaptsurf.Surface().UPeriod();
-      UMin = brepadaptsurf.Surface().FirstUParameter();
-      UMax = brepadaptsurf.Surface().LastUParameter();
-    }
-    else { 
-      PeriodU = 0.0;
-    }
-    if( brepadaptsurf.Surface().IsVPeriodic()) { 
-      PeriodV = brepadaptsurf.Surface().VPeriod();
-      VMin = brepadaptsurf.Surface().FirstVParameter();
-      VMax = brepadaptsurf.Surface().LastVParameter();
-    }
-    else { 
-      PeriodV = 0.0;
-    }
+  for( ; j <= myCurrentnbpoints; j++ )
+  {
+    Standard_Real anU = myIntcs.Point(j).U();
+    Standard_Real aV = myIntcs.Point(j).V();
+  
+    gp_Pnt2d Puv( anU,aV );
 
-    //----------------------------------------------
-    Handle(GeomAdaptor_HCurve)   HC = new GeomAdaptor_HCurve(curve);
-    Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(brepadaptsurf);
-    //----------------------------------------------
-    //-- intcs.Perform(curve,brepadaptsurf);
-    intcs.Perform(HC,HS);
-
-    currentindex = 0;
-    currentnbpoints = intcs.NbPoints();
-    if(currentnbpoints) { 
-      Find();
+    myCurrentstate = myFastClass->Classify(Puv,myTolerance); 
+    if(myCurrentstate == TopAbs_ON || myCurrentstate == TopAbs_IN) 
+    { 
+      myCurrentindex = j;
+      myCurrentU = anU;
+      myCurrentV = aV; 
+      return Standard_True; 
     }
-    else { 
-      explorer.Next();
-      Find(); 
-    }
-  }
-  else { 
-    currentnbpoints=0; 
   }
+  return Standard_False;
 }
 
+//===========================================================================
+//function :Point
+//purpose  : 
+//===========================================================================
 
-IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const {
-  if(currentindex==0) 
+IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  const IntCurveSurface_IntersectionPoint& ICPS = intcs.Point(currentindex);
+  const IntCurveSurface_IntersectionPoint& ICPS = myIntcs.Point(myCurrentindex);
   return(IntCurveSurface_IntersectionPoint(ICPS.Pnt(),
-                                          currentU,     // ICPS.U(),
-                                          currentV,     // ICPS.V(),
+                                          myCurrentU,     // ICPS.U(),
+                                          myCurrentV,     // ICPS.V(),
                                           ICPS.W(),
                                           ICPS.Transition()));
-  //-- return(intcs.Point(currentindex));
+  //-- return(myIntcs.Point(myCurrentindex));
 }
 
-Standard_Real BRepIntCurveSurface_Inter::U() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :U
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::U() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  //-- return(intcs.Point(currentindex).U());
-  return(currentU);
+  //-- return(myIntcs.Point(myCurrentindex).U());
+  return(myCurrentU);
 }
 
-Standard_Real BRepIntCurveSurface_Inter::V() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :V
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::V() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  //-- return(intcs.Point(currentindex).V());
-  return(currentV);
+  //-- return(myIntcs.Point(myCurrentindex).V());
+  return(myCurrentV);
 }
 
-Standard_Real BRepIntCurveSurface_Inter::W() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :W
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::W() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).W());
+  return(myIntcs.Point(myCurrentindex).W());
 }
 
-TopAbs_State BRepIntCurveSurface_Inter::State() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :State
+//purpose  : 
+//===========================================================================
+TopAbs_State BRepIntCurveSurface_Inter::State() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
   //-- return(classifier.State());
-  return(currentstate);
+  return(myCurrentstate);
 }
 
-IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :Transition
+//purpose  : 
+//===========================================================================
+IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).Transition());
+  return(myIntcs.Point(myCurrentindex).Transition());
 }
 
-const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const { 
-  return(TopoDS::Face(explorer.Current()));
+//===========================================================================
+//function :Face
+//purpose  : 
+//===========================================================================
+const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const 
+{ 
+  return(TopoDS::Face(myFaces.Value(myIndFace)));
 }
 
+//===========================================================================
+//function :Pnt
+//purpose  : 
+//===========================================================================
 const gp_Pnt& BRepIntCurveSurface_Inter::Pnt() const { 
-  if(currentindex==0) 
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).Pnt());
+  return(myIntcs.Point(myCurrentindex).Pnt());
 }
+
index 6d98766..3583817 100644 (file)
@@ -75,6 +75,7 @@
 #include <BRepOffset.hxx>
 #include <BRepOffset_MakeOffset.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
+#include <GeomAdaptor_Curve.hxx>
 
 static 
   void SampleEdges (const TopoDS_Shape&   theShape, 
@@ -115,7 +116,7 @@ void  BRepTest::OtherCommands(Draw_Interpretor& theCommands)
                  ,__FILE__,subshape,g);
 
   theCommands.Add("BRepIntCS",
-                 "Calcul d'intersection entre face et curve : BRepIntCS curve shape"
+    "Calcul d'intersection entre face et curve : BRepIntCS curve1 [curve2 ...] shape [res] [tol]"
                  ,__FILE__,brepintcs,g);
 
   theCommands.Add("makeboss",  "create a boss on the shape myS", __FILE__, MakeBoss, g);
@@ -273,25 +274,54 @@ Standard_Integer subshape(Draw_Interpretor& di, Standard_Integer n, const char**
 //function : brepintcs
 //purpose  : 
 //=======================================================================
-Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char** a)
+Standard_Integer brepintcs(Draw_Interpretor& di, Standard_Integer n, const char** a)
 {
-  if (n <= 2) return 1;
-  TopoDS_Shape S = DBRep::Get(a[n-1]);
-  if (S.IsNull()) return 3;
-
-  static BRepIntCurveSurface_Inter theAlg;
-  static double tol=1e-6;
-  static int nbpi=0;
-  static gp_Pnt curp;
+  if (n <= 2) 
+  {
+    cout<<"Invalid input arguments. Should be: curve1 [curve2 ...] shape [result] [tol]"<<endl;
+    return 1;
+  }
+  Standard_Integer indshape = 2;
+  TopoDS_Shape S;
+  for( ; indshape <= n-1 ; indshape++)
+  {
+    S = DBRep::Get(a[indshape]);
+    if(!S.IsNull())
+      break;
+  }
+  if (S.IsNull()) 
+  {
+    cout<<"Invalid input shape"<<endl;
+    return 1;
+  }
 
-  if (n==3) {
+  BRepIntCurveSurface_Inter theAlg;
+  double tol=1e-6;
+  if( indshape < n-1)
+  {
+    Standard_Real preci = atof(a[n-1]);
+    if(preci >= Precision::Confusion())
+      tol = preci;
+  }
+  int nbpi=0;
+  gp_Pnt curp;
+  TopoDS_Compound aComp;
+  BRep_Builder aB;
+  aB.MakeCompound(aComp);
+  if (indshape == 2) {
     Handle(Geom_Curve) C= DrawTrSurf::GetCurve(a[1]);
     if (C.IsNull()) return 2;
     GeomAdaptor_Curve acur(C);
     theAlg.Init(S, acur, tol);
+
     for (; theAlg.More(); theAlg.Next()) {
       curp=theAlg.Pnt();
+      TopoDS_Vertex aV;
+
+      aB.MakeVertex(aV, curp, 0);
+      aB.Add(aComp, aV);
       nbpi++;
+      di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
       char name[64];
       char* temp = name; // pour portage WNT
       Sprintf(temp, "%s_%d", "brics", nbpi); 
@@ -299,24 +329,31 @@ Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char**
     }
   }
   else {
-    Handle(Geom_Line) hl;
-    gp_Lin thel;
-    for (Standard_Integer il = 1; il<n ; il++) {
-      hl= Handle(Geom_Line)::DownCast(DrawTrSurf::GetCurve(a[il]));
+    theAlg.Load(S,tol );
+    for (Standard_Integer il = 1; il<indshape ; il++) 
+    {
+      Handle(Geom_Curve) hl= DrawTrSurf::GetCurve(a[il]);
       if (!hl.IsNull()) {
-       thel=hl->Lin();
-         theAlg.Init(S, thel, tol);
-       for (; theAlg.More(); theAlg.Next()) {
-         curp=theAlg.Pnt();
-         nbpi++;
-         char name[64];
-         char* temp = name; // pour portage WNT
-         Sprintf(temp, "%s_%d", "brics", nbpi); 
-         DrawTrSurf::Set(temp, curp);
-       }
+        theAlg.Init(hl);
+        for (; theAlg.More(); theAlg.Next()) {
+          curp=theAlg.Pnt();
+          nbpi++;
+          TopoDS_Vertex aV;
+          aB.MakeVertex(aV, curp, 0);
+          aB.Add(aComp, aV);
+          di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
+          char name[64];
+          char* temp = name; // pour portage WNT
+          Sprintf(temp, "%s_%d", "brics", nbpi); 
+          DrawTrSurf::Set(temp, curp);
+        }
       }
     }
   }
+  if(!nbpi)
+    di<<"Points of intersections are not found"<<"\n";
+  if(indshape < n-1)
+    DBRep::Set(a[n-1], aComp);
   //POP pour NT
   return 0;
 }
index 5420055..d8b5a71 100644 (file)
@@ -23,7 +23,8 @@
 
 
 #include <Precision.hxx>
-
+#include <gp_Lin.hxx>
+#include <GeomAdaptor_Curve.hxx>
 
 static void Perform(BRepIntCurveSurface_Inter&,
                    LocOpe_SequenceOfPntFace&);
diff --git a/tests/bugs/modalg_5/bug24899 b/tests/bugs/modalg_5/bug24899
new file mode 100644 (file)
index 0000000..b71f27a
--- /dev/null
@@ -0,0 +1,44 @@
+puts "=========="
+puts "OCC24899"
+puts "=========="
+puts ""
+##################################################################################################
+# Time of computation of intersection points with help of class BRepIntCurveSurface_Inter is big
+##################################################################################################
+
+polyline l -10 1 1 80 1 1
+explode l e
+
+restore [locate_data_file bug24899_TheHull.brep] h1
+mkcurve c1 l_1
+BRepIntCS c1 h1 r
+distmini dd l_1 h1
+
+dchrono t1 reset
+dchrono t1 start
+
+for { set i 0} { $i <= 100 } {incr i} {
+  BRepIntCS c1 h1 r
+}
+
+dchrono t1 stop
+set time1 [dchrono t1 show]
+regexp {CPU user time: ([-0-9.+eE]+) seconds} $time1 full timeint
+puts "Time performing BRepIntCurveSurface =  $timeint"
+
+dchrono t2 reset
+dchrono t2 start
+for { set j 0} { $j <= 100 } {incr j} {
+  distmini dd l_1 h1
+}
+
+dchrono t2 stop
+set time2 [dchrono t2 show]
+regexp {CPU user time: ([-0-9.+eE]+) seconds} $time2 full timeextr
+puts "Time performing BRepExtrema_DistShapeShape = $timeextr"
+
+if { $timeint > 2 * $timeextr } {
+  puts "Error : Time of intersection of curve with shell is more than two time from BRepExtrema"
+} else {
+  puts "OK: Time is good"
+}