mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-02 17:46:22 +03:00
OCC22357 Hidden face selection
This commit is contained in:
parent
256d432045
commit
4952a30a49
@ -20,8 +20,6 @@
|
||||
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
|
||||
#include <AIS_Selection.hxx>
|
||||
|
||||
|
||||
static TColStd_ListIteratorOfListOfInteger ItL;
|
||||
//=======================================================================
|
||||
//function : OpenLocalContext
|
||||
//purpose :
|
||||
@ -64,21 +62,13 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
|
||||
UseDisplayedObjects,
|
||||
AllowShapeDecomposition,
|
||||
AcceptEraseOfTemporary);
|
||||
|
||||
// rob 16/04/97 pour les Pbs d'ordres asynchrones
|
||||
if(myLocalContexts.Extent()>0){
|
||||
const Select3D_Projector& Prj = myLocalContexts(untilnow)->MainSelector()->Projector();
|
||||
NewLocal->MainSelector()->Set(Prj);
|
||||
}
|
||||
else{
|
||||
const Select3D_Projector& Prj = myMainSel->Projector();
|
||||
NewLocal->MainSelector()->Set(Prj);
|
||||
}
|
||||
|
||||
NewLocal->MainSelector()->UpdateConversion();
|
||||
|
||||
myLocalContexts.Bind(myCurLocalIndex,NewLocal);
|
||||
NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 0)
|
||||
? myLocalContexts (untilnow)->MainSelector()->Projector()
|
||||
: myMainSel->Projector());
|
||||
|
||||
NewLocal->MainSelector()->UpdateConversion();
|
||||
|
||||
myLocalContexts.Bind(myCurLocalIndex,NewLocal);
|
||||
|
||||
#ifdef DEB
|
||||
cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
|
||||
@ -93,7 +83,6 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
|
||||
cout<<"\t\tNo Objects Were Loaded "<<endl;
|
||||
#endif
|
||||
return myCurLocalIndex;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -268,6 +257,7 @@ Deactivate(const Handle(AIS_InteractiveObject)& anIObj)
|
||||
{
|
||||
if(!HasOpenedContext()){
|
||||
if(!myObjects.IsBound(anIObj)) return;
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
|
||||
ItL.More();
|
||||
ItL.Next()){
|
||||
@ -312,9 +302,9 @@ void AIS_InteractiveContext::
|
||||
ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
TColStd_ListOfInteger& theList) const
|
||||
{
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
if(!HasOpenedContext()){
|
||||
if(myObjects.IsBound(anIObj)){
|
||||
//ItL est une variable statique...
|
||||
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
|
||||
ItL.More();
|
||||
ItL.Next())
|
||||
@ -393,6 +383,7 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
if(myObjects.IsBound(anIObj)){
|
||||
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
|
||||
STAT->SubIntensityOn();
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
|
||||
myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
|
||||
}
|
||||
@ -446,6 +437,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
|
||||
if(myObjects.IsBound(anIObj)){
|
||||
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
|
||||
STAT->SubIntensityOff();
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
|
||||
myMainPM->Unhighlight(anIObj,ItL.Value());
|
||||
if(STAT->IsHilighted())
|
||||
@ -489,11 +481,10 @@ void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer)
|
||||
{
|
||||
|
||||
if(!HasOpenedContext()) return;
|
||||
|
||||
|
||||
AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
|
||||
|
||||
TColStd_ListIteratorOfListOfInteger ItL;
|
||||
for(;It.More();It.Next()){
|
||||
const Handle(AIS_GlobalStatus)& STAT = It.Value();
|
||||
if(STAT->IsSubIntensityOn())
|
||||
@ -501,7 +492,7 @@ void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer
|
||||
for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
|
||||
myMainPM->Unhighlight(It.Key());
|
||||
}
|
||||
|
||||
|
||||
if(updateviewer) myMainVwr->Update();
|
||||
}
|
||||
|
||||
@ -877,7 +868,7 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie
|
||||
{
|
||||
Standard_Boolean upd_main(Standard_False),upd_col(Standard_False);
|
||||
TColStd_ListIteratorOfListOfInteger itl;
|
||||
|
||||
|
||||
for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){
|
||||
const Handle(AIS_InteractiveObject)& iobj = it.Key();
|
||||
const Handle(AIS_GlobalStatus)& STAT = it.Value();
|
||||
|
@ -660,22 +660,25 @@ void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
|
||||
|
||||
|
||||
|
||||
Standard_Boolean AIS_LocalContext::HasSameProjector(const Select3D_Projector& aPrj) const
|
||||
Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const
|
||||
{
|
||||
const Select3D_Projector& CurPrj = myMainVS->Projector();
|
||||
if(CurPrj.Perspective()!=aPrj.Perspective()) return Standard_False;
|
||||
if(CurPrj.Perspective())
|
||||
if(CurPrj.Focus()!=aPrj.Focus()) return Standard_False;
|
||||
gp_GTrsf CurTrsf(CurPrj.Transformation());
|
||||
gp_GTrsf PrjTrsf(aPrj.Transformation());
|
||||
|
||||
for(Standard_Integer i=1;i<=3;i++){
|
||||
for(Standard_Integer j=1;j<=3;j++){
|
||||
if(CurTrsf.Value(i,j)!=PrjTrsf.Value(i,j))
|
||||
return Standard_False;
|
||||
const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector();
|
||||
if (aCurPrj->Perspective() != thePrj->Perspective())
|
||||
return Standard_False;
|
||||
if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus())
|
||||
return Standard_False;
|
||||
const gp_GTrsf& aCurTrsf = aCurPrj->Transformation();
|
||||
const gp_GTrsf& aPrjTrsf = thePrj->Transformation();
|
||||
|
||||
for (Standard_Integer i = 1; i <= 3; ++i)
|
||||
{
|
||||
for (Standard_Integer j = 1; j <= 3 ; ++j)
|
||||
{
|
||||
if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j))
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,13 @@ MeshVS_SensitiveFace::MeshVS_SensitiveFace (
|
||||
// name : MeshVS_SensitiveFace::Project
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_SensitiveFace::Project( const Select3D_Projector& aProj )
|
||||
void MeshVS_SensitiveFace::Project( const Handle(Select3D_Projector)& aProj )
|
||||
{
|
||||
Select3D_SensitiveFace::Project( aProj );
|
||||
if ( HasLocation() )
|
||||
aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
else
|
||||
aProj.Project( myCentre, myProjCentre );
|
||||
aProj->Project( myCentre, myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -139,14 +139,14 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitiveMesh::GetConnected( const TopLo
|
||||
//=======================================================================
|
||||
Standard_Real MeshVS_SensitiveMesh::ComputeDepth( const gp_Lin& /*EyeLine*/ ) const
|
||||
{
|
||||
return 0.;
|
||||
return Precision::Infinite();
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: ProjectOneCorner
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
|
||||
void MeshVS_SensitiveMesh::ProjectOneCorner(const Handle(Select3D_Projector)& theProj,
|
||||
const Standard_Real theX,
|
||||
const Standard_Real theY,
|
||||
const Standard_Real theZ)
|
||||
@ -154,9 +154,9 @@ void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
|
||||
gp_Pnt aPnt( theX, theY, theZ );
|
||||
gp_Pnt2d aProjPnt;
|
||||
if( HasLocation() )
|
||||
theProj.Project( aPnt.Transformed(Location().Transformation()), aProjPnt );
|
||||
theProj->Project( aPnt.Transformed(Location().Transformation()), aProjPnt );
|
||||
else
|
||||
theProj.Project( aPnt, aProjPnt );
|
||||
theProj->Project( aPnt, aProjPnt );
|
||||
mybox2d.Add( aProjPnt );
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
|
||||
// Function: Project
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void MeshVS_SensitiveMesh::Project(const Select3D_Projector& aProj)
|
||||
void MeshVS_SensitiveMesh::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
|
||||
|
@ -34,7 +34,7 @@ MeshVS_SensitivePolyhedron( const Handle( SelectBasics_EntityOwner )& Owner,
|
||||
// Function : Project
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
|
||||
void MeshVS_SensitivePolyhedron::Project( const Handle(Select3D_Projector)& aProjector )
|
||||
{
|
||||
Select3D_SensitiveEntity::Project( aProjector );
|
||||
|
||||
@ -55,9 +55,9 @@ void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
|
||||
{
|
||||
pnt = myNodes->Value( i );
|
||||
if( !hasLoc )
|
||||
aProjector.Project( pnt, proj );
|
||||
aProjector->Project( pnt, proj );
|
||||
else
|
||||
aProjector.Project( pnt.Transformed( Location().Transformation() ), proj );
|
||||
aProjector->Project( pnt.Transformed( Location().Transformation() ), proj );
|
||||
|
||||
myNodes2d->SetValue( i, proj.XY() );
|
||||
myCenter += proj.XY();
|
||||
@ -161,9 +161,10 @@ Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const Standard_Real X,
|
||||
}
|
||||
|
||||
if( inside )
|
||||
Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
|
||||
|
||||
return inside;
|
||||
{
|
||||
return Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
|
@ -27,13 +27,13 @@ MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
|
||||
// name : MeshVS_SensitiveSegment::Project
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void MeshVS_SensitiveSegment::Project( const Select3D_Projector& aProj )
|
||||
void MeshVS_SensitiveSegment::Project( const Handle(Select3D_Projector)& aProj )
|
||||
{
|
||||
Select3D_SensitiveSegment::Project( aProj );
|
||||
if ( HasLocation() )
|
||||
aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
|
||||
else
|
||||
aProj.Project( myCentre, myProjCentre );
|
||||
aProj->Project( myCentre, myProjCentre );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -286,23 +286,19 @@ void EXPORT call_togl_clear_immediat_mode (
|
||||
call_subr_displayCB(aview,OCC_REDRAW_WINDOW);
|
||||
#endif
|
||||
call_func_redraw_all_structs_end (aview->WsId, aFlush);
|
||||
/*
|
||||
After a redraw,
|
||||
Made the back identical to the front buffer
|
||||
*/
|
||||
if( retainmode && (partial >= 0) )
|
||||
TelCopyBuffers (aview->WsId, GL_FRONT, GL_BACK,
|
||||
xm, ym, zm, XM, YM, ZM, partial);
|
||||
// After a redraw,
|
||||
// Made the back identical to the front buffer.
|
||||
// Always perform full copy (partial update optimization is useless on mordern hardware)!
|
||||
if (retainmode)
|
||||
TelCopyBuffers (aview->WsId, GL_FRONT, GL_BACK, xm, ym, zm, XM, YM, ZM, 0);
|
||||
#ifdef TRACE
|
||||
printf(" $$$ REDRAW\n");
|
||||
#endif
|
||||
TelSetBackBufferRestored (TOn);
|
||||
} else if( partial >= 0 ) {
|
||||
/*
|
||||
Restore pixels from the back buffer.
|
||||
*/
|
||||
TelCopyBuffers (aview->WsId, GL_BACK, GL_FRONT,
|
||||
xm, ym, zm, XM, YM, ZM, partial);
|
||||
// Restore pixels from the back buffer.
|
||||
// Always perform full copy (partial update optimization is useless on mordern hardware)!
|
||||
TelCopyBuffers (aview->WsId, GL_BACK, GL_FRONT, xm, ym, zm, XM, YM, ZM, 0);
|
||||
}
|
||||
|
||||
TsmGetWSAttri (aview->WsId, WSTransient, &data);
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
-- -- File: Poly.cdl
|
||||
-- File: Poly.cdl
|
||||
-- Created: Mon Mar 6 09:38:50 1995
|
||||
-- Author: Laurent PAINNOT
|
||||
-- <lpa@metrox>
|
||||
@ -7,17 +6,17 @@
|
||||
|
||||
|
||||
|
||||
package Poly
|
||||
package Poly
|
||||
|
||||
---Purpose: This package provides classes and services to
|
||||
-- handle :
|
||||
--
|
||||
--
|
||||
-- * 3D triangular polyhedrons.
|
||||
--
|
||||
--
|
||||
-- * 3D polygons.
|
||||
--
|
||||
--
|
||||
-- * 2D polygon.
|
||||
--
|
||||
--
|
||||
-- * Tools to dump, save and restore those objects.
|
||||
|
||||
uses
|
||||
@ -26,7 +25,7 @@ uses
|
||||
TCollection,
|
||||
TColStd,
|
||||
gp,
|
||||
TColgp,
|
||||
TColgp,
|
||||
TShort
|
||||
|
||||
is
|
||||
@ -37,7 +36,7 @@ is
|
||||
|
||||
class Array1OfTriangle
|
||||
instantiates Array1 from TCollection(Triangle from Poly);
|
||||
|
||||
|
||||
class HArray1OfTriangle
|
||||
instantiates HArray1 from TCollection(Triangle from Poly,
|
||||
Array1OfTriangle from Poly);
|
||||
@ -47,7 +46,7 @@ is
|
||||
-- triangles. It is made of a nodes which are
|
||||
-- indexed. Nodes have a 3d value and a 2d value.
|
||||
-- Triangles are triplet of node indices.
|
||||
--
|
||||
--
|
||||
-- This is a Transient class.
|
||||
|
||||
|
||||
@ -64,10 +63,10 @@ is
|
||||
-- referencing a triangulation.
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
-- Tools to use triangulations
|
||||
--
|
||||
|
||||
--
|
||||
|
||||
class Connect;
|
||||
---Purpose: Computes and stores the link from nodes to
|
||||
-- triangles and from triangles to neighbouring
|
||||
@ -89,8 +88,8 @@ is
|
||||
|
||||
--
|
||||
-- Package methods
|
||||
--
|
||||
|
||||
--
|
||||
|
||||
Catenate (lstTri: ListOfTriangulation from Poly)
|
||||
returns Triangulation from Poly;
|
||||
---Purpose: Join several triangulations to one new triangulation object.
|
||||
@ -101,7 +100,7 @@ is
|
||||
Write(T : Triangulation from Poly;
|
||||
OS : in out OStream;
|
||||
Compact : Boolean = Standard_True);
|
||||
|
||||
|
||||
---Purpose: Writes the content of the triangulation <T> on the
|
||||
-- stream <OS>. If <Compact> is true this is a "save"
|
||||
-- format intended to be read back with the Read
|
||||
@ -111,7 +110,7 @@ is
|
||||
Write(P : Polygon3D from Poly;
|
||||
OS : in out OStream;
|
||||
Compact : Boolean = Standard_True);
|
||||
|
||||
|
||||
---Purpose: Writes the content of the 3D polygon <P> on the
|
||||
-- stream <OS>. If <Compact> is true this is a "save"
|
||||
-- format intended to be read back with the Read
|
||||
@ -121,7 +120,7 @@ is
|
||||
Write(P : Polygon2D from Poly;
|
||||
OS : in out OStream;
|
||||
Compact : Boolean = Standard_True);
|
||||
|
||||
|
||||
---Purpose: Writes the content of the 2D polygon <P> on the
|
||||
-- stream <OS>. If <Compact> is true this is a "save"
|
||||
-- format intended to be read back with the Read
|
||||
@ -133,32 +132,45 @@ is
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the triangulation. This is a call to the
|
||||
-- previous method with Comapct set to False.
|
||||
|
||||
|
||||
Dump(P : Polygon3D from Poly;
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the 3D polygon. This is a call to the
|
||||
-- previous method with Comapct set to False.
|
||||
|
||||
|
||||
Dump(P : Polygon2D from Poly;
|
||||
OS : in out OStream);
|
||||
---Purpose: Dumps the 2D polygon. This is a call to the
|
||||
-- previous method with Comapct set to False.
|
||||
|
||||
|
||||
|
||||
ReadTriangulation(IS : in out IStream)
|
||||
returns Triangulation from Poly;
|
||||
---Purpose: Reads a triangulation from the stream <IS>.
|
||||
|
||||
|
||||
ReadPolygon3D(IS : in out IStream)
|
||||
returns Polygon3D from Poly;
|
||||
---Purpose: Reads a 3d polygon from the stream <IS>.
|
||||
|
||||
|
||||
ReadPolygon2D(IS : in out IStream)
|
||||
returns Polygon2D from Poly;
|
||||
---Purpose: Reads a 2D polygon from the stream <IS>.
|
||||
|
||||
ComputeNormals(Tri : Triangulation from Poly);
|
||||
---Purpose: Compute node normals for face triangulation
|
||||
---Purpose: Compute node normals for face triangulation
|
||||
-- as mean normal of surrounding triangles
|
||||
|
||||
|
||||
PointOnTriangle(P1, P2, P3, P: XY from gp; UV: out XY from gp)
|
||||
returns Real;
|
||||
---Purpose: Computes parameters of the point P on triangle
|
||||
-- defined by points P1, P2, and P3, in 2d.
|
||||
-- The parameters U and V are defined so that
|
||||
-- P = P1 + U * (P2 - P1) + V * (P3 - P1),
|
||||
-- with U >= 0, V >= 0, U + V <= 1.
|
||||
-- If P is located outside of triangle, or triangle
|
||||
-- is degenerated, the returned parameters correspond
|
||||
-- to closest point, and returned value is square of
|
||||
-- the distance from original point to triangle (0 if
|
||||
-- point is inside).
|
||||
|
||||
end Poly;
|
||||
|
@ -25,8 +25,7 @@
|
||||
//purpose : Join several triangulations to one new triangulation object
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Triangulation) Poly::Catenate
|
||||
(const Poly_ListOfTriangulation& lstTri)
|
||||
Handle(Poly_Triangulation) Poly::Catenate (const Poly_ListOfTriangulation& lstTri)
|
||||
{
|
||||
Standard_Integer nNodes(0);
|
||||
Standard_Integer nTrian(0);
|
||||
@ -75,11 +74,11 @@ Handle(Poly_Triangulation) Poly::Catenate
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Write(const Handle(Poly_Triangulation)& T,
|
||||
Standard_OStream& OS,
|
||||
void Poly::Write(const Handle(Poly_Triangulation)& T,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean Compact)
|
||||
{
|
||||
OS << "Poly_Triangulation\n";
|
||||
@ -125,7 +124,7 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
|
||||
OS << UVNodes(i).Y() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!Compact) OS << "\nTriangles :\n";
|
||||
Standard_Integer nbTriangles = T->NbTriangles();
|
||||
Standard_Integer n1, n2, n3;
|
||||
@ -145,11 +144,11 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Write(const Handle(Poly_Polygon3D)& P,
|
||||
Standard_OStream& OS,
|
||||
void Poly::Write(const Handle(Poly_Polygon3D)& P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean Compact)
|
||||
{
|
||||
OS << "Poly_Polygon3D\n";
|
||||
@ -198,11 +197,11 @@ void Poly::Write(const Handle(Poly_Polygon3D)& P,
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Write(const Handle(Poly_Polygon2D)& P,
|
||||
Standard_OStream& OS,
|
||||
void Poly::Write(const Handle(Poly_Polygon2D)& P,
|
||||
Standard_OStream& OS,
|
||||
const Standard_Boolean Compact)
|
||||
{
|
||||
OS << "Poly_Polygon2D\n";
|
||||
@ -237,7 +236,7 @@ void Poly::Write(const Handle(Poly_Polygon2D)& P,
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Dump(const Handle(Poly_Triangulation)& T, Standard_OStream& OS)
|
||||
@ -248,7 +247,7 @@ void Poly::Dump(const Handle(Poly_Triangulation)& T, Standard_OStream& OS)
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Dump(const Handle(Poly_Polygon3D)& P, Standard_OStream& OS)
|
||||
@ -259,7 +258,7 @@ void Poly::Dump(const Handle(Poly_Polygon3D)& P, Standard_OStream& OS)
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::Dump(const Handle(Poly_Polygon2D)& P, Standard_OStream& OS)
|
||||
@ -270,13 +269,13 @@ void Poly::Dump(const Handle(Poly_Polygon2D)& P, Standard_OStream& OS)
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadTriangulation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
|
||||
{
|
||||
// Read a triangulation
|
||||
|
||||
|
||||
char line[100];
|
||||
IS >> line;
|
||||
if (strcmp(line,"Poly_Triangulation")) {
|
||||
@ -320,7 +319,7 @@ Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
|
||||
Triangles(i).Set(n1,n2,n3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Handle(Poly_Triangulation) T;
|
||||
|
||||
if (hasUV) T = new Poly_Triangulation(Nodes,UVNodes,Triangles);
|
||||
@ -334,13 +333,13 @@ Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPolygon3D
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
|
||||
{
|
||||
// Read a 3d polygon
|
||||
|
||||
|
||||
char line[100];
|
||||
IS >> line;
|
||||
if (strcmp(line,"Poly_Polygon3D")) {
|
||||
@ -377,7 +376,7 @@ Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
|
||||
Handle(Poly_Polygon3D) P;
|
||||
if (!hasparameters)
|
||||
P = new Poly_Polygon3D(Nodes);
|
||||
else
|
||||
else
|
||||
P = new Poly_Polygon3D(Nodes, Param);
|
||||
|
||||
P->Deflection(d);
|
||||
@ -387,13 +386,13 @@ Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPolygon3D
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
|
||||
{
|
||||
// Read a 2d polygon
|
||||
|
||||
|
||||
char line[100];
|
||||
IS >> line;
|
||||
if (strcmp(line,"Poly_Polygon2D")) {
|
||||
@ -417,9 +416,9 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
|
||||
Nodes(i).SetCoord(x,y);
|
||||
}
|
||||
|
||||
Handle(Poly_Polygon2D) P =
|
||||
Handle(Poly_Polygon2D) P =
|
||||
new Poly_Polygon2D(Nodes);
|
||||
|
||||
|
||||
P->Deflection(d);
|
||||
|
||||
return P;
|
||||
@ -427,14 +426,14 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeNormals
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
|
||||
{
|
||||
const TColgp_Array1OfPnt& arrNodes = Tri->Nodes();
|
||||
const Poly_Array1OfTriangle & arrTri = Tri->Triangles();
|
||||
Standard_Integer nbNormVal = Tri->NbNodes() * 3;
|
||||
Standard_Integer nbNormVal = Tri->NbNodes() * 3;
|
||||
const Handle(TShort_HArray1OfShortReal) Normals =
|
||||
new TShort_HArray1OfShortReal(1, nbNormVal);
|
||||
Normals->Init(0.F);
|
||||
@ -493,3 +492,107 @@ void Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
|
||||
|
||||
Tri->SetNormals(Normals);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnTriangle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real Poly::PointOnTriangle (const gp_XY& theP1, const gp_XY& theP2, const gp_XY& theP3,
|
||||
const gp_XY& theP, gp_XY& theUV)
|
||||
{
|
||||
gp_XY aDP = theP - theP1;
|
||||
gp_XY aDU = theP2 - theP1;
|
||||
gp_XY aDV = theP3 - theP1;
|
||||
Standard_Real aDet = aDU ^ aDV;
|
||||
|
||||
// case of non-degenerated triangle
|
||||
if ( Abs (aDet) > gp::Resolution() )
|
||||
{
|
||||
Standard_Real aU = (aDP ^ aDV) / aDet;
|
||||
Standard_Real aV = -(aDP ^ aDU) / aDet;
|
||||
|
||||
// if point is inside triangle, just return parameters
|
||||
if ( aU > -gp::Resolution() &&
|
||||
aV > -gp::Resolution() &&
|
||||
1. - aU - aV > -gp::Resolution() )
|
||||
{
|
||||
theUV.SetCoord (aU, aV);
|
||||
return 0.;
|
||||
}
|
||||
|
||||
// else find closest point on triangle sides; note that in general case
|
||||
// triangle can be very distorted and it is necessary to check
|
||||
// projection on all sides regardless of values of computed parameters
|
||||
|
||||
// project on side U=0
|
||||
aU = 0.;
|
||||
aV = Min (1., Max (0., (aDP * aDV) / aDV.SquareModulus()));
|
||||
Standard_Real aD = (aV * aDV - aDP).SquareModulus();
|
||||
|
||||
// project on side V=0
|
||||
Standard_Real u = Min (1., Max (0., (aDP * aDU) / aDU.SquareModulus()));
|
||||
Standard_Real d = (u * aDU - aDP).SquareModulus();
|
||||
if ( d < aD )
|
||||
{
|
||||
aU = u;
|
||||
aV = 0.;
|
||||
aD = d;
|
||||
}
|
||||
|
||||
// project on side U+V=1
|
||||
gp_XY aDUV = aDV - aDU;
|
||||
Standard_Real v = Min (1., Max (0., ((aDP - aDU) * aDUV) / aDUV.SquareModulus()));
|
||||
d = (theP2 + v * aDUV - theP).SquareModulus();
|
||||
if ( d < aD )
|
||||
{
|
||||
aU = 1. - v;
|
||||
aV = v;
|
||||
aD = d;
|
||||
}
|
||||
|
||||
theUV.SetCoord (aU, aV);
|
||||
return aD;
|
||||
}
|
||||
|
||||
// degenerated triangle
|
||||
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
|
||||
{
|
||||
theUV.SetCoord (0., 0.);
|
||||
return (theP - theP1).SquareModulus();
|
||||
}
|
||||
else
|
||||
{
|
||||
theUV.SetCoord (0., (aDP * aDV) / aL2V);
|
||||
return (theP - (theP1 + theUV.Y() * aDV)).SquareModulus();
|
||||
}
|
||||
}
|
||||
else if ( aL2V < gp::Resolution() ) // side 1-3 is degenerated
|
||||
{
|
||||
theUV.SetCoord ((aDP * aDU) / aL2U, 0.);
|
||||
return (theP - (theP1 + theUV.X() * aDU)).SquareModulus();
|
||||
}
|
||||
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));
|
||||
Standard_Real aD1 = (aDP - aU * aDU).SquareModulus();
|
||||
Standard_Real aD2 = (aDP - aV * aDV).SquareModulus();
|
||||
if ( aD1 < aD2 )
|
||||
{
|
||||
theUV.SetCoord ((aDP * aDU) / aL2U, 0.);
|
||||
return aD1;
|
||||
}
|
||||
else
|
||||
{
|
||||
theUV.SetCoord (0., (aDP * aDV) / aL2V);
|
||||
return aD2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +758,8 @@ static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
|
||||
Standard_Real A,B,C,D;
|
||||
thegpPln.Coefficients(A,B,C,D);
|
||||
Handle_V3d_Plane thePlane = new V3d_Plane(myAISContext->CurrentViewer(),A,B,C,D);
|
||||
Handle_V3d_Plane thePlane = new V3d_Plane(A,B,C,D);
|
||||
myAISContext->CurrentViewer()->AddPlane (thePlane); // add to defined planes list
|
||||
for (myAISContext->CurrentViewer()->InitActiveViews();
|
||||
myAISContext->CurrentViewer()->MoreActiveViews ();
|
||||
myAISContext->CurrentViewer()->NextActiveViews ()) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
-- File: Select3D_Projector.cdl
|
||||
-- Created: Thu Mar 12 13:32:28 1992
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
|
||||
---Copyright: Matra Datavision 1992
|
||||
-- File: Select3D_Projector.cdl
|
||||
-- Created: Thu Mar 12 13:32:28 1992
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class Projector from Select3D
|
||||
---Purpose: A framework to define 3D projectors.
|
||||
class Projector from Select3D inherits Transient from Standard
|
||||
---Purpose: A framework to define 3D projectors.
|
||||
uses
|
||||
Real from Standard,
|
||||
Boolean from Standard,
|
||||
Trsf from gp,
|
||||
Trsf from gp,
|
||||
GTrsf from gp,
|
||||
Lin from gp,
|
||||
Pnt from gp,
|
||||
@ -19,155 +19,169 @@ uses
|
||||
Pnt2d from gp,
|
||||
Box from Bnd,
|
||||
View from V3d
|
||||
|
||||
|
||||
raises
|
||||
NoSuchObject from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(aView:View from V3d) returns Projector from Select3D;
|
||||
--- Purpose: Constructs the 3D projector object defined by the 3D view aView.
|
||||
--- Purpose: Constructs the 3D projector object defined by the 3D view aView.
|
||||
Create returns Projector from Select3D;
|
||||
|
||||
Create(CS : Ax2 from gp)
|
||||
---Purpose: Creates an axonometric projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
---Purpose: Creates an axonometric projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(CS : Ax2 from gp;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: Creates a perspective projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
Focus : Real from Standard)
|
||||
---Purpose: Creates a perspective projector. <CS> is the
|
||||
-- viewing coordinate system.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Create(T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard;
|
||||
v1,v2,v3 : Vec2d from gp)
|
||||
---Purpose: build a Projector with given minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard;
|
||||
v1,v2,v3 : Vec2d from gp)
|
||||
---Purpose: build a Projector with given minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
|
||||
Create(GT : GTrsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
---Purpose: build a Projector with automatic minmax directions.
|
||||
returns Projector from Select3D;
|
||||
|
||||
Delete(me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~Select3D_Projector(){Delete() ; }"
|
||||
|
||||
Set (me: in out ;
|
||||
T : Trsf from gp;
|
||||
Set (me : mutable;
|
||||
T : Trsf from gp;
|
||||
Persp : Boolean from Standard;
|
||||
Focus : Real from Standard)
|
||||
Focus : Real from Standard)
|
||||
is static;
|
||||
|
||||
|
||||
SetView(me:in out ; V : View from V3d);
|
||||
---Purpose: Sets the 3D view V used at the time of construction.
|
||||
|
||||
SetView(me : mutable; V : View from V3d);
|
||||
---Purpose: Sets the 3D view V used at the time of construction.
|
||||
|
||||
View(me) returns any View from V3d;
|
||||
---Purpose: Returns the 3D view used at the time of construction.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
---Purpose: Returns the 3D view used at the time of construction.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
|
||||
|
||||
Directions(me; D1 , D2 , D3 : out Vec2d from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Scaled(me : in out; On : Boolean from Standard = Standard_False)
|
||||
---Purpose: to compute with the given scale and translation.
|
||||
Scaled(me : mutable; On : Boolean from Standard = Standard_False)
|
||||
---Purpose: to compute with the given scale and translation.
|
||||
is virtual;
|
||||
|
||||
Perspective(me) returns Boolean
|
||||
---Purpose: Returns True if there is a perspective transformation.
|
||||
---C++: inline
|
||||
---Purpose: Returns True if there is a perspective transformation.
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transformation(me) returns GTrsf from gp
|
||||
---Purpose: Returns the active transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the active transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
InvertedTransformation(me) returns GTrsf from gp
|
||||
---Purpose: Returns the active inverted transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the active inverted transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
FullTransformation(me) returns Trsf from gp
|
||||
---Purpose: Returns the original transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns the original transformation.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
is virtual;
|
||||
|
||||
Focus(me) returns Real from Standard
|
||||
---Purpose: Returns the focal length.
|
||||
---C++: inline
|
||||
---Purpose: Returns the focal length.
|
||||
---C++: inline
|
||||
raises
|
||||
NoSuchObject from Standard -- if there is no perspective
|
||||
NoSuchObject from Standard -- if there is no perspective
|
||||
is virtual;
|
||||
|
||||
|
||||
Transform(me; D : in out Vec from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; Pnt : in out Pnt from gp)
|
||||
---C++: inline
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
Pout : out Pnt2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is virtual;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
X,Y,Z : out Real from Standard)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is static;
|
||||
|
||||
|
||||
Project(me; P : Pnt from gp;
|
||||
D1 : Vec from gp;
|
||||
Pout : out Pnt2d from gp;
|
||||
D1out : out Vec2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
Pout : out Pnt2d from gp;
|
||||
D1out : out Vec2d from gp)
|
||||
---Purpose: Transform and apply perspective if needed.
|
||||
is virtual;
|
||||
|
||||
|
||||
BoxAdd(me; P : Pnt2d from gp;
|
||||
B : out Box from Bnd)
|
||||
---Purpose: Adds to the box <B> the min-max of the point <P>.
|
||||
---Purpose: Adds to the box <B> the min-max of the point <P>.
|
||||
is virtual;
|
||||
|
||||
Shoot(me; X , Y : Real from Standard)
|
||||
returns Lin from gp
|
||||
---Purpose: return a line going through the eye towards the
|
||||
-- 2d point <X,Y>.
|
||||
---Purpose: return a line going through the eye towards the
|
||||
-- 2d point <X,Y>.
|
||||
is virtual;
|
||||
|
||||
SetDirection(me: in out)
|
||||
is static private;
|
||||
|
||||
Transform(me; P : in out Pnt from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; D : in out Lin from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
DepthMin(me) returns Real from Standard;
|
||||
---Purpose: Returns the minimum depth value (if clipping plane defined).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
---C++: inline
|
||||
|
||||
DepthMax(me) returns Real from Standard;
|
||||
---Purpose: Returns the maximum depth value (if clipping plane defined).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
---C++: inline
|
||||
|
||||
DepthMinMax(me : mutable;
|
||||
theDepthMin : in Real from Standard;
|
||||
theDepthMax : in Real from Standard);
|
||||
---Purpose: Setup the min/max depth values (doesn't affect
|
||||
--- projection functionality itself).
|
||||
--- Should be used when call ::Shoot() to compute eyeline.
|
||||
|
||||
SetDirection(me : mutable)
|
||||
is static private;
|
||||
|
||||
Transform(me; P : in out Pnt from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
Transform(me; D : in out Lin from gp;
|
||||
T : GTrsf from gp)
|
||||
---C++: inline
|
||||
is virtual;
|
||||
|
||||
fields
|
||||
myType : Integer from Standard;
|
||||
|
||||
myType : Integer from Standard;
|
||||
|
||||
myPersp : Boolean from Standard is protected;
|
||||
myFocus : Real from Standard is protected;
|
||||
myScaledTrsf : Trsf from gp is protected;
|
||||
@ -177,7 +191,8 @@ fields
|
||||
myD2 : Vec2d from gp is protected;
|
||||
myD3 : Vec2d from gp is protected;
|
||||
|
||||
|
||||
myView : View from V3d;
|
||||
myView : View from V3d;
|
||||
myDepthMin : Real from Standard;
|
||||
myDepthMax : Real from Standard;
|
||||
|
||||
end Projector;
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun2>
|
||||
|
||||
#define IMP240100 //GG
|
||||
#define IMP240100 //GG
|
||||
// Change RefToPix()/Convert() to Project() method.
|
||||
|
||||
#include <Select3D_Projector.ixx>
|
||||
@ -14,33 +14,34 @@
|
||||
|
||||
// formula for derivating a perspective, from Mathematica
|
||||
|
||||
// X'[t] X[t] Z'[t]
|
||||
// D1 = -------- + -------------
|
||||
// Z[t] Z[t] 2
|
||||
// 1 - ---- f (1 - ----)
|
||||
// f f
|
||||
// X'[t] X[t] Z'[t]
|
||||
// D1 = -------- + -------------
|
||||
// Z[t] Z[t] 2
|
||||
// 1 - ---- f (1 - ----)
|
||||
// f f
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou):
|
||||
myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
||||
myFocus(aViou->Focale()),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myView(aViou)
|
||||
Select3D_Projector::Select3D_Projector(const Handle(V3d_View)& aViou)
|
||||
: myPersp(aViou->Type()==V3d_PERSPECTIVE),
|
||||
myFocus(aViou->Focale()),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myView(aViou),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
|
||||
//Standard_Boolean Pers=Standard_False;
|
||||
|
||||
|
||||
aViou->At(Xat,Yat,Zat);
|
||||
aViou->Up(XUp,YUp,ZUp);
|
||||
aViou->Proj(DX,DY,DZ);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Dir Zpers (DX,DY,DZ);
|
||||
gp_Dir Ypers (XUp,YUp,ZUp);
|
||||
gp_Dir Xpers = Ypers.Crossed(Zpers);
|
||||
@ -48,24 +49,37 @@ myView(aViou)
|
||||
myScaledTrsf.SetTransformation(Axe);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
|
||||
}
|
||||
|
||||
Select3D_Projector::Select3D_Projector () :
|
||||
myPersp(Standard_False),myFocus(0),myD1(1,0),myD2(0,1),myD3(1,1)
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Ax2& CS) :
|
||||
myPersp(Standard_False), myFocus(0)
|
||||
Select3D_Projector::Select3D_Projector()
|
||||
: myPersp(Standard_False),
|
||||
myFocus(0),
|
||||
myD1(1,0),
|
||||
myD2(0,1),
|
||||
myD3(1,1),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector (const gp_Ax2& CS)
|
||||
: myPersp(Standard_False),
|
||||
myFocus(0),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
@ -75,32 +89,35 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Ax2& CS,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Standard_True), myFocus(Focus)
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_Ax2& CS,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Standard_True),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T)
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myScaledTrsf.SetTransformation(CS);
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
@ -109,22 +126,23 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus,
|
||||
const gp_Vec2d& v1,
|
||||
const gp_Vec2d& v2,
|
||||
const gp_Vec2d& v3) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus,
|
||||
const gp_Vec2d& v1,
|
||||
const gp_Vec2d& v2,
|
||||
const gp_Vec2d& v3)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myScaledTrsf(T),
|
||||
myD1(v1),
|
||||
myD2(v2),
|
||||
myD3(v3)
|
||||
myD3(v3),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
myGTrsf.SetTrsf(myScaledTrsf);
|
||||
Scaled();
|
||||
@ -132,33 +150,31 @@ Select3D_Projector::Select3D_Projector
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_Projector
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_Projector::Select3D_Projector
|
||||
(const gp_GTrsf& GT,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus) :
|
||||
myPersp(Persp),
|
||||
Select3D_Projector::Select3D_Projector (const gp_GTrsf& GT,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
: myPersp(Persp),
|
||||
myFocus(Focus),
|
||||
myGTrsf(GT)
|
||||
myGTrsf(GT),
|
||||
myDepthMin(-Precision::Infinite()),
|
||||
myDepthMax( Precision::Infinite())
|
||||
{
|
||||
Scaled();
|
||||
SetDirection();
|
||||
}
|
||||
|
||||
void Select3D_Projector::Delete()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Set
|
||||
(const gp_Trsf& T,
|
||||
(const gp_Trsf& T,
|
||||
const Standard_Boolean Persp,
|
||||
const Standard_Real Focus)
|
||||
const Standard_Real Focus)
|
||||
{
|
||||
myPersp = Persp;
|
||||
myFocus = Focus;
|
||||
@ -169,59 +185,59 @@ void Select3D_Projector::Set
|
||||
|
||||
//=======================================================================
|
||||
//function : Scaled
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
#include <gp_Mat.hxx>
|
||||
|
||||
static Standard_Integer TrsfType(const gp_GTrsf& Trsf) {
|
||||
static Standard_Integer TrsfType(const gp_GTrsf& Trsf) {
|
||||
const gp_Mat& Mat = Trsf.VectorialPart();
|
||||
if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-1.0) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,3)-1.0) < 1e-15)) {
|
||||
return(1); //-- top
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,2)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,3)-0.5) < 1e-15)
|
||||
|
||||
|
||||
&& (Abs(Mat.Value(2,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)+0.5) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(0); //--
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(0); //--
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
else if( (Abs(Mat.Value(1,1)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)-1.0) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)+1.0) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,2)+1.0) < 1e-15)) {
|
||||
return(2); //-- front
|
||||
}
|
||||
else if( (Abs(Mat.Value(1,1)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,2)-0.7071067811865476) < 1e-15)
|
||||
&& (Abs(Mat.Value(1,3)) < 1e-15)
|
||||
|
||||
|
||||
&& (Abs(Mat.Value(2,1)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,2)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(2,3)-0.7071067811865476) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)-0.5) < 1e-15)
|
||||
|
||||
&& (Abs(Mat.Value(3,1)-0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,2)+0.5) < 1e-15)
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
&& (Abs(Mat.Value(3,3)-0.7071067811865476) < 1e-15)) {
|
||||
return(3); //-- axo
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void Select3D_Projector::Scaled (const Standard_Boolean On)
|
||||
{
|
||||
{
|
||||
myType=-1;
|
||||
if (!On) {
|
||||
if (!myPersp) {
|
||||
if (!myPersp) {
|
||||
//myGTrsf.SetTranslationPart(gp_XYZ(0.,0.,0.));
|
||||
myType=TrsfType(myGTrsf);
|
||||
myType=TrsfType(myGTrsf);
|
||||
}
|
||||
}
|
||||
myInvTrsf = myGTrsf;
|
||||
@ -230,7 +246,7 @@ void Select3D_Projector::Scaled (const Standard_Boolean On)
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
@ -249,9 +265,9 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
Pout.SetCoord(Xout,Yout);
|
||||
}
|
||||
else{
|
||||
if(myType!=-1) {
|
||||
if(myType!=-1) {
|
||||
Standard_Real X,Y;
|
||||
switch (myType) {
|
||||
switch (myType) {
|
||||
case 0: { //-- axono standard
|
||||
Standard_Real x07 = P.X()*0.7071067811865475;
|
||||
Standard_Real y05 = P.Y()*0.5;
|
||||
@ -266,12 +282,12 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
Pout.SetCoord(X,Y);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 2: {
|
||||
X=P.X(); Y=P.Z(); //-- Z=-P.Y();
|
||||
Pout.SetCoord(X,Y);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 3: {
|
||||
Standard_Real xmy05 = (P.X()-P.Y())*0.5;
|
||||
Standard_Real z07 = P.Z()*0.7071067811865476;
|
||||
X=0.7071067811865476*(P.X()+P.Y());
|
||||
@ -280,37 +296,37 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
//-- Z= xmy05+z07;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default: {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
if (myPersp) {
|
||||
Standard_Real R = 1.-P2.Z()/myFocus;
|
||||
Pout.SetCoord(P2.X()/R,P2.Y()/R);
|
||||
}
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
if (myPersp) {
|
||||
Standard_Real R = 1.-P2.Z()/myFocus;
|
||||
Pout.SetCoord(P2.X()/R,P2.Y()/R);
|
||||
}
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
else
|
||||
Pout.SetCoord(P2.X(),P2.Y());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
/* ====== TYPE 0 (??)
|
||||
(0.7071067811865476, -0.5 , 0.4999999999999999)
|
||||
@ -327,7 +343,7 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
|
||||
(0.0, 1.110223024625157e-16 , 1.0)
|
||||
(0.0, -1.0 , 1.110223024625157e-16)
|
||||
|
||||
======= TYPE 3
|
||||
======= TYPE 3
|
||||
( 0.7071067811865476, 0.7071067811865475, 0.0)
|
||||
(-0.5 , 0.5000000000000001, 0.7071067811865475)
|
||||
( 0.4999999999999999, -0.5 , 0.7071067811865476)
|
||||
@ -349,8 +365,8 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
if(myType!=-1) {
|
||||
switch (myType) {
|
||||
if(myType!=-1) {
|
||||
switch (myType) {
|
||||
case 0: { //-- axono standard
|
||||
Standard_Real x07 = P.X()*0.7071067811865475;
|
||||
Standard_Real y05 = P.Y()*0.5;
|
||||
@ -364,11 +380,11 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
X=P.X(); Y=P.Y(); Z=P.Z();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 2: {
|
||||
X=P.X(); Y=P.Z(); Z=-P.Y();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 3: {
|
||||
Standard_Real xmy05 = (P.X()-P.Y())*0.5;
|
||||
Standard_Real z07 = P.Z()*0.7071067811865476;
|
||||
X=0.7071067811865476*(P.X()+P.Y());
|
||||
@ -376,7 +392,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
Z= xmy05+z07;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default: {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
P2.Coord(X,Y,Z);
|
||||
@ -384,7 +400,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
gp_Pnt P2 = P;
|
||||
Transform(P2);
|
||||
P2.Coord(X,Y,Z);
|
||||
@ -398,7 +414,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
@ -424,7 +440,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
|
||||
|
||||
//=======================================================================
|
||||
//function : BoxAdd
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::BoxAdd
|
||||
@ -438,7 +454,7 @@ void Select3D_Projector::BoxAdd
|
||||
|
||||
//=======================================================================
|
||||
//function : Shoot
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Lin Select3D_Projector::Shoot
|
||||
@ -446,7 +462,7 @@ gp_Lin Select3D_Projector::Shoot
|
||||
const Standard_Real Y) const
|
||||
{
|
||||
gp_Lin L;
|
||||
|
||||
|
||||
if (myPersp) {
|
||||
L = gp_Lin(gp_Pnt(0,0, myFocus),
|
||||
gp_Dir(X,Y,-myFocus));
|
||||
@ -462,10 +478,10 @@ gp_Lin Select3D_Projector::Shoot
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDirection
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_Projector::SetDirection ()
|
||||
void Select3D_Projector::SetDirection ()
|
||||
{
|
||||
gp_Vec V1(1,0,0);
|
||||
Transform(V1);
|
||||
@ -491,16 +507,23 @@ void Select3D_Projector::SetView(const Handle(V3d_View)& aViou)
|
||||
myFocus= aViou->Focale();
|
||||
Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
|
||||
//Standard_Boolean Pers=Standard_False;
|
||||
|
||||
|
||||
aViou->At(Xat,Yat,Zat);
|
||||
aViou->Up(XUp,YUp,ZUp);
|
||||
aViou->Proj(DX,DY,DZ);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Pnt At (Xat,Yat,Zat);
|
||||
gp_Dir Zpers (DX,DY,DZ);
|
||||
gp_Dir Ypers (XUp,YUp,ZUp);
|
||||
gp_Dir Xpers = Ypers.Crossed(Zpers);
|
||||
gp_Ax3 Axe (At, Zpers, Xpers);
|
||||
myScaledTrsf.SetTransformation(Axe);
|
||||
Scaled();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Select3D_Projector::DepthMinMax (const Standard_Real theDepthMin,
|
||||
const Standard_Real theDepthMax)
|
||||
{
|
||||
myDepthMin = theDepthMin;
|
||||
myDepthMax = theDepthMax;
|
||||
}
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
//=======================================================================
|
||||
//function : Directions
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Directions
|
||||
inline void Select3D_Projector::Directions
|
||||
(gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const
|
||||
{
|
||||
D1 = myD1;
|
||||
@ -25,7 +25,7 @@ inline void Select3D_Projector::Directions
|
||||
|
||||
//=======================================================================
|
||||
//function : Perspective
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean Select3D_Projector::Perspective() const
|
||||
@ -33,7 +33,7 @@ inline Standard_Boolean Select3D_Projector::Perspective() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_GTrsf& Select3D_Projector::Transformation() const
|
||||
@ -41,7 +41,7 @@ inline const gp_GTrsf& Select3D_Projector::Transformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : InvertedTransformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
|
||||
@ -49,7 +49,7 @@ inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : FullTransformation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const gp_Trsf& Select3D_Projector::FullTransformation() const
|
||||
@ -57,7 +57,7 @@ inline const gp_Trsf& Select3D_Projector::FullTransformation() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Focus
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real Select3D_Projector::Focus() const
|
||||
@ -69,7 +69,7 @@ inline Standard_Real Select3D_Projector::Focus() const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Vec& D) const
|
||||
@ -83,11 +83,11 @@ inline void Select3D_Projector::Transform (gp_Vec& D) const
|
||||
|
||||
//=======================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
|
||||
{
|
||||
{
|
||||
gp_XYZ xyz = Pnt.XYZ();
|
||||
myGTrsf.Transforms(xyz);
|
||||
Pnt = gp_Pnt(xyz);
|
||||
@ -98,7 +98,7 @@ inline const Handle(V3d_View)& Select3D_Projector::View() const
|
||||
{return myView;}
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
|
||||
{
|
||||
{
|
||||
gp_Ax1 ax1 = Lin.Position();
|
||||
gp_XYZ xyz = ax1.Location().XYZ();
|
||||
T.Transforms(xyz);
|
||||
@ -118,10 +118,18 @@ inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
|
||||
}
|
||||
|
||||
inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const
|
||||
{
|
||||
{
|
||||
gp_XYZ xyz = Pnt.XYZ();
|
||||
T.Transforms(xyz);
|
||||
Pnt = gp_Pnt(xyz);
|
||||
}
|
||||
|
||||
inline Standard_Real Select3D_Projector::DepthMin() const
|
||||
{
|
||||
return myDepthMin;
|
||||
}
|
||||
|
||||
inline Standard_Real Select3D_Projector::DepthMax() const
|
||||
{
|
||||
return myDepthMax;
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ Select3D_SensitiveEntity(OwnerId)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void Select3D_SensitiveBox::
|
||||
Project(const Select3D_Projector& aProj)
|
||||
Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
|
||||
|
||||
if(HasLocation()){
|
||||
Bnd_Box B = mybox3d.Transformed(Location().Transformation());
|
||||
ProjectBox(aProj,B);
|
||||
@ -164,29 +164,29 @@ void Select3D_SensitiveBox::Dump(Standard_OStream& S,const Standard_Boolean Full
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveBox::ProjectBox(const Select3D_Projector& aPrj,
|
||||
void Select3D_SensitiveBox::ProjectBox(const Handle(Select3D_Projector)& aPrj,
|
||||
const Bnd_Box& aBox)
|
||||
{
|
||||
mybox2d.SetVoid();
|
||||
gp_Pnt2d curp2d;
|
||||
Standard_Real XMin,YMin,ZMin,XMax,YMax,ZMax;
|
||||
aBox.Get(XMin,YMin,ZMin,XMax,YMax,ZMax);
|
||||
|
||||
aPrj.Project(gp_Pnt(XMin,YMin,ZMin),curp2d);
|
||||
|
||||
aPrj->Project(gp_Pnt(XMin,YMin,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMin,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMin,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMax,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMax,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMax,ZMin),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMax,ZMin),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMin,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMin,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMin,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMin,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMax,YMax,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMax,YMax,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
aPrj.Project(gp_Pnt(XMin,YMax,ZMax),curp2d);
|
||||
aPrj->Project(gp_Pnt(XMin,YMax,ZMax),curp2d);
|
||||
mybox2d.Update(curp2d.X(),curp2d.Y());
|
||||
}
|
||||
|
||||
|
@ -64,16 +64,18 @@ Standard_Boolean Select3D_SensitiveCurve
|
||||
Standard_Integer Rank;
|
||||
TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
|
||||
Points2D(aArrayOf2dPnt);
|
||||
Standard_Boolean KK = SelectBasics_BasicTool::MatchPolyg2d(aArrayOf2dPnt,
|
||||
X,Y,
|
||||
aTol,
|
||||
DMin,
|
||||
Rank);
|
||||
if(KK){
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
if (SelectBasics_BasicTool::MatchPolyg2d (aArrayOf2dPnt,
|
||||
X, Y,
|
||||
aTol,
|
||||
DMin,
|
||||
Rank))
|
||||
{
|
||||
mylastseg = Rank;
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
|
||||
|
||||
}
|
||||
return KK;
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
//==================================================
|
||||
|
@ -1,18 +1,18 @@
|
||||
-- File: Select3D_SensitiveEntity.cdl
|
||||
-- Created: Tue Jan 24 09:30:34 1995
|
||||
-- Author: Rob
|
||||
-- modified by rob jul/ 21/ 97 : inserting locations ...
|
||||
-- modified by rob jul/ 21/ 97 : inserting locations ...
|
||||
-- modified by rob jan/ 29/ 98 : Sort by deph-> add a field to be able
|
||||
-- to compute a depth
|
||||
-- to compute a depth
|
||||
-- -> Virtual methods rather than
|
||||
-- Deferred for Project
|
||||
-- WARNING : Must be redefined for
|
||||
-- WARNING : Must be redefined for
|
||||
-- each kind of sensitive entity
|
||||
--
|
||||
--
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
deferred class SensitiveEntity from Select3D inherits
|
||||
deferred class SensitiveEntity from Select3D inherits
|
||||
SensitiveEntity from SelectBasics
|
||||
|
||||
---Purpose: Abstract framework to define 3D sensitive entities.
|
||||
@ -29,7 +29,7 @@ uses
|
||||
EntityOwner from SelectBasics,
|
||||
Location from TopLoc,
|
||||
Lin from gp,
|
||||
Box2d from Bnd,
|
||||
Box2d from Bnd,
|
||||
Array1OfPnt2d from TColgp
|
||||
|
||||
is
|
||||
@ -37,26 +37,26 @@ is
|
||||
Initialize(OwnerId : EntityOwner from SelectBasics);
|
||||
|
||||
NeedsConversion(me) returns Boolean is redefined static;
|
||||
---Level: Public
|
||||
---Level: Public
|
||||
---Purpose: Returns true if this framework needs conversion.
|
||||
---C++: inline
|
||||
|
||||
|
||||
Is3D(me) returns Boolean from Standard is redefined static;
|
||||
---Purpose: Returns true if this framework provides 3D information.
|
||||
|
||||
Project (me:mutable;aProjector : Projector from Select3D) is virtual;
|
||||
---Level: Public
|
||||
---Level: Public
|
||||
---Purpose:Returns the projector aProjector.
|
||||
-- In classes inheriting this framework, you must
|
||||
-- redefine this function in order to get a sensitive 2D
|
||||
-- rectangle from a 3D entity. This rectangle is the
|
||||
-- sensitive zone which makes the 3D entity selectable.
|
||||
-- sensitive zone which makes the 3D entity selectable.
|
||||
|
||||
|
||||
MaxBoxes(me) returns Integer is redefined virtual;
|
||||
---Level: Public
|
||||
---Purpose: Returns the max number of sensitive areas returned
|
||||
-- by this class is 1 by default.
|
||||
---Level: Public
|
||||
---Purpose: Returns the max number of sensitive areas returned
|
||||
-- by this class is 1 by default.
|
||||
-- Else on must redefine this method.
|
||||
|
||||
|
||||
@ -66,18 +66,18 @@ is
|
||||
-- You must redefine this function for any type of
|
||||
-- sensitive entity which can accept another connected
|
||||
-- sensitive entity.//can be connected to another sensitive entity.
|
||||
|
||||
Matches(me :mutable;
|
||||
|
||||
Matches(me :mutable;
|
||||
X,Y : Real from Standard;
|
||||
aTol: Real from Standard;
|
||||
DMin: out Real from Standard)
|
||||
DMin: out Real from Standard)
|
||||
returns Boolean is redefined virtual;
|
||||
---Purpose: Matches the coordinates X, Y with the entity found at
|
||||
-- that point within the tolerance aTol and the minimum depth DMin.
|
||||
-- You must redefine this function for every inheriting entity.
|
||||
-- You will have to call this framework inside the redefined function.
|
||||
|
||||
Matches (me :mutable;
|
||||
Matches (me :mutable;
|
||||
XMin,YMin,XMax,YMax : Real from Standard;
|
||||
aTol: Real from Standard)
|
||||
returns Boolean from Standard is redefined virtual;
|
||||
@ -89,8 +89,8 @@ is
|
||||
-- maximum point in the upper right hand corner of the box.
|
||||
-- You must redefine this function for every inheriting entity.
|
||||
-- You will have to call this framework inside the redefined function.
|
||||
|
||||
Matches (me :mutable;
|
||||
|
||||
Matches (me :mutable;
|
||||
Polyline:Array1OfPnt2d from TColgp;
|
||||
aBox:Box2d from Bnd;
|
||||
aTol: Real from Standard)
|
||||
@ -100,14 +100,14 @@ is
|
||||
|
||||
GetEyeLine(me; X,Y : Real from Standard) returns Lin from gp;
|
||||
---Purpose: Returns the eye line for the point defined by the coordinates X,Y.
|
||||
|
||||
ComputeDepth(me;EyeLine : Lin from gp) returns Real from Standard
|
||||
|
||||
ComputeDepth(me;EyeLine : Lin from gp) returns Real from Standard
|
||||
is deferred;
|
||||
---Purpose: Returns the depth of this object on the line EyeLine.
|
||||
-- EyeLine goes through the eye towards a point
|
||||
-- defined by the coordinates X,Y in the function GetEyeLine.
|
||||
---Purpose: gives an abcissa on <aLin> .
|
||||
-- <aLin> represents the line going through
|
||||
-- <aLin> represents the line going through
|
||||
-- the eye towards an X,Y point on the screen. This Method
|
||||
-- must return a mean Depth on this line.
|
||||
|
||||
@ -115,7 +115,7 @@ is
|
||||
Depth(me) returns Real from Standard is redefined;
|
||||
|
||||
---Category: Location of sensitive entities...
|
||||
-- Default implementations of HasLocation() and Location() rely on
|
||||
-- Default implementations of HasLocation() and Location() rely on
|
||||
-- location obtained from the entity owner, to minimize memory usage.
|
||||
-- SetLocation() and ResetLocation() do nothing by default.
|
||||
|
||||
@ -134,7 +134,7 @@ is
|
||||
---Purpose: 2 options :
|
||||
-- <FullDump> = False -> general information
|
||||
-- <FullDump> = True -> whole informtion 3D +2d ...
|
||||
|
||||
|
||||
DumpBox(myclass; S: in out OStream;abox:Box2d from Bnd) ;
|
||||
|
||||
UpdateLocation(me:mutable;aLoc:Location from TopLoc);
|
||||
@ -145,8 +145,8 @@ is
|
||||
SetLastDepth(me:mutable; aDepth: Real from Standard) is protected;
|
||||
|
||||
fields
|
||||
|
||||
mylastprj : Address from Standard is protected;
|
||||
|
||||
mylastprj : Projector from Select3D is protected;
|
||||
mylastdepth : ShortReal from Standard;
|
||||
end SensitiveEntity;
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
|
||||
SelectBasics_SensitiveEntity(OwnerId),
|
||||
mylastprj(NULL),
|
||||
mylastdepth(0.0)
|
||||
mylastprj(),
|
||||
mylastdepth(ShortRealLast())
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
@ -28,9 +28,9 @@ mylastdepth(0.0)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveEntity::Project(const Select3D_Projector& aPrj)
|
||||
void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
|
||||
{
|
||||
mylastprj = (Standard_Address*)&aPrj;
|
||||
mylastprj = aPrj;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -43,12 +43,17 @@ Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
gp_Lin L;
|
||||
if(mylastprj!=NULL)
|
||||
L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
|
||||
SetLastDepth( ComputeDepth(L) );
|
||||
|
||||
return (Abs(mylastdepth)>Precision::Confusion());
|
||||
if (!mylastprj.IsNull())
|
||||
{
|
||||
gp_Lin L = mylastprj->Shoot (X, Y);
|
||||
SetLastDepth (ComputeDepth (L));
|
||||
return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
|
||||
return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -184,8 +189,10 @@ gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
|
||||
const Standard_Real Y) const
|
||||
{
|
||||
gp_Lin L;
|
||||
if(mylastprj!=NULL)
|
||||
L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
|
||||
if (!mylastprj.IsNull())
|
||||
{
|
||||
L = mylastprj->Shoot (X, Y);
|
||||
}
|
||||
return L;
|
||||
}
|
||||
|
||||
@ -202,8 +209,8 @@ Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveEntity::SetLastPrj(const Select3D_Projector& aprj)
|
||||
{ mylastprj = (Standard_Address*)& aprj;}
|
||||
void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
|
||||
{ mylastprj = aprj; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
|
@ -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)) {
|
||||
@ -151,10 +150,11 @@ Matches(const Standard_Real X,
|
||||
res = Standard_True;
|
||||
}
|
||||
}
|
||||
if(res)
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
|
||||
return res;
|
||||
if (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());
|
||||
for(Standard_Integer i=0;i<mynbpoints-1;i++)
|
||||
val = Min(val,ElCLib::Parameter(EyeLine,((Select3D_Pnt*)mypolyg3d)[i]));
|
||||
return val;
|
||||
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++)
|
||||
{
|
||||
aDepthTest = ElCLib::Parameter (EyeLine, ((Select3D_Pnt* )mypolyg3d)[i]);
|
||||
if (aDepthTest < aDepth && (aDepthTest > aDepthMin) && (aDepthTest < aDepthMax))
|
||||
{
|
||||
aDepth = aDepthTest;
|
||||
}
|
||||
}
|
||||
return aDepth;
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ 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...
|
||||
|
||||
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
|
||||
It.Value()->Project(aProjector);
|
||||
}
|
||||
@ -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)){
|
||||
myX = X;myY = Y;myLastTol = aTol;
|
||||
SetLastDepth( Precision::Infinite() );
|
||||
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
return Standard_True;
|
||||
if (It.Value()->Matches (X, Y, aTol, DMin))
|
||||
{
|
||||
myX = X; myY = Y; myLastTol = aTol;
|
||||
// compute and validate the depth (will call ::ComputeDepth())
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
|
||||
}
|
||||
}
|
||||
myLastRank =0;
|
||||
SetLastDepth(0.0);
|
||||
// no match
|
||||
myLastRank = 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_Real DMin,thedepth(Precision::Infinite());
|
||||
for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
|
||||
Standard_Integer currank = 0;
|
||||
Standard_Real DMin, thedepth (Precision::Infinite());
|
||||
for (Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
|
||||
{
|
||||
currank++;
|
||||
if(currank>=myLastRank){
|
||||
if(It.Value()->Matches(myX,myY,myLastTol,DMin)){
|
||||
It.Value()->ComputeDepth(EyeLine);
|
||||
thedepth = Min(Depth(),
|
||||
It.Value()->Depth());
|
||||
if (currank >= myLastRank)
|
||||
{
|
||||
// this recomputes and validates the depth for the entity
|
||||
if (It.Value()->Matches (myX, myY, myLastTol, DMin))
|
||||
{
|
||||
It.Value()->ComputeDepth (EyeLine);
|
||||
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())
|
||||
|
@ -32,15 +32,15 @@ Select3D_SensitiveEntity(anOwner)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void Select3D_SensitivePoint
|
||||
::Project (const Select3D_Projector& aProj)
|
||||
::Project (const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
gp_Pnt2d aPoint2d;
|
||||
if(!HasLocation())
|
||||
aProj.Project(mypoint, aPoint2d);
|
||||
aProj->Project(mypoint, aPoint2d);
|
||||
else{
|
||||
gp_Pnt aP(mypoint.x, mypoint.y, mypoint.z);
|
||||
aProj.Project(aP.Transformed(Location().Transformation()), aPoint2d);
|
||||
aProj->Project(aP.Transformed(Location().Transformation()), aPoint2d);
|
||||
}
|
||||
myprojpt = aPoint2d;
|
||||
}
|
||||
@ -69,9 +69,10 @@ Standard_Boolean Select3D_SensitivePoint
|
||||
Standard_Real& DMin)
|
||||
{
|
||||
DMin = gp_Pnt2d(X,Y).Distance(myprojpt);
|
||||
if(DMin<=aTol*SensitivityFactor()) {
|
||||
Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
return Standard_True;
|
||||
if(DMin<=aTol*SensitivityFactor())
|
||||
{
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ Select3D_SensitiveEntity(OwnerId)
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void Select3D_SensitivePoly::Project(const Select3D_Projector& aProj)
|
||||
void Select3D_SensitivePoly::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
mybox2d.SetVoid();
|
||||
@ -71,11 +71,14 @@ void Select3D_SensitivePoly::Project(const Select3D_Projector& aProj)
|
||||
for(Standard_Integer i=0;i<mynbpoints;i++)
|
||||
{
|
||||
gp_Pnt aPnt(((Select3D_Pnt*)mypolyg3d)[i].x, ((Select3D_Pnt*)mypolyg3d)[i].y, ((Select3D_Pnt*)mypolyg3d)[i].z);
|
||||
if(hasloc){
|
||||
aProj.Project(aPnt.Transformed(Location().Transformation()),aPnt2d);
|
||||
if (hasloc)
|
||||
{
|
||||
aProj->Project(aPnt.Transformed(Location().Transformation()),aPnt2d);
|
||||
}
|
||||
else
|
||||
aProj.Project(aPnt,aPnt2d);
|
||||
{
|
||||
aProj->Project(aPnt,aPnt2d);
|
||||
}
|
||||
mybox2d.Update(aPnt2d);
|
||||
((Select3D_Pnt2d*)mypolyg2d)[i] = aPnt2d;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ mymaxrect(MaxRect)
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
void Select3D_SensitiveSegment
|
||||
::Project(const Select3D_Projector& aProj)
|
||||
::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
|
||||
gp_Pnt2d aPoint2dStart;
|
||||
@ -54,12 +54,12 @@ void Select3D_SensitiveSegment
|
||||
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);
|
||||
aProj->Project(aStart.Transformed(Location().Transformation()),aPoint2dStart);
|
||||
aProj->Project(aEnd.Transformed(Location().Transformation()),aPoint2dEnd);
|
||||
}
|
||||
else{
|
||||
aProj.Project(mystart,aPoint2dStart);
|
||||
aProj.Project(myend,aPoint2dEnd);
|
||||
aProj->Project(mystart,aPoint2dStart);
|
||||
aProj->Project(myend,aPoint2dEnd);
|
||||
}
|
||||
myprojstart = aPoint2dStart;
|
||||
myprojend = aPoint2dEnd;
|
||||
@ -124,8 +124,7 @@ Standard_Boolean Select3D_SensitiveSegment
|
||||
gp_Pnt2d aPEnd(myprojend.x,myprojend.y);
|
||||
if ( ! SelectBasics_BasicTool::MatchSegment (aPStart, aPEnd, X, Y, aTol, DMin) )
|
||||
return Standard_False;
|
||||
Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); // to compute depth
|
||||
return Standard_True;
|
||||
return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); // compute and validate depth
|
||||
}
|
||||
|
||||
Standard_Boolean Select3D_SensitiveSegment::
|
||||
|
@ -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>
|
||||
@ -31,7 +32,7 @@ static Standard_Integer S3D_NumberOfFreeEdges(const Handle(Poly_Triangulation)&
|
||||
for (j = 0; j < 3; j++)
|
||||
if (t[j] == 0) nFree++;
|
||||
}
|
||||
return nFree;
|
||||
return nFree;
|
||||
}
|
||||
static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY& p1, const gp_XY& TheP,
|
||||
const Standard_Real aTol, Standard_Real& aDMin)
|
||||
@ -45,7 +46,7 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
|
||||
|
||||
gp_XY V01(p1);V01-=p0;
|
||||
gp_XY Vec(TheP);Vec -= p0;
|
||||
|
||||
|
||||
Standard_Real u = Vec*V01.Normalized();
|
||||
if(u<-aTol) return Standard_False;
|
||||
Standard_Real u1 = u-aTol;
|
||||
@ -68,12 +69,12 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
|
||||
// VEdg-= PEdg2.XY();
|
||||
// VCur-=PCur.XY();
|
||||
// Standard_Real long1 = VEdg.SquareModulus();
|
||||
|
||||
|
||||
// if(long1<=TolTol)
|
||||
// return VCur.SquareModulus();
|
||||
// Standard_Real Val = VEdg^VCur;
|
||||
// return Val*Val/long1;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
|
||||
@ -94,7 +95,7 @@ static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Select3D_SensitiveTriangulation::
|
||||
@ -115,11 +116,11 @@ myDetectedTr(-1)
|
||||
|
||||
Standard_Integer fr = 1;
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer nbTriangles (myTriangul->NbTriangles());
|
||||
gp_XYZ cdg(0,0,0);
|
||||
Standard_Integer n[3];
|
||||
|
||||
|
||||
// pour rechercher les connexions dans le cas ou on ne s'occupe de la frontiere...
|
||||
if(!myIntFlag){
|
||||
myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
|
||||
@ -148,10 +149,10 @@ myDetectedTr(-1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(nbTriangles!=0) cdg /= nbTriangles;
|
||||
myCDG3D = gp_Pnt(cdg);
|
||||
|
||||
|
||||
ComputeTotalTrsf();
|
||||
|
||||
if(myTrsf.Form()!=gp_Identity)
|
||||
@ -161,7 +162,7 @@ myDetectedTr(-1)
|
||||
|
||||
//=======================================================================
|
||||
//function : Select3D_SensitiveTriangulation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Select3D_SensitiveTriangulation::
|
||||
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
|
||||
@ -182,105 +183,52 @@ myDetectedTr(-1)
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose :
|
||||
//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...
|
||||
|
||||
|
||||
mybox2d.SetVoid();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
gp_Pnt2d ProjPT;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Areas
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
|
||||
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 :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
const Standard_Real Y,
|
||||
const Standard_Real aTol,
|
||||
Standard_Real& DMin)
|
||||
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();
|
||||
@ -291,12 +239,12 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
// on regarde si on est a l'interieur d'1 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());
|
||||
|
||||
Standard_Real aMinDepth = Precision::Infinite();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
for (Standard_Integer itr=1; itr<=myTriangul->NbTriangles(); itr++)
|
||||
{
|
||||
Standard_Integer n1,n2,n3;
|
||||
@ -304,30 +252,32 @@ 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) +
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cas Uniquement Test sur Frontiere de la triangulation...
|
||||
//
|
||||
//
|
||||
else
|
||||
{
|
||||
//Standard_Integer ifirst;
|
||||
@ -335,7 +285,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
Standard_Integer nn = FreeE.Length(), Node1,Node2;
|
||||
//Standard_Real LEdg;
|
||||
//Standard_Real DMinDMin,TolTol = aTol*aTol;
|
||||
|
||||
|
||||
for (Standard_Integer ifri =1; ifri <= nn && myDetectedTr < 0; ifri+=2)
|
||||
{
|
||||
Node1 = FreeE(ifri);
|
||||
@ -344,43 +294,44 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
|
||||
myNodes2d(Node2).XY(),
|
||||
BidPoint, aTol, DMin) )
|
||||
{
|
||||
for(Standard_Integer itr=1; itr <= myTriangul->NbTriangles(); itr++)
|
||||
for(Standard_Integer itr=1; itr <= myTriangul->NbTriangles(); itr++)
|
||||
{
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(itr).Get(n1,n2,n3);
|
||||
if(S3D_IsEdgeIn(Node1,Node2,n1,n2,n3))
|
||||
triangles(itr).Get(n1,n2,n3);
|
||||
if(S3D_IsEdgeIn(Node1,Node2,n1,n2,n3))
|
||||
{
|
||||
myDetectedTr = itr;
|
||||
myDetectedTr = itr;
|
||||
break; // return first found; selection of closest is not implemented yet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XMin,
|
||||
const Standard_Real YMin,
|
||||
const Standard_Real XMax,
|
||||
const Standard_Real YMax,
|
||||
const Standard_Real aTol)
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
Bnd_Box2d B;
|
||||
B.Update(Min(XMin,XMax)-aTol,
|
||||
Min(YMin,YMax)-aTol,
|
||||
Max(XMin,XMax)+aTol,
|
||||
Max(YMin,YMax)+aTol);
|
||||
|
||||
|
||||
for(Standard_Integer i=myNodes2d.Lower();i<=myNodes2d.Upper();i++){
|
||||
if(B.IsOut(myNodes2d(i)))
|
||||
return Standard_False;
|
||||
@ -391,14 +342,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XM
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::
|
||||
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;
|
||||
@ -427,7 +378,7 @@ Standard_Integer Select3D_SensitiveTriangulation::Status (const gp_XY& TheP,
|
||||
|
||||
//=======================================================================
|
||||
//function : IsFree
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
|
||||
@ -441,36 +392,36 @@ Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer
|
||||
TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
|
||||
|
||||
for(Standard_Integer I=1;I<=FreeE.Length() && FoundIndex==-1;I+=2){
|
||||
|
||||
|
||||
if(FreeE(I) == n[0]){
|
||||
|
||||
|
||||
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]) FoundIndex=I;}
|
||||
else if(FreeE(I) == n[2]){
|
||||
if(FreeE(I+1)== n[0] || FreeE(I+1)== n[1]) FoundIndex=I;}
|
||||
}
|
||||
|
||||
|
||||
return FoundIndex!=-1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangulation::
|
||||
GetConnected(const TopLoc_Location& aLoc)
|
||||
{
|
||||
|
||||
Handle(Select3D_SensitiveTriangulation) NiouEnt =
|
||||
|
||||
Handle(Select3D_SensitiveTriangulation) NiouEnt =
|
||||
new Select3D_SensitiveTriangulation(myOwnerId,myTriangul,myiniloc,myFreeEdges,myCDG3D,myIntFlag);
|
||||
|
||||
|
||||
if(HasLocation()) NiouEnt->SetLocation(Location());
|
||||
// TopLoc_Location TheLocToApply = HasLocation() ? Location()*aLoc : aLoc;
|
||||
// if(!TheLocToApply.IsIdentity())
|
||||
NiouEnt->UpdateLocation(aLoc);
|
||||
|
||||
|
||||
|
||||
return NiouEnt;
|
||||
}
|
||||
@ -478,9 +429,9 @@ GetConnected(const TopLoc_Location& aLoc)
|
||||
|
||||
//=======================================================================
|
||||
//function : ResetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangulation::ResetLocation()
|
||||
void Select3D_SensitiveTriangulation::ResetLocation()
|
||||
{
|
||||
Select3D_SensitiveEntity::ResetLocation();
|
||||
ComputeTotalTrsf();
|
||||
@ -494,9 +445,9 @@ void Select3D_SensitiveTriangulation::SetLocation(const TopLoc_Location& aLoc)
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
{
|
||||
S<<"\tSensitiveTriangulation 3D :"<<endl;
|
||||
if(myiniloc.IsIdentity())
|
||||
@ -505,7 +456,7 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
|
||||
S<<"\t\tExisting Initial Location"<<endl;
|
||||
if(HasLocation())
|
||||
S<<"\t\tExisting Location"<<endl;
|
||||
|
||||
|
||||
S<<"\t\tNb Triangles : "<<myTriangul->NbTriangles()<<endl;
|
||||
S<<"\t\tNb Nodes : "<<myTriangul->NbNodes()<<endl;
|
||||
S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
|
||||
@ -518,14 +469,14 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDepth
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
if(myDetectedTr==-1) return Precision::Infinite(); // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(myDetectedTr).Get(n1,n2,n3);
|
||||
gp_Pnt P[3]={Nodes(n1),Nodes(n2),Nodes(n3)};
|
||||
@ -535,18 +486,18 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
P[i].Transform(myTrsf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// formule calcul du parametre du point sur l'intersection
|
||||
// t = (P1P2 ^P1P3)* OP1 / ((P1P2^P1P3)*Dir)
|
||||
Standard_Real prof(Precision::Infinite());
|
||||
gp_Pnt Oye = EyeLine.Location(); // origine de la ligne oeil/point vise...
|
||||
gp_Dir Dir = EyeLine.Direction();
|
||||
|
||||
gp_Vec Vtr[3];
|
||||
gp_Vec Vtr[3];
|
||||
for(Standard_Integer i=0;i<=2;i++)
|
||||
Vtr[i] = gp_Vec(P[i%3],P[(i+1)%3]);
|
||||
Vtr[2] = -Vtr[2];
|
||||
|
||||
|
||||
// eliminons tout de suite les cas singuliers...
|
||||
Standard_Integer SingularCase(-1);
|
||||
if(Vtr[0].SquareMagnitude()<= Precision::Confusion())
|
||||
@ -557,13 +508,13 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
if(Vtr[2].SquareMagnitude()<= Precision::Confusion())
|
||||
if( SingularCase < 0 ) SingularCase = 1;
|
||||
#endif
|
||||
|
||||
|
||||
// 3 pts confondus...
|
||||
if(SingularCase ==2){
|
||||
prof= ElCLib::Parameter(EyeLine,P[0]);
|
||||
return prof;
|
||||
}
|
||||
|
||||
|
||||
if(SingularCase!=0)
|
||||
Vtr[0].Normalize();
|
||||
if(SingularCase!=1 &&
|
||||
@ -571,7 +522,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
Vtr[2].Normalize();
|
||||
gp_Vec OPo(Oye,P[0]);
|
||||
// 2 points confondus... on recherche l'intersection entre le segment et la ligne oeil/point vise.
|
||||
//
|
||||
//
|
||||
if(SingularCase!=-1){
|
||||
gp_Vec V = SingularCase==0 ? Vtr[2] : Vtr[0];
|
||||
gp_Vec Det = Dir^V;
|
||||
@ -584,25 +535,25 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
|
||||
prof = VSM.Z()/Det.Z();
|
||||
}
|
||||
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()){
|
||||
prof= ElCLib::Parameter(EyeLine,P[0]);
|
||||
prof = Min (prof, ElCLib::Parameter(EyeLine,P[1]));
|
||||
prof = Min (prof, ElCLib::Parameter(EyeLine,P[2]));
|
||||
}
|
||||
|
||||
|
||||
return prof;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DetectedTriangle
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
gp_Pnt& P2,
|
||||
@ -610,10 +561,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
{
|
||||
if(myDetectedTr==-1) return Standard_False; // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles(myDetectedTr).Get(n1,n2,n3);
|
||||
|
||||
|
||||
P1 = Nodes(n1);
|
||||
P2 = Nodes(n2);
|
||||
P3 = Nodes(n3);
|
||||
@ -622,27 +573,27 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
|
||||
P2.Transform(myTrsf);
|
||||
P3.Transform(myTrsf);
|
||||
}
|
||||
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Function : DetectedTriangle2d
|
||||
// Purpose :
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
gp_Pnt2d& P1, gp_Pnt2d& P2, gp_Pnt2d& P3) const
|
||||
{
|
||||
if(myDetectedTr==-1)
|
||||
if(myDetectedTr==-1)
|
||||
return Standard_False; // non implemente actuellement...
|
||||
const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
|
||||
Standard_Integer n1,n2,n3;
|
||||
triangles( myDetectedTr ).Get(n1,n2,n3);
|
||||
|
||||
int aLower = myNodes2d.Lower();
|
||||
int anUpper = myNodes2d.Upper();
|
||||
if ( n1 >= aLower && n1 <= anUpper &&
|
||||
if ( n1 >= aLower && n1 <= anUpper &&
|
||||
n2 >= aLower && n2 <= anUpper &&
|
||||
n3 >= aLower && n3 <= anUpper )
|
||||
{
|
||||
@ -651,15 +602,15 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
|
||||
P3 = myNodes2d.Value( n3 );
|
||||
return Standard_True;
|
||||
}
|
||||
else
|
||||
else
|
||||
return Standard_False;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
|
||||
void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
|
||||
{
|
||||
Standard_Boolean hasloc = (HasLocation() || !myiniloc.IsIdentity());
|
||||
|
||||
|
||||
if(hasloc){
|
||||
if(myiniloc.IsIdentity())
|
||||
myTrsf = Location().Transformation();
|
||||
|
@ -43,13 +43,13 @@ void Select3D_SensitiveWire
|
||||
mysensitive.Append(aSensitive);
|
||||
else
|
||||
mysensitive.Append(aSensitive->GetConnected(Location()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
@ -60,7 +60,7 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
|
||||
if(HasLocation())
|
||||
if(aLoc == Location()) return;
|
||||
|
||||
|
||||
Select3D_SensitiveEntity::SetLocation(aLoc);
|
||||
for(Standard_Integer i=1;i<=mysensitive.Length();i++){
|
||||
if(mysensitive(i)->HasLocation()){
|
||||
@ -69,12 +69,12 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
|
||||
}
|
||||
else
|
||||
mysensitive(i)->SetLocation(aLoc);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ResetLocation
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::ResetLocation()
|
||||
@ -85,7 +85,7 @@ void Select3D_SensitiveWire::ResetLocation()
|
||||
mysensitive(i)->SetLocation(mysensitive(i)->Location()*Location().Inverted());
|
||||
else
|
||||
mysensitive(i)->ResetLocation();
|
||||
|
||||
|
||||
}
|
||||
Select3D_SensitiveEntity::ResetLocation();
|
||||
}
|
||||
@ -94,9 +94,9 @@ void Select3D_SensitiveWire::ResetLocation()
|
||||
// Purpose :
|
||||
//=====================================================
|
||||
void Select3D_SensitiveWire
|
||||
::Project(const Select3D_Projector& aProj)
|
||||
::Project(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
for ( Standard_Integer i=1; i<=mysensitive.Length(); i++)
|
||||
for ( Standard_Integer i=1; i<=mysensitive.Length(); i++)
|
||||
mysensitive(i)->Project(aProj);
|
||||
Select3D_SensitiveEntity::Project(aProj);
|
||||
}
|
||||
@ -113,12 +113,12 @@ void Select3D_SensitiveWire
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++)
|
||||
mysensitive.Value(i)->Areas(BidL);
|
||||
|
||||
|
||||
for(SelectBasics_ListIteratorOfListOfBox2d it(BidL);it.More();it.Next())
|
||||
BB.Add(it.Value());
|
||||
|
||||
|
||||
theareas.Append(BB);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
@ -144,9 +144,11 @@ Standard_Boolean Select3D_SensitiveWire
|
||||
}
|
||||
}
|
||||
}
|
||||
// Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
|
||||
return IsTouched;
|
||||
if ( ! IsTouched )
|
||||
return Standard_False;
|
||||
|
||||
// compute and validate the depth (::Depth()) along the eyeline
|
||||
return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
@ -162,7 +164,7 @@ Matches (const Standard_Real XMin,
|
||||
{
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++) {
|
||||
if (!(mysensitive.Value(i)->Matches(XMin,YMin,XMax,YMax,aTol)))
|
||||
if (!(mysensitive.Value(i)->Matches(XMin,YMin,XMax,YMax,aTol)))
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
@ -170,17 +172,17 @@ Matches (const Standard_Real XMin,
|
||||
|
||||
//=======================================================================
|
||||
//function : Matches
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Select3D_SensitiveWire::
|
||||
Matches (const TColgp_Array1OfPnt2d& aPoly,
|
||||
const Bnd_Box2d& aBox,
|
||||
const Standard_Real aTol)
|
||||
{
|
||||
{
|
||||
Standard_Integer i;
|
||||
for (i=1; i<=mysensitive.Length(); i++) {
|
||||
if (!(mysensitive.Value(i)->Matches(aPoly, aBox, aTol)))
|
||||
if (!(mysensitive.Value(i)->Matches(aPoly, aBox, aTol)))
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
@ -199,14 +201,14 @@ MaxBoxes () const
|
||||
|
||||
//=======================================================================
|
||||
//function : GetConnected
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopLoc_Location& aLoc)
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopLoc_Location& aLoc)
|
||||
{
|
||||
Handle(Select3D_SensitiveWire) SWIR = new Select3D_SensitiveWire(myOwnerId);
|
||||
for(Standard_Integer i=1;i<=mysensitive.Length();i++)
|
||||
SWIR->Add(mysensitive(i));
|
||||
|
||||
|
||||
if(HasLocation())
|
||||
SWIR->SetLocation(Location()*aLoc);
|
||||
else
|
||||
@ -217,7 +219,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopL
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
|
||||
@ -237,23 +239,23 @@ void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean Ful
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDepth
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
Standard_Real Select3D_SensitiveWire::ComputeDepth(const gp_Lin& EyeLine) const
|
||||
{
|
||||
|
||||
|
||||
if(myDetectedIndex==-1)
|
||||
// should be never called...
|
||||
return Precision::Infinite();
|
||||
return mysensitive(myDetectedIndex)->ComputeDepth(EyeLine);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLastPrj
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::SetLastPrj(const Select3D_Projector& Prj)
|
||||
void Select3D_SensitiveWire::SetLastPrj(const Handle(Select3D_Projector)& Prj)
|
||||
{
|
||||
Select3D_SensitiveEntity::SetLastPrj(Prj);
|
||||
for(Standard_Integer i=1;i<=mysensitive.Length();i++)
|
||||
@ -263,7 +265,7 @@ void Select3D_SensitiveWire::SetLastPrj(const Select3D_Projector& Prj)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEdges
|
||||
//purpose : returns the sensitive edges stored in this wire
|
||||
//purpose : returns the sensitive edges stored in this wire
|
||||
//=======================================================================
|
||||
void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdges )
|
||||
{
|
||||
@ -273,7 +275,7 @@ void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdge
|
||||
|
||||
//=============================================================================
|
||||
// Function : GetLastDetected
|
||||
// Purpose :
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
|
||||
{
|
||||
|
@ -4,8 +4,6 @@
|
||||
// Author: Robert COUBLANC
|
||||
// <rob>
|
||||
|
||||
|
||||
|
||||
#include <StdSelect.ixx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
@ -24,12 +22,8 @@
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <V3d_PerspectiveView.hxx>
|
||||
#include <StdSelect_BRepOwner.hxx>
|
||||
//#include <.hxx>
|
||||
|
||||
|
||||
|
||||
|
||||
Select3D_Projector StdSelect::GetProjector(const Handle(V3d_View)& aViou)
|
||||
Handle(Select3D_Projector) StdSelect::GetProjector(const Handle(V3d_View)& aViou)
|
||||
{
|
||||
Standard_Real Focale=0.,Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
|
||||
Standard_Boolean Pers=Standard_False;
|
||||
@ -48,7 +42,7 @@ Select3D_Projector StdSelect::GetProjector(const Handle(V3d_View)& aViou)
|
||||
gp_Ax3 Axe (At, Zpers, Xpers);
|
||||
gp_Trsf T;
|
||||
T.SetTransformation(Axe);
|
||||
return Select3D_Projector(T,Pers,Focale);
|
||||
return new Select3D_Projector(T,Pers,Focale);
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <V3d_PerspectiveView.hxx>
|
||||
#include <V3d_Plane.hxx>
|
||||
#include <Select3D_SensitiveEntity.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
|
||||
@ -83,6 +84,7 @@ static Standard_Boolean StdSelectDebugModeOn()
|
||||
|
||||
StdSelect_ViewerSelector3d
|
||||
::StdSelect_ViewerSelector3d():
|
||||
myprj(new Select3D_Projector()),
|
||||
mylastzoom(0.0),
|
||||
mypixtol(2),
|
||||
myupdatetol(Standard_True)
|
||||
@ -98,7 +100,7 @@ myupdatetol(Standard_True)
|
||||
//==================================================
|
||||
|
||||
StdSelect_ViewerSelector3d
|
||||
::StdSelect_ViewerSelector3d(const Select3D_Projector& aProj):
|
||||
::StdSelect_ViewerSelector3d(const Handle(Select3D_Projector)& aProj):
|
||||
myprj(aProj),
|
||||
mylastzoom(0.0),
|
||||
mypixtol(2),
|
||||
@ -147,7 +149,7 @@ void StdSelect_ViewerSelector3d
|
||||
//==================================================
|
||||
|
||||
void StdSelect_ViewerSelector3d
|
||||
::Set(const Select3D_Projector& aProj)
|
||||
::Set(const Handle(Select3D_Projector)& aProj)
|
||||
{
|
||||
myprj = aProj;
|
||||
toupdate=Standard_True;
|
||||
@ -167,7 +169,53 @@ void StdSelect_ViewerSelector3d
|
||||
Standard_Real Xr3d,Yr3d,Zr3d;
|
||||
gp_Pnt2d P2d;
|
||||
aView->Convert(XPix,YPix,Xr3d,Yr3d,Zr3d);
|
||||
myprj.Project(gp_Pnt(Xr3d,Yr3d,Zr3d),P2d);
|
||||
myprj->Project(gp_Pnt(Xr3d,Yr3d,Zr3d),P2d);
|
||||
|
||||
// compute depth limits if clipping plane(s) enabled
|
||||
gp_Lin anEyeLine = myprj->Shoot (P2d.X(), P2d.Y());
|
||||
Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD;
|
||||
Standard_Real aDepthFrom = ShortRealFirst();
|
||||
Standard_Real aDepthTo = ShortRealLast();
|
||||
for (aView->InitActivePlanes(); aView->MoreActivePlanes(); aView->NextActivePlanes())
|
||||
{
|
||||
aView->ActivePlane()->Plane (aPlaneA, aPlaneB, aPlaneC, aPlaneD);
|
||||
const gp_Dir& anEyeLineDir = anEyeLine.Direction();
|
||||
gp_Dir aPlaneNormal (aPlaneA, aPlaneB, aPlaneC);
|
||||
|
||||
Standard_Real aDotProduct = anEyeLineDir.Dot (aPlaneNormal);
|
||||
Standard_Real aDirection = -(aPlaneD + anEyeLine.Location().XYZ().Dot (aPlaneNormal.XYZ()));
|
||||
if (Abs (aDotProduct) < Precision::Angular())
|
||||
{
|
||||
// eyeline parallel to the clipping plane
|
||||
if (aDirection > 0.0)
|
||||
{
|
||||
// invalidate the interval
|
||||
aDepthTo = ShortRealFirst();
|
||||
aDepthFrom = ShortRealFirst();
|
||||
break;
|
||||
}
|
||||
// just ignore this plane
|
||||
continue;
|
||||
}
|
||||
|
||||
// compute distance along the eyeline from eyeline location to intersection with clipping plane
|
||||
Standard_Real aDepth = aDirection / aDotProduct;
|
||||
|
||||
// reduce depth limits
|
||||
if (aDotProduct < 0.0)
|
||||
{
|
||||
if (aDepth < aDepthTo)
|
||||
{
|
||||
aDepthTo = aDepth;
|
||||
}
|
||||
}
|
||||
else if (aDepth > aDepthFrom)
|
||||
{
|
||||
aDepthFrom = aDepth;
|
||||
}
|
||||
}
|
||||
myprj->DepthMinMax (aDepthFrom, aDepthTo);
|
||||
|
||||
InitSelect(P2d.X(),P2d.Y());
|
||||
}
|
||||
|
||||
@ -195,8 +243,8 @@ void StdSelect_ViewerSelector3d
|
||||
gp_Pnt2d P2d_1,P2d_2;
|
||||
aView->Convert(XPMin,YPMin,x1,y1,z1);
|
||||
aView->Convert(XPMax,YPMax,x2,y2,z2);
|
||||
myprj.Project(gp_Pnt(x1,y1,z1),P2d_1);
|
||||
myprj.Project(gp_Pnt(x2,y2,z2),P2d_2);
|
||||
myprj->Project(gp_Pnt(x1,y1,z1),P2d_1);
|
||||
myprj->Project(gp_Pnt(x2,y2,z2),P2d_2);
|
||||
|
||||
InitSelect (Min(P2d_1.X(),P2d_2.X()),
|
||||
Min(P2d_1.Y(),P2d_2.Y()),
|
||||
@ -236,7 +284,7 @@ void StdSelect_ViewerSelector3d
|
||||
gp_Pnt2d Pnt2d;
|
||||
|
||||
aView->Convert (XP, YP, x, y, z);
|
||||
myprj.Project (gp_Pnt (x, y, z), Pnt2d);
|
||||
myprj->Project (gp_Pnt (x, y, z), Pnt2d);
|
||||
|
||||
P2d->SetValue (i, Pnt2d);
|
||||
}
|
||||
@ -272,8 +320,8 @@ DisplayAreas(const Handle(V3d_View)& aView)
|
||||
}
|
||||
|
||||
SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities);
|
||||
Select3D_Projector prj = StdSelect::GetProjector(aView);
|
||||
prj.SetView(aView);
|
||||
Handle(Select3D_Projector) prj = StdSelect::GetProjector(aView);
|
||||
prj->SetView(aView);
|
||||
|
||||
|
||||
Graphic3d_Array1OfVertex Av1 (1,5);
|
||||
@ -291,23 +339,23 @@ DisplayAreas(const Handle(V3d_View)& aView)
|
||||
itb.Value().Get (xmin, ymin, xmax, ymax);
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
|
||||
prj.Transform (Pbid, prj.InvertedTransformation());
|
||||
prj->Transform (Pbid, prj->InvertedTransformation());
|
||||
Av1.SetValue (1, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmax + mytolerance, ymin - mytolerance, 0.0);
|
||||
prj.Transform (Pbid, prj.InvertedTransformation());
|
||||
prj->Transform (Pbid, prj->InvertedTransformation());
|
||||
Av1.SetValue (2, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmax + mytolerance, ymax + mytolerance, 0.0);
|
||||
prj.Transform (Pbid, prj.InvertedTransformation());
|
||||
prj->Transform (Pbid, prj->InvertedTransformation());
|
||||
Av1.SetValue (3, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymax + mytolerance, 0.0);
|
||||
prj.Transform (Pbid, prj.InvertedTransformation());
|
||||
prj->Transform (Pbid, prj->InvertedTransformation());
|
||||
Av1.SetValue (4,Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
|
||||
prj.Transform (Pbid, prj.InvertedTransformation());
|
||||
prj->Transform (Pbid, prj->InvertedTransformation());
|
||||
Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
myareagroup->Polyline (Av1);
|
||||
@ -421,14 +469,14 @@ UpdateProj(const Handle(V3d_View)& aView)
|
||||
GT.SetTranslationPart (loc);
|
||||
GT.SetVectorialPart (matrix);
|
||||
|
||||
myprj = Select3D_Projector (GT, Pers, mycoeff[9]);
|
||||
myprj = new Select3D_Projector (GT, Pers, mycoeff[9]);
|
||||
|
||||
// SAV 08/05/02 : fix for detection problem in a perspective view
|
||||
if (aView->Type() == V3d_PERSPECTIVE)
|
||||
myprj.SetView (aView);
|
||||
myprj->SetView (aView);
|
||||
// NKV 31/07/07 : fix for detection problem in case of custom matrix
|
||||
else if (aView->ViewOrientation().IsCustomMatrix())
|
||||
myprj.SetView (aView);
|
||||
myprj->SetView (aView);
|
||||
}
|
||||
|
||||
if (Abs (aView->Scale() - mylastzoom) > 1.e-3)
|
||||
@ -1008,23 +1056,23 @@ ComputeAreasPrs (const Handle(SelectMgr_Selection)& Sel)
|
||||
itb.Value().Get (xmin, ymin, xmax, ymax);
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
|
||||
myprj.Transform (Pbid, myprj.InvertedTransformation());
|
||||
myprj->Transform (Pbid, myprj->InvertedTransformation());
|
||||
Av1.SetValue (1, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmax + mytolerance, ymin - mytolerance, 0.0);
|
||||
myprj.Transform (Pbid, myprj.InvertedTransformation());
|
||||
myprj->Transform (Pbid, myprj->InvertedTransformation());
|
||||
Av1.SetValue (2, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmax + mytolerance, ymax + mytolerance, 0.0);
|
||||
myprj.Transform (Pbid, myprj.InvertedTransformation());
|
||||
myprj->Transform (Pbid, myprj->InvertedTransformation());
|
||||
Av1.SetValue (3, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymax + mytolerance, 0.0);
|
||||
myprj.Transform (Pbid, myprj.InvertedTransformation());
|
||||
myprj->Transform (Pbid, myprj->InvertedTransformation());
|
||||
Av1.SetValue (4, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
|
||||
myprj.Transform (Pbid, myprj.InvertedTransformation());
|
||||
myprj->Transform (Pbid, myprj->InvertedTransformation());
|
||||
Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
|
||||
|
||||
myareagroup->Polyline (Av1);
|
||||
|
@ -1,2 +1,4 @@
|
||||
inline const Select3D_Projector& StdSelect_ViewerSelector3d::
|
||||
Projector() const {return myprj;}
|
||||
inline const Handle(Select3D_Projector)& StdSelect_ViewerSelector3d::Projector() const
|
||||
{
|
||||
return myprj;
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Plane from V3d
|
||||
|
||||
inherits
|
||||
class Plane from V3d
|
||||
|
||||
inherits
|
||||
|
||||
TShared
|
||||
---Purpose: Defines the services of Plane type objects. Only
|
||||
-- the creation and editing of the functions is dealt
|
||||
-- the creation and editing of the functions is dealt
|
||||
-- with here.
|
||||
-- Warning: The representation of the clipping plane must be
|
||||
-- calculated by the application by means of Graphic3d.
|
||||
@ -20,12 +20,11 @@ inherits
|
||||
|
||||
uses
|
||||
|
||||
Viewer from V3d,
|
||||
View from V3d,
|
||||
ClipPlane from Visual3d,
|
||||
Structure from Graphic3d,
|
||||
Parameter from Quantity,
|
||||
Color from Quantity
|
||||
Color from Quantity
|
||||
|
||||
|
||||
raises
|
||||
@ -38,11 +37,11 @@ is
|
||||
-- The methods :
|
||||
--
|
||||
|
||||
Create ( VM : Viewer ; A: Parameter = 0.0;
|
||||
B: Parameter = 0.0;
|
||||
C: Parameter = 1.0;
|
||||
D: Parameter = 0.0
|
||||
) returns mutable Plane
|
||||
Create (A: Parameter = 0.0;
|
||||
B: Parameter = 0.0;
|
||||
C: Parameter = 1.0;
|
||||
D: Parameter = 0.0
|
||||
) returns mutable Plane
|
||||
---Level : Public
|
||||
---Purpose: Creates a clipping plane using the equation :
|
||||
-- <A>*X + <B>*Y + <C>*Z + <D> = 0.0
|
||||
@ -54,7 +53,7 @@ is
|
||||
---Category: Methods to modify the Attributs of the Plane
|
||||
--------------------------------------------------------
|
||||
|
||||
SetPlane( me : mutable; A,B,C,D : Parameter)
|
||||
SetPlane( me : mutable; A,B,C,D : Parameter)
|
||||
---Level : Public
|
||||
---Purpose: Modifies the plane equation.
|
||||
raises BadValue from Viewer
|
||||
@ -67,13 +66,13 @@ is
|
||||
aColor: Color from Quantity= Quantity_NOC_GRAY)
|
||||
---Level : Public
|
||||
---Purpose: Display the plane representation
|
||||
-- in the choosen view.
|
||||
-- in the choosen view.
|
||||
is virtual;
|
||||
|
||||
Erase(me: mutable) is static;
|
||||
---Level: Public
|
||||
---Purpose: Erase the plane representation.
|
||||
|
||||
|
||||
---------------------------------------------------
|
||||
---Category: Inquire methods
|
||||
---------------------------------------------------
|
||||
@ -84,7 +83,7 @@ is
|
||||
|
||||
IsDisplayed( me ) returns Boolean from Standard is static;
|
||||
---Level : Public
|
||||
---Purpose: Returns TRUE when the plane representation is displayed
|
||||
---Purpose: Returns TRUE when the plane representation is displayed
|
||||
|
||||
-----------------------------------------
|
||||
---Category: Private or Protected methods
|
||||
@ -97,7 +96,7 @@ is
|
||||
Update( me : mutable ) is static private;
|
||||
---Level : Internal
|
||||
---Purpose: Updates the the plane representation.
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
|
@ -6,33 +6,36 @@
|
||||
|
||||
//-Version
|
||||
|
||||
//-Design
|
||||
//-Design
|
||||
|
||||
//-Warning
|
||||
//-Warning
|
||||
|
||||
//-References
|
||||
|
||||
//-Language C++ 2.1
|
||||
|
||||
// for the class
|
||||
#include <V3d.hxx>
|
||||
#include <V3d_Plane.ixx>
|
||||
#include <Viewer_BadValue.hxx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
//-Constructors
|
||||
|
||||
V3d_Plane::V3d_Plane(const Handle(V3d_Viewer)& VM, const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) {
|
||||
V3d_Plane::V3d_Plane(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) {
|
||||
|
||||
Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::V3d_Plane, bad plane coefficients");
|
||||
|
||||
MyPlane = new Visual3d_ClipPlane(A,B,C,D) ;
|
||||
VM->AddPlane(this) ;
|
||||
MyPlane = new Visual3d_ClipPlane(A,B,C,D) ;
|
||||
}
|
||||
|
||||
//-Methods, in order
|
||||
|
||||
void V3d_Plane::SetPlane( const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) {
|
||||
|
||||
|
||||
Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::SetPlane, bad plane coefficients");
|
||||
|
||||
MyPlane->SetPlane(A,B,C,D) ;
|
||||
@ -42,31 +45,28 @@ void V3d_Plane::SetPlane( const Standard_Real A, const Standard_Real B, const St
|
||||
}
|
||||
}
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Array1OfVertex.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
void V3d_Plane::Display(const Handle(V3d_View)& aView,
|
||||
const Quantity_Color& aColor) {
|
||||
Handle(V3d_Viewer) theViewer = aView->Viewer();
|
||||
if (!MyGraphicStructure.IsNull()) {
|
||||
if (!MyGraphicStructure.IsNull()) {
|
||||
MyGraphicStructure->Clear();
|
||||
}
|
||||
Standard_Real size = theViewer->DefaultViewSize();
|
||||
Standard_Real size = theViewer->DefaultViewSize();
|
||||
Standard_Real offset = size/10000.;
|
||||
MyGraphicStructure = new Graphic3d_Structure(theViewer->Viewer());
|
||||
Handle(Graphic3d_Group) group = new Graphic3d_Group(MyGraphicStructure);
|
||||
Handle(Graphic3d_AspectFillArea3d) aspect =
|
||||
Handle(Graphic3d_AspectFillArea3d) aspect =
|
||||
new Graphic3d_AspectFillArea3d();
|
||||
Graphic3d_MaterialAspect plastic(Graphic3d_NOM_PLASTIC);
|
||||
plastic.SetColor(aColor);
|
||||
plastic.SetTransparency(0.5);
|
||||
aView->SetTransparency(Standard_True);
|
||||
aspect->SetFrontMaterial(plastic);
|
||||
aspect->SetFrontMaterial(plastic);
|
||||
// aspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
aspect->SetInteriorStyle (Aspect_IS_HATCH);
|
||||
aspect->SetHatchStyle (Aspect_HS_GRID_DIAGONAL_WIDE);
|
||||
MyGraphicStructure->SetPrimitivesAspect(aspect);
|
||||
Graphic3d_Array1OfVertex p(1,4);
|
||||
Graphic3d_Array1OfVertex p(1,4);
|
||||
p(1).SetCoord(-size/2.,-size/2.,offset);
|
||||
p(2).SetCoord(-size/2., size/2.,offset);
|
||||
p(3).SetCoord( size/2., size/2.,offset);
|
||||
@ -96,7 +96,6 @@ Standard_Boolean V3d_Plane::IsDisplayed() const {
|
||||
return MyGraphicStructure->IsDisplayed();
|
||||
}
|
||||
|
||||
#include <gp_Pln.hxx>
|
||||
void V3d_Plane::Update() {
|
||||
|
||||
if( !MyGraphicStructure.IsNull() ) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -305,12 +305,12 @@ void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx)
|
||||
|
||||
Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
|
||||
{
|
||||
return TheAISContext()->CurrentViewer();
|
||||
return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
|
||||
}
|
||||
|
||||
Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
|
||||
{
|
||||
return TheAISContext()->CurrentViewer();
|
||||
return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
|
||||
}
|
||||
|
||||
|
||||
@ -2066,7 +2066,7 @@ static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
|
||||
// Function : VAnimation
|
||||
//==================================================================================
|
||||
static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
|
||||
if (argc != 5) {
|
||||
if (argc =! 5) {
|
||||
di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
@ -2580,7 +2580,7 @@ Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
|
||||
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
|
||||
|
||||
// step 1: prepare the data
|
||||
if(curindex != 0){
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
@ -2639,7 +2639,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
|
||||
|
||||
// step 1: prepare the data
|
||||
|
||||
if(curindex != 0){
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
@ -2666,7 +2666,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
|
||||
IO = TheAISContext()->SelectedInteractive();
|
||||
}
|
||||
|
||||
if(curindex != 0)
|
||||
if(curindex!=0)
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
return IO;
|
||||
}
|
||||
@ -3079,7 +3079,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
|
||||
|
||||
static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if(argc != 2) return 1;
|
||||
if(argc!=2) return 1;
|
||||
|
||||
AIS_KindOfInteractive TheType;
|
||||
Standard_Integer TheSign(-1);
|
||||
|
@ -26,8 +26,10 @@
|
||||
|
||||
#include <OSD_Chronometer.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Visual3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Plane.hxx>
|
||||
#include <V3d.hxx>
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
@ -2556,6 +2558,180 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VClipPlane
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VClipPlane (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
Standard_Real coeffA, coeffB, coeffC, coeffD;
|
||||
if (aViewer.IsNull() || aView.IsNull())
|
||||
{
|
||||
std::cout << "Viewer not initialized!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// count an active planes count
|
||||
Standard_Integer aNewPlaneId = 1;
|
||||
Standard_Integer anActivePlanes = 0;
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aNewPlaneId)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
if (aView->IsActivePlane (aPlaneV3d))
|
||||
{
|
||||
++anActivePlanes;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
// just show info about existing planes
|
||||
Standard_Integer aPlaneId = 1;
|
||||
std::cout << "Active planes: " << anActivePlanes << " from maximal " << aView->View()->PlaneLimit() << "\n";
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
aPlaneV3d->Plane (coeffA, coeffB, coeffC, coeffD);
|
||||
gp_Pln aPlane (coeffA, coeffB, coeffC, coeffD);
|
||||
const gp_Pnt& aLoc = aPlane.Location();
|
||||
const gp_Dir& aNor = aPlane.Axis().Direction();
|
||||
Standard_Boolean isActive = aView->IsActivePlane (aPlaneV3d);
|
||||
std::cout << "Plane #" << aPlaneId
|
||||
<< " " << aLoc.X() << " " << aLoc.Y() << " " << aLoc.Z()
|
||||
<< " " << aNor.X() << " " << aNor.Y() << " " << aNor.Z()
|
||||
<< (isActive ? " on" : " off")
|
||||
<< (aPlaneV3d->IsDisplayed() ? ", displayed" : ", hidden")
|
||||
<< "\n";
|
||||
}
|
||||
if (aPlaneId == 1)
|
||||
{
|
||||
std::cout << "No defined clipping planes\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (argc == 2 || argc == 3)
|
||||
{
|
||||
Standard_Integer aPlaneIdToOff = (argc == 3) ? atoi (argv[1]) : 1;
|
||||
Standard_Boolean toIterateAll = (argc == 2);
|
||||
TCollection_AsciiString isOnOffStr ((argc == 3) ? argv[2] : argv[1]);
|
||||
isOnOffStr.LowerCase();
|
||||
Standard_Integer aPlaneId = 1;
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
if (aPlaneIdToOff == aPlaneId || toIterateAll)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
if (isOnOffStr.Search ("off") >= 0)
|
||||
{
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was disabled\n";
|
||||
}
|
||||
else if (isOnOffStr.Search ("on") >= 0)
|
||||
{
|
||||
// avoid z-fighting glitches
|
||||
aPlaneV3d->Erase();
|
||||
if (!aView->IsActivePlane (aPlaneV3d))
|
||||
{
|
||||
if (anActivePlanes < aView->View()->PlaneLimit())
|
||||
{
|
||||
aView->SetPlaneOn (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was enabled\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
|
||||
<< "You should disable or remove some existing plane to activate this one\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was already enabled\n";
|
||||
}
|
||||
}
|
||||
else if (isOnOffStr.Search ("del") >= 0 || isOnOffStr.Search ("rem") >= 0)
|
||||
{
|
||||
aPlaneV3d->Erase(); // not performed on destructor!!!
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aViewer->DelPlane (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
|
||||
if (toIterateAll)
|
||||
{
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->InitDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
aPlaneV3d = aViewer->DefinedPlane();
|
||||
aPlaneV3d->Erase(); // not performed on destructor!!!
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aViewer->DelPlane (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (isOnOffStr.Search ("disp") >= 0 || isOnOffStr.Search ("show") >= 0)
|
||||
{
|
||||
// avoid z-fighting glitches
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aPlaneV3d->Display (aView);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was shown and disabled\n";
|
||||
}
|
||||
else if (isOnOffStr.Search ("hide") >= 0)
|
||||
{
|
||||
aPlaneV3d->Erase();
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was hidden\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aPlaneIdToOff >= aPlaneId && !toIterateAll)
|
||||
{
|
||||
std::cout << "Clipping plane with id " << aPlaneIdToOff << " not found!\n";
|
||||
return 1;
|
||||
}
|
||||
aView->Update();
|
||||
return 0;
|
||||
}
|
||||
else if (argc != 7)
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aLocX = atof (argv[1]);
|
||||
Standard_Real aLocY = atof (argv[2]);
|
||||
Standard_Real aLocZ = atof (argv[3]);
|
||||
Standard_Real aNormDX = atof (argv[4]);
|
||||
Standard_Real aNormDY = atof (argv[5]);
|
||||
Standard_Real aNormDZ = atof (argv[6]);
|
||||
|
||||
Handle(V3d_Plane) aPlaneV3d = new V3d_Plane();
|
||||
gp_Pln aPlane (gp_Pnt (aLocX, aLocY, aLocZ), gp_Dir (aNormDX, aNormDY, aNormDZ));
|
||||
aPlane.Coefficients (coeffA, coeffB, coeffC, coeffD);
|
||||
aPlaneV3d->SetPlane(coeffA, coeffB, coeffC, coeffD);
|
||||
|
||||
aViewer->AddPlane (aPlaneV3d); // add to defined planes list
|
||||
std::cout << "Added clipping plane #" << aNewPlaneId << "\n";
|
||||
if (anActivePlanes < aView->View()->PlaneLimit())
|
||||
{
|
||||
aView->SetPlaneOn (aPlaneV3d); // add to enabled planes list
|
||||
aView->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
|
||||
<< "You should disable or remove some existing plane to activate the new one\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ObjectsCommands
|
||||
@ -2625,4 +2801,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
|
||||
__FILE__,VDrawSphere,group);
|
||||
|
||||
theCommands.Add("vclipplane",
|
||||
"vclipplane : vclipplane [x y z dx dy dz] [planeId {on/off/del/display/hide}]",
|
||||
__FILE__,VClipPlane,group);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user