#include <CSLib_Class2d.hxx>
-#define COORD(a,b) ((Select3D_Pnt*)mypolyg3d)[(a)].b
-#define COORD2d(a,b) ((Select3D_Pnt2d*)mypolyg2d)[(a)].b
-
static Standard_Boolean S3D_Str_NearSegment (const gp_XY& p0, const gp_XY& p1, const gp_XY& TheP,
const Standard_Real aTol, Standard_Real& aDMin)
{
const Select3D_TypeOfSensitivity aType):
Select3D_SensitivePoly(OwnerId,3),
mytype (aType)
-{
- ((Select3D_Pnt*)mypolyg3d)[0] = P0;
- ((Select3D_Pnt*)mypolyg3d)[1] = P1;
- ((Select3D_Pnt*)mypolyg3d)[2] = P2;
+{
+ mypolyg.SetPnt(0, P0);
+ mypolyg.SetPnt(1, P1);
+ mypolyg.SetPnt(2, P2);
}
//==================================================
if(Bnd_Box2d(mybox2d).IsOut(gp_Pnt2d(X,Y))) return Standard_False;
Standard_Integer Res;
- switch (mytype)
+ switch (mytype)
{
case Select3D_TOS_BOUNDARY:
Res = Status(X,Y,aTol,DMin);
#ifndef DEB
default:
break;
-#endif
+#endif
}
return Standard_True;
}
Min(YMin,YMax)-aTol,
Max(XMin,XMax)+aTol,
Max(YMin,YMax)+aTol);
- for(Standard_Integer i=0;i<=2;i++)
+ for(Standard_Integer anIndex=0;anIndex<=2;++anIndex)
{
- if(B.IsOut(((Select3D_Pnt2d*)mypolyg2d)[i]))
+ if(B.IsOut(mypolyg.Pnt2d(anIndex)))
return Standard_False;
}
return Standard_True;
Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
-{
+{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
Standard_Real Tolu,Tolv;
Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
- for(Standard_Integer i=0;i<=2;i++)
+ for(Standard_Integer anIndex=0;anIndex<=2;++anIndex)
{
- Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[i]);
- if(RES!=1) return Standard_False;
+ Standard_Integer RES = aClassifier2d.SiDans(mypolyg.Pnt2d(anIndex));
+ if(RES!=1)
+ return Standard_False;
}
return Standard_True;
}
// Purpose :
//==================================================
- void Select3D_SensitiveTriangle::Points3D(gp_Pnt& P0,gp_Pnt& P1,gp_Pnt& P2) const
+void Select3D_SensitiveTriangle::Points3D(gp_Pnt& P0,gp_Pnt& P1,gp_Pnt& P2) const
{
- P0 = ((Select3D_Pnt*)mypolyg3d)[0];
- P1 = ((Select3D_Pnt*)mypolyg3d)[1];
- P2 = ((Select3D_Pnt*)mypolyg3d)[2];
+ P0 = mypolyg.Pnt(0);
+ P1 = mypolyg.Pnt(1);
+ P2 = mypolyg.Pnt(2);
}
//==================================================
gp_Pnt Select3D_SensitiveTriangle::Center3D() const
{
- gp_XYZ CDG(((Select3D_Pnt*)mypolyg3d)[0]);
- CDG += ((Select3D_Pnt*)mypolyg3d)[1];
- CDG += ((Select3D_Pnt*)mypolyg3d)[2];
- CDG /=3.;
- return gp_Pnt(CDG);;
+ gp_XYZ aPnt1, aPnt2, aPnt3;
+ aPnt1 = mypolyg.Pnt(0);
+ aPnt2 = mypolyg.Pnt(1);
+ aPnt3 = mypolyg.Pnt(2);
+ return gp_Pnt((aPnt1+aPnt2+aPnt3)/3.);
}
//==================================================
gp_XY Select3D_SensitiveTriangle::Center2D() const
{
- return (gp_XY(((Select3D_Pnt2d*)mypolyg2d)[0])+gp_XY(((Select3D_Pnt2d*)mypolyg2d)[1])
- +gp_XY(((Select3D_Pnt2d*)mypolyg2d)[2]))/3.;
+ gp_XY aPnt1, aPnt2, aPnt3;
+ aPnt1 = mypolyg.Pnt2d(0);
+ aPnt2 = mypolyg.Pnt2d(1);
+ aPnt3 = mypolyg.Pnt2d(2);
+ return (aPnt1+aPnt2+aPnt3)/3.;
}
//=======================================================================
Standard_Integer Select3D_SensitiveTriangle::Status(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
- Standard_Real& DMin) const
-{
- return Status(((Select3D_Pnt2d*)mypolyg2d)[0],((Select3D_Pnt2d*)mypolyg2d)[1],
- ((Select3D_Pnt2d*)mypolyg2d)[2],gp_XY(X,Y),aTol,DMin);
+ Standard_Real& DMin) const
+{
+ return Status(mypolyg.Pnt2d(0), mypolyg.Pnt2d(1), mypolyg.Pnt2d(2),
+ gp_XY(X,Y), aTol, DMin);
}
//=======================================================================
Bnd_Box2d B;
B.Update(p0.X(),p0.Y());B.Update(p1.X(),p1.Y());B.Update(p2.X(),p2.Y());
B.Enlarge(aTol);
- if(B.IsOut(TheP)) return 2;
+ if(B.IsOut(TheP)) return 2;
// the point is classified corresponding to demi-spaces limited
// by each side of the triangle (with tolerance)
Standard_Real TolTol = aTol*aTol;
// check these particular cases...
- // if one of vectors is almost null (2 points are mixed),
+ // if one of vectors is almost null (2 points are mixed),
// leave at once (it is already in the bounding box, which is good...)
DMin = aTol;
void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
// general information....
-
+
S<<"\tSensitiveTriangle 3D :\n";
if(HasLocation())
S<<"\t\tExisting Location"<<endl;
- S<<"\t\t P0 [ "<<COORD(0,x)<<" , "<<COORD(0,y) <<" , "<<COORD(0,z)<<" ]"<<endl;
- S<<"\t\t P1 [ "<<COORD(1,x)<<" , "<<COORD(1,y) <<" , "<<COORD(1,z)<<" ]"<<endl;
- S<<"\t\t P2 [ "<<COORD(2,x)<<" , "<<COORD(2,y) <<" , "<<COORD(2,z)<<" ]"<<endl;
+ gp_Pnt aPnt1, aPnt2, aPnt3;
+ aPnt1 = mypolyg.Pnt(0);
+ aPnt2 = mypolyg.Pnt(1);
+ aPnt3 = mypolyg.Pnt(2);
+ S<<"\t\t P0 [ "<<aPnt1.X()<<" , "<<aPnt1.Y()<<" , "<<aPnt1.Z()<<" ]"<<endl;
+ S<<"\t\t P1 [ "<<aPnt2.X()<<" , "<<aPnt2.Y()<<" , "<<aPnt2.Z()<<" ]"<<endl;
+ S<<"\t\t P2 [ "<<aPnt3.X()<<" , "<<aPnt3.Y()<<" , "<<aPnt3.Z()<<" ]"<<endl;
if(FullDump)
{
S<<"\t\tProjected Points"<<endl;
-
- S<<"\t\t 0.[ "<<COORD2d(0,x)<<" , "<<COORD2d(0,y)<<" ]"<<endl;
- S<<"\t\t 1.[ "<<COORD2d(1,x)<<" , "<<COORD2d(1,y)<<" ]"<<endl;
- S<<"\t\t 2.[ "<<COORD2d(2,x)<<" , "<<COORD2d(2,y)<<" ]"<<endl;
-// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
+
+ gp_Pnt2d aPnt1, aPnt2, aPnt3;
+ aPnt1 = mypolyg.Pnt2d(0);
+ aPnt2 = mypolyg.Pnt2d(1);
+ aPnt3 = mypolyg.Pnt2d(2);
+ S<<"\t\t 0.[ "<<aPnt1.X()<<" , "<<aPnt1.Y()<<" ]"<<endl;
+ S<<"\t\t 1.[ "<<aPnt2.X()<<" , "<<aPnt2.Y()<<" ]"<<endl;
+ S<<"\t\t 2.[ "<<aPnt3.X()<<" , "<<aPnt3.Y()<<" ]"<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
}
}
Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) const
{
- gp_Pnt P1 = ((Select3D_Pnt*)mypolyg3d)[0];
- gp_Pnt P2 = ((Select3D_Pnt*)mypolyg3d)[1];
- gp_Pnt P3 = ((Select3D_Pnt*)mypolyg3d)[2];
+ Standard_Real prof(Precision::Infinite());
+
+ gp_Pnt P1, P2, P3;
+ P1 = mypolyg.Pnt(0);
+ P2 = mypolyg.Pnt(1);
+ P3 = mypolyg.Pnt(2);
gp_Trsf TheTrsf ;
if(HasLocation())
P3.Transform(TheTrsf);
}
- Standard_Real prof(Precision::Infinite());
// formula calculation of the point parameters on intersection
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
{
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity =
- new Select3D_SensitiveTriangle(myOwnerId,
- ((Select3D_Pnt*)mypolyg3d)[0],
- ((Select3D_Pnt*)mypolyg3d)[1],
- ((Select3D_Pnt*)mypolyg3d)[2],
- mytype);
+ new Select3D_SensitiveTriangle(myOwnerId, mypolyg.Pnt(0), mypolyg.Pnt(1), mypolyg.Pnt(2), mytype);
if (HasLocation())
aNewEntity->SetLocation(Location());