Salome HOME
Update copyright information
[modules/geom.git] / src / OBJECT / GEOM_AssemblyBuilder.cxx
index b4d94c841d0f1a62d5522d6c98a1388099b3c2ff..69d7fa9f5ceee0a3c72b5155803f02b7d859e98f 100644 (file)
@@ -1,31 +1,30 @@
-//  GEOM OBJECT : interactive object for Geometry entities visualization
+//  Copyright (C) 2007-2008  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
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  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://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
+//  You should have received a copy of the GNU Lesser General Public
+//  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://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  GEOM OBJECT : interactive object for Geometry entities visualization
 //  File   : GEOM_AssemblyBuilder.cxx
 //  Author : Christophe ATTANASIO
 //  Module : GEOM
 //  $Header$
-
+//
 /*!
   \class GEOM_AssemblyBuilder GEOM_AssemblyBuilder.h
   \brief ....
 #include "GEOM_Actor.h"
 
 #include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
 
 #include <vtkProperty.h>
+#include <vtkAssembly.h>
+#include <vtkActorCollection.h>
 
 // Open CASCADE Includes
 #include <TopExp_Explorer.hxx>
@@ -50,6 +52,9 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopoDS_Iterator.hxx>
 
+// Qt includes
+#include <QColor>
+
 #include "utilities.h"
 
 using namespace std;
@@ -70,7 +75,7 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
                                          vtkProperty* VertexProp,
                                          vtkProperty* IsoPVProp,
                                          vtkProperty* EdgePVProp,
-                                         vtkProperty* VertexPVProp)
+                                         vtkProperty* VertexPVProp)
 {
   // Shading like default OCC material
   FaceProp->SetRepresentationToSurface();
@@ -174,6 +179,7 @@ void GEOM_AssemblyBuilder::MeshShape(const TopoDS_Shape myShape,
       // Compute default deflection
       Bnd_Box B;
       BRepBndLib::Add(myShape, B);
+      if ( B.IsVoid() ) return; // NPAL15983 (Bug when displaying empty groups) 
       Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
       B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
       deflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin) * 0.001 *4;
@@ -185,21 +191,43 @@ void GEOM_AssemblyBuilder::MeshShape(const TopoDS_Shape myShape,
 
 
 vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
-                                                         Standard_Real deflection,
-                                                         Standard_Integer mode,
-                                                         Standard_Boolean forced) {
+                                                      Standard_Real    deflection,
+                                                      Standard_Integer mode,
+                                                      Standard_Boolean forced,
+                                                      Standard_Boolean isVector)
+{
+  /*
+  vtkProperty* IsoProp = vtkProperty::New();
+  vtkProperty* FaceProp = vtkProperty::New();
+  vtkProperty* EdgeFProp = vtkProperty::New();
+  vtkProperty* EdgeSProp = vtkProperty::New();
+  vtkProperty* EdgeIProp = vtkProperty::New();
+  vtkProperty* VertexProp = vtkProperty::New();
+  vtkProperty* IsoPVProp = vtkProperty::New();
+  vtkProperty* EdgePVProp = vtkProperty::New();
+  vtkProperty* VertexPVProp = vtkProperty::New();
+  InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
+  */
 
   vtkActorCollection* AISActors = vtkActorCollection::New();
+  MeshShape(myShape,deflection,forced);
+  GEOM_Actor* aGeomActor = GEOM_Actor::New();
+  aGeomActor->SetShape(myShape,(float)deflection,false,isVector);
+  AISActors->AddItem(aGeomActor);
 
+  aGeomActor->Delete();
+  
+  /*
   if(myShape.ShapeType() == TopAbs_COMPOUND) {
     TopoDS_Iterator anItr(myShape);
     for(; anItr.More(); anItr.Next()) {
-      vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
+      vtkActorCollection* theActors =
+        GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
       theActors->InitTraversal();
       vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
       while(!(anActor==NULL)) {
-       AISActors->AddItem(anActor);
-       anActor = (vtkActor*)theActors->GetNextActor();
+        AISActors->AddItem(anActor);
+        anActor = (vtkActor*)theActors->GetNextActor();
       }
     }
   }
@@ -301,7 +329,7 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
     }
   } else if ( myShape.ShapeType() == TopAbs_EDGE ) { // EDGE Actor
     GEOM_Actor* EdgeActor = GEOM_Actor::New();
-    EdgeActor->setInputShape(myShape,deflection,mode);
+    EdgeActor->setInputShape(myShape,deflection,mode,isVector);
     EdgeActor->SetShadingProperty(EdgeIProp);
     EdgeActor->SetWireframeProperty(EdgeIProp);
     EdgeActor->SetPreviewProperty(EdgePVProp);
@@ -317,6 +345,8 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
     AISActors->AddItem(VertexActor);
   
   } 
+  */
+  
   
   return AISActors;
 
@@ -335,8 +365,7 @@ vtkAssembly*  GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
   // Create a new vtkAssembly
 
   vtkAssembly* myVTKShape = vtkAssembly::New();
-
-
+  /*
   // Create graphics properties
 
   vtkProperty* IsoProp = vtkProperty::New();
@@ -415,6 +444,8 @@ vtkAssembly*  GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
     }
     myVTKShape->AddPart(myFaceAssembly);
   }
+
+  */
   
   return myVTKShape;