1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0022887: Request to make Intf_InterferencePolygon2d class thread-safe.

This commit is contained in:
azn 2012-03-12 18:31:11 +04:00 committed by bugmaster
parent d64e6d05d9
commit 9530af2780
34 changed files with 1054 additions and 1332 deletions

View File

@ -3,6 +3,5 @@ IntCurve_IntConicConic_1.cxx
IntCurve_IntConicConic_Tool.cxx
IntCurve_IntConicConic_Tool.cxx
IntCurve_IntConicConic_Tool.cxx
IntCurve_ToolPolygon.gxx
IntCurve_IntConicConic_1.hxx
IntCurve_IntConicConic_Tool.hxx

View File

@ -43,7 +43,6 @@ package IntCurve
-- ProjPCurGen,
-- UserIntConicCurveGen,
-- IntPolyPolyGen,
-- ToolPolygon,
-- Polygon2dGen,
-- DistBetweenPCurvesGen> are Internal
--
@ -67,11 +66,7 @@ is
generic class Polygon2dGen;
generic class ToolPolygon;
generic class IntPolyPolyGen,ThePolygon2d,
ThePolygon2dTool,
InterferencePoly2d,
TheDistBetweenPCurves,
ExactIntersectionPoint;

View File

@ -1,7 +1,6 @@
-- File: IntPolyPolyGen.cdl
-- Created: Mon Oct 19 12:03:29 1992
-- Author: Laurent BUCHARD
-- <lbr@sdsun2>
---Copyright: Matra Datavision 1992
@ -22,23 +21,11 @@ uses Domain from IntRes2d
class ThePolygon2d instantiates Polygon2dGen from IntCurve
(TheCurve,
TheCurveTool);
TheCurveTool);
class ThePolygon2dTool instantiates ToolPolygon from IntCurve
(Pnt2d from gp,
ThePolygon2d,
Box2d from Bnd);
class InterferencePoly2d instantiates InterferencePolygon2d from Intf
(ThePolygon2d,
ThePolygon2dTool,
ThePolygon2d,
ThePolygon2dTool);
class TheDistBetweenPCurves instantiates DistBetweenPCurvesGen
(TheCurve,
TheCurveTool);
TheCurveTool);
class ExactIntersectionPoint

View File

@ -1,7 +1,6 @@
// File: IntCurve_IntPolyPolyGen.gxx
// Created: Tue Oct 13 11:12:26 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
// Modified by skv - Tue Mar 1 14:22:09 2005 OCC8169
@ -26,6 +25,7 @@
#include <Intf_SectionPoint.hxx>
#include <Intf_SectionLine.hxx>
#include <Intf_TangentZone.hxx>
#include <Intf_InterferencePolygon2d.hxx>
#include <gp_Vec2d.hxx>
@ -387,7 +387,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
Poly1.SetDeflectionOverEstimation(TolConf);
}
IntCurve_InterferencePoly2d InterPP(Poly1);
Intf_InterferencePolygon2d InterPP(Poly1);
IntCurve_ExactIntersectionPoint EIP(C1,C1,TolConf);
Standard_Real U,V;
@ -843,7 +843,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
if(PtrPoly2->DeflectionOverEstimation() < TolConf) {
PtrPoly2->SetDeflectionOverEstimation(TolConf);
}
IntCurve_InterferencePoly2d InterPP(*PtrPoly1,*PtrPoly2);
Intf_InterferencePolygon2d InterPP(*PtrPoly1,*PtrPoly2);
IntCurve_ExactIntersectionPoint EIP(C1,C2,TolConf);
Standard_Real U,V;

View File

@ -1,7 +1,6 @@
-- File: Polygon2dGen.cdl
-- Created: Mon Oct 19 11:51:16 1992
-- Author: Laurent BUCHARD
-- <lbr@sdsun2>
---Copyright: Matra Datavision 1992
@ -11,21 +10,20 @@ generic class Polygon2dGen from IntCurve (
---Purpose: Describe a polyline as a topology to compute the
-- interference beetween two polylines 2 dimension.
---Level: Internal
inherits Polygon2d from Intf
uses Pnt2d from gp,
Box2d from Bnd,
Array1OfPnt2d from TColgp,
Array1OfReal from TColStd,
Array1OfInteger from TColStd,
Domain from IntRes2d
Array1OfReal from TColStd,
Array1OfInteger from TColStd,
Domain from IntRes2d
raises OutOfRange from Standard
is
Create (Curve : TheCurve;
@ -63,17 +61,10 @@ is
-- a polygon inside or near the OtherBox.
is static;
Bounding (me)
returns Box2d from Bnd
is static;
---C++: return const &
---C++: inline
---Purpose: Give the bounding box of the polygon.
DeflectionOverEstimation(me)
returns Real from Standard
---C++: inline
is static;
is redefined virtual;
SetDeflectionOverEstimation(me: in out; x:Real from Standard)
---C++: inline
@ -83,34 +74,16 @@ is
---C++: inline
is static;
Closed (me)
returns Boolean from Standard
---C++: inline
is static;
NbSegments (me)
returns Integer
---C++: inline
is static;
is redefined virtual;
---Purpose: Give the number of Segments in the polyline.
BeginOfSeg (me;
Index : in Integer)
returns Pnt2d from gp
raises OutOfRange from Standard
is static;
---Purpose: Give the point of range Index in the Polygon.
---C++: inline
---C++: return const &
EndOfSeg (me;
Index : in Integer)
returns Pnt2d from gp
raises OutOfRange from Standard
is static;
---Purpose: Give the point of range Index in the Polygon.
---C++: inline
---C++: return const &
Segment (me; theIndex : in Integer from Standard;
theBegin, theEnd : in out Pnt2d from gp)
raises OutOfRange from Standard is redefined virtual;
---Purpose: Returns the points of the segment <Index> in the Polygon.
-- Implementation :
@ -165,22 +138,17 @@ is
is static;
fields TheBnd : Box2d from Bnd;
TheDeflection : Real from Standard;
fields TheDeflection : Real from Standard;
NbPntIn : Integer from Standard;
TheMaxNbPoints: Integer from Standard;
TheMaxNbPoints: Integer from Standard;
ThePnts : Array1OfPnt2d from TColgp;
TheParams : Array1OfReal from TColStd;
TheIndex : Array1OfInteger from TColStd;
ClosedPolygon : Boolean from Standard;
TheParams : Array1OfReal from TColStd;
TheIndex : Array1OfInteger from TColStd;
ClosedPolygon : Boolean from Standard;
--- To compute an approximate parameter on the Curve
--
Binf : Real from Standard;
Bsup : Real from Standard;
end Polygon2dGen;

View File

@ -1,11 +1,9 @@
// File: IntCurve_Polygon2dGen.gxx
// Created: Mon Oct 12 17:17:30 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
#define TEST 0
#include <Standard_ConstructionError.hxx>
#include <Bnd_Box2d.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
@ -14,8 +12,6 @@
#include <gp_Dir2d.hxx>
#define MAJORATION_DEFLECTION 1.5
//======================================================================
//== On echantillonne sur le Domain de la Curve NbPts Points
@ -57,7 +53,7 @@ IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
do {
gp_Pnt2d P=TheCurveTool::Value(C,u);
TheBnd.Add(P);
myBox.Add(P);
TheIndex.SetValue(i,i);
ThePnts.SetValue(i,P);
TheParams.SetValue(i,u);
@ -100,7 +96,7 @@ IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
}
while(i<NbPts);
TheBnd.Enlarge(TheDeflection*MAJORATION_DEFLECTION);
myBox.Enlarge(TheDeflection*MAJORATION_DEFLECTION);
ClosedPolygon = Standard_False;
}
//======================================================================
@ -130,7 +126,7 @@ IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
Standard_Integer i=1;
do {
gp_Pnt2d P=TheCurveTool::Value(C,u);
TheBnd.Add(P);
myBox.Add(P);
ThePnts.SetValue(i,P);
TheParams.SetValue(i,u);
TheIndex.SetValue(i,i);
@ -171,7 +167,7 @@ IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
}
while(i<NbPts);
TheBnd.Enlarge(TheDeflection*MAJORATION_DEFLECTION);
myBox.Enlarge(TheDeflection*MAJORATION_DEFLECTION);
ClosedPolygon = Standard_False;
//-------------------------------------------------------
//-- On supprime les points alignes
@ -209,9 +205,9 @@ IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
//======================================================================
void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C,
const Bnd_Box2d& BoxOtherPolygon) {
if(TheBnd.IsOut(BoxOtherPolygon)) {
if(myBox.IsOut(BoxOtherPolygon)) {
NbPntIn=2;
TheBnd.SetVoid();
myBox.SetVoid();
}
else {
Standard_Real bx0,bx1,by0,by1;
@ -264,12 +260,12 @@ void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C,
}
if(nbp==1) {
NbPntIn=2;
TheBnd.SetVoid();
myBox.SetVoid();
}
else {
TheBnd.SetVoid();
myBox.SetVoid();
if(nbp) {
TheBnd.Add(ThePnts.Value(TheIndex.Value(1)));
myBox.Add(ThePnts.Value(TheIndex.Value(1)));
}
Standard_Real RatioDeflection;
Standard_Integer nbpassagedeflection = 0;
@ -285,7 +281,7 @@ void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C,
Standard_Integer Iim1= TheIndex.Value(i-1);
const gp_Pnt2d& Pi = ThePnts.Value(Ii);
const gp_Pnt2d& Pim1 = ThePnts.Value(Iim1);
TheBnd.Add(Pi);
myBox.Add(Pi);
Standard_Integer Regi = CalculRegion(Pi.X(),Pi.Y(),bx0,bx1,by0,by1);
Standard_Integer Regim1 = CalculRegion(Pim1.X(),Pim1.Y(),bx0,bx1,by0,by1);
if((Regi & Regim1) == 0) {
@ -346,7 +342,7 @@ void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C,
}
TheDeflection*=MAJORATION_DEFLECTION;
TheBnd.Enlarge(TheDeflection);
myBox.Enlarge(TheDeflection);
}
ClosedPolygon = Standard_False;
Dump();
@ -403,8 +399,8 @@ extern void DrawSegment(const gp_Pnt2d& _P1,const gp_Pnt2d& _P2);
void IntCurve_Polygon2dGen::Dump(void) const {
if(!DebugPolygon2d) return;
Standard_Real bx0,bx1,by0,by1;
if(TheBnd.IsVoid()) return;
TheBnd.Get(bx0,by0,bx1,by1);
if(myBox.IsVoid()) return;
myBox.Get(bx0,by0,bx1,by1);
DrawSegment(gp_Pnt2d(bx0,by0),gp_Pnt2d(bx1,by0));
DrawSegment(gp_Pnt2d(bx1,by0),gp_Pnt2d(bx1,by1));
DrawSegment(gp_Pnt2d(bx1,by1),gp_Pnt2d(bx0,by1));
@ -422,11 +418,11 @@ void IntCurve_Polygon2dGen::Dump(void) const {
Standard_Real bx0,bx1,by0,by1;
cout<<"\n ----- Dump de IntCurve_Polygon2dGen -----"<<endl;
if(TheBnd.IsVoid()) {
if(myBox.IsVoid()) {
cout<<" Polygone Vide "<<endl;
return;
}
TheBnd.Get(bx0,by0,bx1,by1);
myBox.Get(bx0,by0,bx1,by1);
cout<<" bx0:"<<bx0 <<endl;
cout<<" by0:"<<by0<<endl;
cout<<" bx1:"<<bx1<<endl;
@ -441,5 +437,16 @@ void IntCurve_Polygon2dGen::Dump(void) const {
}
#endif
//======================================================================
void IntCurve_Polygon2dGen::Segment(const Standard_Integer theIndex,
gp_Pnt2d &theBegin, gp_Pnt2d &theEnd) const
{
Standard_Integer ind = theIndex;
theBegin = ThePnts(TheIndex(theIndex));
if (theIndex >= NbPntIn) {
if (!ClosedPolygon)
Standard_OutOfRange::Raise("IntCurve_Polygon2dGen::Segment!");
ind = 0;
}
theEnd = ThePnts(TheIndex(ind+1));
}
//======================================================================

View File

@ -1,14 +1,9 @@
// File: IntCurve_Polygon2dGen.lxx
// Created: Thu 3 Jun 1993
// Author: Laurent BUCHARD
// <lbr@nonox>
#include <Standard_OutOfRange.hxx>
//======================================================================
inline const Bnd_Box2d& IntCurve_Polygon2dGen::Bounding(void) const {
return(TheBnd);
}
//======================================================================
inline Standard_Real IntCurve_Polygon2dGen::DeflectionOverEstimation() const {
return(TheDeflection);
@ -16,35 +11,17 @@ inline Standard_Real IntCurve_Polygon2dGen::DeflectionOverEstimation() const {
inline void IntCurve_Polygon2dGen::SetDeflectionOverEstimation
(const Standard_Real x) {
TheDeflection = x;
TheBnd.Enlarge(TheDeflection);
myBox.Enlarge(TheDeflection);
}
//======================================================================
inline void IntCurve_Polygon2dGen::Closed(const Standard_Boolean flag) {
ClosedPolygon = flag;
}
//======================================================================
inline Standard_Boolean IntCurve_Polygon2dGen::Closed(void) const {
return(Standard_False); //-- Voir si le cas Closed est traitable
}
//======================================================================
inline Standard_Integer IntCurve_Polygon2dGen::NbSegments(void) const {
return((ClosedPolygon)? NbPntIn : NbPntIn-1);
}
//======================================================================
inline const gp_Pnt2d& IntCurve_Polygon2dGen::EndOfSeg(const Standard_Integer Index) const {
Standard_Integer ind = Index;
if (Index >= NbPntIn) {
if (!ClosedPolygon)
Standard_OutOfRange::Raise("OutOfRange Polygon2d::EndOfSeg !");
ind = 0;
}
return ThePnts(TheIndex(ind+1));
}
//======================================================================
inline const gp_Pnt2d& IntCurve_Polygon2dGen::BeginOfSeg(const Standard_Integer Index) const {
return ThePnts(TheIndex(Index));
}
//======================================================================
inline Standard_Real IntCurve_Polygon2dGen::InfParameter() const {
return(TheParams.Value(TheIndex(1)));
}

View File

@ -1,58 +0,0 @@
-- File: ToolPolygon.cdl
-- Created: Fri Aug 2 08:18:37 1991
-- Author: Didier PIFFAULT
-- <dpf@sdsun2>
---Copyright: Matra Datavision 1991
generic class ToolPolygon from IntCurve (Point as any;
Polygon as any;
BoundingBox as any)
---Purpose: Describe a polyline as a topology to compute the
-- interference beetween two polylines.
---Level: Internal
raises OutOfRange from Standard
is Bounding (myclass; thePolygon : Polygon)
returns BoundingBox;
---Purpose: Give the bounding box of the polygon.
---C++: inline
---C++: return const &
DeflectionOverEstimation
(myclass; thePolygon : Polygon)
---C++: inline
returns Real from Standard;
Closed (myclass; thePolygon : Polygon)
---C++: inline
returns Boolean from Standard;
NbSegments (myclass; thePolygon : Polygon)
---C++: inline
returns Integer;
---Purpose: Give the number of Segments in the polyline.
BeginOfSeg (myclass; thePolygon : Polygon;
Index : in Integer)
---C++: inline
returns Point
raises OutOfRange from Standard;
---C++: return const &
---Purpose: Give the point of range Index in the Polygon.
EndOfSeg (myclass; thePolygon : Polygon;
Index : in Integer)
---C++: inline
returns Point
raises OutOfRange from Standard;
---C++: return const &
---Purpose: Give the point of range Index in the Polygon.
end ToolPolygon;

View File

@ -1,5 +0,0 @@
// File: IntCurve_ToolPolygon.gxx
// Created: Tue Jun 4 16:14:49 1996
// Author: Laurent BUCHARD
// <lbr@sherlox.paris1.matra-dtv.fr>

View File

@ -1,49 +0,0 @@
// File: IntCurve_ToolPolygon.gxx
// Created: Thu Jun 3 14:52:18 1993
// Author: Laurent BUCHARD
// <lbr@nonox>
#include Polygon_hxx
//=================================================================
inline const BoundingBox& IntCurve_ToolPolygon::Bounding
(const Polygon& thePolygon)
{
return thePolygon.Bounding();
}
//=================================================================
inline Standard_Real IntCurve_ToolPolygon::DeflectionOverEstimation
(const Polygon& thePolygon)
{
return thePolygon.DeflectionOverEstimation();
}
//=================================================================
inline Standard_Boolean IntCurve_ToolPolygon::Closed
(const Polygon& thePolygon)
{
return thePolygon.Closed();
}
//=================================================================
inline Standard_Integer IntCurve_ToolPolygon::NbSegments
(const Polygon& thePolygon)
{
return thePolygon.NbSegments();
}
//=================================================================
inline const Point& IntCurve_ToolPolygon::BeginOfSeg
(const Polygon& thePolygon,
const Standard_Integer Index)
{
return thePolygon.BeginOfSeg(Index);
}
//=================================================================
inline const Point& IntCurve_ToolPolygon::EndOfSeg
(const Polygon& thePolygon,
const Standard_Integer Index)
{
return thePolygon.EndOfSeg(Index);
}
//=================================================================

View File

@ -52,8 +52,6 @@ is
class PolyArc; -- inherits Polygo from IntPatch
class PolygoTool;
class RstInt;
@ -143,8 +141,7 @@ is
HSurface from Adaptor3d,
HSurfaceTool from Adaptor3d);
class SearchPnt instantiates InterferencePolygon2d from Intf
(Polygo, PolygoTool, Polygo, PolygoTool);
alias SearchPnt is InterferencePolygon2d from Intf;
class CSFunction instantiates ZerCOnSSParFunc from IntImp
(HSurface from Adaptor3d,

View File

@ -31,14 +31,7 @@ is
--- This exception is raised if Pfirst=RealFirst or Plast=RealLast or
-- NbSample<=1.
Bounding(me)
---C++: return const&
returns Box2d from Bnd;
Error(me) returns Real from Standard;
Closed(me) returns Boolean from Standard;
Closed(me) returns Boolean from Standard is redefined virtual;
NbPoints(me) returns Integer;
@ -53,8 +46,6 @@ fields
brise : Array1OfPnt2d from TColgp;
param : Array1OfReal from TColStd;
boite : Box2d from Bnd;
fleche : Real from Standard;
offsetx: Real from Standard;
offsety: Real from Standard;
ferme : Boolean from Standard;

View File

@ -72,10 +72,10 @@ IntPatch_PolyArc::IntPatch_PolyArc(const Handle(Adaptor2d_HCurve2d)& Line ,
Xs = p2d.X(); Ys = p2d.Y();
brise(1).SetCoord(Xs,Ys);
boite.SetVoid();
myBox.SetVoid();
boite.Add(brise(1));
fleche =0.;
myBox.Add(brise(1));
myError =0.;
for (Standard_Integer i =2; i<=NbSample;i++) {
param(i) = Pdeb + (i-1)*Pas;
@ -111,12 +111,12 @@ IntPatch_PolyArc::IntPatch_PolyArc(const Handle(Adaptor2d_HCurve2d)& Line ,
if(IndexSup<i) IndexSup=Min(i+1,NbSample);
}
boite.Add(brise(i));
myBox.Add(brise(i));
Line->D0(param(i)-Pas*0.5,p2d);
Xm = p2d.X() - XXs;
Ym = p2d.Y() - YYs;
Xm = Sqrt(Xm*Xm+Ym*Ym);
fleche =Max (fleche , Xm);
myError =Max (myError , Xm);
Xs = X;
Ys = Y;
}
@ -145,25 +145,14 @@ IntPatch_PolyArc::IntPatch_PolyArc(const Handle(Adaptor2d_HCurve2d)& Line ,
}
}
while((IndexInf > IndexSup) && nbloop<=10);
fleche*=1.2;
if(fleche<0.00000001)
fleche = 0.00000001;
boite.Enlarge(fleche);
myError*=1.2;
if(myError<0.00000001)
myError = 0.00000001;
myBox.Enlarge(myError);
if(Line->Value(aPdeb).Distance(Line->Value(aPfin))<=1e-7) {
ferme=Standard_True;
}
else {
ferme=Standard_False;
}
ferme = (Line->Value(aPdeb).Distance(Line->Value(aPfin)) <= 1e-7);
}
const Bnd_Box2d& IntPatch_PolyArc::Bounding() const {
return(boite);
}
Standard_Real IntPatch_PolyArc::Error() const {return fleche;}
Standard_Boolean IntPatch_PolyArc::Closed() const { return ferme;}
Standard_Integer IntPatch_PolyArc::NbPoints() const {return brise.Length();}
@ -183,16 +172,16 @@ Standard_Real IntPatch_PolyArc::Parameter(const Standard_Integer Index ) const
void IntPatch_PolyArc::SetOffset(const Standard_Real ox,const Standard_Real oy) {
Standard_Real xmin,ymin,xmax,ymax,g;
boite.Get(xmin,ymin,xmax,ymax);
g = boite.GetGap();
myBox.Get(xmin,ymin,xmax,ymax);
g = myBox.GetGap();
boite.SetVoid();
myBox.SetVoid();
boite.Update(xmin-offsetx,ymin-offsety,
myBox.Update(xmin-offsetx,ymin-offsety,
xmax-offsetx,ymax-offsety);
offsetx = ox;
offsety = oy;
boite.Update(xmin+offsetx,ymin+offsety,
myBox.Update(xmin+offsetx,ymin+offsety,
xmax+offsetx,ymax+offsety);
boite.SetGap(g);
myBox.SetGap(g);
}

View File

@ -32,14 +32,6 @@ is
ResetError(me: in out);
Bounding (me)
---C++: return const &
returns Box2d from Bnd;
Error(me) returns Real from Standard;
Closed(me) returns Boolean from Standard;
NbPoints(me) returns Integer;
Point(me; Index : Integer)
@ -48,12 +40,10 @@ is
fields
box : Box2d from Bnd;
pnt : Pnt2d from gp;
typ : IType from IntPatch;
onfirst : Boolean from Standard;
wpoly : WLine from IntPatch;
rpoly : RLine from IntPatch;
defle : Real from Standard;
end PolyLine;

View File

@ -18,7 +18,7 @@
//=======================================================================
IntPatch_PolyLine::IntPatch_PolyLine ()
: defle(INITDEFLE)
: IntPatch_Polygo(INITDEFLE)
{}
//=======================================================================
@ -27,7 +27,7 @@ IntPatch_PolyLine::IntPatch_PolyLine ()
//=======================================================================
IntPatch_PolyLine::IntPatch_PolyLine (const Standard_Real InitDefle)
: defle(InitDefle)
: IntPatch_Polygo(InitDefle)
{}
//=======================================================================
@ -64,9 +64,9 @@ void IntPatch_PolyLine::SetRLine(const Standard_Boolean OnFirst, const Handle(In
void IntPatch_PolyLine::Prepare()
{
Standard_Integer i;
box.SetVoid();
myBox.SetVoid();
Standard_Integer n=NbPoints();
Standard_Real eps = defle;
Standard_Real eps = myError;
gp_Pnt2d P1, P2;
if (n >= 3) {
@ -82,7 +82,7 @@ void IntPatch_PolyLine::Prepare()
d = V13.CrossMagnitude(V12) / d13;
else
d = eps;
if (d > defle) {
if (d > myError) {
// try to compute deflection more precisely using parabola interpolation
gp_XY V23 = P3.XY() - P2.XY();
Standard_Real d12 = V12.Modulus(), d23 = V23.Modulus();
@ -119,13 +119,13 @@ void IntPatch_PolyLine::Prepare()
// select min deflection from linear and parabolic ones
if (d1 < d) d = d1;
}
if (d > defle) defle=d;
if (d > myError) myError=d;
}
P1 = P2; P2 = P3;
}
box.Add(P3);
myBox.Add(P3);
}
box.Enlarge(defle);
myBox.Enlarge(myError);
}
//=======================================================================
@ -135,38 +135,7 @@ void IntPatch_PolyLine::Prepare()
void IntPatch_PolyLine::ResetError()
{
defle = INITDEFLE;
}
//=======================================================================
//function : Bounding
//purpose :
//=======================================================================
const Bnd_Box2d& IntPatch_PolyLine::Bounding() const
{
return box;
}
//=======================================================================
//function : Error
//purpose :
//=======================================================================
Standard_Real IntPatch_PolyLine::Error() const
{
// return 0.0000001;
return defle;
}
//=======================================================================
//function : Closed
//purpose :
//=======================================================================
Standard_Boolean IntPatch_PolyLine::Closed() const
{
return Standard_False;
myError = INITDEFLE;
}
//=======================================================================

View File

@ -1,38 +1,52 @@
-- File: IntPatch_Polygo.cdl
-- Created: Thu May 6 17:49:16 1993
-- Author: Jacques GOUSSARD
-- <jag@form4>
---Copyright: Matra Datavision 1993
-- File: IntPatch_Polygo.cdl
-- Created: Thu May 6 17:49:16 1993
-- Author: Jacques GOUSSARD
---Copyright: Matra Datavision 1993
deferred class Polygo from IntPatch
---Purpose:
inherits Polygon2d from Intf
uses Pnt2d from gp,
Box2d from Bnd
raises OutOfRange from Standard
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~IntPatch_Polygo(){Delete() ; }"
Bounding (me)
---C++: return const &
returns Box2d from Bnd
is deferred;
Error(me) returns Real from Standard
is deferred;
Closed(me) returns Boolean from Standard
is deferred;
Initialize (theError : Real from Standard = 0.0)
returns Polygo from IntPatch;
Error (me) returns Real from Standard;
---C++: inline
NbPoints (me) returns Integer is deferred;
Point (me; Index : Integer) returns Pnt2d from gp is deferred;
DeflectionOverEstimation (me)
returns Real from Standard is redefined virtual;
---C++: inline
---Purpose: Returns the tolerance of the polygon.
NbSegments (me)
returns Integer from Standard is redefined virtual;
---C++: inline
---Purpose: Returns the number of Segments in the polyline.
Segment (me; theIndex : in Integer from Standard;
theBegin, theEnd : in out Pnt2d from gp)
raises OutOfRange from Standard is redefined virtual;
---C++: inline
---Purpose: Returns the points of the segment <Index> in the Polygon.
Dump (me);
fields
myError : Real from Standard is protected;
NbPoints(me) returns Integer
is deferred;
Point(me; Index : Integer)
returns Pnt2d from gp
is deferred;
end Polygo;

View File

@ -1,4 +1,40 @@
// File: IntPatch_Polygo.cxx
// Created: Thu May 6 17:49:16 1993
// Author: Jacques GOUSSARD
// Copyright: Matra Datavision 1993
#include <IntPatch_Polygo.ixx>
void IntPatch_Polygo::Delete()
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
IntPatch_Polygo::IntPatch_Polygo (const Standard_Real theError)
: myError(theError)
{}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void IntPatch_Polygo::Dump () const
{
static int num=0;
num++;
cout<<"\n#------------- D u m p B o x 2 d ("<<num<<")"<<endl;
Bounding().Dump();
cout<<"\n#-----------------------------------------------"<<endl;
const Standard_Integer nbs = NbSegments();
cout<<"\npol2d "<<num<<" "<<nbs<<" ";
cout<<DeflectionOverEstimation()<<endl;
gp_Pnt2d P, PF;
for(Standard_Integer i=1;i<=nbs;i++) {
Segment(i,P,PF);
cout<<"pnt2d "<<num<<" "<< P.X()<<" "<<P.Y()<<endl;
}
cout<<"pnt2d "<<num<<" "<< PF.X()<<" "<<PF.Y()<<endl;
}

View File

@ -0,0 +1,47 @@
// File: IntPatch_Polygo.lxx
// Created: Fri Feb 10 08:18:37 2012
// Author: Sergey ZERCHANINOV
// Copyright: OPEN CASCADE SAS 2012
//=======================================================================
//function : Error
//purpose :
//=======================================================================
inline Standard_Real IntPatch_Polygo::Error () const
{
return myError;
}
//=======================================================================
//function : DeflectionOverEstimation
//purpose :
//=======================================================================
inline Standard_Real IntPatch_Polygo::DeflectionOverEstimation () const
{
return myError;
}
//=======================================================================
//function : NbSegments
//purpose :
//=======================================================================
inline Standard_Integer IntPatch_Polygo::NbSegments () const
{
return NbPoints()-1;
}
//=======================================================================
//function : BeginOfSeg
//purpose :
//=======================================================================
inline void IntPatch_Polygo::Segment (const Standard_Integer theIndex,
gp_Pnt2d &theBegin, gp_Pnt2d &theEnd) const
{
theBegin = Point(theIndex);
theEnd = Point(theIndex+1);
}

View File

@ -1,65 +0,0 @@
-- File: IntPatch_PolygoTool.cdl
-- Created: Thu May 6 17:50:02 1993
-- Author: Jacques GOUSSARD
-- <jag@form4>
---Copyright: Matra Datavision 1993
class PolygoTool from IntPatch
---Purpose: Tool an a polygon to instantiates the Interference
-- between 2 polygons.
uses Box2d from Bnd,
Pnt2d from gp,
Polygo from IntPatch
is
Bounding (myclass; Line : Polygo from IntPatch )
returns Box2d from Bnd;
---C++: return const &
---C++: inline
DeflectionOverEstimation(myclass; Line :Polygo from IntPatch)
returns Real from Standard;
---C++: inline
Closed(myclass; Line : Polygo from IntPatch )
returns Boolean from Standard;
---C++: inline
NbSegments(myclass; Line : Polygo from IntPatch )
returns Integer from Standard;
---C++: inline
BeginOfSeg(myclass; Line : Polygo from IntPatch;
Index : Integer from Standard)
returns Pnt2d from gp;
---C++: inline
EndOfSeg(myclass; Line : Polygo from IntPatch ;
Index : Integer from Standard)
returns Pnt2d from gp;
---C++: inline
Dump(myclass; Line : Polygo from IntPatch);
end PolygoTool;

View File

@ -1,24 +0,0 @@
#include <IntPatch_PolygoTool.ixx>
void IntPatch_PolygoTool::Dump(const IntPatch_Polygo& L) {
static int num=0;
num++;
cout<<"\n#------------- D u m p B o x 2 d ("<<num<<")"<<endl;
IntPatch_PolygoTool::Bounding(L).Dump();
cout<<"\n#-----------------------------------------------"<<endl;
Standard_Integer nbs = IntPatch_PolygoTool::NbSegments(L);
cout<<"\npol2d "<<num<<" "<<nbs<<" ";
cout<<IntPatch_PolygoTool::DeflectionOverEstimation(L)<<endl;
for(Standard_Integer i=1;i<=nbs;i++) {
gp_Pnt2d P(IntPatch_PolygoTool::BeginOfSeg(L,i));
cout<<"pnt2d "<<num<<" "<< P.X()<<" "<<P.Y()<<endl;
}
gp_Pnt2d PF(IntPatch_PolygoTool::EndOfSeg(L,nbs));
cout<<"pnt2d "<<num<<" "<< PF.X()<<" "<<PF.Y()<<endl;
}

View File

@ -1,34 +0,0 @@
#ifndef IntPatch_Polygo_HeaderFile
#include <IntPatch_Polygo.hxx>
#endif
#ifndef Bnd_Box2d_HeaderFile
#include <Bnd_Box2d.hxx>
#endif
#ifndef gp_Pnt2d_HeaderFile
#include <gp_Pnt2d.hxx>
#endif
inline const Bnd_Box2d& IntPatch_PolygoTool::Bounding(const IntPatch_Polygo& Line)
{ return Line.Bounding(); }
inline Standard_Real IntPatch_PolygoTool::DeflectionOverEstimation
(const IntPatch_Polygo& Line)
{ return Line.Error();} // fleche non calculable
inline Standard_Boolean IntPatch_PolygoTool::Closed(const IntPatch_Polygo& Line)
{ return Line.Closed();}
inline Standard_Integer IntPatch_PolygoTool::NbSegments(const IntPatch_Polygo& Line)
{ return Line.NbPoints()-1;}
inline gp_Pnt2d IntPatch_PolygoTool::BeginOfSeg(const IntPatch_Polygo& Line,
const Standard_Integer Index)
{ return Line.Point(Index);}
inline gp_Pnt2d IntPatch_PolygoTool::EndOfSeg(const IntPatch_Polygo& Line,
const Standard_Integer Index)
{ return Line.Point(Index+1);}

View File

@ -9,7 +9,6 @@ class RstInt from IntPatch
-- cheminement et les arcs de restriction
uses Polygo from IntPatch,
PolygoTool from IntPatch,
Line from IntPatch,
HSurface from Adaptor3d,
TopolTool from Adaptor3d

View File

@ -26,7 +26,6 @@
#include <Precision.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <IntPatch_PolygoTool.hxx>
#include <IntPatch_WLine.hxx>
#include <IntPatch_RLine.hxx>
#include <IntPatch_HInterTool.hxx>
@ -572,7 +571,7 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L,
}
}
Bnd_Box2d BPLin = IntPatch_PolygoTool::Bounding(PLin);
Bnd_Box2d BPLin = PLin.Bounding();
if(SurfaceIsPeriodic) {
Standard_Real xmin,ymin,xmax,ymax,g;
@ -642,8 +641,8 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L,
static int debug_polygon2d =0;
if(debug_polygon2d) {
cout<<" ***** Numero Restriction : "<<NumeroEdge<<" *****"<<endl;
IntPatch_PolygoTool::Dump(PLin);
IntPatch_PolygoTool::Dump(Brise);
PLin.Dump();
Brise.Dump();
}
Commun.Perform(PLin,Brise);

View File

@ -1,8 +1,7 @@
-- File: Intf.cdl
-- Created: Thu May 23 11:21:00 1991
-- Author: Didier PIFFAULT
-- <dpf@topsn3>
---Copyright: Matra Datavision 1991, 1992
-- File: Intf.cdl
-- Created: Thu May 23 11:21:00 1991
-- Author: Didier PIFFAULT
---Copyright: Matra Datavision 1991, 1992
package Intf
@ -27,9 +26,9 @@ is
-- Classes input data :
generic class ToolPolygon; -- Signature
---Purpose: Describes the necessary polygon information to compute the
-- interferences.
deferred class Polygon2d;
---Purpose: Describes the necessary polygon information to compute
-- the interferences.
generic class ToolPolyhedron; -- Signature
---Purpose: Describes the necessary polyhedron information to compute
@ -83,7 +82,7 @@ is
generic class InterferencePolygon2d;
class InterferencePolygon2d;
---Purpose: Computes the interference between two polygons in 2d.
-- Result : points of intersections and zones of tangence.

View File

@ -1,7 +1,6 @@
-- File: Interference.cdl
-- Created: Mon Jun 24 10:15:49 1991
-- Author: Didier PIFFAULT
-- <dpf@phobox>
---Copyright: Matra Datavision 1991, 1992
@ -31,6 +30,7 @@ is Initialize(Self : Boolean from Standard);
returns Integer is static;
---Purpose: Gives the number of points of intersection in the
-- interference.
---C++: inline
PntValue (me;
Index : in Integer)
@ -41,12 +41,13 @@ is Initialize(Self : Boolean from Standard);
-- the interference.
--
---C++: return const &
---C++: inline
NbSectionLines (me)
returns Integer is static;
---Purpose: Gives the number of polylines of intersection in the
-- interference.
---C++: inline
LineValue (me;
Index : in Integer)
@ -57,12 +58,12 @@ is Initialize(Self : Boolean from Standard);
-- the interference.
--
---C++: return const &
---C++: inline
NbTangentZones (me)
returns Integer is static;
---Purpose: Gives the number of zones of tangence in the interference.
---C++: inline
ZoneValue (me;
Index : in Integer)
@ -73,13 +74,13 @@ is Initialize(Self : Boolean from Standard);
-- interference.
--
---C++: return const &
---C++: inline
GetTolerance (me)
returns Real
is static;
---Purpose: Gives the tolerance used for the calculation.
---C++: inline
-- Implementation functions :
@ -115,6 +116,6 @@ fields mySPoins : SeqOfSectionPoint from Intf is protected;
mySLines : SeqOfSectionLine from Intf is protected;
myTZones : SeqOfTangentZone from Intf is protected;
SelfIntf : Boolean from Standard is protected;
Tolerance : Real from Standard is protected;
Tolerance : Real from Standard is protected;
end Interference;

View File

@ -1,7 +1,6 @@
// File: Intf_Interference.cxx
// Created: Mon Jun 24 11:52:34 1991
// Author: Didier PIFFAULT
// <dpf@phobox>
#include <Intf_Interference.ixx>
#include <gp_Pnt2d.hxx>
@ -31,69 +30,6 @@ void Intf_Interference::SelfInterference (const Standard_Boolean Self)
}
//---------------------------------------------------------
// Return the number of sections points in an interference.
//---------------------------------------------------------
Standard_Integer Intf_Interference::NbSectionPoints () const
{
return mySPoins.Length();
}
//-----------------------------------------------------------
// Give the section point of range Index in the interference.
//-----------------------------------------------------------
const Intf_SectionPoint& Intf_Interference::PntValue
(const Standard_Integer Index) const
{
return mySPoins(Index);
}
//--------------------------------------------------------
// Return the number of sections lines in an interference.
//--------------------------------------------------------
Standard_Integer Intf_Interference::NbSectionLines () const
{
return mySLines.Length();
}
//----------------------------------------------------------
// Give the section line of range Index in the interference.
//----------------------------------------------------------
const Intf_SectionLine& Intf_Interference::LineValue
(const Standard_Integer Index) const
{
return mySLines(Index);
}
//---------------------------------------------------------------
// Return the number of sections TangentZones in an interference.
//---------------------------------------------------------------
Standard_Integer Intf_Interference::NbTangentZones () const
{
return myTZones.Length();
}
//---------------------------------------------------------
// Give the tangentzone of range Index in the interference.
//---------------------------------------------------------
const Intf_TangentZone& Intf_Interference::ZoneValue
(const Standard_Integer Index) const
{
return myTZones(Index);
}
//=======================================================================
//function : GetTolerance
//purpose :
//=======================================================================
Standard_Real Intf_Interference::GetTolerance () const
{
return Tolerance;
}
//=======================================================================
//function : Insert
//purpose : Insert a tangent zone in the list of the interference

View File

@ -0,0 +1,67 @@
// File: Intf_Interference.lxx
// Created: Mon Jun 24 11:52:34 1991
// Author: Didier PIFFAULT
//=======================================================================
// Return the number of sections points in an interference.
//=======================================================================
inline Standard_Integer Intf_Interference::NbSectionPoints () const
{
return mySPoins.Length();
}
//=======================================================================
// Give the section point of range Index in the interference.
//=======================================================================
inline const Intf_SectionPoint& Intf_Interference::PntValue (const Standard_Integer Index) const
{
return mySPoins(Index);
}
//=======================================================================
// Return the number of sections lines in an interference.
//=======================================================================
inline Standard_Integer Intf_Interference::NbSectionLines () const
{
return mySLines.Length();
}
//=======================================================================
// Give the section line of range Index in the interference.
//=======================================================================
inline const Intf_SectionLine& Intf_Interference::LineValue (const Standard_Integer Index) const
{
return mySLines(Index);
}
//=======================================================================
// Return the number of sections TangentZones in an interference.
//=======================================================================
inline Standard_Integer Intf_Interference::NbTangentZones () const
{
return myTZones.Length();
}
//=======================================================================
// Give the tangentzone of range Index in the interference.
//=======================================================================
inline const Intf_TangentZone& Intf_Interference::ZoneValue (const Standard_Integer Index) const
{
return myTZones(Index);
}
//=======================================================================
//function : GetTolerance
//purpose :
//=======================================================================
inline Standard_Real Intf_Interference::GetTolerance () const
{
return Tolerance;
}

View File

@ -1,29 +1,23 @@
-- File: InterferencePolygon2d.cdl
-- Created: Mon Sep 28 17:09:45 1992
-- Author: Didier PIFFAULT
-- <dpf@phylox>
---Copyright: Matra Datavision 1992
-- File: Intf_InterferencePolygon2d.cdl
-- Created: Mon Sep 28 17:09:45 1992
-- Author: Didier PIFFAULT
---Copyright: Matra Datavision 1992
generic class InterferencePolygon2d from Intf
(Polygon2d1 as any;
ToolPolygon2d1 as any; -- as ToolPolygon(Pnt2d, Polygon2d1, Box2d)
Polygon2d2 as any;
ToolPolygon2d2 as any) -- as ToolPolygon(Pnt2d, Polygon2d2, Box2d)
inherits Interference from Intf
class InterferencePolygon2d from Intf
inherits Interference from Intf
---Purpose: Computes the interference between two polygons or
-- the self intersection of a polygon in two
-- dimensions.
uses Pnt2d from gp,
SectionPoint from Intf,
SeqOfSectionPoint from Intf,
TangentZone from Intf,
SeqOfTangentZone from Intf
SeqOfTangentZone from Intf,
Polygon2d from Intf
raises OutOfRange from Standard
@ -35,23 +29,23 @@ is
---Purpose: Constructs an empty interference of Polygon.
Create (Obje1: in Polygon2d1 ;Obje2 : in Polygon2d2)
Create (Obje1, Obje2 : in Polygon2d)
returns InterferencePolygon2d from Intf;
---Purpose: Constructs and computes an interference between two Polygons.
Create (Obje : in Polygon2d1)
Create (Obje : in Polygon2d)
returns InterferencePolygon2d from Intf;
---Purpose: Constructs and computes the auto interference of a Polygon.
Perform (me : in out;
Obje1: Polygon2d1 ;Obje2 : in Polygon2d2);
Obje1, Obje2 : in Polygon2d);
---Purpose: Computes an interference between two Polygons.
Perform (me : in out;
Obje : in Polygon2d1);
Obje : in Polygon2d);
---Purpose: Computes the self interference of a Polygon.
@ -66,30 +60,25 @@ is
-- Implementation :
Interference (me : in out;
Obje1 : in Polygon2d1;
Obje2 : in Polygon2d2)
Interference (me : in out; Obje1, Obje2 : in Polygon2d)
is private;
Interference (me : in out;
Obje : in Polygon2d1)
Interference (me : in out; Obje : in Polygon2d)
is private;
Clean (me : in out) is private;
Intersect (me : in out;
BegO : in Pnt2d from gp;
EndO : in Pnt2d from gp;
BegT : in Pnt2d from gp;
EndT : in Pnt2d from gp)
iO, iT : Integer from Standard;
BegO, EndO : in Pnt2d from gp;
BegT, EndT : in Pnt2d from gp)
is private;
---Purpose: Computes the intersection between two segments
-- <BegO><EndO> et <BegT><EndT>.
fields
oClos, tClos : Boolean from Standard;
iObje1, iObje2, nbso : Integer from Standard;
BeginOfNotClosedObje1: Boolean from Standard;
BeginOfNotClosedObje2: Boolean from Standard;
nbso : Integer from Standard;
end InterferencePolygon2d;

View File

@ -0,0 +1,675 @@
// File: Intf_InterferencePolygon2d.cxx
// Created: Mon Jun 24 11:52:34 1991
// Author: Didier PIFFAULT
#include <Intf_InterferencePolygon2d.ixx>
#include <gp_Pnt2d.hxx>
#include <Bnd_Box2d.hxx>
#include <Intf_SectionPoint.hxx>
#include <Intf_SeqOfSectionPoint.hxx>
#include <Intf_TangentZone.hxx>
#include <Intf_SeqOfTangentZone.hxx>
#include <Precision.hxx>
#include <TColStd_ListOfInteger.hxx>
// Angular precision (sinus) below that value two right segments
// are considered as having a potential zone of tangency.
namespace
{
static const Standard_Real PRCANG = Precision::Angular();
};
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : constructor empty
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d()
: Intf_Interference (Standard_False),
oClos (Standard_False),
tClos (Standard_False),
nbso (0)
{}
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : Constructor of the interference beetween two Polygon.
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
(const Intf_Polygon2d& Obje1, const Intf_Polygon2d& Obje2)
: Intf_Interference (Standard_False),
oClos (Standard_False),
tClos (Standard_False),
nbso (0)
{
if (!Obje1.Bounding().IsOut(Obje2.Bounding())) {
Tolerance=Obje1.DeflectionOverEstimation()+
Obje2.DeflectionOverEstimation();
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
nbso=Obje1.NbSegments();
oClos=Obje1.Closed();
tClos=Obje2.Closed();
Interference(Obje1, Obje2);
Clean();
}
}
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : Constructor of the auto interference of a Polygon.
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
(const Intf_Polygon2d& Obje)
: Intf_Interference (Standard_True),
oClos (Standard_False),
tClos (Standard_False),
nbso (0)
{
Tolerance=Obje.DeflectionOverEstimation()*2;
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
oClos=Obje.Closed();
tClos=oClos;
Interference(Obje);
Clean();
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Perform
(const Intf_Polygon2d& Obje1, const Intf_Polygon2d& Obje2)
{
SelfInterference(Standard_False);
if (!Obje1.Bounding().IsOut(Obje2.Bounding())) {
Tolerance=Obje1.DeflectionOverEstimation()+
Obje2.DeflectionOverEstimation();
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
nbso=Obje1.NbSegments();
oClos=Obje1.Closed();
tClos=Obje2.Closed();
Interference(Obje1, Obje2);
Clean();
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Perform
(const Intf_Polygon2d& Obje)
{
SelfInterference(Standard_True);
Tolerance=Obje.DeflectionOverEstimation()*2;
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
oClos=Obje.Closed();
tClos=oClos;
Interference(Obje);
Clean();
}
//=======================================================================
//function : Pnt2dValue
//purpose : Give the section point of range Index in the interference.
//=======================================================================
gp_Pnt2d Intf_InterferencePolygon2d::Pnt2dValue
(const Standard_Integer Index) const
{
return gp_Pnt2d((mySPoins(Index)).Pnt().X(),
(mySPoins(Index)).Pnt().Y());
}
//=======================================================================
//function : Interference
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Interference
(const Intf_Polygon2d& Obje1,
const Intf_Polygon2d& Obje2)
{
Bnd_Box2d bSO;
Bnd_Box2d bST;
Standard_Integer iObje1, iObje2;
gp_Pnt2d p1b, p1e, p2b, p2e;
for (iObje1=1; iObje1<=Obje1.NbSegments(); iObje1++)
{
bSO.SetVoid();
Obje1.Segment(iObje1,p1b,p1e);
bSO.Add(p1b);
bSO.Add(p1e);
bSO.Enlarge(Obje1.DeflectionOverEstimation());
if (!Obje2.Bounding().IsOut(bSO)) {
for (iObje2=1; iObje2<=Obje2.NbSegments(); iObje2++) {
bST.SetVoid();
Obje2.Segment(iObje2,p2b,p2e);
bST.Add(p2b);
bST.Add(p2e);
bST.Enlarge(Obje2.DeflectionOverEstimation());
if (!bSO.IsOut(bST))
Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e);
}
}
}
}
//=======================================================================
//function : Interference
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Interference
(const Intf_Polygon2d& Obje)
{
Bnd_Box2d bSO;
Bnd_Box2d bST;
Standard_Integer iObje1, iObje2;
gp_Pnt2d p1b, p1e, p2b, p2e;
for (iObje1=1; iObje1<=Obje.NbSegments(); iObje1++) {
bSO.SetVoid();
Obje.Segment(iObje1,p1b,p1e);
bSO.Add(p1b);
bSO.Add(p1e);
bSO.Enlarge(Obje.DeflectionOverEstimation());
if (!Obje.Bounding().IsOut(bSO)) {
for (iObje2=iObje1+1;iObje2<=Obje.NbSegments();iObje2++){
bST.SetVoid();
Obje.Segment(iObje2,p2b,p2e);
bST.Add(p2b);
bST.Add(p2e);
bST.Enlarge(Obje.DeflectionOverEstimation());
if (!bSO.IsOut(bST))
Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e);
}
}
}
}
//=======================================================================
//function : Clean
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Clean()
{
// The zones of tangency that concerns only one couple of segments are
// conserved if the angle between the segments is less than <PRCANG> and
// if there is no real point of intersection EDGE/EDGE:
Standard_Integer nbIt=myTZones.Length();
Standard_Integer decal=0;
Standard_Integer addr1, addr2;
Intf_PIType dim1, dim2;
Standard_Real par;
Standard_Integer tsp, tsps;
Standard_Integer lpi, ltz;
Standard_Boolean Only1Seg=Standard_False;
#define PI1 (myTZones(ltz-decal).GetPoint(lpi))
#define PI2 (myTZones(ltz-decal).GetPoint(tsp))
for (ltz=1; ltz<=nbIt; ltz++) {
tsp=tsps=0;
Standard_Real pr1mi,pr1ma,pr2mi,pr2ma,delta1,delta2;
myTZones(ltz-decal).ParamOnFirst(pr1mi,pr1ma);
delta1=pr1ma-pr1mi;
myTZones(ltz-decal).ParamOnSecond(pr2mi,pr2ma);
delta2=pr2ma-pr2mi;
if (delta1<1. && delta2<1.) Only1Seg=Standard_True;
if (delta1==0. || delta2==0.) Only1Seg=Standard_True;
for (lpi=1; lpi<=myTZones(ltz-decal).NumberOfPoints(); lpi++) {
if (PI1.Incidence()<=PRCANG) {tsp=tsps=0;break;}
PI1.InfoFirst(dim1,addr1,par);
PI1.InfoSecond(dim2,addr2,par);
if (dim1==Intf_EDGE && dim2==Intf_EDGE) {
tsps=0;
if (tsp>0) {
tsp=0;
Only1Seg=Standard_False;
break;
}
tsp=lpi;
}
else if (dim1!=Intf_EXTERNAL && dim2!=Intf_EXTERNAL) {
tsps=lpi;
}
}
if (tsp>0) {
mySPoins.Append(myTZones(ltz-decal).GetPoint(tsp));
myTZones.Remove(ltz-decal);
decal++;
}
else if (Only1Seg && tsps!=0) {
mySPoins.Append(myTZones(ltz-decal).GetPoint(tsps));
myTZones.Remove(ltz-decal);
decal++;
}
}
// The points of intersection located in the tangency zone are
// removed from the list :
nbIt=mySPoins.Length();
decal=0;
for (lpi=1; lpi<=nbIt; lpi++) {
for (ltz=1; ltz<=myTZones.Length(); ltz++) {
if (myTZones(ltz).RangeContains(mySPoins(lpi-decal))) {
mySPoins.Remove(lpi-decal);
decal++;
break;
}
}
}
}
//=======================================================================
//function : Intersect
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Intersect
(const Standard_Integer iObje1, const Standard_Integer iObje2,
const gp_Pnt2d& BegO, const gp_Pnt2d& EndO,
const gp_Pnt2d& BegT, const gp_Pnt2d& EndT)
{
if(SelfIntf) {
if(Abs(iObje1-iObje2)<=1) return; //-- Ajout du 15 jan 98
}
Standard_Integer nbpi=0;
Standard_Real parO[8];
Standard_Real parT[8];
Intf_SeqOfSectionPoint thePi;
gp_XY segT =EndT.XY()-BegT.XY();
gp_XY segO =EndO.XY()-BegO.XY();
// If the length of segment is zero, nothing is done
Standard_Real lgT =Sqrt(segT*segT);
if (lgT<=0.) return;
Standard_Real lgO =Sqrt(segO*segO);
if (lgO<=0.) return;
// Direction of parsing of segments
Standard_Real sigPS=(segO*segT)>0.0 ? 1.0 : -1.0;
// Precision of calculation
Standard_Real floatgap=Epsilon(lgO+lgT);
// Angle between two straight lines and radius of interference
Standard_Real sinTeta=(segO.CrossMagnitude(segT)/lgO)/lgT;
Standard_Real rayIntf=0.;
if (sinTeta>0.) rayIntf=Tolerance/sinTeta;
// Interference <begO> <segT>
Standard_Real dbOT=((BegO.XY()-BegT.XY())^segT)/lgT;
Standard_Real dbObT=BegO.Distance(BegT);
Standard_Real dbOeT=BegO.Distance(EndT);
if (Abs(dbOT)<=Tolerance) {
if (dbObT<=Tolerance) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_VERTEX,iObje2,0.,sinTeta));
}
if (dbOeT<=Tolerance) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
if (dbObT>Tolerance && dbOeT>Tolerance &&
dbObT+dbOeT<=(lgT+Tolerance)) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=dbObT/lgT;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_EDGE,iObje2,parT[nbpi],sinTeta));
}
}
// Interference <endO> <segT>
Standard_Real deOT=((EndO.XY()-BegT.XY())^segT)/lgT;
Standard_Real deObT=EndO.Distance(BegT);
Standard_Real deOeT=EndO.Distance(EndT);
if (Abs(deOT)<=Tolerance) {
if (deObT<=Tolerance) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_VERTEX,iObje2,0.,sinTeta));
}
if (deOeT<=Tolerance) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
if (deObT>Tolerance && deOeT>Tolerance &&
deObT+deOeT<=(lgT+Tolerance)) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=deObT/lgT;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_EDGE,iObje2,parT[nbpi],sinTeta));
}
}
// Interference <begT> <segO>
Standard_Real dbTO=((BegT.XY()-BegO.XY())^segO)/lgO;
if (Abs(dbTO)<=Tolerance) {
if (dbObT>Tolerance && deObT>Tolerance &&
dbObT+deObT<=(lgO+Tolerance)) {
nbpi++;
parO[nbpi]=dbObT/lgO;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(BegT,Intf_EDGE,iObje1,parO[nbpi],
Intf_VERTEX,iObje2,0.,sinTeta));
}
}
// Interference <endT> <segO>
Standard_Real deTO=((EndT.XY()-BegO.XY())^segO)/lgO;
if (Abs(deTO)<=Tolerance) {
if (dbOeT>Tolerance && deOeT>Tolerance &&
dbOeT+deOeT<=(lgO+Tolerance)) {
nbpi++;
parO[nbpi]=dbOeT/lgO;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(EndT,Intf_EDGE,iObje1,parO[nbpi],
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
}
Standard_Boolean edgeSP=Standard_False;
Standard_Real parOSP=0, parTSP=0;
if (Abs(dbOT-deOT)>floatgap && Abs(dbTO-deTO)>floatgap) {
parOSP=dbOT/(dbOT-deOT);
parTSP=dbTO/(dbTO-deTO);
if (dbOT*deOT<=0. && dbTO*deTO<=0.) {
edgeSP=Standard_True;
}
else if (nbpi==0) return;
// If there is no interference it is necessary to take the points segment by segment
if (nbpi==0 && sinTeta>PRCANG) {
nbpi++;
parO[nbpi]=parOSP;
parT[nbpi]=parTSP;
thePi.Append(Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta));
}
// Otherwise it is required to check if there is no other
else if (rayIntf>=Tolerance) {
Standard_Real deltaO=rayIntf/lgO;
Standard_Real deltaT=rayIntf/lgT;
Standard_Real x, y;
Standard_Real parOdeb=parOSP-deltaO;
Standard_Real parOfin=parOSP+deltaO;
Standard_Real parTdeb=parTSP-sigPS*deltaT;
Standard_Real parTfin=parTSP+sigPS*deltaT;
if (nbpi==0) {
parO[1]=parOdeb;
parO[2]=parOfin;
parT[1]=parTdeb;
parT[2]=parTfin;
while (nbpi<2) {
nbpi++;
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
else { //nbpi>0
if (nbpi==1) {
Standard_Boolean ok=Standard_True;
if (0.<parOdeb && parOdeb<1. && 0.<parTdeb && parTdeb<1. ) {
parO[nbpi+1]=parOdeb;
parT[nbpi+1]=parTdeb;
}
else if (0.<parOfin && parOfin<1. && 0.<parTfin && parTfin<1. ) {
parO[nbpi+1]= parOfin;
parT[nbpi+1]= parTfin;
}
else {
ok=Standard_False;
}
if (ok) {
x=BegO.X()+ (segO.X()*parO[nbpi+1]);
y=BegO.Y()+ (segO.Y()*parO[nbpi+1]);
if (thePi(1).Pnt().Distance(gp_Pnt(x, y, 0)) >= (Tolerance/4.)) {
nbpi++;
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
}
else { // plus d une singularite
Standard_Real parOmin=parO[1];
Standard_Real parOmax=parO[1];
Standard_Real parTmin=parT[1];
Standard_Real parTmax=parT[1];
for (Standard_Integer i=2; i<=nbpi; i++) {
parOmin=Min(parOmin, parO[i]);
parOmax=Max(parOmax, parO[i]);
parTmin=Min(parTmin, parT[i]);
parTmax=Max(parTmax, parT[i]);
}
Standard_Real delta;
if (parOdeb<0.) {
delta=-parOdeb;
parOdeb=0.;
parTdeb=parTdeb+sigPS*(delta*(deltaT/deltaO));
}
if (parOfin>1.) {
delta=parOfin-1.;
parOfin=1.;
parTfin=parTfin-sigPS*(delta*(deltaT/deltaO));
}
if (sigPS>0.) {
if (parTdeb<0.) {
delta=-parTdeb;
parTdeb=0.;
parOdeb=parOdeb+delta*(deltaO/deltaT);
}
if (parTfin>1.) {
delta=parTfin-1.;
parTfin=1.;
parOfin=parOfin-delta*(deltaO/deltaT);
}
}
else {
if (parTdeb>1.) {
delta=parTdeb-1.;
parTdeb=1.;
parOdeb=parOdeb+delta*(deltaO/deltaT);
}
if (parTfin<0.) {
delta=-parTfin;
parTfin=0.;
parOfin=parOfin-delta*(deltaO/deltaT);
}
}
if ((parOdeb<parOmin && parOmin>0.) ||
(sigPS>0. && parTdeb<parTmin && parTmin>0.) ||
(sigPS<0. && parTdeb>parTmax && parTmax<1.)) {
nbpi++;
parO[nbpi]=Max(0., Min(1., parOdeb));
parT[nbpi]=Max(0., Min(1., parTdeb));
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
if ((parOfin>parOmax && parOmax<1.) ||
(sigPS<0. && parTfin<parTmin && parTmin>0.) ||
(sigPS>0. && parTfin>parTmax && parTmax<1.)) {
nbpi++;
parO[nbpi]=Min(1., Max(0., parOfin));
parT[nbpi]=Min(1., Max(0., parTfin));
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
}
}
}
//-- lbr : The points too close to each other are suspended
Standard_Boolean suppr;
do {
suppr=Standard_False;
for(Standard_Integer i=2; suppr==Standard_False && i<=nbpi; i++) {
const gp_Pnt& Pim1 = thePi(i-1).Pnt();
const gp_Pnt& Pi = thePi(i).Pnt();
Standard_Real d=Pi.Distance(Pim1);
d*=50.0;
if(d<lgT && d<lgO) {
for(Standard_Integer j=i; j<nbpi; j++) {
thePi(j)=thePi(j+1);
}
nbpi--;
suppr=Standard_True;
}
}
}
while(suppr==Standard_True);
if (nbpi==1) {
if (edgeSP) {
thePi(1)=Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta);
parO[1]=parOSP;
parT[1]=parTSP;
}
if (!SelfIntf) {
Standard_Boolean contains = Standard_False;
for (Standard_Integer i = 1; i <= mySPoins.Length(); i++)
if (thePi(1).IsEqual(mySPoins(i))) {
contains = Standard_True;
break;
}
if (!contains)
mySPoins.Append(thePi(1));
}
else if (iObje2-iObje1!=1 &&
(!oClos || (iObje1!=1 && iObje2!=nbso))) {
mySPoins.Append(thePi(1));
}
}
else if (nbpi>=2) {
Intf_TangentZone TheTZ;
if (nbpi==2) {
TheTZ.PolygonInsert(thePi(1));
TheTZ.PolygonInsert(thePi(2));
}
else {
Standard_Integer lpj;
Standard_Integer lmin=1;
Standard_Integer lmax=1;
for (lpj=2; lpj<=nbpi; lpj++) {
if (parO[lpj]<parO[lmin]) lmin=lpj;
else if (parO[lpj]>parO[lmax]) lmax=lpj;
}
TheTZ.PolygonInsert(thePi(lmin));
TheTZ.PolygonInsert(thePi(lmax));
Standard_Integer ltmin=1;
Standard_Integer ltmax=1;
for (lpj=2; lpj<=nbpi; lpj++) {
if (parT[lpj]<parT[ltmin]) ltmin=lpj;
else if (parT[lpj]>parT[ltmax]) ltmax=lpj;
}
if (ltmin!=lmin && ltmin!=lmax) TheTZ.PolygonInsert(thePi(ltmin));
if (ltmax!=lmin && ltmax!=lmax) TheTZ.PolygonInsert(thePi(ltmax));
}
if (edgeSP) TheTZ.PolygonInsert(Intf_SectionPoint
(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta));
Standard_Integer nbtz=myTZones.Length();
#if 0
Standard_Integer decaltz=0;
for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
if (TheTZ.HasCommonRange(myTZones(ltz-decaltz))) {
TheTZ.Append(myTZones(ltz-decaltz));
myTZones.Remove(ltz-decaltz);
decaltz++;
}
}
myTZones.Append(TheTZ);
#else
TColStd_ListOfInteger LIndex;
for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
if (TheTZ.HasCommonRange(myTZones(ltz))) {
LIndex.Append(ltz);
}
}
//------------------------------------------------------------------------
//-- The list is parsed in ascending order by index, zone and tg
//--
if(LIndex.IsEmpty()) {
myTZones.Append(TheTZ);
}
else {
Standard_Integer indexfirst = LIndex.First();
LIndex.RemoveFirst();
Standard_Integer decal = 0;
myTZones(indexfirst).Append(TheTZ);
while(!LIndex.IsEmpty()) {
Standard_Integer index = LIndex.First();
LIndex.RemoveFirst();
myTZones(indexfirst).Append(myTZones(index-decal));
myTZones.Remove(index-decal);
decal++;
}
}
#endif
}
}

View File

@ -1,698 +0,0 @@
// File: Intf_InterferencePolygon2d.gxx
// Created: Mon Jun 24 11:52:34 1991
// Author: Didier PIFFAULT
// <dpf@phobox>
#include <gp_Pnt2d.hxx>
#include <Bnd_Box2d.hxx>
#include <Intf_SectionPoint.hxx>
#include <Intf_SeqOfSectionPoint.hxx>
#include <Intf_TangentZone.hxx>
#include <Intf_SeqOfTangentZone.hxx>
#include <Precision.hxx>
#include <TColStd_ListOfInteger.hxx>
// Angular precision (sinus) below that value two right segments
// are considered as having a potential zone of tangency.
namespace
{
static const Standard_Real PRCANG = Precision::Angular();
};
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : constructor empty
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d()
: Intf_Interference (Standard_False),
oClos (Standard_False),
tClos (Standard_False),
iObje1 (0),
iObje2 (0),
nbso (0),
BeginOfNotClosedObje1 (Standard_False),
BeginOfNotClosedObje2 (Standard_False)
{}
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : Constructor of the interference beetween two Polygon.
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
(const Polygon2d1& Obje1, const Polygon2d2& Obje2)
: Intf_Interference (Standard_False),
oClos (Standard_False),
tClos (Standard_False),
iObje1 (0),
iObje2 (0),
nbso (0),
BeginOfNotClosedObje1 (Standard_False),
BeginOfNotClosedObje2 (Standard_False)
{
if (!ToolPolygon2d1::Bounding(Obje1).IsOut
(ToolPolygon2d2::Bounding(Obje2))) {
Tolerance=ToolPolygon2d1::DeflectionOverEstimation(Obje1)+
ToolPolygon2d2::DeflectionOverEstimation(Obje2);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
nbso=ToolPolygon2d1::NbSegments(Obje1);
oClos=ToolPolygon2d1::Closed(Obje1);
tClos=ToolPolygon2d2::Closed(Obje2);
Interference(Obje1, Obje2);
Clean();
}
}
//=======================================================================
//function : Intf_InterferencePolygon2d
//purpose : Constructor of the auto interference of a Polygon.
//=======================================================================
Intf_InterferencePolygon2d::Intf_InterferencePolygon2d
(const Polygon2d1& Obje)
: Intf_Interference (Standard_True),
oClos (Standard_False),
tClos (Standard_False),
iObje1 (0),
iObje2 (0),
nbso (0),
BeginOfNotClosedObje1 (Standard_False),
BeginOfNotClosedObje2 (Standard_False)
{
Tolerance=ToolPolygon2d1::DeflectionOverEstimation(Obje)*2;
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
oClos=ToolPolygon2d1::Closed(Obje);
tClos=oClos;
Interference(Obje);
Clean();
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Perform
(const Polygon2d1& Obje1, const Polygon2d2& Obje2)
{
SelfInterference(Standard_False);
if (!ToolPolygon2d1::Bounding(Obje1).IsOut(ToolPolygon2d2::Bounding(Obje2))) {
Tolerance=ToolPolygon2d1::DeflectionOverEstimation(Obje1)+
ToolPolygon2d2::DeflectionOverEstimation(Obje2);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
nbso=ToolPolygon2d1::NbSegments(Obje1);
oClos=ToolPolygon2d1::Closed(Obje1);
tClos=ToolPolygon2d2::Closed(Obje2);
Interference(Obje1, Obje2);
Clean();
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Perform
(const Polygon2d1& Obje)
{
SelfInterference(Standard_True);
Tolerance=ToolPolygon2d1::DeflectionOverEstimation(Obje)*2;
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
oClos=ToolPolygon2d1::Closed(Obje);
tClos=oClos;
Interference(Obje);
Clean();
}
//=======================================================================
//function : Pnt2dValue
//purpose : Give the section point of range Index in the interference.
//=======================================================================
gp_Pnt2d Intf_InterferencePolygon2d::Pnt2dValue
(const Standard_Integer Index) const
{
return gp_Pnt2d((mySPoins(Index)).Pnt().X(),
(mySPoins(Index)).Pnt().Y());
}
//=======================================================================
//function : Interference
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Interference
(const Polygon2d1& Obje1,
const Polygon2d2& Obje2)
{
Bnd_Box2d bSO;
Bnd_Box2d bST;
BeginOfNotClosedObje1=!oClos;
for (iObje1=1; iObje1<=ToolPolygon2d1::NbSegments(Obje1); iObje1++) {
bSO.SetVoid();
bSO.Add(ToolPolygon2d1::BeginOfSeg(Obje1, iObje1));
bSO.Add(ToolPolygon2d1::EndOfSeg(Obje1, iObje1));
bSO.Enlarge(ToolPolygon2d1::DeflectionOverEstimation(Obje1));
if (!ToolPolygon2d2::Bounding(Obje2).IsOut(bSO)) {
BeginOfNotClosedObje2=!tClos;
for (iObje2=1; iObje2<=ToolPolygon2d2::NbSegments(Obje2); iObje2++) {
bST.SetVoid();
bST.Add(ToolPolygon2d2::BeginOfSeg(Obje2, iObje2));
bST.Add(ToolPolygon2d2::EndOfSeg(Obje2, iObje2));
bST.Enlarge(ToolPolygon2d2::DeflectionOverEstimation(Obje2));
if (!bSO.IsOut(bST))
Intersect(ToolPolygon2d1::BeginOfSeg(Obje1, iObje1),
ToolPolygon2d1::EndOfSeg(Obje1, iObje1),
ToolPolygon2d2::BeginOfSeg(Obje2, iObje2),
ToolPolygon2d2::EndOfSeg(Obje2, iObje2));
}
BeginOfNotClosedObje2=Standard_False;
}
BeginOfNotClosedObje1=Standard_False;
}
}
//=======================================================================
//function : Interference
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Interference
(const Polygon2d1& Obje)
{
Bnd_Box2d bSO;
Bnd_Box2d bST;
BeginOfNotClosedObje1=!oClos;
for (iObje1=1; iObje1<=ToolPolygon2d1::NbSegments(Obje); iObje1++) {
bSO.SetVoid();
bSO.Add(ToolPolygon2d1::BeginOfSeg(Obje, iObje1));
bSO.Add(ToolPolygon2d1::EndOfSeg(Obje, iObje1));
bSO.Enlarge(ToolPolygon2d1::DeflectionOverEstimation(Obje));
if (!ToolPolygon2d1::Bounding(Obje).IsOut(bSO)) {
BeginOfNotClosedObje2=!tClos;
for (iObje2=iObje1+1;iObje2<=ToolPolygon2d1::NbSegments(Obje);iObje2++){
bST.SetVoid();
bST.Add(ToolPolygon2d1::BeginOfSeg(Obje, iObje2));
bST.Add(ToolPolygon2d1::EndOfSeg(Obje, iObje2));
bST.Enlarge(ToolPolygon2d1::DeflectionOverEstimation(Obje));
if (!bSO.IsOut(bST))
Intersect(ToolPolygon2d1::BeginOfSeg(Obje, iObje1),
ToolPolygon2d1::EndOfSeg(Obje, iObje1),
ToolPolygon2d1::BeginOfSeg(Obje, iObje2),
ToolPolygon2d1::EndOfSeg(Obje, iObje2));
}
BeginOfNotClosedObje2=Standard_False;
}
BeginOfNotClosedObje1=Standard_False;
}
}
//=======================================================================
//function : Clean
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Clean()
{
// The zones of tangency that concerns only one couple of segments are
// conserved if the angle between the segments is less than <PRCANG> and
// if there is no real point of intersection EDGE/EDGE:
Standard_Integer nbIt=myTZones.Length();
Standard_Integer decal=0;
Standard_Integer addr1, addr2;
Intf_PIType dim1, dim2;
Standard_Real par;
Standard_Integer tsp, tsps;
Standard_Integer lpi, ltz;
Standard_Boolean Only1Seg=Standard_False;
#define PI1 (myTZones(ltz-decal).GetPoint(lpi))
#define PI2 (myTZones(ltz-decal).GetPoint(tsp))
for (ltz=1; ltz<=nbIt; ltz++) {
tsp=tsps=0;
Standard_Real pr1mi,pr1ma,pr2mi,pr2ma,delta1,delta2;
myTZones(ltz-decal).ParamOnFirst(pr1mi,pr1ma);
delta1=pr1ma-pr1mi;
myTZones(ltz-decal).ParamOnSecond(pr2mi,pr2ma);
delta2=pr2ma-pr2mi;
if (delta1<1. && delta2<1.) Only1Seg=Standard_True;
if (delta1==0. || delta2==0.) Only1Seg=Standard_True;
for (lpi=1; lpi<=myTZones(ltz-decal).NumberOfPoints(); lpi++) {
if (PI1.Incidence()<=PRCANG) {tsp=tsps=0;break;}
PI1.InfoFirst(dim1,addr1,par);
PI1.InfoSecond(dim2,addr2,par);
if (dim1==Intf_EDGE && dim2==Intf_EDGE) {
tsps=0;
if (tsp>0) {
tsp=0;
Only1Seg=Standard_False;
break;
}
tsp=lpi;
}
else if (dim1!=Intf_EXTERNAL && dim2!=Intf_EXTERNAL) {
tsps=lpi;
}
}
if (tsp>0) {
mySPoins.Append(myTZones(ltz-decal).GetPoint(tsp));
myTZones.Remove(ltz-decal);
decal++;
}
else if (Only1Seg && tsps!=0) {
mySPoins.Append(myTZones(ltz-decal).GetPoint(tsps));
myTZones.Remove(ltz-decal);
decal++;
}
}
// The points of intersection located in the tangency zone are
// removed from the list :
nbIt=mySPoins.Length();
decal=0;
for (lpi=1; lpi<=nbIt; lpi++) {
for (ltz=1; ltz<=myTZones.Length(); ltz++) {
if (myTZones(ltz).RangeContains(mySPoins(lpi-decal))) {
mySPoins.Remove(lpi-decal);
decal++;
break;
}
}
}
}
//=======================================================================
//function : Intersect
//purpose :
//=======================================================================
void Intf_InterferencePolygon2d::Intersect
(const gp_Pnt2d& BegO, const gp_Pnt2d& EndO,
const gp_Pnt2d& BegT, const gp_Pnt2d& EndT)
{
if(SelfIntf) {
if(Abs(iObje1-iObje2)<=1) return; //-- Ajout du 15 jan 98
}
Standard_Integer nbpi=0;
Standard_Real parO[8];
Standard_Real parT[8];
Intf_SeqOfSectionPoint thePi;
gp_XY segT =EndT.XY()-BegT.XY();
gp_XY segO =EndO.XY()-BegO.XY();
// If the length of segment is zero, nothing is done
Standard_Real lgT =Sqrt(segT*segT);
if (lgT<=0.) return;
Standard_Real lgO =Sqrt(segO*segO);
if (lgO<=0.) return;
// Direction of parsing of segments
Standard_Real sigPS=(segO*segT)>0.0 ? 1.0 : -1.0;
// Precision of calculation
Standard_Real floatgap=Epsilon(lgO+lgT);
// Angle between two straight lines and radius of interference
Standard_Real sinTeta=(segO.CrossMagnitude(segT)/lgO)/lgT;
Standard_Real rayIntf=0.;
if (sinTeta>0.) rayIntf=Tolerance/sinTeta;
// Interference <begO> <segT>
Standard_Real dbOT=((BegO.XY()-BegT.XY())^segT)/lgT;
Standard_Real dbObT=BegO.Distance(BegT);
Standard_Real dbOeT=BegO.Distance(EndT);
if (Abs(dbOT)<=Tolerance) {
if (dbObT<=Tolerance) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_VERTEX,iObje2,0.,sinTeta));
}
if (dbOeT<=Tolerance) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
if (dbObT>Tolerance && dbOeT>Tolerance &&
dbObT+dbOeT<=(lgT+Tolerance)) {
nbpi++;
parO[nbpi]=0.;parT[nbpi]=dbObT/lgT;
thePi.Append(Intf_SectionPoint(BegO,Intf_VERTEX,iObje1,0.,
Intf_EDGE,iObje2,parT[nbpi],sinTeta));
}
}
// Interference <endO> <segT>
Standard_Real deOT=((EndO.XY()-BegT.XY())^segT)/lgT;
Standard_Real deObT=EndO.Distance(BegT);
Standard_Real deOeT=EndO.Distance(EndT);
if (Abs(deOT)<=Tolerance) {
if (deObT<=Tolerance) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_VERTEX,iObje2,0.,sinTeta));
}
if (deOeT<=Tolerance) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
if (deObT>Tolerance && deOeT>Tolerance &&
deObT+deOeT<=(lgT+Tolerance)) {
nbpi++;
parO[nbpi]=1.;parT[nbpi]=deObT/lgT;
thePi.Append(Intf_SectionPoint(EndO,Intf_VERTEX,iObje1+1,0.,
Intf_EDGE,iObje2,parT[nbpi],sinTeta));
}
}
// Interference <begT> <segO>
Standard_Real dbTO=((BegT.XY()-BegO.XY())^segO)/lgO;
if (Abs(dbTO)<=Tolerance) {
if (dbObT>Tolerance && deObT>Tolerance &&
dbObT+deObT<=(lgO+Tolerance)) {
nbpi++;
parO[nbpi]=dbObT/lgO;parT[nbpi]=0.;
thePi.Append(Intf_SectionPoint(BegT,Intf_EDGE,iObje1,parO[nbpi],
Intf_VERTEX,iObje2,0.,sinTeta));
}
}
// Interference <endT> <segO>
Standard_Real deTO=((EndT.XY()-BegO.XY())^segO)/lgO;
if (Abs(deTO)<=Tolerance) {
if (dbOeT>Tolerance && deOeT>Tolerance &&
dbOeT+deOeT<=(lgO+Tolerance)) {
nbpi++;
parO[nbpi]=dbOeT/lgO;parT[nbpi]=1.;
thePi.Append(Intf_SectionPoint(EndT,Intf_EDGE,iObje1,parO[nbpi],
Intf_VERTEX,iObje2+1,0.,sinTeta));
}
}
Standard_Boolean edgeSP=Standard_False;
Standard_Real parOSP=0, parTSP=0;
if (Abs(dbOT-deOT)>floatgap && Abs(dbTO-deTO)>floatgap) {
parOSP=dbOT/(dbOT-deOT);
parTSP=dbTO/(dbTO-deTO);
if (dbOT*deOT<=0. && dbTO*deTO<=0.) {
edgeSP=Standard_True;
}
else if (nbpi==0) return;
// If there is no interference it is necessary to take the points segment by segment
if (nbpi==0 && sinTeta>PRCANG) {
nbpi++;
parO[nbpi]=parOSP;
parT[nbpi]=parTSP;
thePi.Append(Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta));
}
// Otherwise it is required to check if there is no other
else if (rayIntf>=Tolerance) {
Standard_Real deltaO=rayIntf/lgO;
Standard_Real deltaT=rayIntf/lgT;
Standard_Real x, y;
Standard_Real parOdeb=parOSP-deltaO;
Standard_Real parOfin=parOSP+deltaO;
Standard_Real parTdeb=parTSP-sigPS*deltaT;
Standard_Real parTfin=parTSP+sigPS*deltaT;
if (nbpi==0) {
parO[1]=parOdeb;
parO[2]=parOfin;
parT[1]=parTdeb;
parT[2]=parTfin;
while (nbpi<2) {
nbpi++;
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
else { //nbpi>0
if (nbpi==1) {
Standard_Boolean ok=Standard_True;
if (0.<parOdeb && parOdeb<1. && 0.<parTdeb && parTdeb<1. ) {
parO[nbpi+1]=parOdeb;
parT[nbpi+1]=parTdeb;
}
else if (0.<parOfin && parOfin<1. && 0.<parTfin && parTfin<1. ) {
parO[nbpi+1]= parOfin;
parT[nbpi+1]= parTfin;
}
else {
ok=Standard_False;
}
if (ok) {
x=BegO.X()+ (segO.X()*parO[nbpi+1]);
y=BegO.Y()+ (segO.Y()*parO[nbpi+1]);
if (thePi(1).Pnt().Distance(gp_Pnt(x, y, 0)) >= (Tolerance/4.)) {
nbpi++;
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
}
else { // plus d une singularite
Standard_Real parOmin=parO[1];
Standard_Real parOmax=parO[1];
Standard_Real parTmin=parT[1];
Standard_Real parTmax=parT[1];
for (Standard_Integer i=2; i<=nbpi; i++) {
parOmin=Min(parOmin, parO[i]);
parOmax=Max(parOmax, parO[i]);
parTmin=Min(parTmin, parT[i]);
parTmax=Max(parTmax, parT[i]);
}
Standard_Real delta;
if (parOdeb<0.) {
delta=-parOdeb;
parOdeb=0.;
parTdeb=parTdeb+sigPS*(delta*(deltaT/deltaO));
}
if (parOfin>1.) {
delta=parOfin-1.;
parOfin=1.;
parTfin=parTfin-sigPS*(delta*(deltaT/deltaO));
}
if (sigPS>0.) {
if (parTdeb<0.) {
delta=-parTdeb;
parTdeb=0.;
parOdeb=parOdeb+delta*(deltaO/deltaT);
}
if (parTfin>1.) {
delta=parTfin-1.;
parTfin=1.;
parOfin=parOfin-delta*(deltaO/deltaT);
}
}
else {
if (parTdeb>1.) {
delta=parTdeb-1.;
parTdeb=1.;
parOdeb=parOdeb+delta*(deltaO/deltaT);
}
if (parTfin<0.) {
delta=-parTfin;
parTfin=0.;
parOfin=parOfin-delta*(deltaO/deltaT);
}
}
if ((parOdeb<parOmin && parOmin>0.) ||
(sigPS>0. && parTdeb<parTmin && parTmin>0.) ||
(sigPS<0. && parTdeb>parTmax && parTmax<1.)) {
nbpi++;
parO[nbpi]=Max(0., Min(1., parOdeb));
parT[nbpi]=Max(0., Min(1., parTdeb));
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
if ((parOfin>parOmax && parOmax<1.) ||
(sigPS<0. && parTfin<parTmin && parTmin>0.) ||
(sigPS>0. && parTfin>parTmax && parTmax<1.)) {
nbpi++;
parO[nbpi]=Min(1., Max(0., parOfin));
parT[nbpi]=Min(1., Max(0., parTfin));
x=BegO.X()+ (segO.X()*parO[nbpi]);
y=BegO.Y()+ (segO.Y()*parO[nbpi]);
thePi.Append(Intf_SectionPoint(gp_Pnt2d(x, y),
Intf_EXTERNAL, iObje1, parO[nbpi],
Intf_EXTERNAL, iObje2, parT[nbpi],
sinTeta));
}
}
}
}
}
//-- lbr : The points too close to each other are suspended
Standard_Boolean suppr;
do {
suppr=Standard_False;
for(Standard_Integer i=2; suppr==Standard_False && i<=nbpi; i++) {
const gp_Pnt& Pim1 = thePi(i-1).Pnt();
const gp_Pnt& Pi = thePi(i).Pnt();
Standard_Real d=Pi.Distance(Pim1);
d*=50.0;
if(d<lgT && d<lgO) {
for(Standard_Integer j=i; j<nbpi; j++) {
thePi(j)=thePi(j+1);
}
nbpi--;
suppr=Standard_True;
}
}
}
while(suppr==Standard_True);
if (nbpi==1) {
if (edgeSP) {
thePi(1)=Intf_SectionPoint(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta);
parO[1]=parOSP;
parT[1]=parTSP;
}
if (!SelfIntf) {
// if ((BeginOfNotClosedObje1 && parO[1]==0.) ||
// (BeginOfNotClosedObje2 && parT[1]==0.) ||
// (parO[1]>0. && parT[1]>0.)) {
{
Standard_Boolean contains = Standard_False;
for (Standard_Integer i = 1; i <= mySPoins.Length(); i++)
if (thePi(1).IsEqual(mySPoins(i))) {
contains = Standard_True;
break;
}
if (!contains)
mySPoins.Append(thePi(1));
}
}
else if (iObje2-iObje1!=1 &&
(!oClos || (iObje1!=1 && iObje2!=nbso))) {
mySPoins.Append(thePi(1));
}
}
else if (nbpi>=2) {
Intf_TangentZone TheTZ;
if (nbpi==2) {
TheTZ.PolygonInsert(thePi(1));
TheTZ.PolygonInsert(thePi(2));
}
else {
Standard_Integer lpj;
Standard_Integer lmin=1;
Standard_Integer lmax=1;
for (lpj=2; lpj<=nbpi; lpj++) {
if (parO[lpj]<parO[lmin]) lmin=lpj;
else if (parO[lpj]>parO[lmax]) lmax=lpj;
}
TheTZ.PolygonInsert(thePi(lmin));
TheTZ.PolygonInsert(thePi(lmax));
Standard_Integer ltmin=1;
Standard_Integer ltmax=1;
for (lpj=2; lpj<=nbpi; lpj++) {
if (parT[lpj]<parT[ltmin]) ltmin=lpj;
else if (parT[lpj]>parT[ltmax]) ltmax=lpj;
}
if (ltmin!=lmin && ltmin!=lmax) TheTZ.PolygonInsert(thePi(ltmin));
if (ltmax!=lmin && ltmax!=lmax) TheTZ.PolygonInsert(thePi(ltmax));
}
if (edgeSP) TheTZ.PolygonInsert(Intf_SectionPoint
(gp_Pnt2d (BegO.X()+ (segO.X()*parOSP),
BegO.Y()+ (segO.Y()*parOSP)),
Intf_EDGE,iObje1,parOSP,
Intf_EDGE,iObje2,parTSP,sinTeta));
Standard_Integer nbtz=myTZones.Length();
#if 0
Standard_Integer decaltz=0;
for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
if (TheTZ.HasCommonRange(myTZones(ltz-decaltz))) {
TheTZ.Append(myTZones(ltz-decaltz));
myTZones.Remove(ltz-decaltz);
decaltz++;
}
}
myTZones.Append(TheTZ);
#else
TColStd_ListOfInteger LIndex;
for (Standard_Integer ltz=1; ltz<=nbtz; ltz++) {
if (TheTZ.HasCommonRange(myTZones(ltz))) {
LIndex.Append(ltz);
}
}
//------------------------------------------------------------------------
//-- The list is parsed in ascending order by index, zone and tg
//--
if(LIndex.IsEmpty()) {
myTZones.Append(TheTZ);
}
else {
Standard_Integer indexfirst = LIndex.First();
LIndex.RemoveFirst();
Standard_Integer decal = 0;
myTZones(indexfirst).Append(TheTZ);
while(!LIndex.IsEmpty()) {
Standard_Integer index = LIndex.First();
LIndex.RemoveFirst();
myTZones(indexfirst).Append(myTZones(index-decal));
myTZones.Remove(index-decal);
decal++;
}
}
#endif
}
}
// EOF File: Intf_InterferencePolygon2d.gxx

View File

@ -0,0 +1,43 @@
-- File: Intf_Polygon2d.cdl
-- Created: Fri Feb 10 17:49:16 2012
-- Author: Serey ZERCHANINOV
---Copyright: OPEN CASCADE SAS 2012
deferred class Polygon2d from Intf
---Purpose:
uses Pnt2d from gp,
Box2d from Bnd
raises OutOfRange from Standard
is
Bounding (me)
returns Box2d from Bnd;
---C++: return const &
---C++: inline
---Purpose: Returns the bounding box of the polygon.
Closed (me)
returns Boolean from Standard is virtual;
---Purpose: Returns True if the polyline is closed.
DeflectionOverEstimation (me) returns Real from Standard is deferred;
---Purpose: Returns the tolerance of the polygon.
NbSegments (me) returns Integer from Standard is deferred;
---Purpose: Returns the number of Segments in the polyline.
Segment (me; theIndex : in Integer from Standard;
theBegin, theEnd : in out Pnt2d from gp)
raises OutOfRange from Standard is deferred;
---Purpose: Returns the points of the segment <Index> in the Polygon.
fields
myBox : Box2d from Bnd is protected;
end Polygon2d;

View File

@ -0,0 +1,16 @@
// File: Intf_Polygon2d.cxx
// Created: Fri Feb 10 17:49:16 2012
// Author: Sergey ZERCHANINOV
// Copyright: OPEN CASCADE SAS 2012
#include <Intf_Polygon2d.ixx>
//=======================================================================
//function : Closed
//purpose :
//=======================================================================
Standard_Boolean Intf_Polygon2d::Closed () const
{
return Standard_False;
}

View File

@ -0,0 +1,15 @@
// File: Intf_Polygon2d.lxx
// Created: Fri Feb 10 17:49:16 2012
// Author: Sergey ZERCHANINOV
// Copyright: OPEN CASCADE SAS 2012
//=======================================================================
//function : Bounding
//purpose :
//=======================================================================
inline const Bnd_Box2d& Intf_Polygon2d::Bounding () const
{
return myBox;
}

View File

@ -1,50 +0,0 @@
-- File: ToolPolygon.cdl
-- Created: Fri Aug 2 08:18:37 1991
-- Author: Didier PIFFAULT
-- <dpf@sdsun2>
---Copyright: Matra Datavision 1991, 1992
generic class ToolPolygon from Intf
(Point as any; -- as Pnt2d, Pnt from gp
Polygon as any;
BoundingBox as any) -- as Box2d, Box from Bnd
---Purpose: Describes the necessary information about a polyline to
-- compute the interference between two polylines.
raises OutOfRange from Standard
is Bounding (myclass; thePolyg : Polygon)
returns BoundingBox;
---Purpose: Returns the bounding box of the polygon.
DeflectionOverEstimation
(myclass; thePolyg : Polygon)
returns Real from Standard;
---Purpose: Returns the tolerance of the polygon.
Closed (myclass; thePolyg : Polygon)
returns Boolean from Standard;
---Purpose: Returns True if the polyline is closed.
NbSegments (myclass; thePolyg : Polygon)
returns Integer;
---Purpose: Returns the number of Segments in the polyline.
BeginOfSeg (myclass; thePolyg : Polygon;
Index : in Integer)
returns Point
raises OutOfRange from Standard;
---Purpose: Returns the first point of segment of range <Index> in the
-- Polygon.
EndOfSeg (myclass; thePolyg : Polygon;
Index : in Integer)
returns Point
raises OutOfRange from Standard;
---Purpose: Returns the Second point of the segment of range Index in
-- the Polygon.
end ToolPolygon;