]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Introduction of the ELNO related VTK WarpVector filter
authorapo <apo@opencascade.com>
Wed, 30 Apr 2008 15:47:29 +0000 (15:47 +0000)
committerapo <apo@opencascade.com>
Wed, 30 Apr 2008 15:47:29 +0000 (15:47 +0000)
src/CONVERTOR/Makefile.am
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_ElnoMeshValue.hxx [new file with mode: 0644]
src/CONVERTOR/VISU_MeshValue.cxx
src/CONVERTOR/VISU_TypeList.hxx
src/CONVERTOR/VISU_VTKTypeList.hxx [new file with mode: 0644]
src/PIPELINE/Makefile.am
src/PIPELINE/VISUPipeLine.cxx
src/PIPELINE/VISU_ElnoGeometryFilter.cxx
src/PIPELINE/VISU_ElnoWarpVector.cxx [new file with mode: 0644]
src/PIPELINE/VISU_ElnoWarpVector.hxx [new file with mode: 0644]

index 448bbdcaaa8c7bcc0071f393b77dc782d1d79abe..30a5a8763d283614ae66a95ab4867dc3896282ae 100644 (file)
@@ -28,6 +28,7 @@ lib_LTLIBRARIES = libVisuConvertor.la
 
 salomeinclude_HEADERS= \
        VISU_TypeList.hxx \
+       VISU_VTKTypeList.hxx \
        VISU_IDMapper.hxx \
        VISU_ConvertorDef.hxx \
        VISU_Structures.hxx \
@@ -35,6 +36,7 @@ salomeinclude_HEADERS= \
        VISU_ConvertorDef_impl.hxx \
        VISU_Structures_impl.hxx \
        VISU_MeshValue.hxx \
+       VISU_ElnoMeshValue.hxx \
        VISU_PointCoords.hxx \
        VISU_Convertor_impl.hxx \
        VISU_ConvertorUtils.hxx \
index e9ecb27b657ffb5d28cc192484f6cbcfdb21370a..c908ab0bbf2f6040f258b581fa4cc76046abb594 100644 (file)
@@ -85,18 +85,12 @@ namespace
 
   
   //---------------------------------------------------------------
+  inline
   void
-  PrintCells(int& theStartId,
-            vtkCellArray* theConnectivity, 
-            const VISU::TConnect& theVector)
+  PrintCells( vtkCellArray* theConnectivity, 
+             const VISU::TConnect& theVector)
   {
-    vtkIdList *anIdList = vtkIdList::New();
-    int kEnd = theVector.size();
-    anIdList->SetNumberOfIds(kEnd);
-    for(int k = 0; k < kEnd; k++)
-      anIdList->SetId(k,theVector[k]);
-    theConnectivity->InsertNextCell(anIdList);
-    anIdList->Delete();
+    theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] );
   }
 
 
@@ -124,7 +118,7 @@ namespace
     aCellTypesArray->SetNumberOfTuples(aNbCells);
 
     for(vtkIdType anID = 0; anID < aNbCells; anID++){
-      PrintCells(anID,aConnectivity,anArray[anID]);
+      PrintCells( aConnectivity, anArray[ anID ] );
       aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
     }
 
@@ -219,7 +213,7 @@ namespace
       VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
       for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){
        vtkIdType anID = *aSubMeshIDIter;
-       PrintCells(aCellId, aConnectivity, anArray[anID]);
+       PrintCells( aConnectivity, anArray[ anID ] );
        aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
        vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
        anElemObj2VTKID[anObjID] = aCellId;
@@ -284,7 +278,7 @@ namespace
       VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
       for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
        const VISU::TConnect& anArray = aCell2Connect[anId];
-       PrintCells(aConnId,aConnectivity,anArray);
+       PrintCells( aConnectivity, anArray );
        aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
        aConnId += aNbNodes;
        anId++;
@@ -294,7 +288,7 @@ namespace
       for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
        vtkIdType aSubId = *anIter;
        const VISU::TConnect& anArray = aCell2Connect[aSubId];
-       PrintCells(aConnId,aConnectivity,anArray);
+       PrintCells( aConnectivity, anArray );
        aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
        aConnId += aNbNodes;
        anId++;
diff --git a/src/CONVERTOR/VISU_ElnoMeshValue.hxx b/src/CONVERTOR/VISU_ElnoMeshValue.hxx
new file mode 100644 (file)
index 0000000..3548f2e
--- /dev/null
@@ -0,0 +1,78 @@
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  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. 
+// 
+//  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
+//
+//
+//  File   : VISU_ElnoMeshValue.hxx
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#ifndef VISU_ElnoMeshValue_HeaderFile
+#define VISU_ElnoMeshValue_HeaderFile
+
+#include "VISU_VTKTypeList.hxx"
+
+/*! 
+  \file VISU_ElnoMeshValue.hxx
+  \brief The file contains declarations for the acess to the specific ELNO MED data
+*/
+
+namespace VISU
+{
+  //---------------------------------------------------------------
+  template< int elno_type >
+  struct TGetElnoNodeData
+  {
+    typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
+    typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
+    TVTKDataArray *myElnoDataArray;
+    vtkIntArray *myElnoDataMapper;
+    int myElemInfo[3];
+
+
+    //----------------------------------------------------------------------------
+    TGetElnoNodeData( vtkDataArray *theElnoDataArray,
+                     vtkIntArray *theElnoDataMapper )
+      : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) )
+      , myElnoDataMapper( theElnoDataMapper )
+    {}
+
+
+    //----------------------------------------------------------------------------
+    TDataType*
+    operator () ( vtkIdType theCellId, vtkIdType theLocalPntId )
+    {
+      myElnoDataMapper->GetTupleValue( theCellId, myElemInfo );
+      return myElnoDataArray->GetPointer( myElemInfo[ 0 ] );
+    }
+
+
+    //----------------------------------------------------------------------------
+    int
+    getNbComp()
+    {
+      myElnoDataMapper->GetTupleValue( 0, myElemInfo );
+      return myElemInfo[ 1 ];
+    }
+  };
+
+
+  //---------------------------------------------------------------
+}
+
+#endif
index ac4bc0f4e74b6e5b49082af716b29a7c31d41183..42c3eb3daea1cd5effb544b55ad4124df73960f3 100644 (file)
@@ -29,7 +29,7 @@
 #include "VISU_ConvertorUtils.hxx"
 
 #include "VISU_PointCoords.hxx"
-#include "VISU_TypeList.hxx"
+#include "VISU_VTKTypeList.hxx"
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkPolyData.h>
@@ -113,76 +113,6 @@ namespace VISU
   }
 
 
-  namespace TL
-  {
-    //----------------------------------------------------------------------------
-    typedef TList<char,
-                 TList<unsigned char,
-                       TList<short,
-                             TList<unsigned short,
-                                   TList<int,
-                                         TList<unsigned int,
-                                               TList<long,
-                                                     TList<unsigned long, 
-                                                           TList<float, 
-                                                                 TList<double, 
-                                                                       TNullType> > > > > > > > > >
-    TVTKBasicTypeList;
-    
-
-    //----------------------------------------------------------------------------
-    typedef TList<vtkCharArray,
-                 TList<vtkUnsignedCharArray,
-                       TList<vtkShortArray,
-                             TList<vtkUnsignedShortArray,
-                                   TList<vtkIntArray,
-                                         TList<vtkUnsignedIntArray,
-                                               TList<vtkLongArray,
-                                                     TList<vtkUnsignedLongArray, 
-                                                           TList<vtkFloatArray, 
-                                                                 TList<vtkDoubleArray, 
-                                                                             TNullType> > > > > > > > > >
-    TVTKArrayTypeList;
-    
-
-    typedef TList<TInt2Type<VTK_CHAR>,
-                 TList<TInt2Type<VTK_UNSIGNED_CHAR>,
-                       TList<TInt2Type<VTK_SHORT>,
-                             TList<TInt2Type<VTK_UNSIGNED_SHORT>,
-                                   TList<TInt2Type<VTK_INT>,
-                                         TList<TInt2Type<VTK_UNSIGNED_INT>,
-                                               TList<TInt2Type<VTK_LONG>,
-                                                     TList<TInt2Type<VTK_UNSIGNED_LONG>,
-                                                           TList<TInt2Type<VTK_FLOAT>, 
-                                                                 TList<TInt2Type<VTK_DOUBLE>, 
-                                                                       TNullType> > > > > > > > > >
-    TVTKBasicEnumList;
-    
-
-    //----------------------------------------------------------------------------
-    template <unsigned int type_enum>
-    struct TEnum2VTKBasicType
-    {
-      typedef typename TTypeAt<TVTKBasicTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
-    };
-    
-    //----------------------------------------------------------------------------
-    template <unsigned int type_enum>
-    struct TEnum2VTKArrayType
-    {
-      typedef typename TTypeAt<TVTKArrayTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
-    };
-    
-    //----------------------------------------------------------------------------
-    template <class T>
-    struct TVTKBasicType2Enum
-    {
-      typedef typename TTypeAt<TVTKBasicEnumList, TIndexOf<TVTKBasicTypeList, T>::value >::TResult TResult;
-    };
-    
-  }
-
-
   //----------------------------------------------------------------------------
   template<int EDataType>
   void 
index 1a09efc3dff3438a122861c2adef421691e44ab3..a2eda5b7608620e3ded20007fad0eacd1ff29ae0 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
-//  File   : VISU_ColoredPrs3dCache_i.hh
+//  File   : VISU_TypeList.hxx
 //  Author : Oleg UVAROV
 //  Module : VISU
 
 #ifndef VISU_TypeList_HeaderFile
 #define VISU_TypeList_HeaderFile
 
+
+//----------------------------------------------------------------------------
 namespace VISU
 {
+  //----------------------------------------------------------------------------
   namespace TL
   {
     //----------------------------------------------------------------------------
-    template <class T, class U>
+    struct TNullType {};
+    
+
+    //----------------------------------------------------------------------------
+    template < class T, class U >
     struct TList
     {
       typedef T THead;
       typedef U TTail;
     };
     
-    template <int v>
+    template < int v >
     struct TInt2Type
     {
       enum { value = v };
     };
     
-    struct TNullType {};
-    
+
     //----------------------------------------------------------------------------
-    template <class TypeList, unsigned int index
+    template < class TypeList, unsigned int index 
     struct TTypeAt;
 
-    template <class THead, class TTail>
-    struct TTypeAt<TList<THead, TTail>, 0>
+    template < class THead, class TTail >
+    struct TTypeAt< TList< THead, TTail >, 0 >
     {
       typedef THead TResult;
     };
 
 
-    template <class THead, class TTail, unsigned int index>
-    struct TTypeAt<TList<THead, TTail>, index>
+    template < class THead, class TTail, unsigned int index >
+    struct TTypeAt< TList< THead, TTail >, index >
     {
-      typedef typename TTypeAt<TTail, index - 1>::TResult TResult;
+      typedef typename TTypeAt< TTail, index - 1 >::TResult TResult;
     };
 
+
     //----------------------------------------------------------------------------
-    template <class TypeList, class T
+    template < class TypeList, class T 
     struct TIndexOf;
 
-    template <class T>
-    struct TIndexOf<TNullType, T>
+    template < class T >
+    struct TIndexOf< TNullType, T >
     {
       enum { value = -1 };
     };
 
-    template <class T, class TTail>
-    struct TIndexOf<TList<T, TTail>, T>
+    template < class T, class TTail >
+    struct TIndexOf< TList< T, TTail >, T >
     {
       enum { value = 0 };
     };
 
-    template <class THead, class TTail, class T>
-    struct TIndexOf<TList<THead, TTail>, T>
+    template < class THead, class TTail, class T >
+    struct TIndexOf< TList< THead, TTail >, T >
     {
     private:
-      enum { temp = TIndexOf<TTail, T>::value };
+      enum { temp = TIndexOf< TTail, T >::value };
     public:
       enum { value = temp == -1? -1 : 1 + temp };
     };
     
+
+    //----------------------------------------------------------------------------
+    template
+    <
+      class T01 = TNullType, class T02 = TNullType, class T03 = TNullType, class T04 = TNullType, class T05 = TNullType,
+      class T06 = TNullType, class T07 = TNullType, class T08 = TNullType, class T09 = TNullType, class T10 = TNullType,
+      class T11 = TNullType, class T12 = TNullType, class T13 = TNullType, class T14 = TNullType, class T15 = TNullType,
+      class T16 = TNullType, class T17 = TNullType, class T18 = TNullType, class T19 = TNullType, class T20 = TNullType,
+      class T21 = TNullType, class T22 = TNullType, class T23 = TNullType, class T24 = TNullType, class T25 = TNullType,
+      class T26 = TNullType, class T27 = TNullType, class T28 = TNullType, class T29 = TNullType, class T30 = TNullType,
+      class T31 = TNullType, class T32 = TNullType, class T33 = TNullType, class T34 = TNullType, class T35 = TNullType,
+      class T36 = TNullType, class T37 = TNullType, class T38 = TNullType, class T39 = TNullType, class T40 = TNullType
+    >
+    struct TSequence
+    {
+    private:
+      typedef typename TSequence<      T02, T03, T04, T05, T06, T07, T08, T09, T10,
+                                  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20,
+                                  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
+                                 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40
+                                      >::TResult 
+                       TailResult;
+    public:
+      typedef TList< T01, TailResult > TResult;
+    };
+        
+
+    //----------------------------------------------------------------------------
+    template<>
+    struct TSequence<>
+    {
+      typedef TNullType TResult;
+    };
+
+
     //----------------------------------------------------------------------------
   }
+
+  
+  //----------------------------------------------------------------------------
 }
 
 #endif
diff --git a/src/CONVERTOR/VISU_VTKTypeList.hxx b/src/CONVERTOR/VISU_VTKTypeList.hxx
new file mode 100644 (file)
index 0000000..f210f65
--- /dev/null
@@ -0,0 +1,120 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  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
+//
+//
+//  File   : VISU_VTKTypeList.hxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#ifndef VISU_VTKTypeList_HeaderFile
+#define VISU_VTKTypeList_HeaderFile
+
+#include "VISU_TypeList.hxx"
+
+#include <vtkCharArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkShortArray.h>
+#include <vtkUnsignedShortArray.h>
+#include <vtkIntArray.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkLongArray.h>
+#include <vtkUnsignedLongArray.h> 
+#include <vtkFloatArray.h> 
+#include <vtkDoubleArray.h> 
+
+
+//----------------------------------------------------------------------------
+namespace VISU
+{
+  //----------------------------------------------------------------------------
+  namespace TL
+  {
+    //----------------------------------------------------------------------------
+    typedef TSequence< char, 
+                      unsigned char, 
+                      short, 
+                      unsigned short, 
+                      int, 
+                      unsigned int, 
+                      long, 
+                      unsigned long, 
+                      float, 
+                      double >::TResult TVTKBasicTypeList;
+
+
+    //----------------------------------------------------------------------------
+    typedef TSequence< vtkCharArray, 
+                      vtkUnsignedCharArray, 
+                      vtkShortArray, 
+                      vtkUnsignedShortArray, 
+                      vtkIntArray, 
+                      vtkUnsignedIntArray, 
+                      vtkLongArray, 
+                      vtkUnsignedLongArray, 
+                      vtkFloatArray, 
+                      vtkDoubleArray >::TResult TVTKArrayTypeList;
+
+
+    //----------------------------------------------------------------------------
+    typedef TSequence< TInt2Type< VTK_CHAR >, 
+                      TInt2Type< VTK_UNSIGNED_CHAR >, 
+                      TInt2Type< VTK_SHORT >, 
+                      TInt2Type< VTK_UNSIGNED_SHORT >, 
+                      TInt2Type< VTK_INT >, 
+                      TInt2Type< VTK_UNSIGNED_INT >, 
+                      TInt2Type< VTK_LONG >, 
+                      TInt2Type< VTK_UNSIGNED_LONG >, 
+                      TInt2Type< VTK_FLOAT >, 
+                      TInt2Type< VTK_DOUBLE > >::TResult TVTKBasicEnumList;
+    
+    
+    //----------------------------------------------------------------------------
+    template< unsigned int type_enum >
+    struct TEnum2VTKBasicType
+    {
+      typedef typename TTypeAt< TVTKBasicTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult;
+    };
+
+    
+    //----------------------------------------------------------------------------
+    template< unsigned int type_enum >
+    struct TEnum2VTKArrayType
+    {
+      typedef typename TTypeAt< TVTKArrayTypeList, TIndexOf< TVTKBasicEnumList, TInt2Type< type_enum > >::value >::TResult TResult;
+    };
+    
+
+    //----------------------------------------------------------------------------
+    template< class T >
+    struct TVTKBasicType2Enum
+    {
+      typedef typename TTypeAt< TVTKBasicEnumList, TIndexOf< TVTKBasicTypeList, T >::value >::TResult TResult;
+    };
+    
+
+    //----------------------------------------------------------------------------
+  }
+
+
+  //----------------------------------------------------------------------------
+}
+
+#endif
index 7a26914cc3e4ca89b3d8e6a9a0a6d03f1c4807f4..a686ea8c96f786631fd0f7b6302f27d225f11399 100644 (file)
@@ -65,10 +65,11 @@ salomeinclude_HEADERS= \
        VISU_WidgetCtrl.hxx \
        VISU_ScalarMapOnDeformedShapePL.hxx \
        VISU_OpenGLElnoMapper.hxx \
-       VISUPipeline.hxx \
+       VISU_ElnoWarpVector.cxx \
        VISU_ElnoGeometryFilter.hxx \
        VISU_ElnoMapperHolder.hxx \
-       VISU_ElnoScalarMapPL.hxx
+       VISU_ElnoScalarMapPL.hxx \
+       VISUPipeline.hxx 
 
 dist_libVisuPipeLine_la_SOURCES= \
        VISU_MapperHolder.cxx \
@@ -109,7 +110,8 @@ dist_libVisuPipeLine_la_SOURCES= \
        VISU_OpenGLElnoMapper.cxx \
        VISU_ElnoGeometryFilter.cxx \
        VISU_ElnoMapperHolder.cxx \
-       VISU_ElnoScalarMapPL.cxx
+       VISU_ElnoScalarMapPL.cxx \
+       VISU_ElnoWarpVector.cxx
 
 
 libVisuPipeLine_la_CPPFLAGS= \
index befed7be200335ddeeb303533738d2bdcda39dc5..d660d7b48573b0c27891fef97d410ea5029ef9fb 100644 (file)
 #include "VISU_StreamLinesPL.hxx"
 #include "VISU_GaussPointsPL.hxx"
 #include "VISU_ScalarMapOnDeformedShapePL.hxx"
-#include "VISU_OpenGLElnoMapper.hxx"
 #include "VISU_Plot3DPL.hxx"
+
 #include "VISU_ScalarBarActor.hxx"
 #include "VISU_OpenGLPointSpriteMapper.hxx"
 #include "VTKViewer_GeometryFilter.h"
+
+#include "VISU_ElnoWarpVector.hxx"
 #include "VISU_ElnoGeometryFilter.hxx"
+#include "VISU_OpenGLElnoMapper.hxx"
 
 // VTK includes
 #include <vtkMaskPoints.h>
@@ -231,15 +234,24 @@ main(int argc, char** argv)
                                                anEntity,
                                                theFieldName,
                                                aTimeStamp);
+             
+             VISU_ElnoWarpVector* anElnoWarpVector = VISU_ElnoWarpVector::New();
+              anElnoWarpVector->SetInput( anUnstructuredGridIDMapper->GetUnstructuredGridOutput() );
 
               VISU_ElnoGeometryFilter *aGeometryFilter = VISU_ElnoGeometryFilter::New();
               aGeometryFilter->SetScalarMode(aComponentNumber);
-              aGeometryFilter->SetInput( anUnstructuredGridIDMapper->GetUnstructuredGridOutput() );
-              aGeometryFilter->Update();
-              
+              aGeometryFilter->SetInput( anElnoWarpVector->GetOutput() );
+
+             // To calculate and apply default scale factor
+             {
+               vtkFloatingPointType aScale = VISU_DeformedShapePL::GetScaleFactor( anElnoWarpVector->GetOutput() );
+               vtkFloatingPointType* aRange = aGeometryFilter->GetRange();
+               aScale /= aRange[1];
+               anElnoWarpVector->SetScaleFactor( aScale );
+             }
+
               VISU_OpenGLElnoMapper* aMapper = VISU_OpenGLElnoMapper::New();
-              aMapper->SetInput( aGeometryFilter->GetOutput() );
-              
+              aMapper->SetInput( aGeometryFilter->GetOutput() );              
 
               VISU_LookupTable* aMapperTable( VISU_LookupTable::New() );
               aMapperTable->SetHueRange(0.667, 0.0);
index dc8c48f5411149e78e3fff5adc9ba0ea9d6ccd92..8f05a18d93c0abcf12cb2976f5c29c8867ecd290 100755 (executable)
@@ -54,8 +54,8 @@ VISU_ElnoGeometryFilter::VISU_ElnoGeometryFilter()
   myElnoData = NULL;
   myElnoMapper = NULL;
   myScalarMode = 0;
-  myMinMax[0] = 0.;
-  myMinMax[1] = 1.;
+  myMinMax[0] = -VTK_DOUBLE_MAX;
+  myMinMax[1] = VTK_DOUBLE_MAX;
 }
 //----------------------------------------------------------------------------------------------
 VISU_ElnoGeometryFilter::~VISU_ElnoGeometryFilter()
@@ -661,6 +661,8 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput,
   Strips->Delete();
   
   //Compute Min and Max
+  myMinMax[0] = -VTK_DOUBLE_MAX;
+  myMinMax[1] = VTK_DOUBLE_MAX;
   switch(myElnoData->GetDataType()){
     vtkTemplateMacro3(BuildMinMax,
                       static_cast<VTK_TT*>(aElnoScalars->GetVoidPointer(0)),
@@ -702,6 +704,7 @@ vtkIdType VISU_ElnoGeometryFilter::GetScalarMode() const{
 
 //----------------------------------------------------------------------------------------------
 double* VISU_ElnoGeometryFilter::GetRange(){
+  this->Update(); // To perform automatic update if neccesary
   return myMinMax;
 } 
 
diff --git a/src/PIPELINE/VISU_ElnoWarpVector.cxx b/src/PIPELINE/VISU_ElnoWarpVector.cxx
new file mode 100644 (file)
index 0000000..7882573
--- /dev/null
@@ -0,0 +1,240 @@
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  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 "VISU_ElnoWarpVector.hxx"
+#include "VISU_PipeLineUtils.hxx"
+#include "VISU_ElnoMeshValue.hxx"
+
+#include <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkPoints.h>
+#include <vtkCellArray.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro( VISU_ElnoWarpVector );
+
+
+//----------------------------------------------------------------------------
+VISU_ElnoWarpVector::VISU_ElnoWarpVector()
+{
+  this->myScaleFactor = 1.0;
+
+  this->SetInputArrayToProcess( 0, // idx
+                               0, // port
+                               0, // connection
+                               vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association
+                               "ELNO_FIELD" ); // name
+
+  this->SetInputArrayToProcess( 1, // idx
+                               0, // port
+                               0, // connection
+                               vtkDataObject::FIELD_ASSOCIATION_CELLS, // field association
+                               "ELNO_COMPONENT_MAPPER" ); // name
+}
+
+
+//----------------------------------------------------------------------------
+VISU_ElnoWarpVector::~VISU_ElnoWarpVector()
+{}
+
+
+//----------------------------------------------------------------------------
+void VISU_ElnoWarpVector::SetScaleFactor( vtkFloatingPointType theValue )
+{
+  if ( VISU::CheckIsSameValue( theValue, this->myScaleFactor ) )
+    return;
+
+  this->myScaleFactor = theValue;
+  this->Modified();
+}
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType VISU_ElnoWarpVector::GetScaleFactor()
+{
+  return this->myScaleFactor;
+}
+
+
+//----------------------------------------------------------------------------
+namespace
+{
+  template < int points_type, int elno_type >
+  int ElnoWarpVectorExecute2( VISU_ElnoWarpVector *self, 
+                             vtkUnstructuredGrid *theInput, 
+                             vtkUnstructuredGrid *theOutput, 
+                             vtkDataArray *theElnoDataArray,
+                             vtkIntArray *theElnoDataMapper )
+  {
+    VISU::TGetElnoNodeData< elno_type > aGetElnoNodeData( theElnoDataArray, theElnoDataMapper );
+    typedef typename VISU::TL::TEnum2VTKBasicType< elno_type >::TResult TElnoDataType;
+
+    TElnoDataType aScaleFactor = TElnoDataType( self->GetScaleFactor() );
+    vtkIdType aNbDim = std::min( 3, aGetElnoNodeData.getNbComp() );
+    
+    vtkCellArray *aConnectivity = vtkCellArray::New();
+    aConnectivity->DeepCopy( theInput->GetCells() );
+    
+    vtkPoints *anInputPoints = theInput->GetPoints();
+    vtkPoints *aPoints = anInputPoints->New( anInputPoints->GetDataType() );
+    vtkIdType aNbPoints = aConnectivity->GetNumberOfConnectivityEntries();
+    aPoints->SetNumberOfPoints( aNbPoints );
+    
+    typedef typename VISU::TL::TEnum2VTKArrayType< points_type >::TResult TVTKDataArray;
+    typedef typename VISU::TL::TEnum2VTKBasicType< points_type >::TResult TPointsDataType;
+    TVTKDataArray* anInputPointsArray = TVTKDataArray::SafeDownCast( anInputPoints->GetData() );
+    TVTKDataArray* anOutputPointsArray = TVTKDataArray::SafeDownCast( aPoints->GetData() );
+    
+    vtkPointData *anInputPointData = theInput->GetPointData();
+    vtkPointData *aPointData = theOutput->GetPointData();
+    aPointData->Allocate( aNbPoints );
+    
+    aConnectivity->InitTraversal();
+    vtkIdType aNbPts = 0, *aPts = 0;
+    for ( vtkIdType aCellId = 0; aConnectivity->GetNextCell( aNbPts, aPts ); aCellId++ ) {
+      for ( vtkIdType aPntId = 0; aPntId < aNbPts; aPntId++ ) {
+       TPointsDataType aCoords[ 3 ];
+       vtkIdType aCurrentPntId = aPts[ aPntId ];
+       anInputPointsArray->GetTupleValue( aCurrentPntId, aCoords );
+       TElnoDataType* anElnoData = aGetElnoNodeData( aCellId, aCurrentPntId );
+       
+       for ( vtkIdType aDimId = 0; aDimId < aNbDim; aDimId++ )
+         aCoords[ aDimId ] += TPointsDataType( aScaleFactor * anElnoData[ aDimId ] );
+       
+       aPts[ aPntId ] = anOutputPointsArray->InsertNextTupleValue( aCoords );
+       aPointData->CopyData( anInputPointData, aCurrentPntId, aPts[ aPntId ] );
+      }
+    }
+    
+    theOutput->SetPoints( aPoints );
+    
+    theOutput->SetCells( theInput->GetCellTypesArray(), 
+                        theInput->GetCellLocationsArray(),
+                        aConnectivity );
+    
+    theOutput->GetCellData()->PassData( theInput->GetCellData() );
+    
+    return 1;
+  }
+          
+
+  //----------------------------------------------------------------------------
+  template < int points_type >
+  int ElnoWarpVectorExecute( VISU_ElnoWarpVector *self, 
+                            vtkUnstructuredGrid *theInput, 
+                            vtkUnstructuredGrid *theOutput, 
+                            vtkDataArray *theElnoDataArray,
+                            vtkIntArray *theElnoDataMapper )
+  {
+    switch( theElnoDataArray->GetDataType() ){
+    case VTK_DOUBLE:
+      return ElnoWarpVectorExecute2< points_type, VTK_DOUBLE >( self, 
+                                                               theInput, 
+                                                               theOutput, 
+                                                               theElnoDataArray, 
+                                                               theElnoDataMapper );
+    case VTK_FLOAT:
+      return ElnoWarpVectorExecute2< points_type, VTK_FLOAT >( self, 
+                                                              theInput, 
+                                                              theOutput, 
+                                                              theElnoDataArray, 
+                                                              theElnoDataMapper );
+    case VTK_INT:
+      return ElnoWarpVectorExecute2< points_type, VTK_INT >( self, 
+                                                            theInput, 
+                                                            theOutput, 
+                                                            theElnoDataArray, 
+                                                            theElnoDataMapper );
+    case VTK_LONG:
+      return ElnoWarpVectorExecute2< points_type, VTK_LONG >( self, 
+                                                             theInput, 
+                                                             theOutput, 
+                                                             theElnoDataArray, 
+                                                             theElnoDataMapper );
+    default:
+      break;
+    }
+    
+    return 0;
+  } 
+
+
+  //----------------------------------------------------------------------------
+}
+
+
+//----------------------------------------------------------------------------
+int VISU_ElnoWarpVector::RequestData( vtkInformation *vtkNotUsed(request),
+                                     vtkInformationVector **inputVector,
+                                     vtkInformationVector *outputVector )
+{
+  // get the info objects
+  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+  vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+  // get the input and ouptut
+  vtkUnstructuredGrid *anInput =
+    vtkUnstructuredGrid::SafeDownCast( inInfo->Get( vtkDataObject::DATA_OBJECT() ) );
+  vtkUnstructuredGrid *anOutput = 
+    vtkUnstructuredGrid::SafeDownCast( outInfo->Get( vtkDataObject::DATA_OBJECT() ) );
+
+  vtkDataArray *anElnoDataArray = this->GetInputArrayToProcess( 0, inputVector );
+  vtkIntArray *anElnoDataMapper = 
+    vtkIntArray::SafeDownCast( this->GetInputArrayToProcess( 1, inputVector ) );
+
+  vtkPoints *aPoints = anInput->GetPoints();
+  switch( aPoints->GetDataType() ){
+  case VTK_DOUBLE:
+    return ::ElnoWarpVectorExecute< VTK_DOUBLE >( this, 
+                                                 anInput, 
+                                                 anOutput, 
+                                                 anElnoDataArray, 
+                                                 anElnoDataMapper );
+  case VTK_FLOAT:
+    return ::ElnoWarpVectorExecute< VTK_FLOAT >( this, 
+                                                anInput, 
+                                                anOutput, 
+                                                anElnoDataArray, 
+                                                anElnoDataMapper );
+  case VTK_INT:
+    return ::ElnoWarpVectorExecute< VTK_INT >( this, 
+                                              anInput, 
+                                              anOutput, 
+                                              anElnoDataArray, 
+                                              anElnoDataMapper );
+  case VTK_LONG:
+    return ::ElnoWarpVectorExecute< VTK_LONG >( this, 
+                                               anInput, 
+                                               anOutput, 
+                                               anElnoDataArray, 
+                                               anElnoDataMapper );
+  default:
+    break;
+  }  
+  
+  return 0;
+}
+
+
+//----------------------------------------------------------------------------
diff --git a/src/PIPELINE/VISU_ElnoWarpVector.hxx b/src/PIPELINE/VISU_ElnoWarpVector.hxx
new file mode 100644 (file)
index 0000000..3047a72
--- /dev/null
@@ -0,0 +1,48 @@
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  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 VISU_ElnoWarpVector_H
+#define VISU_ElnoWarpVector_H
+
+#include <vtkUnstructuredGridAlgorithm.h>
+
+class VISU_ElnoWarpVector : public vtkUnstructuredGridAlgorithm
+{
+public:
+  typedef vtkUnstructuredGridAlgorithm Superclass;
+
+  static VISU_ElnoWarpVector *New();
+
+  //! Specify value to scale displacement.
+  void SetScaleFactor( vtkFloatingPointType theValue );
+  vtkFloatingPointType GetScaleFactor();
+
+protected:
+  VISU_ElnoWarpVector();
+  ~VISU_ElnoWarpVector();
+
+  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+  vtkFloatingPointType myScaleFactor;
+
+private:
+  VISU_ElnoWarpVector(const VISU_ElnoWarpVector&);  // Not implemented.
+  void operator=(const VISU_ElnoWarpVector&);  // Not implemented.
+};
+
+#endif