From aca3b21855b86298b62c50cb6d5ee578c6171da2 Mon Sep 17 00:00:00 2001 From: ema Date: Tue, 25 Nov 2014 15:46:02 +0300 Subject: [PATCH] ParaView / PARAVIS improvements 2014: 2.6.3/2.6.4: Geometry & Mesh plug-ins in the ParaVis module --- CMakeLists.txt | 53 ++++++- SalomePARAVISConfig.cmake.in | 25 ++++ src/Plugins/CMakeLists.txt | 7 + src/Plugins/ParaGEOMCorba/CMakeLists.txt | 50 +++++++ .../ParaGEOMCorbaServerManager.xml | 39 +++++ .../ParaGEOMCorbaUserInterfaceSources.xml | 3 + .../ParaGEOMCorba/vtkParaGEOMCorbaSource.cxx | 141 ++++++++++++++++++ .../ParaGEOMCorba/vtkParaGEOMCorbaSource.h | 54 +++++++ src/Plugins/ParaSMESHCorba/CMakeLists.txt | 52 +++++++ .../ParaSMESHCorbaServerManager.xml | 29 ++++ .../ParaSMESHCorbaUserInterfaceSources.xml | 3 + .../vtkParaSMESHCorbaSource.cxx | 133 +++++++++++++++++ .../ParaSMESHCorba/vtkParaSMESHCorbaSource.h | 50 +++++++ 13 files changed, 638 insertions(+), 1 deletion(-) create mode 100644 src/Plugins/ParaGEOMCorba/CMakeLists.txt create mode 100644 src/Plugins/ParaGEOMCorba/ParaGEOMCorbaServerManager.xml create mode 100644 src/Plugins/ParaGEOMCorba/ParaGEOMCorbaUserInterfaceSources.xml create mode 100644 src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.cxx create mode 100644 src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.h create mode 100644 src/Plugins/ParaSMESHCorba/CMakeLists.txt create mode 100644 src/Plugins/ParaSMESHCorba/ParaSMESHCorbaServerManager.xml create mode 100644 src/Plugins/ParaSMESHCorba/ParaSMESHCorbaUserInterfaceSources.xml create mode 100644 src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.cxx create mode 100644 src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 97ebc97e..b53b5cbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,8 @@ OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON) OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) OPTION(SALOME_PARAVIS_ALL_TEST "Add all tests for Salome PARAVIS module" OFF) OPTION(SALOME_PARAVIS_BUILD_PLUGINS "Build PARAVIS plugins (MEDReader, etc ...)" ON) +OPTION(SALOME_PARAVIS_USE_GEOM_SOURCE "Import a GEOMETRY object to PARAVIS via its Corba IOR" ON ) +OPTION(SALOME_PARAVIS_USE_SMESH_SOURCE "Import a MESH object to PARAVIS via its Corba IOR" ON) CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF "NOT SALOME_KERNEL_LIGHT_ONLY" ON) CMAKE_DEPENDENT_OPTION(SALOME_PARAVIS_MINIMAL_CORBA "Build PARAVIS with a minimal CORBA interface" ON @@ -163,6 +165,53 @@ IF(SALOME_PARAVIS_BUILD_PLUGINS) SALOME_LOG_OPTIONAL_PACKAGE(MEDFile SALOME_PARAVIS_BUILD_PLUGINS) ENDIF() +## +## From GEOM +## + +IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE) + SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM") + IF(EXISTS ${GEOM_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS GEOMClient SalomeIDLGEOM OCC2VTK) + ELSE() + MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM to import GEOM objects to PARAVIS, please define GEOM_ROOT_DIR + or set SALOME_PARAVIS_USE_GEOM_SOURCE=OFF") + ENDIF() +ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE) + MESSAGE(FATAL_ERROR "We absolutely need to build PARAVIS plugins to use the import of GEOM objects to PARAVIS, + please set SALOME_PARAVIS_BUILD_PLUGINS=ON + or SALOME_PARAVIS_USE_GEOM_SOURCE=OFF") +ENDIF() + +## +## From SMESH +## +IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE) + IF(NOT SALOME_PARAVIS_USE_GEOM_SOURCE) + SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM") + IF(EXISTS ${GEOM_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS SalomeIDLGEOM ) + ELSE() + MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM to import MESH objects to PARAVIS, please define GEOM_ROOT_DIR + or set SALOME_PARAVIS_USE_SMESH_SOURCE=OFF") + ENDIF() + ENDIF() + SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH") + IF(EXISTS ${SMESH_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeSMESH REQUIRED) + ELSE() + MESSAGE(FATAL_ERROR "We absolutely need a Salome MESH to import MESH objects to PARAVIS, please define SMESH_ROOT_DIR + or set SALOME_PARAVIS_USE_SMESH_SOURCE=OFF") + ENDIF() +ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE) + MESSAGE(FATAL_ERROR "We absolutely need to build PARAVIS plugins to use the import of MESH objects to PARAVIS, + please set SALOME_PARAVIS_BUILD_PLUGINS=ON + or SALOME_PARAVIS_USE_SMESH_SOURCE=OFF") +ENDIF() + ## Detection summary: SALOME_PACKAGE_REPORT_AND_CHECK() @@ -267,6 +316,8 @@ SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}") SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}") SET(MED_ROOT_DIR "${MED_ROOT_DIR}") SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}") +SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}") +SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}") SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") @@ -277,7 +328,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR) + KERNEL_ROOT_DIR GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR GEOM_ROOT_DIR SMESH_ROOT_DIR) # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?): # Get the relative path of the include directory so diff --git a/SalomePARAVISConfig.cmake.in b/SalomePARAVISConfig.cmake.in index 07fe64e2..2cde34a2 100644 --- a/SalomePARAVISConfig.cmake.in +++ b/SalomePARAVISConfig.cmake.in @@ -51,6 +51,8 @@ SET(PARAVIS_DEFINITIONS "@GUI_DEFINITIONS@") SET(SALOME_PARAVIS_BUILD_DOC @SALOME_BUILD_DOC@) SET(SALOME_PARAVIS_BUILD_TESTS @SALOME_BUILD_TESTS@) SET(SALOME_PARAVIS_LIGHT_ONLY @SALOME_LIGHT_ONLY@) +SET(SALOME_PARAVIS_USE_GEOM_SOURCE @SALOME_PARAVIS_USE_GEOM_SOURCE@) +SET(SALOME_PARAVIS_USE_SMESH_SOURCE @SALOME_PARAVIS_USE_SMESH_SOURCE@) # Advanced options SET(SALOME_USE_OCCVIEWER @SALOME_USE_OCCVIEWER@) @@ -65,6 +67,17 @@ IF(SALOME_PARAVIS_BUILD_PLUGINS) SET_AND_CHECK(MED_ROOT_DIR_EXP "@PACKAGE_MED_ROOT_DIR@") LIST(APPEND PARAVIS_DEFINITIONS "@MED_DEFINITIONS@") ENDIF() + +IF(SALOME_PARAVIS_USE_GEOM_SOURCE) + SET_AND_CHECK(GEOM_ROOT_DIR_EXP "@PACKAGE_GEOM_ROOT_DIR@") + LIST(APPEND PARAVIS_DEFINITIONS "@GEOM_DEFINITIONS@") +ENDIF() + +IF(SALOME_PARAVIS_USE_SMESH_SOURCE) + SET_AND_CHECK(SMESH_ROOT_DIR_EXP "@PACKAGE_SMESH_ROOT_DIR@") + LIST(APPEND PARAVIS_DEFINITIONS "@SMESH_DEFINITIONS@") +ENDIF() + SET_AND_CHECK(MEDFILE_ROOT_DIR_EXP "@PACKAGE_MEDFILE_ROOT_DIR@") # Optional level 1 prerequisites: @@ -127,6 +140,18 @@ IF(SALOME_PARAVIS_BUILD_PLUGINS) INCLUDE("${MED_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE_LOCAL}/SalomeMEDTargets.cmake") ENDIF() ENDIF() +IF(SALOME_PARAVIS_USE_GEOM_SOURCE) + # Include GEOM targets if they were not already loaded: + IF(NOT TARGET SalomeIDLGEOM) + INCLUDE("${GEOM_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE_LOCAL}/SalomeGEOMTargets.cmake") + ENDIF() +ENDIF() +IF(SALOME_PARAVIS_USE_SMESH_SOURCE) + # Include GEOM targets if they were not already loaded: + IF(NOT TARGET SalomeIDLSMESH) + INCLUDE("${SMESH_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE_LOCAL}/SalomeSMESHTargets.cmake") + ENDIF() +ENDIF() # Exposed PARAVIS targets: SET(PARAVIS_SalomeIDLPARAVIS SalomeIDLPARAVIS) diff --git a/src/Plugins/CMakeLists.txt b/src/Plugins/CMakeLists.txt index 357a7448..b4a29fb7 100755 --- a/src/Plugins/CMakeLists.txt +++ b/src/Plugins/CMakeLists.txt @@ -40,6 +40,13 @@ IF(NOT SALOME_LIGHT_ONLY) ParaMEDCorba ) ENDIF() +IF(SALOME_PARAVIS_USE_GEOM_SOURCE) + LIST(APPEND _subdirs ParaGEOMCorba) +ENDIF() + +IF(SALOME_PARAVIS_USE_SMESH_SOURCE) + LIST(APPEND _subdirs ParaSMESHCorba) +ENDIF() FOREACH(_dir ${_subdirs}) ADD_SUBDIRECTORY(${_dir}) diff --git a/src/Plugins/ParaGEOMCorba/CMakeLists.txt b/src/Plugins/ParaGEOMCorba/CMakeLists.txt new file mode 100644 index 00000000..ff98cc8d --- /dev/null +++ b/src/Plugins/ParaGEOMCorba/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + +PROJECT( ParaGEOMCorba ) + + CMAKE_MINIMUM_REQUIRED( VERSION 2.8.7 ) + FIND_PACKAGE(ParaView REQUIRED) + INCLUDE( ${PARAVIEW_USE_FILE} ) + SET( PARA_GEOM_CORBA_SRCS + ${ParaGEOMCorba_SOURCE_DIR}/vtkParaGEOMCorbaSource.cxx + ) + ADD_PARAVIEW_PLUGIN( ParaGEOMCorbaPlugin "1.0" + SERVER_MANAGER_XML ParaGEOMCorbaServerManager.xml + GUI_RESOURCE_FILES + ParaGEOMCorbaUserInterfaceSources.xml + SERVER_MANAGER_SOURCES ${PARA_GEOM_CORBA_SRCS} ) + + INCLUDE_DIRECTORIES( + ${OMNIORB_INCLUDE_DIR} + ${GEOM_ROOT_DIR}/include/salome + ${KERNEL_ROOT_DIR}/include/salome ) + + ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) + TARGET_LINK_LIBRARIES(ParaGEOMCorbaPlugin + ${OMNIORB_LIBRARIES} + ${KERNEL_SalomeIDLKernel} + ${GUI_SalomeApp} + ${GEOM_GEOMClient} + ${GEOM_SalomeIDLGEOM} + ${GEOM_OCC2VTK} + ) + + INSTALL(TARGETS ParaGEOMCorbaPlugin DESTINATION lib/paraview) + INSTALL(FILES ParaGEOMCorbaServerManager.xml DESTINATION share) diff --git a/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaServerManager.xml b/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaServerManager.xml new file mode 100644 index 00000000..3f3085b7 --- /dev/null +++ b/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaServerManager.xml @@ -0,0 +1,39 @@ + + + + + + + Source of a remote Geometry Corba reference. + + + + This property specifies the IOR of a Geometry object in memory. + + + + + This property specifies the Deflection coefficient. + + + + + + + + + diff --git a/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaUserInterfaceSources.xml b/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaUserInterfaceSources.xml new file mode 100644 index 00000000..d465f286 --- /dev/null +++ b/src/Plugins/ParaGEOMCorba/ParaGEOMCorbaUserInterfaceSources.xml @@ -0,0 +1,3 @@ + + + diff --git a/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.cxx b/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.cxx new file mode 100644 index 00000000..7a442b7a --- /dev/null +++ b/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.cxx @@ -0,0 +1,141 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +// + +#include "vtkParaGEOMCorbaSource.h" + +#include "vtkMultiBlockDataSet.h" +#include "vtkUnstructuredGrid.h" +// +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkInformationVector.h" +#include "vtkObjectFactory.h" +#include "vtkInformation.h" + +#include +#include +#include "vtkPolyData.h" +#include +#include "GEOM_Gen.hh" +#include "GEOM_Client.hxx" +#include "OCC2VTK_Tools.h" + + +//---------------------------------------------- +vtkStandardNewMacro(vtkParaGEOMCorbaSource); + +void *vtkParaGEOMCorbaSource::Orb=0; + +//---------------------------------------------- +vtkParaGEOMCorbaSource::vtkParaGEOMCorbaSource():Deflection(0.0) +{ + if(!Orb) { + CORBA::ORB_var *OrbC=new CORBA::ORB_var; + int argc=0; + *OrbC=CORBA::ORB_init(argc,0); + this->Orb=OrbC; + } + this->SetNumberOfInputPorts(0); + this->SetNumberOfOutputPorts(1); +} + +//---------------------------------------------- +vtkParaGEOMCorbaSource::~vtkParaGEOMCorbaSource() { +} + +//---------------------------------------------- +const char* vtkParaGEOMCorbaSource::GetIORCorba() +{ + return &IOR[0]; +} + +//---------------------------------------------- +void vtkParaGEOMCorbaSource::SetIORCorba(char *ior) { + if(!ior) + return; + if(ior[0]=='\0') + return; + int length=strlen(ior); + IOR.resize(length+1); + vtksys_stl::copy(ior,ior+length+1,&IOR[0]); + this->Modified(); +} + +//---------------------------------------------- +int vtkParaGEOMCorbaSource::ProcessRequest(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { + // generate the data + if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) { + return this->RequestData(request, inputVector, outputVector); + } + return this->Superclass::ProcessRequest(request, inputVector, outputVector); +} + +//---------------------------------------------- +int vtkParaGEOMCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) { + info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); + return 1; +} + +//---------------------------------------------- +int vtkParaGEOMCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) { + vtkInformation *outInfo=outputVector->GetInformationObject(0); + vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + double reqTS = 0; + if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) + reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); + try { + //Client request on ORB. + CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb; + CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]); + GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow(obj); + + if(!CORBA::is_nil(geomObj)) { + SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService()); + Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","GEOM"); + GEOM::GEOM_Gen_var geomGen = GEOM::GEOM_Gen::_narrow(aComponent); + if ( !CORBA::is_nil( geomGen ) ) { + TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( geomGen, geomObj ); + + if ( !aTopoDSShape.IsNull() ) { + vtkPolyData *ret=GEOM::GetData(aTopoDSShape, this->Deflection); + if(!ret) { + vtkErrorMacro("On geom object CORBA fetching an error occurs !"); + return 0; + } + ret0->SetBlock(0,ret); + ret->Delete(); + return 1; + } + } + } + vtkErrorMacro("Unrecognized CORBA reference!"); + } + catch(CORBA::Exception& ex) { + vtkErrorMacro("On fetching object error occurs"); + } + return 0; +} + +//---------------------------------------------- +void vtkParaGEOMCorbaSource::PrintSelf(ostream& os, vtkIndent indent) { + this->Superclass::PrintSelf( os, indent ); + os << "Deflection: " << this->Deflection << "\n"; +} + diff --git a/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.h b/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.h new file mode 100644 index 00000000..2c5f4dc1 --- /dev/null +++ b/src/Plugins/ParaGEOMCorba/vtkParaGEOMCorbaSource.h @@ -0,0 +1,54 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +// + + +#ifndef __vtkParaGEOMCorbaSource_h +#define __vtkParaGEOMCorbaSource_h + +#include "vtkUnstructuredGridAlgorithm.h" +#include + +class vtkParaGEOMCorbaSource : public vtkAlgorithm { + public: + static vtkParaGEOMCorbaSource* New(); + vtkTypeMacro(vtkParaGEOMCorbaSource, vtkAlgorithm); + virtual void PrintSelf( ostream& os, vtkIndent indent ); + const char *GetIORCorba(); + void SetIORCorba(char *ior); + + vtkSetMacro(Deflection,double); + + protected: + vtkParaGEOMCorbaSource(); + virtual ~vtkParaGEOMCorbaSource(); + int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info); + int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); + virtual int RequestData( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo ); + + vtksys_stl::vector IOR; + static void *Orb; + double Deflection; + + private: + vtkParaGEOMCorbaSource( const vtkParaGEOMCorbaSource& ); // Not implemented. + void operator = ( const vtkParaGEOMCorbaSource& ); // Not implemented. +}; + +#endif // __vtkParaGEOMCorbaSource_h + diff --git a/src/Plugins/ParaSMESHCorba/CMakeLists.txt b/src/Plugins/ParaSMESHCorba/CMakeLists.txt new file mode 100644 index 00000000..1552593e --- /dev/null +++ b/src/Plugins/ParaSMESHCorba/CMakeLists.txt @@ -0,0 +1,52 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 +# + + PROJECT(ParaSMESHCorba) + CMAKE_MINIMUM_REQUIRED( VERSION 2.8.7 ) + + FIND_PACKAGE(ParaView REQUIRED) + INCLUDE(${PARAVIEW_USE_FILE}) + + SET(PARA_SMESH_CORBA_SRC + ${ParaSMESHCorba_SOURCE_DIR}/vtkParaSMESHCorbaSource.cxx + ) + + ADD_PARAVIEW_PLUGIN( ParaSMESHCorbaPlugin "1.0" + SERVER_MANAGER_XML ParaSMESHCorbaServerManager.xml + GUI_RESOURCE_FILES + ParaSMESHCorbaUserInterfaceSources.xml + SERVER_MANAGER_SOURCES ${PARA_SMESH_CORBA_SRC} ) + + INCLUDE_DIRECTORIES( + ${OMNIORB_INCLUDE_DIR} + ${SMESH_ROOT_DIR}/include/salome + ${GEOM_ROOT_DIR}/include/salome + ${KERNEL_ROOT_DIR}/include/salome ) + + ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) + TARGET_LINK_LIBRARIES(ParaSMESHCorbaPlugin + ${OMNIORB_LIBRARIES} + ${KERNEL_SalomeIDLKernel} + ${SMESH_SalomeIDLSMESH} + ${SMESH_SMESHClient} + ${GEOM_SalomeIDLGEOM} + ) + + INSTALL(TARGETS ParaSMESHCorbaPlugin DESTINATION lib/paraview) + INSTALL(FILES ParaSMESHCorbaServerManager.xml DESTINATION share) diff --git a/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaServerManager.xml b/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaServerManager.xml new file mode 100644 index 00000000..f547c556 --- /dev/null +++ b/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaServerManager.xml @@ -0,0 +1,29 @@ + + + + + + + Source of a remote Mesh Corba reference. + + + + This property specifies the IOR of a Mesh object in memory. + + + + + + + + + diff --git a/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaUserInterfaceSources.xml b/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaUserInterfaceSources.xml new file mode 100644 index 00000000..c28f1a06 --- /dev/null +++ b/src/Plugins/ParaSMESHCorba/ParaSMESHCorbaUserInterfaceSources.xml @@ -0,0 +1,3 @@ + + + diff --git a/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.cxx b/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.cxx new file mode 100644 index 00000000..f0cd3c5f --- /dev/null +++ b/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.cxx @@ -0,0 +1,133 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +// + +#include "vtkParaSMESHCorbaSource.h" + +#include +#include + +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkInformationVector.h" +#include "vtkInformation.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkObjectFactory.h" +#include "vtkUnstructuredGridReader.h" + +#include "SMDS_UnstructuredGrid.hxx" +#include "SMESH_Mesh.hh" + +vtkStandardNewMacro(vtkParaSMESHCorbaSource); + +void *vtkParaSMESHCorbaSource::Orb=0; + +//---------------------------------------------- +vtkParaSMESHCorbaSource::vtkParaSMESHCorbaSource() { + if(!Orb) { + CORBA::ORB_var *OrbC=new CORBA::ORB_var; + int argc=0; + *OrbC=CORBA::ORB_init(argc,0); + this->Orb=OrbC; + } + this->SetNumberOfInputPorts(0); + this->SetNumberOfOutputPorts(1); +} + +//---------------------------------------------- +vtkParaSMESHCorbaSource::~vtkParaSMESHCorbaSource() { + +} + +//---------------------------------------------- +const char* vtkParaSMESHCorbaSource::GetIORCorba() +{ + return &IOR[0]; +} + +//---------------------------------------------- +void vtkParaSMESHCorbaSource::SetIORCorba(char *ior) { + if(!ior) + return; + if(ior[0]=='\0') + return; + int length=strlen(ior); + IOR.resize(length+1); + vtksys_stl::copy(ior,ior+length+1,&IOR[0]); + this->Modified(); +} + +//---------------------------------------------- +int vtkParaSMESHCorbaSource::ProcessRequest(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { + // generate the data + if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) { + return this->RequestData(request, inputVector, outputVector); + } + return this->Superclass::ProcessRequest(request, inputVector, outputVector); +} + +//---------------------------------------------- +int vtkParaSMESHCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) { + info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); + return 1; +} + +//---------------------------------------------- +int vtkParaSMESHCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) { + vtkInformation *outInfo=outputVector->GetInformationObject(0); + vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + double reqTS = 0; + if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) + reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); + + try { + CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb; + CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]); + SMESH::SMESH_Mesh_var meshObj = SMESH::SMESH_Mesh::_narrow(obj); + if(!CORBA::is_nil(meshObj)) { + SALOMEDS::TMPFile* SeqFile = meshObj->GetVtkUgStream(); + int aSize = SeqFile->length(); + char* buf = (char*)SeqFile->NP_data(); + vtkUnstructuredGridReader* aReader = vtkUnstructuredGridReader::New(); + aReader->ReadFromInputStringOn(); + aReader->SetBinaryInputString(buf, aSize); + aReader->Update(); + vtkUnstructuredGrid* ret = vtkUnstructuredGrid::New(); + ret->ShallowCopy(aReader->GetOutput()); + aReader->Delete(); + if(!ret) { + vtkErrorMacro("On smesh object CORBA fetching an error occurs !"); + return 0; + } + + ret0->SetBlock(0, ret); + ret->Delete(); + return 1; + } + + vtkErrorMacro("Unrecognized CORBA reference!"); + } + catch(CORBA::Exception&) { + vtkErrorMacro("On fetching object error occurs"); + } + return 0; +} + + + diff --git a/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.h b/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.h new file mode 100644 index 00000000..ae43c982 --- /dev/null +++ b/src/Plugins/ParaSMESHCorba/vtkParaSMESHCorbaSource.h @@ -0,0 +1,50 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +// + + +#ifndef __vtkParaSMESHCorbaSource_h +#define __vtkParaSMESHCorbaSource_h + +#include "vtkUnstructuredGridAlgorithm.h" +#include + +class vtkParaSMESHCorbaSource: public vtkAlgorithm { + public: + static vtkParaSMESHCorbaSource* New(); + vtkTypeMacro(vtkParaSMESHCorbaSource, vtkAlgorithm); + + + const char *GetIORCorba(); + void SetIORCorba(char *ior); + +protected: + vtkParaSMESHCorbaSource(); + virtual ~vtkParaSMESHCorbaSource(); + int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info); + int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); + virtual int RequestData( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo ); + vtksys_stl::vector IOR; + static void *Orb; + private: + vtkParaSMESHCorbaSource( const vtkParaSMESHCorbaSource& ); // Not implemented. + void operator = ( const vtkParaSMESHCorbaSource& ); // Not implemented. +}; + +#endif // __vtkParaSMESHCorbaSource_h + -- 2.39.2