]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Geomerty & Mesh plug-ins in the ParaVis module: small corrections. ema/2.6.3_2.6.4
authorrnv <rnv@opencascade.com>
Thu, 27 Nov 2014 12:39:37 +0000 (15:39 +0300)
committerrnv <rnv@opencascade.com>
Thu, 27 Nov 2014 12:39:37 +0000 (15:39 +0300)
src/OCC2VTK/OCC2VTK_Tools.cxx
src/VTKPlugin/VTKPlugin_ExportDriver.cxx

index b9b16b135763ee1c397c8808e54a434f9c83c363..6326c2904a39a155bb28b15b61bcf6ed1fc3477b 100755 (executable)
@@ -166,77 +166,67 @@ namespace GEOM
     }
   }
 
-  vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection)
-  {
-         BRepBuilderAPI_Copy aCopy(theShape);
-         if(!aCopy.IsDone())
-         {
-                 return 0;
-         }
-         TopoDS_Shape aShape = aCopy.Shape();
-
-       try
-       {
-               GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
-               GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
-               GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
-               GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New();
-               GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New();
-               GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New();
-
-               vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New();
-               myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() );
-               myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
-               myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
-               myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );
-
-               myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
-
-               bool anIsVector = false;
-
-               // Is shape triangulated?
-               bool wasMeshed = true;
-               TopExp_Explorer ex;
-               TopLoc_Location aLoc;
-               for (ex.Init(aShape, TopAbs_FACE); ex.More(); ex.Next())
-               {
-                       const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
-                   Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
-                   if(aPoly.IsNull())
-                   {
-                       wasMeshed = false;
-                       break;
-                   }
-               }
-               GEOM::MeshShape( aShape, theDeflection );
-               TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
-               for( ; aVertexExp.More(); aVertexExp.Next() )
-               {
-                       const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
-                   myVertexSource->AddVertex( aVertex );
-               }
-
-               TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
-               TopExp::MapShapesAndAncestors( aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
-
-               GEOM::SetShape( aShape,
-                               anEdgeMap,
-                       anIsVector,
-                               0,
-                               myIsolatedEdgeSource,
-                               myOneFaceEdgeSource,
-                               mySharedEdgeSource,
-                               myWireframeFaceSource,
-                               myShadingFaceSource );
-
-               myAppendFilter->Update();
-
-               return myAppendFilter->GetOutput();
-       }
-        catch(Standard_Failure)
-       {
-          return 0;
-       }
-   }
+  vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection) {
+    BRepBuilderAPI_Copy aCopy(theShape);
+    if(!aCopy.IsDone()) {
+      return 0;
+    }
 
+    TopoDS_Shape aShape = aCopy.Shape();
+    
+    try {
+      GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
+      GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
+      GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
+      GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New();
+      GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New();
+      GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New();
+      
+      vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New();
+      myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() );
+      myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
+      myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
+      myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );      
+      myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
+      
+      bool anIsVector = false;
+      
+      GEOM::MeshShape( aShape, theDeflection );
+      TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
+      for( ; aVertexExp.More(); aVertexExp.Next() ) {
+       const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
+       myVertexSource->AddVertex( aVertex );
+      }
+      
+      TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
+      TopExp::MapShapesAndAncestors( aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
+      
+      GEOM::SetShape( aShape,
+                     anEdgeMap,
+                     anIsVector,
+                     0,
+                     myIsolatedEdgeSource,
+                     myOneFaceEdgeSource,
+                     mySharedEdgeSource,
+                     myWireframeFaceSource,
+                     myShadingFaceSource );
+      
+      myAppendFilter->Update();
+
+      myVertexSource->Delete();
+      myIsolatedEdgeSource->Delete();
+      myOneFaceEdgeSource->Delete();
+      mySharedEdgeSource->Delete();
+      myWireframeFaceSource->Delete();
+      myShadingFaceSource->Delete();
+
+      vtkPolyData* ret = vtkPolyData::New();
+      ret->ShallowCopy(myAppendFilter->GetOutput());
+      myAppendFilter->Delete();
+      return ret;
+    }
+    catch(Standard_Failure) {
+      return 0;
+    }
+  }  
 }
index a77897278cd28b6bd729e184fd0f5ac473b8d308..1242f4468c471dd9c5bbba97eb0eb47121c35d10 100644 (file)
@@ -91,80 +91,16 @@ Standard_Integer VTKPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const
   MESSAGE( "Export VTK into file " << aFileName );
   try
   {
-    GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
-    GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
-    GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
-    GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New();
-    GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New();
-    GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New();
-
-    vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New();
-    myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() );
-    myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
-    myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
-    myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );
-    //myAppendFilter->AddInputConnection( myWireframeFaceSource->GetOutputPort() ); // iso-lines are unnecessary
-    myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
-
-    bool anIsVector = false;
-
-    // Is shape triangulated?
-    bool wasMeshed = true;
-    TopExp_Explorer ex;
-    TopLoc_Location aLoc;
-    for (ex.Init(aShape, TopAbs_FACE); ex.More(); ex.Next()) {
-      const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
-      Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
-      if(aPoly.IsNull()) {
-        wasMeshed = false;
-        break;
-      }
-    }
-
-    GEOM::MeshShape( aShape, aDeflection );
-
-    TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
-    for( ; aVertexExp.More(); aVertexExp.Next() )
-    {
-      const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
-      myVertexSource->AddVertex( aVertex );
-    }
-
-    TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
-    TopExp::MapShapesAndAncestors( aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
-
-    GEOM::SetShape( aShape,
-                   anEdgeMap,
-                   anIsVector,
-                   0,
-                   myIsolatedEdgeSource,
-                   myOneFaceEdgeSource,
-                   mySharedEdgeSource,
-                   myWireframeFaceSource,
-                   myShadingFaceSource );
-
-    myAppendFilter->Update();
-
     // Set "C" numeric locale to save numbers correctly
     Kernel_Utils::Localizer loc;
 
-    vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
-    aWriter->SetInputConnection( myAppendFilter->GetOutputPort() );
+    vtkPolyData* pd = GEOM::GetData( aShape, aDeflection );
+    vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();    
+    aWriter->SetInputData( pd );
     aWriter->SetFileName( aFileName.ToCString() );
     aWriter->Write();
     aWriter->Delete();
-
-    myVertexSource->Delete();
-    myIsolatedEdgeSource->Delete();
-    myOneFaceEdgeSource->Delete();
-    mySharedEdgeSource->Delete();
-    myWireframeFaceSource->Delete();
-    myShadingFaceSource->Delete();
-
-    myAppendFilter->Delete();
-
-    if(!wasMeshed)
-      BRepTools::Clean(aShape);
+    pd->Delete(); //instanciated by the GEOM::GetData(...) method
 
     return 1;
   }