//=======================================================================
Select3D_SensitiveCircle::
-Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(Geom_Circle)& TheCircle,
+Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
+ const Handle(Geom_Circle)& TheCircle,
const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, S3D_GetCircleNBPoints(TheCircle,NbPoints)),
for(Standard_Integer anIndex=1;anIndex<=NbPoints;anIndex++)
{
TheCircle->D1(curu,p1,v1);
-
+
v1.Normalize();
mypolyg.SetPnt(rank-1, p1);
rank++;
//=======================================================================
Select3D_SensitiveCircle::
-Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
+Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Circle)& TheCircle,
const Standard_Real u1,
const Standard_Real u2,
{
gp_Pnt p1,p2;
gp_Vec v1;
-
+
if (u1 > u2)
{
mystart = u2;
myend = u1;
}
-
+
Standard_Real du = (myend-mystart)/(NbPoints-1);
Standard_Real R = TheCircle->Radius();
Standard_Integer rank = 1;
Standard_Real curu = mystart;
-
+
for(Standard_Integer anIndex=1;anIndex<=NbPoints-1;anIndex++)
{
TheCircle->D1(curu,p1,v1);
}
TheCircle->D0(myend,p1);
mypolyg.SetPnt(NbPoints*2-2, p1);
- // Get myCenter3D
+ // Get myCenter3D
myCenter3D = TheCircle->Location();
}
else
//=======================================================================
//function : Select3D_SensitiveCircle
-//purpose :
+//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
//=======================================================================
//function : Select3D_SensitiveCircle
-//purpose :
+//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::
{
Standard_Boolean Found = Standard_False;
Standard_Integer anIndex = 0;
-
+
if(!myFillStatus)
{
while(anIndex < aSize-2 && !Found)
// Fill anArrayOf2dPnt with points from mypolig2d
Points2D(anArrayOf2dPnt);
-
+
CSLib_Class2d anInOutTool(anArrayOf2dPnt,aTol,aTol,Xmin,Ymin,Xmax,Ymax);
// Method SiDans returns the status :
- // 1 - the point is inside the circle
+ // 1 - the point is inside the circle
// 0 - the point is on the circle
// -1 - the point is outside the circle
Standard_Integer aStat = anInOutTool.SiDans(gp_Pnt2d(X,Y));
{
// Compute DMin (a distance between the center and the point)
DMin = gp_XY(myCenter2D.x - X, myCenter2D.y - Y).Modulus();
- Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
+ Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
return Standard_True;
}
return Standard_False;
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::
myDetectedIndex = -1;
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = Precision::Confusion();
- Tolv = Precision::Confusion();
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex)
//=======================================================================
//function : ArrayBounds
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveCircle::
//=======================================================================
//function : GetPoint3d
-//purpose :
+//purpose :
//=======================================================================
gp_Pnt Select3D_SensitiveCircle::
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
Standard_Integer aSize = mypolyg.Size();
-
+
S<<"\tSensitiveCircle 3D :";
-
+
Standard_Boolean isclosed = 1== aSize;
if(isclosed)
S<<"(Closed Circle)"<<endl;
else
S<<"(Arc Of Circle)"<<endl;
-
+
if(HasLocation())
S<<"\t\tExisting Location"<<endl;
-
+
if(FullDump)
{
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) const
//=======================================================================
//function : GetConnected
-//purpose :
+//purpose :
//=======================================================================
-Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const TopLoc_Location& theLocation)
+Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const TopLoc_Location& theLocation)
{
- // Create a copy of this
+ // Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Circle)
if(!myCircle.IsNull())
}
}
// this was constructed using TColgp_Array1OfPnt
- else
+ else
{
Standard_Integer aSize = mypolyg.Size();
TColgp_Array1OfPnt aPolyg(1, aSize);
}
if(HasLocation())
- aNewEntity->SetLocation(Location());
+ aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
//=======================================================================
//function : Project
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProjector)
{
- Select3D_SensitivePoly::Project(aProjector);
+ Select3D_SensitivePoly::Project(aProjector);
gp_Pnt2d aCenter;
aProjector->Project(myCenter3D, aCenter);
myCenter2D = aCenter;
//=======================================================================
//function : ComputeCenter3D
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveCircle::ComputeCenter3D()
const Handle(Geom_Curve)& C,
const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, NbPoints),
-mylastseg(0),
+mylastseg(0),
myCurve(C)
{
LoadPoints(C,NbPoints);
{
Bnd_Box2d BoundBox;
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
-
+
for(Standard_Integer anIndex=0; anIndex<mypolyg.Size(); ++anIndex)
{
if(BoundBox.IsOut(mypolyg.Pnt2d(anIndex)))
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCurve::
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex)
void Select3D_SensitiveCurve
::LoadPoints (const Handle(Geom_Curve)& aCurve,const Standard_Integer NbP)
{
- /*this method is private and it used only inside of constructor.
+ /*this method is private and it used only inside of constructor.
That's why check !NbP==mypolyg3d->Length() was removed*/
Standard_Real Step = (aCurve->LastParameter()- aCurve->FirstParameter())/(NbP-1);
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-void Select3D_SensitiveCurve::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
+void Select3D_SensitiveCurve::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
S<<"\tSensitiveCurve 3D :"<<endl;
if (HasLocation())
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveCurve::ComputeDepth(const gp_Lin& EyeLine) const
//=======================================================================
//function : GetConnected
-//purpose :
-//=======================================================================
+//purpose :
+//=======================================================================
-Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected(const TopLoc_Location &theLocation)
+Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected(const TopLoc_Location &theLocation)
{
- // Create a copy of this
+ // Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
- // this was constructed using Handle(Geom_Curve)
- if (!myCurve.IsNull())
+ // this was constructed using Handle(Geom_Curve)
+ if (!myCurve.IsNull())
{
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, myCurve);
}
// this was constructed using TColgp_HArray1OfPnt
- else
+ else
{
Standard_Integer aSize = mypolyg.Size();
Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt(1, aSize);
// Fill the array with points from mypolyg3d
- for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
+ for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
{
aPoints->SetValue(anIndex, mypolyg.Pnt(anIndex-1));
}
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, aPoints);
}
-
- if (HasLocation())
- aNewEntity->SetLocation(Location());
+
+ if (HasLocation())
+ aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
-}
\ No newline at end of file
+}
V-=mypolyg.Pnt2d(anIndex-1);
Standard_Real Vector = V1^V;
Standard_Real V1V1 = V1.SquareModulus();
- DMin2 =
- (V1V1 <=aTol2) ?
+ DMin2 =
+ (V1V1 <=aTol2) ?
Min(DMin2,V.SquareModulus()): // if the segment is too small...
Min(DMin2,Vector*Vector/V1V1);
//cdg ...
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveFace::
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveFace::
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
gp_Pnt2d aPnt2d;
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
S<<"\tSensitiveFace 3D :"<<endl;;
if(HasLocation())
S<<"\t\tExisting Location"<<endl;
-
- if(mytype==Select3D_TOS_BOUNDARY)
+
+ if(mytype==Select3D_TOS_BOUNDARY)
S<<"\t\tSelection Of Bounding Polyline Only"<<endl;
-
+
if(FullDump)
{
S<<"\t\tNumber Of Points :"<<mypolyg.Size()<<endl;
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
//=======================================================================
//function : GetConnected
-//purpose :
+//purpose :
//=======================================================================
-Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected(const TopLoc_Location &theLocation)
+Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected(const TopLoc_Location &theLocation)
{
// Create a copy of this
Standard_Integer aSize = mypolyg.Size();
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
-}
\ No newline at end of file
+}
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitivePoint::
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;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
Standard_Integer RES = aClassifier2d.SiDans(myprojpt);
if(RES==1) return Standard_True;
-
+
return Standard_False;
}
//=======================================================================
//function : Point
-//purpose :
+//purpose :
//=======================================================================
gp_Pnt Select3D_SensitivePoint::Point() const
//=======================================================================
//function : GetConnected
-//purpose :
+//purpose :
//=======================================================================
-Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected(const TopLoc_Location& aLoc)
+Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected(const TopLoc_Location& aLoc)
{
Handle(Select3D_SensitivePoint) NiouEnt = new Select3D_SensitivePoint(myOwnerId,mypoint);
if(HasLocation()) NiouEnt->SetLocation(Location());
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitivePoint::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitivePoint::ComputeDepth(const gp_Lin& EyeLine) const
//=====================================================
Select3D_SensitiveSegment::
-Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId,
+Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId,
const gp_Pnt& FirstP,
const gp_Pnt& LastP,
const Standard_Integer MaxRect):
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
gp_Pnt2d aPoint2dStart;
gp_Pnt2d aPoint2dEnd;
-
- if(HasLocation())
+
+ if(HasLocation())
{
gp_Pnt aStart(mystart.x, mystart.y, mystart.z);
gp_Pnt aEnd(myend.x, myend.y, myend.z);
aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart);
aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd);
}
- else
+ else
{
aProj->Project(mystart,aPoint2dStart);
aProj->Project(myend,aPoint2dEnd);
}
//=====================================================
-// Function : Areas
+// Function : Areas
// Purpose :
//=====================================================
{
// gp_Dir2d dy (0.,1.);
gp_Pnt2d aPStart(myprojstart.x,myprojstart.y);
- if(aPStart.Distance(myprojend)<=Precision::Confusion())
+ if(aPStart.Distance(myprojend)<=Precision::Confusion())
{
Bnd_Box2d curbox;
curbox.Set(myprojstart);
theareas.Append(curbox);
}
- else
+ else
{
gp_Vec2d MyVec(myprojstart,myprojend);//,VAxx(gp_Dir2d(0.,1.));
Standard_Real theangle = Abs(gp_Dir2d(0.,1.).Angle(gp_Vec2d(myprojstart,myprojend)));
if(theangle>=M_PI/2.) theangle-=M_PI/2;
if(theangle>=M_PI/12. && theangle <=5*M_PI/12.)
- {
- TColgp_Array1OfPnt2d BoxPoint (1,mymaxrect+1);
+ {
+ TColgp_Array1OfPnt2d BoxPoint (1,mymaxrect+1);
BoxPoint (1) = myprojstart;
- BoxPoint(mymaxrect+1)=myprojend;
+ BoxPoint(mymaxrect+1)=myprojend;
gp_Vec2d Vtr = MyVec/mymaxrect;
- Standard_Integer i;
- for ( i=2;i<=mymaxrect;i++)
- {
- BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);
- }
- for (i=2;i<=mymaxrect+1;i++)
- {
+ Standard_Integer i;
+ for ( i=2;i<=mymaxrect;i++)
+ {
+ BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);
+ }
+ for (i=2;i<=mymaxrect+1;i++)
+ {
Bnd_Box2d curbox;
curbox.Set(BoxPoint(i-1));
curbox.Add(BoxPoint(i));
}
}
else
- {
- Bnd_Box2d curbox;
- curbox.Set(myprojstart);
- curbox.Add(myprojend);
+ {
+ Bnd_Box2d curbox;
+ curbox.Set(myprojstart);
+ curbox.Add(myprojend);
theareas.Append(curbox);
}
}
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveSegment::
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;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
Standard_Integer RES = aClassifier2d.SiDans(myprojstart);
//=======================================================================
//function : GetConnected
-//purpose :
+//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment::
-GetConnected(const TopLoc_Location& aLoc)
+GetConnected(const TopLoc_Location& aLoc)
{
- Handle(Select3D_SensitiveSegment) NiouEnt =
+ Handle(Select3D_SensitiveSegment) NiouEnt =
new Select3D_SensitiveSegment(myOwnerId,mystart,myend,mymaxrect);
if(HasLocation()) NiouEnt->SetLocation(Location());
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveSegment::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
S<<"\t\t P1 [ "<<mystart.x<<" , "<<mystart.y <<" , "<<mystart.z <<" ]"<<endl;
S<<"\t\t P2 [ "<<myend.x<<" , "<<myend.y <<" , "<<myend.z <<" ]"<<endl;
S<<"\t\t maxrect ="<<mymaxrect<<endl;
-
+
}
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveSegment::ComputeDepth(const gp_Lin& EyeLine) const
gp_XY Vec(TheP);
Vec -= p0;
-
+
Standard_Real u = Vec*V01.Normalized();
if(u<-aTol) return Standard_False;
Standard_Real u1 = u-aTol;
//==================================================
Standard_Boolean Select3D_SensitiveTriangle::
-Matches(const Standard_Real X,
- const Standard_Real Y,
- const Standard_Real aTol,
+Matches(const Standard_Real X,
+ const Standard_Real Y,
+ const Standard_Real aTol,
Standard_Real& DMin)
{
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
//=======================================================================
//function : Matches
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangle::
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<=2;++anIndex)
//=======================================================================
//function : Status
-//purpose :
+//purpose :
//=======================================================================
Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
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;
-
+
// the point is classified corresponding to demi-spaces limited
// by each side of the triangle (with tolerance)
gp_XY V01(p1);V01-=p0;
// check these particular cases...
// 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;
-
+
if ( V01.SquareModulus() <= gp::Resolution() )
{
Standard_Real LV = V02.SquareModulus();
if ( S3D_Str_NearSegment (p0, p2, TheP, aTol, DMin) )
return 0;
- return 2;
+ return 2;
}
if ( V02.SquareModulus() <= gp::Resolution() )
{
}
// oriented normal to p0p1...
- gp_Dir2d N (-V01.Y(), V01.X());
+ gp_Dir2d N (-V01.Y(), V01.X());
Standard_Boolean Neg = (N * V02 < 0.);
- if ( Neg )
+ if ( Neg )
N.Reverse();
gp_XY Vec(TheP);
Vec -= p0;
-
+
Standard_Real aD1 = Vec * N.XY();
- if ( aD1 < -aTol )
+ if ( aD1 < -aTol )
return 2;
// oriented normal to p1p2...
N.SetCoord(p2.Y()-p1.Y(),p1.X()-p2.X());
else
N.SetCoord(p1.Y()-p2.Y(),p2.X()-p1.X());
-
+
Vec.SetCoord(TheP.X()-p1.X(),TheP.Y()-p1.Y());
Standard_Real aD2 = Vec * N.XY();
- if ( aD2 < -aTol )
+ if ( aD2 < -aTol )
return 2; // outside
// oriented normal to p2p0...
N.SetCoord(p0.Y()-p2.Y(),p2.X()-p0.X());
else
N.SetCoord(p2.Y()-p0.Y(),p0.X()-p2.X());
-
+
Vec.SetCoord(TheP.X()-p2.X(),TheP.Y()-p2.Y());
Standard_Real aD3 = Vec * N.XY();
- if ( aD3 < -aTol )
+ if ( aD3 < -aTol )
return 2; // outside
// compute 2d distance to triangle
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
+void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
// general information....
S<<"\t\t P1 [ "<<aPnt2.X()<<" , "<<aPnt2.Y()<<" , "<<aPnt2.Z()<<" ]"<<endl;
S<<"\t\t P2 [ "<<aPnt3.X()<<" , "<<aPnt3.Y()<<" , "<<aPnt3.Z()<<" ]"<<endl;
- if(FullDump)
+ if(FullDump)
{
S<<"\t\tProjected Points"<<endl;
//=======================================================================
//function : ComputeDepth
-//purpose :
+//purpose :
//=======================================================================
Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) const
P3 = mypolyg.Pnt(2);
gp_Trsf TheTrsf ;
- if(HasLocation())
+ if(HasLocation())
TheTrsf = Location().Transformation();
-
- if(TheTrsf.Form()!=gp_Identity)
+
+ if(TheTrsf.Form()!=gp_Identity)
{
P1.Transform(TheTrsf);
P2.Transform(TheTrsf);
P3.Transform(TheTrsf);
}
-
+
// formula calculation of the point parameters on intersection
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
-
+
gp_Pnt Oye = EyeLine.Location(); // origin of the target line eye/point...
gp_Dir Dir = EyeLine.Direction();
-
+
gp_Vec P1P2 (P1,P2), P1P3(P1,P3);
P1P2.Normalize();
P1P3.Normalize();
-
+
gp_Vec oP1(Oye,P1);
Standard_Real val1 = oP1.DotCross(P1P2,P1P3);
Standard_Real val2 = Dir.DotCross(P1P2,P1P3);
-
+
if(Abs(val2)>Precision::Confusion())
prof =val1/val2;
-
- if (prof==Precision::Infinite())
+
+ if (prof==Precision::Infinite())
{
prof= ElCLib::Parameter(EyeLine,P1);
prof = Min (prof, ElCLib::Parameter(EyeLine,P2));
//==================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle::
-GetConnected(const TopLoc_Location &theLocation)
+GetConnected(const TopLoc_Location &theLocation)
{
- // Create a copy of this
- Handle(Select3D_SensitiveEntity) aNewEntity =
+ // Create a copy of this
+ Handle(Select3D_SensitiveEntity) aNewEntity =
new Select3D_SensitiveTriangle(myOwnerId, mypolyg.Pnt(0), mypolyg.Pnt(1), mypolyg.Pnt(2), mytype);
- if (HasLocation())
- aNewEntity->SetLocation(Location());
+ if (HasLocation())
+ aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation);
return aNewEntity;
-}
\ No newline at end of file
+}
//=======================================================================
Select3D_SensitiveTriangulation::
-Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(Poly_Triangulation)& Trg,
- const TopLoc_Location& Loc,
- const Standard_Boolean InteriorFlag):
+Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
+ const Handle(Poly_Triangulation)& Trg,
+ const TopLoc_Location& Loc,
+ const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg),
myiniloc(Loc),
Standard_Integer nbTriangles (myTriangul->NbTriangles());
gp_XYZ cdg(0,0,0);
Standard_Integer n[3];
-
+
// to find connections in case when the border is not concerned...
- if(!myIntFlag)
+ if(!myIntFlag)
{
myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
Poly_Connect pc(myTriangul);
Standard_Integer t[3];
Standard_Integer i,j;
- for ( i = 1; i <= nbTriangles; i++)
+ for ( i = 1; i <= nbTriangles; i++)
{
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.;
- for (j = 0; j < 3; j++)
+ for (j = 0; j < 3; j++)
{
- Standard_Integer k = (j+1) % 3;
- if (t[j] == 0)
+ Standard_Integer k = (j+1) % 3;
+ if (t[j] == 0)
{
FreeE(fr) = n[j];
FreeE(fr+1)= n[k];
}
}
else{
- for (Standard_Integer i = 1; i <= nbTriangles; i++)
+ for (Standard_Integer i = 1; i <= nbTriangles; i++)
{
triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.;
//=======================================================================
Select3D_SensitiveTriangulation::
-Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(Poly_Triangulation)& Trg,
- const TopLoc_Location& Loc,
- const Handle(TColStd_HArray1OfInteger)& FreeEdges,
- const gp_Pnt& TheCDG,
+Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
+ const Handle(Poly_Triangulation)& Trg,
+ const TopLoc_Location& Loc,
+ const Handle(TColStd_HArray1OfInteger)& FreeEdges,
+ const gp_Pnt& TheCDG,
const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg),
//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::
-Matches(const Standard_Real X,
+Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
}
}
}
-
+
// Case only Test on Border of the triangulation...
- //
+ //
else
{
//Standard_Integer ifirst;
{
Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = 1e-7;
- Tolv = 1e-7;
CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=1;j<=myNodes2d.Length();j++)
//=======================================================================
Standard_Integer Select3D_SensitiveTriangulation::
-Status (const gp_XY& TheP,
+Status (const gp_XY& TheP,
const gp_XY& Proj0,
const gp_XY& Proj1,
const gp_XY& Proj2,
{
if(FreeE(I) == n[0])
{
- if(FreeE(I+1)== n[1] || FreeE(I+1)== n[2])
+ if(FreeE(I+1)== n[1] || FreeE(I+1)== n[2])
FoundIndex=I;
}
else if(FreeE(I) == n[1])
{
- if(FreeE(I+1)== n[0] || FreeE(I+1)== n[2])
+ if(FreeE(I+1)== n[0] || FreeE(I+1)== n[2])
FoundIndex=I;
}
else if(FreeE(I) == n[2])
{
- if(FreeE(I+1)== n[0] || FreeE(I+1)== n[1])
+ if(FreeE(I+1)== n[0] || FreeE(I+1)== n[1])
FoundIndex=I;
}
}
Handle(Select3D_SensitiveTriangulation) NiouEnt =
new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag);
- if(HasLocation())
+ if(HasLocation())
NiouEnt->SetLocation(Location());
// TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc;
// if(!TheLocToApply.IsIdentity())
S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl;
S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
- if(FullDump)
+ if(FullDump)
{
// S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d);
P[i].Transform(myTrsf);
}
}
-
+
// formula calculate the parameter of the point on the intersection
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
Standard_Real prof(Precision::Infinite());
for(Standard_Integer i=0;i<=2;i++)
Vtr[i] = gp_Vec(P[i%3],P[(i+1)%3]);
Vtr[2] = -Vtr[2];
-
+
// remove singular cases immediately...
Standard_Integer SingularCase(-1);
if(Vtr[0].SquareMagnitude()<= Precision::Confusion())
if(Vtr[2].SquareMagnitude()<= Precision::Confusion())
if( SingularCase < 0 ) SingularCase = 1;
#endif
-
+
// 3 pts mixed...
- if(SingularCase ==2)
+ if(SingularCase ==2)
{
prof= ElCLib::Parameter(EyeLine,P[0]);
return prof;
Vtr[2].Normalize();
gp_Vec OPo(Oye,P[0]);
// 2 points mixed... the intersection between the segment and the target line eye/point.
- //
- if(SingularCase!=-1)
+ //
+ if(SingularCase!=-1)
{
gp_Vec V = SingularCase==0 ? Vtr[2] : Vtr[0];
gp_Vec Det = Dir^V;
else if(Det.Z()> Precision::Confusion())
prof = VSM.Z()/Det.Z();
}
- else
+ else
{
Standard_Real val1 = OPo.DotCross(Vtr[0],Vtr[2]);
Standard_Real val2 = Dir.DotCross(Vtr[0],Vtr[2]);
if(Abs(val2)>Precision::Confusion())
prof =val1/val2;
}
- if (prof==Precision::Infinite())
+ if (prof==Precision::Infinite())
{
prof= ElCLib::Parameter(EyeLine,P[0]);
prof = Min (prof, ElCLib::Parameter(EyeLine,P[1]));
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::
-DetectedTriangle(gp_Pnt& P1,
- gp_Pnt& P2,
+DetectedTriangle(gp_Pnt& P1,
+ gp_Pnt& P2,
gp_Pnt& P3) const
{
if(myDetectedTr==-1) return Standard_False; // currently not implemented...
P1 = Nodes(n1);
P2 = Nodes(n2);
P3 = Nodes(n3);
- if(myTrsf.Form()!=gp_Identity)
+ if(myTrsf.Form()!=gp_Identity)
{
P1.Transform(myTrsf);
P2.Transform(myTrsf);
//=============================================================================
Standard_Boolean Select3D_SensitiveTriangulation::
-DetectedTriangle2d(gp_Pnt2d& P1,
- gp_Pnt2d& P2,
+DetectedTriangle2d(gp_Pnt2d& P1,
+ gp_Pnt2d& P2,
gp_Pnt2d& P3) const
{
- if(myDetectedTr==-1)
+ if(myDetectedTr==-1)
return Standard_False; // currently not implemented...
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
Standard_Integer n1,n2,n3;
{
if(myiniloc.IsIdentity())
myTrsf = Location().Transformation();
- else if(HasLocation())
+ else if(HasLocation())
{
myTrsf = (Location()*myiniloc).Transformation();
}
else
myTrsf = myiniloc.Transformation();
}
- else
+ else
{
gp_Trsf TheId;
myTrsf = TheId;