1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
-- File: IntCurvesFace.cdl
-- Created: Fri May 31 13:50:31 1996
-- Author: Laurent BUCHARD
-- <lbr@sherlox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
package IntCurvesFace
----------------------------------------------------------------------
-- This package provide algorithms to compute the intersection points
-- between a Face [a Shape] and a set of curves (The face [shape] is
-- loaded, then for each curve is given to compute the intersection).
--
-- Intersector [ ShapeIntersector ] can be used when the caller have
-- to intersect more than one curve with the face [the shape].
--
--
-- If there is only one curve, or if the face has no restrictions,
-- someother algorithms can be called.
--
-- see for example the packages :
--
-- ** BRepIntCurveSurface : ( One Curve <-> One Shape )
-- ** IntCurveSurface : ( One Curve <-> One Surface)
--
----------------------------------------------------------------------
uses
gp ,
TopAbs ,
TopoDS ,
BRepTopAdaptor ,
BRepAdaptor ,
Adaptor3d ,
Bnd ,
IntCurveSurface ,
TColStd ,
GeomAbs
is
class Intersector; -- Intersection between a Face and a set of curves
class ShapeIntersector; -- Intersection between a Shape and a set of curves
-- Note ( has an empty constructor )
end;

View File

@@ -0,0 +1,192 @@
-- File: IntCurvesFace_Intersector.cdl
-- Created: Fri May 31 13:53:21 1996
-- Author: Laurent BUCHARD
-- <lbr@sherlox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
-- Modified by skv - Wed Sep 3 15:38:56 2003 OCC578
-- Adding a sequence of state with two possible values: 0 means the point is
-- inside the face, 1 - the point is on the bound of face. This is done to get
-- a proper result of method State(int), which always returned TopAbs_IN before.
class Intersector from IntCurvesFace
uses
Lin from gp,
Pnt from gp,
Pnt2d from gp,
Box from Bnd,
Face from TopoDS,
Shape from TopoDS,
State from TopAbs,
TopolTool from BRepTopAdaptor,
HSurface from BRepAdaptor,
TransitionOnCurve from IntCurveSurface,
SequenceOfPnt from IntCurveSurface,
-- Modified by skv - Wed Sep 3 15:38:56 2003 OCC578 Begin
SequenceOfInteger from TColStd,
-- Modified by skv - Wed Sep 3 15:38:56 2003 OCC578 End
HCurve from Adaptor3d,
HInter from IntCurveSurface,
SurfaceType from GeomAbs
is
Create(F : Face from TopoDS;
aTol : Real from Standard)
---Purpose: Load a Face.
--
-- The Tolerance <Tol> is used to determine if the
-- first point of the segment is near the face. In
-- that case, the parameter of the intersection point
-- on the line can be a negative value (greater than -Tol).
returns Intersector from IntCurvesFace;
Perform(me: in out; L : Lin from gp;
PInf : Real from Standard;
PSup : Real from Standard)
---Purpose: Perform the intersection between the
-- segment L and the loaded face.
--
-- PInf is the smallest parameter on the line
-- PSup is the highest parmaeter on the line
--
-- For an infinite line PInf and PSup can be
-- +/- RealLast.
is static;
Perform(me: in out; HCu : HCurve from Adaptor3d;
PInf : Real from Standard;
PSup : Real from Standard)
---Purpose : same method for a HCurve from Adaptor3d.
-- PInf an PSup can also be - and + INF.
is static;
SurfaceType(me)
---Purpose: Return the surface type
returns SurfaceType from GeomAbs
is static;
IsDone(me)
---Purpose: True is returned when the intersection have been computed.
---C++: inline
returns Boolean from Standard
is static;
NbPnt(me)
---C++: inline
returns Integer from Standard
is static;
UParameter(me; I : Integer from Standard)
---Purpose: Returns the U parameter of the ith intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
VParameter(me; I : Integer from Standard)
---Purpose: Returns the V parameter of the ith intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
WParameter(me; I : Integer from Standard)
---Purpose: Returns the parameter of the ith intersection point
-- on the line.
---C++: inline
returns Real from Standard
is static;
Pnt(me; I : Integer from Standard)
---Purpose: Returns the geometric point of the ith intersection
-- between the line and the surface.
---C++: inline
---C++: return const &
returns Pnt from gp
is static;
Transition(me; I : Integer from Standard)
---Purpose: Returns the ith transition of the line on the surface.
---C++: inline
returns TransitionOnCurve from IntCurveSurface
is static;
State(me; I : Integer from Standard)
---Purpose: Returns the ith state of the point on the face.
-- The values can be either TopAbs_IN
-- ( the point is in the face)
-- or TopAbs_ON
-- ( the point is on a boudary of the face).
---C++: inline
returns State from TopAbs
is static;
Face(me)
---Purpose: Returns the significant face used to determine
-- the intersection.
--
---C++: inline
---C++: return const &
returns Face from TopoDS
is static;
InternalCall(me: in out;
HICS: HInter from IntCurveSurface;
pinf: Real from Standard;
psup: Real from Standard)
is static private;
ClassifyUVPoint(me; Puv: Pnt2d from gp)
returns State from TopAbs;
Bounding(me)
returns Box from Bnd;
Destroy(me: in out);
---C++: alias ~
fields
myTopolTool : TopolTool from BRepTopAdaptor;
Hsurface : HSurface from BRepAdaptor;
Tol : Real from Standard;
SeqPnt : SequenceOfPnt from IntCurveSurface;
-- Modified by skv - Wed Sep 3 15:38:56 2003 OCC578 Begin
mySeqState : SequenceOfInteger from TColStd; -- 0 = IN, 1 = ON
-- Modified by skv - Wed Sep 3 15:38:56 2003 OCC578 End
-- pnt : Pnt from gp;
-- U : Real from Standard;
-- V : Real from Standard;
-- W : Real from Standard;
-- transition : TransitionOnCurve from IntCurveSurface;
done : Boolean from Standard;
nbpnt : Integer from Standard;
-- state : State from TopAbs;
face : Face from TopoDS;
PtrOnPolyhedron : Address from Standard;
PtrOnBndBounding : Address from Standard;
end Intersector from IntCurvesFace;

View File

@@ -0,0 +1,378 @@
// File: IntCurvesFace_Intersector.cxx
// Created: Mon Jun 3 10:08:13 1996
// Author: Laurent BUCHARD
// <lbr@sherlox.paris1.matra-dtv.fr>
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578
#define OPTIMISATION 1
#include <IntCurvesFace_Intersector.ixx>
#include <IntCurveSurface_ThePolyhedronToolOfHInter.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <IntCurveSurface_IntersectionPoint.hxx>
#include <gp_Lin.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs.hxx>
#include <IntCurveSurface_HInter.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <Geom_Line.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <Bnd_Box.hxx>
#include <Intf_Tool.hxx>
#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <IntCurveSurface_SequenceOfPnt.hxx>
GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const {
return(Adaptor3d_HSurfaceTool::GetType(Hsurface));
}
//============================================================================
IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
const Standard_Real aTol)
:
Tol(aTol),done(Standard_False),nbpnt(0),PtrOnPolyhedron(NULL),PtrOnBndBounding(NULL)
{
BRepAdaptor_Surface surface;
face = Face;
surface.Initialize(Face,Standard_True);
Hsurface = new BRepAdaptor_HSurface(surface);
myTopolTool = new BRepTopAdaptor_TopolTool(Hsurface);
GeomAbs_SurfaceType SurfaceType = Adaptor3d_HSurfaceTool::GetType(Hsurface);
if( (SurfaceType != GeomAbs_Plane)
&& (SurfaceType != GeomAbs_Cylinder)
&& (SurfaceType != GeomAbs_Cone)
&& (SurfaceType != GeomAbs_Sphere)
&& (SurfaceType != GeomAbs_Torus)) {
Standard_Integer nbsu,nbsv;
Standard_Real U0,V0,U1,V1;
U0 = Hsurface->FirstUParameter();
U1 = Hsurface->LastUParameter();
V0 = Hsurface->FirstVParameter();
V1 = Hsurface->LastVParameter();
//-- nbsu = Adaptor3d_HSurfaceTool::NbSamplesU(Hsurface,U0,U1);
//-- nbsv = Adaptor3d_HSurfaceTool::NbSamplesV(Hsurface,V0,V1);
nbsu = myTopolTool->NbSamplesU();
nbsv = myTopolTool->NbSamplesV();
if(nbsu>40) nbsu = 40;
if(nbsv>40) nbsv = 40;
//-- printf("\n IntCurvesFace_Intersector : nbsu=(%3d)->%3d nbsv=(%3d)->%3d",myTopolTool->NbSamplesU(),nbsu,myTopolTool->NbSamplesV(),nbsv);
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *) new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
}
}
//============================================================================
void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
const Standard_Real parinf,const Standard_Real parsup) {
if(HICS.IsDone()) {
for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) {
const IntCurveSurface_IntersectionPoint& HICSPointindex = HICS.Point(index);
gp_Pnt2d Puv(HICSPointindex.U(),HICSPointindex.V());
TopAbs_State currentstate = myTopolTool->Classify(Puv,Tol);
if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) {
Standard_Real HICSW = HICSPointindex.W();
if(HICSW >= parinf && HICSW <= parsup ) {
Standard_Real U = HICSPointindex.U();
Standard_Real V = HICSPointindex.V();
Standard_Real W = HICSW;
IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition();
gp_Pnt pnt = HICSPointindex.Pnt();
// state = currentstate;
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1;
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
if(transition != IntCurveSurface_Tangent && face.Orientation()==TopAbs_REVERSED) {
if(transition == IntCurveSurface_In)
transition = IntCurveSurface_Out;
else
transition = IntCurveSurface_In;
}
//----- Insertion du point
if(nbpnt==0) {
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
SeqPnt.Append(PPP);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Append(anIntState);
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
else {
Standard_Integer i = 1;
Standard_Integer b = nbpnt+1;
while(i<=nbpnt) {
const IntCurveSurface_IntersectionPoint& Pnti=SeqPnt.Value(i);
Standard_Real wi = Pnti.W();
if(wi >= W) { b=i; i=nbpnt; }
i++;
}
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
// if(b>nbpnt) { SeqPnt.Append(PPP); }
// else if(b>0) { SeqPnt.InsertBefore(b,PPP); }
if(b>nbpnt) {
SeqPnt.Append(PPP);
mySeqState.Append(anIntState);
} else if(b>0) {
SeqPnt.InsertBefore(b,PPP);
mySeqState.InsertBefore(b, anIntState);
}
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
nbpnt++;
}
} //-- classifier state is IN or ON
} //-- Loop on Intersection points.
} //-- HICS.IsDone()
}
//--------------------------------------------------------------------------------
void IntCurvesFace_Intersector::Perform(const gp_Lin& L,const Standard_Real ParMin,const Standard_Real ParMax) {
done = Standard_True;
SeqPnt.Clear();
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Clear();
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
nbpnt = 0;
IntCurveSurface_HInter HICS;
Handle(Geom_Line) geomline = new Geom_Line(L);
GeomAdaptor_Curve LL(geomline);
//--
Handle(GeomAdaptor_HCurve) HLL = new GeomAdaptor_HCurve(LL);
//--
Standard_Real parinf=ParMin;
Standard_Real parsup=ParMax;
if(PtrOnPolyhedron == NULL) {
HICS.Perform(HLL,Hsurface);
}
else {
Intf_Tool bndTool;
Bnd_Box boxLine;
bndTool.LinBox(L,((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(),boxLine);
if(bndTool.NbSegments() == 0)
return;
for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) {
Standard_Real pinf = bndTool.BeginParam(nbseg);
Standard_Real psup = bndTool.EndParam(nbseg);
Standard_Real pppp = 0.05*(psup-pinf);
pinf-=pppp;
psup+=pppp;
if((psup - pinf)<1e-10) { pinf-=1e-10; psup+=1e-10; }
if(nbseg==1) { parinf=pinf; parsup=psup; }
else {
if(parinf>pinf) parinf = pinf;
if(parsup<psup) parsup = psup;
}
}
if(parinf>ParMax) { return; }
if(parsup<ParMin) { return; }
if(parinf<ParMin) parinf=ParMin;
if(parsup>ParMax) parsup=ParMax;
if(parinf>(parsup-1e-9)) return;
IntCurveSurface_ThePolygonOfHInter polygon(HLL,
parinf,
parsup,
2);
#if OPTIMISATION
if(PtrOnBndBounding==NULL) {
PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
}
HICS.Perform(HLL,
polygon,
Hsurface,
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
*((Bnd_BoundSortBox *)PtrOnBndBounding));
#else
HICS.Perform(HLL,
polygon,
Hsurface,
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
#endif
}
InternalCall(HICS,parinf,parsup);
#if 0
if(HICS.IsDone()) {
for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) {
const IntCurveSurface_IntersectionPoint& HICSPointindex = HICS.Point(index);
gp_Pnt2d Puv(HICSPointindex.U(),HICSPointindex.V());
TopAbs_State currentstate = myTopolTool->Classify(Puv,Tol);
if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) {
Standard_Real HICSW = HICSPointindex.W();
if(HICSW >= parinf && HICSW <= parsup ) {
Standard_Real U = HICSPointindex.U();
Standard_Real V = HICSPointindex.V();
Standard_Real W = HICSW;
IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition();
gp_Pnt pnt = HICSPointindex.Pnt();
// state = currentstate;
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1;
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
if(face.Orientation()==TopAbs_REVERSED) {
if(transition == IntCurveSurface_In)
transition = IntCurveSurface_Out;
else
transition = IntCurveSurface_In;
}
//----- Insertion du point
if(nbpnt==0) {
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
SeqPnt.Append(PPP);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Append(anIntState);
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
else {
Standard_Integer i = 1;
Standard_Integer b = nbpnt+1;
while(i<=nbpnt) {
const IntCurveSurface_IntersectionPoint& Pnti=SeqPnt.Value(i);
Standard_Real wi = Pnti.W();
if(wi >= W) { b=i; i=nbpnt; }
i++;
}
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
// if(b>nbpnt) { SeqPnt.Append(PPP); }
// else if(b>0) { SeqPnt.InsertBefore(b,PPP); }
if(b>nbpnt) {
SeqPnt.Append(PPP);
mySeqState.Append(anIntState);
} else if(b>0) {
SeqPnt.InsertBefore(b,PPP);
mySeqState.InsertBefore(b, anIntState);
}
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
nbpnt++;
}
} //-- classifier state is IN or ON
} //-- Loop on Intersection points.
} //-- HICS.IsDone()
#endif
}
//============================================================================
void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,const Standard_Real ParMin,const Standard_Real ParMax) {
done = Standard_True;
SeqPnt.Clear();
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Clear();
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
nbpnt = 0;
IntCurveSurface_HInter HICS;
//--
Standard_Real parinf=ParMin;
Standard_Real parsup=ParMax;
if(PtrOnPolyhedron == NULL) {
HICS.Perform(HCu,Hsurface);
}
else {
parinf = IntCurveSurface_TheHCurveTool::FirstParameter(HCu);
parsup = IntCurveSurface_TheHCurveTool::LastParameter(HCu);
if(parinf<ParMin) parinf = ParMin;
if(parsup>ParMax) parsup = ParMax;
if(parinf>(parsup-1e-9)) return;
Standard_Integer nbs;
nbs = IntCurveSurface_TheHCurveTool::NbSamples(HCu,parinf,parsup);
IntCurveSurface_ThePolygonOfHInter polygon(HCu,
parinf,
parsup,
nbs);
#if OPTIMISATION
if(PtrOnBndBounding==NULL) {
PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
}
HICS.Perform(HCu,
polygon,
Hsurface,
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
*((Bnd_BoundSortBox *)PtrOnBndBounding));
#else
HICS.Perform(HCu,
polygon,
Hsurface,
*((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
#endif
}
InternalCall(HICS,parinf,parsup);
}
//============================================================================
Bnd_Box IntCurvesFace_Intersector::Bounding() const {
if(PtrOnPolyhedron !=NULL) {
return(((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding());
}
else {
Bnd_Box B;
return(B);
}
}
TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const {
TopAbs_State state = myTopolTool->Classify(Puv,1e-7);
return(state);
}
//============================================================================
void IntCurvesFace_Intersector::Destroy() {
if(PtrOnPolyhedron !=NULL) {
delete (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
PtrOnPolyhedron = NULL;
}
if(PtrOnBndBounding !=NULL) {
delete (Bnd_BoundSortBox *)PtrOnBndBounding;
PtrOnBndBounding=NULL;
}
}

View File

@@ -0,0 +1,54 @@
// File: IntCurvesFace_Intersector.lxx
// Created: Mon Jun 3 10:22:43 1996
// Author: Laurent BUCHARD
// <lbr@sherlox.paris1.matra-dtv.fr>
// Modified by skv - Wed Sep 3 15:33:17 2003 OCC578
#include <IntCurveSurface_IntersectionPoint.hxx>
#include <TopAbs_State.hxx>
//============================================================================
inline Standard_Boolean IntCurvesFace_Intersector::IsDone() const {
return(done);
}
//============================================================================
inline Standard_Integer IntCurvesFace_Intersector::NbPnt() const {
return(nbpnt);
}
//============================================================================
inline const gp_Pnt& IntCurvesFace_Intersector::Pnt(const Standard_Integer i ) const {
return(SeqPnt.Value(i).Pnt());
}
//============================================================================
inline Standard_Real IntCurvesFace_Intersector::UParameter(const Standard_Integer i) const {
return(SeqPnt.Value(i).U());
}
//============================================================================
inline Standard_Real IntCurvesFace_Intersector::VParameter(const Standard_Integer i) const {
return(SeqPnt.Value(i).V());
}
//============================================================================
inline Standard_Real IntCurvesFace_Intersector::WParameter(const Standard_Integer i) const {
return(SeqPnt.Value(i).W());
}
//============================================================================
inline IntCurveSurface_TransitionOnCurve IntCurvesFace_Intersector::Transition(const Standard_Integer i) const {
return(SeqPnt.Value(i).Transition());
}
//============================================================================
// Modified by skv - Wed Sep 3 15:34:18 2003 OCC578 Begin
// //inline TopAbs_State IntCurvesFace_Intersector::State(const Standard_Integer i) const {
// inline TopAbs_State IntCurvesFace_Intersector::State(const Standard_Integer ) const {
// return(TopAbs_IN);
// }
inline TopAbs_State IntCurvesFace_Intersector::State(const Standard_Integer i) const {
return (mySeqState.Value(i) == 0) ? TopAbs_IN : TopAbs_ON;
}
// Modified by skv - Wed Sep 3 15:34:20 2003 OCC578 End
//============================================================================
inline const TopoDS_Face& IntCurvesFace_Intersector::Face() const {
return(face);
}
//============================================================================

View File

@@ -0,0 +1,175 @@
-- File: IntCurvesFace_ShapeIntersector.cdl
-- Created: Tue Jan 27 15:42:18 1998
-- Author: Laurent BUCHARD
-- <lbr@cracbox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class ShapeIntersector from IntCurvesFace
uses
Lin from gp,
HCurve from Adaptor3d,
Shape from TopoDS,
Face from TopoDS,
Pnt from gp,
State from TopAbs,
TransitionOnCurve from IntCurveSurface,
SequenceOfInteger from TColStd,
SequenceOfReal from TColStd,
SeqOfPtr from BRepTopAdaptor
is
-- ========================= i n i t i a l i s a t i o n s ================
Create
-- empty constructor
returns ShapeIntersector from IntCurvesFace;
Load(me: in out; Sh : Shape from TopoDS;
Tol: Real from Standard)
is static;
Perform(me: in out; L : Lin from gp;
PInf : Real from Standard;
PSup : Real from Standard)
---Purpose: Perform the intersection between the
-- segment L and the loaded shape.
--
-- PInf is the smallest parameter on the line
-- PSup is the highest parammter on the line
--
-- For an infinite line PInf and PSup can be
-- +/- RealLast.
is static;
PerformNearest(me: in out; L : Lin from gp;
PInf : Real from Standard;
PSup : Real from Standard)
---Purpose: Perform the intersection between the
-- segment L and the loaded shape.
--
-- PInf is the smallest parameter on the line
-- PSup is the highest parammter on the line
--
-- For an infinite line PInf and PSup can be
-- +/- RealLast.
is static;
Perform(me: in out; HCu : HCurve from Adaptor3d;
PInf : Real from Standard;
PSup : Real from Standard)
---Purpose : same method for a HCurve from Adaptor3d.
-- PInf an PSup can also be - and + INF.
is static;
-- ============================= r e s u l t s ============================
-- ===
-- === (ordered by increasing parameter on the curve)
-- ===
IsDone(me)
---Purpose: True is returned when the intersection have been computed.
---C++: inline
returns Boolean from Standard
is static;
NbPnt(me)
---C++: inline
returns Integer from Standard
is static;
UParameter(me; I : Integer from Standard)
---Purpose: Returns the U parameter of the ith intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
VParameter(me; I : Integer from Standard)
---Purpose: Returns the V parameter of the ith intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
WParameter(me; I : Integer from Standard)
---Purpose: Returns the parameter of the ith intersection point
-- on the line.
---C++: inline
returns Real from Standard
is static;
Pnt(me; I : Integer from Standard)
---Purpose: Returns the geometric point of the ith intersection
-- between the line and the surface.
---C++: inline
---C++: return const &
returns Pnt from gp
is static;
Transition(me; I : Integer from Standard)
---Purpose: Returns the ith transition of the line on the surface.
---C++: inline
returns TransitionOnCurve from IntCurveSurface
is static;
State(me; I : Integer from Standard)
---Purpose: Returns the ith state of the point on the face.
-- The values can be either TopAbs_IN
-- ( the point is in the face)
-- or TopAbs_ON
-- ( the point is on a boudary of the face).
---C++: inline
returns State from TopAbs
is static;
Face(me; I : Integer from Standard)
---Purpose: Returns the significant face used to determine
-- the intersection.
--
---C++: inline
---C++: return const &
returns Face from TopoDS
is static;
-- ================== I n t e r n a l F u n c t i o n s ===============
SortResult(me: in out)
---Purpose: Internal method. Sort the result on the Curve
-- parameter.
is static;
Destroy(me: in out);
---C++: alias ~
fields
done : Boolean from Standard;
nbfaces : Integer from Standard;
PtrJetons : Address from Standard;
PtrJetonsIndex : Address from Standard;
PtrIntersector : SeqOfPtr from BRepTopAdaptor;
IndexPt : SequenceOfInteger from TColStd;
IndexFace : SequenceOfInteger from TColStd;
IndexIntPnt : SequenceOfInteger from TColStd;
IndexPar : SequenceOfReal from TColStd;
end ShapeIntersector from IntCurvesFace;

View File

@@ -0,0 +1,216 @@
// File: IntCurvesFace_ShapeIntersector.cxx
// Created: Tue Jan 27 16:58:07 1998
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>
#include <IntCurvesFace_ShapeIntersector.ixx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <IntCurvesFace_Intersector.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <Bnd_HArray1OfBox.hxx>
#include <ElCLib.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
//-- ================================================================================
IntCurvesFace_ShapeIntersector::IntCurvesFace_ShapeIntersector() {
nbfaces=0;
done=Standard_False;
PtrJetons=NULL;
PtrJetonsIndex=NULL;
}
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::Load(const TopoDS_Shape& shape,
const Standard_Real tol) {
PtrJetons=NULL;
PtrJetonsIndex=NULL;
if(nbfaces) {
Destroy();
}
TopExp_Explorer Ex;
Standard_Integer i;
for(nbfaces=0,i=0,Ex.Init(shape,TopAbs_FACE); Ex.More(); i++,Ex.Next()) {
nbfaces++;
TopoDS_Face currentface = TopoDS::Face(Ex.Current());
PtrIntersector.Append((void *)(new IntCurvesFace_Intersector(currentface,tol)));
}
}
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::Destroy() {
if(PtrJetons) {
delete ((Standard_Integer *)PtrJetons);
PtrJetons=NULL;
}
if(PtrJetonsIndex) {
delete ((Standard_Integer *)PtrJetonsIndex);
PtrJetonsIndex=NULL;
}
for(Standard_Integer i=1; i<=nbfaces; i++) {
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
delete Ptr;
}
done=Standard_False;
nbfaces=0;
PtrIntersector.Clear();
IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
}
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::Perform(const gp_Lin& L,
const Standard_Real ParMin,
const Standard_Real ParMax) {
done = Standard_False;
for(Standard_Integer i=1; i<=nbfaces; i++) {
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
Ptr->Perform(L,ParMin,ParMax);
}
SortResult();
}
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::PerformNearest(const gp_Lin& L,
const Standard_Real ParMin,
const Standard_Real _ParMax) {
Standard_Integer i;
Standard_Integer* _PtrJetons=(Standard_Integer *)PtrJetons;
Standard_Integer* _PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
if(nbfaces>2) {
if(PtrJetons==NULL) {
PtrJetons = (void *) new Standard_Integer [nbfaces];
PtrJetonsIndex = (void *) new Standard_Integer [nbfaces];
Standard_Integer *Ptr =(Standard_Integer *)PtrJetons;
Standard_Integer *PtrI=(Standard_Integer *)PtrJetonsIndex;
for(i=0;i<nbfaces;i++) {
Ptr[i]=0;
PtrI[i]=i+1;
}
_PtrJetons=(Standard_Integer *)PtrJetons;
_PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
}
}
Standard_Integer Indexface=-1;
Standard_Real ParMax=_ParMax;
done = Standard_False;
for(Standard_Integer ii=1; ii<=nbfaces; ii++) {
if(_PtrJetons) {
i=_PtrJetonsIndex[ii-1];
}
else {
i=ii;
}
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
if(ParMin<ParMax) {
Ptr->Perform(L,ParMin,ParMax);
if(Ptr->IsDone()) {
Standard_Integer n=Ptr->NbPnt();
for(Standard_Integer j=1;j<=n;j++) {
Standard_Real w=Ptr->WParameter(j);
if(w<ParMax) {
ParMax=w;
Indexface=ii-1;
}
}
}
else {
done = Standard_False;
return;
}
}
}
if(PtrJetons && Indexface>=0) {
_PtrJetons[Indexface]++;
Standard_Integer im1;
for(im1=Indexface-1,i=Indexface; i>=1 && _PtrJetons[i]>_PtrJetons[i-1]; i--,im1--) {
Standard_Integer t=_PtrJetonsIndex[i];
_PtrJetonsIndex[i]=_PtrJetonsIndex[im1];
_PtrJetonsIndex[im1]=t;
t=_PtrJetons[i];
_PtrJetons[i]=_PtrJetons[im1];
_PtrJetons[im1]=t;
}
//--for(Standard_Integer dd=0; dd<nbfaces;dd++) { if(_PtrJetons[dd]) { printf("\n<%3d %3d %3d>",dd,_PtrJetons[dd],_PtrJetonsIndex[dd]); } }
//--printf("\n");
}
SortResult();
}
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,
const Standard_Real ParMin,
const Standard_Real ParMax) {
done = Standard_False;
for(Standard_Integer i=1; i<=nbfaces; i++) {
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
Ptr->Perform(HCu,ParMin,ParMax);
}
SortResult();
}
//-- ================================================================================
//-- PtrIntersector : Sequence d addresses
//-- IndexPt : 1 2 3 .... n points avant le tri
//-- IndexFace : Numero de la face (de l intersector) du point IndexPt(i)
//-- IndexIntPnt : Numero du point IndexPt(i) dans l'intersector IndexFace(IndexPt(i))
//-- IndexPar : W parameter du point IndexPt(i)
//--
//-- En resume, pour chaque point indice par K = IndexPt(i) on a
//-- * la face a laquelle il appartient : IndexFace(K)
//-- * le numero du point dans l'intersecteur FaceCurve : IndexIntPnt(K)
//-- * le parametre W du point sur la courbe : IndexPar(K)
//--
//-- SortResult Trie les points par ordre croissant de W
//-- (remet a jour le tableau d index TabPt(.))
//--
//-- ================================================================================
void IntCurvesFace_ShapeIntersector::SortResult() {
done = Standard_True;
Standard_Integer nbpnt=0;
IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
//-- -----------------------------------------------------
//-- r e c u p e r a t i o n d e s r e s u l t a t s
//--
for(Standard_Integer f=1; f<=nbfaces; f++) {
IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(f);
if(Ptr->IsDone()) {
Standard_Integer n=Ptr->NbPnt();
for(Standard_Integer j=1;j<=n;j++) {
IndexPt.Append(++nbpnt);
IndexFace.Append(f);
IndexIntPnt.Append(j);
IndexPar.Append(Ptr->WParameter(j));
}
}
else {
done = Standard_False;
return;
}
}
//-- -----------------------------------------------------
//-- t r i s e l o n l e p a r a m e t r e w
//--
Standard_Boolean triok;
do {
triok=Standard_True;
for(Standard_Integer ind0=1;ind0<nbpnt;ind0++) {
Standard_Integer ind =IndexPt(ind0);
Standard_Integer indp1=IndexPt(ind0+1);
if(IndexPar(ind) > IndexPar(indp1)) {
IndexPt(ind0) =indp1;
IndexPt(ind0+1)=ind;
triok=Standard_False;
}
}
}
while(triok==Standard_False);
}
//-- ================================================================================
//-- Creation le 28 jan 98
//--

View File

@@ -0,0 +1,62 @@
// File: IntCurvesFace_ShapeIntersector.lxx
// Created: Wed Jan 28 10:10:37 1998
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>
#include <IntCurvesFace_Intersector.hxx>
inline Standard_Integer IntCurvesFace_ShapeIntersector::NbPnt() const {
return(IndexPt.Length());
}
inline Standard_Real IntCurvesFace_ShapeIntersector::UParameter(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->UParameter(IndexIntPnt(IndexPt(i))));
}
inline Standard_Real IntCurvesFace_ShapeIntersector::VParameter(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->VParameter(IndexIntPnt(IndexPt(i))));
}
inline Standard_Real IntCurvesFace_ShapeIntersector::WParameter(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->WParameter(IndexIntPnt(IndexPt(i))));
}
inline const gp_Pnt& IntCurvesFace_ShapeIntersector::Pnt(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->Pnt(IndexIntPnt(IndexPt(i))));
}
inline IntCurveSurface_TransitionOnCurve IntCurvesFace_ShapeIntersector::Transition(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->Transition(IndexIntPnt(IndexPt(i))));
}
inline TopAbs_State IntCurvesFace_ShapeIntersector::State(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->State(IndexIntPnt(IndexPt(i))));
}
inline const TopoDS_Face& IntCurvesFace_ShapeIntersector::Face(const Standard_Integer i) const {
IntCurvesFace_Intersector *Ptr =
(IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
return(Ptr->Face());
}
inline Standard_Boolean IntCurvesFace_ShapeIntersector::IsDone() const {
return(done);
}