Salome HOME
No more macro mode. Replaced by SimpleMode plugin.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 25 Jan 2017 07:21:23 +0000 (08:21 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 25 Jan 2017 08:43:10 +0000 (09:43 +0100)
src/Macro/CMakeLists.txt
src/Macro/modes.py [deleted file]
src/Plugins/CMakeLists.txt
src/Plugins/SimpleMode/CMakeLists.txt [new file with mode: 0644]
src/Plugins/SimpleMode/IO/CMakeLists.txt [new file with mode: 0644]
src/Plugins/SimpleMode/IO/module.cmake [new file with mode: 0644]
src/Plugins/SimpleMode/IO/vtkSimpleMode.cxx [new file with mode: 0644]
src/Plugins/SimpleMode/IO/vtkSimpleMode.h [new file with mode: 0644]
src/Plugins/SimpleMode/ParaViewPlugin/CMakeLists.txt [new file with mode: 0644]
src/Plugins/SimpleMode/ParaViewPlugin/Resources/SimpleModeServer.xml [new file with mode: 0644]

index c84dcd6e2675a2a678a1c581de34d1388ad80b37..999f1b574044ac551e2913dde4fdb1dda7c5e717 100644 (file)
@@ -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 (file)
index a0396b5..0000000
+++ /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()
index d975922ca69417a4a237bc0da6342a0bd0398c2a..c60e06457d57d16c0b17ebcc7a36a9f82a41d38a 100755 (executable)
@@ -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 (file)
index 0000000..fd3ef6e
--- /dev/null
@@ -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 (file)
index 0000000..a33d581
--- /dev/null
@@ -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 (file)
index 0000000..0e437ca
--- /dev/null
@@ -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 (file)
index 0000000..74645d1
--- /dev/null
@@ -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 <map>
+#include <deque>
+#include <sstream>
+
+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<vtkDoubleArray> ForceTo3Compo(vtkDoubleArray *arr)
+{
+  if(!arr)
+    return vtkSmartPointer<vtkDoubleArray>();
+  int nbCompo(arr->GetNumberOfComponents()),nbTuples(arr->GetNumberOfTuples());
+  if(nbCompo==3)
+    {
+      vtkSmartPointer<vtkDoubleArray> ret(arr);
+      arr->Register(0);
+      return ret;
+    }
+  if(nbCompo==6)
+    {
+      vtkSmartPointer<vtkDoubleArray> ret(vtkSmartPointer<vtkDoubleArray>::New());
+      ret->SetNumberOfComponents(3);
+      ret->SetNumberOfTuples(nbTuples);
+      const double *srcPt(arr->Begin());
+      double *destPt(ret->Begin());
+      for(int i=0;i<nbTuples;i++,destPt+=3,srcPt+=6)
+        std::copy(srcPt,srcPt+3,destPt);
+      return ret;
+    }
+  throw MZCException("ForceTo3Compo : internal error ! 6 or 3 compo arrays expected !");
+}
+
+std::vector< std::string > 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;i<att->GetNumberOfArrays();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<std::string>& arrNames, const std::string& key0, const std::string& key1)
+{
+  std::string ret;
+  char points(0);
+  if(arrNames.empty())
+    return ret;
+  for(std::vector<std::string>::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<std::string>& arrNames)
+{
+  static const char KEY1[]="DEPL";
+  static const char KEY2[]="REEL";
+  return FindTheBest(arrNames,KEY1,KEY2);
+}
+
+std::string FindBestImagAmong(const std::vector<std::string>& 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;i<att->GetNumberOfArrays();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;i<nbPts;i++,srcPt1+=nbCompo)
+    {
+      minmax2[0]=std::max(fabs(srcPt1[0]),minmax2[0]);
+      minmax2[1]=std::max(fabs(srcPt1[1]),minmax2[1]);
+      minmax2[2]=std::max(fabs(srcPt1[2]),minmax2[2]);
+    }
+  double maxDispDelta(*std::max_element(minmax2,minmax2+3));
+  if(maxDispDelta<EPS)
+    maxDispDelta=1.;
+  for(int i=0;i<3;i++)
+    minmax2[i]=minmax1[2*i+1]-minmax1[2*i];
+  double maxGeoDelta(*std::max_element(minmax2,minmax2+3));
+  if(maxDispDelta<EPS)
+    maxDispDelta=1.;
+  return maxGeoDelta/maxDispDelta;
+}
+
+int vtkSimpleMode::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
+{ 
+  //std::cerr << "########################################## vtkSimpleMode::RequestInformation ##########################################" << std::endl;
+  try
+    {
+      if(this->Internal->getFieldForReal().empty())
+        return 1;
+      vtkUnstructuredGrid *usgIn(0);
+      vtkDoubleArray *arr(0);
+      ExtractInfo(inputVector[0],usgIn,this->Internal->getFieldForReal(),arr);
+      std::vector<std::string> 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<char *>(oss.str().c_str()));
+      else
+        vtkOutputWindowDisplayErrorText(const_cast<char *>(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<vtkDoubleArray> arrReal(ForceTo3Compo(arrRealBase));
+      //
+      int nbPts(usgIn->GetNumberOfPoints());
+      vtkSmartPointer<vtkUnstructuredGrid> step1(vtkSmartPointer<vtkUnstructuredGrid>::New());
+      step1->DeepCopy(usgIn);
+      vtkSmartPointer<vtkDoubleArray> arr1(vtkSmartPointer<vtkDoubleArray>::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<double>(),cst1));
+      //
+      int idx1(step1->GetPointData()->AddArray(arr1));
+      step1->GetPointData()->SetActiveAttribute(idx1,vtkDataSetAttributes::VECTORS);
+      //
+      vtkSmartPointer<vtkDataSetSurfaceFilter> surface(vtkSmartPointer<vtkDataSetSurfaceFilter>::New());
+      surface->SetInputData(step1);
+      //
+      vtkSmartPointer<vtkWarpVector> ws(vtkSmartPointer<vtkWarpVector>::New());//vtkNew
+      ws->SetInputConnection(surface->GetOutputPort());
+      ws->SetScaleFactor(1.);
+      ws->SetInputArrayToProcess(idx1,0,0,"vtkDataObject::FIELD_ASSOCIATION_POINTS",ZE_DISPLACEMENT_NAME1);
+      ws->Update();
+      vtkSmartPointer<vtkDataSet> 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<char *>(oss.str().c_str()));
+      else
+        vtkOutputWindowDisplayErrorText(const_cast<char *>(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 (file)
index 0000000..db110c2
--- /dev/null
@@ -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 (file)
index 0000000..1d875eb
--- /dev/null
@@ -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 (file)
index 0000000..93bcd34
--- /dev/null
@@ -0,0 +1,72 @@
+<ServerManagerConfiguration>
+  <ProxyGroup name="filters">
+    <SourceProxy name="SimpleMode" class="vtkSimpleMode" label="Simple Mode">
+     <InputProperty name="Input" command="SetInputConnection">
+       <ProxyGroupDomain name="groups">
+         <Group name="sources"/>
+         <Group name="filters"/>
+       </ProxyGroupDomain>
+       <DataTypeDomain name="input_type">
+         <DataType value="vtkDataSet"/>
+       </DataTypeDomain>
+       <Documentation>
+         This property specifies the input to the Level Scalars filter.
+       </Documentation>
+     <InputArrayDomain name="input_array2"
+                      number_of_components="3,6"
+                      optional="1" />
+     </InputProperty>
+
+     <StringVectorProperty command="SetInputArrayToProcess"
+                            default_values="0;0;0;3"
+                            default_values_delimiter=";"
+                            element_types="0 0 0 0 2"
+                            name="Real"
+                            number_of_elements="5">
+        <!-- default value=1 so normals go to the right place -->
+        <ArrayListDomain attribute_type="Vectors"
+                         input_domain_name="input_array2"
+                         name="array_list">
+          <RequiredProperties>
+            <Property function="Input"
+                      name="Input" />
+          </RequiredProperties>
+        </ArrayListDomain>
+        <FieldDataDomain name="field_list">
+          <RequiredProperties>
+            <Property function="Input"
+                      name="Input" />
+          </RequiredProperties>
+        </FieldDataDomain>
+        <Documentation>
+Select the array that represent the real part of the complex mode.
+        </Documentation>
+      </StringVectorProperty>
+
+      <DoubleVectorProperty animateable="1"
+                            command="SetFactor"
+                           default_values="1"
+                            name="Factor"
+                            number_of_elements="1">
+        <BoundsDomain name="range" mode="array_scaled_extent">
+          <RequiredProperties>
+            <Property function="Input" name="Input" />
+            <Property function="ArraySelection" name="Real" />
+          </RequiredProperties>
+        </BoundsDomain>
+        <Documentation>The value of this property sets the scale factor applied for all nodes displacement.</Documentation>
+      </DoubleVectorProperty>
+
+      <DoubleVectorProperty animateable="1"
+                            command="SetAnimationTime"
+                            default_values="0"
+                            name="AnimationTime"
+                           panel_visibility="advanced"
+                            number_of_elements="1">
+        <DoubleRangeDomain max="1" min="0" name="range" />
+        <Documentation>The value of this property sets the scale factor applied for all nodes displacement.</Documentation>
+      </DoubleVectorProperty>
+
+    </SourceProxy>
+  </ProxyGroup>
+</ServerManagerConfiguration>