mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024899: Time of computation of intersection points with help of class BRepIntCurveSurface_Inter is big.
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
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <ElCLib.hxx>
|
#include <ElCLib.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
|
||||||
#include <GeomAdaptor_Surface.hxx>
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
#include <GeomAbs_SurfaceType.hxx>
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
@@ -59,6 +59,7 @@
|
|||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
#ifdef DRAW
|
#ifdef DRAW
|
||||||
#include <DrawTrSurf.hxx>
|
#include <DrawTrSurf.hxx>
|
||||||
@@ -434,7 +435,7 @@ Standard_Boolean BRepFill_TrimSurfaceTool::IsOnFace
|
|||||||
|
|
||||||
// eval if is on face 1
|
// eval if is on face 1
|
||||||
// modified by NIZHNY-EAP Fri Jan 21 09:49:09 2000 ___BEGIN___
|
// 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;
|
if (Inter.More()) return Standard_True;
|
||||||
|
|
||||||
// eval if is on face 2
|
// eval if is on face 2
|
||||||
|
@@ -37,7 +37,9 @@ uses
|
|||||||
TopAbs,
|
TopAbs,
|
||||||
TopExp,
|
TopExp,
|
||||||
StdFail,
|
StdFail,
|
||||||
gp
|
gp,
|
||||||
|
Bnd,
|
||||||
|
TopTools
|
||||||
|
|
||||||
is
|
is
|
||||||
|
|
||||||
|
@@ -16,8 +16,26 @@
|
|||||||
|
|
||||||
class Inter from BRepIntCurveSurface
|
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
|
uses
|
||||||
--modified by NIZNHY-PKV Sun Dec 15 16:52:33 2002 f
|
--modified by NIZNHY-PKV Sun Dec 15 16:52:33 2002 f
|
||||||
@@ -34,7 +52,11 @@ uses
|
|||||||
Lin from gp,
|
Lin from gp,
|
||||||
Pnt from gp,
|
Pnt from gp,
|
||||||
TransitionOnCurve from IntCurveSurface,
|
TransitionOnCurve from IntCurveSurface,
|
||||||
Face from TopoDS
|
Face from TopoDS,
|
||||||
|
Box from Bnd,
|
||||||
|
SequenceOfShape from TopTools,
|
||||||
|
HArray1OfBox from Bnd,
|
||||||
|
HCurve from GeomAdaptor
|
||||||
|
|
||||||
|
|
||||||
raises
|
raises
|
||||||
@@ -47,118 +69,110 @@ is
|
|||||||
--- Purpose: Empty constructor;
|
--- Purpose: Empty constructor;
|
||||||
|
|
||||||
Init(me : in out;
|
Init(me : in out;
|
||||||
Sh : Shape from TopoDS;
|
theShape : Shape from TopoDS;
|
||||||
Cu : Curve from GeomAdaptor;
|
theCurve : Curve from GeomAdaptor;
|
||||||
Tol: Real from Standard)
|
theTol: Real from Standard);
|
||||||
|
|
||||||
--- Purpose: Load the Shape, the curve and initialize the
|
--- Purpose: Load the Shape, the curve and initialize the
|
||||||
-- tolerance used for the classification.
|
-- tolerance used for the classification.
|
||||||
is static;
|
|
||||||
|
|
||||||
Init(me : in out;
|
Init(me : in out;
|
||||||
Sh : Shape from TopoDS;
|
theShape : Shape from TopoDS;
|
||||||
L : Lin from gp;
|
theLine : Lin from gp;
|
||||||
Tol: Real from Standard)
|
theTol: Real from Standard);
|
||||||
|
|
||||||
--- Purpose: Load the Shape, the curve and initialize the
|
--- Purpose: Load the Shape, the curve and initialize the
|
||||||
-- tolerance used for the classification.
|
-- tolerance used for the classification.
|
||||||
is static;
|
|
||||||
|
|
||||||
More(me)
|
|
||||||
|
|
||||||
|
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.
|
--- Purpose: returns True if there is a current face.
|
||||||
returns Boolean from Standard
|
|
||||||
is static;
|
|
||||||
|
|
||||||
|
|
||||||
Next(me: in out)
|
Next(me: in out);
|
||||||
|
--- Purpose: Sets the next intersection point to check.
|
||||||
--- Purpose: Sets the explorer to the next face.
|
|
||||||
is static;
|
|
||||||
|
|
||||||
Find(me: in out)
|
|
||||||
|
Find(me: in out) is protected;
|
||||||
---Purpose: Internal function
|
---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
|
---Purpose: returns the current geometric Point
|
||||||
---C++: return const &
|
---C++: return const &
|
||||||
returns Pnt from gp
|
raises NotDone from StdFail;
|
||||||
raises NotDone from StdFail
|
|
||||||
is static;
|
|
||||||
|
|
||||||
|
|
||||||
U(me)
|
U(me) returns Real from Standard
|
||||||
---Purpose: returns the U parameter of the current point
|
---Purpose: returns the U parameter of the current point
|
||||||
-- on the current face.
|
-- on the current face.
|
||||||
returns Real from Standard
|
raises NotDone from StdFail;
|
||||||
raises NotDone from StdFail
|
|
||||||
is static;
|
|
||||||
|
|
||||||
V(me)
|
|
||||||
|
V(me) returns Real from Standard
|
||||||
---Purpose: returns the V parameter of the current point
|
---Purpose: returns the V parameter of the current point
|
||||||
-- on the current face.
|
-- on the current face.
|
||||||
returns Real from Standard
|
raises NotDone from StdFail;
|
||||||
raises NotDone from StdFail
|
|
||||||
is static;
|
|
||||||
|
|
||||||
W(me)
|
W(me) returns Real from Standard
|
||||||
---Purpose: returns the parameter of the current point
|
---Purpose: returns the parameter of the current point
|
||||||
-- on the curve.
|
-- on the curve.
|
||||||
returns Real from Standard
|
raises NotDone from StdFail;
|
||||||
raises NotDone from StdFail
|
|
||||||
is static;
|
|
||||||
|
|
||||||
State(me)
|
|
||||||
|
|
||||||
---Purpose: returns the current state (IN or ON)
|
State(me) returns State from TopAbs
|
||||||
returns State from TopAbs
|
---Purpose: returns the current state (IN or ON)
|
||||||
raises NotDone from StdFail
|
raises NotDone from StdFail;
|
||||||
is static;
|
|
||||||
|
|
||||||
Transition(me)
|
|
||||||
|
Transition(me) returns TransitionOnCurve from IntCurveSurface
|
||||||
---Purpose: returns the transition of the line on the surface (IN or OUT or UNKNOWN)
|
---Purpose: returns the transition of the line on the surface (IN or OUT or UNKNOWN)
|
||||||
returns TransitionOnCurve from IntCurveSurface
|
raises NotDone from StdFail;
|
||||||
raises NotDone from StdFail
|
|
||||||
is static;
|
|
||||||
|
|
||||||
Face(me)
|
|
||||||
|
Face(me) returns Face from TopoDS;
|
||||||
---Purpose: returns the current face.
|
---Purpose: returns the current face.
|
||||||
---C++: return const &
|
---C++: return const &
|
||||||
returns Face from TopoDS
|
|
||||||
is static;
|
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
|
fields
|
||||||
|
|
||||||
empty : Boolean from Standard;
|
myTolerance : Real from Standard;
|
||||||
curveisaline : Boolean from Standard;
|
myCurve : HCurve from GeomAdaptor;
|
||||||
tolerance : Real from Standard;
|
|
||||||
line : Lin from gp;
|
myIntcs : HInter from IntCurveSurface;
|
||||||
curve : Curve from GeomAdaptor;
|
|
||||||
|
|
||||||
explorer : Explorer from TopExp;
|
myCurrentindex : Integer from Standard;
|
||||||
classifier : FaceClassifier from BRepClass;
|
myCurrentnbpoints: Integer from Standard;
|
||||||
--intcs : ICSInter from BRepIntCurveSurface;
|
myFastClass : TopolTool from BRepTopAdaptor;
|
||||||
intcs : HInter from IntCurveSurface;
|
|
||||||
|
|
||||||
currentindex : Integer from Standard;
|
myCurrentstate : State from TopAbs;
|
||||||
currentnbpoints: Integer from Standard;
|
myCurrentU : Real from Standard;
|
||||||
--modified by NIZNHY-PKV Sun Dec 15 16:51:34 2002 f
|
myCurrentV : Real from Standard;
|
||||||
FastClass : TopolTool from BRepTopAdaptor;
|
myCurveBox : Box from Bnd;
|
||||||
SurfForFastClass: HSurface from BRepAdaptor;
|
myIndFace : Integer from Standard;
|
||||||
currentstate : State from TopAbs;
|
myFaces : SequenceOfShape from TopTools;
|
||||||
currentU : Real from Standard;
|
myFaceBoxes : HArray1OfBox from Bnd;
|
||||||
currentV : Real from Standard;
|
|
||||||
--modified by NIZNHY-PKV Sun Dec 15 16:52:15 2002 t
|
|
||||||
end Inter from BRepIntCurveSurface;
|
end Inter from BRepIntCurveSurface;
|
||||||
|
@@ -24,224 +24,288 @@
|
|||||||
#include <GeomAdaptor_HCurve.hxx>
|
#include <GeomAdaptor_HCurve.hxx>
|
||||||
#include <BRepTopAdaptor_TopolTool.hxx>
|
#include <BRepTopAdaptor_TopolTool.hxx>
|
||||||
#include <BRepAdaptor_HSurface.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
|
//function :BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inte
|
||||||
//purpose :
|
//purpose :
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inter()
|
BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inter()
|
||||||
: empty(Standard_True)
|
|
||||||
{
|
{
|
||||||
//modified by NIZNHY-PKV Sun Dec 15 16:58:10 2002 f
|
myFastClass = new BRepTopAdaptor_TopolTool();
|
||||||
FastClass = new BRepTopAdaptor_TopolTool();
|
Clear();
|
||||||
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,
|
//function :Init
|
||||||
const Standard_Real tol) {
|
//purpose :
|
||||||
empty = Standard_False;
|
//===========================================================================
|
||||||
curveisaline = Standard_False;
|
|
||||||
curve = acurve;
|
void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
|
||||||
explorer.Init(ashape,TopAbs_FACE);
|
const GeomAdaptor_Curve& theCurve,
|
||||||
currentnbpoints = 0;
|
const Standard_Real theTol)
|
||||||
tolerance = tol;
|
{
|
||||||
Find();
|
Load(theShape, theTol);
|
||||||
|
Init(theCurve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
|
//===========================================================================
|
||||||
const gp_Lin& aline,
|
//function :Init
|
||||||
const Standard_Real tol) {
|
//purpose :
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean BRepIntCurveSurface_Inter::More() const {
|
void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
|
||||||
return(explorer.More());
|
const gp_Lin& theLine,
|
||||||
}
|
const Standard_Real theTol)
|
||||||
|
{
|
||||||
void BRepIntCurveSurface_Inter::Next() {
|
|
||||||
Find();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BRepIntCurveSurface_Inter::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;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
explorer.Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
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()) {
|
Handle(Geom_Line) geomline = new Geom_Line(theLine);
|
||||||
PeriodU = brepadaptsurf.Surface().UPeriod();
|
GeomAdaptor_Curve aCurve(geomline);
|
||||||
UMin = brepadaptsurf.Surface().FirstUParameter();
|
Load(theShape, theTol);
|
||||||
UMax = brepadaptsurf.Surface().LastUParameter();
|
Init(aCurve);
|
||||||
}
|
|
||||||
else {
|
}
|
||||||
PeriodU = 0.0;
|
|
||||||
}
|
|
||||||
if( brepadaptsurf.Surface().IsVPeriodic()) {
|
|
||||||
PeriodV = brepadaptsurf.Surface().VPeriod();
|
|
||||||
VMin = brepadaptsurf.Surface().FirstVParameter();
|
|
||||||
VMax = brepadaptsurf.Surface().LastVParameter();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PeriodV = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------
|
//===========================================================================
|
||||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(curve);
|
//function :Clear
|
||||||
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(brepadaptsurf);
|
//purpose :
|
||||||
//----------------------------------------------
|
//===========================================================================
|
||||||
//-- intcs.Perform(curve,brepadaptsurf);
|
|
||||||
intcs.Perform(HC,HS);
|
|
||||||
|
|
||||||
currentindex = 0;
|
void BRepIntCurveSurface_Inter::Clear()
|
||||||
currentnbpoints = intcs.NbPoints();
|
{
|
||||||
if(currentnbpoints) {
|
myCurrentindex = 0;
|
||||||
Find();
|
myCurrentnbpoints = 0;
|
||||||
}
|
myIndFace = 0;
|
||||||
else {
|
myCurrentstate = TopAbs_UNKNOWN;
|
||||||
explorer.Next();
|
myCurrentU = 0;
|
||||||
Find();
|
myCurrentV = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//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());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//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();
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//function :More
|
||||||
|
//purpose :
|
||||||
|
//===========================================================================
|
||||||
|
Standard_Boolean BRepIntCurveSurface_Inter::More() const
|
||||||
|
{
|
||||||
|
return (myIndFace <= myFaces.Length() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//function :Next
|
||||||
|
//purpose :
|
||||||
|
//===========================================================================
|
||||||
|
void BRepIntCurveSurface_Inter::Next()
|
||||||
|
{
|
||||||
|
if(myCurrentnbpoints)
|
||||||
|
myCurrentindex++;
|
||||||
|
Find();
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//function :Find
|
||||||
|
//purpose :
|
||||||
|
//===========================================================================
|
||||||
|
void BRepIntCurveSurface_Inter::Find()
|
||||||
|
{
|
||||||
|
if(myCurrentnbpoints && myCurrentindex <= myCurrentnbpoints && FindPoint())
|
||||||
|
return;
|
||||||
|
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
currentnbpoints=0;
|
if(!myCurrentnbpoints && i > myFaces.Length())
|
||||||
|
{
|
||||||
|
myIndFace = i;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//function :FindPoint
|
||||||
|
//purpose :
|
||||||
|
//===========================================================================
|
||||||
|
Standard_Boolean BRepIntCurveSurface_Inter::FindPoint()
|
||||||
|
{
|
||||||
|
Standard_Integer j = (!myCurrentindex ? 1 : myCurrentindex);
|
||||||
|
|
||||||
|
for( ; j <= myCurrentnbpoints; j++ )
|
||||||
|
{
|
||||||
|
Standard_Real anU = myIntcs.Point(j).U();
|
||||||
|
Standard_Real aV = myIntcs.Point(j).V();
|
||||||
|
|
||||||
|
gp_Pnt2d Puv( anU,aV );
|
||||||
|
|
||||||
IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const {
|
myCurrentstate = myFastClass->Classify(Puv,myTolerance);
|
||||||
if(currentindex==0)
|
if(myCurrentstate == TopAbs_ON || myCurrentstate == TopAbs_IN)
|
||||||
|
{
|
||||||
|
myCurrentindex = j;
|
||||||
|
myCurrentU = anU;
|
||||||
|
myCurrentV = aV;
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//function :Point
|
||||||
|
//purpose :
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const
|
||||||
|
{
|
||||||
|
if(myCurrentindex==0)
|
||||||
StdFail_NotDone::Raise();
|
StdFail_NotDone::Raise();
|
||||||
const IntCurveSurface_IntersectionPoint& ICPS = intcs.Point(currentindex);
|
const IntCurveSurface_IntersectionPoint& ICPS = myIntcs.Point(myCurrentindex);
|
||||||
return(IntCurveSurface_IntersectionPoint(ICPS.Pnt(),
|
return(IntCurveSurface_IntersectionPoint(ICPS.Pnt(),
|
||||||
currentU, // ICPS.U(),
|
myCurrentU, // ICPS.U(),
|
||||||
currentV, // ICPS.V(),
|
myCurrentV, // ICPS.V(),
|
||||||
ICPS.W(),
|
ICPS.W(),
|
||||||
ICPS.Transition()));
|
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();
|
StdFail_NotDone::Raise();
|
||||||
//-- return(intcs.Point(currentindex).U());
|
//-- return(myIntcs.Point(myCurrentindex).U());
|
||||||
return(currentU);
|
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();
|
StdFail_NotDone::Raise();
|
||||||
//-- return(intcs.Point(currentindex).V());
|
//-- return(myIntcs.Point(myCurrentindex).V());
|
||||||
return(currentV);
|
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();
|
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();
|
StdFail_NotDone::Raise();
|
||||||
//-- return(classifier.State());
|
//-- 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();
|
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 {
|
const gp_Pnt& BRepIntCurveSurface_Inter::Pnt() const {
|
||||||
if(currentindex==0)
|
if(myCurrentindex==0)
|
||||||
StdFail_NotDone::Raise();
|
StdFail_NotDone::Raise();
|
||||||
return(intcs.Point(currentindex).Pnt());
|
return(myIntcs.Point(myCurrentindex).Pnt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,6 +75,7 @@
|
|||||||
#include <BRepOffset.hxx>
|
#include <BRepOffset.hxx>
|
||||||
#include <BRepOffset_MakeOffset.hxx>
|
#include <BRepOffset_MakeOffset.hxx>
|
||||||
#include <BRepClass3d_SolidClassifier.hxx>
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
|
||||||
static
|
static
|
||||||
void SampleEdges (const TopoDS_Shape& theShape,
|
void SampleEdges (const TopoDS_Shape& theShape,
|
||||||
@@ -115,7 +116,7 @@ void BRepTest::OtherCommands(Draw_Interpretor& theCommands)
|
|||||||
,__FILE__,subshape,g);
|
,__FILE__,subshape,g);
|
||||||
|
|
||||||
theCommands.Add("BRepIntCS",
|
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);
|
,__FILE__,brepintcs,g);
|
||||||
|
|
||||||
theCommands.Add("makeboss", "create a boss on the shape myS", __FILE__, MakeBoss, 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
|
//function : brepintcs
|
||||||
//purpose :
|
//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;
|
if (n <= 2)
|
||||||
TopoDS_Shape S = DBRep::Get(a[n-1]);
|
{
|
||||||
if (S.IsNull()) return 3;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
static BRepIntCurveSurface_Inter theAlg;
|
BRepIntCurveSurface_Inter theAlg;
|
||||||
static double tol=1e-6;
|
double tol=1e-6;
|
||||||
static int nbpi=0;
|
if( indshape < n-1)
|
||||||
static gp_Pnt curp;
|
{
|
||||||
|
Standard_Real preci = atof(a[n-1]);
|
||||||
if (n==3) {
|
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]);
|
Handle(Geom_Curve) C= DrawTrSurf::GetCurve(a[1]);
|
||||||
if (C.IsNull()) return 2;
|
if (C.IsNull()) return 2;
|
||||||
GeomAdaptor_Curve acur(C);
|
GeomAdaptor_Curve acur(C);
|
||||||
theAlg.Init(S, acur, tol);
|
theAlg.Init(S, acur, tol);
|
||||||
|
|
||||||
for (; theAlg.More(); theAlg.Next()) {
|
for (; theAlg.More(); theAlg.Next()) {
|
||||||
curp=theAlg.Pnt();
|
curp=theAlg.Pnt();
|
||||||
|
TopoDS_Vertex aV;
|
||||||
|
|
||||||
|
aB.MakeVertex(aV, curp, 0);
|
||||||
|
aB.Add(aComp, aV);
|
||||||
nbpi++;
|
nbpi++;
|
||||||
|
di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
|
||||||
char name[64];
|
char name[64];
|
||||||
char* temp = name; // pour portage WNT
|
char* temp = name; // pour portage WNT
|
||||||
Sprintf(temp, "%s_%d", "brics", nbpi);
|
Sprintf(temp, "%s_%d", "brics", nbpi);
|
||||||
@@ -299,24 +329,31 @@ Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char**
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Handle(Geom_Line) hl;
|
theAlg.Load(S,tol );
|
||||||
gp_Lin thel;
|
for (Standard_Integer il = 1; il<indshape ; il++)
|
||||||
for (Standard_Integer il = 1; il<n ; il++) {
|
{
|
||||||
hl= Handle(Geom_Line)::DownCast(DrawTrSurf::GetCurve(a[il]));
|
Handle(Geom_Curve) hl= DrawTrSurf::GetCurve(a[il]);
|
||||||
if (!hl.IsNull()) {
|
if (!hl.IsNull()) {
|
||||||
thel=hl->Lin();
|
theAlg.Init(hl);
|
||||||
theAlg.Init(S, thel, tol);
|
for (; theAlg.More(); theAlg.Next()) {
|
||||||
for (; theAlg.More(); theAlg.Next()) {
|
curp=theAlg.Pnt();
|
||||||
curp=theAlg.Pnt();
|
nbpi++;
|
||||||
nbpi++;
|
TopoDS_Vertex aV;
|
||||||
char name[64];
|
aB.MakeVertex(aV, curp, 0);
|
||||||
char* temp = name; // pour portage WNT
|
aB.Add(aComp, aV);
|
||||||
Sprintf(temp, "%s_%d", "brics", nbpi);
|
di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
|
||||||
DrawTrSurf::Set(temp, curp);
|
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
|
//POP pour NT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
|
#include <gp_Lin.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
|
||||||
static void Perform(BRepIntCurveSurface_Inter&,
|
static void Perform(BRepIntCurveSurface_Inter&,
|
||||||
LocOpe_SequenceOfPntFace&);
|
LocOpe_SequenceOfPntFace&);
|
||||||
|
44
tests/bugs/modalg_5/bug24899
Normal file
44
tests/bugs/modalg_5/bug24899
Normal file
@@ -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"
|
||||||
|
}
|
Reference in New Issue
Block a user