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

Merge OCC22357 and replacing french comments by english one

This commit is contained in:
bugmaster 2011-04-28 16:36:12 +00:00 committed by bugmaster
parent d4c2114a1d
commit 4bf18dff31
3 changed files with 136 additions and 169 deletions

View File

@ -8,6 +8,7 @@
//Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
#include <Select3D_SensitiveFace.ixx>
#include <Select3D_Projector.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
@ -117,11 +118,9 @@ Matches(const Standard_Real X,
Standard_Real valtst = PlaneTest^V1;
if(isplane2d && Abs(valtst)>aTol) isplane2d=Standard_False;
}
if(isplane2d) {
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
return Standard_True;
if (isplane2d)
{
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
}
//detection d'une auto - intersection dans le polygon 2D; si oui on sort
// if (!AutoComputeFlag(myautointer)) {
@ -152,9 +151,10 @@ Matches(const Standard_Real X,
}
}
if (res)
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
return res;
{
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
}
return Standard_False;
}
//=======================================================================
@ -230,8 +230,17 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
//=======================================================================
Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
{
Standard_Real val(Precision::Infinite());
Standard_Real aDepth = Precision::Infinite();
Standard_Real aDepthMin = !mylastprj.IsNull() ? mylastprj->DepthMin() : -Precision::Infinite();
Standard_Real aDepthMax = !mylastprj.IsNull() ? mylastprj->DepthMax() : Precision::Infinite();
Standard_Real aDepthTest;
for (Standard_Integer i = 0; i < mynbpoints - 1; i++)
val = Min(val,ElCLib::Parameter(EyeLine,((Select3D_Pnt*)mypolyg3d)[i]));
return val;
{
aDepthTest = ElCLib::Parameter (EyeLine, ((Select3D_Pnt* )mypolyg3d)[i]);
if (aDepthTest < aDepth && (aDepthTest > aDepthMin) && (aDepthTest < aDepthMax))
{
aDepth = aDepthTest;
}
}
return aDepth;
}

View File

@ -89,7 +89,7 @@ void Select3D_SensitiveGroup::Clear()
//purpose :
//=======================================================================
void Select3D_SensitiveGroup::Project(const Select3D_Projector& aProjector)
void Select3D_SensitiveGroup::Project(const Handle(Select3D_Projector)& aProjector)
{
Select3D_SensitiveEntity::Project(aProjector); // to set the field last proj...
@ -180,16 +180,16 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
myLastTol = aTol;
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
myLastRank++;
if(It.Value()->Matches(X,Y,aTol,DMin)){
if (It.Value()->Matches (X, Y, aTol, DMin))
{
myX = X; myY = Y; myLastTol = aTol;
SetLastDepth( Precision::Infinite() );
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
return Standard_True;
// compute and validate the depth (will call ::ComputeDepth())
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
}
}
// no match
myLastRank = 0;
SetLastDepth(0.0);
SetLastDepth (ShortRealLast());
return Standard_False;
}
@ -258,18 +258,25 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
//=======================================================================
Standard_Real Select3D_SensitiveGroup::ComputeDepth(const gp_Lin& EyeLine) const
{
Standard_Integer currank(0);
Standard_Integer currank = 0;
Standard_Real DMin, thedepth (Precision::Infinite());
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
for (Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
{
currank++;
if(currank>=myLastRank){
if(It.Value()->Matches(myX,myY,myLastTol,DMin)){
if (currank >= myLastRank)
{
// this recomputes and validates the depth for the entity
if (It.Value()->Matches (myX, myY, myLastTol, DMin))
{
It.Value()->ComputeDepth (EyeLine);
thedepth = Min(Depth(),
It.Value()->Depth());
if (It.Value()->Depth() < thedepth)
{
// search for topmost entity
thedepth = It.Value()->Depth();
//myLastRank = currank; // can not do this here...
}
}
}
}
return thedepth;
}
@ -287,7 +294,7 @@ Standard_Integer Select3D_SensitiveGroup::MaxBoxes() const
return nbboxes;
}
void Select3D_SensitiveGroup::SetLastPrj(const Select3D_Projector& Prj)
void Select3D_SensitiveGroup::SetLastPrj(const Handle(Select3D_Projector)& Prj)
{
Select3D_SensitiveEntity::SetLastPrj(Prj);
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())

View File

@ -11,6 +11,7 @@
#include <Select3D_SensitiveTriangulation.ixx>
#include <gp_Pnt2d.hxx>
#include <Poly.hxx>
#include <Poly_Connect.hxx>
#include <CSLib_Class2d.hxx>
#include <TColStd_Array1OfInteger.hxx>
@ -184,7 +185,7 @@ myDetectedTr(-1)
//purpose :
//=======================================================================
void Select3D_SensitiveTriangulation::Project(const Select3D_Projector& aPrj)
void Select3D_SensitiveTriangulation::Project(const Handle(Select3D_Projector)& aPrj)
{
Select3D_SensitiveEntity::Project(aPrj); // to set the field last proj...
@ -195,15 +196,15 @@ void Select3D_SensitiveTriangulation::Project(const Select3D_Projector& aPrj)
for(Standard_Integer I=1;I<=myTriangul->NbNodes();I++){
if(myTrsf.Form()!=gp_Identity)
aPrj.Project(Nodes(I).Transformed(myTrsf),ProjPT);
aPrj->Project(Nodes(I).Transformed(myTrsf),ProjPT);
else
aPrj.Project(Nodes(I),ProjPT);
aPrj->Project(Nodes(I),ProjPT);
myNodes2d.SetValue(I,ProjPT);
mybox2d.Add(ProjPT);
}
aPrj.Project(myCDG3D,myCDG2D);
aPrj->Project(myCDG3D,myCDG2D);
}
//=======================================================================
@ -216,59 +217,6 @@ void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
boxes.Append(mybox2d);
}
//=======================================================================
//function : getUV
//purpose : compute parameters of the picked point on triangle in 2d
// Note: parameters of point P on triangle (P1, P2, P3) are defined
// as U and V such that P = P1 + U * (P2 - P1) + V * (P3 - P1);
// Range: U >= 0, V >= 0, U + V <= 1
//=======================================================================
static gp_XY getUV (const gp_XY& aP2d1, const gp_XY& aP2d2, const gp_XY& aP2d3,
const gp_XY& aPick)
{
gp_XY aDU = aP2d2 - aP2d1;
gp_XY aDV = aP2d3 - aP2d1;
Standard_Real aDet = aDU ^ aDV;
// case of non-degenerated triangle
gp_XY aDP = aPick - aP2d1;
if ( Abs (aDet) > gp::Resolution() )
{
Standard_Real aU = (aDP ^ aDV) / aDet;
Standard_Real aV = -(aDP ^ aDU) / aDet;
if ( aU < 0. ) aU = 0.;
if ( aV < 0. ) aV = 0.;
if ( aU + aV > 1. ) { Standard_Real aD = aU + aV; aU /= aD; aV /= aD; }
return gp_XY (aU, aV);
}
// degenerated case (in 2d projection)
Standard_Real aL2U = aDU.SquareModulus();
Standard_Real aL2V = aDV.SquareModulus();
if ( aL2U < gp::Resolution() ) // side 1-2 is degenerated
{
if ( aL2V < gp::Resolution() ) // whole triangle is degenerated to point
return gp_XY (0., 0.);
else
return gp_XY (0., (aDP * aDV) / aL2V);
}
else if ( aL2V < gp::Resolution() ) // side 1-3 is degenerated
return gp_XY ((aDP * aDU) / aL2U, 0.);
else // sides 1-2 and 1-3 are collinear
{
// select parameter on one of sides so as to have points closer to picked
Standard_Real aU = Min (1., Max (0., (aDP * aDU) / aL2U));
Standard_Real aV = Min (1., Max (0., (aDP * aDV) / aL2V));
gp_XY aP2dU = aP2d1 + aU * aDU;
gp_XY aP2dV = aP2d1 + aV * aDV;
if ( (aPick - aP2dU).SquareModulus() < (aPick - aP2dV).SquareModulus() )
return gp_XY ((aDP * aDU) / aL2U, 0.);
else
return gp_XY (0., (aDP * aDV) / aL2V);
}
}
//=======================================================================
//function : Matches
//purpose :
@ -279,7 +227,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
Standard_Real& DMin)
{
// get view direction (necessary for calculation of depth) from field mylastprj of the base class
if ( ! mylastprj )
if (mylastprj.IsNull())
return Standard_False;
DMin = Precision::Infinite();
@ -290,7 +238,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
// it is checked if we are inside the triangle 2d.
if(myIntFlag)
{
gp_Lin EyeLine = (*((Select3D_Projector*)mylastprj)).Shoot(X,Y);
gp_Lin EyeLine = mylastprj->Shoot(X,Y);
if ( myTrsf.Form()!=gp_Identity )
EyeLine.Transform (myTrsf.Inverted());
@ -303,24 +251,26 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
const gp_XY& aPnt2d1 = myNodes2d(n1).XY();
const gp_XY& aPnt2d2 = myNodes2d(n2).XY();
const gp_XY& aPnt2d3 = myNodes2d(n3).XY();
Standard_Real DD = 0.;
if (Status (BidPoint, aPnt2d1, aPnt2d2, aPnt2d3, aTol, DD) == 2)
gp_XY aUV;
Standard_Real aDistSquare = Poly::PointOnTriangle (aPnt2d1, aPnt2d2, aPnt2d3, BidPoint, aUV);
if ( aDistSquare > aTol * aTol )
continue;
// compute depth on this triangle
gp_XY aUV = getUV (aPnt2d1, aPnt2d2, aPnt2d3, BidPoint);
Standard_Real aDepth1 = ElCLib::Parameter (EyeLine, Nodes(n1));
Standard_Real aDepth2 = ElCLib::Parameter (EyeLine, Nodes(n2));
Standard_Real aDepth3 = ElCLib::Parameter (EyeLine, Nodes(n3));
Standard_Real aDepth = aDepth1 + aUV.X() * (aDepth2 - aDepth1) +
aUV.Y() * (aDepth3 - aDepth1);
// take triangle with lowest depth
if ( aDepth < aMinDepth )
// take triangle with lowest depth and within defined depth interval
if (aDepth < aMinDepth &&
aDepth > mylastprj->DepthMin() &&
aDepth < mylastprj->DepthMax())
{
aMinDepth = aDepth;
myDetectedTr = itr;
DMin = DD;
DMin = Sqrt (aDistSquare);
}
}
}
@ -358,8 +308,9 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
}
if ( myDetectedTr <= 0 )
return Standard_False;
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
return Standard_True;
// compute and validate the depth (::Depth()) along the eyeline
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
}