From: ema Date: Tue, 25 Nov 2014 12:56:20 +0000 (+0300) Subject: ParaView / PARAVIS improvements 2014: 2.6.3/2.6.4: Geometry & Mesh plug-ins in the... X-Git-Tag: V7_6_0a1~35 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=cb136b9fea915007494b27a181a4552bf4f8b307 ParaView / PARAVIS improvements 2014: 2.6.3/2.6.4: Geometry & Mesh plug-ins in the ParaVis module --- diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 593272ab0..e143062f6 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -313,6 +313,11 @@ module SMESH * happen if mesh data is not yet fully loaded from the file of study. */ boolean IsMeshInfoCorrect(); + + /*! + * Returns mesh unstructed grid information. + */ + SALOMEDS::TMPFile GetVtkUgStream(); }; interface SMESH_Group; diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 3d7977cb6..df4b3de60 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -2517,6 +2517,17 @@ SMESH::SMESH_Mesh_ptr Filter_i::GetMesh() return SMESH_Mesh::_duplicate( myMesh ); } +//======================================================================= +//function : GetVtkUgStream +//purpose : Return data vtk unstructured grid (not implemented) +//======================================================================= + +SALOMEDS::TMPFile* Filter_i::GetVtkUgStream() +{ + SALOMEDS::TMPFile_var SeqFile; + return SeqFile._retn(); +} + //================================================================================ /*! * \brief Stores an object to be notified on change of predicate diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 92c4618df..19ca05f6e 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(); /*! * \brief Object notified on change of predicate */ diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index d55846ade..36ff20a15 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -749,6 +749,17 @@ bool SMESH_GroupBase_i::IsMeshInfoCorrect() return myPreMeshInfo ? myPreMeshInfo->IsMeshInfoCorrect() : true; } +//======================================================================= +//function : GetVtkUgStream +//purpose : Return data vtk unstructured grid (not implemented) +//======================================================================= + +SALOMEDS::TMPFile* SMESH_GroupBase_i::GetVtkUgStream() +{ + SALOMEDS::TMPFile_var SeqFile; + return SeqFile._retn(); +} + //================================================================================ /*! * \brief Retrieves the predicate from the filter diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index f08e51b24..5278ed889 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -95,6 +95,10 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: * happen if mesh data is not yet fully loaded from the file of study. */ virtual bool IsMeshInfoCorrect(); + /*! + * Returns mesh unstructed grid information. + */ + virtual SALOMEDS::TMPFile* GetVtkUgStream(); // 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 7ed7cd842..39a9d25d6 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -781,6 +781,11 @@ struct SMESH_MeshEditor_i::_IDSource : public virtual POA_SMESH::SMESH_IDSource, } return types._retn(); } + 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 a5ed1ac3c..b9fc6e025 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -79,6 +79,8 @@ #include #include +#include + // to pass CORBA exception through SMESH_TRY #define SMY_OWN_CATCH catch( SALOME::SALOME_Exception& se ) { throw se; } @@ -5048,6 +5050,37 @@ void SMESH_Mesh_i::CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, while (theItr->more()) theInfo[ theItr->next()->GetEntityType() ]++; } +//============================================================================= +/* + * Returns mesh unstructed grid information. + */ +//============================================================================= + +SALOMEDS::TMPFile* SMESH_Mesh_i::GetVtkUgStream() +{ + 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(); +} //============================================================================= namespace /* Iterators used in SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_var obj, diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index e4c1b634a..9c36bb40e 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -650,6 +650,10 @@ public: * happen if mesh data is not yet fully loaded from the file of study. */ bool IsMeshInfoCorrect(); + /*! + * Returns mesh unstructed grid information. + */ + virtual SALOMEDS::TMPFile* GetVtkUgStream(); std::map _mapSubMesh_i; //NRI std::map _mapSubMesh; //NRI diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index ac64d86ad..5d81fec24 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -607,3 +607,14 @@ bool SMESH_subMesh_i::IsMeshInfoCorrect() { return _preMeshInfo ? _preMeshInfo->IsMeshInfoCorrect() : true; } + +//======================================================================= +//function : GetVtkUgStream +//purpose : Return data vtk unstructured grid (not implemented) +//======================================================================= + +SALOMEDS::TMPFile* SMESH_subMesh_i::GetVtkUgStream() +{ + SALOMEDS::TMPFile_var SeqFile; + return SeqFile._retn(); +} diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index 69fdcd72e..b02d09c2b 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -110,7 +110,10 @@ public: * happen if mesh data is not yet fully loaded from the file of study. */ virtual bool IsMeshInfoCorrect(); - + /*! + * Returns mesh unstructed grid information. + */ + virtual SALOMEDS::TMPFile* GetVtkUgStream(); protected: