From: rnv Date: Thu, 27 Nov 2014 12:40:27 +0000 (+0300) Subject: Geomerty & Mesh plug-ins in the ParaVis module: small corrections. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fema%2F2.6.3_2.6.4;p=modules%2Fsmesh.git Geomerty & Mesh plug-ins in the ParaVis module: small corrections. --- diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 14769b088..483f7fb87 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -952,7 +952,7 @@ namespace SMESH virtual SMESH::array_of_ElementType* GetTypes(); virtual SMESH::SMESH_Mesh_ptr GetMesh(); virtual bool IsMeshInfoCorrect() { return true; } - virtual SALOMEDS::TMPFile* GetVtkUgStream(){ return NULL; } + virtual SALOMEDS::TMPFile* GetVtkUgStream(){ SALOMEDS::TMPFile_var SeqFile; return SeqFile._retn(); } /*! * \brief Object notified on change of predicate */ diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 6c6df5e32..e8ccfff91 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -98,7 +98,7 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: /*! * Returns mesh unstructed grid information. */ - virtual SALOMEDS::TMPFile* GetVtkUgStream(){ return NULL; } + virtual SALOMEDS::TMPFile* GetVtkUgStream(){ SALOMEDS::TMPFile_var SeqFile; return SeqFile._retn(); } // Internal C++ interface int GetLocalID() const { return myLocalID; } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index d3ef48332..24ecccf56 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -779,7 +779,7 @@ struct SMESH_MeshEditor_i::_IDSource : public virtual POA_SMESH::SMESH_IDSource, } return types._retn(); } - SALOMEDS::TMPFile* GetVtkUgStream(){ return NULL; } + SALOMEDS::TMPFile* GetVtkUgStream(){ SALOMEDS::TMPFile_var SeqFile; return SeqFile._retn(); } }; SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index e8febe231..b9fc6e025 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -5058,34 +5058,28 @@ void SMESH_Mesh_i::CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, SALOMEDS::TMPFile* SMESH_Mesh_i::GetVtkUgStream() { - if ( SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS() ) - { - vtkUnstructuredGrid* aCopy; - SMDS_UnstructuredGrid* aGrid = aMeshDS->getGrid(); - if(aGrid) - { - aCopy = aGrid->NewInstance(); - aCopy->ShallowCopy(aGrid); - vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); - aWriter->WriteToOutputStringOn(); - aWriter->SetInputData(aCopy); - aWriter->SetFileTypeToBinary(); - aWriter->Write(); - char* str = aWriter->GetOutputString(); - int size = aWriter->GetOutputStringLength(); - - //Allocate octect buffer of required size - CORBA::Octet* OctetBuf = SALOMEDS::TMPFile::allocbuf(size); - //Copy ostrstream content to the octect buffer - memcpy(OctetBuf, str, size); - //Create and return TMPFile - SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size, size, OctetBuf, 1); - - aWriter->Delete(); - return SeqFile._retn(); - } - } - return NULL; + SALOMEDS::TMPFile_var SeqFile; + if ( SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS() ) { + SMDS_UnstructuredGrid* aGrid = aMeshDS->getGrid(); + if(aGrid) { + vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); + aWriter->WriteToOutputStringOn(); + aWriter->SetInputData(aGrid); + aWriter->SetFileTypeToBinary(); + aWriter->Write(); + char* str = aWriter->GetOutputString(); + int size = aWriter->GetOutputStringLength(); + + //Allocate octect buffer of required size + CORBA::Octet* OctetBuf = SALOMEDS::TMPFile::allocbuf(size); + //Copy ostrstream content to the octect buffer + memcpy(OctetBuf, str, size); + //Create and return TMPFile + SeqFile = new SALOMEDS::TMPFile(size, size, OctetBuf, 1); + aWriter->Delete(); + } + } + return SeqFile._retn(); } //============================================================================= diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index bd8a9846e..1fcb7035d 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -113,7 +113,7 @@ public: /*! * Returns mesh unstructed grid information. */ - virtual SALOMEDS::TMPFile* GetVtkUgStream(){ return NULL; } + virtual SALOMEDS::TMPFile* GetVtkUgStream(){ SALOMEDS::TMPFile_var SeqFile; return SeqFile._retn(); } protected: