#include <Extrema_ExtElC.hxx>
#include <Extrema_POnCurv.hxx>
-#include <Precision.hxx>
static const int Pourcent3[4] = {0, 1, 2, 0};
static Standard_Boolean IsInSegment(const gp_Vec& P1P2,
- const gp_Vec& P1P,
- const Standard_Real NP1P2,
- Standard_Real &Param,
- const Standard_Real Tolerance) {
- Param = P1P2.Dot(P1P);
- Param/= NP1P2;
- if(Param > (NP1P2+Tolerance))
- return(Standard_False);
- if(Param < (-Tolerance))
- return(Standard_False);
- Param/=NP1P2;
- if(Param<0.0) Param=0.0;
- if(Param>1.0) Param=1.0;
- return(Standard_True);
+ const gp_Vec& P1P,
+ const Standard_Real NP1P2,
+ Standard_Real &Param,
+ const Standard_Real Tolerance) {
+ Param = P1P2.Dot(P1P);
+ Param/= NP1P2;
+ if(Param > (NP1P2+Tolerance))
+ return(Standard_False);
+ if(Param < (-Tolerance))
+ return(Standard_False);
+ Param/=NP1P2;
+ if(Param<0.0) Param=0.0;
+ if(Param>1.0) Param=1.0;
+ return(Standard_True);
}
-
+
//=======================================================================
//function : Intf_InterferencePolygonPolyhedron
//=======================================================================
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron()
- : Intf_Interference (Standard_False),
+: Intf_Interference (Standard_False),
BeginOfClosedPolygon (Standard_False),
iLin (0)
{}
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const Polygon3d& thePolyg, const Polyhedron& thePolyh)
- : Intf_Interference (Standard_False),
+: Intf_Interference (Standard_False),
BeginOfClosedPolygon (Standard_False),
iLin (0)
{
Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
+ ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
- : Intf_Interference (Standard_False),
+ Bnd_BoundSortBox &PolyhGrid)
+: Intf_Interference (Standard_False),
BeginOfClosedPolygon (Standard_False),
iLin (0)
{
Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
+ ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const gp_Lin& theLin, const Polyhedron& thePolyh)
- : Intf_Interference (Standard_False),
+: Intf_Interference (Standard_False),
BeginOfClosedPolygon (Standard_False),
iLin (0)
{
Bnd_BoundSortBox PolyhGrid;
PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
iLin=0;
while (iCl.More()) {
indTri=iCl.Value();
Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ (theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True, indTri, thePolyh);
iCl.Next();
}
}
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh)
- : Intf_Interference (Standard_False),
+: Intf_Interference (Standard_False),
BeginOfClosedPolygon (Standard_False),
iLin (0)
{
Bnd_BoundSortBox PolyhGrid;
PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
while (ilC.More()) {
indTri=ilC.Value();
Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ (theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True, indTri, thePolyh);
ilC.Next();
}
}
{
SelfInterference(Standard_False);
Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
+ ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
if (!ToolPolygon3d::Bounding(thePolyg).IsOut
- (ToolPolyh::Bounding(thePolyh))) {
- Interference(thePolyg, thePolyh);
+ (ToolPolyh::Bounding(thePolyh))) {
+ Interference(thePolyg, thePolyh);
}
}
Bnd_BoundSortBox PolyhGrid;
PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
while (lCi.More()) {
indTri=lCi.Value();
Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ (theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True, indTri, thePolyh);
lCi.Next();
}
}
Bnd_BoundSortBox PolyhGrid;
PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
while (tlC.More()) {
indTri=tlC.Value();
Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ (theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True, indTri, thePolyh);
tlC.Next();
}
}
Bnd_BoundSortBox PolyhGrid;
PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
BeginOfClosedPolygon=ToolPolygon3d::Closed(thePolyg);
gp_Vec Normale = PaPb.Crossed(PaPc);
Standard_Real Norm_Normale=Normale.Magnitude();
if(Norm_Normale<1e-14)
- continue;
+ continue;
Normale.Multiply(defPh/Norm_Normale);
gp_Pnt p1m = p1.Translated(-Normale);
gp_Pnt p1p = p1.Translated( Normale);
gp_Pnt p2m = p2.Translated(-Normale);
gp_Pnt p2p = p2.Translated( Normale);
Intersect(p1m,
- p2p,
- Standard_False, indTri, thePolyh);
+ p2p,
+ Standard_False, indTri, thePolyh);
Intersect(p1p,
- p2m,
- Standard_False, indTri, thePolyh);
- // Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin),
- // ToolPolygon3d::EndOfSeg(thePolyg, iLin),
- // Standard_False, indTri, thePolyh);
+ p2m,
+ Standard_False, indTri, thePolyh);
+// Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin),
+// ToolPolygon3d::EndOfSeg(thePolyg, iLin),
+// Standard_False, indTri, thePolyh);
}
BeginOfClosedPolygon=Standard_False;
}
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const gp_Lin& theLin, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
- : Intf_Interference(Standard_False)
+ Bnd_BoundSortBox &PolyhGrid)
+: Intf_Interference(Standard_False)
{
Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
while (iCl.More()) {
indTri=iCl.Value();
Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ (theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True, indTri, thePolyh);
iCl.Next();
}
}
Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
(const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
- : Intf_Interference(Standard_False)
+ Bnd_BoundSortBox &PolyhGrid)
+: Intf_Interference(Standard_False)
{
Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
while (ilC.More()) {
indTri=ilC.Value();
Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ (theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True, indTri, thePolyh);
ilC.Next();
}
}
void Intf_InterferencePolygonPolyhedron::Perform
(const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+ Bnd_BoundSortBox &PolyhGrid)
{
SelfInterference(Standard_False);
Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
+ ToolPolyh::DeflectionOverEstimation(thePolyh);
if (Tolerance==0.)
Tolerance=Epsilon(1000.);
if (!ToolPolygon3d::Bounding(thePolyg).IsOut
- (ToolPolyh::Bounding(thePolyh))) {
- Interference(thePolyg, thePolyh,PolyhGrid);
+ (ToolPolyh::Bounding(thePolyh))) {
+ Interference(thePolyg, thePolyh,PolyhGrid);
}
}
void Intf_InterferencePolygonPolyhedron::Perform
(const gp_Lin& theLin, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+ Bnd_BoundSortBox &PolyhGrid)
{
SelfInterference(Standard_False);
Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
while (lCi.More()) {
indTri=lCi.Value();
Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ (theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True, indTri, thePolyh);
lCi.Next();
}
}
void Intf_InterferencePolygonPolyhedron::Perform
(const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+ Bnd_BoundSortBox &PolyhGrid)
{
SelfInterference(Standard_False);
Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
while (tlC.More()) {
indTri=tlC.Value();
Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ (theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True, indTri, thePolyh);
tlC.Next();
}
}
void Intf_InterferencePolygonPolyhedron::Interference
(const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+ Bnd_BoundSortBox &PolyhGrid)
{
Bnd_Box bofSeg;
ToolPolyh::Triangle(thePolyh, indTri, pTri[0], pTri[1], pTri[2]);
gp_XYZ triNor; // Vecteur normal.
Standard_Real triDp = 0.; // Distance polaire.
-
+
Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
- ToolPolyh::Point(thePolyh, pTri[1]),
- ToolPolyh::Point(thePolyh, pTri[2]),
- triNor, triDp);
+ ToolPolyh::Point(thePolyh, pTri[1]),
+ ToolPolyh::Point(thePolyh, pTri[2]),
+ triNor, triDp);
// enlarge boundary segment
if ( iLin == 1 ) {
- gp_XYZ dif = p1.XYZ() - p2.XYZ();
- Standard_Real dist = dif.Modulus();
- if ( dist > gp::Resolution() ) {
- dif /= dist;
- Standard_Real aCos = dif * triNor;
- aCos = fabs(aCos);
- if ( aCos > gp::Resolution() ) {
- Standard_Real shift = defPh / aCos;
- Beg0.SetXYZ( p1.XYZ() + dif * shift );
- }
- }
+ gp_XYZ dif = p1.XYZ() - p2.XYZ();
+ Standard_Real dist = dif.Modulus();
+ if ( dist > gp::Resolution() ) {
+ dif /= dist;
+ Standard_Real aCos = dif * triNor;
+ aCos = fabs(aCos);
+ if ( aCos > gp::Resolution() ) {
+ Standard_Real shift = defPh / aCos;
+ Beg0.SetXYZ( p1.XYZ() + dif * shift );
+ }
+ }
}
else if ( iLin == ToolPolygon3d::NbSegments(thePolyg) ) {
- gp_XYZ dif = p2.XYZ() - p1.XYZ();
- Standard_Real dist = dif.Modulus();
- if ( dist > gp::Resolution() ) {
- dif /= dist;
- Standard_Real aCos = dif * triNor;
- aCos = fabs(aCos);
- if ( aCos > gp::Resolution() ) {
- Standard_Real shift = defPh / aCos;
- End0.SetXYZ( p2.XYZ() + dif * shift );
- }
- }
+ gp_XYZ dif = p2.XYZ() - p1.XYZ();
+ Standard_Real dist = dif.Modulus();
+ if ( dist > gp::Resolution() ) {
+ dif /= dist;
+ Standard_Real aCos = dif * triNor;
+ aCos = fabs(aCos);
+ if ( aCos > gp::Resolution() ) {
+ Standard_Real shift = defPh / aCos;
+ End0.SetXYZ( p2.XYZ() + dif * shift );
+ }
+ }
}
Standard_Real dBegTri=(triNor*Beg0.XYZ())-triDp; // Distance <p1> plane
Standard_Real dEndTri=(triNor*End0.XYZ())-triDp; // Distance <p2> plane
//=======================================================================
#if 0
void Intf_InterferencePolygonPolyhedron::Intersect
- (const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
- const Standard_Integer TTri, const Polyhedron& thePolyh)
+(const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
+ const Standard_Integer TTri, const Polyhedron& thePolyh)
{
Standard_Integer pTri0,pTri1,pTri2;
ToolPolyh::Triangle(thePolyh, TTri, pTri0, pTri1, pTri2);
Standard_Real Norm_Normale=Normale.Magnitude();
if(Norm_Normale<1e-14)
return;
-
+
//-- Equation du Plan
Standard_Real A=Normale.X()/Norm_Normale;
Standard_Real B=Normale.Y()/Norm_Normale;
Standard_Real C=Normale.Z()/Norm_Normale;
Standard_Real D=-(A*Pa.X()+B*Pa.Y()+C*Pa.Z());
-
+
gp_Vec BegOEndO(BegO,EndO);
Standard_Real Norm_BegOEndO=BegOEndO.Magnitude();
if(Norm_BegOEndO<1e-14)
Standard_Real Lx=BegOEndO.X()/Norm_BegOEndO;
Standard_Real Ly=BegOEndO.Y()/Norm_BegOEndO;
Standard_Real Lz=BegOEndO.Z()/Norm_BegOEndO;
-
+
Standard_Real Vd=A*Lx+B*Ly+C*Lz; //-- DirLigne . NormalePlan
-
+
if(Vd==0) { //-- Droite parallele au plan
return;
}
-
-
+
+
//-- Calcul du parametre sur la ligne
Standard_Real t=-(A*BegO.X()+B*BegO.Y()+C*BegO.Z()+D) / Vd;
-
+
Standard_Real tol=1e-8; //-- Deflection sur le triangle
if(t<-tol || t>(Norm_BegOEndO+tol)) {
if(Infinite==Standard_False) {
//-- On a une intersection droite plan
//-- On teste si c est dans le triangle
gp_Pnt PRes(BegO.X()+t*Lx,BegO.Y()+t*Ly,BegO.Z()+t*Lz);
-
+
Standard_Real AbsA=A; if(AbsA<0) AbsA=-AbsA;
Standard_Real AbsB=B; if(AbsB<0) AbsB=-AbsB;
Standard_Real AbsC=C; if(AbsC<0) AbsC=-AbsC;
-
+
Standard_Real Au,Av,Bu,Bv,Cu,Cv,Pu,Pv;
if(AbsA>AbsB) {
if(AbsA>AbsC) {
Standard_Real ABu=Bu-Au; Standard_Real ABv=Bv-Av;
Standard_Real ACu=Cu-Au; Standard_Real ACv=Cv-Av;
Standard_Real BCu=Cu-Bu; Standard_Real BCv=Cv-Bv;
-
+
Standard_Real t1,t2;
//-- Test sur AB et C
t1=-ABv*Cu + ABu*Cv;
Intf_SectionPoint SP(PRes,
- Intf_EDGE,
- 0,
- iLin, //-- !!!!! VARIABLE STATIQUE
- t / Norm_BegOEndO,
- Intf_FACE,
- TTri, 0, 0.,1.);
+ Intf_EDGE,
+ 0,
+ iLin, //-- !!!!! VARIABLE STATIQUE
+ t / Norm_BegOEndO,
+ Intf_FACE,
+ TTri, 0, 0.,1.);
mySPoins.Append(SP);
}
#else
void Intf_InterferencePolygonPolyhedron::Intersect
(const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
- const Standard_Integer TTri, const Polyhedron& thePolyh)
+ const Standard_Integer TTri, const Polyhedron& thePolyh)
{
Intf_PIType typOnG=Intf_EDGE;
Standard_Real t;
Standard_Real triDp; // Distance polaire.
Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
- ToolPolyh::Point(thePolyh, pTri[1]),
- ToolPolyh::Point(thePolyh, pTri[2]),
- triNor, triDp);
+ ToolPolyh::Point(thePolyh, pTri[1]),
+ ToolPolyh::Point(thePolyh, pTri[2]),
+ triNor, triDp);
Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
param = dBegTri/t;
else param = dBegTri;
Standard_Real floatgap=Epsilon(1000.);
-
+
if (!Infinite) {
if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
param=0.;typOnG=Intf_VERTEX;
if (BeginOfClosedPolygon)
- NoIntersectionWithTriangle = Standard_False;
+ NoIntersectionWithTriangle = Standard_False;
}
else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
param=1.;typOnG=Intf_VERTEX;
Standard_Integer tbreak=0;
{ //-- is = 0
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
dPtPi[0]=vecP.Modulus();
if (dPtPi[0]<=floatgap) {
- sVertex=0;
- is=0;
- tbreak=1;
+ sVertex=0;
+ is=0;
+ tbreak=1;
}
else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
- sEdge=0;
- is=0;
- tbreak=1;
- }
+ gp_XYZ segT_x_vecP(segT^vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP*triNor;
+ if(sigd>floatgap)
+ sigd = 1.0;
+ else if(sigd<-floatgap)
+ sigd = -1.0;
+ else {
+ sigd = 0.0;
+ }
+ dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+ if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
+ sEdge=0;
+ is=0;
+ tbreak=1;
+ }
}
}
if(tbreak==0) { //-- is = 1
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
dPtPi[1]=vecP.Modulus();
if (dPtPi[1]<=floatgap) {
- sVertex=1;
- is=1;
- tbreak=1;
+ sVertex=1;
+ is=1;
+ tbreak=1;
}
else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
- sEdge=1;
- is=1;
- tbreak=1;
- }
+ gp_XYZ segT_x_vecP(segT^vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP*triNor;
+ if(sigd>floatgap)
+ sigd = 1.0;
+ else if(sigd<-floatgap)
+ sigd = -1.0;
+ else {
+ sigd = 0.0;
+ }
+ dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+ if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
+ sEdge=1;
+ is=1;
+ tbreak=1;
+ }
}
}
if(tbreak==0) { //-- is = 2
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
dPtPi[2]=vecP.Modulus();
if (dPtPi[2]<=floatgap) {
- sVertex=2;
- is=2;
+ sVertex=2;
+ is=2;
}
gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
sigd = segT_x_vecP*triNor;
if(sigd>floatgap)
- sigd = 1.0;
+ sigd = 1.0;
else if(sigd<-floatgap)
- sigd = -1.0;
+ sigd = -1.0;
else {
- sigd = 0.0;
+ sigd = 0.0;
}
dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
- sEdge=2;
- is=2;
+ sEdge=2;
+ is=2;
}
}
//-- fin for i=0 to 2
// !!cout<<endl;
-
+
Standard_Integer triCon, pedg;
if (sVertex>-1) {
triCon=TTri;
pedg=pTri[Pourcent3[sVertex+1]];
- //-- while (triCon!=0) {
- //-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
- //-- //-- if (triCon<TTri) return;
- //-- if (triCon==TTri) break;
- //-- }
+//-- while (triCon!=0) {
+//-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+//-- //-- if (triCon<TTri) return;
+//-- if (triCon==TTri) break;
+//-- }
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_VERTEX, pTri[is], 0, 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_VERTEX, pTri[is], 0, 0.,
+ 1.);
mySPoins.Append(SP);
}
else if (sEdge>-1) {
ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
- triCon, pedg);
+ triCon, pedg);
//-- if (triCon<=TTri) return; ???????????????????? LBR
// !!cout<<" sEdge "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
- Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
+ Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
+ 1.);
mySPoins.Append(SP);
}
else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
// !!cout<<" 3 Positifs "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_FACE, TTri, 0, 0.,
+ 1.);
mySPoins.Append(SP);
}
- // Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
+// Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
// Sometimes triangulation doesn't cover whole the face. In this
// case it is necessary to take into account the deflection between boundary
// isolines of the surface and boundary trianles. Computed value of this
Standard_Integer i;
for (i = 1; i <= 3; i++) {
- Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
- Standard_Integer indP2 = pTri[i - 1];
-
- if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
- // For boundary line it is necessary to check the border deflection.
- Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
- const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
- const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
- gp_Vec VecTri(BegP,EndP);
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegP,DirTri);
- gp_Pnt aPOnE(spLieu);
- Standard_Real aDist = LinTri.Distance(aPOnE);
-
- if (aDist <= Deflection) {
- gp_Vec aVLocPOnE(BegP, aPOnE);
- gp_Vec aVecDirTri(DirTri);
- Standard_Real aPar = aVLocPOnE*aVecDirTri;
- Standard_Real aMaxPar = VecTri.Magnitude();
-
- if (aPar >= 0 && aPar <= aMaxPar) {
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
+ Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+ Standard_Integer indP2 = pTri[i - 1];
+
+ if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
+ // For boundary line it is necessary to check the border deflection.
+ Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+ const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
+ const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
+ gp_Vec VecTri(BegP,EndP);
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegP,DirTri);
+ gp_Pnt aPOnE(spLieu);
+ Standard_Real aDist = LinTri.Distance(aPOnE);
+
+ if (aDist <= Deflection) {
+ gp_Vec aVLocPOnE(BegP, aPOnE);
+ gp_Vec aVecDirTri(DirTri);
+ Standard_Real aPar = aVLocPOnE*aVecDirTri;
+ Standard_Real aMaxPar = VecTri.Magnitude();
+
+ if (aPar >= 0 && aPar <= aMaxPar) {
+ Intf_SectionPoint SP(spLieu,
+ typOnG, 0, iLin, param,
+ Intf_FACE, TTri, 0, 0.,
+ 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
}
}
- // Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
+// Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
} //---- if(NoIntersectionWithTriangle == Standard_False)
-
+
//---------------------------------------------------------------------------
//-- On teste la distance entre les cotes du triangle et le polygone
//--
//-- Si cette distance est inferieure a Tolerance, on cree un SP.
//--
//-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
- // if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+// if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
{
gp_Vec VecPol(BegO,EndO);
Standard_Real NVecPol = VecPol.Magnitude();
gp_Dir DirPol(VecPol);
gp_Lin LinPol(BegO,DirPol);
Standard_Real dist2,ParamOnO,ParamOnT;
-
+
for (Standard_Integer i=0; i<3; i++) {
Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
Standard_Integer pTri_i = pTri[i];
gp_Lin LinTri(BegT,DirTri);
Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
if(Extrema.IsDone()) {
- if(Extrema.IsParallel() == Standard_False) {
- if(Extrema.NbExt()) {
- dist2 = Extrema.SquareDistance();
- if(dist2<=Tolerance * Tolerance) {
- Extrema_POnCurv POnC1,POnC2;
- Extrema.Points(1,POnC1,POnC2);
- const gp_Pnt& PO = POnC1.Value();
- const gp_Pnt& PT = POnC2.Value();
- //--cout<<" ** Nouveau "<<dist2<<endl;
- if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
- if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
- //-- cout<<" * "<<endl;
- gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
- Standard_Integer tmin,tmax;
- if(pTri_i>pTri_ip1pc3) {
- tmin=pTri_ip1pc3; tmax=pTri_i;
- }
- else {
- tmax=pTri_ip1pc3; tmin=pTri_i;
- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, ParamOnO,
- Intf_EDGE,
- tmin,
- tmax, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
- }
- }
+ if(Extrema.IsParallel() == Standard_False) {
+ if(Extrema.NbExt()) {
+ dist2 = Extrema.SquareDistance();
+ if(dist2<=Tolerance * Tolerance) {
+ Extrema_POnCurv POnC1,POnC2;
+ Extrema.Points(1,POnC1,POnC2);
+ const gp_Pnt& PO = POnC1.Value();
+ const gp_Pnt& PT = POnC2.Value();
+ //--cout<<" ** Nouveau "<<dist2<<endl;
+ if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
+ if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
+ //-- cout<<" * "<<endl;
+ gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
+ Standard_Integer tmin,tmax;
+ if(pTri_i>pTri_ip1pc3) {
+ tmin=pTri_ip1pc3; tmax=pTri_i;
+ }
+ else {
+ tmax=pTri_ip1pc3; tmin=pTri_i;
+ }
+ Intf_SectionPoint SP(spLieu,
+ typOnG, 0, iLin, ParamOnO,
+ Intf_EDGE,
+ tmin,
+ tmax, 0.,
+ 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
+ }
+ }
}
}
}
#endif
void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
- const gp_Pnt& EndO,
- const Standard_Boolean Infinite,
- const Standard_Integer TTri,
- const Polyhedron& thePolyh,
- const gp_XYZ& TriNormal,
- const Standard_Real /*TriDp*/,
- const Standard_Real dBegTri,
- const Standard_Real dEndTri)
+ const gp_Pnt& EndO,
+ const Standard_Boolean Infinite,
+ const Standard_Integer TTri,
+ const Polyhedron& thePolyh,
+ const gp_XYZ& TriNormal,
+ const Standard_Real /*TriDp*/,
+ const Standard_Real dBegTri,
+ const Standard_Real dEndTri)
{
Intf_PIType typOnG=Intf_EDGE;
Standard_Real t;
//Standard_Real triDp = TriDp; // Distance polaire.
- // Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
- // Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
+// Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
+// Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
Standard_Boolean NoIntersectionWithTriangle = Standard_False;
param = dBegTri/t;
else param = dBegTri;
Standard_Real floatgap=Epsilon(1000.);
-
+
if (!Infinite) {
if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
param=0.;typOnG=Intf_VERTEX;
if (BeginOfClosedPolygon)
- NoIntersectionWithTriangle = Standard_False;
+ NoIntersectionWithTriangle = Standard_False;
}
else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
param=1.;typOnG=Intf_VERTEX;
Standard_Integer tbreak=0;
{ //-- is = 0
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
dPtPi[0]=vecP.Modulus();
if (dPtPi[0]<=floatgap) {
- sVertex=0;
- is=0;
- tbreak=1;
+ sVertex=0;
+ is=0;
+ tbreak=1;
}
else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
- sEdge=0;
- is=0;
- tbreak=1;
- }
+ gp_XYZ segT_x_vecP(segT^vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP*triNor;
+ if(sigd>floatgap)
+ sigd = 1.0;
+ else if(sigd<-floatgap)
+ sigd = -1.0;
+ else {
+ sigd = 0.0;
+ }
+ dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+ if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
+ sEdge=0;
+ is=0;
+ tbreak=1;
+ }
}
}
-
+
if(tbreak==0) { //-- is = 1
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
dPtPi[1]=vecP.Modulus();
if (dPtPi[1]<=floatgap) {
- sVertex=1;
- is=1;
- tbreak=1;
+ sVertex=1;
+ is=1;
+ tbreak=1;
}
else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
- sEdge=1;
- is=1;
- tbreak=1;
- }
+ gp_XYZ segT_x_vecP(segT^vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP*triNor;
+ if(sigd>floatgap)
+ sigd = 1.0;
+ else if(sigd<-floatgap)
+ sigd = -1.0;
+ else {
+ sigd = 0.0;
+ }
+ dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+ if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
+ sEdge=1;
+ is=1;
+ tbreak=1;
+ }
}
}
if(tbreak==0) { //-- is = 2
gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
dPtPi[2]=vecP.Modulus();
if (dPtPi[2]<=floatgap) {
- sVertex=2;
- is=2;
+ sVertex=2;
+ is=2;
}
gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP;
- if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
- Precision::IsInfinite(segT_x_vecP.Z()))
- {
- Modulus_segT_x_vecP = Precision::Infinite();
- }
- else
- {
- Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- }
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
sigd = segT_x_vecP*triNor;
if(sigd>floatgap)
- sigd = 1.0;
+ sigd = 1.0;
else if(sigd<-floatgap)
- sigd = -1.0;
+ sigd = -1.0;
else {
- sigd = 0.0;
+ sigd = 0.0;
}
dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
- sEdge=2;
- is=2;
+ sEdge=2;
+ is=2;
}
}
//-- fin for i=0 to 2
// !!cout<<endl;
-
+
Standard_Integer triCon, pedg;
if (sVertex>-1) {
triCon=TTri;
pedg=pTri[Pourcent3[sVertex+1]];
- //-- while (triCon!=0) {
- //-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
- //-- //-- if (triCon<TTri) return;
- //-- if (triCon==TTri) break;
- //-- }
+//-- while (triCon!=0) {
+//-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+//-- //-- if (triCon<TTri) return;
+//-- if (triCon==TTri) break;
+//-- }
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_VERTEX, pTri[is], 0, 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_VERTEX, pTri[is], 0, 0.,
+ 1.);
mySPoins.Append(SP);
}
else if (sEdge>-1) {
ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
- triCon, pedg);
+ triCon, pedg);
//-- if (triCon<=TTri) return; ???????????????????? LBR
// !!cout<<" sEdge "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
- Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
+ Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
+ 1.);
mySPoins.Append(SP);
}
else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
// !!cout<<" 3 Positifs "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
+ typOnG, 0, iLin, param,
+ Intf_FACE, TTri, 0, 0.,
+ 1.);
mySPoins.Append(SP);
}
- // Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
+// Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
// Sometimes triangulation doesn't cover whole the face. In this
// case it is necessary to take into account the deflection between boundary
// isolines of the surface and boundary trianles. Computed value of this
Standard_Integer i;
for (i = 1; i <= 3; i++) {
- Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
- Standard_Integer indP2 = pTri[i - 1];
-
- if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
- // For boundary line it is necessary to check the border deflection.
- Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
- const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
- const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
- gp_Vec VecTri(BegP,EndP);
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegP,DirTri);
- gp_Pnt aPOnE(spLieu);
- Standard_Real aDist = LinTri.Distance(aPOnE);
-
- if (aDist <= Deflection) {
- gp_Vec aVLocPOnE(BegP, aPOnE);
- gp_Vec aVecDirTri(DirTri);
- Standard_Real aPar = aVLocPOnE*aVecDirTri;
- Standard_Real aMaxPar = VecTri.Magnitude();
-
- if (aPar >= 0 && aPar <= aMaxPar) {
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
+ Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+ Standard_Integer indP2 = pTri[i - 1];
+
+ if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
+ // For boundary line it is necessary to check the border deflection.
+ Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+ const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
+ const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
+ gp_Vec VecTri(BegP,EndP);
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegP,DirTri);
+ gp_Pnt aPOnE(spLieu);
+ Standard_Real aDist = LinTri.Distance(aPOnE);
+
+ if (aDist <= Deflection) {
+ gp_Vec aVLocPOnE(BegP, aPOnE);
+ gp_Vec aVecDirTri(DirTri);
+ Standard_Real aPar = aVLocPOnE*aVecDirTri;
+ Standard_Real aMaxPar = VecTri.Magnitude();
+
+ if (aPar >= 0 && aPar <= aMaxPar) {
+ Intf_SectionPoint SP(spLieu,
+ typOnG, 0, iLin, param,
+ Intf_FACE, TTri, 0, 0.,
+ 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
}
}
- // Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
+// Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
} //---- if(NoIntersectionWithTriangle == Standard_False)
-
+
//---------------------------------------------------------------------------
//-- On teste la distance entre les cotes du triangle et le polygone
//--
//-- Si cette distance est inferieure a Tolerance, on cree un SP.
//--
//-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
- // if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+// if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
{
gp_Vec VecPol(BegO,EndO);
Standard_Real NVecPol = VecPol.Magnitude();
gp_Dir DirPol(VecPol);
gp_Lin LinPol(BegO,DirPol);
Standard_Real dist2,ParamOnO,ParamOnT;
-
+
for (Standard_Integer i=0; i<3; i++) {
Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
Standard_Integer pTri_i = pTri[i];
gp_Lin LinTri(BegT,DirTri);
Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
if(Extrema.IsDone()) {
- if(Extrema.IsParallel() == Standard_False) {
- if(Extrema.NbExt()) {
- dist2 = Extrema.SquareDistance();
- if(dist2<=Tolerance * Tolerance) {
- Extrema_POnCurv POnC1,POnC2;
- Extrema.Points(1,POnC1,POnC2);
- const gp_Pnt& PO = POnC1.Value();
- const gp_Pnt& PT = POnC2.Value();
- //--cout<<" ** Nouveau "<<dist2<<endl;
- if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
- if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
- //-- cout<<" * "<<endl;
- gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
- Standard_Integer tmin,tmax;
- if(pTri_i>pTri_ip1pc3) {
- tmin=pTri_ip1pc3; tmax=pTri_i;
- }
- else {
- tmax=pTri_ip1pc3; tmin=pTri_i;
- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, ParamOnO,
- Intf_EDGE,
- tmin,
- tmax, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
- }
- }
+ if(Extrema.IsParallel() == Standard_False) {
+ if(Extrema.NbExt()) {
+ dist2 = Extrema.SquareDistance();
+ if(dist2<=Tolerance * Tolerance) {
+ Extrema_POnCurv POnC1,POnC2;
+ Extrema.Points(1,POnC1,POnC2);
+ const gp_Pnt& PO = POnC1.Value();
+ const gp_Pnt& PT = POnC2.Value();
+ //--cout<<" ** Nouveau "<<dist2<<endl;
+ if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
+ if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
+ //-- cout<<" * "<<endl;
+ gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
+ Standard_Integer tmin,tmax;
+ if(pTri_i>pTri_ip1pc3) {
+ tmin=pTri_ip1pc3; tmax=pTri_i;
+ }
+ else {
+ tmax=pTri_ip1pc3; tmin=pTri_i;
+ }
+ Intf_SectionPoint SP(spLieu,
+ typOnG, 0, iLin, ParamOnO,
+ Intf_EDGE,
+ tmin,
+ tmax, 0.,
+ 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
+ }
+ }
}
}
}