1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-05 11:24:17 +03:00

0023728: Unused variables "Tolu" and "Tolv" in Select3D

This commit is contained in:
kgv 2013-01-26 23:39:56 +04:00 committed by kgv
parent 3616fc066e
commit aec37c1569
7 changed files with 180 additions and 201 deletions

View File

@ -66,8 +66,8 @@ static Standard_Integer S3D_GetArcNBPoints(const Handle(Geom_Circle)& C,
//======================================================================= //=======================================================================
Select3D_SensitiveCircle:: Select3D_SensitiveCircle::
Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Circle)& TheCircle, const Handle(Geom_Circle)& TheCircle,
const Standard_Boolean FilledCircle, const Standard_Boolean FilledCircle,
const Standard_Integer NbPoints): const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, S3D_GetCircleNBPoints(TheCircle,NbPoints)), Select3D_SensitivePoly(OwnerId, S3D_GetCircleNBPoints(TheCircle,NbPoints)),
@ -89,7 +89,7 @@ myend(0)
for(Standard_Integer anIndex=1;anIndex<=NbPoints;anIndex++) for(Standard_Integer anIndex=1;anIndex<=NbPoints;anIndex++)
{ {
TheCircle->D1(curu,p1,v1); TheCircle->D1(curu,p1,v1);
v1.Normalize(); v1.Normalize();
mypolyg.SetPnt(rank-1, p1); mypolyg.SetPnt(rank-1, p1);
rank++; rank++;
@ -121,7 +121,7 @@ myend(0)
//======================================================================= //=======================================================================
Select3D_SensitiveCircle:: Select3D_SensitiveCircle::
Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom_Circle)& TheCircle, const Handle(Geom_Circle)& TheCircle,
const Standard_Real u1, const Standard_Real u1,
const Standard_Real u2, const Standard_Real u2,
@ -138,18 +138,18 @@ myend(u2)
{ {
gp_Pnt p1,p2; gp_Pnt p1,p2;
gp_Vec v1; gp_Vec v1;
if (u1 > u2) if (u1 > u2)
{ {
mystart = u2; mystart = u2;
myend = u1; myend = u1;
} }
Standard_Real du = (myend-mystart)/(NbPoints-1); Standard_Real du = (myend-mystart)/(NbPoints-1);
Standard_Real R = TheCircle->Radius(); Standard_Real R = TheCircle->Radius();
Standard_Integer rank = 1; Standard_Integer rank = 1;
Standard_Real curu = mystart; Standard_Real curu = mystart;
for(Standard_Integer anIndex=1;anIndex<=NbPoints-1;anIndex++) for(Standard_Integer anIndex=1;anIndex<=NbPoints-1;anIndex++)
{ {
TheCircle->D1(curu,p1,v1); TheCircle->D1(curu,p1,v1);
@ -165,7 +165,7 @@ myend(u2)
} }
TheCircle->D0(myend,p1); TheCircle->D0(myend,p1);
mypolyg.SetPnt(NbPoints*2-2, p1); mypolyg.SetPnt(NbPoints*2-2, p1);
// Get myCenter3D // Get myCenter3D
myCenter3D = TheCircle->Location(); myCenter3D = TheCircle->Location();
} }
else else
@ -178,7 +178,7 @@ myend(u2)
//======================================================================= //=======================================================================
//function : Select3D_SensitiveCircle //function : Select3D_SensitiveCircle
//purpose : //purpose :
//======================================================================= //=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
@ -198,7 +198,7 @@ myend(0)
//======================================================================= //=======================================================================
//function : Select3D_SensitiveCircle //function : Select3D_SensitiveCircle
//purpose : //purpose :
//======================================================================= //=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
@ -218,7 +218,7 @@ myend(0)
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveCircle:: Standard_Boolean Select3D_SensitiveCircle::
@ -232,7 +232,7 @@ Matches(const Standard_Real X,
{ {
Standard_Boolean Found = Standard_False; Standard_Boolean Found = Standard_False;
Standard_Integer anIndex = 0; Standard_Integer anIndex = 0;
if(!myFillStatus) if(!myFillStatus)
{ {
while(anIndex < aSize-2 && !Found) while(anIndex < aSize-2 && !Found)
@ -258,11 +258,11 @@ Matches(const Standard_Real X,
// Fill anArrayOf2dPnt with points from mypolig2d // Fill anArrayOf2dPnt with points from mypolig2d
Points2D(anArrayOf2dPnt); Points2D(anArrayOf2dPnt);
CSLib_Class2d anInOutTool(anArrayOf2dPnt,aTol,aTol,Xmin,Ymin,Xmax,Ymax); CSLib_Class2d anInOutTool(anArrayOf2dPnt,aTol,aTol,Xmin,Ymin,Xmax,Ymax);
// Method SiDans returns the status : // 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 // 0 - the point is on the circle
// -1 - the point is outside the circle // -1 - the point is outside the circle
Standard_Integer aStat = anInOutTool.SiDans(gp_Pnt2d(X,Y)); Standard_Integer aStat = anInOutTool.SiDans(gp_Pnt2d(X,Y));
@ -270,7 +270,7 @@ Matches(const Standard_Real X,
{ {
// Compute DMin (a distance between the center and the point) // Compute DMin (a distance between the center and the point)
DMin = gp_XY(myCenter2D.x - X, myCenter2D.y - Y).Modulus(); 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_True;
} }
return Standard_False; return Standard_False;
@ -291,7 +291,7 @@ Matches(const Standard_Real X,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveCircle:: Standard_Boolean Select3D_SensitiveCircle::
@ -316,7 +316,7 @@ Matches(const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveCircle:: Standard_Boolean Select3D_SensitiveCircle::
@ -327,9 +327,6 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
myDetectedIndex = -1; myDetectedIndex = -1;
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex) for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex)
@ -343,7 +340,7 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//======================================================================= //=======================================================================
//function : ArrayBounds //function : ArrayBounds
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveCircle:: void Select3D_SensitiveCircle::
@ -356,7 +353,7 @@ ArrayBounds(Standard_Integer & Low,
//======================================================================= //=======================================================================
//function : GetPoint3d //function : GetPoint3d
//purpose : //purpose :
//======================================================================= //=======================================================================
gp_Pnt Select3D_SensitiveCircle:: gp_Pnt Select3D_SensitiveCircle::
@ -370,24 +367,24 @@ GetPoint3d(const Standard_Integer Rank) const
//======================================================================= //=======================================================================
//function : Dump //function : Dump
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{ {
Standard_Integer aSize = mypolyg.Size(); Standard_Integer aSize = mypolyg.Size();
S<<"\tSensitiveCircle 3D :"; S<<"\tSensitiveCircle 3D :";
Standard_Boolean isclosed = 1== aSize; Standard_Boolean isclosed = 1== aSize;
if(isclosed) if(isclosed)
S<<"(Closed Circle)"<<endl; S<<"(Closed Circle)"<<endl;
else else
S<<"(Arc Of Circle)"<<endl; S<<"(Arc Of Circle)"<<endl;
if(HasLocation()) if(HasLocation())
S<<"\t\tExisting Location"<<endl; S<<"\t\tExisting Location"<<endl;
if(FullDump) if(FullDump)
{ {
@ -401,7 +398,7 @@ void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean F
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) const
@ -423,12 +420,12 @@ Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) cons
//======================================================================= //=======================================================================
//function : GetConnected //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; Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Circle) // this was constructed using Handle(Geom_Circle)
if(!myCircle.IsNull()) if(!myCircle.IsNull())
@ -445,7 +442,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const To
} }
} }
// this was constructed using TColgp_Array1OfPnt // this was constructed using TColgp_Array1OfPnt
else else
{ {
Standard_Integer aSize = mypolyg.Size(); Standard_Integer aSize = mypolyg.Size();
TColgp_Array1OfPnt aPolyg(1, aSize); TColgp_Array1OfPnt aPolyg(1, aSize);
@ -457,7 +454,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const To
} }
if(HasLocation()) if(HasLocation())
aNewEntity->SetLocation(Location()); aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation); aNewEntity->UpdateLocation(theLocation);
@ -466,12 +463,12 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected(const To
//======================================================================= //=======================================================================
//function : Project //function : Project
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProjector) void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProjector)
{ {
Select3D_SensitivePoly::Project(aProjector); Select3D_SensitivePoly::Project(aProjector);
gp_Pnt2d aCenter; gp_Pnt2d aCenter;
aProjector->Project(myCenter3D, aCenter); aProjector->Project(myCenter3D, aCenter);
myCenter2D = aCenter; myCenter2D = aCenter;
@ -479,7 +476,7 @@ void Select3D_SensitiveCircle::Project(const Handle_Select3D_Projector &aProject
//======================================================================= //=======================================================================
//function : ComputeCenter3D //function : ComputeCenter3D
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveCircle::ComputeCenter3D() void Select3D_SensitiveCircle::ComputeCenter3D()

View File

@ -39,7 +39,7 @@ Select3D_SensitiveCurve
const Handle(Geom_Curve)& C, const Handle(Geom_Curve)& C,
const Standard_Integer NbPoints): const Standard_Integer NbPoints):
Select3D_SensitivePoly(OwnerId, NbPoints), Select3D_SensitivePoly(OwnerId, NbPoints),
mylastseg(0), mylastseg(0),
myCurve(C) myCurve(C)
{ {
LoadPoints(C,NbPoints); LoadPoints(C,NbPoints);
@ -113,7 +113,7 @@ Matches (const Standard_Real XMin,
{ {
Bnd_Box2d BoundBox; Bnd_Box2d BoundBox;
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol); BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
for(Standard_Integer anIndex=0; anIndex<mypolyg.Size(); ++anIndex) for(Standard_Integer anIndex=0; anIndex<mypolyg.Size(); ++anIndex)
{ {
if(BoundBox.IsOut(mypolyg.Pnt2d(anIndex))) if(BoundBox.IsOut(mypolyg.Pnt2d(anIndex)))
@ -124,7 +124,7 @@ Matches (const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveCurve:: Standard_Boolean Select3D_SensitiveCurve::
@ -134,9 +134,6 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex) for(Standard_Integer anIndex=0;anIndex<mypolyg.Size();++anIndex)
@ -156,7 +153,7 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
void Select3D_SensitiveCurve void Select3D_SensitiveCurve
::LoadPoints (const Handle(Geom_Curve)& aCurve,const Standard_Integer NbP) ::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*/ That's why check !NbP==mypolyg3d->Length() was removed*/
Standard_Real Step = (aCurve->LastParameter()- aCurve->FirstParameter())/(NbP-1); Standard_Real Step = (aCurve->LastParameter()- aCurve->FirstParameter())/(NbP-1);
@ -170,10 +167,10 @@ void Select3D_SensitiveCurve
//======================================================================= //=======================================================================
//function : Dump //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; S<<"\tSensitiveCurve 3D :"<<endl;
if (HasLocation()) if (HasLocation())
@ -189,7 +186,7 @@ void Select3D_SensitiveCurve::Dump(Standard_OStream& S,const Standard_Boolean Fu
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitiveCurve::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitiveCurve::ComputeDepth(const gp_Lin& EyeLine) const
@ -219,35 +216,35 @@ Standard_Real Select3D_SensitiveCurve::ComputeDepth(const gp_Lin& EyeLine) const
//======================================================================= //=======================================================================
//function : GetConnected //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; Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Curve) // this was constructed using Handle(Geom_Curve)
if (!myCurve.IsNull()) if (!myCurve.IsNull())
{ {
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, myCurve); aNewEntity = new Select3D_SensitiveCurve(myOwnerId, myCurve);
} }
// this was constructed using TColgp_HArray1OfPnt // this was constructed using TColgp_HArray1OfPnt
else else
{ {
Standard_Integer aSize = mypolyg.Size(); Standard_Integer aSize = mypolyg.Size();
Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt(1, aSize); Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt(1, aSize);
// Fill the array with points from mypolyg3d // 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)); aPoints->SetValue(anIndex, mypolyg.Pnt(anIndex-1));
} }
aNewEntity = new Select3D_SensitiveCurve(myOwnerId, aPoints); aNewEntity = new Select3D_SensitiveCurve(myOwnerId, aPoints);
} }
if (HasLocation()) if (HasLocation())
aNewEntity->SetLocation(Location()); aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation); aNewEntity->UpdateLocation(theLocation);
return aNewEntity; return aNewEntity;
} }

View File

@ -122,8 +122,8 @@ Matches(const Standard_Real X,
V-=mypolyg.Pnt2d(anIndex-1); V-=mypolyg.Pnt2d(anIndex-1);
Standard_Real Vector = V1^V; Standard_Real Vector = V1^V;
Standard_Real V1V1 = V1.SquareModulus(); Standard_Real V1V1 = V1.SquareModulus();
DMin2 = DMin2 =
(V1V1 <=aTol2) ? (V1V1 <=aTol2) ?
Min(DMin2,V.SquareModulus()): // if the segment is too small... Min(DMin2,V.SquareModulus()): // if the segment is too small...
Min(DMin2,Vector*Vector/V1V1); Min(DMin2,Vector*Vector/V1V1);
//cdg ... //cdg ...
@ -163,7 +163,7 @@ Matches(const Standard_Real X,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveFace:: Standard_Boolean Select3D_SensitiveFace::
@ -186,7 +186,7 @@ Matches (const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveFace:: Standard_Boolean Select3D_SensitiveFace::
@ -196,9 +196,6 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
gp_Pnt2d aPnt2d; gp_Pnt2d aPnt2d;
@ -213,7 +210,7 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//======================================================================= //=======================================================================
//function : Dump //function : Dump
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
@ -221,10 +218,10 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
S<<"\tSensitiveFace 3D :"<<endl;; S<<"\tSensitiveFace 3D :"<<endl;;
if(HasLocation()) if(HasLocation())
S<<"\t\tExisting Location"<<endl; S<<"\t\tExisting Location"<<endl;
if(mytype==Select3D_TOS_BOUNDARY) if(mytype==Select3D_TOS_BOUNDARY)
S<<"\t\tSelection Of Bounding Polyline Only"<<endl; S<<"\t\tSelection Of Bounding Polyline Only"<<endl;
if(FullDump) if(FullDump)
{ {
S<<"\t\tNumber Of Points :"<<mypolyg.Size()<<endl; S<<"\t\tNumber Of Points :"<<mypolyg.Size()<<endl;
@ -234,7 +231,7 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
@ -258,10 +255,10 @@ Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
//======================================================================= //=======================================================================
//function : GetConnected //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 // Create a copy of this
Standard_Integer aSize = mypolyg.Size(); Standard_Integer aSize = mypolyg.Size();
@ -280,4 +277,4 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected(const TopL
aNewEntity->UpdateLocation(theLocation); aNewEntity->UpdateLocation(theLocation);
return aNewEntity; return aNewEntity;
} }

View File

@ -115,30 +115,27 @@ Matches (const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitivePoint:: Standard_Boolean Select3D_SensitivePoint::
Matches (const TColgp_Array1OfPnt2d& aPoly, Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox, const Bnd_Box2d& aBox,
const Standard_Real aTol) const Standard_Real aTol)
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
Standard_Integer RES = aClassifier2d.SiDans(myprojpt); Standard_Integer RES = aClassifier2d.SiDans(myprojpt);
if(RES==1) return Standard_True; if(RES==1) return Standard_True;
return Standard_False; return Standard_False;
} }
//======================================================================= //=======================================================================
//function : Point //function : Point
//purpose : //purpose :
//======================================================================= //=======================================================================
gp_Pnt Select3D_SensitivePoint::Point() const gp_Pnt Select3D_SensitivePoint::Point() const
@ -146,10 +143,10 @@ gp_Pnt Select3D_SensitivePoint::Point() const
//======================================================================= //=======================================================================
//function : GetConnected //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); Handle(Select3D_SensitivePoint) NiouEnt = new Select3D_SensitivePoint(myOwnerId,mypoint);
if(HasLocation()) NiouEnt->SetLocation(Location()); if(HasLocation()) NiouEnt->SetLocation(Location());
@ -159,7 +156,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitivePoint::GetConnected(const Top
//======================================================================= //=======================================================================
//function : Dump //function : Dump
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitivePoint::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const void Select3D_SensitivePoint::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
@ -174,7 +171,7 @@ void Select3D_SensitivePoint::Dump(Standard_OStream& S,const Standard_Boolean Fu
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitivePoint::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitivePoint::ComputeDepth(const gp_Lin& EyeLine) const

View File

@ -43,7 +43,7 @@
//===================================================== //=====================================================
Select3D_SensitiveSegment:: Select3D_SensitiveSegment::
Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId,
const gp_Pnt& FirstP, const gp_Pnt& FirstP,
const gp_Pnt& LastP, const gp_Pnt& LastP,
const Standard_Integer MaxRect): const Standard_Integer MaxRect):
@ -65,15 +65,15 @@ void Select3D_SensitiveSegment
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj... Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
gp_Pnt2d aPoint2dStart; gp_Pnt2d aPoint2dStart;
gp_Pnt2d aPoint2dEnd; gp_Pnt2d aPoint2dEnd;
if(HasLocation()) if(HasLocation())
{ {
gp_Pnt aStart(mystart.x, mystart.y, mystart.z); gp_Pnt aStart(mystart.x, mystart.y, mystart.z);
gp_Pnt aEnd(myend.x, myend.y, myend.z); gp_Pnt aEnd(myend.x, myend.y, myend.z);
aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart); aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart);
aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd); aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd);
} }
else else
{ {
aProj->Project(mystart,aPoint2dStart); aProj->Project(mystart,aPoint2dStart);
aProj->Project(myend,aPoint2dEnd); aProj->Project(myend,aPoint2dEnd);
@ -83,7 +83,7 @@ void Select3D_SensitiveSegment
} }
//===================================================== //=====================================================
// Function : Areas // Function : Areas
// Purpose : // Purpose :
//===================================================== //=====================================================
@ -92,30 +92,30 @@ void Select3D_SensitiveSegment
{ {
// gp_Dir2d dy (0.,1.); // gp_Dir2d dy (0.,1.);
gp_Pnt2d aPStart(myprojstart.x,myprojstart.y); gp_Pnt2d aPStart(myprojstart.x,myprojstart.y);
if(aPStart.Distance(myprojend)<=Precision::Confusion()) if(aPStart.Distance(myprojend)<=Precision::Confusion())
{ {
Bnd_Box2d curbox; Bnd_Box2d curbox;
curbox.Set(myprojstart); curbox.Set(myprojstart);
theareas.Append(curbox); theareas.Append(curbox);
} }
else else
{ {
gp_Vec2d MyVec(myprojstart,myprojend);//,VAxx(gp_Dir2d(0.,1.)); gp_Vec2d MyVec(myprojstart,myprojend);//,VAxx(gp_Dir2d(0.,1.));
Standard_Real theangle = Abs(gp_Dir2d(0.,1.).Angle(gp_Vec2d(myprojstart,myprojend))); 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/2.) theangle-=M_PI/2;
if(theangle>=M_PI/12. && theangle <=5*M_PI/12.) 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 (1) = myprojstart;
BoxPoint(mymaxrect+1)=myprojend; BoxPoint(mymaxrect+1)=myprojend;
gp_Vec2d Vtr = MyVec/mymaxrect; gp_Vec2d Vtr = MyVec/mymaxrect;
Standard_Integer i; Standard_Integer i;
for ( i=2;i<=mymaxrect;i++) for ( i=2;i<=mymaxrect;i++)
{ {
BoxPoint (i) = BoxPoint (i-1).Translated(Vtr); BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);
} }
for (i=2;i<=mymaxrect+1;i++) for (i=2;i<=mymaxrect+1;i++)
{ {
Bnd_Box2d curbox; Bnd_Box2d curbox;
curbox.Set(BoxPoint(i-1)); curbox.Set(BoxPoint(i-1));
curbox.Add(BoxPoint(i)); curbox.Add(BoxPoint(i));
@ -123,10 +123,10 @@ void Select3D_SensitiveSegment
} }
} }
else else
{ {
Bnd_Box2d curbox; Bnd_Box2d curbox;
curbox.Set(myprojstart); curbox.Set(myprojstart);
curbox.Add(myprojend); curbox.Add(myprojend);
theareas.Append(curbox); theareas.Append(curbox);
} }
} }
@ -171,19 +171,16 @@ Matches (const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveSegment:: Standard_Boolean Select3D_SensitiveSegment::
Matches (const TColgp_Array1OfPnt2d& aPoly, Matches (const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox, const Bnd_Box2d& aBox,
const Standard_Real aTol) const Standard_Real aTol)
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
Standard_Integer RES = aClassifier2d.SiDans(myprojstart); Standard_Integer RES = aClassifier2d.SiDans(myprojstart);
@ -198,13 +195,13 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//======================================================================= //=======================================================================
//function : GetConnected //function : GetConnected
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveSegment:: 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); new Select3D_SensitiveSegment(myOwnerId,mystart,myend,mymaxrect);
if(HasLocation()) NiouEnt->SetLocation(Location()); if(HasLocation()) NiouEnt->SetLocation(Location());
@ -214,7 +211,7 @@ GetConnected(const TopLoc_Location& aLoc)
//======================================================================= //=======================================================================
//function : Dump //function : Dump
//purpose : //purpose :
//======================================================================= //=======================================================================
void Select3D_SensitiveSegment::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const void Select3D_SensitiveSegment::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
@ -225,11 +222,11 @@ void Select3D_SensitiveSegment::Dump(Standard_OStream& S,const Standard_Boolean
S<<"\t\t P1 [ "<<mystart.x<<" , "<<mystart.y <<" , "<<mystart.z <<" ]"<<endl; 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 P2 [ "<<myend.x<<" , "<<myend.y <<" , "<<myend.z <<" ]"<<endl;
S<<"\t\t maxrect ="<<mymaxrect<<endl; S<<"\t\t maxrect ="<<mymaxrect<<endl;
} }
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitiveSegment::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitiveSegment::ComputeDepth(const gp_Lin& EyeLine) const

View File

@ -42,7 +42,7 @@ static Standard_Boolean S3D_Str_NearSegment (const gp_XY& p0, const gp_XY& p1, c
gp_XY Vec(TheP); gp_XY Vec(TheP);
Vec -= p0; Vec -= p0;
Standard_Real u = Vec*V01.Normalized(); Standard_Real u = Vec*V01.Normalized();
if(u<-aTol) return Standard_False; if(u<-aTol) return Standard_False;
Standard_Real u1 = u-aTol; Standard_Real u1 = u-aTol;
@ -80,9 +80,9 @@ mytype (aType)
//================================================== //==================================================
Standard_Boolean Select3D_SensitiveTriangle:: Standard_Boolean Select3D_SensitiveTriangle::
Matches(const Standard_Real X, Matches(const Standard_Real X,
const Standard_Real Y, const Standard_Real Y,
const Standard_Real aTol, const Standard_Real aTol,
Standard_Real& DMin) Standard_Real& DMin)
{ {
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin); Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
@ -131,7 +131,7 @@ Matches (const Standard_Real XMin,
//======================================================================= //=======================================================================
//function : Matches //function : Matches
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveTriangle:: Standard_Boolean Select3D_SensitiveTriangle::
@ -141,9 +141,6 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer anIndex=0;anIndex<=2;++anIndex) for(Standard_Integer anIndex=0;anIndex<=2;++anIndex)
@ -211,7 +208,7 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const Standard_Real X,
//======================================================================= //=======================================================================
//function : Status //function : Status
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0, Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
@ -225,7 +222,7 @@ 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.Update(p0.X(),p0.Y());B.Update(p1.X(),p1.Y());B.Update(p2.X(),p2.Y());
B.Enlarge(aTol); B.Enlarge(aTol);
if(B.IsOut(TheP)) return 2; if(B.IsOut(TheP)) return 2;
// the point is classified corresponding to demi-spaces limited // the point is classified corresponding to demi-spaces limited
// by each side of the triangle (with tolerance) // by each side of the triangle (with tolerance)
gp_XY V01(p1);V01-=p0; gp_XY V01(p1);V01-=p0;
@ -235,9 +232,9 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
// check these particular cases... // 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...) // leave at once (it is already in the bounding box, which is good...)
DMin = aTol; DMin = aTol;
if ( V01.SquareModulus() <= gp::Resolution() ) if ( V01.SquareModulus() <= gp::Resolution() )
{ {
Standard_Real LV = V02.SquareModulus(); Standard_Real LV = V02.SquareModulus();
@ -246,7 +243,7 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
if ( S3D_Str_NearSegment (p0, p2, TheP, aTol, DMin) ) if ( S3D_Str_NearSegment (p0, p2, TheP, aTol, DMin) )
return 0; return 0;
return 2; return 2;
} }
if ( V02.SquareModulus() <= gp::Resolution() ) if ( V02.SquareModulus() <= gp::Resolution() )
{ {
@ -268,16 +265,16 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
} }
// oriented normal to p0p1... // oriented normal to p0p1...
gp_Dir2d N (-V01.Y(), V01.X()); gp_Dir2d N (-V01.Y(), V01.X());
Standard_Boolean Neg = (N * V02 < 0.); Standard_Boolean Neg = (N * V02 < 0.);
if ( Neg ) if ( Neg )
N.Reverse(); N.Reverse();
gp_XY Vec(TheP); gp_XY Vec(TheP);
Vec -= p0; Vec -= p0;
Standard_Real aD1 = Vec * N.XY(); Standard_Real aD1 = Vec * N.XY();
if ( aD1 < -aTol ) if ( aD1 < -aTol )
return 2; return 2;
// oriented normal to p1p2... // oriented normal to p1p2...
@ -285,10 +282,10 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
N.SetCoord(p2.Y()-p1.Y(),p1.X()-p2.X()); N.SetCoord(p2.Y()-p1.Y(),p1.X()-p2.X());
else else
N.SetCoord(p1.Y()-p2.Y(),p2.X()-p1.X()); N.SetCoord(p1.Y()-p2.Y(),p2.X()-p1.X());
Vec.SetCoord(TheP.X()-p1.X(),TheP.Y()-p1.Y()); Vec.SetCoord(TheP.X()-p1.X(),TheP.Y()-p1.Y());
Standard_Real aD2 = Vec * N.XY(); Standard_Real aD2 = Vec * N.XY();
if ( aD2 < -aTol ) if ( aD2 < -aTol )
return 2; // outside return 2; // outside
// oriented normal to p2p0... // oriented normal to p2p0...
@ -298,10 +295,10 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
N.SetCoord(p0.Y()-p2.Y(),p2.X()-p0.X()); N.SetCoord(p0.Y()-p2.Y(),p2.X()-p0.X());
else else
N.SetCoord(p2.Y()-p0.Y(),p0.X()-p2.X()); N.SetCoord(p2.Y()-p0.Y(),p0.X()-p2.X());
Vec.SetCoord(TheP.X()-p2.X(),TheP.Y()-p2.Y()); Vec.SetCoord(TheP.X()-p2.X(),TheP.Y()-p2.Y());
Standard_Real aD3 = Vec * N.XY(); Standard_Real aD3 = Vec * N.XY();
if ( aD3 < -aTol ) if ( aD3 < -aTol )
return 2; // outside return 2; // outside
// compute 2d distance to triangle // compute 2d distance to triangle
@ -312,10 +309,10 @@ Standard_Integer Select3D_SensitiveTriangle::Status(const gp_XY& p0,
//======================================================================= //=======================================================================
//function : Dump //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.... // general information....
@ -331,7 +328,7 @@ void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean
S<<"\t\t P1 [ "<<aPnt2.X()<<" , "<<aPnt2.Y()<<" , "<<aPnt2.Z()<<" ]"<<endl; S<<"\t\t P1 [ "<<aPnt2.X()<<" , "<<aPnt2.Y()<<" , "<<aPnt2.Z()<<" ]"<<endl;
S<<"\t\t P2 [ "<<aPnt3.X()<<" , "<<aPnt3.Y()<<" , "<<aPnt3.Z()<<" ]"<<endl; S<<"\t\t P2 [ "<<aPnt3.X()<<" , "<<aPnt3.Y()<<" , "<<aPnt3.Z()<<" ]"<<endl;
if(FullDump) if(FullDump)
{ {
S<<"\t\tProjected Points"<<endl; S<<"\t\tProjected Points"<<endl;
@ -348,7 +345,7 @@ void Select3D_SensitiveTriangle::Dump(Standard_OStream& S,const Standard_Boolean
//======================================================================= //=======================================================================
//function : ComputeDepth //function : ComputeDepth
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) const Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) const
@ -361,34 +358,34 @@ Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) co
P3 = mypolyg.Pnt(2); P3 = mypolyg.Pnt(2);
gp_Trsf TheTrsf ; gp_Trsf TheTrsf ;
if(HasLocation()) if(HasLocation())
TheTrsf = Location().Transformation(); TheTrsf = Location().Transformation();
if(TheTrsf.Form()!=gp_Identity) if(TheTrsf.Form()!=gp_Identity)
{ {
P1.Transform(TheTrsf); P1.Transform(TheTrsf);
P2.Transform(TheTrsf); P2.Transform(TheTrsf);
P3.Transform(TheTrsf); P3.Transform(TheTrsf);
} }
// formula calculation of the point parameters on intersection // formula calculation of the point parameters on intersection
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir) // t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
gp_Pnt Oye = EyeLine.Location(); // origin of the target line eye/point... gp_Pnt Oye = EyeLine.Location(); // origin of the target line eye/point...
gp_Dir Dir = EyeLine.Direction(); gp_Dir Dir = EyeLine.Direction();
gp_Vec P1P2 (P1,P2), P1P3(P1,P3); gp_Vec P1P2 (P1,P2), P1P3(P1,P3);
P1P2.Normalize(); P1P2.Normalize();
P1P3.Normalize(); P1P3.Normalize();
gp_Vec oP1(Oye,P1); gp_Vec oP1(Oye,P1);
Standard_Real val1 = oP1.DotCross(P1P2,P1P3); Standard_Real val1 = oP1.DotCross(P1P2,P1P3);
Standard_Real val2 = Dir.DotCross(P1P2,P1P3); Standard_Real val2 = Dir.DotCross(P1P2,P1P3);
if(Abs(val2)>Precision::Confusion()) if(Abs(val2)>Precision::Confusion())
prof =val1/val2; prof =val1/val2;
if (prof==Precision::Infinite()) if (prof==Precision::Infinite())
{ {
prof= ElCLib::Parameter(EyeLine,P1); prof= ElCLib::Parameter(EyeLine,P1);
prof = Min (prof, ElCLib::Parameter(EyeLine,P2)); prof = Min (prof, ElCLib::Parameter(EyeLine,P2));
@ -403,16 +400,16 @@ Standard_Real Select3D_SensitiveTriangle::ComputeDepth(const gp_Lin& EyeLine) co
//================================================== //==================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle:: Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangle::
GetConnected(const TopLoc_Location &theLocation) GetConnected(const TopLoc_Location &theLocation)
{ {
// Create a copy of this // Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity = Handle(Select3D_SensitiveEntity) aNewEntity =
new Select3D_SensitiveTriangle(myOwnerId, mypolyg.Pnt(0), mypolyg.Pnt(1), mypolyg.Pnt(2), mytype); new Select3D_SensitiveTriangle(myOwnerId, mypolyg.Pnt(0), mypolyg.Pnt(1), mypolyg.Pnt(2), mytype);
if (HasLocation()) if (HasLocation())
aNewEntity->SetLocation(Location()); aNewEntity->SetLocation(Location());
aNewEntity->UpdateLocation(theLocation); aNewEntity->UpdateLocation(theLocation);
return aNewEntity; return aNewEntity;
} }

View File

@ -113,10 +113,10 @@ static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
//======================================================================= //=======================================================================
Select3D_SensitiveTriangulation:: Select3D_SensitiveTriangulation::
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg, const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc, const TopLoc_Location& Loc,
const Standard_Boolean InteriorFlag): const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId), Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg), myTriangul(Trg),
myiniloc(Loc), myiniloc(Loc),
@ -133,24 +133,24 @@ myDetectedTr(-1)
Standard_Integer nbTriangles (myTriangul->NbTriangles()); Standard_Integer nbTriangles (myTriangul->NbTriangles());
gp_XYZ cdg(0,0,0); gp_XYZ cdg(0,0,0);
Standard_Integer n[3]; Standard_Integer n[3];
// to find connections in case when the border is not concerned... // to find connections in case when the border is not concerned...
if(!myIntFlag) if(!myIntFlag)
{ {
myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg)); myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1(); TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
Poly_Connect pc(myTriangul); Poly_Connect pc(myTriangul);
Standard_Integer t[3]; Standard_Integer t[3];
Standard_Integer i,j; 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]); pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]); triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.; 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; Standard_Integer k = (j+1) % 3;
if (t[j] == 0) if (t[j] == 0)
{ {
FreeE(fr) = n[j]; FreeE(fr) = n[j];
FreeE(fr+1)= n[k]; FreeE(fr+1)= n[k];
@ -160,7 +160,7 @@ myDetectedTr(-1)
} }
} }
else{ 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]); triangles(i).Get(n[0],n[1],n[2]);
cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.; cdg += (Nodes(n[0]).XYZ() + Nodes(n[1]).XYZ()+ Nodes(n[2]).XYZ())/3.;
@ -183,11 +183,11 @@ myDetectedTr(-1)
//======================================================================= //=======================================================================
Select3D_SensitiveTriangulation:: Select3D_SensitiveTriangulation::
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId, Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Poly_Triangulation)& Trg, const Handle(Poly_Triangulation)& Trg,
const TopLoc_Location& Loc, const TopLoc_Location& Loc,
const Handle(TColStd_HArray1OfInteger)& FreeEdges, const Handle(TColStd_HArray1OfInteger)& FreeEdges,
const gp_Pnt& TheCDG, const gp_Pnt& TheCDG,
const Standard_Boolean InteriorFlag): const Standard_Boolean InteriorFlag):
Select3D_SensitiveEntity(OwnerId), Select3D_SensitiveEntity(OwnerId),
myTriangul(Trg), myTriangul(Trg),
@ -242,7 +242,7 @@ void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation:: Standard_Boolean Select3D_SensitiveTriangulation::
Matches(const Standard_Real X, Matches(const Standard_Real X,
const Standard_Real Y, const Standard_Real Y,
const Standard_Real aTol, const Standard_Real aTol,
Standard_Real& DMin) Standard_Real& DMin)
@ -295,9 +295,9 @@ Matches(const Standard_Real X,
} }
} }
} }
// Case only Test on Border of the triangulation... // Case only Test on Border of the triangulation...
// //
else else
{ {
//Standard_Integer ifirst; //Standard_Integer ifirst;
@ -373,9 +373,6 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
{ {
Standard_Real Umin,Vmin,Umax,Vmax; Standard_Real Umin,Vmin,Umax,Vmax;
aBox.Get(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); CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
for(Standard_Integer j=1;j<=myNodes2d.Length();j++) for(Standard_Integer j=1;j<=myNodes2d.Length();j++)
@ -392,7 +389,7 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//======================================================================= //=======================================================================
Standard_Integer Select3D_SensitiveTriangulation:: Standard_Integer Select3D_SensitiveTriangulation::
Status (const gp_XY& TheP, Status (const gp_XY& TheP,
const gp_XY& Proj0, const gp_XY& Proj0,
const gp_XY& Proj1, const gp_XY& Proj1,
const gp_XY& Proj2, const gp_XY& Proj2,
@ -420,17 +417,17 @@ Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer
{ {
if(FreeE(I) == n[0]) 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; FoundIndex=I;
} }
else if(FreeE(I) == n[1]) 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; FoundIndex=I;
} }
else if(FreeE(I) == n[2]) 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; FoundIndex=I;
} }
} }
@ -450,7 +447,7 @@ GetConnected(const TopLoc_Location& aLoc)
Handle(Select3D_SensitiveTriangulation) NiouEnt = Handle(Select3D_SensitiveTriangulation) NiouEnt =
new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag); new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag);
if(HasLocation()) if(HasLocation())
NiouEnt->SetLocation(Location()); NiouEnt->SetLocation(Location());
// TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc; // TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc;
// if(!TheLocToApply.IsIdentity()) // if(!TheLocToApply.IsIdentity())
@ -500,7 +497,7 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl; S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl;
S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl; S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
if(FullDump) if(FullDump)
{ {
// S<<"\t\t\tOwner:"<<myOwnerId<<endl; // S<<"\t\t\tOwner:"<<myOwnerId<<endl;
Select3D_SensitiveEntity::DumpBox(S,mybox2d); Select3D_SensitiveEntity::DumpBox(S,mybox2d);
@ -529,7 +526,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
P[i].Transform(myTrsf); P[i].Transform(myTrsf);
} }
} }
// formula calculate the parameter of the point on the intersection // formula calculate the parameter of the point on the intersection
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir) // t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
Standard_Real prof(Precision::Infinite()); Standard_Real prof(Precision::Infinite());
@ -540,7 +537,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
for(Standard_Integer i=0;i<=2;i++) for(Standard_Integer i=0;i<=2;i++)
Vtr[i] = gp_Vec(P[i%3],P[(i+1)%3]); Vtr[i] = gp_Vec(P[i%3],P[(i+1)%3]);
Vtr[2] = -Vtr[2]; Vtr[2] = -Vtr[2];
// remove singular cases immediately... // remove singular cases immediately...
Standard_Integer SingularCase(-1); Standard_Integer SingularCase(-1);
if(Vtr[0].SquareMagnitude()<= Precision::Confusion()) if(Vtr[0].SquareMagnitude()<= Precision::Confusion())
@ -551,9 +548,9 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
if(Vtr[2].SquareMagnitude()<= Precision::Confusion()) if(Vtr[2].SquareMagnitude()<= Precision::Confusion())
if( SingularCase < 0 ) SingularCase = 1; if( SingularCase < 0 ) SingularCase = 1;
#endif #endif
// 3 pts mixed... // 3 pts mixed...
if(SingularCase ==2) if(SingularCase ==2)
{ {
prof= ElCLib::Parameter(EyeLine,P[0]); prof= ElCLib::Parameter(EyeLine,P[0]);
return prof; return prof;
@ -566,8 +563,8 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
Vtr[2].Normalize(); Vtr[2].Normalize();
gp_Vec OPo(Oye,P[0]); gp_Vec OPo(Oye,P[0]);
// 2 points mixed... the intersection between the segment and the target line eye/point. // 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 V = SingularCase==0 ? Vtr[2] : Vtr[0];
gp_Vec Det = Dir^V; gp_Vec Det = Dir^V;
@ -579,7 +576,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
else if(Det.Z()> Precision::Confusion()) else if(Det.Z()> Precision::Confusion())
prof = VSM.Z()/Det.Z(); prof = VSM.Z()/Det.Z();
} }
else else
{ {
Standard_Real val1 = OPo.DotCross(Vtr[0],Vtr[2]); Standard_Real val1 = OPo.DotCross(Vtr[0],Vtr[2]);
Standard_Real val2 = Dir.DotCross(Vtr[0],Vtr[2]); Standard_Real val2 = Dir.DotCross(Vtr[0],Vtr[2]);
@ -587,7 +584,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
if(Abs(val2)>Precision::Confusion()) if(Abs(val2)>Precision::Confusion())
prof =val1/val2; prof =val1/val2;
} }
if (prof==Precision::Infinite()) if (prof==Precision::Infinite())
{ {
prof= ElCLib::Parameter(EyeLine,P[0]); prof= ElCLib::Parameter(EyeLine,P[0]);
prof = Min (prof, ElCLib::Parameter(EyeLine,P[1])); prof = Min (prof, ElCLib::Parameter(EyeLine,P[1]));
@ -603,8 +600,8 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
//======================================================================= //=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation:: Standard_Boolean Select3D_SensitiveTriangulation::
DetectedTriangle(gp_Pnt& P1, DetectedTriangle(gp_Pnt& P1,
gp_Pnt& P2, gp_Pnt& P2,
gp_Pnt& P3) const gp_Pnt& P3) const
{ {
if(myDetectedTr==-1) return Standard_False; // currently not implemented... if(myDetectedTr==-1) return Standard_False; // currently not implemented...
@ -616,7 +613,7 @@ DetectedTriangle(gp_Pnt& P1,
P1 = Nodes(n1); P1 = Nodes(n1);
P2 = Nodes(n2); P2 = Nodes(n2);
P3 = Nodes(n3); P3 = Nodes(n3);
if(myTrsf.Form()!=gp_Identity) if(myTrsf.Form()!=gp_Identity)
{ {
P1.Transform(myTrsf); P1.Transform(myTrsf);
P2.Transform(myTrsf); P2.Transform(myTrsf);
@ -632,11 +629,11 @@ DetectedTriangle(gp_Pnt& P1,
//============================================================================= //=============================================================================
Standard_Boolean Select3D_SensitiveTriangulation:: Standard_Boolean Select3D_SensitiveTriangulation::
DetectedTriangle2d(gp_Pnt2d& P1, DetectedTriangle2d(gp_Pnt2d& P1,
gp_Pnt2d& P2, gp_Pnt2d& P2,
gp_Pnt2d& P3) const gp_Pnt2d& P3) const
{ {
if(myDetectedTr==-1) if(myDetectedTr==-1)
return Standard_False; // currently not implemented... return Standard_False; // currently not implemented...
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles(); const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
Standard_Integer n1,n2,n3; Standard_Integer n1,n2,n3;
@ -670,14 +667,14 @@ void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
{ {
if(myiniloc.IsIdentity()) if(myiniloc.IsIdentity())
myTrsf = Location().Transformation(); myTrsf = Location().Transformation();
else if(HasLocation()) else if(HasLocation())
{ {
myTrsf = (Location()*myiniloc).Transformation(); myTrsf = (Location()*myiniloc).Transformation();
} }
else else
myTrsf = myiniloc.Transformation(); myTrsf = myiniloc.Transformation();
} }
else else
{ {
gp_Trsf TheId; gp_Trsf TheId;
myTrsf = TheId; myTrsf = TheId;