OCC22357 Hidden face selection
authorbugmaster <>
Thu, 28 Apr 2011 15:57:34 +0000 (15:57 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:28:20 +0000 (19:28 +0400)
32 files changed:
src/AIS/AIS_InteractiveContext_2.cxx
src/AIS/AIS_LocalContext.cxx
src/MeshVS/MeshVS_SensitiveFace.cxx
src/MeshVS/MeshVS_SensitiveMesh.cxx
src/MeshVS/MeshVS_SensitivePolyhedron.cxx
src/MeshVS/MeshVS_SensitiveSegment.cxx
src/OpenGl/OpenGl_togl_begin_immediat_mode.cxx
src/Poly/Poly.cdl
src/Poly/Poly.cxx
src/QABUC/QABUC.cxx
src/Select3D/Select3D_Projector.cdl
src/Select3D/Select3D_Projector.cxx
src/Select3D/Select3D_Projector.lxx
src/Select3D/Select3D_SensitiveBox.cxx
src/Select3D/Select3D_SensitiveCurve.cxx
src/Select3D/Select3D_SensitiveEntity.cdl
src/Select3D/Select3D_SensitiveEntity.cxx
src/Select3D/Select3D_SensitiveFace.cxx
src/Select3D/Select3D_SensitiveGroup.cxx
src/Select3D/Select3D_SensitivePoint.cxx
src/Select3D/Select3D_SensitivePoly.cxx
src/Select3D/Select3D_SensitiveSegment.cxx
src/Select3D/Select3D_SensitiveTriangulation.cxx
src/Select3D/Select3D_SensitiveWire.cxx
src/StdSelect/StdSelect.cxx
src/StdSelect/StdSelect_ViewerSelector3d.cxx
src/StdSelect/StdSelect_ViewerSelector3d.lxx
src/V3d/V3d_Plane.cdl
src/V3d/V3d_Plane.cxx
src/V3d/V3d_Viewer.cdl
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx

index c991f9e..559133b 100755 (executable)
@@ -20,8 +20,6 @@
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 #include <AIS_Selection.hxx>
 
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 #include <AIS_Selection.hxx>
 
-
-static TColStd_ListIteratorOfListOfInteger ItL;
 //=======================================================================
 //function : OpenLocalContext
 //purpose  : 
 //=======================================================================
 //function : OpenLocalContext
 //purpose  : 
@@ -64,21 +62,13 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
                                                           UseDisplayedObjects,
                                                           AllowShapeDecomposition,
                                                           AcceptEraseOfTemporary);
                                                           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();
   NewLocal->MainSelector()->UpdateConversion();
-  
-  myLocalContexts.Bind(myCurLocalIndex,NewLocal);
 
 
+  myLocalContexts.Bind(myCurLocalIndex,NewLocal);
 
 #ifdef DEB
   cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
 
 #ifdef DEB
   cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
@@ -93,7 +83,6 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
     cout<<"\t\tNo Objects Were Loaded "<<endl;
 #endif
   return myCurLocalIndex;
     cout<<"\t\tNo Objects Were Loaded "<<endl;
 #endif
   return myCurLocalIndex;
-  
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -268,6 +257,7 @@ Deactivate(const Handle(AIS_InteractiveObject)& anIObj)
 {
   if(!HasOpenedContext()){
     if(!myObjects.IsBound(anIObj)) return;
 {
   if(!HasOpenedContext()){
     if(!myObjects.IsBound(anIObj)) return;
+    TColStd_ListIteratorOfListOfInteger ItL;
     for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
         ItL.More();
         ItL.Next()){
     for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
         ItL.More();
         ItL.Next()){
@@ -312,9 +302,9 @@ void AIS_InteractiveContext::
 ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj, 
                TColStd_ListOfInteger& theList) const 
 {
 ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj, 
                TColStd_ListOfInteger& theList) const 
 {
+  TColStd_ListIteratorOfListOfInteger ItL;
   if(!HasOpenedContext()){
     if(myObjects.IsBound(anIObj)){
   if(!HasOpenedContext()){
     if(myObjects.IsBound(anIObj)){
-      //ItL est une variable statique... 
       for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
           ItL.More();
           ItL.Next())
       for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
           ItL.More();
           ItL.Next())
@@ -393,6 +383,7 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
     if(myObjects.IsBound(anIObj)){
       const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
       STAT->SubIntensityOn();
     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());
     }
       for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
         myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
     }
@@ -446,6 +437,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
     if(myObjects.IsBound(anIObj)){
       const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
       STAT->SubIntensityOff();
     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())
       for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
         myMainPM->Unhighlight(anIObj,ItL.Value());
       if(STAT->IsHilighted())
@@ -489,11 +481,10 @@ void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
 //=======================================================================
 void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer)
 {
 //=======================================================================
 void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer)
 {
-  
   if(!HasOpenedContext()) return;
   if(!HasOpenedContext()) return;
-  
+
   AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
   AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
-  
+  TColStd_ListIteratorOfListOfInteger ItL;
   for(;It.More();It.Next()){
     const Handle(AIS_GlobalStatus)& STAT = It.Value();
     if(STAT->IsSubIntensityOn())
   for(;It.More();It.Next()){
     const Handle(AIS_GlobalStatus)& STAT = It.Value();
     if(STAT->IsSubIntensityOn())
@@ -501,7 +492,7 @@ void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer
     for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
       myMainPM->Unhighlight(It.Key());
   }
     for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
       myMainPM->Unhighlight(It.Key());
   }
-  
+
   if(updateviewer) myMainVwr->Update();
 }
 
   if(updateviewer) myMainVwr->Update();
 }
 
@@ -877,7 +868,7 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie
 {
   Standard_Boolean upd_main(Standard_False),upd_col(Standard_False);
   TColStd_ListIteratorOfListOfInteger itl;
 {
   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();
   for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){
     const Handle(AIS_InteractiveObject)& iobj = it.Key();
     const Handle(AIS_GlobalStatus)& STAT = it.Value();
index b616ec9..a6be221 100755 (executable)
@@ -660,22 +660,25 @@ void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
 
 
 
 
 
 
-Standard_Boolean AIS_LocalContext::HasSameProjector(const Select3D_Projector& aPrj) const
+Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const
 {
 {
-  const Select3D_Projector& CurPrj = myMainVS->Projector();
-  if(CurPrj.Perspective()!=aPrj.Perspective()) return Standard_False;  
-  if(CurPrj.Perspective())
-    if(CurPrj.Focus()!=aPrj.Focus()) return Standard_False;
-  gp_GTrsf CurTrsf(CurPrj.Transformation());
-  gp_GTrsf PrjTrsf(aPrj.Transformation());
-  
-  for(Standard_Integer i=1;i<=3;i++){
-    for(Standard_Integer j=1;j<=3;j++){
-      if(CurTrsf.Value(i,j)!=PrjTrsf.Value(i,j)) 
-       return Standard_False;
+  const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector();
+  if (aCurPrj->Perspective() != thePrj->Perspective())
+    return Standard_False;  
+  if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus())
+    return Standard_False;
+  const gp_GTrsf& aCurTrsf = aCurPrj->Transformation();
+  const gp_GTrsf& aPrjTrsf = thePrj->Transformation();
+
+  for (Standard_Integer i = 1; i <= 3; ++i)
+  {
+    for (Standard_Integer j = 1; j <= 3 ; ++j)
+    {
+      if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j))
+        return Standard_False;
     }
   }
     }
   }
-  
+
   return Standard_True;
 }
 
   return Standard_True;
 }
 
index 21c6958..ce7c530 100755 (executable)
@@ -31,13 +31,13 @@ MeshVS_SensitiveFace::MeshVS_SensitiveFace (
 // name    : MeshVS_SensitiveFace::Project
 // Purpose :
 //=======================================================================
 // 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() )
 {
   Select3D_SensitiveFace::Project( aProj );
   if ( HasLocation() )
-    aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
+    aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
   else
   else
-    aProj.Project( myCentre, myProjCentre );
+    aProj->Project( myCentre, myProjCentre );
 }
 
 //=======================================================================
 }
 
 //=======================================================================
index e39dcba..de5475e 100755 (executable)
@@ -139,14 +139,14 @@ Handle(Select3D_SensitiveEntity) MeshVS_SensitiveMesh::GetConnected( const TopLo
 //=======================================================================
 Standard_Real MeshVS_SensitiveMesh::ComputeDepth( const gp_Lin& /*EyeLine*/ ) const
 {
 //=======================================================================
 Standard_Real MeshVS_SensitiveMesh::ComputeDepth( const gp_Lin& /*EyeLine*/ ) const
 {
-  return 0.;
+  return Precision::Infinite();
 }
 
 //==================================================
 // Function: ProjectOneCorner
 // Purpose :
 //==================================================
 }
 
 //==================================================
 // 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)
                                            const Standard_Real theX, 
                                            const Standard_Real theY, 
                                            const Standard_Real theZ)
@@ -154,9 +154,9 @@ void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
   gp_Pnt aPnt( theX, theY, theZ );  
   gp_Pnt2d aProjPnt;
   if( HasLocation() )
   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 
   else 
-    theProj.Project( aPnt, aProjPnt );
+    theProj->Project( aPnt, aProjPnt );
   mybox2d.Add( aProjPnt );
 }
 
   mybox2d.Add( aProjPnt );
 }
 
@@ -164,7 +164,7 @@ void MeshVS_SensitiveMesh::ProjectOneCorner(const Select3D_Projector& theProj,
 // Function: Project
 // Purpose :
 //==================================================
 // 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...
 
 {
   Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
 
index 928123a..ed9eddf 100755 (executable)
@@ -34,7 +34,7 @@ MeshVS_SensitivePolyhedron( const Handle( SelectBasics_EntityOwner )& Owner,
 // Function : Project
 // Purpose  :
 //================================================================
 // Function : Project
 // Purpose  :
 //================================================================
-void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
+void MeshVS_SensitivePolyhedron::Project( const Handle(Select3D_Projector)& aProjector )
 {
   Select3D_SensitiveEntity::Project( aProjector );
 
 {
   Select3D_SensitiveEntity::Project( aProjector );
 
@@ -55,9 +55,9 @@ void MeshVS_SensitivePolyhedron::Project( const Select3D_Projector& aProjector )
   {
     pnt = myNodes->Value( i );
     if( !hasLoc )
   {
     pnt = myNodes->Value( i );
     if( !hasLoc )
-      aProjector.Project( pnt, proj );
+      aProjector->Project( pnt, proj );
     else
     else
-      aProjector.Project( pnt.Transformed( Location().Transformation() ), proj );
+      aProjector->Project( pnt.Transformed( Location().Transformation() ), proj );
 
     myNodes2d->SetValue( i, proj.XY() );
     myCenter += proj.XY();
 
     myNodes2d->SetValue( i, proj.XY() );
     myCenter += proj.XY();
@@ -161,9 +161,10 @@ Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const Standard_Real X,
   }
 
   if( inside )
   }
 
   if( inside )
-    Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
-
-  return inside;
+  {
+    return Select3D_SensitiveEntity::Matches( X, Y, aTol, DMin );
+  }
+  return Standard_False;
 }
 
 //================================================================
 }
 
 //================================================================
index 1b51622..d672a7e 100755 (executable)
@@ -27,13 +27,13 @@ MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
 // name    : MeshVS_SensitiveSegment::Project
 // Purpose :
 //=======================================================================
 // 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() )
 {
   Select3D_SensitiveSegment::Project( aProj );
   if ( HasLocation() )
-    aProj.Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
+    aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
   else
   else
-    aProj.Project( myCentre, myProjCentre );
+    aProj->Project( myCentre, myProjCentre );
 }
 
 //=======================================================================
 }
 
 //=======================================================================
index c0f2e3e..4351e3d 100755 (executable)
@@ -286,23 +286,19 @@ void EXPORT call_togl_clear_immediat_mode (
     call_subr_displayCB(aview,OCC_REDRAW_WINDOW);
 #endif
     call_func_redraw_all_structs_end (aview->WsId, aFlush);
     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 ) {
 #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);
   }
 
   TsmGetWSAttri (aview->WsId, WSTransient, &data);
index fd229e1..c5587b7 100755 (executable)
@@ -1,5 +1,4 @@
-
--- -- File:        Poly.cdl
+-- File:        Poly.cdl
 -- Created:     Mon Mar  6 09:38:50 1995
 -- Author:      Laurent PAINNOT
 --              <lpa@metrox>
 -- Created:     Mon Mar  6 09:38:50 1995
 -- Author:      Laurent PAINNOT
 --              <lpa@metrox>
@@ -7,17 +6,17 @@
 
 
 
 
 
 
-package Poly 
+package Poly
 
         ---Purpose: This  package  provides  classes  and services  to
         --          handle :
 
         ---Purpose: This  package  provides  classes  and services  to
         --          handle :
-        --          
+        --
         --          * 3D triangular polyhedrons.
         --          * 3D triangular polyhedrons.
-        --          
+        --
         --          * 3D polygons.
         --          * 3D polygons.
-        --          
+        --
         --          * 2D polygon.
         --          * 2D polygon.
-        --          
+        --
         --          * Tools to dump, save and restore those objects.
 
 uses
         --          * Tools to dump, save and restore those objects.
 
 uses
@@ -26,7 +25,7 @@ uses
     TCollection,
     TColStd,
     gp,
     TCollection,
     TColStd,
     gp,
-    TColgp, 
+    TColgp,
     TShort
 
 is
     TShort
 
 is
@@ -37,7 +36,7 @@ is
 
     class Array1OfTriangle
     instantiates Array1 from TCollection(Triangle from Poly);
 
     class Array1OfTriangle
     instantiates Array1 from TCollection(Triangle from Poly);
-    
+
     class HArray1OfTriangle
     instantiates HArray1 from TCollection(Triangle         from Poly,
                                           Array1OfTriangle from Poly);
     class HArray1OfTriangle
     instantiates HArray1 from TCollection(Triangle         from Poly,
                                           Array1OfTriangle from Poly);
@@ -47,7 +46,7 @@ is
         --          triangles.  It   is  made  of  a nodes  which  are
         --          indexed. Nodes  have a 3d  value  and a  2d value.
         --          Triangles are triplet of node indices.
         --          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.
 
 
         --          This is a Transient class.
 
 
@@ -64,10 +63,10 @@ is
         --          referencing a triangulation.
 
 
         --          referencing a triangulation.
 
 
-    --         
+    --
     -- Tools to use triangulations
     -- Tools to use triangulations
-    -- 
-    
+    --
+
     class Connect;
         ---Purpose: Computes and  stores  the    link from   nodes  to
         --          triangles     and from triangles to   neighbouring
     class Connect;
         ---Purpose: Computes and  stores  the    link from   nodes  to
         --          triangles     and from triangles to   neighbouring
@@ -89,8 +88,8 @@ is
 
     --
     --  Package methods
 
     --
     --  Package methods
-    --  
-    
+    --
+
     Catenate (lstTri: ListOfTriangulation from Poly)
         returns Triangulation from Poly;
         ---Purpose: Join several triangulations to one new triangulation object.
     Catenate (lstTri: ListOfTriangulation from Poly)
         returns Triangulation from Poly;
         ---Purpose: Join several triangulations to one new triangulation object.
@@ -101,7 +100,7 @@ is
     Write(T       : Triangulation from Poly;
           OS      : in out OStream;
           Compact : Boolean = Standard_True);
     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
         ---Purpose: Writes the content of the triangulation <T> on the
         --          stream <OS>. If <Compact> is true this is a "save"
         --          format  intended  to  be read back   with the Read
@@ -111,7 +110,7 @@ is
     Write(P       : Polygon3D from Poly;
           OS      : in out OStream;
           Compact : Boolean = Standard_True);
     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
         ---Purpose: Writes  the  content  of the 3D polygon <P> on the
         --          stream <OS>. If <Compact> is true this is a "save"
         --          format  intended  to  be read back   with the Read
@@ -121,7 +120,7 @@ is
     Write(P       : Polygon2D from Poly;
           OS      : in out OStream;
           Compact : Boolean = Standard_True);
     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
         ---Purpose: Writes the  content  of the 2D polygon  <P> on the
         --          stream <OS>. If <Compact> is true this is a "save"
         --          format  intended  to  be read back   with the Read
@@ -133,32 +132,45 @@ is
          OS      : in out OStream);
        ---Purpose: Dumps  the triangulation.  This   is a call to  the
        --          previous method with Comapct set to False.
          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       : 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.
     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>.
 
     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>.
     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);
     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
         --  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;
 end Poly;
index f6469c5..a35e023 100755 (executable)
@@ -25,8 +25,7 @@
 //purpose  : Join several triangulations to one new triangulation object
 //=======================================================================
 
 //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);
 {
   Standard_Integer nNodes(0);
   Standard_Integer nTrian(0);
@@ -75,11 +74,11 @@ Handle(Poly_Triangulation) Poly::Catenate
 
 //=======================================================================
 //function : Write
 
 //=======================================================================
 //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";
                  const Standard_Boolean Compact)
 {
   OS << "Poly_Triangulation\n";
@@ -125,7 +124,7 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
       OS << UVNodes(i).Y() << "\n";
     }
   }
       OS << UVNodes(i).Y() << "\n";
     }
   }
-      
+
   if (!Compact) OS << "\nTriangles :\n";
   Standard_Integer nbTriangles = T->NbTriangles();
   Standard_Integer n1, n2, n3;
   if (!Compact) OS << "\nTriangles :\n";
   Standard_Integer nbTriangles = T->NbTriangles();
   Standard_Integer n1, n2, n3;
@@ -145,11 +144,11 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
 
 //=======================================================================
 //function : Write
 
 //=======================================================================
 //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";
                  const Standard_Boolean        Compact)
 {
   OS << "Poly_Polygon3D\n";
@@ -198,11 +197,11 @@ void Poly::Write(const Handle(Poly_Polygon3D)& P,
 
 //=======================================================================
 //function : Write
 
 //=======================================================================
 //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";
                  const Standard_Boolean        Compact)
 {
   OS << "Poly_Polygon2D\n";
@@ -237,7 +236,7 @@ void Poly::Write(const Handle(Poly_Polygon2D)& P,
 
 //=======================================================================
 //function : Dump
 
 //=======================================================================
 //function : Dump
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Triangulation)& T, Standard_OStream& OS)
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Triangulation)& T, Standard_OStream& OS)
@@ -248,7 +247,7 @@ void Poly::Dump(const Handle(Poly_Triangulation)& T, Standard_OStream& OS)
 
 //=======================================================================
 //function : Dump
 
 //=======================================================================
 //function : Dump
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Polygon3D)& P, Standard_OStream& OS)
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Polygon3D)& P, Standard_OStream& OS)
@@ -259,7 +258,7 @@ void Poly::Dump(const Handle(Poly_Polygon3D)& P, Standard_OStream& OS)
 
 //=======================================================================
 //function : Dump
 
 //=======================================================================
 //function : Dump
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Polygon2D)& P, Standard_OStream& OS)
 //=======================================================================
 
 void Poly::Dump(const Handle(Poly_Polygon2D)& P, Standard_OStream& OS)
@@ -270,13 +269,13 @@ void Poly::Dump(const Handle(Poly_Polygon2D)& P, Standard_OStream& OS)
 
 //=======================================================================
 //function : ReadTriangulation
 
 //=======================================================================
 //function : ReadTriangulation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
 {
   // Read a triangulation
 //=======================================================================
 
 Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
 {
   // Read a triangulation
-  
+
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Triangulation")) {
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Triangulation")) {
@@ -320,7 +319,7 @@ Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
     Triangles(i).Set(n1,n2,n3);
   }
 
     Triangles(i).Set(n1,n2,n3);
   }
 
-  
+
   Handle(Poly_Triangulation) T;
 
   if (hasUV) T =  new Poly_Triangulation(Nodes,UVNodes,Triangles);
   Handle(Poly_Triangulation) T;
 
   if (hasUV) T =  new Poly_Triangulation(Nodes,UVNodes,Triangles);
@@ -334,13 +333,13 @@ Handle(Poly_Triangulation) Poly::ReadTriangulation(Standard_IStream& IS)
 
 //=======================================================================
 //function : ReadPolygon3D
 
 //=======================================================================
 //function : ReadPolygon3D
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
 {
   // Read a 3d polygon
 //=======================================================================
 
 Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
 {
   // Read a 3d polygon
-  
+
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Polygon3D")) {
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Polygon3D")) {
@@ -377,7 +376,7 @@ Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
   Handle(Poly_Polygon3D) P;
   if (!hasparameters)
     P = new Poly_Polygon3D(Nodes);
   Handle(Poly_Polygon3D) P;
   if (!hasparameters)
     P = new Poly_Polygon3D(Nodes);
-  else 
+  else
     P = new Poly_Polygon3D(Nodes, Param);
 
   P->Deflection(d);
     P = new Poly_Polygon3D(Nodes, Param);
 
   P->Deflection(d);
@@ -387,13 +386,13 @@ Handle(Poly_Polygon3D) Poly::ReadPolygon3D(Standard_IStream& IS)
 
 //=======================================================================
 //function : ReadPolygon3D
 
 //=======================================================================
 //function : ReadPolygon3D
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
 {
   // Read a 2d polygon
 //=======================================================================
 
 Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
 {
   // Read a 2d polygon
-  
+
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Polygon2D")) {
   char line[100];
   IS >> line;
   if (strcmp(line,"Poly_Polygon2D")) {
@@ -417,9 +416,9 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
     Nodes(i).SetCoord(x,y);
   }
 
     Nodes(i).SetCoord(x,y);
   }
 
-  Handle(Poly_Polygon2D) P = 
+  Handle(Poly_Polygon2D) P =
     new Poly_Polygon2D(Nodes);
     new Poly_Polygon2D(Nodes);
-  
+
   P->Deflection(d);
 
   return P;
   P->Deflection(d);
 
   return P;
@@ -427,14 +426,14 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
 
 //=======================================================================
 //function : ComputeNormals
 
 //=======================================================================
 //function : ComputeNormals
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void  Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
 {
   const TColgp_Array1OfPnt&     arrNodes = Tri->Nodes();
   const Poly_Array1OfTriangle & arrTri   = Tri->Triangles();
 //=======================================================================
 
 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);
   const Handle(TShort_HArray1OfShortReal) Normals =
     new TShort_HArray1OfShortReal(1, nbNormVal);
   Normals->Init(0.F);
@@ -493,3 +492,107 @@ void  Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
 
   Tri->SetNormals(Normals);
 }
 
   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;
+    }
+  }
+}
+
index 04ddd4d..1a82b68 100755 (executable)
@@ -758,7 +758,8 @@ static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, co
   gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
   Standard_Real A,B,C,D;
   thegpPln.Coefficients(A,B,C,D);
   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 ()) {
   for (myAISContext->CurrentViewer()->InitActiveViews();
        myAISContext->CurrentViewer()->MoreActiveViews ();
        myAISContext->CurrentViewer()->NextActiveViews ()) {
index 328d649..142c5c9 100755 (executable)
@@ -1,15 +1,15 @@
--- File:       Select3D_Projector.cdl
--- Created:    Thu Mar 12 13:32:28 1992
--- Author:     Christophe MARION
---             <cma@sdsun2> copie quasi exacte de HLRAlgo_Projector
----Copyright:   Matra Datavision 1992
-
-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,
 uses
     Real    from Standard,
     Boolean from Standard,
-    Trsf    from gp, 
+    Trsf    from gp,
     GTrsf   from gp,
     Lin     from gp,
     Pnt     from gp,
     GTrsf   from gp,
     Lin     from gp,
     Pnt     from gp,
@@ -19,155 +19,169 @@ uses
     Pnt2d   from gp,
     Box     from Bnd,
     View    from V3d
     Pnt2d   from gp,
     Box     from Bnd,
     View    from V3d
-    
+
 raises
     NoSuchObject from Standard
 
 is
 
     Create(aView:View from V3d) returns Projector from Select3D;
 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)
     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;
     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;
     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;
     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;
     returns Projector from Select3D;
-  
+
     Create(GT        : GTrsf   from gp;
     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;
 
     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;
          Persp     : Boolean from Standard;
-         Focus     : Real    from Standard) 
+         Focus     : Real    from Standard)
     is static;
 
     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;
 
     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)
 
 
     Directions(me; D1 , D2 , D3 : out Vec2d from gp)
-       ---C++: inline
+    ---C++: inline
     is virtual;
 
     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
     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
     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
     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
     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
     is virtual;
 
     Focus(me) returns Real from Standard
-       ---Purpose: Returns the focal length.
-       ---C++: inline
+    ---Purpose: Returns the focal length.
+    ---C++: inline
     raises
     raises
-       NoSuchObject from Standard -- if there is no perspective
+        NoSuchObject from Standard -- if there is no perspective
     is virtual;
     is virtual;
-    
+
     Transform(me; D : in out Vec from gp)
     Transform(me; D : in out Vec from gp)
-       ---C++: inline
+    ---C++: inline
     is virtual;
 
     Transform(me; Pnt : in out Pnt from gp)
     is virtual;
 
     Transform(me; Pnt : in out Pnt from gp)
-       ---C++: inline
+        ---C++: inline
     is virtual;
     is virtual;
-    
+
     Project(me; P    :     Pnt   from gp;
                 Pout : out Pnt2d from gp)
     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;
     is virtual;
-    
+
     Project(me; P     :     Pnt  from gp;
                 X,Y,Z : out Real from Standard)
     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;
     is static;
+
     Project(me; P     :     Pnt   from gp;
                 D1    :     Vec   from gp;
     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;
     is virtual;
-    
+
     BoxAdd(me; P :     Pnt2d from gp;
                B : out Box   from Bnd)
     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
     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;
 
     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
     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;
     myPersp      : Boolean from Standard is protected;
     myFocus      : Real    from Standard is protected;
     myScaledTrsf : Trsf    from gp is protected;
@@ -177,7 +191,8 @@ fields
     myD2         : Vec2d   from gp is protected;
     myD3         : Vec2d   from gp is protected;
 
     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;
 
 end Projector;
index 6b65e87..53770f1 100755 (executable)
@@ -3,7 +3,7 @@
 // Author:     Christophe MARION
 //             <cma@sdsun2>
 
 // Author:     Christophe MARION
 //             <cma@sdsun2>
 
-#define IMP240100      //GG 
+#define IMP240100      //GG
 //                     Change RefToPix()/Convert() to Project() method.
 
 #include <Select3D_Projector.ixx>
 //                     Change RefToPix()/Convert() to Project() method.
 
 #include <Select3D_Projector.ixx>
 
 // formula for derivating a perspective, from Mathematica
 
 
 // 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
 
 //=======================================================================
 //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;
 {
   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);
   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_Dir Zpers (DX,DY,DZ);
   gp_Dir Ypers (XUp,YUp,ZUp);
   gp_Dir Xpers = Ypers.Crossed(Zpers);
@@ -48,24 +49,37 @@ myView(aViou)
   myScaledTrsf.SetTransformation(Axe);
   myGTrsf.SetTrsf(myScaledTrsf);
   Scaled();
   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();
 {
   Scaled();
   SetDirection();
-} 
+}
 
 //=======================================================================
 //function : Select3D_Projector
 
 //=======================================================================
 //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);
 {
   myScaledTrsf.SetTransformation(CS);
   myGTrsf.SetTrsf(myScaledTrsf);
@@ -75,13 +89,15 @@ Select3D_Projector::Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
 
 //=======================================================================
 //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);
 {
   myScaledTrsf.SetTransformation(CS);
   myGTrsf.SetTrsf(myScaledTrsf);
@@ -91,16 +107,17 @@ Select3D_Projector::Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
 
 //=======================================================================
 //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),
   myFocus(Focus),
-  myScaledTrsf(T)
+  myScaledTrsf(T),
+  myDepthMin(-Precision::Infinite()),
+  myDepthMax( Precision::Infinite())
 {
   myGTrsf.SetTrsf(myScaledTrsf);
   Scaled();
 {
   myGTrsf.SetTrsf(myScaledTrsf);
   Scaled();
@@ -109,22 +126,23 @@ Select3D_Projector::Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 //=======================================================================
 
-Select3D_Projector::Select3D_Projector 
-  (const gp_Trsf& T, 
-   const Standard_Boolean Persp,
-   const Standard_Real Focus,
-   const gp_Vec2d& v1,
-   const gp_Vec2d& v2,
-   const gp_Vec2d& v3) :
-  myPersp(Persp),
+Select3D_Projector::Select3D_Projector (const gp_Trsf& T,
+                                        const Standard_Boolean Persp,
+                                        const Standard_Real Focus,
+                                        const gp_Vec2d& v1,
+                                        const gp_Vec2d& v2,
+                                        const gp_Vec2d& v3)
+: myPersp(Persp),
   myFocus(Focus),
   myScaledTrsf(T),
   myD1(v1),
   myD2(v2),
   myFocus(Focus),
   myScaledTrsf(T),
   myD1(v1),
   myD2(v2),
-  myD3(v3)
+  myD3(v3),
+  myDepthMin(-Precision::Infinite()),
+  myDepthMax( Precision::Infinite())
 {
   myGTrsf.SetTrsf(myScaledTrsf);
   Scaled();
 {
   myGTrsf.SetTrsf(myScaledTrsf);
   Scaled();
@@ -132,33 +150,31 @@ Select3D_Projector::Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
 
 //=======================================================================
 //function : Select3D_Projector
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 //=======================================================================
 
-Select3D_Projector::Select3D_Projector 
-  (const gp_GTrsf& GT, 
-   const Standard_Boolean Persp,
-   const Standard_Real Focus) :
-  myPersp(Persp),
+Select3D_Projector::Select3D_Projector (const gp_GTrsf& GT,
+                                        const Standard_Boolean Persp,
+                                        const Standard_Real Focus)
+: myPersp(Persp),
   myFocus(Focus),
   myFocus(Focus),
-  myGTrsf(GT)
+  myGTrsf(GT),
+  myDepthMin(-Precision::Infinite()),
+  myDepthMax( Precision::Infinite())
 {
   Scaled();
   SetDirection();
 }
 
 {
   Scaled();
   SetDirection();
 }
 
-void Select3D_Projector::Delete()
-{}
-
 //=======================================================================
 //function : Set
 //=======================================================================
 //function : Set
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_Projector::Set
 //=======================================================================
 
 void Select3D_Projector::Set
-  (const gp_Trsf& T, 
+  (const gp_Trsf& T,
    const Standard_Boolean Persp,
    const Standard_Boolean Persp,
-   const Standard_Real Focus) 
+   const Standard_Real Focus)
 {
   myPersp      = Persp;
   myFocus      = Focus;
 {
   myPersp      = Persp;
   myFocus      = Focus;
@@ -169,59 +185,59 @@ void Select3D_Projector::Set
 
 //=======================================================================
 //function : Scaled
 
 //=======================================================================
 //function : Scaled
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 #include <gp_Mat.hxx>
 
 //=======================================================================
 
 #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();
   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(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)
     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(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,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(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)
     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(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,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)
     return(3); //-- axo
   }
   return(-1);
 }
 
 void Select3D_Projector::Scaled (const Standard_Boolean On)
-{ 
+{
   myType=-1;
   if (!On) {
   myType=-1;
   if (!On) {
-    if (!myPersp) { 
+    if (!myPersp) {
       //myGTrsf.SetTranslationPart(gp_XYZ(0.,0.,0.));
       //myGTrsf.SetTranslationPart(gp_XYZ(0.,0.,0.));
-      myType=TrsfType(myGTrsf); 
+      myType=TrsfType(myGTrsf);
     }
   }
   myInvTrsf = myGTrsf;
     }
   }
   myInvTrsf = myGTrsf;
@@ -230,7 +246,7 @@ void Select3D_Projector::Scaled (const Standard_Boolean On)
 
 //=======================================================================
 //function : Project
 
 //=======================================================================
 //function : Project
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
 //=======================================================================
 
 void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
@@ -249,9 +265,9 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
     Pout.SetCoord(Xout,Yout);
   }
   else{
     Pout.SetCoord(Xout,Yout);
   }
   else{
-    if(myType!=-1) { 
+    if(myType!=-1) {
       Standard_Real X,Y;
       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;
       case 0: {  //-- axono standard
        Standard_Real x07 = P.X()*0.7071067811865475;
        Standard_Real y05 = P.Y()*0.5;
@@ -266,12 +282,12 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
        Pout.SetCoord(X,Y);
        break;
       }
        Pout.SetCoord(X,Y);
        break;
       }
-      case 2: { 
+      case 2: {
        X=P.X(); Y=P.Z(); //-- Z=-P.Y();
        Pout.SetCoord(X,Y);
        break;
       }
        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());
        Standard_Real xmy05 = (P.X()-P.Y())*0.5;
        Standard_Real z07 = P.Z()*0.7071067811865476;
        X=0.7071067811865476*(P.X()+P.Y());
@@ -280,37 +296,37 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
        //-- Z= xmy05+z07;
        break;
       }
        //-- 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);
        }
        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;
       }
       }
     }
        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);
       }
       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
 
 }
 
 //=======================================================================
 //function : Project
-//purpose  : 
+//purpose  :
 //=======================================================================
 /*  ====== TYPE 0  (??)
    (0.7071067811865476, -0.5               ,  0.4999999999999999)
 //=======================================================================
 /*  ====== TYPE 0  (??)
    (0.7071067811865476, -0.5               ,  0.4999999999999999)
@@ -327,7 +343,7 @@ void Select3D_Projector::Project (const gp_Pnt& P, gp_Pnt2d& Pout) const
 (0.0,  1.110223024625157e-16 , 1.0)
 (0.0, -1.0                   , 1.110223024625157e-16)
 
 (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)
 ( 0.7071067811865476, 0.7071067811865475, 0.0)
 (-0.5               , 0.5000000000000001, 0.7071067811865475)
 ( 0.4999999999999999, -0.5              , 0.7071067811865476)
@@ -349,8 +365,8 @@ void Select3D_Projector::Project (const gp_Pnt& P,
 #endif
   }
   else{
 #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;
       case 0: {  //-- axono standard
        Standard_Real x07 = P.X()*0.7071067811865475;
        Standard_Real y05 = P.Y()*0.5;
@@ -364,11 +380,11 @@ void Select3D_Projector::Project (const gp_Pnt& P,
        X=P.X(); Y=P.Y(); Z=P.Z();
        break;
       }
        X=P.X(); Y=P.Y(); Z=P.Z();
        break;
       }
-      case 2: { 
+      case 2: {
        X=P.X(); Y=P.Z(); Z=-P.Y();
        break;
       }
        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());
        Standard_Real xmy05 = (P.X()-P.Y())*0.5;
        Standard_Real z07 = P.Z()*0.7071067811865476;
        X=0.7071067811865476*(P.X()+P.Y());
@@ -376,7 +392,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
        Z= xmy05+z07;
        break;
       }
        Z= xmy05+z07;
        break;
       }
-      default: { 
+      default: {
        gp_Pnt P2 = P;
        Transform(P2);
        P2.Coord(X,Y,Z);
        gp_Pnt P2 = P;
        Transform(P2);
        P2.Coord(X,Y,Z);
@@ -384,7 +400,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
       }
       }
     }
       }
       }
     }
-    else { 
+    else {
       gp_Pnt P2 = P;
       Transform(P2);
       P2.Coord(X,Y,Z);
       gp_Pnt P2 = P;
       Transform(P2);
       P2.Coord(X,Y,Z);
@@ -398,7 +414,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
 }
 //=======================================================================
 //function : Project
 }
 //=======================================================================
 //function : Project
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_Projector::Project (const gp_Pnt& P,
 //=======================================================================
 
 void Select3D_Projector::Project (const gp_Pnt& P,
@@ -424,7 +440,7 @@ void Select3D_Projector::Project (const gp_Pnt& P,
 
 //=======================================================================
 //function : BoxAdd
 
 //=======================================================================
 //function : BoxAdd
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_Projector::BoxAdd
 //=======================================================================
 
 void Select3D_Projector::BoxAdd
@@ -438,7 +454,7 @@ void Select3D_Projector::BoxAdd
 
 //=======================================================================
 //function : Shoot
 
 //=======================================================================
 //function : Shoot
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 gp_Lin Select3D_Projector::Shoot
 //=======================================================================
 
 gp_Lin Select3D_Projector::Shoot
@@ -446,7 +462,7 @@ gp_Lin Select3D_Projector::Shoot
    const Standard_Real Y) const
 {
   gp_Lin L;
    const Standard_Real Y) const
 {
   gp_Lin L;
-  
+
   if (myPersp) {
     L = gp_Lin(gp_Pnt(0,0, myFocus),
               gp_Dir(X,Y,-myFocus));
   if (myPersp) {
     L = gp_Lin(gp_Pnt(0,0, myFocus),
               gp_Dir(X,Y,-myFocus));
@@ -462,10 +478,10 @@ gp_Lin Select3D_Projector::Shoot
 
 //=======================================================================
 //function : SetDirection
 
 //=======================================================================
 //function : SetDirection
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 //=======================================================================
 
-void Select3D_Projector::SetDirection () 
+void Select3D_Projector::SetDirection ()
 {
   gp_Vec V1(1,0,0);
   Transform(V1);
 {
   gp_Vec V1(1,0,0);
   Transform(V1);
@@ -491,16 +507,23 @@ void Select3D_Projector::SetView(const Handle(V3d_View)& aViou)
   myFocus= aViou->Focale();
   Standard_Real Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
   //Standard_Boolean Pers=Standard_False;
   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);
   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();
   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;
 }
 }
index 87f10ed..b929f48 100755 (executable)
 
 //=======================================================================
 //function : Directions
 
 //=======================================================================
 //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;
   (gp_Vec2d& D1, gp_Vec2d& D2, gp_Vec2d& D3) const
 {
   D1 = myD1;
@@ -25,7 +25,7 @@ inline void Select3D_Projector::Directions
 
 //=======================================================================
 //function : Perspective
 
 //=======================================================================
 //function : Perspective
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline Standard_Boolean Select3D_Projector::Perspective() const
 //=======================================================================
 
 inline Standard_Boolean Select3D_Projector::Perspective() const
@@ -33,7 +33,7 @@ inline Standard_Boolean Select3D_Projector::Perspective() const
 
 //=======================================================================
 //function : Transformation
 
 //=======================================================================
 //function : Transformation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline const gp_GTrsf& Select3D_Projector::Transformation() const
 //=======================================================================
 
 inline const gp_GTrsf& Select3D_Projector::Transformation() const
@@ -41,7 +41,7 @@ inline const gp_GTrsf& Select3D_Projector::Transformation() const
 
 //=======================================================================
 //function : InvertedTransformation
 
 //=======================================================================
 //function : InvertedTransformation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
 //=======================================================================
 
 inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
@@ -49,7 +49,7 @@ inline const gp_GTrsf& Select3D_Projector::InvertedTransformation() const
 
 //=======================================================================
 //function : FullTransformation
 
 //=======================================================================
 //function : FullTransformation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline const gp_Trsf& Select3D_Projector::FullTransformation() const
 //=======================================================================
 
 inline const gp_Trsf& Select3D_Projector::FullTransformation() const
@@ -57,7 +57,7 @@ inline const gp_Trsf& Select3D_Projector::FullTransformation() const
 
 //=======================================================================
 //function : Focus
 
 //=======================================================================
 //function : Focus
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline Standard_Real Select3D_Projector::Focus() const
 //=======================================================================
 
 inline Standard_Real Select3D_Projector::Focus() const
@@ -69,7 +69,7 @@ inline Standard_Real Select3D_Projector::Focus() const
 
 //=======================================================================
 //function : Transform
 
 //=======================================================================
 //function : Transform
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline void Select3D_Projector::Transform (gp_Vec& D) const
 //=======================================================================
 
 inline void Select3D_Projector::Transform (gp_Vec& D) const
@@ -83,11 +83,11 @@ inline void Select3D_Projector::Transform (gp_Vec& D) const
 
 //=======================================================================
 //function : Transform
 
 //=======================================================================
 //function : Transform
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
 //=======================================================================
 
 inline void Select3D_Projector::Transform (gp_Pnt& Pnt) const
-{ 
+{
   gp_XYZ xyz = Pnt.XYZ();
   myGTrsf.Transforms(xyz);
   Pnt = gp_Pnt(xyz);
   gp_XYZ xyz = Pnt.XYZ();
   myGTrsf.Transforms(xyz);
   Pnt = gp_Pnt(xyz);
@@ -98,7 +98,7 @@ inline const Handle(V3d_View)& Select3D_Projector::View() const
 {return myView;}
 
 inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
 {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);
   gp_Ax1 ax1 = Lin.Position();
   gp_XYZ xyz = ax1.Location().XYZ();
   T.Transforms(xyz);
@@ -118,10 +118,18 @@ inline void Select3D_Projector::Transform (gp_Lin& Lin, const gp_GTrsf& T) const
 }
 
 inline void Select3D_Projector::Transform (gp_Pnt& Pnt, const gp_GTrsf& T) const
 }
 
 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);
 }
 
   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;
+}
index 979996e..0a8115f 100755 (executable)
@@ -49,10 +49,10 @@ Select3D_SensitiveEntity(OwnerId)
 // Purpose :
 //==================================================
 void Select3D_SensitiveBox::
 // 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...
 {
   Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
-  
+
   if(HasLocation()){
     Bnd_Box B = mybox3d.Transformed(Location().Transformation());
     ProjectBox(aProj,B);
   if(HasLocation()){
     Bnd_Box B = mybox3d.Transformed(Location().Transformation());
     ProjectBox(aProj,B);
@@ -164,29 +164,29 @@ void Select3D_SensitiveBox::Dump(Standard_OStream& S,const Standard_Boolean Full
 //purpose  : 
 //=======================================================================
 
 //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);
                                       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());
   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());
   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());
   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());
   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());
   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());
   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());
   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());
 }
 
   mybox2d.Update(curp2d.X(),curp2d.Y());
 }
 
index df4971a..8259ac9 100755 (executable)
@@ -64,16 +64,18 @@ Standard_Boolean Select3D_SensitiveCurve
   Standard_Integer Rank;
   TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
   Points2D(aArrayOf2dPnt);
   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;
     mylastseg = Rank;
+    // compute and validate the depth (::Depth()) along the eyeline
+    return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin);
+    
   }
   }
-  return KK;
+  return Standard_False;
 
 }
 //==================================================
 
 }
 //==================================================
index 0d774d7..74238ff 100755 (executable)
@@ -1,18 +1,18 @@
 -- File:       Select3D_SensitiveEntity.cdl
 -- Created:    Tue Jan 24 09:30:34 1995
 -- Author:     Rob
 -- 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
 -- 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
 --                               -> Virtual methods rather than
 --                               Deferred for Project
---                               WARNING : Must be redefined for 
+--                               WARNING : Must be redefined for
 --                               each kind of sensitive entity
 --                               each kind of sensitive entity
---                             
+--
 ---Copyright:   Matra Datavision 1995
 
 
 ---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.
     SensitiveEntity from SelectBasics
 
        ---Purpose:  Abstract framework to define 3D sensitive entities.
@@ -29,7 +29,7 @@ uses
     EntityOwner from SelectBasics,
     Location    from TopLoc,
     Lin         from gp,
     EntityOwner from SelectBasics,
     Location    from TopLoc,
     Lin         from gp,
-    Box2d       from Bnd, 
+    Box2d       from Bnd,
     Array1OfPnt2d from TColgp
 
 is
     Array1OfPnt2d from TColgp
 
 is
@@ -37,26 +37,26 @@ is
     Initialize(OwnerId : EntityOwner from SelectBasics);
 
     NeedsConversion(me) returns Boolean is redefined static;
     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
     ---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;
     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
        ---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;
 
 
     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.
 
 
     --          Else on must redefine this method.
 
 
@@ -66,18 +66,18 @@ is
     -- You must redefine this function for any type of
     -- sensitive entity which can accept another connected
     -- sensitive entity.//can be connected to another sensitive entity.
     -- 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;
             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.
 
     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;
              XMin,YMin,XMax,YMax : Real from Standard;
              aTol: Real from Standard)
     returns Boolean from Standard is redefined virtual;
@@ -89,8 +89,8 @@ is
     -- maximum point in the upper right hand corner of the box.
     -- You must redefine this function for every inheriting entity.
     -- You will have to call this framework inside the redefined function.
     -- 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)
              Polyline:Array1OfPnt2d from TColgp;
             aBox:Box2d from Bnd;
              aTol: Real from Standard)
@@ -100,14 +100,14 @@ is
 
     GetEyeLine(me; X,Y : Real from Standard) returns Lin from gp;
     ---Purpose: Returns the eye line for the point defined by the coordinates X,Y.
 
     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> .
     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.
 
     --          the eye towards an X,Y point on the screen. This Method
     --          must return a mean Depth on this line.
 
@@ -115,7 +115,7 @@ is
     Depth(me) returns Real from Standard is redefined;
 
     ---Category: Location of sensitive entities...
     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.
 
     --           location obtained from the entity owner, to minimize memory usage.
     --           SetLocation() and ResetLocation() do nothing by default.
 
@@ -134,7 +134,7 @@ is
     ---Purpose: 2 options :
     --          <FullDump> = False -> general information
     --         <FullDump> = True  -> whole informtion 3D +2d ...
     ---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);
     DumpBox(myclass; S: in out OStream;abox:Box2d from Bnd) ;
 
     UpdateLocation(me:mutable;aLoc:Location from TopLoc);
@@ -145,8 +145,8 @@ is
     SetLastDepth(me:mutable; aDepth: Real from Standard) is protected;
 
 fields
     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;
 
     mylastdepth   : ShortReal from Standard;
 end SensitiveEntity;
 
index 7f69e5b..1303a5a 100755 (executable)
@@ -19,8 +19,8 @@
 
 Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
 SelectBasics_SensitiveEntity(OwnerId),
 
 Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
 SelectBasics_SensitiveEntity(OwnerId),
-mylastprj(NULL),
-mylastdepth(0.0)
+mylastprj(),
+mylastdepth(ShortRealLast())
 {}
 
 //=======================================================================
 {}
 
 //=======================================================================
@@ -28,9 +28,9 @@ mylastdepth(0.0)
 //purpose  : 
 //=======================================================================
 
 //purpose  : 
 //=======================================================================
 
-void Select3D_SensitiveEntity::Project(const Select3D_Projector& aPrj)
+void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
 {
 {
-  mylastprj = (Standard_Address*)&aPrj;
+  mylastprj = aPrj;
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -43,12 +43,17 @@ Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
                                                   const Standard_Real aTol,
                                                   Standard_Real&  DMin)
 {
                                                   const Standard_Real aTol,
                                                   Standard_Real&  DMin)
 {
-  gp_Lin L;
-  if(mylastprj!=NULL)
-    L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
-  SetLastDepth( ComputeDepth(L) );
-
-  return (Abs(mylastdepth)>Precision::Confusion());
+  if (!mylastprj.IsNull())
+  {
+    gp_Lin L = mylastprj->Shoot (X, Y);
+    SetLastDepth (ComputeDepth (L));
+    return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
+  }
+  else
+  {
+    SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
+    return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
+  }
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -184,8 +189,10 @@ gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
                                            const Standard_Real Y) const
 {
   gp_Lin L;
                                            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;
 }
 
   return L;
 }
 
@@ -202,8 +209,8 @@ Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
 //purpose  : 
 //=======================================================================
 
 //purpose  : 
 //=======================================================================
 
-void Select3D_SensitiveEntity::SetLastPrj(const Select3D_Projector& aprj)
-{ mylastprj = (Standard_Address*)& aprj;}
+void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
+{ mylastprj = aprj; }
 
 
 //=======================================================================
 
 
 //=======================================================================
index c0154c6..c029851 100755 (executable)
@@ -8,6 +8,7 @@
 //Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
 
 #include <Select3D_SensitiveFace.ixx>
 //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>
 #include <SelectBasics_BasicTool.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Pnt.hxx>
@@ -117,11 +118,9 @@ Matches(const Standard_Real X,
     Standard_Real valtst = PlaneTest^V1;
     if(isplane2d && Abs(valtst)>aTol) isplane2d=Standard_False;
   }
     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)) {
   }
   //detection d'une auto - intersection dans le polygon 2D; si oui on sort
 //    if (!AutoComputeFlag(myautointer)) {
@@ -151,10 +150,11 @@ Matches(const Standard_Real X,
        res = Standard_True;
     }
   }
        res = Standard_True;
     }
   }
-  if(res)
-    Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
-    
-  return res;
+  if (res)
+  {
+    return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
+  }
+  return Standard_False;
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -230,8 +230,17 @@ void Select3D_SensitiveFace::Dump(Standard_OStream& S,const Standard_Boolean Ful
 //=======================================================================
 Standard_Real Select3D_SensitiveFace::ComputeDepth(const gp_Lin& EyeLine) const
 {
 //=======================================================================
 Standard_Real 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;
 }
 }
index bd7d3ca..ebacc23 100755 (executable)
@@ -89,10 +89,10 @@ void Select3D_SensitiveGroup::Clear()
 //purpose  : 
 //=======================================================================
 
 //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...
 {
   Select3D_SensitiveEntity::Project(aProjector); // to set the field last proj...
-  
+
   for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
     It.Value()->Project(aProjector);
   }
   for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
     It.Value()->Project(aProjector);
   }
@@ -180,16 +180,16 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X,
   myLastTol = aTol;
   for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){
     myLastRank++;
   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;
 }
 
   return Standard_False;
 }
 
@@ -258,18 +258,25 @@ Matches (const TColgp_Array1OfPnt2d& aPoly,
 //=======================================================================
 Standard_Real Select3D_SensitiveGroup::ComputeDepth(const gp_Lin& EyeLine) const
 {
 //=======================================================================
 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++;
     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 thedepth;
 }
@@ -287,7 +294,7 @@ Standard_Integer Select3D_SensitiveGroup::MaxBoxes() const
   return nbboxes;
 }
 
   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())
 {
   Select3D_SensitiveEntity::SetLastPrj(Prj);
   for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next())
index 63cccc7..7c0115a 100755 (executable)
@@ -32,15 +32,15 @@ Select3D_SensitiveEntity(anOwner)
 // Purpose :
 //==================================================
 void Select3D_SensitivePoint
 // 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())
 {
   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);
   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;
 }
   }
   myprojpt = aPoint2d;
 }
@@ -69,9 +69,10 @@ Standard_Boolean Select3D_SensitivePoint
          Standard_Real& DMin)
 {
   DMin = gp_Pnt2d(X,Y).Distance(myprojpt);
          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;
 }
   }
   return Standard_False;
 }
index 15c2b0e..69b58d4 100755 (executable)
@@ -61,7 +61,7 @@ Select3D_SensitiveEntity(OwnerId)
 // Purpose :
 //==================================================
 
 // 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();
 {
   Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
   mybox2d.SetVoid();
@@ -71,11 +71,14 @@ void Select3D_SensitivePoly::Project(const Select3D_Projector& aProj)
   for(Standard_Integer i=0;i<mynbpoints;i++)
     {
       gp_Pnt aPnt(((Select3D_Pnt*)mypolyg3d)[i].x, ((Select3D_Pnt*)mypolyg3d)[i].y, ((Select3D_Pnt*)mypolyg3d)[i].z);
   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
       }
       else
-       aProj.Project(aPnt,aPnt2d);
+      {
+        aProj->Project(aPnt,aPnt2d);
+      }
       mybox2d.Update(aPnt2d);
       ((Select3D_Pnt2d*)mypolyg2d)[i] = aPnt2d;
     }
       mybox2d.Update(aPnt2d);
       ((Select3D_Pnt2d*)mypolyg2d)[i] = aPnt2d;
     }
index cbb37d3..c8a0ac8 100755 (executable)
@@ -45,7 +45,7 @@ mymaxrect(MaxRect)
 // Purpose  :
 //=====================================================
 void Select3D_SensitiveSegment
 // 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;
 {
   Select3D_SensitiveEntity::Project(aProj); // to set the field last proj...
   gp_Pnt2d aPoint2dStart;
@@ -54,12 +54,12 @@ void Select3D_SensitiveSegment
   if(HasLocation()){
     gp_Pnt aStart(mystart.x, mystart.y, mystart.z);
     gp_Pnt aEnd(myend.x, myend.y, myend.z);
   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{
   }
   else{
-    aProj.Project(mystart,aPoint2dStart);
-    aProj.Project(myend,aPoint2dEnd);
+    aProj->Project(mystart,aPoint2dStart);
+    aProj->Project(myend,aPoint2dEnd);
   }
   myprojstart = aPoint2dStart;
   myprojend = aPoint2dEnd;
   }
   myprojstart = aPoint2dStart;
   myprojend = aPoint2dEnd;
@@ -124,8 +124,7 @@ Standard_Boolean Select3D_SensitiveSegment
   gp_Pnt2d aPEnd(myprojend.x,myprojend.y);
   if ( ! SelectBasics_BasicTool::MatchSegment (aPStart, aPEnd, X, Y, aTol, DMin) )
     return Standard_False;
   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::
 }
 
 Standard_Boolean Select3D_SensitiveSegment::
index acce87a..ac0ef1a 100755 (executable)
@@ -11,6 +11,7 @@
 
 #include <Select3D_SensitiveTriangulation.ixx>
 #include <gp_Pnt2d.hxx>
 
 #include <Select3D_SensitiveTriangulation.ixx>
 #include <gp_Pnt2d.hxx>
+#include <Poly.hxx>
 #include <Poly_Connect.hxx>
 #include <CSLib_Class2d.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 #include <Poly_Connect.hxx>
 #include <CSLib_Class2d.hxx>
 #include <TColStd_Array1OfInteger.hxx>
@@ -31,7 +32,7 @@ static Standard_Integer S3D_NumberOfFreeEdges(const Handle(Poly_Triangulation)&
     for (j = 0; j < 3; j++)
       if (t[j] == 0) nFree++;
   }
     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)
 }
 static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY& p1, const gp_XY& TheP,
                                                    const Standard_Real aTol, Standard_Real& aDMin)
@@ -45,7 +46,7 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
 
   gp_XY V01(p1);V01-=p0;
   gp_XY Vec(TheP);Vec -= p0;
 
   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;
   Standard_Real u = Vec*V01.Normalized();
   if(u<-aTol) return Standard_False;
   Standard_Real u1 = u-aTol;
@@ -68,12 +69,12 @@ static Standard_Boolean S3D_STriangul_NearSegment (const gp_XY& p0, const gp_XY&
 //   VEdg-= PEdg2.XY();
 //   VCur-=PCur.XY();
 //   Standard_Real long1 = VEdg.SquareModulus();
 //   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;
 //   if(long1<=TolTol)
 //     return VCur.SquareModulus();
 //   Standard_Real Val = VEdg^VCur;
 //   return Val*Val/long1;
-  
+
 // }
 
 static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
 // }
 
 static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
@@ -94,7 +95,7 @@ static Standard_Boolean S3D_IsEdgeIn(const Standard_Integer e1,
 
 //=======================================================================
 //function : Select3D_SensitiveTriangulation
 
 //=======================================================================
 //function : Select3D_SensitiveTriangulation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Select3D_SensitiveTriangulation::
 //=======================================================================
 
 Select3D_SensitiveTriangulation::
@@ -115,11 +116,11 @@ myDetectedTr(-1)
 
   Standard_Integer fr = 1;
   const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
 
   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];
   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));
   // pour rechercher les connexions dans le cas ou on ne s'occupe de la frontiere...
   if(!myIntFlag){
     myFreeEdges = new TColStd_HArray1OfInteger(1,2*S3D_NumberOfFreeEdges(Trg));
@@ -148,10 +149,10 @@ myDetectedTr(-1)
     }
   }
 
     }
   }
 
-  
+
   if(nbTriangles!=0) cdg /= nbTriangles;
   myCDG3D = gp_Pnt(cdg);
   if(nbTriangles!=0) cdg /= nbTriangles;
   myCDG3D = gp_Pnt(cdg);
-  
+
   ComputeTotalTrsf();
 
   if(myTrsf.Form()!=gp_Identity)
   ComputeTotalTrsf();
 
   if(myTrsf.Form()!=gp_Identity)
@@ -161,7 +162,7 @@ myDetectedTr(-1)
 
 //=======================================================================
 //function : Select3D_SensitiveTriangulation
 
 //=======================================================================
 //function : Select3D_SensitiveTriangulation
-//purpose  : 
+//purpose  :
 //=======================================================================
 Select3D_SensitiveTriangulation::
 Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
 //=======================================================================
 Select3D_SensitiveTriangulation::
 Select3D_SensitiveTriangulation(const Handle(SelectBasics_EntityOwner)& OwnerId,
@@ -182,105 +183,52 @@ myDetectedTr(-1)
 }
 //=======================================================================
 //function : Project
 }
 //=======================================================================
 //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...
 {
   Select3D_SensitiveEntity::Project(aPrj); // to set the field last proj...
-  
+
   mybox2d.SetVoid();
   mybox2d.SetVoid();
-  const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();  
-  
+  const TColgp_Array1OfPnt& Nodes = myTriangul->Nodes();
+
   gp_Pnt2d ProjPT;
   gp_Pnt2d ProjPT;
-  
+
   for(Standard_Integer I=1;I<=myTriangul->NbNodes();I++){
     if(myTrsf.Form()!=gp_Identity)
   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
     else
-      aPrj.Project(Nodes(I),ProjPT);
-    
+      aPrj->Project(Nodes(I),ProjPT);
+
     myNodes2d.SetValue(I,ProjPT);
     mybox2d.Add(ProjPT);
   }
     myNodes2d.SetValue(I,ProjPT);
     mybox2d.Add(ProjPT);
   }
-  
-  aPrj.Project(myCDG3D,myCDG2D);
+
+  aPrj->Project(myCDG3D,myCDG2D);
 }
 
 //=======================================================================
 //function : Areas
 }
 
 //=======================================================================
 //function : Areas
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 //=======================================================================
 
-void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes) 
+void Select3D_SensitiveTriangulation::Areas(SelectBasics_ListOfBox2d& boxes)
 {
   boxes.Append(mybox2d);
 }
 
 {
   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
 //=======================================================================
 //function : Matches
-//purpose  : 
+//purpose  :
 //=======================================================================
 Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
                                                          const Standard_Real Y,
                                                          const Standard_Real aTol,
 //=======================================================================
 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
 {
   // 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();
     return Standard_False;
 
   DMin = Precision::Infinite();
@@ -291,12 +239,12 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
   // on regarde si on est a l'interieur d'1 triangle 2d.
   if(myIntFlag)
   {
   // 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();
     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;
     for (Standard_Integer itr=1; itr<=myTriangul->NbTriangles(); itr++)
     {
       Standard_Integer n1,n2,n3;
@@ -304,30 +252,32 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
       const gp_XY& aPnt2d1 = myNodes2d(n1).XY();
       const gp_XY& aPnt2d2 = myNodes2d(n2).XY();
       const gp_XY& aPnt2d3 = myNodes2d(n3).XY();
       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
         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 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);
 
                                        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;
       {
         aMinDepth = aDepth;
         myDetectedTr = itr;
-        DMin = DD;
+        DMin = Sqrt (aDistSquare);
       }
     }
   }
       }
     }
   }
-  
+
   //    Cas Uniquement Test sur Frontiere de la triangulation...
   //    Cas Uniquement Test sur Frontiere de la triangulation...
-  //   
+  //
   else
   {
     //Standard_Integer ifirst;
   else
   {
     //Standard_Integer ifirst;
@@ -335,7 +285,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
     Standard_Integer nn = FreeE.Length(), Node1,Node2;
     //Standard_Real LEdg;
     //Standard_Real DMinDMin,TolTol = aTol*aTol;
     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);
     for (Standard_Integer ifri =1; ifri <= nn && myDetectedTr < 0; ifri+=2)
     {
       Node1 = FreeE(ifri);
@@ -344,43 +294,44 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real X,
                                      myNodes2d(Node2).XY(),
                                      BidPoint, aTol, DMin) )
       {
                                      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;
         {
           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
           }
             break; // return first found; selection of closest is not implemented yet
           }
-       }
+        }
       }
     }
       }
     }
-  } 
+  }
   if ( myDetectedTr <= 0 )
     return Standard_False;
   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
 }
 
 
 //=======================================================================
 //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,
 //=======================================================================
 
 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);
 {
   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;
   for(Standard_Integer i=myNodes2d.Lower();i<=myNodes2d.Upper();i++){
     if(B.IsOut(myNodes2d(i)))
       return Standard_False;
@@ -391,14 +342,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::Matches(const Standard_Real XM
 
 //=======================================================================
 //function : Matches
 
 //=======================================================================
 //function : Matches
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Standard_Boolean Select3D_SensitiveTriangulation::
 Matches (const TColgp_Array1OfPnt2d& aPoly,
         const Bnd_Box2d& aBox,
         const Standard_Real aTol)
 //=======================================================================
 
 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;
   Standard_Real Umin,Vmin,Umax,Vmax;
   aBox.Get(Umin,Vmin,Umax,Vmax);
   Standard_Real Tolu,Tolv;
@@ -427,7 +378,7 @@ Standard_Integer Select3D_SensitiveTriangulation::Status (const gp_XY& TheP,
 
 //=======================================================================
 //function : IsFree
 
 //=======================================================================
 //function : IsFree
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
 //=======================================================================
 
 Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer IndexOfTriangle,
@@ -441,36 +392,36 @@ Standard_Boolean Select3D_SensitiveTriangulation::IsFree(const Standard_Integer
     TColStd_Array1OfInteger& FreeE = myFreeEdges->ChangeArray1();
 
   for(Standard_Integer I=1;I<=FreeE.Length() && FoundIndex==-1;I+=2){
     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) == 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;}
   }
       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
   return FoundIndex!=-1;
 }
 
 
 //=======================================================================
 //function : GetConnected
-//purpose  : 
+//purpose  :
 //=======================================================================
 Handle(Select3D_SensitiveEntity) Select3D_SensitiveTriangulation::
 GetConnected(const TopLoc_Location& aLoc)
 {
 //=======================================================================
 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);
     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);
   if(HasLocation()) NiouEnt->SetLocation(Location());
 //  TopLoc_Location TheLocToApply = HasLocation() ?  Location()*aLoc : aLoc;
 //  if(!TheLocToApply.IsIdentity())
   NiouEnt->UpdateLocation(aLoc);
-    
+
 
   return NiouEnt;
 }
 
   return NiouEnt;
 }
@@ -478,9 +429,9 @@ GetConnected(const TopLoc_Location& aLoc)
 
 //=======================================================================
 //function : ResetLocation
 
 //=======================================================================
 //function : ResetLocation
-//purpose  : 
+//purpose  :
 //=======================================================================
 //=======================================================================
-void Select3D_SensitiveTriangulation::ResetLocation() 
+void Select3D_SensitiveTriangulation::ResetLocation()
 {
   Select3D_SensitiveEntity::ResetLocation();
   ComputeTotalTrsf();
 {
   Select3D_SensitiveEntity::ResetLocation();
   ComputeTotalTrsf();
@@ -494,9 +445,9 @@ void Select3D_SensitiveTriangulation::SetLocation(const TopLoc_Location& aLoc)
 
 //=======================================================================
 //function : Dump
 
 //=======================================================================
 //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<<"\tSensitiveTriangulation 3D :"<<endl;
   if(myiniloc.IsIdentity())
@@ -505,7 +456,7 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
     S<<"\t\tExisting Initial Location"<<endl;
   if(HasLocation())
     S<<"\t\tExisting Location"<<endl;
     S<<"\t\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;
   S<<"\t\tNb Triangles : "<<myTriangul->NbTriangles()<<endl;
   S<<"\t\tNb Nodes     : "<<myTriangul->NbNodes()<<endl;
   S<<"\t\tNb Free Edges: "<<myFreeEdges->Length()/2<<endl;
@@ -518,14 +469,14 @@ void Select3D_SensitiveTriangulation::Dump(Standard_OStream& S,const Standard_Bo
 
 //=======================================================================
 //function : ComputeDepth
 
 //=======================================================================
 //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();
 //=======================================================================
 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)};
   Standard_Integer n1,n2,n3;
   triangles(myDetectedTr).Get(n1,n2,n3);
   gp_Pnt P[3]={Nodes(n1),Nodes(n2),Nodes(n3)};
@@ -535,18 +486,18 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
       P[i].Transform(myTrsf);
     }
   }
       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();
 
   // 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];
   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())
   // eliminons tout de suite les cas singuliers...
   Standard_Integer SingularCase(-1);
   if(Vtr[0].SquareMagnitude()<= Precision::Confusion())
@@ -557,13 +508,13 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
   if(Vtr[2].SquareMagnitude()<= Precision::Confusion())
     if( SingularCase < 0 ) SingularCase = 1;
 #endif
   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;
   }
   // 3 pts confondus...
   if(SingularCase ==2){
     prof= ElCLib::Parameter(EyeLine,P[0]);
     return prof;
   }
-  
+
   if(SingularCase!=0)
     Vtr[0].Normalize();
   if(SingularCase!=1 &&
   if(SingularCase!=0)
     Vtr[0].Normalize();
   if(SingularCase!=1 &&
@@ -571,7 +522,7 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
     Vtr[2].Normalize();
   gp_Vec OPo(Oye,P[0]);
   // 2 points confondus... on recherche l'intersection entre le segment et la ligne oeil/point vise.
     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;
   if(SingularCase!=-1){
     gp_Vec V = SingularCase==0 ? Vtr[2] : Vtr[0];
     gp_Vec Det = Dir^V;
@@ -584,25 +535,25 @@ Standard_Real Select3D_SensitiveTriangulation::ComputeDepth(const gp_Lin& EyeLin
       prof = VSM.Z()/Det.Z();
   }
   else{
       prof = VSM.Z()/Det.Z();
   }
   else{
-    
+
     Standard_Real val1 = OPo.DotCross(Vtr[0],Vtr[2]);
     Standard_Real val2 = Dir.DotCross(Vtr[0],Vtr[2]);
     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(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]));
   }
   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
   return prof;
 }
 
 //=======================================================================
 //function : DetectedTriangle
-//purpose  : 
+//purpose  :
 //=======================================================================
 Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
                                                                   gp_Pnt& P2,
 //=======================================================================
 Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
                                                                   gp_Pnt& P2,
@@ -610,10 +561,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
 {
   if(myDetectedTr==-1) return Standard_False; // non implemente actuellement...
   const Poly_Array1OfTriangle& triangles = myTriangul->Triangles();
 {
   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);
   Standard_Integer n1,n2,n3;
   triangles(myDetectedTr).Get(n1,n2,n3);
-  
+
   P1 = Nodes(n1);
   P2 = Nodes(n2);
   P3 = Nodes(n3);
   P1 = Nodes(n1);
   P2 = Nodes(n2);
   P3 = Nodes(n3);
@@ -622,27 +573,27 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle(gp_Pnt& P1,
     P2.Transform(myTrsf);
     P3.Transform(myTrsf);
   }
     P2.Transform(myTrsf);
     P3.Transform(myTrsf);
   }
-  
+
   return Standard_True;
 }
 
 //=============================================================================
 // Function : DetectedTriangle2d
   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
 {
   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();
     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();
   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 )
   {
        n2 >= aLower && n2 <= anUpper &&
        n3 >= aLower && n3 <= anUpper )
   {
@@ -651,15 +602,15 @@ Standard_Boolean Select3D_SensitiveTriangulation::DetectedTriangle2d(
     P3 = myNodes2d.Value( n3 );
     return Standard_True;
   }
     P3 = myNodes2d.Value( n3 );
     return Standard_True;
   }
-  else 
+  else
     return Standard_False;
     return Standard_False;
-  
+
 }
 
 }
 
-void Select3D_SensitiveTriangulation::ComputeTotalTrsf() 
+void Select3D_SensitiveTriangulation::ComputeTotalTrsf()
 {
   Standard_Boolean hasloc = (HasLocation() || !myiniloc.IsIdentity());
 {
   Standard_Boolean hasloc = (HasLocation() || !myiniloc.IsIdentity());
-  
+
   if(hasloc){
     if(myiniloc.IsIdentity())
       myTrsf = Location().Transformation();
   if(hasloc){
     if(myiniloc.IsIdentity())
       myTrsf = Location().Transformation();
index 67acf6a..6cd7211 100755 (executable)
@@ -43,13 +43,13 @@ void Select3D_SensitiveWire
       mysensitive.Append(aSensitive);
     else
       mysensitive.Append(aSensitive->GetConnected(Location()));
       mysensitive.Append(aSensitive);
     else
       mysensitive.Append(aSensitive->GetConnected(Location()));
-    
+
   }
 }
 
 //=======================================================================
 //function : SetLocation
   }
 }
 
 //=======================================================================
 //function : SetLocation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
 //=======================================================================
 
 void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
@@ -60,7 +60,7 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
 
   if(HasLocation())
     if(aLoc == Location()) return;
 
   if(HasLocation())
     if(aLoc == Location()) return;
-  
+
   Select3D_SensitiveEntity::SetLocation(aLoc);
   for(Standard_Integer i=1;i<=mysensitive.Length();i++){
     if(mysensitive(i)->HasLocation()){
   Select3D_SensitiveEntity::SetLocation(aLoc);
   for(Standard_Integer i=1;i<=mysensitive.Length();i++){
     if(mysensitive(i)->HasLocation()){
@@ -69,12 +69,12 @@ void Select3D_SensitiveWire::SetLocation(const TopLoc_Location& aLoc)
     }
     else
       mysensitive(i)->SetLocation(aLoc);
     }
     else
       mysensitive(i)->SetLocation(aLoc);
-    
+
   }
 }
 //=======================================================================
 //function : ResetLocation
   }
 }
 //=======================================================================
 //function : ResetLocation
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_SensitiveWire::ResetLocation()
 //=======================================================================
 
 void Select3D_SensitiveWire::ResetLocation()
@@ -85,7 +85,7 @@ void Select3D_SensitiveWire::ResetLocation()
       mysensitive(i)->SetLocation(mysensitive(i)->Location()*Location().Inverted());
     else
       mysensitive(i)->ResetLocation();
       mysensitive(i)->SetLocation(mysensitive(i)->Location()*Location().Inverted());
     else
       mysensitive(i)->ResetLocation();
-    
+
   }
   Select3D_SensitiveEntity::ResetLocation();
 }
   }
   Select3D_SensitiveEntity::ResetLocation();
 }
@@ -94,9 +94,9 @@ void Select3D_SensitiveWire::ResetLocation()
 // Purpose  :
 //=====================================================
 void Select3D_SensitiveWire
 // 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);
 }
     mysensitive(i)->Project(aProj);
   Select3D_SensitiveEntity::Project(aProj);
 }
@@ -113,12 +113,12 @@ void Select3D_SensitiveWire
   Standard_Integer i;
   for (i=1; i<=mysensitive.Length(); i++)
     mysensitive.Value(i)->Areas(BidL);
   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());
   for(SelectBasics_ListIteratorOfListOfBox2d it(BidL);it.More();it.Next())
     BB.Add(it.Value());
-  
+
   theareas.Append(BB);
   theareas.Append(BB);
-  
+
 }
 
 //=====================================================
 }
 
 //=====================================================
@@ -144,9 +144,11 @@ Standard_Boolean Select3D_SensitiveWire
       }
     }
   }
       }
     }
   }
-//  Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
-  
-  return IsTouched;
+  if ( ! IsTouched )
+    return Standard_False;
+
+  // compute and validate the depth (::Depth()) along the eyeline
+  return Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
 }
 
 //=====================================================
 }
 
 //=====================================================
@@ -162,7 +164,7 @@ Matches (const Standard_Real XMin,
 {
   Standard_Integer i;
   for (i=1; i<=mysensitive.Length(); i++) {
 {
   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;
       return Standard_False;
   }
   return Standard_True;
@@ -170,17 +172,17 @@ Matches (const Standard_Real XMin,
 
 //=======================================================================
 //function : Matches
 
 //=======================================================================
 //function : Matches
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Standard_Boolean Select3D_SensitiveWire::
 Matches (const TColgp_Array1OfPnt2d& aPoly,
         const Bnd_Box2d& aBox,
         const Standard_Real aTol)
 //=======================================================================
 
 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++) {
   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;
       return Standard_False;
   }
   return Standard_True;
@@ -199,14 +201,14 @@ MaxBoxes () const
 
 //=======================================================================
 //function : GetConnected
 
 //=======================================================================
 //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));
 {
   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
   if(HasLocation())
     SWIR->SetLocation(Location()*aLoc);
   else
@@ -217,7 +219,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetConnected(const TopL
 
 //=======================================================================
 //function : Dump
 
 //=======================================================================
 //function : Dump
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
 //=======================================================================
 
 void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
@@ -237,23 +239,23 @@ void Select3D_SensitiveWire::Dump(Standard_OStream& S,const Standard_Boolean Ful
 
 //=======================================================================
 //function : ComputeDepth
 
 //=======================================================================
 //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);
   if(myDetectedIndex==-1)
     // should be never called...
     return Precision::Infinite();
   return mysensitive(myDetectedIndex)->ComputeDepth(EyeLine);
-    
+
 }
 
 //=======================================================================
 //function : SetLastPrj
 }
 
 //=======================================================================
 //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++)
 {
   Select3D_SensitiveEntity::SetLastPrj(Prj);
   for(Standard_Integer i=1;i<=mysensitive.Length();i++)
@@ -263,7 +265,7 @@ void Select3D_SensitiveWire::SetLastPrj(const Select3D_Projector& Prj)
 
 //=======================================================================
 //function : GetEdges
 
 //=======================================================================
 //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 )
 {
 //=======================================================================
 void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdges )
 {
@@ -273,7 +275,7 @@ void Select3D_SensitiveWire::GetEdges( Select3D_SensitiveEntitySequence& theEdge
 
 //=============================================================================
 // Function : GetLastDetected
 
 //=============================================================================
 // Function : GetLastDetected
-// Purpose  : 
+// Purpose  :
 //=============================================================================
 Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
 {
 //=============================================================================
 Handle(Select3D_SensitiveEntity) Select3D_SensitiveWire::GetLastDetected() const
 {
index a13d5dc..d80f61d 100755 (executable)
@@ -4,8 +4,6 @@
 // Author:     Robert COUBLANC
 //             <rob>
 
 // Author:     Robert COUBLANC
 //             <rob>
 
-
-
 #include <StdSelect.ixx>
 #include <SelectMgr_Selection.hxx>
 #include <Graphic3d_StructureManager.hxx>
 #include <StdSelect.ixx>
 #include <SelectMgr_Selection.hxx>
 #include <Graphic3d_StructureManager.hxx>
 #include <gp_Ax3.hxx>
 #include <V3d_PerspectiveView.hxx>
 #include <StdSelect_BRepOwner.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;
 {
   Standard_Real Focale=0.,Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
   Standard_Boolean Pers=Standard_False;
@@ -48,7 +42,7 @@ Select3D_Projector  StdSelect::GetProjector(const Handle(V3d_View)& aViou)
   gp_Ax3 Axe (At, Zpers, Xpers);
   gp_Trsf T;
   T.SetTransformation(Axe);
   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);
   
 }
 
   
 }
 
index 4292c19..51ad4dd 100755 (executable)
@@ -15,6 +15,7 @@
 #include <gp_Ax3.hxx>
 #include <gp_GTrsf.hxx>
 #include <V3d_PerspectiveView.hxx>
 #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>
 #include <Select3D_SensitiveEntity.hxx>
 #include <Graphic3d_Array1OfVertex.hxx>
 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
@@ -83,6 +84,7 @@ static Standard_Boolean StdSelectDebugModeOn()
 
 StdSelect_ViewerSelector3d
 ::StdSelect_ViewerSelector3d():
 
 StdSelect_ViewerSelector3d
 ::StdSelect_ViewerSelector3d():
+myprj(new Select3D_Projector()),
 mylastzoom(0.0),
 mypixtol(2),
 myupdatetol(Standard_True)
 mylastzoom(0.0),
 mypixtol(2),
 myupdatetol(Standard_True)
@@ -98,7 +100,7 @@ myupdatetol(Standard_True)
 //==================================================
 
 StdSelect_ViewerSelector3d
 //==================================================
 
 StdSelect_ViewerSelector3d
-::StdSelect_ViewerSelector3d(const Select3D_Projector& aProj):
+::StdSelect_ViewerSelector3d(const Handle(Select3D_Projector)& aProj):
 myprj(aProj),
 mylastzoom(0.0),
 mypixtol(2),
 myprj(aProj),
 mylastzoom(0.0),
 mypixtol(2),
@@ -147,7 +149,7 @@ void StdSelect_ViewerSelector3d
 //==================================================
 
 void StdSelect_ViewerSelector3d
 //==================================================
 
 void StdSelect_ViewerSelector3d
-::Set(const Select3D_Projector& aProj)
+::Set(const Handle(Select3D_Projector)& aProj)
 {
   myprj = aProj;
   toupdate=Standard_True;
 {
   myprj = aProj;
   toupdate=Standard_True;
@@ -167,7 +169,53 @@ void StdSelect_ViewerSelector3d
   Standard_Real Xr3d,Yr3d,Zr3d;
   gp_Pnt2d P2d;
   aView->Convert(XPix,YPix,Xr3d,Yr3d,Zr3d);
   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());
 }
 
   InitSelect(P2d.X(),P2d.Y());
 }
 
@@ -195,8 +243,8 @@ void StdSelect_ViewerSelector3d
   gp_Pnt2d P2d_1,P2d_2;
   aView->Convert(XPMin,YPMin,x1,y1,z1);
   aView->Convert(XPMax,YPMax,x2,y2,z2);
   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()),
 
   InitSelect (Min(P2d_1.X(),P2d_2.X()),
               Min(P2d_1.Y(),P2d_2.Y()),
@@ -236,7 +284,7 @@ void StdSelect_ViewerSelector3d
     gp_Pnt2d Pnt2d;
 
     aView->Convert (XP, YP, x, y, z);
     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);
   }
 
     P2d->SetValue (i, Pnt2d);
   }
@@ -272,8 +320,8 @@ DisplayAreas(const Handle(V3d_View)& aView)
   }
 
   SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities);
   }
 
   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);
 
 
   Graphic3d_Array1OfVertex Av1 (1,5);
@@ -291,23 +339,23 @@ DisplayAreas(const Handle(V3d_View)& aView)
       itb.Value().Get (xmin, ymin, xmax, ymax);
 
       Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
       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);
       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);
       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);
       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);
       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);
       Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
 
       myareagroup->Polyline (Av1);
@@ -421,14 +469,14 @@ UpdateProj(const Handle(V3d_View)& aView)
     GT.SetTranslationPart (loc);
     GT.SetVectorialPart (matrix);
 
     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)
 
     // 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())
     // 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)
   }
 
   if (Abs (aView->Scale() - mylastzoom) > 1.e-3)
@@ -1008,23 +1056,23 @@ ComputeAreasPrs (const Handle(SelectMgr_Selection)& Sel)
       itb.Value().Get (xmin, ymin, xmax, ymax);
 
       Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0);
       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);
       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);
       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);
       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);
       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);
       Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z()));
 
       myareagroup->Polyline (Av1);
index e2ceabe..44b9cbb 100755 (executable)
@@ -1,2 +1,4 @@
-inline const Select3D_Projector& StdSelect_ViewerSelector3d::
-Projector() const {return myprj;}
+inline const Handle(Select3D_Projector)& StdSelect_ViewerSelector3d::Projector() const
+{
+  return myprj;
+}
index fb5160b..2a9fa5e 100755 (executable)
@@ -5,13 +5,13 @@
 ---Copyright:  Matra Datavision 1992
 
 
 ---Copyright:  Matra Datavision 1992
 
 
-class Plane from V3d 
-       
-inherits 
+class Plane from V3d
+
+inherits
 
        TShared
        ---Purpose: Defines the services of Plane type objects. Only
 
        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.
        --          with here.
        -- Warning: The representation of the clipping plane must be
        --          calculated by the application by means of Graphic3d.
@@ -20,12 +20,11 @@ inherits
 
 uses
 
 
 uses
 
-       Viewer from V3d,
        View from V3d,
        ClipPlane from Visual3d,
        Structure from Graphic3d,
        Parameter from Quantity,
        View from V3d,
        ClipPlane from Visual3d,
        Structure from Graphic3d,
        Parameter from Quantity,
-       Color from Quantity  
+       Color from Quantity
 
 
 raises
 
 
 raises
@@ -38,11 +37,11 @@ is
         -- The methods :
         --
 
         -- 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
        ---Level : Public
         ---Purpose: Creates a clipping plane using the equation :
         --          <A>*X + <B>*Y + <C>*Z + <D> = 0.0
@@ -54,7 +53,7 @@ is
         ---Category: Methods to modify the Attributs of the Plane
         --------------------------------------------------------
 
         ---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
        ---Level : Public
        ---Purpose: Modifies the plane equation.
        raises BadValue from Viewer
@@ -67,13 +66,13 @@ is
                             aColor: Color from Quantity= Quantity_NOC_GRAY)
        ---Level : Public
        ---Purpose: Display the plane representation
                             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.
         is virtual;
 
         Erase(me: mutable) is static;
         ---Level: Public
         ---Purpose: Erase the plane representation.
-       
+
         ---------------------------------------------------
         ---Category: Inquire methods
         ---------------------------------------------------
         ---------------------------------------------------
         ---Category: Inquire methods
         ---------------------------------------------------
@@ -84,7 +83,7 @@ is
 
        IsDisplayed( me ) returns Boolean from Standard is static;
        ---Level : Public
 
        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
 
         -----------------------------------------
         ---Category: Private or Protected methods
@@ -97,7 +96,7 @@ is
        Update( me : mutable ) is static private;
        ---Level : Internal
        ---Purpose: Updates the the plane representation.
        Update( me : mutable ) is static private;
        ---Level : Internal
        ---Purpose: Updates the the plane representation.
-       
+
 
 fields
 
 
 fields
 
index 33a2d22..db245a5 100755 (executable)
@@ -6,33 +6,36 @@
 
 //-Version
 
 
 //-Version
 
-//-Design       
+//-Design
 
 
-//-Warning      
+//-Warning
 
 //-References
 
 //-Language     C++ 2.1
 
 
 //-References
 
 //-Language     C++ 2.1
 
-// for the class
 #include <V3d.hxx>
 #include <V3d_Plane.ixx>
 #include <Viewer_BadValue.hxx>
 
 #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
 
 //-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");
 
 
   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) {
 }
 
 //-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) ;
   Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::SetPlane, bad plane coefficients");
 
   MyPlane->SetPlane(A,B,C,D) ;
@@ -42,31 +45,28 @@ void V3d_Plane::SetPlane( const Standard_Real A, const Standard_Real B, const St
   }
 }
 
   }
 }
 
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Array1OfVertex.hxx> 
-#include <Graphic3d_AspectFillArea3d.hxx>
 void V3d_Plane::Display(const Handle(V3d_View)& aView,
                        const Quantity_Color& aColor) {
     Handle(V3d_Viewer) theViewer = aView->Viewer();
 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();
     }
       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);
     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);
                                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);
 //    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);
     p(1).SetCoord(-size/2.,-size/2.,offset);
     p(2).SetCoord(-size/2., size/2.,offset);
     p(3).SetCoord( size/2., size/2.,offset);
@@ -96,7 +96,6 @@ Standard_Boolean V3d_Plane::IsDisplayed() const {
   return MyGraphicStructure->IsDisplayed();
 }
 
   return MyGraphicStructure->IsDisplayed();
 }
 
-#include <gp_Pln.hxx>
 void V3d_Plane::Update() {
 
   if( !MyGraphicStructure.IsNull() ) {
 void V3d_Plane::Update() {
 
   if( !MyGraphicStructure.IsNull() ) {
index 599dc9a..7873c53 100755 (executable)
@@ -1,28 +1,28 @@
--- 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
 
 
 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:
 
 
         ---References:
 
@@ -30,656 +30,652 @@ inherits
 
         Viewer from Viewer
 
 
         Viewer from Viewer
 
-uses 
+uses
 
 
---        GraphicDevice from Graphic3d,
         GraphicDevice from Aspect,
         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,
         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,
         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
 
         GradientFillMethod from Aspect
 
-       
 raises
 
 raises
 
-       BadValue from Viewer
+        BadValue from Viewer
 
 is
 
 
 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;
 
         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;
         DefaultOrthographicView(me: mutable) returns mutable OrthographicView from V3d;
-       
+
         DefaultPerspectiveView(me: mutable) returns mutable PerspectiveView 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 );
         -------------------------------------------------------
 
         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);
 
         SetViewOff (me:mutable);
-       ---Level: Public
+        ---Level: Public
         ---Purpose: Deactivates all the views of a Viewer
         ---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;
 
         Update (me:mutable ) is redefined static;
-       ---Level: Public
+        ---Level: Public
         ---Purpose: Updates the display of all the views of a viewer.
         ---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);
 
         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 );
 
         Redraw ( me );
-       ---Level: Public
+        ---Level: Public
         ---Purpose: Redraws all the views of the Viewer even if no
         ---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);
 
         Remove (me:mutable);
-       ---Level: Public
+        ---Level: Public
         ---Purpose: Suppresses the Viewer.
 
         ---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  );
                                      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
                                      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);
 
 
         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;
         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);
 
         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);
 
         SetDefaultTypeOfView(me:mutable; Type : TypeOfView from V3d);
-       ---Level: Public
+        ---Level: Public
 
 
         SetPrivilegedPlane(me: mutable; aPlane: Ax3 from gp);
 
 
         SetPrivilegedPlane(me: mutable; aPlane: Ax3 from gp);
-       ---Level: Public
-       
+        ---Level: Public
+
         PrivilegedPlane(me) returns Ax3 from gp;
         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);
         SetCurrentSelectedLight (me : mutable; TheLight : Light from V3d);
-       ---Level: Advanced 
+        ---Level: Advanced
         ---Purpose: Defines the selected light.
 
         ---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
         -----------------------------------------
 
 
         -----------------------------------------
         ---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;
                                  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.
 
         ---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;
 
         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;
 
         IfMoreViews( me ) returns Boolean;
-       ---Level:   Advanced 
+        ---Level:   Advanced
         ---Purpose: Returns True if One View more can be
         --          activated in this Viewer.
         ---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)
         ---Purpose : Go to the next active view
         --           (if there is not, ActiveView will raise an exception)
-       
+
         ActiveView(me) returns mutable View from V3d;
         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)
         ---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)
 
         ---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)
         ---Purpose : Go to the next Defined Light
         --           (if there is not, DefinedLight will raise an exception)
-       
+
         DefinedLight(me) returns Light from V3d;
         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)
         ---Purpose : Go to the next Defined Plane
         --           (if there is not, DefinedPlane will raise an exception)
-       
+
         DefinedPlane(me) returns Plane from V3d;
         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;
 
         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;
 
         IsGlobalLight (me; TheLight : Light from V3d) returns Boolean;
-       ---Level:   Advanced 
-       
+        ---Level:   Advanced
+
         ComputedMode(me) returns Boolean from Standard;
         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;
 
         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>.
         ---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
         -----------------------------------------
 
 
         -----------------------------------------
         ---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);
 
         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)
 
         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
 
 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 ;
         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;
         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;
         myActiveViewsIterator: ListIteratorOfListOfTransient from TColStd;
         myDefinedViewsIterator: ListIteratorOfListOfTransient from TColStd;
         myActiveLightsIterator: ListIteratorOfListOfTransient from TColStd;
@@ -687,23 +683,23 @@ fields
         myDefinedPlanesIterator: ListIteratorOfListOfTransient from TColStd;
         myComputedMode: Boolean from Standard;
         myDefaultComputedMode: Boolean from Standard;
         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;
 
         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
 
 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;
         SetPlane  from package V3d (aViewer: Viewer from V3d; x1,y1,z1,x2,y2,z2: Length from Quantity)
 end Viewer;
index a2df927..19e206e 100755 (executable)
@@ -305,12 +305,12 @@ void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx)
 
 Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
 {
 
 Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
 {
-  return TheAISContext()->CurrentViewer();
+  return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
 }
 
 Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
 {
 }
 
 Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
 {
-  return TheAISContext()->CurrentViewer();
+  return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
 }
 
 
 }
 
 
@@ -2066,7 +2066,7 @@ static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
 // Function : VAnimation
 //==================================================================================
 static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
 // 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;
   }
     di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
     return 1;
   }
@@ -2580,7 +2580,7 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
   Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
 
   // step 1: prepare the data
   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);
   }
     Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
     TheAISContext()->AddFilter(F1);
   }
@@ -2639,7 +2639,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
 
   // step 1: prepare the data
 
 
   // step 1: prepare the data
 
-  if(curindex != 0){
+  if(curindex !=0){
     Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
     TheAISContext()->AddFilter(F1);
   }
     Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
     TheAISContext()->AddFilter(F1);
   }
@@ -2666,7 +2666,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
     IO = TheAISContext()->SelectedInteractive();
   }
 
     IO = TheAISContext()->SelectedInteractive();
   }
 
-  if(curindex != 0)
+  if(curindex!=0)
     TheAISContext()->CloseLocalContext(curindex);
   return IO;
 }
     TheAISContext()->CloseLocalContext(curindex);
   return IO;
 }
@@ -3079,7 +3079,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
 
 static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
 {
 
 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);
 
   AIS_KindOfInteractive TheType;
   Standard_Integer TheSign(-1);
index b736fcf..44ed93e 100755 (executable)
 
 #include <OSD_Chronometer.hxx>
 #include <TCollection_AsciiString.hxx>
 
 #include <OSD_Chronometer.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
 #include <V3d_View.hxx>
 #include <V3d_Viewer.hxx>
 #include <V3d_View.hxx>
+#include <V3d_Plane.hxx>
 #include <V3d.hxx>
 
 #include <AIS_Shape.hxx>
 #include <V3d.hxx>
 
 #include <AIS_Shape.hxx>
@@ -2556,6 +2558,180 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
   return 0;
 }
 
   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
 
 //=======================================================================
 //function : ObjectsCommands
@@ -2625,4 +2801,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
     __FILE__,VDrawSphere,group);
 
     "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);
+
 }
 }