#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <AIS_Selection.hxx>
-
-static TColStd_ListIteratorOfListOfInteger ItL;
//=======================================================================
//function : OpenLocalContext
//purpose :
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()->Set ((myLocalContexts.Extent() > 0)
+ ? myLocalContexts (untilnow)->MainSelector()->Projector()
+ : myMainSel->Projector());
+
NewLocal->MainSelector()->UpdateConversion();
-
- myLocalContexts.Bind(myCurLocalIndex,NewLocal);
+ myLocalContexts.Bind(myCurLocalIndex,NewLocal);
#ifdef DEB
cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
cout<<"\t\tNo Objects Were Loaded "<<endl;
#endif
return myCurLocalIndex;
-
}
//=======================================================================
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj)) return;
+ TColStd_ListIteratorOfListOfInteger ItL;
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
ItL.More();
ItL.Next()){
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())
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());
}
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())
//=======================================================================
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())
for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Unhighlight(It.Key());
}
-
+
if(updateviewer) myMainVwr->Update();
}
{
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();
-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;
}
// 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 );
}
//=======================================================================
//=======================================================================
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)
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 );
}
// 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...
// Function : Project
// Purpose :
//================================================================
-void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
+void MeshVS_SensitivePolyhedron::Project( const Handle(Select3D_Projector)& aProjector )
{
Select3D_SensitiveEntity::Project( 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();
}
if( inside )
- Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
-
- return inside;
+ {
+ return Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
+ }
+ return Standard_False;
}
//================================================================
// 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 );
}
//=======================================================================
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);
-
--- -- File: Poly.cdl
+-- File: Poly.cdl
-- Created: Mon Mar 6 09:38:50 1995
-- Author: Laurent PAINNOT
-- <lpa@metrox>
-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
TCollection,
TColStd,
gp,
- TColgp,
+ TColgp,
TShort
is
class Array1OfTriangle
instantiates Array1 from TCollection(Triangle from Poly);
-
+
class HArray1OfTriangle
instantiates HArray1 from TCollection(Triangle from Poly,
Array1OfTriangle from Poly);
-- 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.
-- referencing a triangulation.
- --
+ --
-- Tools to use triangulations
- --
-
+ --
+
class Connect;
---Purpose: Computes and stores the link from nodes to
-- triangles and from triangles to neighbouring
--
-- Package methods
- --
-
+ --
+
Catenate (lstTri: ListOfTriangulation from Poly)
returns Triangulation from Poly;
---Purpose: Join several triangulations to one new triangulation object.
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
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
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
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;
//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);
//=======================================================================
//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";
OS << UVNodes(i).Y() << "\n";
}
}
-
+
if (!Compact) OS << "\nTriangles :\n";
Standard_Integer nbTriangles = T->NbTriangles();
Standard_Integer n1, n2, n3;
//=======================================================================
//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";
//=======================================================================
//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";
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
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)
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
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")) {
Triangles(i).Set(n1,n2,n3);
}
-
+
Handle(Poly_Triangulation) T;
if (hasUV) T = new Poly_Triangulation(Nodes,UVNodes,Triangles);
//=======================================================================
//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")) {
Handle(Poly_Polygon3D) P;
if (!hasparameters)
P = new Poly_Polygon3D(Nodes);
- else
+ else
P = new Poly_Polygon3D(Nodes, Param);
P->Deflection(d);
//=======================================================================
//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")) {
Nodes(i).SetCoord(x,y);
}
- Handle(Poly_Polygon2D) P =
+ Handle(Poly_Polygon2D) P =
new Poly_Polygon2D(Nodes);
-
+
P->Deflection(d);
return P;
//=======================================================================
//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);
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;
+ }
+ }
+}
+
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 ()) {
--- 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.
+-- 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 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,
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;
+
+ 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;
- 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
+ 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;
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;
// Author: Christophe MARION
// <cma@sdsun2>
-#define IMP240100 //GG
+#define IMP240100 //GG
// Change RefToPix()/Convert() to Project() method.
#include <Select3D_Projector.ixx>
// 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);
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)
+//=======================================================================
+//function : Select3D_Projector
+//purpose :
+//=======================================================================
+
+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 :
+//purpose :
//=======================================================================
-Select3D_Projector::Select3D_Projector
- (const gp_Ax2& CS) :
- myPersp(Standard_False), myFocus(0)
+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);
//=======================================================================
//function : Select3D_Projector
-//purpose :
+//purpose :
//=======================================================================
-Select3D_Projector::Select3D_Projector
- (const gp_Ax2& CS,
- const Standard_Real Focus) :
- myPersp(Standard_True), myFocus(Focus)
+Select3D_Projector::Select3D_Projector (const gp_Ax2& CS,
+ const Standard_Real Focus)
+: myPersp(Standard_True),
+ myFocus(Focus),
+ myDepthMin(-Precision::Infinite()),
+ myDepthMax( Precision::Infinite())
{
myScaledTrsf.SetTransformation(CS);
myGTrsf.SetTrsf(myScaledTrsf);
//=======================================================================
//function : Select3D_Projector
-//purpose :
+//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_Trsf& T,
+ const Standard_Boolean Persp,
+ const Standard_Real Focus)
+: myPersp(Persp),
myFocus(Focus),
- myScaledTrsf(T)
+ myScaledTrsf(T),
+ myDepthMin(-Precision::Infinite()),
+ myDepthMax( Precision::Infinite())
{
myGTrsf.SetTrsf(myScaledTrsf);
Scaled();
//=======================================================================
//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();
//=======================================================================
//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;
//=======================================================================
//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;
//=======================================================================
//function : Project
-//purpose :
+//purpose :
//=======================================================================
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;
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());
//-- 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)
(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)
#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;
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());
Z= xmy05+z07;
break;
}
- default: {
+ default: {
gp_Pnt P2 = P;
Transform(P2);
P2.Coord(X,Y,Z);
}
}
}
- else {
+ else {
gp_Pnt P2 = P;
Transform(P2);
P2.Coord(X,Y,Z);
}
//=======================================================================
//function : Project
-//purpose :
+//purpose :
//=======================================================================
void Select3D_Projector::Project (const gp_Pnt& P,
//=======================================================================
//function : BoxAdd
-//purpose :
+//purpose :
//=======================================================================
void Select3D_Projector::BoxAdd
//=======================================================================
//function : Shoot
-//purpose :
+//purpose :
//=======================================================================
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));
//=======================================================================
//function : SetDirection
-//purpose :
+//purpose :
//=======================================================================
-void Select3D_Projector::SetDirection ()
+void Select3D_Projector::SetDirection ()
{
gp_Vec V1(1,0,0);
Transform(V1);
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;
}
//=======================================================================
//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;
//=======================================================================
//function : Perspective
-//purpose :
+//purpose :
//=======================================================================
inline Standard_Boolean Select3D_Projector::Perspective() const
//=======================================================================
//function : Transformation
-//purpose :
+//purpose :
//=======================================================================
inline const gp_GTrsf& Select3D_Projector::Transformation() const
//=======================================================================
//function : InvertedTransformation
-//purpose :
+//purpose :
//=======================================================================
inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
//=======================================================================
//function : FullTransformation
-//purpose :
+//purpose :
//=======================================================================
inline const gp_Trsf& Select3D_Projector::FullTransformation() const
//=======================================================================
//function : Focus
-//purpose :
+//purpose :
//=======================================================================
inline Standard_Real Select3D_Projector::Focus() const
//=======================================================================
//function : Transform
-//purpose :
+//purpose :
//=======================================================================
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);
{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);
}
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;
+}
// 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);
//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());
}
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;
}
//==================================================
-- 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.
EntityOwner from SelectBasics,
Location from TopLoc,
Lin from gp,
- Box2d from Bnd,
+ Box2d from Bnd,
Array1OfPnt2d from TColgp
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.
-- 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;
-- 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)
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.
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.
---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);
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;
Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
SelectBasics_SensitiveEntity(OwnerId),
-mylastprj(NULL),
-mylastdepth(0.0)
+mylastprj(),
+mylastdepth(ShortRealLast())
{}
//=======================================================================
//purpose :
//=======================================================================
-void Select3D_SensitiveEntity::Project(const Select3D_Projector& aPrj)
+void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
{
- mylastprj = (Standard_Address*)&aPrj;
+ mylastprj = aPrj;
}
//=======================================================================
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());
+ }
}
//=======================================================================
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;
}
//purpose :
//=======================================================================
-void Select3D_SensitiveEntity::SetLastPrj(const Select3D_Projector& aprj)
-{ mylastprj = (Standard_Address*)& aprj;}
+void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
+{ mylastprj = aprj; }
//=======================================================================
//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>
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)) {
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;
}
//=======================================================================
//=======================================================================
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;
}
//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);
}
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;
}
//=======================================================================
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;
}
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())
// 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;
}
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;
}
// 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();
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;
}
// 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;
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;
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::
#include <Select3D_SensitiveTriangulation.ixx>
#include <gp_Pnt2d.hxx>
+#include <Poly.hxx>
#include <Poly_Connect.hxx>
#include <CSLib_Class2d.hxx>
#include <TColStd_Array1OfInteger.hxx>
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)
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;
// 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,
//=======================================================================
//function : Select3D_SensitiveTriangulation
-//purpose :
+//purpose :
//=======================================================================
Select3D_SensitiveTriangulation::
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));
}
}
-
+
if(nbTriangles!=0) cdg /= nbTriangles;
myCDG3D = gp_Pnt(cdg);
-
+
ComputeTotalTrsf();
if(myTrsf.Form()!=gp_Identity)
//=======================================================================
//function : Select3D_SensitiveTriangulation
-//purpose :
+//purpose :
//=======================================================================
Select3D_SensitiveTriangulation::
Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
}
//=======================================================================
//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();
// 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;
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;
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);
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;
//=======================================================================
//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;
//=======================================================================
//function : IsFree
-//purpose :
+//purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
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;
}
//=======================================================================
//function : ResetLocation
-//purpose :
+//purpose :
//=======================================================================
-void Select3D_SensitiveTriangulation::ResetLocation()
+void Select3D_SensitiveTriangulation::ResetLocation()
{
Select3D_SensitiveEntity::ResetLocation();
ComputeTotalTrsf();
//=======================================================================
//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())
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;
//=======================================================================
//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)};
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())
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 &&
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;
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,
{
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);
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 )
{
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();
mysensitive.Append(aSensitive);
else
mysensitive.Append(aSensitive->GetConnected(Location()));
-
+
}
}
//=======================================================================
//function : SetLocation
-//purpose :
+//purpose :
//=======================================================================
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()){
}
else
mysensitive(i)->SetLocation(aLoc);
-
+
}
}
//=======================================================================
//function : ResetLocation
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveWire::ResetLocation()
mysensitive(i)->SetLocation(mysensitive(i)->Location()*Location().Inverted());
else
mysensitive(i)->ResetLocation();
-
+
}
Select3D_SensitiveEntity::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);
}
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);
-
+
}
//=====================================================
}
}
}
-// 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);
}
//=====================================================
{
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;
//=======================================================================
//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;
//=======================================================================
//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
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
//=======================================================================
//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++)
//=======================================================================
//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 )
{
//=============================================================================
// Function : GetLastDetected
-// Purpose :
+// Purpose :
//=============================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
{
// Author: Robert COUBLANC
// <rob>
-
-
#include <StdSelect.ixx>
#include <SelectMgr_Selection.hxx>
#include <Graphic3d_StructureManager.hxx>
#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;
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);
}
#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>
StdSelect_ViewerSelector3d
::StdSelect_ViewerSelector3d():
+myprj(new Select3D_Projector()),
mylastzoom(0.0),
mypixtol(2),
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),
//==================================================
void StdSelect_ViewerSelector3d
-::Set(const Select3D_Projector& aProj)
+::Set(const Handle(Select3D_Projector)& aProj)
{
myprj = aProj;
toupdate=Standard_True;
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());
}
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()),
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);
}
}
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);
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);
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)
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);
-inline const Select3D_Projector& StdSelect_ViewerSelector3d::
-Projector() const {return myprj;}
+inline const Handle(Select3D_Projector)& StdSelect_ViewerSelector3d::Projector() const
+{
+ return myprj;
+}
---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.
uses
- Viewer from V3d,
View from V3d,
ClipPlane from Visual3d,
Structure from Graphic3d,
Parameter from Quantity,
- Color from Quantity
+ Color from Quantity
raises
-- 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
---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
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
---------------------------------------------------
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
Update( me : mutable ) is static private;
---Level : Internal
---Purpose: Updates the the plane representation.
-
+
fields
//-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) ;
}
}
-#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);
return MyGraphicStructure->IsDisplayed();
}
-#include <gp_Pln.hxx>
void V3d_Plane::Update() {
if( !MyGraphicStructure.IsNull() ) {
--- File: Viewer.cdl
--- Created: Fri Jan 17 11:23:08 1992
--- Author: GG
--- Modified FMN - 02/02/98 -> Specifique UNIX
--- CAL - 16/07/98 -> S3892. Ajout grilles 3d.
--- GG - 15/12/99 -> GER61351 Add SetDefaultBackgroundColor()
--- and DefaultBackgroundColor() methods
--- GG - 20/01/00 -> IMP200100 Add GridDrawMode() method
--- GG - 24/01/00 -> IMP240100 Add SetGridEcho() methods
--- Add GridEcho() method.
--- Add ShowGridEcho() private method
--- SAV - 26/11/02 -> Add new field to store grid echo aspect
---
----Copyright: Matra Datavision 1992
+-- File: Viewer.cdl
+-- Created: Fri Jan 17 11:23:08 1992
+-- Author: GG
+-- Modified FMN - 02/02/98 -> Specifique UNIX
+-- CAL - 16/07/98 -> S3892. Ajout grilles 3d.
+-- GG - 15/12/99 -> GER61351 Add SetDefaultBackgroundColor()
+-- and DefaultBackgroundColor() methods
+-- GG - 20/01/00 -> IMP200100 Add GridDrawMode() method
+-- GG - 24/01/00 -> IMP240100 Add SetGridEcho() methods
+-- Add GridEcho() method.
+-- Add ShowGridEcho() private method
+-- SAV - 26/11/02 -> Add new field to store grid echo aspect
+--
+---Copyright: Matra Datavision 1992
class Viewer from V3d
- ---Version:
+ ---Version:
- ---Purpose: Defines services on Viewer type objects.
- -- The methods of this class allow editing and
- -- interrogation of the parameters linked to the viewer
- -- its friend classes (View,light,plane).
+ ---Purpose: Defines services on Viewer type objects.
+ -- The methods of this class allow editing and
+ -- interrogation of the parameters linked to the viewer
+ -- its friend classes (View,light,plane).
- ---Keywords: Viewer,Default Attributes
+ ---Keywords: Viewer,Default Attributes
---References:
Viewer from Viewer
-uses
+uses
--- GraphicDevice from Graphic3d,
GraphicDevice from Aspect,
- TypeOfUpdate from V3d,
- TypeOfVisualization from V3d,
- TypeOfShadingModel from V3d,
- TypeOfSurfaceDetail from V3d,
- TypeOfOrientation from V3d,
- View from V3d,
- Light from V3d,
- Plane from V3d,
- ListOfTransient from V3d,
+ TypeOfUpdate from V3d,
+ TypeOfVisualization from V3d,
+ TypeOfShadingModel from V3d,
+ TypeOfSurfaceDetail from V3d,
+ TypeOfOrientation from V3d,
+ View from V3d,
+ Light from V3d,
+ Plane from V3d,
+ ListOfTransient from V3d,
ListIteratorOfListOfTransient from TColStd,
TypeOfView from V3d,
- Vector from Graphic3d,
- ViewManager from Visual3d,
- NameOfColor from Quantity,
- TypeOfColor from Quantity,
- Color from Quantity,
- Length from Quantity,
- PlaneAngle from Quantity,
- Background from Aspect,
- GradientBackground from Aspect,
- Parameter from Quantity,
- OrthographicView from V3d,
- PerspectiveView from V3d,
+ Vector from Graphic3d,
+ ViewManager from Visual3d,
+ NameOfColor from Quantity,
+ TypeOfColor from Quantity,
+ Color from Quantity,
+ Length from Quantity,
+ PlaneAngle from Quantity,
+ Background from Aspect,
+ GradientBackground from Aspect,
+ Parameter from Quantity,
+ OrthographicView from V3d,
+ PerspectiveView from V3d,
AsciiString,ExtendedString from TCollection,
Ax3 from gp,Structure from Graphic3d,
- Vertex from Graphic3d,
- Group from Graphic3d,
- AspectMarker3d from Graphic3d,
- RectangularGrid from V3d,
- CircularGrid from V3d,
- Grid from Aspect,
- GridType from Aspect,
- GridDrawMode from Aspect,
+ Vertex from Graphic3d,
+ Group from Graphic3d,
+ AspectMarker3d from Graphic3d,
+ RectangularGrid from V3d,
+ CircularGrid from V3d,
+ Grid from Aspect,
+ GridType from Aspect,
+ GridDrawMode from Aspect,
GradientFillMethod from Aspect
-
raises
- BadValue from Viewer
+ BadValue from Viewer
is
--- Create ( Device : GraphicDevice from Graphic3d;
- Create ( Device : GraphicDevice from Aspect;
- aName : ExtString from Standard;
- aDomain : CString from Standard = "";
- ViewSize : Length from Quantity = 1000.0 ;
- ViewProj : TypeOfOrientation from V3d= V3d_XposYnegZpos ;
- ViewBackground : NameOfColor from Quantity = Quantity_NOC_GRAY30;
- Visualization : TypeOfVisualization from V3d = V3d_ZBUFFER;
- ShadingModel : TypeOfShadingModel from V3d = V3d_GOURAUD ;
- UpdateMode : TypeOfUpdate from V3d = V3d_WAIT;
- ComputedMode : Boolean from Standard = Standard_True;
- DefaultComputedMode: Boolean from Standard = Standard_True;
- SurfaceDetail : TypeOfSurfaceDetail from V3d = V3d_TEX_NONE)
- returns mutable Viewer from V3d
- ---Purpose: Create a Viewer on the given device with the given parameters or
- -- with their default values.
- raises BadValue from Viewer ;
- ---Purpose: If the size of the view is <= 0
- -- if ComputedMode is false, only the degenerate mode will be used.
- --
- -- Warning: Client must creates a graphic-device of type
- -- Graphic3d_GraphicDevice under UNIX
- -- or Graphic3d_WNTGraphicDevice under WindowsNT
+ Create ( Device : GraphicDevice from Aspect;
+ aName : ExtString from Standard;
+ aDomain : CString from Standard = "";
+ ViewSize : Length from Quantity = 1000.0 ;
+ ViewProj : TypeOfOrientation from V3d= V3d_XposYnegZpos ;
+ ViewBackground : NameOfColor from Quantity = Quantity_NOC_GRAY30;
+ Visualization : TypeOfVisualization from V3d = V3d_ZBUFFER;
+ ShadingModel : TypeOfShadingModel from V3d = V3d_GOURAUD ;
+ UpdateMode : TypeOfUpdate from V3d = V3d_WAIT;
+ ComputedMode : Boolean from Standard = Standard_True;
+ DefaultComputedMode: Boolean from Standard = Standard_True;
+ SurfaceDetail : TypeOfSurfaceDetail from V3d = V3d_TEX_NONE)
+ returns mutable Viewer from V3d
+ ---Purpose: Create a Viewer on the given device with the given parameters or
+ -- with their default values.
+ raises BadValue from Viewer ;
+ ---Purpose: If the size of the view is <= 0
+ -- if ComputedMode is false, only the degenerate mode will be used.
+ --
+ -- Warning: Client must creates a graphic-device of type
+ -- Graphic3d_GraphicDevice under UNIX
+ -- or Graphic3d_WNTGraphicDevice under WindowsNT
CreateView (me: mutable) returns mutable View from V3d;
- ---Level: Public
- ---Purpose: creates a view in the viewer according to its
- -- default parameters.
-
+ ---Level: Public
+ ---Purpose: creates a view in the viewer according to its
+ -- default parameters.
+
DefaultOrthographicView(me: mutable) returns mutable OrthographicView from V3d;
-
+
DefaultPerspectiveView(me: mutable) returns mutable PerspectiveView from V3d;
-------------------------------------------------------
- ---Category: Methods to modify the status of the viewer
+ ---Category: Methods to modify the status of the viewer
-------------------------------------------------------
SetViewOn (me:mutable );
- ---Level: Public
- ---Purpose: Activates all of the views of a viewer attached
- -- to a window.
-
- SetViewOn (me:mutable; View : View from V3d )
- ---Level: Public
- ---Purpose: Activates a particular view in the Viewer .
- -- Must be call if the Window attached to the view
- -- has been Deiconified .
- raises BadValue from Viewer;
- -- If the view is not mapped on the window.
+ ---Level: Public
+ ---Purpose: Activates all of the views of a viewer attached
+ -- to a window.
+
+ SetViewOn (me:mutable; View : View from V3d )
+ ---Level: Public
+ ---Purpose: Activates a particular view in the Viewer .
+ -- Must be call if the Window attached to the view
+ -- has been Deiconified .
+ raises BadValue from Viewer;
+ -- If the view is not mapped on the window.
SetViewOff (me:mutable);
- ---Level: Public
+ ---Level: Public
---Purpose: Deactivates all the views of a Viewer
- -- attached to a window.
-
- SetViewOff (me:mutable; View : View from V3d)
- ---Level: Public
- ---Purpose: Deactivates a particular view in the Viewer.
- -- Must be call if the Window attached to the view
- -- has been Iconified .
- raises BadValue from Viewer;
- -- If the view is not mapped on the window.
+ -- attached to a window.
+
+ SetViewOff (me:mutable; View : View from V3d)
+ ---Level: Public
+ ---Purpose: Deactivates a particular view in the Viewer.
+ -- Must be call if the Window attached to the view
+ -- has been Iconified .
+ raises BadValue from Viewer;
+ -- If the view is not mapped on the window.
Update (me:mutable ) is redefined static;
- ---Level: Public
+ ---Level: Public
---Purpose: Updates the display of all the views of a viewer.
- -- Must be called when the views must be updated
- -- simultaneously while the Update mode is deferred (WAIT).
+ -- Must be called when the views must be updated
+ -- simultaneously while the Update mode is deferred (WAIT).
UpdateLights (me: mutable);
- ---Level: Public
- ---Purpose: Updates the lights of all the views of a viewer.
+ ---Level: Public
+ ---Purpose: Updates the lights of all the views of a viewer.
Redraw ( me );
- ---Level: Public
+ ---Level: Public
---Purpose: Redraws all the views of the Viewer even if no
- -- modification has taken place. Must be called if
- -- all the views of the Viewer are exposed, as for
- -- example in a global DeIconification.
+ -- modification has taken place. Must be called if
+ -- all the views of the Viewer are exposed, as for
+ -- example in a global DeIconification.
Remove (me:mutable);
- ---Level: Public
+ ---Level: Public
---Purpose: Suppresses the Viewer.
- Erase ( me );
- ---Level: Public
- ---Purpose: Erase all Objects in All the views.
+ Erase ( me );
+ ---Level: Public
+ ---Purpose: Erase all Objects in All the views.
- UnHighlight ( me );
- ---Level: Public
- ---Purpose: UnHighlight all Objects in All the views.
+ UnHighlight ( me );
+ ---Level: Public
+ ---Purpose: UnHighlight all Objects in All the views.
- SetDefaultBackgroundColor (me:mutable; Type : TypeOfColor; V1, V2, V3 : Parameter );
- ---Level: Public
- ---Purpose: Defines the default base colour of views attached
- -- to the Viewer by supplying the type of colour
- -- definition and the three component values..
+ SetDefaultBackgroundColor (me:mutable; Type : TypeOfColor; V1, V2, V3 : Parameter );
+ ---Level: Public
+ ---Purpose: Defines the default base colour of views attached
+ -- to the Viewer by supplying the type of colour
+ -- definition and the three component values..
- SetDefaultBackgroundColor (me:mutable; Name : NameOfColor );
- ---Level: Public
- ---Purpose: Defines the default background colour of views
- -- attached to the viewer by supplying the name of the
- -- colour under the form Quantity_NOC_xxxx .
+ SetDefaultBackgroundColor (me:mutable; Name : NameOfColor );
+ ---Level: Public
+ ---Purpose: Defines the default background colour of views
+ -- attached to the viewer by supplying the name of the
+ -- colour under the form Quantity_NOC_xxxx .
- SetDefaultBackgroundColor (me:mutable; Color : Color from Quantity);
- ---Level: Public
- ---Purpose: Defines the default background colour of views
- -- attached to the viewer by supplying the color object
+ SetDefaultBackgroundColor (me:mutable; Color : Color from Quantity);
+ ---Level: Public
+ ---Purpose: Defines the default background colour of views
+ -- attached to the viewer by supplying the color object
- SetDefaultBgGradientColors ( me:mutable;
+ SetDefaultBgGradientColors ( me:mutable;
Name1 : NameOfColor;
Name2 : NameOfColor;
FillStyle : GradientFillMethod from Aspect = Aspect_GFM_HOR );
- ---Level: Public
- ---Purpose: Defines the default gradient background colours of view
- -- attached to the viewer by supplying the name of the
- -- colours under the form Quantity_NOC_xxxx .
+ ---Level: Public
+ ---Purpose: Defines the default gradient background colours of view
+ -- attached to the viewer by supplying the name of the
+ -- colours under the form Quantity_NOC_xxxx .
- SetDefaultBgGradientColors ( me : mutable ;
- Color1 : Color from Quantity;
+ SetDefaultBgGradientColors ( me : mutable ;
+ Color1 : Color from Quantity;
Color2 : Color from Quantity;
FillStyle : GradientFillMethod from Aspect = Aspect_GFM_HOR );
---Level: Public
- ---Purpose: Defines the default gradient background colours of views
- -- attached to the viewer by supplying the colour objects
+ ---Purpose: Defines the default gradient background colours of views
+ -- attached to the viewer by supplying the colour objects
- SetDefaultViewSize (me:mutable; Size : Length )
- ---Level: Public
- ---Purpose: Gives a default size for the creation of views of
- -- the viewer.
- raises BadValue from Viewer;
- -- If the size of the view is <= 0
+ SetDefaultViewSize (me:mutable; Size : Length )
+ ---Level: Public
+ ---Purpose: Gives a default size for the creation of views of
+ -- the viewer.
+ raises BadValue from Viewer;
+ -- If the size of the view is <= 0
- SetDefaultViewProj (me:mutable; Orientation : TypeOfOrientation );
- ---Level: Public
- ---Purpose: Gives the default projection for creating views
- -- in the viewer.
+ SetDefaultViewProj (me:mutable; Orientation : TypeOfOrientation );
+ ---Level: Public
+ ---Purpose: Gives the default projection for creating views
+ -- in the viewer.
- SetDefaultVisualization(me:mutable; Type : TypeOfVisualization from V3d);
- ---Level: Public
- ---Purpose: Gives the default visualisation mode..
+ SetDefaultVisualization(me:mutable; Type : TypeOfVisualization from V3d);
+ ---Level: Public
+ ---Purpose: Gives the default visualisation mode..
SetZBufferManagment(me: mutable; Automatic: Boolean from Standard);
- ---Level: Public
- ---Purpose: defines the strategy concerning the ZBuffer activity.
- -- If Automatic is true, ZBuffer will be activated or
- -- deactivated depending on the fact that faces exist or
- -- not in the Viewer. This will optimize the response time
- -- in the case where only wireframe objects are displayed.
- -- If Automatic is False, ZBuffer will be activated or
- -- deactivated depending on the choice of SetVisualization
- -- in each View.
- -- Note that by default, the ZBufferManagment is not automatic.
-
+ ---Level: Public
+ ---Purpose: defines the strategy concerning the ZBuffer activity.
+ -- If Automatic is true, ZBuffer will be activated or
+ -- deactivated depending on the fact that faces exist or
+ -- not in the Viewer. This will optimize the response time
+ -- in the case where only wireframe objects are displayed.
+ -- If Automatic is False, ZBuffer will be activated or
+ -- deactivated depending on the choice of SetVisualization
+ -- in each View.
+ -- Note that by default, the ZBufferManagment is not automatic.
+
ZBufferManagment(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: returns the ZBuffer stategy choice.
-
- SetDefaultShadingModel(me:mutable; Type : TypeOfShadingModel from V3d);
- ---Level: Public
- ---Purpose: Gives the default type of SHADING.
-
- SetDefaultSurfaceDetail(me:mutable; Type : TypeOfSurfaceDetail from V3d);
- ---Level: Public
- ---Purpose: Gives the default type of texture mapping.
+ ---Level: Public
+ ---Purpose: returns the ZBuffer stategy choice.
+
+ SetDefaultShadingModel(me:mutable; Type : TypeOfShadingModel from V3d);
+ ---Level: Public
+ ---Purpose: Gives the default type of SHADING.
+
+ SetDefaultSurfaceDetail(me:mutable; Type : TypeOfSurfaceDetail from V3d);
+ ---Level: Public
+ ---Purpose: Gives the default type of texture mapping.
SetDefaultAngle (me:mutable; Angle : PlaneAngle from Quantity);
- ---Level: Public
-
- SetUpdateMode ( me: mutable ; Mode : TypeOfUpdate from V3d );
- ---Level: Public
- ---Purpose: Defines the mode of regenerating the views making
- -- up the viewer. This can be immediate <ASAP> or
- -- deferred <WAIT>. In this latter case, the views are
- -- updated when the method Update(me) is called.
+ ---Level: Public
+
+ SetUpdateMode ( me: mutable ; Mode : TypeOfUpdate from V3d );
+ ---Level: Public
+ ---Purpose: Defines the mode of regenerating the views making
+ -- up the viewer. This can be immediate <ASAP> or
+ -- deferred <WAIT>. In this latter case, the views are
+ -- updated when the method Update(me) is called.
SetDefaultTypeOfView(me:mutable; Type : TypeOfView from V3d);
- ---Level: Public
+ ---Level: Public
SetPrivilegedPlane(me: mutable; aPlane: Ax3 from gp);
- ---Level: Public
-
+ ---Level: Public
+
PrivilegedPlane(me) returns Ax3 from gp;
- ---Level: Public
-
- DisplayPrivilegedPlane(me: mutable; OnOff: Boolean from Standard; aSize: Length from Quantity = 1);
- ---Level: Public
-
- SetLightOn(me:mutable; MyLight : Light from V3d )
- ---Level: Public
- ---Purpose: Activates MyLight in the viewer.
- raises BadValue from Viewer;
- -- If No More Light can be activated in MyViewer .
-
- SetLightOn(me:mutable)
- ---Level: Public
- ---Purpose: Activates all the lights defined in this viewer.
- raises BadValue from Viewer;
- -- If No More Light can be activated in MyViewer .
-
- SetLightOff(me:mutable; MyLight : Light from V3d );
- ---Level: Public
- ---Purpose: Desactivate MyLight in this viewer.
-
- SetLightOff(me:mutable);
- ---Level: Public
- ---Purpose: Deactivate all the Lights defined in this viewer.
-
- DelLight(me:mutable; MyLight : Light from V3d);
- ---Level: Internal
- ---Purpose: Delete Light in Sequence Of Lights.
-
+ ---Level: Public
+
+ DisplayPrivilegedPlane(me: mutable; OnOff: Boolean from Standard; aSize: Length from Quantity = 1);
+ ---Level: Public
+
+ SetLightOn(me:mutable; MyLight : Light from V3d )
+ ---Level: Public
+ ---Purpose: Activates MyLight in the viewer.
+ raises BadValue from Viewer;
+ -- If No More Light can be activated in MyViewer .
+
+ SetLightOn(me:mutable)
+ ---Level: Public
+ ---Purpose: Activates all the lights defined in this viewer.
+ raises BadValue from Viewer;
+ -- If No More Light can be activated in MyViewer .
+
+ SetLightOff(me:mutable; MyLight : Light from V3d );
+ ---Level: Public
+ ---Purpose: Desactivate MyLight in this viewer.
+
+ SetLightOff(me:mutable);
+ ---Level: Public
+ ---Purpose: Deactivate all the Lights defined in this viewer.
+
+ DelLight(me:mutable; MyLight : Light from V3d);
+ ---Level: Internal
+ ---Purpose: Delete Light in Sequence Of Lights.
+
SetCurrentSelectedLight (me : mutable; TheLight : Light from V3d);
- ---Level: Advanced
+ ---Level: Advanced
---Purpose: Defines the selected light.
- ClearCurrentSelectedLight (me : mutable);
- ---Level: Advanced
- ---Purpose: Defines the selected light at NULL.
+ ClearCurrentSelectedLight (me : mutable);
+ ---Level: Advanced
+ ---Purpose: Defines the selected light at NULL.
-----------------------------------------
---Category: Inquire methods
-----------------------------------------
- DefaultBackgroundColor ( me ; Type : TypeOfColor ; V1,V2,V3 : out Parameter);
- ---Level: Public
- ---Purpose: Returns the default background colour depending of the type.
- DefaultBackgroundColor ( me ) returns Color from Quantity;
- ---Level: Public
- ---Purpose: Returns the default background colour object.
+ DefaultBackgroundColor ( me ; Type : TypeOfColor ; V1,V2,V3 : out Parameter);
+ ---Level: Public
+ ---Purpose: Returns the default background colour depending of the type.
+ DefaultBackgroundColor ( me ) returns Color from Quantity;
+ ---Level: Public
+ ---Purpose: Returns the default background colour object.
- DefaultBgGradientColors( me;
+ DefaultBgGradientColors( me;
Color1 : out Color from Quantity;
- Color2 : out Color from Quantity) ;
- ---Level: Public
+ Color2 : out Color from Quantity) ;
+ ---Level: Public
---Purpose: Returns the gradient background colour objects of the view.
- DefaultViewSize ( me) returns Length;
- ---Level: Public
- ---Purpose: Returns the default size of the view.
+ DefaultViewSize ( me) returns Length;
+ ---Level: Public
+ ---Purpose: Returns the default size of the view.
- DefaultViewProj ( me) returns TypeOfOrientation;
- ---Level: Public
- ---Purpose: Returns the default Projection.
+ DefaultViewProj ( me) returns TypeOfOrientation;
+ ---Level: Public
+ ---Purpose: Returns the default Projection.
- DefaultVisualization ( me ) returns TypeOfVisualization from V3d;
- ---Level: Public
- ---Purpose: Returns the default type of Visualization.
+ DefaultVisualization ( me ) returns TypeOfVisualization from V3d;
+ ---Level: Public
+ ---Purpose: Returns the default type of Visualization.
- DefaultShadingModel ( me ) returns TypeOfShadingModel from V3d;
- ---Level: Public
- ---Purpose: Returns the default type of Shading
+ DefaultShadingModel ( me ) returns TypeOfShadingModel from V3d;
+ ---Level: Public
+ ---Purpose: Returns the default type of Shading
- DefaultSurfaceDetail ( me ) returns TypeOfSurfaceDetail from V3d;
- ---Level: Public
- ---Purpose: Returns the default type of texture mapping
+ DefaultSurfaceDetail ( me ) returns TypeOfSurfaceDetail from V3d;
+ ---Level: Public
+ ---Purpose: Returns the default type of texture mapping
DefaultAngle ( me ) returns PlaneAngle from Quantity;
- ---Level: Public
-
- UpdateMode ( me ) returns TypeOfUpdate from V3d;
- ---Level: Public
- ---Purpose: Returns the regeneration mode of views in the viewer.
+ ---Level: Public
+
+ UpdateMode ( me ) returns TypeOfUpdate from V3d;
+ ---Level: Public
+ ---Purpose: Returns the regeneration mode of views in the viewer.
IfMoreViews( me ) returns Boolean;
- ---Level: Advanced
+ ---Level: Advanced
---Purpose: Returns True if One View more can be
-- activated in this Viewer.
- --
-
- ------------------------------
- ---Category: iteration methods
- ------------------------------
-
- InitActiveViews(me: mutable);
- ---Level: Advanced
- ---Purpose: initializes an iteration on the active views.
-
- MoreActiveViews (me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there are more active view(s) to return.
-
- NextActiveViews (me: mutable);
- ---Level: Advanced
+ --
+
+ ------------------------------
+ ---Category: iteration methods
+ ------------------------------
+
+ InitActiveViews(me: mutable);
+ ---Level: Advanced
+ ---Purpose: initializes an iteration on the active views.
+
+ MoreActiveViews (me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there are more active view(s) to return.
+
+ NextActiveViews (me: mutable);
+ ---Level: Advanced
---Purpose : Go to the next active view
-- (if there is not, ActiveView will raise an exception)
-
+
ActiveView(me) returns mutable View from V3d;
- ---Level: Advanced
-
- LastActiveView(me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there is only
- -- one active view.
-
- InitDefinedViews(me: mutable);
- ---Level: Advanced
- ---Purpose: initializes an iteration on the Defined views.
-
-
- MoreDefinedViews (me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there are more Defined view(s) to return.
-
-
- NextDefinedViews (me: mutable);
- ---Level: Advanced
+ ---Level: Advanced
+
+ LastActiveView(me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there is only
+ -- one active view.
+
+ InitDefinedViews(me: mutable);
+ ---Level: Advanced
+ ---Purpose: initializes an iteration on the Defined views.
+
+
+ MoreDefinedViews (me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there are more Defined view(s) to return.
+
+
+ NextDefinedViews (me: mutable);
+ ---Level: Advanced
---Purpose : Go to the next Defined view
-- (if there is not, DefinedView will raise an exception)
-
- DefinedView(me) returns View from V3d;
- ---Level: Advanced
-
- InitActiveLights(me: mutable);
- ---Level: Advanced
- ---Purpose: initializes an iteration on the active Lights.
-
- MoreActiveLights (me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there are more active Light(s) to return.
-
-
- NextActiveLights (me: mutable);
- ---Level: Advanced
+
+ DefinedView(me) returns View from V3d;
+ ---Level: Advanced
+
+ InitActiveLights(me: mutable);
+ ---Level: Advanced
+ ---Purpose: initializes an iteration on the active Lights.
+
+ MoreActiveLights (me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there are more active Light(s) to return.
+
+
+ NextActiveLights (me: mutable);
+ ---Level: Advanced
---Purpose : Go to the next active Light
-- (if there is not, ActiveLight will raise an exception)
-
- ActiveLight(me) returns mutable Light from V3d;
- ---Level: Advanced
-
- InitDefinedLights(me: mutable);
- ---Level: Advanced
- ---Purpose: initializes an iteration on the Defined Lights.
-
- MoreDefinedLights (me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there are more Defined Light(s) to return.
-
- NextDefinedLights (me: mutable);
- ---Level: Advanced
+
+ ActiveLight(me) returns mutable Light from V3d;
+ ---Level: Advanced
+
+ InitDefinedLights(me: mutable);
+ ---Level: Advanced
+ ---Purpose: initializes an iteration on the Defined Lights.
+
+ MoreDefinedLights (me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there are more Defined Light(s) to return.
+
+ NextDefinedLights (me: mutable);
+ ---Level: Advanced
---Purpose : Go to the next Defined Light
-- (if there is not, DefinedLight will raise an exception)
-
+
DefinedLight(me) returns Light from V3d;
- ---Level: Advanced
-
- InitDefinedPlanes(me: mutable);
- ---Level: Advanced
- ---Purpose: initializes an iteration on the Defined Planes.
-
- MoreDefinedPlanes (me) returns Boolean from Standard;
- ---Level: Advanced
- ---Purpose: returns true if there are more Defined Plane(s) to return.
-
- NextDefinedPlanes (me: mutable);
- ---Level: Advanced
+ ---Level: Advanced
+
+ AddPlane( me: mutable; MyPlane : Plane from V3d);
+ ---Purpose: Adds Plane in Sequence Of Planes.
+
+ DelPlane( me: mutable; MyPlane : Plane from V3d);
+ ---Purpose: Delete Plane in Sequence Of Planes.
+
+ InitDefinedPlanes(me: mutable);
+ ---Level: Advanced
+ ---Purpose: initializes an iteration on the Defined Planes.
+
+ MoreDefinedPlanes (me) returns Boolean from Standard;
+ ---Level: Advanced
+ ---Purpose: returns true if there are more Defined Plane(s) to return.
+
+ NextDefinedPlanes (me: mutable);
+ ---Level: Advanced
---Purpose : Go to the next Defined Plane
-- (if there is not, DefinedPlane will raise an exception)
-
+
DefinedPlane(me) returns Plane from V3d;
- ---Level: Advanced
-
- Viewer (me) returns mutable ViewManager ;
- ---Level: Advanced
- ---Purpose: Returns the viewer associated to Visual3d .
+ ---Level: Advanced
+
+ Viewer (me) returns mutable ViewManager ;
+ ---Level: Advanced
+ ---Purpose: Returns the viewer associated to Visual3d .
CurrentSelectedLight (me) returns Light from V3d;
- ---Level: Advanced
- ---Purpose: Returns the Selected Light.
+ ---Level: Advanced
+ ---Purpose: Returns the Selected Light.
IsGlobalLight (me; TheLight : Light from V3d) returns Boolean;
- ---Level: Advanced
-
+ ---Level: Advanced
+
ComputedMode(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: returns true if the computed mode can be used.
+ ---Level: Public
+ ---Purpose: returns true if the computed mode can be used.
DefaultComputedMode(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: returns true if by default the computed mode must be used.
+ ---Level: Public
+ ---Purpose: returns true if by default the computed mode must be used.
-----------------------------------------
- ---Category: grid management
+ ---Category: grid management
-----------------------------------------
- ActivateGrid (me : mutable;
- aGridType : GridType from Aspect;
- aGridDrawMode : GridDrawMode from Aspect)
- is static;
- ---Purpose: Activates the grid in all views of <me>.
- ---Level : Public
- ---Category: grid management
-
- DeactivateGrid (me : mutable)
- is static;
- ---Purpose: Deactivates the grid in all views of <me>.
- ---Level : Public
- ---Category: grid management
-
- SetGridEcho (me : mutable;
- showGrid: Boolean from Standard = Standard_True) is static;
- ---Purpose: Show/Don't show grid echo to the hit point.
- -- If TRUE,the grid echo will be shown at ConvertToGrid() time.
- ---Level : Public
- ---Category: grid management
-
- SetGridEcho (me : mutable;
- aMarker: AspectMarker3d from Graphic3d) is static;
- ---Purpose: Show grid echo <aMarker> to the hit point.
- -- Warning: When the grid echo marker is not set,
- -- a default marker is build with the attributes:
- -- marker type : Aspect_TOM_STAR
- -- marker color : Quantity_NOC_GRAY90
- -- marker size : 3.0
- ---Level : Public
- ---Category: grid management
-
- GridEcho (me) returns Boolean from Standard is static;
- ---Purpose: Returns TRUE when grid echo must be displayed
- -- at hit point.
- ---Level : Public
- ---Category: grid management
-
- IsActive (me)
- returns Boolean from Standard
- is static;
- ---Purpose: Returns Standard_True if a grid is activated in <me>.
- ---Level : Public
- ---Category: grid management
-
- Grid (me)
- returns mutable Grid from Aspect
- is static;
+ ActivateGrid (me : mutable;
+ aGridType : GridType from Aspect;
+ aGridDrawMode : GridDrawMode from Aspect)
+ is static;
+ ---Purpose: Activates the grid in all views of <me>.
+ ---Level : Public
+ ---Category: grid management
+
+ DeactivateGrid (me : mutable)
+ is static;
+ ---Purpose: Deactivates the grid in all views of <me>.
+ ---Level : Public
+ ---Category: grid management
+
+ SetGridEcho (me : mutable;
+ showGrid: Boolean from Standard = Standard_True) is static;
+ ---Purpose: Show/Don't show grid echo to the hit point.
+ -- If TRUE,the grid echo will be shown at ConvertToGrid() time.
+ ---Level : Public
+ ---Category: grid management
+
+ SetGridEcho (me : mutable;
+ aMarker: AspectMarker3d from Graphic3d) is static;
+ ---Purpose: Show grid echo <aMarker> to the hit point.
+ -- Warning: When the grid echo marker is not set,
+ -- a default marker is build with the attributes:
+ -- marker type : Aspect_TOM_STAR
+ -- marker color : Quantity_NOC_GRAY90
+ -- marker size : 3.0
+ ---Level : Public
+ ---Category: grid management
+
+ GridEcho (me) returns Boolean from Standard is static;
+ ---Purpose: Returns TRUE when grid echo must be displayed
+ -- at hit point.
+ ---Level : Public
+ ---Category: grid management
+
+ IsActive (me)
+ returns Boolean from Standard
+ is static;
+ ---Purpose: Returns Standard_True if a grid is activated in <me>.
+ ---Level : Public
+ ---Category: grid management
+
+ Grid (me)
+ returns mutable Grid from Aspect
+ is static;
---Purpose : Returns the defined grid in <me>.
- ---Level : Public
- ---Category: grid management
-
- GridType (me)
- returns GridType from Aspect
- is static;
- ---Purpose: Returns the current grid type defined in <me>.
- ---Level : Public
- ---Category: grid management
-
- GridDrawMode (me)
- returns GridDrawMode from Aspect
- is static;
- ---Purpose: Returns the current grid draw mode defined in <me>.
- ---Level : Public
- ---Category: grid management
-
- RectangularGridValues (me;
- XOrigin, YOrigin : out Length from Quantity;
- XStep, YStep : out Length from Quantity;
- RotationAngle : out PlaneAngle from Quantity)
- is static;
- ---Purpose: Returns the definition of the rectangular grid.
- ---Level : Public
- ---Category: grid management
-
- SetRectangularGridValues (me : mutable;
- XOrigin, YOrigin : Length from Quantity;
- XStep, YStep : Length from Quantity;
- RotationAngle : PlaneAngle from Quantity)
- is static;
- ---Purpose: Sets the definition of the rectangular grid.
- --- <XOrigin>, <YOrigin> defines the origin of the grid.
- --- <XStep> defines the interval between 2 vertical lines.
- --- <YStep> defines the interval between 2 horizontal lines.
- --- <RotationAngle> defines the rotation angle of the grid.
- ---Level : Public
- ---Category: grid management
-
- CircularGridValues (me;
- XOrigin, YOrigin : out Length from Quantity;
- RadiusStep : out Length from Quantity;
- DivisionNumber : out Integer from Standard;
- RotationAngle : out PlaneAngle from Quantity)
- is static;
- ---Purpose: Returns the definition of the circular grid.
- ---Level : Public
- ---Category: grid management
-
- SetCircularGridValues (me : mutable;
- XOrigin, YOrigin : Length from Quantity;
- RadiusStep : Length from Quantity;
- DivisionNumber : Integer from Standard;
- RotationAngle : PlaneAngle from Quantity)
- is static;
- ---Purpose: Sets the definition of the circular grid.
- --- <XOrigin>, <YOrigin> defines the origin of the grid.
- --- <RadiusStep> defines the interval between 2 circles.
- --- <DivisionNumber> defines the section number of one half circle.
- --- <RotationAngle> defines the rotation angle of the grid.
- ---Level : Public
- ---Category: grid management
-
- CircularGridGraphicValues (me;
- Radius : out Length from Quantity;
- OffSet : out Length from Quantity)
- is static;
- ---Purpose: Returns the location and the size of the grid.
- ---Level : Public
- ---Category: grid management
-
- SetCircularGridGraphicValues (me : mutable;
- Radius : Length from Quantity;
- OffSet : Length from Quantity)
- is static;
- ---Purpose: Sets the location and the size of the grid.
- --- <XSize> defines the width of the grid.
- --- <YSize> defines the height of the grid.
- --- <OffSet> defines the displacement along the plane normal.
- ---Level : Public
- ---Category: grid management
-
- RectangularGridGraphicValues (me;
- XSize, YSize : out Length from Quantity;
- OffSet : out Length from Quantity)
- is static;
- ---Purpose: Returns the location and the size of the grid.
- ---Level : Public
- ---Category: grid management
-
- SetRectangularGridGraphicValues (me : mutable;
- XSize, YSize : Length from Quantity;
- OffSet : Length from Quantity)
- is static;
- ---Purpose: Sets the location and the size of the grid.
- --- <XSize> defines the width of the grid.
- --- <YSize> defines the height of the grid.
- --- <OffSet> defines the displacement along the plane normal.
- ---Level : Public
- ---Category: grid management
+ ---Level : Public
+ ---Category: grid management
+
+ GridType (me)
+ returns GridType from Aspect
+ is static;
+ ---Purpose: Returns the current grid type defined in <me>.
+ ---Level : Public
+ ---Category: grid management
+
+ GridDrawMode (me)
+ returns GridDrawMode from Aspect
+ is static;
+ ---Purpose: Returns the current grid draw mode defined in <me>.
+ ---Level : Public
+ ---Category: grid management
+
+ RectangularGridValues (me;
+ XOrigin, YOrigin : out Length from Quantity;
+ XStep, YStep : out Length from Quantity;
+ RotationAngle : out PlaneAngle from Quantity)
+ is static;
+ ---Purpose: Returns the definition of the rectangular grid.
+ ---Level : Public
+ ---Category: grid management
+
+ SetRectangularGridValues (me : mutable;
+ XOrigin, YOrigin : Length from Quantity;
+ XStep, YStep : Length from Quantity;
+ RotationAngle : PlaneAngle from Quantity)
+ is static;
+ ---Purpose: Sets the definition of the rectangular grid.
+ --- <XOrigin>, <YOrigin> defines the origin of the grid.
+ --- <XStep> defines the interval between 2 vertical lines.
+ --- <YStep> defines the interval between 2 horizontal lines.
+ --- <RotationAngle> defines the rotation angle of the grid.
+ ---Level : Public
+ ---Category: grid management
+
+ CircularGridValues (me;
+ XOrigin, YOrigin : out Length from Quantity;
+ RadiusStep : out Length from Quantity;
+ DivisionNumber : out Integer from Standard;
+ RotationAngle : out PlaneAngle from Quantity)
+ is static;
+ ---Purpose: Returns the definition of the circular grid.
+ ---Level : Public
+ ---Category: grid management
+
+ SetCircularGridValues (me : mutable;
+ XOrigin, YOrigin : Length from Quantity;
+ RadiusStep : Length from Quantity;
+ DivisionNumber : Integer from Standard;
+ RotationAngle : PlaneAngle from Quantity)
+ is static;
+ ---Purpose: Sets the definition of the circular grid.
+ --- <XOrigin>, <YOrigin> defines the origin of the grid.
+ --- <RadiusStep> defines the interval between 2 circles.
+ --- <DivisionNumber> defines the section number of one half circle.
+ --- <RotationAngle> defines the rotation angle of the grid.
+ ---Level : Public
+ ---Category: grid management
+
+ CircularGridGraphicValues (me;
+ Radius : out Length from Quantity;
+ OffSet : out Length from Quantity)
+ is static;
+ ---Purpose: Returns the location and the size of the grid.
+ ---Level : Public
+ ---Category: grid management
+
+ SetCircularGridGraphicValues (me : mutable;
+ Radius : Length from Quantity;
+ OffSet : Length from Quantity)
+ is static;
+ ---Purpose: Sets the location and the size of the grid.
+ --- <XSize> defines the width of the grid.
+ --- <YSize> defines the height of the grid.
+ --- <OffSet> defines the displacement along the plane normal.
+ ---Level : Public
+ ---Category: grid management
+
+ RectangularGridGraphicValues (me;
+ XSize, YSize : out Length from Quantity;
+ OffSet : out Length from Quantity)
+ is static;
+ ---Purpose: Returns the location and the size of the grid.
+ ---Level : Public
+ ---Category: grid management
+
+ SetRectangularGridGraphicValues (me : mutable;
+ XSize, YSize : Length from Quantity;
+ OffSet : Length from Quantity)
+ is static;
+ ---Purpose: Sets the location and the size of the grid.
+ --- <XSize> defines the width of the grid.
+ --- <YSize> defines the height of the grid.
+ --- <OffSet> defines the displacement along the plane normal.
+ ---Level : Public
+ ---Category: grid management
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
- GetBackgroundColor ( me )
- returns Background from Aspect is private;
- ---Purpose: Returns the default background colour.
+ GetBackgroundColor ( me )
+ returns Background from Aspect is private;
+ ---Purpose: Returns the default background colour.
- GetGradientBackground ( me ) returns GradientBackground from Aspect;
- ---Level: Public
- ---Purpose: Returns the gradient background of the view.
-
- AddView( me: mutable; MyView : View from V3d) is private;
- ---Purpose: Adds View in Sequence Of Views.
-
- DelView( me: mutable; MyView : View from V3d) is private;
- ---Purpose: Delete View in Sequence Of Views.
+ GetGradientBackground ( me ) returns GradientBackground from Aspect;
+ ---Level: Public
+ ---Purpose: Returns the gradient background of the view.
- AddLight( me: mutable; MyLight : Light from V3d) is private;
- ---Purpose: Adds Light in Sequence Of Lights.
+ AddView( me: mutable; MyView : View from V3d) is private;
+ ---Purpose: Adds View in Sequence Of Views.
- AddPlane( me: mutable; MyPlane : Plane from V3d) is private ;
- ---Purpose: Adds Plane in Sequence Of Planes.
+ DelView( me: mutable; MyView : View from V3d) is private;
+ ---Purpose: Delete View in Sequence Of Views.
- DelPlane( me: mutable; MyPlane : Plane from V3d) is private;
- ---Purpose: Delete Plane in Sequence Of Planes.
+ AddLight( me: mutable; MyLight : Light from V3d) is private;
+ ---Purpose: Adds Light in Sequence Of Lights.
SetDefaultLights(me: mutable);
- ---Purpose: defines default lights -
- -- positional-light 0.3 0. 0.
- -- directional-light V3d_XnegYposZpos
- -- directional-light V3d_XnegYneg
- -- ambient-light
+ ---Purpose: defines default lights -
+ -- positional-light 0.3 0. 0.
+ -- directional-light V3d_XnegYposZpos
+ -- directional-light V3d_XnegYneg
+ -- ambient-light
Init(me: mutable);
IsActive(me; aView: View from V3d)
- returns Boolean from Standard is private;
-
- ShowGridEcho(me : mutable;
- aView: View from V3d;
- aPoint: Vertex from Graphic3d) is private;
- ---Purpose:
- -- Display grid echo at requested point in the view.
-
-
+ returns Boolean from Standard is private;
+
+ ShowGridEcho(me : mutable;
+ aView: View from V3d;
+ aPoint: Vertex from Graphic3d) is private;
+ ---Purpose:
+ -- Display grid echo at requested point in the view.
+
fields
- MyViewer: ViewManager from Visual3d ;
- MyDefinedViews: ListOfTransient from V3d;
- MyActiveViews: ListOfTransient from V3d;
- MyDefinedLights: ListOfTransient from V3d;
- MyActiveLights: ListOfTransient from V3d;
- MyDefinedPlanes: ListOfTransient from V3d;
- MyBackground: Background from Aspect ;
- MyGradientBackground: GradientBackground from Aspect ;
- MyViewSize: Real ;
- MyViewProj: TypeOfOrientation from V3d ;
+ MyViewer: ViewManager from Visual3d ;
+ MyDefinedViews: ListOfTransient from V3d;
+ MyActiveViews: ListOfTransient from V3d;
+ MyDefinedLights: ListOfTransient from V3d;
+ MyActiveLights: ListOfTransient from V3d;
+ MyDefinedPlanes: ListOfTransient from V3d;
+ MyBackground: Background from Aspect ;
+ MyGradientBackground: GradientBackground from Aspect ;
+ MyViewSize: Real ;
+ MyViewProj: TypeOfOrientation from V3d ;
MyVisualization: TypeOfVisualization from V3d ;
- MyShadingModel: TypeOfShadingModel from V3d ;
- MySurfaceDetail: TypeOfSurfaceDetail from V3d ;
- MyDefaultAngle: PlaneAngle from Quantity;
+ MyShadingModel: TypeOfShadingModel from V3d ;
+ MySurfaceDetail: TypeOfSurfaceDetail from V3d ;
+ MyDefaultAngle: PlaneAngle from Quantity;
MyDefaultTypeOfView: TypeOfView from V3d;
MyDefaultOrthographicView: OrthographicView from V3d;
MyDefaultPerspectiveView: PerspectiveView from V3d;
- MyCurrentSelectedLight: Light from V3d;
+ MyCurrentSelectedLight: Light from V3d;
myActiveViewsIterator: ListIteratorOfListOfTransient from TColStd;
myDefinedViewsIterator: ListIteratorOfListOfTransient from TColStd;
myActiveLightsIterator: ListIteratorOfListOfTransient from TColStd;
myDefinedPlanesIterator: ListIteratorOfListOfTransient from TColStd;
myComputedMode: Boolean from Standard;
myDefaultComputedMode: Boolean from Standard;
- myPrivilegedPlane: Ax3 from gp;
- myPlaneStructure: Structure from Graphic3d;
- myDisplayPlane: Boolean from Standard;
+ myPrivilegedPlane: Ax3 from gp;
+ myPlaneStructure: Structure from Graphic3d;
+ myDisplayPlane: Boolean from Standard;
myDisplayPlaneLength: Length from Quantity;
- myRGrid: RectangularGrid from V3d;
- myCGrid: CircularGrid from V3d;
- myGridType: GridType from Aspect;
+ myRGrid: RectangularGrid from V3d;
+ myCGrid: CircularGrid from V3d;
+ myGridType: GridType from Aspect;
- myGridEcho: Boolean from Standard;
- myGridEchoStructure: Structure from Graphic3d;
- myGridEchoGroup: Group from Graphic3d;
- myGridEchoAspect : AspectMarker3d from Graphic3d;
+ myGridEcho: Boolean from Standard;
+ myGridEchoStructure: Structure from Graphic3d;
+ myGridEchoGroup: Group from Graphic3d;
+ myGridEchoAspect : AspectMarker3d from Graphic3d;
friends
- class View from V3d,
- class Light from V3d,
- class Plane from V3d,
+ class View from V3d,
+ class Light from V3d,
+ class Plane from V3d,
SetPlane from package V3d (aViewer: Viewer from V3d; x1,y1,z1,x2,y2,z2: Length from Quantity)
end Viewer;
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)();
}
// 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;
}
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);
}
// step 1: prepare the data
- if(curindex != 0){
+ if(curindex !=0){
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
TheAISContext()->AddFilter(F1);
}
IO = TheAISContext()->SelectedInteractive();
}
- if(curindex != 0)
+ if(curindex!=0)
TheAISContext()->CloseLocalContext(curindex);
return IO;
}
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);
#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>
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
"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);
+
}