Salome HOME
Rollback previous incorrect integration.
[modules/geom.git] / src / OBJECT / GEOM_Actor.cxx
index cb0ad35296a276cdfd47202731ca4b68588c47cb..e45f39cf35e888097c3f0f7e68deea19680a7fe7 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -17,7 +17,9 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://ww
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 //  GEOM OBJECT : interactive object for Geometry entities visualization
 //  File   : GEOM_Actor.cxx
 //  Author : Christophe ATTANASIO
@@ -37,6 +39,8 @@
 #include "GEOM_ShadingFace.h"
 #include "SVTK_Actor.h"
 
+#include <OCC2VTK_Tools.h>
+
 #include <vtkObjectFactory.h> 
 #include <vtkRenderer.h> 
 #include <vtkProperty.h> 
  
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopExp_Explorer.hxx>
-#include <Poly_Triangulation.hxx>
-#include <BRepMesh_IncrementalMesh.hxx>
-#include <Bnd_Box.hxx>
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
-#include <BRepBndLib.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopoDS_Iterator.hxx>
 #include <TopExp.hxx>
  
 #include <vtkPolyDataWriter.h> 
@@ -176,6 +174,7 @@ GEOM_Actor::GEOM_Actor():
 
   // Toggle display mode 
   setDisplayMode(0); // WIRE FRAME
+  SetVectorMode(0);  //
 
 } 
  
@@ -302,7 +301,7 @@ SetVisibility(int theVisibility)
 { 
 #ifdef MYDEBUG
   MESSAGE ( "GEOM_Actor::SetVisibility = "<<theVisibility <<"  myIsSelected="<< myIsSelected
-           << " theVisibility="<<theVisibility<<" myIsPreselected="<<myIsPreselected );
+            << " theVisibility="<<theVisibility<<" myIsPreselected="<<myIsPreselected );
 #endif
 
   SALOME_Actor::SetVisibility(theVisibility);
@@ -352,35 +351,6 @@ GEOM_Actor
   return myVectorMode;
 }
 
-static 
-void 
-MeshShape(const TopoDS_Shape& theShape,
-          float& theDeflection, 
-          bool theIsRelative)
-{ 
-  static Standard_Real RELATIVE_DEFLECTION = 0.0001; 
-  Standard_Real aDeflection = theDeflection; 
-
-  if(theDeflection <= 0) { // Compute default theDeflection
-    Bnd_Box B;
-    BRepBndLib::Add(theShape, B);
-    Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
-    B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-    Standard_Real aDiagonal = (aXmax-aXmin)*(aXmax-aXmin) +
-                              (aYmax-aYmin)*(aYmax-aYmin) +
-                              (aZmax-aZmin)*(aZmax-aZmin);
-    aDiagonal = sqrt(aDiagonal); 
-    aDeflection = aDiagonal*RELATIVE_DEFLECTION; 
-    if(theIsRelative) 
-      theDeflection = RELATIVE_DEFLECTION; 
-    else 
-      theDeflection = aDeflection; 
-  }
-  
-  BRepMesh_IncrementalMesh aMesh(theShape,aDeflection);
-}
-
 void  
 GEOM_Actor:: 
 SetDeflection(float theDeflection, bool theIsRelative) 
@@ -388,7 +358,7 @@ SetDeflection(float theDeflection, bool theIsRelative)
   myDeflection = theDeflection; 
   myIsRelative = theIsRelative; 
  
-  MeshShape(myShape,myDeflection,myIsRelative); 
+  GEOM::MeshShape2(myShape,myDeflection,myIsRelative); 
  
   SetModified(); 
 } 
@@ -419,7 +389,12 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
   TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
   TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
   
-  SetShape(theShape,anEdgeMap,theIsVector);
+  GEOM::SetShape(theShape,anEdgeMap,theIsVector,
+                 myIsolatedEdgeSource.Get(),
+                 myOneFaceEdgeSource.Get(),
+                 mySharedEdgeSource.Get(),
+                 myWireframeFaceSource.Get(),
+                 myShadingFaceSource.Get());
   isOnlyVertex =  
     myIsolatedEdgeSource->IsEmpty() &&
     myOneFaceEdgeSource->IsEmpty() &&
@@ -434,65 +409,6 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
   }
 }
 
-void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
-                           const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
-                           bool theIsVector)
-{
-  if (theShape.ShapeType() == TopAbs_COMPOUND) {
-    TopoDS_Iterator anItr(theShape);
-    for (; anItr.More(); anItr.Next()) {
-      SetShape(anItr.Value(),theEdgeMap,theIsVector);
-    }
-  }
-
-  switch (theShape.ShapeType()) {
-    case TopAbs_WIRE: {
-      TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE);
-      for (; anEdgeExp.More(); anEdgeExp.Next()){
-        const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
-        if (!BRep_Tool::Degenerated(anEdge))
-          myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
-      }
-      break;
-    }
-    case TopAbs_EDGE: {
-      const TopoDS_Edge& anEdge = TopoDS::Edge(theShape);
-      if (!BRep_Tool::Degenerated(anEdge))
-        myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
-      break;
-    }
-    case TopAbs_VERTEX: {
-      break;
-    }
-    default: {
-      TopExp_Explorer aFaceExp (theShape,TopAbs_FACE);
-      for(; aFaceExp.More(); aFaceExp.Next()) {
-        const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
-        myWireframeFaceSource->AddFace(aFace);
-        myShadingFaceSource->AddFace(aFace);
-        TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
-       for(; anEdgeExp.More(); anEdgeExp.Next()) {
-         const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
-          if(!BRep_Tool::Degenerated(anEdge)){
-           // compute the number of faces
-           int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent();
-           switch(aNbOfFaces){
-           case 0:  // isolated edge
-             myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
-             break;
-           case 1:  // edge in only one face
-             myOneFaceEdgeSource->AddEdge(anEdge,theIsVector);
-             break;
-           default: // edge shared by at least two faces
-             mySharedEdgeSource->AddEdge(anEdge,theIsVector);
-           }
-          }
-        }
-      }
-    }
-  }
-}
-
 // OLD METHODS
 void GEOM_Actor::setDeflection(double adef) {
 #ifdef MYDEBUG
@@ -746,8 +662,8 @@ GEOM_Actor
 bool
 GEOM_Actor
 ::PreHighlight(vtkInteractorStyle *theInteractorStyle, 
-              SVTK_SelectionEvent* theSelectionEvent,
-              bool theIsHighlight)
+               SVTK_SelectionEvent* theSelectionEvent,
+               bool theIsHighlight)
 {
 #ifdef MYDEBUG
   MESSAGE ( this<<" GEOM_Actor::PreHighlight (3) theIsHighlight="<<theIsHighlight );
@@ -773,8 +689,8 @@ GEOM_Actor
       //      cout << " nbio = " << nbio << endl;
 
       if( !mySelector->IsSelected( myIO ) ) {
-       //      printf ("!!!!!!!!!!!!!!!!\n");
-       SetPreSelected( true );
+        //      printf ("!!!!!!!!!!!!!!!!\n");
+        SetPreSelected( true );
       }
     }
     default:
@@ -795,8 +711,8 @@ GEOM_Actor
 bool
 GEOM_Actor
 ::Highlight(vtkInteractorStyle *theInteractorStyle, 
-           SVTK_SelectionEvent* theSelectionEvent,
-           bool theIsHighlight)
+            SVTK_SelectionEvent* theSelectionEvent,
+            bool theIsHighlight)
 {
   // define the selection of object
 #ifdef MYDEBUG
@@ -858,13 +774,13 @@ void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
     else
       {
       distance = sqrt(
-       (pos[0] - this->Position[0])*(pos[0] - this->Position[0]) +
+        (pos[0] - this->Position[0])*(pos[0] - this->Position[0]) +
         (pos[1] - this->Position[1])*(pos[1] - this->Position[1]) +
         (pos[2] - this->Position[2])*(pos[2] - this->Position[2]));
       for (i = 0; i < 3; i++)
-       {
+        {
         Rz[i] = (pos[i] - this->Position[i])/distance;
-       }
+        }
       }
   
     vtkMath::Cross(vup,Rz,Rx);
@@ -897,3 +813,5 @@ void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
   matrix->Delete();
   this->Transform->Pop();  
 }  
+
+