From: Anthony Geay Date: Wed, 25 Jan 2017 07:21:23 +0000 (+0100) Subject: No more macro mode. Replaced by SimpleMode plugin. X-Git-Tag: SHAPER_2.7.0~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34be7bda9c8b1d87939ae8d3b6c07f222676b314;p=modules%2Fparavis.git No more macro mode. Replaced by SimpleMode plugin. --- diff --git a/src/Macro/CMakeLists.txt b/src/Macro/CMakeLists.txt index c84dcd6e..999f1b57 100644 --- a/src/Macro/CMakeLists.txt +++ b/src/Macro/CMakeLists.txt @@ -18,7 +18,6 @@ # SET(_PYFILES_TO_INSTALL - modes.py annotate_groups.py ShowSalomeObject.py ) diff --git a/src/Macro/modes.py b/src/Macro/modes.py deleted file mode 100644 index a0396b53..00000000 --- a/src/Macro/modes.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright (C) 2010-2016 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 -# - -try: paraview.simple -except: from paraview.simple import * -paraview.simple._DisableFirstRenderCameraReset() - -import sys - -source = GetActiveSource() -representation = GetDisplayProperties(source) -representation.Visibility = 0 - -oldmode = None - -if source.SMProxy.GetVTKClassName() == 'vtkMedReader' : - oldmode = source.AnimationMode - source.AnimationMode = 'Modes' - -ExtractSurface1 = ExtractSurface() -ScaleVector1 = ScaleVector() -WarpByVector1 = WarpByVector() - -# first, find the first point-centered vector array. -ExtractSurface1.UpdatePipeline() -info = ExtractSurface1.GetDataInformation() -pinfo = info.DataInformation.GetPointDataInformation() -arrayinfo = None -vectorname = None -rootname = None -for arrayid in range(0, pinfo.GetNumberOfArrays()) : - arrayinfo = pinfo.GetArrayInformation(arrayid) - if arrayinfo.GetNumberOfComponents() == 3 : - vectorname = arrayinfo.GetName() - rootpos = vectorname.rfind("[") - if rootpos == -1 : - rootname = vectorname - else : - rootname = vectorname[0:rootpos-1] - ScaleVector1.VectorField = ['POINTS', vectorname] - WarpByVector1.Vectors = ['POINTS', rootname] - break - -if vectorname == None : - source.AnimationMode = oldmode -else : - ScaleVector1.ScaleFactor = 0 - ScaleVector1.UpdatePipeline() - bounds = info.DataInformation.GetBounds() - side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]] - length = side[0] - if side[1] > length : length = side[1] - if side[2] > length : length = side[2] - - scale = length / 20 - if vectorname != None : - arrayrange = arrayinfo.GetComponentRange(-1) - if arrayrange[1] > 0 : - scale = scale / arrayrange[1] - - WarpByVector1.ScaleFactor = scale - - AnimationScene1 = GetAnimationScene() - - TimeAnimationCue1 = GetTimeTrack() - TimeAnimationCue1.Enabled = 0 - - KeyFrameAnimationCue1 = KeyFrameAnimationCue() - KeyFrameAnimationCue1.AnimatedProxy = ScaleVector1 - KeyFrameAnimationCue1.AnimatedPropertyName = "ScaleFactor" - KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' ) - KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] ) - - KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ] - - AnimationScene1.Cues.append(KeyFrameAnimationCue1) - AnimationScene1.Loop = 1 - AnimationScene1.PlayMode = 'Sequence' - AnimationScene1.StartTime = 0 - AnimationScene1.EndTime = 1 - AnimationScene1.NumberOfFrames = 21 - - WarpByVectorDataRepresentation = Show(WarpByVector1) - if rootname != None : - pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' ) - WarpByVectorDataRepresentation.ColorArrayName = rootname - WarpByVectorDataRepresentation.LookupTable = pvLookupTable - WarpByVectorDataRepresentation.RescaleTransferFunctionToDataRange(True) - - AnimationScene1.Play() diff --git a/src/Plugins/CMakeLists.txt b/src/Plugins/CMakeLists.txt index d975922c..c60e0645 100755 --- a/src/Plugins/CMakeLists.txt +++ b/src/Plugins/CMakeLists.txt @@ -23,6 +23,7 @@ SET(_subdirs MEDReader MEDWriter # TableReader + SimpleMode ElevationSurface ScaleVector EllipseBuilder diff --git a/src/Plugins/SimpleMode/CMakeLists.txt b/src/Plugins/SimpleMode/CMakeLists.txt new file mode 100644 index 00000000..fd3ef6e8 --- /dev/null +++ b/src/Plugins/SimpleMode/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright (C) 2017 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 +# +# Author : Anthony Geay (EDF R&D) + +PROJECT(SimpleMode) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +CMAKE_POLICY(SET CMP0003 NEW) +IF(${CMAKE_VERSION} VERSION_GREATER "3.0.0") + CMAKE_POLICY(SET CMP0022 OLD) + CMAKE_POLICY(SET CMP0023 OLD) +ENDIF() + +SET(MED_READER_VERSION "0.0.0") + +# Common CMake macros +# =================== +SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files") +IF(EXISTS ${CONFIGURATION_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") + INCLUDE(SalomeMacros) +ELSE() + MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") +ENDIF() +FIND_PACKAGE(SalomePythonInterp REQUIRED) +FIND_PACKAGE(SalomePythonLibs REQUIRED) + +FIND_PACKAGE(ParaView REQUIRED) +IF(NOT ParaView_FOUND) + MESSAGE(FATAL_ERROR "Please locate ParaView." ) +ENDIF(NOT ParaView_FOUND) +INCLUDE(${PARAVIEW_USE_FILE}) +PV_SETUP_MODULE_ENVIRONMENT("vtkSimpleMode") + +OPTION(BUILD_SHARED_LIBS "Build with shared libraries." ${VTK_BUILD_SHARED_LIBS}) + +SET(VTK_INSTALL_RUNTIME_DIR lib) +SET(VTK_INSTALL_LIBRARY_DIR lib) +SET(VTK_INSTALL_ARCHIVE_DIR lib) + +PV_PROCESS_MODULES() + +ADD_SUBDIRECTORY(ParaViewPlugin) diff --git a/src/Plugins/SimpleMode/IO/CMakeLists.txt b/src/Plugins/SimpleMode/IO/CMakeLists.txt new file mode 100644 index 00000000..a33d5811 --- /dev/null +++ b/src/Plugins/SimpleMode/IO/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2017 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 +# +# Author : Anthony Geay (EDF R&D) + +VTK_MODULE_LIBRARY(vtkSimpleMode vtkSimpleMode.cxx) +TARGET_LINK_LIBRARIES(vtkSimpleMode vtkPVVTKExtensionsRendering vtkFiltersGeneral vtkFiltersCore vtkRenderingOpenGL ${PARAVIEW_LIBRARIES}) +INSTALL(TARGETS vtkSimpleMode RUNTIME DESTINATION lib/salome LIBRARY DESTINATION lib/salome ARCHIVE DESTINATION lib/salome) diff --git a/src/Plugins/SimpleMode/IO/module.cmake b/src/Plugins/SimpleMode/IO/module.cmake new file mode 100644 index 00000000..0e437ca5 --- /dev/null +++ b/src/Plugins/SimpleMode/IO/module.cmake @@ -0,0 +1,2 @@ +SET(VTK_LIBS vtkCommonExecutionModel vtkParallelCore) +VTK_MODULE(vtkSimpleMode DEPENDS ${VTK_LIBS}) diff --git a/src/Plugins/SimpleMode/IO/vtkSimpleMode.cxx b/src/Plugins/SimpleMode/IO/vtkSimpleMode.cxx new file mode 100644 index 00000000..74645d1d --- /dev/null +++ b/src/Plugins/SimpleMode/IO/vtkSimpleMode.cxx @@ -0,0 +1,388 @@ +// Copyright (C) 2017 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 +// +// Author : Anthony Geay (EDF R&D) + +#include "vtkSimpleMode.h" + +#include "vtkAdjacentVertexIterator.h" +#include "vtkDataSetSurfaceFilter.h" +#include "vtkIntArray.h" +#include "vtkCellData.h" +#include "vtkPointData.h" + +#include "vtkStreamingDemandDrivenPipeline.h" +#include "vtkUnstructuredGrid.h" +#include "vtkPolyData.h" +#include "vtkMultiBlockDataSet.h" + +#include "vtkInformationStringKey.h" +#include "vtkAlgorithmOutput.h" +#include "vtkObjectFactory.h" +#include "vtkMutableDirectedGraph.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkDataSet.h" +#include "vtkInformationVector.h" +#include "vtkInformation.h" +#include "vtkDataArraySelection.h" +#include "vtkTimeStamp.h" +#include "vtkInEdgeIterator.h" +#include "vtkInformationDataObjectKey.h" +#include "vtkExecutive.h" +#include "vtkVariantArray.h" +#include "vtkStringArray.h" +#include "vtkDoubleArray.h" +#include "vtkCharArray.h" +#include "vtkUnsignedCharArray.h" +#include "vtkDataSetAttributes.h" +#include "vtkDemandDrivenPipeline.h" +#include "vtkDataObjectTreeIterator.h" +#include "vtkWarpScalar.h" +#include "vtkWarpVector.h" +#include "vtkMultiBlockDataGroupFilter.h" +#include "vtkCompositeDataToUnstructuredGridFilter.h" + +#include +#include +#include + +vtkStandardNewMacro(vtkSimpleMode); + +static const char ZE_DISPLACEMENT_NAME1[]="@@ForReal?@@"; + +static const char ZE_DISPLACEMENT_NAME2[]="@@ForImag?@@"; + +static const char ZE_DISPLACEMENT_NAME3[]="MagnitudeOfCpxDisp"; + +static const double EPS=1e-12; + +/////////////////// + +class MZCException : public std::exception +{ +public: + MZCException(const std::string& s):_reason(s) { } + virtual const char *what() const throw() { return _reason.c_str(); } + virtual ~MZCException() throw() { } +private: + std::string _reason; +}; + +vtkSmartPointer ForceTo3Compo(vtkDoubleArray *arr) +{ + if(!arr) + return vtkSmartPointer(); + int nbCompo(arr->GetNumberOfComponents()),nbTuples(arr->GetNumberOfTuples()); + if(nbCompo==3) + { + vtkSmartPointer ret(arr); + arr->Register(0); + return ret; + } + if(nbCompo==6) + { + vtkSmartPointer ret(vtkSmartPointer::New()); + ret->SetNumberOfComponents(3); + ret->SetNumberOfTuples(nbTuples); + const double *srcPt(arr->Begin()); + double *destPt(ret->Begin()); + for(int i=0;i GetPossibleArrayNames(vtkDataSet *dataset) +{ + if(!dataset) + throw MZCException("The input dataset is null !"); + std::vector< std::string > ret; + vtkPointData *att(dataset->GetPointData()); + for(int i=0;iGetNumberOfArrays();i++) + { + vtkDataArray *locArr(att->GetArray(i)); + int nbComp(locArr->GetNumberOfComponents()); + if(nbComp!=3 && nbComp!=6) + continue; + std::string s(locArr->GetName()); + ret.push_back(s); + } + return ret; +} + +std::string FindTheBest(const std::vector& arrNames, const std::string& key0, const std::string& key1) +{ + std::string ret; + char points(0); + if(arrNames.empty()) + return ret; + for(std::vector::const_iterator it=arrNames.begin();it!=arrNames.end();it++) + { + char curNbPts(1); + if((*it).find(key0,0)!=std::string::npos) + curNbPts++; + if((*it).find(key1,0)!=std::string::npos) + curNbPts++; + if(curNbPts>points) + { + points=curNbPts; + ret=*it; + } + } + return ret; +} + +std::string FindBestRealAmong(const std::vector& arrNames) +{ + static const char KEY1[]="DEPL"; + static const char KEY2[]="REEL"; + return FindTheBest(arrNames,KEY1,KEY2); +} + +std::string FindBestImagAmong(const std::vector& arrNames) +{ + static const char KEY1[]="DEPL"; + static const char KEY2[]="IMAG"; + return FindTheBest(arrNames,KEY1,KEY2); +} + +vtkUnstructuredGrid *ExtractInfo1(vtkInformationVector *inputVector) +{ + vtkInformation *inputInfo(inputVector->GetInformationObject(0)); + vtkDataSet *input(0); + vtkDataSet *input0(vtkDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); + vtkMultiBlockDataSet *input1(vtkMultiBlockDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); + if(input0) + input=input0; + else + { + if(!input1) + throw MZCException("Input dataSet must be a DataSet or single elt multi block dataset expected !"); + if(input1->GetNumberOfBlocks()!=1) + throw MZCException("Input dataSet is a multiblock dataset with not exactly one block ! Use MergeBlocks or ExtractBlocks filter before calling this filter !"); + vtkDataObject *input2(input1->GetBlock(0)); + if(!input2) + throw MZCException("Input dataSet is a multiblock dataset with exactly one block but this single element is NULL !"); + vtkDataSet *input2c(vtkDataSet::SafeDownCast(input2)); + if(!input2c) + throw MZCException("Input dataSet is a multiblock dataset with exactly one block but this single element is not a dataset ! Use MergeBlocks or ExtractBlocks filter before calling this filter !"); + input=input2c; + } + if(!input) + throw MZCException("Input data set is NULL !"); + vtkUnstructuredGrid *usgIn(vtkUnstructuredGrid::SafeDownCast(input)); + if(!usgIn) + throw MZCException("Input data set is not an unstructured mesh ! This filter works only on unstructured meshes !"); + return usgIn; +} + +void ExtractInfo(vtkInformationVector *inputVector, vtkUnstructuredGrid *& usgIn, const std::string& arrName, vtkDoubleArray *& arr) +{ + usgIn=ExtractInfo1(inputVector); + vtkPointData *att(usgIn->GetPointData()); + if(!att) + throw MZCException("Input dataset has no point data attribute ! Impossible to move mesh !"); + vtkDataArray *zeArr(0); + for(int i=0;iGetNumberOfArrays();i++) + { + vtkDataArray *locArr(att->GetArray(i)); + std::string s(locArr->GetName()); + if(s==arrName) + { + zeArr=locArr; + break; + } + } + if(!zeArr) + { + std::ostringstream oss; + oss << "Impossible to locate the array called \"" << arrName << "\" used to move mesh !"; + throw MZCException(oss.str()); + } + arr=vtkDoubleArray::SafeDownCast(zeArr); + if(!arr) + { + std::ostringstream oss; + oss << "Array called \"" << arrName << "\" has been located but this is NOT a float64 array !"; + throw MZCException(oss.str()); + } + if(arr->GetNumberOfComponents()!=3 && arr->GetNumberOfComponents()!=6) + { + std::ostringstream oss; + oss << "Float64 array called \"" << arrName << "\" has been located but this array has not exactly 3 or 6 components as it should !"; + throw MZCException(oss.str()); + } + if(arr->GetNumberOfTuples()!=usgIn->GetNumberOfPoints()) + { + std::ostringstream oss; + oss << "Float64-1 components array called \"" << arrName << "\" has been located but the number of tuples is invalid ! Should be " << usgIn->GetNumberOfPoints() << " instead of " << arr->GetNumberOfTuples() << " !"; + throw MZCException(oss.str()); + } +} + +//////////////////// + +class vtkSimpleMode::vtkSimpleModeInternal +{ +public: + void setFieldForReal(const std::string& st) { _real=st; } + std::string getFieldForReal() const { return _real; } +private: + std::string _real; +}; + +vtkSimpleMode::vtkSimpleMode():Factor(1.),AnimationTime(0.),Internal(new vtkSimpleMode::vtkSimpleModeInternal) +{ + //this->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,vtkDataSetAttributes::VECTORS); +} + +vtkSimpleMode::~vtkSimpleMode() +{ + delete this->Internal; +} + +void vtkSimpleMode::SetInputArrayToProcess(int idx, int port, int connection, int ff, const char *name) +{ + if(idx==0) + this->Internal->setFieldForReal(name); + vtkPolyDataAlgorithm::SetInputArrayToProcess(idx,port,connection,ff,name); +} + +double GetOptimalRatioFrom(vtkUnstructuredGrid *dataset, vtkDoubleArray *array) +{ + if(!dataset || !array) + throw MZCException("The input dataset and or array is null !"); + vtkDataArray *coords(dataset->GetPoints()->GetData()); + vtkDoubleArray *coords2(vtkDoubleArray::SafeDownCast(coords)); + if(!coords2) + throw MZCException("Input coordinates are not float64 !"); + int nbCompo(array->GetNumberOfComponents()); + if(coords2->GetNumberOfComponents()!=3 || (nbCompo!=3 && nbCompo!=6)) + throw MZCException("Input coordinates do not have 3 components as it should !"); + int nbPts(dataset->GetNumberOfPoints()); + const double *srcPt1(array->Begin()); + dataset->ComputeBounds(); + double *minmax1(dataset->GetBounds()); + double minmax2[3]={0.,0.,0.}; + for(int i=0;iInternal->getFieldForReal().empty()) + return 1; + vtkUnstructuredGrid *usgIn(0); + vtkDoubleArray *arr(0); + ExtractInfo(inputVector[0],usgIn,this->Internal->getFieldForReal(),arr); + std::vector candidatesArrName(GetPossibleArrayNames(usgIn)); + // + double ratio(GetOptimalRatioFrom(usgIn,arr)); + std::string optArrNameForReal(FindBestRealAmong(candidatesArrName)); + std::string optArrNameForImag(FindBestImagAmong(candidatesArrName)); + //std::cerr << ratio << std::endl; + //std::cerr << optArrNameForReal << " * " << optArrNameForImag << std::endl; + } + catch(MZCException& e) + { + std::ostringstream oss; + oss << "Exception has been thrown in vtkSimpleMode::RequestInformation : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); + return 0; + } + return 1; +} + +int vtkSimpleMode::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + //std::cerr << "########################################## vtkSimpleMode::RequestData ##########################################" << std::endl; + try + { + vtkUnstructuredGrid *usgIn(0); + vtkDoubleArray *arrRealBase(0),*arrImagBase(0); + ExtractInfo(inputVector[0],usgIn,this->Internal->getFieldForReal(),arrRealBase); + vtkSmartPointer arrReal(ForceTo3Compo(arrRealBase)); + // + int nbPts(usgIn->GetNumberOfPoints()); + vtkSmartPointer step1(vtkSmartPointer::New()); + step1->DeepCopy(usgIn); + vtkSmartPointer arr1(vtkSmartPointer::New()); + arr1->SetName(ZE_DISPLACEMENT_NAME1); + arr1->SetNumberOfComponents(3); + arr1->SetNumberOfTuples(nbPts); + double *ptToFeed1(arr1->Begin()); + const double *srcPt1(arrReal->Begin()); + double cst1(Factor*sin(AnimationTime*2*M_PI)); + std::transform(srcPt1,srcPt1+3*nbPts,ptToFeed1,std::bind2nd(std::multiplies(),cst1)); + // + int idx1(step1->GetPointData()->AddArray(arr1)); + step1->GetPointData()->SetActiveAttribute(idx1,vtkDataSetAttributes::VECTORS); + // + vtkSmartPointer surface(vtkSmartPointer::New()); + surface->SetInputData(step1); + // + vtkSmartPointer ws(vtkSmartPointer::New());//vtkNew + ws->SetInputConnection(surface->GetOutputPort()); + ws->SetScaleFactor(1.); + ws->SetInputArrayToProcess(idx1,0,0,"vtkDataObject::FIELD_ASSOCIATION_POINTS",ZE_DISPLACEMENT_NAME1); + ws->Update(); + vtkSmartPointer ds(ws->GetOutput()); + ds->GetPointData()->RemoveArray(idx1); + vtkInformation *outInfo(outputVector->GetInformationObject(0)); + vtkPolyData *output(vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()))); + output->ShallowCopy(ds); + } + catch(MZCException& e) + { + std::ostringstream oss; + oss << "Exception has been thrown in vtkSimpleMode::RequestInformation : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); + return 0; + } + return 1; +} + +void vtkSimpleMode::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); +} diff --git a/src/Plugins/SimpleMode/IO/vtkSimpleMode.h b/src/Plugins/SimpleMode/IO/vtkSimpleMode.h new file mode 100644 index 00000000..db110c2b --- /dev/null +++ b/src/Plugins/SimpleMode/IO/vtkSimpleMode.h @@ -0,0 +1,60 @@ +// Copyright (C) 2017 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 +// +// Author : Anthony Geay (EDF R&D) + +#ifndef vtkSimpleMode_h__ +#define vtkSimpleMode_h__ + +#include "vtkPolyDataAlgorithm.h" + +class vtkMutableDirectedGraph; + +class VTK_EXPORT vtkSimpleMode : public vtkPolyDataAlgorithm +{ +public: + static vtkSimpleMode* New(); + vtkTypeMacro(vtkSimpleMode, vtkPolyDataAlgorithm) + void PrintSelf(ostream& os, vtkIndent indent); + void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name); + vtkGetMacro(Factor,double); + vtkSetClampMacro(Factor,double,0.,VTK_DOUBLE_MAX); + vtkGetMacro(AnimationTime,double); + vtkSetClampMacro(AnimationTime,double,0.,1.); +protected: + vtkSimpleMode(); + ~vtkSimpleMode(); + + int RequestInformation(vtkInformation *request, + vtkInformationVector **inputVector, vtkInformationVector *outputVector); + + int RequestData(vtkInformation *request, vtkInformationVector **inputVector, + vtkInformationVector *outputVector); +private: + vtkSimpleMode(const vtkSimpleMode&); + void operator=(const vtkSimpleMode&); // Not implemented. + private: + //BTX + //ETX + double Factor; + double AnimationTime; + class vtkSimpleModeInternal; + vtkSimpleModeInternal* Internal; +}; + +#endif diff --git a/src/Plugins/SimpleMode/ParaViewPlugin/CMakeLists.txt b/src/Plugins/SimpleMode/ParaViewPlugin/CMakeLists.txt new file mode 100644 index 00000000..1d875eb7 --- /dev/null +++ b/src/Plugins/SimpleMode/ParaViewPlugin/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2017 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 +# +# Author : Anthony Geay (EDF R&D) + +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../IO ) +ADD_PARAVIEW_PLUGIN(SimpleModePlugin "4.0" + SERVER_MANAGER_SOURCES ${SM_SRCS} + SERVER_MANAGER_XML Resources/SimpleModeServer.xml + CS_KITS + vtkSimpleMode) +TARGET_LINK_LIBRARIES(SimpleModePlugin vtkSimpleMode vtkSimpleModeCS) +INSTALL(TARGETS SimpleModePlugin RUNTIME DESTINATION lib/paraview LIBRARY DESTINATION lib/paraview ARCHIVE DESTINATION lib/paraview) diff --git a/src/Plugins/SimpleMode/ParaViewPlugin/Resources/SimpleModeServer.xml b/src/Plugins/SimpleMode/ParaViewPlugin/Resources/SimpleModeServer.xml new file mode 100644 index 00000000..93bcd348 --- /dev/null +++ b/src/Plugins/SimpleMode/ParaViewPlugin/Resources/SimpleModeServer.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + This property specifies the input to the Level Scalars filter. + + + + + + + + + + + + + + + + + +Select the array that represent the real part of the complex mode. + + + + + + + + + + + The value of this property sets the scale factor applied for all nodes displacement. + + + + + The value of this property sets the scale factor applied for all nodes displacement. + + + + +