X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKPlugin%2FVTKPlugin_ExportDriver.cxx;h=d3bc3a361f37cbb96d754d907e50dbe9ff9ec1ca;hb=89e60b0cd04dc7c92a7ffd545a3d83c23ac222f4;hp=a77897278cd28b6bd729e184fd0f5ac473b8d308;hpb=852ccfccc50fb56a385fdc8227c985c1417bf053;p=modules%2Fgeom.git diff --git a/src/VTKPlugin/VTKPlugin_ExportDriver.cxx b/src/VTKPlugin/VTKPlugin_ExportDriver.cxx index a77897278..d3bc3a361 100644 --- a/src/VTKPlugin/VTKPlugin_ExportDriver.cxx +++ b/src/VTKPlugin/VTKPlugin_ExportDriver.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -69,7 +69,7 @@ VTKPlugin_ExportDriver::VTKPlugin_ExportDriver() //function : Execute //purpose : //======================================================================= -Standard_Integer VTKPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +Standard_Integer VTKPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); @@ -91,99 +91,26 @@ 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::GetVTKData( 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(); //instantiated by the GEOM::GetData(...) method return 1; } catch( Standard_Failure ) { - //THROW_SALOME_CORBA_EXCEPTION("Exception catched in ExportVTK", SALOME::BAD_PARAM); + //THROW_SALOME_CORBA_EXCEPTION("Exception caught in ExportVTK", SALOME::BAD_PARAM); } return 0; } -//======================================================================= -//function : MustExecute -//purpose : -//======================================================================= -Standard_Boolean VTKPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const -{ - return Standard_True; -} - //================================================================================ /*! * \brief Returns a name of creation operation and names and values of creation parameters @@ -196,5 +123,4 @@ GetCreationInformation( std::string& theOperationName, return false; } -IMPLEMENT_STANDARD_HANDLE( VTKPlugin_ExportDriver,GEOM_BaseDriver ); IMPLEMENT_STANDARD_RTTIEXT( VTKPlugin_ExportDriver,GEOM_BaseDriver );