]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of the improvement 0016840 "EDF PAL 569: Cut plane on Deformed".
authorrnv <rnv@opencascade.com>
Wed, 25 Jun 2008 10:16:58 +0000 (10:16 +0000)
committerrnv <rnv@opencascade.com>
Wed, 25 Jun 2008 10:16:58 +0000 (10:16 +0000)
23 files changed:
idl/VISU_Gen.idl
src/CONVERTOR/VISU_MergeFilterUtilities.cxx
src/PIPELINE/Makefile.am
src/PIPELINE/VISU_CutLinesPL.cxx
src/PIPELINE/VISU_CutLinesPL.hxx
src/PIPELINE/VISU_CutPlanesPL.cxx
src/PIPELINE/VISU_CutPlanesPL.hxx
src/PIPELINE/VISU_DeformationPL.cxx [new file with mode: 0755]
src/PIPELINE/VISU_DeformationPL.hxx [new file with mode: 0755]
src/PIPELINE/VISU_OptionalDeformationPL.cxx [new file with mode: 0755]
src/PIPELINE/VISU_OptionalDeformationPL.hxx [new file with mode: 0755]
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI_CutPlanesDlg.cxx
src/VISUGUI/VisuGUI_CutPlanesDlg.h
src/VISU_I/Makefile.am
src/VISU_I/VISU_CutPlanes_i.cc
src/VISU_I/VISU_CutPlanes_i.hh
src/VISU_I/VISU_Deformation_i.cc [new file with mode: 0755]
src/VISU_I/VISU_Deformation_i.hh [new file with mode: 0755]
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_OptionalDeformation_i.cc [new file with mode: 0755]
src/VISU_I/VISU_OptionalDeformation_i.hh [new file with mode: 0755]
src/VISU_I/VISU_Result_i.cc

index f79261a4f844842df0eb5a6007420d4e31df6c6b..36b383b44d12a5a7ae49749a10b484e99ea12a83 100644 (file)
@@ -874,6 +874,61 @@ module VISU {
 
   };
 
+  //-------------------------------------------------------
+  /*! \brief Deformation interface
+   *
+   * This is base interface for building of the deformed presentations
+   */
+  interface Deformation{
+    /*!
+     * Sets the scale of the presentatable object.
+     * \param theScale Double value defining the scale of this presentable object.
+     */
+    void SetScale(in double theScale);
+
+    /*!
+     * Gets the scale of the presentatable object.
+     */
+    double GetScale();
+
+    /*!
+     * Sets the vectorial field
+     * \param theEntity    - entity of vectorial field
+     * \param theFieldName - the name of vectorial field
+     */
+    void SetVectorialField(in Entity theEntity,
+                          in string theFieldName);
+
+    /*!
+     * Get vectorial entity
+     */
+    Entity GetVectorialFieldEntity();
+
+    /*!
+     * Get scalar field name
+     */
+    string GetVectorialFieldName();
+    
+  };
+
+  //-------------------------------------------------------
+  /*! \brief OptionalDeformation interface
+   *
+   * This is interface for switch on/off of the deformation of the presentation
+   */
+  interface OptionalDeformation : Deformation{
+
+    /*!
+     * Sets the deformation flag of the presentatable object.
+     * \param theFlag Boolean value defining the deformation flag of this presentable object.
+     */
+    void UseDeformation(in boolean theFlag);
+
+    /*!
+     * Gets the deformation flag of the presentatable object.
+     */
+    boolean IsDeformed();
+  };
 
   //-------------------------------------------------------
   /*! \brief Scalar Map on Deformed shape presentation interface
@@ -1090,7 +1145,7 @@ module VISU {
    * consists of cutting your initial mesh by a definite number of planes. As the
    * result you will see these planes which will be cutted by the borders of the mesh.
    */
-  interface CutPlanes : ScalarMap {
+  interface CutPlanes : ScalarMap, OptionalDeformation {
     /*!
      * This enumeration contains a set of elements defining the type of orientation in 3D space
      * of the cut planes.
index 488463696a9adf42b87fd34be88e554c3e2f9f19..2d1eafc2f40da645af9d05b03c51a61cafddfa34 100644 (file)
@@ -81,6 +81,9 @@ namespace
       vtkCellData *anOutputCellData = theOutput->GetCellData();
       anOutputCellData->CopyAllocate(aCellData);
 
+      if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet)
+        anOutputCellData->CopyVectorsOff();
+
       vtkIdType aNbTuples = anIntersection.size();
       theOutput->Allocate(aNbTuples);
       vtkIdList *aCellIds = vtkIdList::New();
@@ -100,13 +103,68 @@ namespace
       aCellIds->Delete();
 
       theOutput->SetPoints(theInput->GetPoints());
+      
     }else{
       theOutput->CopyStructure(theInput);
       theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData());
     }
     theOutput->GetPointData()->ShallowCopy(theInput->GetPointData());
+    
+    //If need, copy vectors data.
+    if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
+      bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
+      bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
+      if(isVectorsOnCells) {
+        CopyVectorsOnCells(theVectorsDataSet,theOutput);
+      }
+      else if(isVectorsDataOnPoints){
+        CopyVectorsOnPoints(theVectorsDataSet,theOutput);
+      }
+    }
   }
   
+  void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet,
+                          vtkDataSet *theOutput)
+  {
+    vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors();
+    vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+    
+    //Clear output vector data
+    theOutput->GetCellData()->SetVectors(NULL);
+    
+    //Copy vectors data
+    vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+                                                TGetCellData(),
+                                                "VISU_CELLS_MAPPER");
+    
+    vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+                                               TGetCellData(),
+                                               "VISU_CELLS_MAPPER");
+    
+    TObjectIdArray anIntersection;
+    GetIntersection(anOutputIDMapper,
+                    anInputIDMapper,
+                    anIntersection);
+
+    vtkIdType aNbTuples = anIntersection.size();
+    anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+    anOutputVectors->SetNumberOfTuples(aNbTuples);
+    theOutput->GetCellData()->SetVectors(anOutputVectors);
+    anOutputVectors->Delete();
+    
+    TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+    GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+    
+    TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+    GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+
+    for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+      TObjectId &anObjectId = anIntersection[iTupleId];
+      vtkIdType anOutputCellId  = anOutputObjectId2TupleIdMap[anObjectId];
+      vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId];
+      anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId));
+    }
+  }
   
   //---------------------------------------------------------------
   template<class TDataSet>
@@ -200,7 +258,118 @@ namespace
       theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());
     }
     theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData());
+    
+    //If need, copy vectors data.
+    if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
+      bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
+      bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
+
+      //Merge cells if need
+      //rnv
+      if(!IsDifferent(theGeometryPointMapper, theDataPointMapper)){
+        vtkIntArray* theGeometryCellMapper = GetIDMapper(theVectorsDataSet,
+                                                         TGetCellData(),
+                                                         "VISU_CELLS_MAPPER");
+        
+        vtkIntArray* theDataCellMapper = GetIDMapper(theScalarsDataSet,
+                                                     TGetCellData(),
+                                                     "VISU_CELLS_MAPPER");
+        
+          
+        if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
+          TObjectIdArray anIntersection;
+          
+          GetIntersection(theGeometryCellMapper,
+                          theDataCellMapper,
+                          anIntersection);
+    
+          TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+          GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
+      
+          TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
+          GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
+      
+          vtkCellData *aCellData = theScalarsDataSet->GetCellData();
+          vtkCellData *anOutputCellData = theOutput->GetCellData();
+          anOutputCellData->CopyAllocate(aCellData);
+
+          vtkIdType aNbTuples = anIntersection.size();
+          theOutput->Allocate(aNbTuples);
+          vtkIdList *aCellIds = vtkIdList::New();
+          for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+            TObjectId& anObjectId = anIntersection[aTupleId];
+            vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
+            vtkCell *aCell = theInput->GetCell(aCellId);
+            aCellIds->Reset();
+            vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+            for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
+              aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
+            vtkIdType aCellType = theInput->GetCellType(aCellId);
+            vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+            vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
+            anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
+          }
+          aCellIds->Delete();
+          
+        }
+      }
+        
+      if(isVectorsOnCells) {
+        CopyVectorsOnCells(theVectorsDataSet,theOutput);
+      }
+      else if(isVectorsDataOnPoints){
+        CopyVectorsOnPoints(theVectorsDataSet,theOutput);
+      }
+    }
   }
+  
+  void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet,
+                          vtkDataSet *theOutput)
+  {
+    vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors();
+    
+    //Clear output vector data
+    theOutput->GetPointData()->SetVectors(NULL);
+    
+    vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+    
+    //Copy vectors data
+    vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+                                                TGetPointData(),
+                                                "VISU_POINTS_MAPPER");
+    
+    vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+                                               TGetPointData(),
+                                               "VISU_POINTS_MAPPER");
+    TObjectIdArray anIntersection;
+
+    GetIntersection(anOutputIDMapper,
+                    anInputIDMapper,
+                    anIntersection);
+    
+    vtkIdType aNbTuples = anIntersection.size();  
+    anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+    anOutputVectors->SetNumberOfTuples(aNbTuples);
+    
+    
+
+    TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+    GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+    
+    TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+    GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+    
+    for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+      TObjectId& anObjectId = anIntersection[iTupleId];
+      vtkIdType anOutputPointId  = anOutputObjectId2TupleIdMap[anObjectId];
+      vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId];
+      anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId));
+    }
+    
+    theOutput->GetPointData()->SetVectors(anOutputVectors);
+    anOutputVectors->Delete();
+  }
+  
 
   //---------------------------------------------------------------
   typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
index 5a3a130863474f816582d78820058f0e5e57dc0d..9fe94fa0909c01639a856dd56624517b69be7617 100644 (file)
@@ -67,7 +67,9 @@ salomeinclude_HEADERS= \
        VISUPipeline.hxx \
        VISU_LabelPointsFilter.hxx \
        VISU_ElnoDisassembleFilter.hxx \
-       VISU_ElnoAssembleFilter.hxx 
+       VISU_ElnoAssembleFilter.hxx \
+       VISU_DeformationPL.hxx \
+       VISU_OptionalDeformationPL.hxx 
 
 dist_libVisuPipeLine_la_SOURCES= \
        VISU_MapperHolder.cxx \
@@ -107,7 +109,9 @@ dist_libVisuPipeLine_la_SOURCES= \
        VISU_DeformedShapeAndScalarMapPL.cxx \
        VISU_LabelPointsFilter.cxx \
        VISU_ElnoDisassembleFilter.cxx \
-       VISU_ElnoAssembleFilter.cxx 
+       VISU_ElnoAssembleFilter.cxx \
+       VISU_DeformationPL.cxx \
+       VISU_OptionalDeformationPL.cxx
 
 libVisuPipeLine_la_CPPFLAGS= \
        $(VTK_INCLUDES) \
index 3bad32d187df31620c822023e025f48bab754d2a..dbd2243a9d6c187fcc665eccde8f4a881e5857d5 100644 (file)
@@ -100,6 +100,12 @@ VISU_CutLinesPL
   Modified();
 }
 
+vtkDataSet* 
+VISU_CutLinesPL
+::InsertCustomPL()
+{
+  return myAppendPolyData->GetOutput();
+}
 
 //----------------------------------------------------------------------------
 vtkFloatingPointType 
index 5811683414924df07c684056fe9484f6c03008cf..7ed0ecd83e5234791c692935f096c9d801a0a267 100644 (file)
@@ -64,6 +64,9 @@ public:
   void
   Init();
 
+  vtkDataSet*
+  InsertCustomPL();
+
   virtual
   void
   Update();
index 6928b49875f6adf5df5e73acebc18d1090623444..a8776eaf28dad097d9eb8041506c5f60c652d5cb 100644 (file)
 #include "VISU_FieldTransform.hxx"
 #include "VISU_PipeLineUtils.hxx"
 #include "VTKViewer_GeometryFilter.h"
+#include "VISU_MapperHolder.hxx"
+#include "VISU_DeformationPL.hxx"
 
 #include <vtkAppendPolyData.h>
 #include <vtkCutter.h>
 #include <vtkPlane.h>
 
+//#include <vtkUnstructuredGrid.h>
+
 static vtkFloatingPointType EPS = 1.0E-3;
 
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
 
 //----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_CutPlanesPL);
@@ -43,8 +53,11 @@ vtkStandardNewMacro(VISU_CutPlanesPL);
 
 //----------------------------------------------------------------------------
 VISU_CutPlanesPL
-::VISU_CutPlanesPL()
+::VISU_CutPlanesPL():
+  VISU_OptionalDeformationPL()
 {
+  if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::VISU_CutPlanesPL() - "<<this);
+  
   SetIsShrinkable(false);
 
   SetElnoDisassembleState( true );
@@ -60,6 +73,7 @@ VISU_CutPlanesPL
 
   myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
   myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
+  UseDeformation(false);
 }
 
 
@@ -67,6 +81,7 @@ VISU_CutPlanesPL
 VISU_CutPlanesPL
 ::~VISU_CutPlanesPL()
 {
+  if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::~VISU_CutPlanesPL() - "<<this);
   myAppendPolyData->Delete();
   myAppendPolyData = NULL;
 }
@@ -78,7 +93,11 @@ VISU_CutPlanesPL
 ::GetMTime()
 {
   unsigned long int aTime = Superclass::GetMTime();
-
+  
+  if(IsDeformed()) {
+    aTime = std::max(aTime, VISU_OptionalDeformationPL::GetMTime());
+  }
+  
   aTime = std::max(aTime, myAppendPolyData->GetMTime());
 
   return aTime;
@@ -115,11 +134,11 @@ VISU_CutPlanesPL
 ::Init()
 {
   Superclass::Init();
-
   SetNbParts(10);
   myBasePlane[0] = YZ;
   myDisplacement[0] = 0.5;
   myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
+  SetScale(VISU_DeformationPL::GetDefaultScaleFactor(this));
 }
 
 
@@ -128,7 +147,7 @@ vtkDataSet*
 VISU_CutPlanesPL
 ::InsertCustomPL()
 {
-  return myAppendPolyData->GetOutput();
+  return GetWarpVectorOutput();
 }
 
 
@@ -139,18 +158,32 @@ VISU_CutPlanesPL
 {
   ClearAppendPolyData(myAppendPolyData);
 
-  SetPartPosition();
 
+  if(!myVectorialField || !IsDeformed()){
+    SetMergeFilterInput(GetMergedInput(),GetMergedInput());
+  }
+  
+
+  if(VISU::IsDataOnCells(GetMergedInput()))
+    GetMapper()->SetScalarModeToUseCellData();
+  else
+    GetMapper()->SetScalarModeToUsePointData();
+
+  SetPartPosition();
+  
   vtkFloatingPointType aDir[3];
   GetDir(aDir, 
         myAng[0], 
         myBasePlane[0]);
-
+  
   vtkFloatingPointType aBounds[6];
-  GetMergedInput()->GetBounds(aBounds);
+
+  vtkDataSet* aFilterOutput = GetMergeFilterOutput();
+  
+  aFilterOutput->GetBounds(aBounds);
 
   CutWithPlanes(myAppendPolyData,
-               GetMergedInput(),
+                aFilterOutput,
                myNbParts,
                aDir,
                aBounds,
@@ -158,6 +191,9 @@ VISU_CutPlanesPL
                myPartCondition, 
                myDisplacement[0]);
 
+  
+
+  SetWarpVectorInput(myAppendPolyData->GetOutput());
   Superclass::Update();
 }
 
@@ -414,7 +450,11 @@ VISU_CutPlanesPL
   vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
   if(myPartCondition[thePartNumber]){
       vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
-      GetMergedInput()->GetBounds(aBounds);
+      if(!IsDeformed()) 
+        GetMergedInput()->GetBounds(aBounds);
+      else
+        GetMergeFilterOutput()->GetBounds(aBounds);
+
 
       GetDir(aDir,
             myAng[theNum],
@@ -566,3 +606,33 @@ VISU_CutPlanesPL
 
 
 //----------------------------------------------------------------------------
+void
+VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper)
+{  
+  if(myVectorialField == theMapper)
+    return;
+
+  if(CheckCanDeformate(theMapper->GetOutput())){
+    myVectorialField = theMapper;
+    
+    SetMergeFilterInput(GetMergedInput(),theMapper->GetOutput());
+  }
+  else
+    UseDeformation(false);
+  
+  Modified();
+}
+
+//----------------------------------------------------------------------------
+VISU::PUnstructuredGridIDMapper VISU_CutPlanesPL::
+getVectorialField()
+{
+  return myVectorialField;
+}
+
+//----------------------------------------------------------------------------
+void VISU_CutPlanesPL::SetMapScale(vtkFloatingPointType theMapScale){
+  Superclass::SetMapScale(theMapScale);
+  if(IsDeformed())
+    VISU_OptionalDeformationPL::SetMapScale(theMapScale);
+}
index 27d377fd8971d3ecac67413a3a3f132c601d419f..054b8761deae1b9e8910131484264b8515b68d41 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "VISUPipeline.hxx"
 #include "VISU_ScalarMapPL.hxx"
+#include "VISU_OptionalDeformationPL.hxx"
+#include "VISU_MapperHolder.hxx"
 
 #include <vector>
 
@@ -36,7 +38,8 @@ class vtkAppendPolyData;
 
 
 //----------------------------------------------------------------------------
-class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL
+class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL,
+                                              public VISU_OptionalDeformationPL
 {
 public:
   vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL);
@@ -182,6 +185,14 @@ public:
                const std::vector<int>& thePlaneCondition,
                vtkFloatingPointType theDisplacement);
 
+  virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper);
+  VISU::PUnstructuredGridIDMapper getVectorialField();
+
+  virtual
+  void
+  SetMapScale(vtkFloatingPointType theMapScale = 1.0);
+
+
 protected:
   VISU_CutPlanesPL();
 
diff --git a/src/PIPELINE/VISU_DeformationPL.cxx b/src/PIPELINE/VISU_DeformationPL.cxx
new file mode 100755 (executable)
index 0000000..2189b22
--- /dev/null
@@ -0,0 +1,163 @@
+//  Copyright (C) 2008  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_ScalarMapPL.cxx
+// Author:  Roman NIKOLAEV
+// Module : VISU
+
+//Salome includes
+#include "VISU_DeformationPL.hxx"
+#include "VISU_MergeFilter.hxx"
+#include "VISU_DeformedShapePL.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+//VTK includes
+#include <vtkDataSet.h>
+#include <vtkPassThroughFilter.h>
+#include <vtkWarpVector.h>
+#include <vtkCellDataToPointData.h>
+#include <vtkUnstructuredGrid.h>
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+VISU_DeformationPL::VISU_DeformationPL():
+  myScaleFactor(1.0),
+  myMapScaleFactor(1.0)
+{
+  if(MYDEBUG) MESSAGE("VISU_DeformationPL()::VISU_DeformationPL() - "<<this);
+  myWarpVector = vtkWarpVector::New();
+  myWarpVector->SetScaleFactor(myScaleFactor);
+  
+  myVectorMergeFilter = VISU_MergeFilter::New();
+  myVectorMergeFilter->SetMergingInputs(true);
+  myInputPassFilter = vtkPassThroughFilter::New();
+  myOutputPassFiler = vtkPassThroughFilter::New();
+  myCellDataToPointData = vtkCellDataToPointData::New();
+  myCellDataToPointData->PassCellDataOn();
+
+  myInputPassFilter->SetInput(vtkUnstructuredGrid::New());
+
+  myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
+
+  myWarpVector->SetInput(myCellDataToPointData->GetOutput());
+  
+  myOutputPassFiler->SetInput(myWarpVector->GetOutput());
+}
+
+//----------------------------------------------------------------------------
+VISU_DeformationPL::~VISU_DeformationPL()
+{
+  if(MYDEBUG) MESSAGE("VISU_DeformationPL()::~VISU_DeformationPL() - "<<this);
+  myWarpVector->Delete();
+  myVectorMergeFilter->Delete();
+  myInputPassFilter->Delete();
+  myOutputPassFiler->Delete();
+  myCellDataToPointData->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int 
+VISU_DeformationPL::GetMTime(){
+  unsigned long int aTime = std::max(myWarpVector->GetMTime(), 
+                                     myVectorMergeFilter->GetMTime());
+
+  aTime = std::max(aTime,myInputPassFilter->GetMTime());
+  aTime = std::max(aTime,myOutputPassFiler->GetMTime());
+  aTime = std::max(aTime,myCellDataToPointData->GetMTime());
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetScale(vtkFloatingPointType theScaleFactor)
+{
+  if(myScaleFactor == theScaleFactor)
+    return;
+  myScaleFactor = theScaleFactor;
+  myWarpVector->SetScaleFactor(myScaleFactor*myMapScaleFactor);
+}
+
+void VISU_DeformationPL::SetMapScale(vtkFloatingPointType theMapScaleFactor)
+{
+  if(myMapScaleFactor == theMapScaleFactor)
+    return;
+  myMapScaleFactor = theMapScaleFactor;
+  
+  myWarpVector->SetScaleFactor(myScaleFactor*myMapScaleFactor);
+}
+
+
+vtkFloatingPointType VISU_DeformationPL::GetScale()
+{
+  return myScaleFactor;
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetWarpVectorInput(vtkDataSet *theInput)
+{
+  myInputPassFilter->SetInput(theInput);
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet* VISU_DeformationPL::GetWarpVectorOutput()
+{
+  return myOutputPassFiler->GetOutput();
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetMergeFilterInput(vtkDataSet* ScalarInput,
+                         vtkDataSet* VectorialInput)
+{
+  myVectorMergeFilter->SetScalars(ScalarInput);
+  myVectorMergeFilter->AddField("VISU_CELLS_MAPPER",ScalarInput);
+  myVectorMergeFilter->AddField("VISU_POINTS_MAPPER",ScalarInput);
+  
+  myVectorMergeFilter->SetGeometry(VectorialInput);
+  myVectorMergeFilter->SetVectors(VectorialInput);
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet* VISU_DeformationPL::GetMergeFilterOutput(){
+ return myVectorMergeFilter->GetOutput();
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType VISU_DeformationPL::GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine)
+{
+  if(!thePipeLine || !thePipeLine->GetMergeFilterOutput())
+    return 0.0;
+  
+  vtkFloatingPointType aSourceRange[2];
+  thePipeLine->GetMergeFilterOutput()->GetScalarRange(aSourceRange);
+  
+  static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
+  if(fabs(aSourceRange[1]) > EPS){
+    vtkDataSet* aDataSet = thePipeLine->GetMergeFilterOutput();
+    vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor(aDataSet);
+    return aScaleFactor / aSourceRange[1];
+  }
+  return 0.0;
+}
+
diff --git a/src/PIPELINE/VISU_DeformationPL.hxx b/src/PIPELINE/VISU_DeformationPL.hxx
new file mode 100755 (executable)
index 0000000..e18f43e
--- /dev/null
@@ -0,0 +1,87 @@
+//  Copyright (C) 2008  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_DeformationPL.hxx
+//  Author : 
+//  Module : SALOME
+
+#ifndef VISU_DeformationPL_HeaderFile
+#define VISU_DeformationPL_HeaderFile
+
+#include "VISUPipeline.hxx"
+#include "VISU_MapperHolder.hxx"
+#include <vtkSmartPointer.h>
+
+class vtkDataSet;
+class VISU_MergeFilter;
+class vtkPassThroughFilter;
+class vtkWarpVector;
+class vtkCellDataToPointData;
+
+class VISU_PIPELINE_EXPORT VISU_DeformationPL {
+  
+public:
+  VISU_DeformationPL();
+  virtual ~VISU_DeformationPL();
+
+  //-----------------------------------------------------------
+  virtual void SetScale(vtkFloatingPointType theScaleFactor);
+  virtual void SetMapScale(vtkFloatingPointType theMapScaleFactor);
+  virtual vtkFloatingPointType GetScale();
+
+  //-----------------------------------------------------------
+  virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper theIdMapper) = 0;
+  virtual VISU::PUnstructuredGridIDMapper getVectorialField() = 0;
+
+
+  //-----------------------------------------------------------
+  virtual 
+  unsigned 
+  long int
+  GetMTime();
+
+  static vtkFloatingPointType GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine);
+
+  void SetWarpVectorInput(vtkDataSet *theInput);
+  vtkDataSet* GetWarpVectorOutput();
+
+  //-----------------------------------------------------------
+  void SetMergeFilterInput(vtkDataSet* ScalarInput,
+                           vtkDataSet* VectorialInput);
+
+  vtkDataSet* GetMergeFilterOutput();
+
+protected:
+
+  VISU::PUnstructuredGridIDMapper myVectorialField;
+  vtkWarpVector *myWarpVector;
+  vtkSmartPointer<VISU_MergeFilter> myVectorMergeFilter;
+  vtkPassThroughFilter *myInputPassFilter;
+  vtkPassThroughFilter *myOutputPassFiler;
+  vtkCellDataToPointData *myCellDataToPointData;
+
+private:
+  vtkFloatingPointType myScaleFactor;
+  vtkFloatingPointType myMapScaleFactor;
+
+};
+
+#endif
diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.cxx b/src/PIPELINE/VISU_OptionalDeformationPL.cxx
new file mode 100755 (executable)
index 0000000..a4bc455
--- /dev/null
@@ -0,0 +1,101 @@
+//  Copyright (C) 2008  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_ScalarMapPL.cxx
+// Author:  Roman NIKOLAEV
+// Module : VISU
+
+//Salome includes
+#include "VISU_OptionalDeformationPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+//VTK includes
+#include <vtkDataSet.h>
+#include <vtkPassThroughFilter.h>
+#include <vtkWarpVector.h>
+#include <vtkCellDataToPointData.h>
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+VISU_OptionalDeformationPL::VISU_OptionalDeformationPL():
+  VISU_DeformationPL(),
+  myIsDeformed(true)
+{
+    if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::VISU_OptionalDeformationPL() - "<<this);
+}
+
+//----------------------------------------------------------------------------
+VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL()
+{
+  if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::~VISU_OptionalDeformationPL() - "<<this);
+}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_OptionalDeformationPL::GetMTime(){
+  return Superclass::GetMTime();
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::UseDeformation(bool flag){
+  if(myIsDeformed == flag)
+    return;
+
+  myIsDeformed = flag;
+  if(myIsDeformed)
+    OnDeformation();
+  else
+    OffDeformation();
+}
+
+//----------------------------------------------------------------------------
+bool VISU_OptionalDeformationPL::IsDeformed(){
+  return myIsDeformed;
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::OnDeformation(){
+
+  myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
+  myWarpVector->SetInput(myCellDataToPointData->GetOutput());
+  myOutputPassFiler->SetInput(myWarpVector->GetOutput());
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::OffDeformation(){
+  myOutputPassFiler->SetInput(myInputPassFilter->GetOutput());
+}
+
+
+
+bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){
+  if(theInput) {
+    if(VISU::IsDataOnCells(theInput))
+      return theInput->GetCellData()->GetVectors() != NULL;
+    else if(VISU::IsDataOnPoints(theInput))
+      return theInput->GetPointData()->GetVectors() != NULL;
+  }
+  return false;
+}
diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.hxx b/src/PIPELINE/VISU_OptionalDeformationPL.hxx
new file mode 100755 (executable)
index 0000000..333da0c
--- /dev/null
@@ -0,0 +1,59 @@
+//  Copyright (C) 2008  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_OptionalDeformationPL.hxx
+//  Author : 
+//  Module : SALOME
+
+#ifndef VISU_OptionalDeformationPL_HeaderFile
+#define VISU_OptionalDeformationPL_HeaderFile
+
+#include "VISUPipeline.hxx"
+#include "VISU_DeformationPL.hxx"
+
+class VISU_PIPELINE_EXPORT VISU_OptionalDeformationPL: public VISU_DeformationPL
+{
+public:
+  VISU_OptionalDeformationPL();
+  virtual ~VISU_OptionalDeformationPL();
+
+  typedef VISU_DeformationPL Superclass;
+
+  void UseDeformation(bool flag);
+  bool IsDeformed();
+
+  virtual 
+  unsigned 
+  long int
+  GetMTime();
+
+protected:
+  bool CheckCanDeformate(vtkDataSet* theInput);
+
+private:
+  void OnDeformation();
+  void OffDeformation();
+
+private:
+  bool myIsDeformed;
+};
+
+#endif
index 087b4d9b38acb40b2fadf36095fb810e38a9c013..d91aef28f8af785e33569e8ee298a9c97d145735 100644 (file)
@@ -669,6 +669,15 @@ msgstr "Rotation around Z (X to Y):"
 msgid "VisuGUI_CutPlanesPane::LBL_ROTATION"
 msgstr "Rotations"
 
+msgid "VisuGUI_CutPlanesPane::LBL_DEFORMATION"
+msgstr "Deformation"
+
+msgid "VisuGUI_CutPlanesPane::LBL_DEFROMATION_VECT"
+msgstr "Vectors :"
+
+msgid "VisuGUI_CutPlanesPane::LBL_DEFROMATION_SCALE"
+msgstr "Scale Factor :"
+
 
 #: VisuGUI_DeformedShapeDlg.cxx
 
index bcc04d68d899058e86b99308286e043bd8dc88fa..1bb4f27030a2bbbb5a263e98e7d1e5fe6e6aa679 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "VISU_ColoredPrs3dFactory.hh"
 #include "VISU_CutPlanes_i.hh"
+#include "VISU_Result_i.hh"
 #include "VISU_CutPlanesPL.hxx"
 
 #include "OB_Browser.h"
@@ -68,6 +69,7 @@
 #include <vtkPolyData.h>
 #include <vtkAppendPolyData.h>
 #include <vtkDataSetMapper.h>
+#include <vtkDataSet.h>
 
 using namespace std;
 
@@ -145,6 +147,40 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
   QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
   myPosSpn = new QtxDblSpinBox( 0, 1, 0.1, this );
 
+  GDeformation = new QGroupBox (tr("LBL_DEFORMATION"), this, "GDeformation");
+  GDeformation->setCheckable(true);
+  GDeformation->setChecked(false);
+  GDeformation->setColumnLayout(0, Qt::Horizontal);
+  GDeformation->layout()->setSpacing( 0 );
+  GDeformation->layout()->setMargin( 0 );
+  QGridLayout* GDeformationLayout = new QGridLayout( GDeformation->layout() );
+  GDeformationLayout->setAlignment( Qt::AlignTop );
+  GDeformationLayout->setSpacing( 6 );
+  GDeformationLayout->setMargin( 11 );
+  connect(GDeformation, SIGNAL(toggled(bool)), this, SLOT(onDeformationCheck(bool)));
+
+  QLabel* LabelDeformation1 = new QLabel (tr("LBL_DEFROMATION_VECT"), GDeformation, "LabelDeformation1");
+  GDeformationLayout->addWidget( LabelDeformation1, 0, 0 );
+
+
+  myVectorialFieldCombo = new QComboBox (GDeformation,"myVectorialFieldCombo");
+  GDeformationLayout->addWidget( myVectorialFieldCombo, 0, 1 );
+
+  QLabel* LabelDeformation2 = new QLabel (tr("LBL_DEFROMATION_SCALE"), GDeformation, "LabelDeformation2");
+  GDeformationLayout->addWidget( LabelDeformation2, 1, 0 );
+  myScaleSpn = new QtxDblSpinBox (0.0, 1.0E+38, 0.1, GDeformation);
+  myScaleSpn->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+  GDeformationLayout->addWidget( myScaleSpn, 1, 1 );
+  connect(myVectorialFieldCombo,     SIGNAL(activated(int)), this, SLOT(onVectorialFieldChanged(int)));
+  connect(myScaleSpn, SIGNAL(valueChanged(double)), this, SLOT(onScaleFactorChanged(double)));
+
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
+  
+  myScaleSpn->setPrecision( aPrecision*(-1) );
+  myScaleSpn->setValue(0.1);
+
+
   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this);
   myPreviewCheck->setChecked(false);
   connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
@@ -157,7 +193,8 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
   TopLayout->setRowStretch ( 3, 3 );
   TopLayout->addWidget(aPosLbl, 4, 0 );
   TopLayout->addWidget(myPosSpn, 4, 1 );
-  TopLayout->addMultiCellWidget( myPreviewCheck, 5, 5, 0, 1 );
+  TopLayout->addMultiCellWidget( GDeformation, 5, 5, 0, 1 );
+  TopLayout->addMultiCellWidget( myPreviewCheck, 6, 6, 0, 1 );
 
   // signals and slots connections
   connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) );
@@ -187,31 +224,102 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs)
   setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
   setPlanePos(thePrs->GetOrientationType());
   myPosSpn->setValue(thePrs->GetDisplacement());
+  InitEntity2VectorialFieldsMap(thePrs);
+  InsertAllVectorialFields();
+  setScaleFactor(thePrs->GetScale());
+  if(myEntity2VectorialFields.size() < 1)
+    GDeformation->setDisabled(true);
+  else{
+    if(thePrs->IsDeformed()){
+      GDeformation->setChecked(true);
+      myVectorialFieldCombo->setCurrentText(thePrs->GetVectorialFieldName());
+    }
+  }
+    
   hasInit = true;
   // init table
   myCutPlanes = VISU::TSameAsFactory<VISU::TCUTPLANES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
   myCutPlanes->SameAs(thePrs);
   DrawTable();
-
+  
   // Draw Preview
   if (myPreviewCheck->isChecked()) {
     createPlanes();
   }
 }
 
+
+void VisuGUI_CutPlanesPane::InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs){
+
+  VISU::Result_var theResult = thePrs->GetResultObject();
+  VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(GetServant(theResult).in());
+  VISU::Result::Entities_var aEntities = aResult->GetEntities(thePrs->GetMeshName());
+  VISU::Result::TimeStampNumbers_var aScalarTimeStamp = aResult->GetTimeStampNumbers(thePrs->GetMeshName(),
+                                                                                     thePrs->GetEntity(),
+                                                                                     thePrs->GetFieldName());
+  CORBA::Long aTimeStampNumber = aScalarTimeStamp->length();
+  
+  for(size_t iEntity = 0; iEntity < aEntities->length(); iEntity++){
+    VISU::Entity aEntity = aEntities[iEntity];
+    VISU::Result::EntityNames_var aFields = aResult->GetFields(thePrs->GetMeshName(),aEntity);
+    for(size_t iField = 0; iField < aFields->length(); iField++){
+
+      TVectorialFieldsList aVectorialFields;
+      VISU::Result::TimeStampNumbers_var aTimeStamps =  aResult->GetTimeStampNumbers(thePrs->GetMeshName(),aEntity,aFields[iField] );
+      
+      if((aResult->GetNumberOfComponents(thePrs->GetMeshName(),aEntity,aFields[iField] ) > 1) &&
+         (aTimeStamps->length() >= aTimeStampNumber)){
+        aVectorialFields.push_back(QString(aFields[iField].in()));
+      }
+      if(aVectorialFields.size() > 0){
+        myEntity2VectorialFields.insert(TEntVectPair(aEntity,aVectorialFields));
+      }
+    }
+  }
+}
+
+void VisuGUI_CutPlanesPane::InsertAllVectorialFields(){
+  TEntity2VectorialFields::const_iterator aFieldIter = myEntity2VectorialFields.begin();
+  for( ;aFieldIter != myEntity2VectorialFields.end();aFieldIter++ ){
+    TVectorialFieldsList aVectorialFields = aFieldIter->second;
+    for(size_t iField = 0;iField < aVectorialFields.size(); iField++)
+      myVectorialFieldCombo->insertItem(aVectorialFields[iField]);
+  }
+}
+
+double VisuGUI_CutPlanesPane::getScaleFactor(){
+  return myScaleSpn->value();
+}
+
+void VisuGUI_CutPlanesPane::setScaleFactor(double theFactor){
+  double i=0.1;
+  while (1) { // Calculate Step & Precission
+    if ( int (theFactor/i) > 0)
+      break;
+    else {
+      i = i*0.1;
+    }
+  }
+
+  myScaleSpn->setLineStep(i);
+  myScaleSpn->setValue(theFactor);
+  
+}
+
+
 void VisuGUI_CutPlanesPane::createPlanes()
 {
   if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
   if (!myCutPlanes) return;
   if (myPreviewActor != 0) return;
 
-  vtkAppendPolyData* aPolyData = myCutPlanes->GetSpecificPL()->GetAppendPolyData();
-  if (!aPolyData->GetOutput()->GetNumberOfCells()) {
+  vtkDataSet* aDataSet = myCutPlanes->GetSpecificPL()->GetWarpVectorOutput();
+  if (!aDataSet->GetNumberOfCells()) {
     onPreviewCheck(false);
     return;
   }
   vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
-  aPlaneMapper->SetInput(aPolyData->GetOutput());
+  aPlaneMapper->SetInput(aDataSet);
   aPlaneMapper->ScalarVisibilityOff();
 
   myPreviewActor = SALOME_Actor::New();
@@ -235,6 +343,31 @@ int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs)
     else
       thePrs->SetDefault(i);
   }
+
+  thePrs->UseDeformation(GDeformation->isChecked());
+  
+  if(GDeformation->isChecked()){
+    TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin();
+    VISU::Entity anEntity;
+    QString aFieldName;
+    bool isInited = false;
+    for(;anIter != myEntity2VectorialFields.end();anIter++){
+      TVectorialFieldsList aFields = anIter->second;
+      for(int it = 0;it < aFields.size();it++)
+        if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){
+          anEntity = anIter->first;
+          aFieldName = aFields[it];
+          isInited = true;
+          break;
+        }
+      if(isInited)
+        break;
+    }
+    if(isInited)
+      thePrs->SetVectorialField(anEntity,aFieldName.latin1());
+    
+    thePrs->SetScale(myScaleSpn->value());
+  }
   return 1;
 }
 
@@ -303,6 +436,45 @@ void VisuGUI_CutPlanesPane::setRotation (const double r1, const double r2)
   Rot2->setValue( r2 );
 }
 
+void VisuGUI_CutPlanesPane::onScaleFactorChanged(double theFactor){
+  DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::onVectorialFieldChanged(int pos){
+  InitVectorialField();
+  DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::onDeformationCheck(bool Flag){
+  if(!myCutPlanes || !hasInit) return;
+  myCutPlanes->UseDeformation(Flag);
+  InitVectorialField();
+  DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::InitVectorialField(){
+  if(myCutPlanes->IsDeformed()){
+    TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin();
+    VISU::Entity anEntity;
+    QString aFieldName;
+    bool isInited = false;
+    for(;anIter != myEntity2VectorialFields.end();anIter++){
+      TVectorialFieldsList aFields = anIter->second;
+      for(int it = 0;it < aFields.size();it++)
+        if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){
+          anEntity = anIter->first;
+          aFieldName = aFields[it];
+          isInited = true;
+          break;
+        }
+      if(isInited)
+        break;
+    }
+    if(isInited)
+      myCutPlanes->SetVectorialField(anEntity,aFieldName.latin1());
+  }
+}
+
 /*!
   Draw the table of planes positions
 */
@@ -317,6 +489,7 @@ void VisuGUI_CutPlanesPane::DrawTable()
   myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
   myCutPlanes->SetNbPlanes(aNbPlanes);
   myCutPlanes->SetDisplacement(myPosSpn->value());
+  myCutPlanes->SetScale(getScaleFactor());
   if (aNbRows>0)
     for (int i = 0; i < aNbRows; ++i) {
       QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
@@ -537,7 +710,7 @@ void VisuGUI_CutPlanesDlg::initFromPrsObject ( VISU::ColoredPrs3d_i* thePrs,
   VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
 
   myCutPane->initFromPrsObject(myPrsCopy);
-
+  
   if( !theInit )
     return;
 
index 9b029d90c5981c47f7c4ab366bef9e70b69ff8cd..458433dde50903566970d43bb3bf9643226bfa28 100644 (file)
 #include <qradiobutton.h>
 #include <qtable.h>
 #include <qtabwidget.h>
+#include <qcombobox.h>
 
 #include <QtxDblSpinBox.h>
 
 #include "SALOMEconfig.h"
 #include CORBA_CLIENT_HEADER(VISU_Gen)
 
+#include <map>
+#include <vector>
+
+
 namespace VISU 
 {
   class CutPlanes_i;
+  class Result_i;
 };
 
 class SUIT_ViewWindow;
@@ -53,6 +59,7 @@ class SUIT_ViewManager;
 class SalomeApp_Module;
 class VisuGUI_InputPane;
 
+
 class VisuGUI_CutPlanesPane : public QFrame
 {
     Q_OBJECT
@@ -69,15 +76,30 @@ public:
     double getRotation1() {return Rot1->value();}
     double getRotation2() {return Rot2->value();}
 
+    double getScaleFactor();
+    void setScaleFactor(double factor);
+
     void initFromPrsObject(VISU::CutPlanes_i* thePrs);
     int storeToPrsObject(VISU::CutPlanes_i* thePrs);
 
 private:
+    
+    typedef std::vector<QString> TVectorialFieldsList;
+    typedef std::map<VISU::Entity, TVectorialFieldsList> TEntity2VectorialFields;
+    typedef std::pair<VISU::Entity,TVectorialFieldsList> TEntVectPair;
+    TEntity2VectorialFields myEntity2VectorialFields;
+
     void createPlanes();
     void deletePlanes();
 
+    void InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs);
+    void InsertAllVectorialFields();
+    void InitVectorialField();
+
+
     QLabel* LabelRot1;
     QLabel* LabelRot2;
+    QGroupBox* GDeformation;
     QSpinBox* nbPlan;
     QtxDblSpinBox* Rot1;
     QtxDblSpinBox* Rot2;
@@ -88,6 +110,8 @@ private:
     QTable* myPosTable;
     SALOME::GenericObjPtr<VISU::CutPlanes_i> myCutPlanes;
     QCheckBox* myPreviewCheck;
+    QComboBox* myVectorialFieldCombo;
+    QtxDblSpinBox* myScaleSpn;
     double          X1, X2;
     double          Y1, Y2;
     double          Z1, Z2;
@@ -102,6 +126,9 @@ private slots:
     void onValueChanged(int theRow, int theCol);
     void onRotation(double theValue);
     void onPreviewCheck(bool thePreview);
+    void onScaleFactorChanged(double);
+    void onDeformationCheck(bool);
+    void onVectorialFieldChanged(int);
 };
 
 
index 4e2d5ffb41be9e357db29c36c36831be1f9cfe54..20bff31863fd7f39d1ad968105b9cf21396ab119 100644 (file)
@@ -53,8 +53,11 @@ salomeinclude_HEADERS = \
        VISU_DeformedShapeAndScalarMap_i.hh \
        VISU_ColoredPrs3dFactory.hh \
        VISU_MonoColorPrs_i.hh \
+       VISU_Deformation_i.hh \
+       VISU_OptionalDeformation_i.hh \
        SALOME_GenericObjPointer.hh
 
+
 libVISUEngineImpl_la_SOURCES = \
        VISUConfig.cc \
        VISU_Result_i.cc \
@@ -87,6 +90,8 @@ libVISUEngineImpl_la_SOURCES = \
        VISU_PointMap3d_i.cc \
        VISU_DumpPython.cc \
        VISU_MonoColorPrs_i.cc \
+       VISU_Deformation_i.cc \
+       VISU_OptionalDeformation_i.cc \
        SALOME_GenericObjPointer.cc
 
 MOC_FILES = VISU_TimeAnimation_moc.cxx
index a0f724b7cdb0330ad02634f061ccd6cb2c6804f1..dfbb7d00707bd23b74feca7ec2feb5753edb1226 100644 (file)
@@ -25,6 +25,7 @@
 //  Module : VISU
 
 #include "VISU_CutPlanesPL.hxx"
+#include "VISU_Convertor.hxx"
 #include "VISU_Prs3dUtils.hh"
 #include "VISU_CutPlanes_i.hh"
 
@@ -41,6 +42,7 @@ static int MYDEBUG = 0;
 #endif
 
 
+
 //----------------------------------------------------------------------------
 size_t 
 VISU::CutPlanes_i
@@ -95,8 +97,12 @@ VISU::CutPlanes_i
 ::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
   ColoredPrs3d_i(thePublishInStudyMode),
   ScalarMap_i(thePublishInStudyMode),
-  myCutPlanesPL(NULL)
-{}
+  myCutPlanesPL(NULL),
+  Deformation_i(this),
+  OptionalDeformation_i(this)
+{
+  if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i()");
+}
 
 
 //----------------------------------------------------------------------------
@@ -131,6 +137,8 @@ VISU::CutPlanes_i
     if(aCondList[i].toInt() == 0)
       SetPlanePosition(i,aPosList[i].toDouble());
 
+  OptionalDeformation_i::RestoreDeformation(theSObject,theMap);
+  
   return this;
 }
 
@@ -152,6 +160,7 @@ void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
   }
   Storable::DataToStream( theStr, "myPlanePosition",  aStrPos.latin1());
   Storable::DataToStream( theStr, "myPlaneCondition", aStrCon.latin1());
+  OptionalDeformation_i::DeformationToStream(theStr);
 }
 
 
@@ -321,6 +330,7 @@ VISU::CutPlanes_i
   }else
     myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
 
+  InitDeformedPipeLine(myCutPlanesPL);
   TSuperClass::CreatePipeLine(myCutPlanesPL);
 }
 
@@ -348,3 +358,10 @@ VISU::CutPlanes_i
   return NULL;
 }
 
+void
+VISU::CutPlanes_i::
+SameAs(const Prs3d_i* theOrigin){
+  if(MYDEBUG) MESSAGE("CutPlanes_i::SameAs()");
+  TSuperClass::SameAs(theOrigin);
+  OptionalDeformation_i::SameAsDeformation(dynamic_cast<const Deformation_i*>(theOrigin));
+}
index 9386f9f3ea241aef07e830b6d8aeeb9dbcdf86ab..8a5f9355d9510828ba3c478b92509e46fb287650 100644 (file)
@@ -28,6 +28,7 @@
 #define VISU_CutPlanes_i_HeaderFile
 
 #include "VISU_ScalarMap_i.hh"
+#include "VISU_OptionalDeformation_i.hh"
 
 class VISU_CutPlanesPL;
 
@@ -35,7 +36,8 @@ namespace VISU
 {
   //----------------------------------------------------------------------------
   class VISU_I_EXPORT CutPlanes_i : public virtual POA_VISU::CutPlanes,
-                                   public virtual ScalarMap_i
+                                   public virtual ScalarMap_i,
+                                   public virtual OptionalDeformation_i
   {
     static int myNbPresent;
     CutPlanes_i(const CutPlanes_i&);
@@ -157,6 +159,10 @@ namespace VISU
     Restore(SALOMEDS::SObject_ptr theSObject,
            const Storable::TRestoringMap& theMap);
 
+    virtual 
+    void
+    SameAs(const Prs3d_i* theOrigin);
+
     //! Redefines VISU_ColoredPrs3d_i::CreateActor
     virtual 
     VISU_Actor* 
diff --git a/src/VISU_I/VISU_Deformation_i.cc b/src/VISU_I/VISU_Deformation_i.cc
new file mode 100755 (executable)
index 0000000..8f4c05b
--- /dev/null
@@ -0,0 +1,166 @@
+//  Copyright (C) 2008  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_Deformation_i.cc
+//  Author : 
+//  Module : VISU
+
+#include "VISU_Deformation_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Prs3dUtils.hh"
+
+#include "VISU_DeformationPL.hxx"
+#include "VISU_Convertor.hxx"
+#include "VISU_DeformationPL.hxx"
+#include "VISUConfig.hh"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+VISU::Deformation_i::Deformation_i(VISU::ColoredPrs3d_i *thePrs3d):
+  myColoredPrs3d(thePrs3d)
+{
+  if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()");
+}
+
+//---------------------------------------------------------------
+VISU::Deformation_i::~Deformation_i()
+{
+  if(MYDEBUG) MESSAGE("Deformation_i::~Deformation_i()");
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::SetScale(CORBA::Double theScale)
+{
+  if(MYDEBUG) MESSAGE("Deformation_i::SetScale()");
+
+  VISU::TSetModified aModified(GetColoredPrs3d());
+
+  ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, vtkFloatingPointType>
+                  (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale));
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
+  
+  if(MYDEBUG) MESSAGE("Deformation_i::InitDeformedPipeLine()");
+  myDeformationPL = theDeformedPipeLine;
+}
+
+//---------------------------------------------------------------
+CORBA::Double 
+VISU::Deformation_i
+::GetScale()
+{
+  if(MYDEBUG) MESSAGE("Deformation_i::GetScale()");
+  return GetSpecificDeformedPL()->GetScale();
+}
+
+//---------------------------------------------------------------
+VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){
+  return myVectorialEntity;
+}
+
+//---------------------------------------------------------------
+char* VISU::Deformation_i::GetVectorialFieldName(){
+  return CORBA::string_dup(myVectorialFieldName.c_str());
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::
+DeformationToStream(std::ostringstream& theStr)
+{
+  Storable::DataToStream(theStr,"myScaleFactor", GetScale());
+  Storable::DataToStream(theStr,"myVectorialField", GetVectorialFieldName());
+  Storable::DataToStream(theStr,"myVectorialEntiry", GetVectorialFieldEntity());
+
+}
+
+//---------------------------------------------------------------
+void
+VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+                                       const Storable::TRestoringMap& theMap)
+{
+  SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
+  VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt());
+  
+  SetVectorialField(anEntity,
+                   VISU::Storable::FindValue(theMap, "myVectorialField")); 
+}
+
+//---------------------------------------------------------------
+void
+VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
+  if(const Deformation_i* aPrs = dynamic_cast<const Deformation_i*>(aDeformedPrs)) {
+    Deformation_i* anOrigin = const_cast<Deformation_i*>(aPrs);
+    
+    CORBA::String_var aVectorialFieldName = anOrigin->GetVectorialFieldName();
+    VISU::Entity anEntity = anOrigin->GetVectorialFieldEntity();
+    this->SetVectorialField(anEntity,
+                           aVectorialFieldName);
+    this->SetScale(anOrigin->GetScale());
+  }
+}
+
+void VISU::Deformation_i::SetVectorialField(Entity theEntity, const char* theFieldName){
+  if(MYDEBUG) MESSAGE("CutPlanes_i::SetVectorialField()");
+
+  bool anIsModified = false;
+  if(!anIsModified)
+    anIsModified |= GetVectorialFieldEntity() != theEntity;
+  
+  if(!anIsModified)
+    anIsModified |= GetVectorialFieldName() != theFieldName;
+
+  if(!anIsModified)
+    return;
+
+  ColoredPrs3d_i *aColoredPrs = GetColoredPrs3d();
+  int aTimeStampNumber = aColoredPrs->GetTimeStampNumber();
+
+  VISU::TEntity aEntity = VISU::TEntity(theEntity);
+
+  VISU::Result_i::PInput anInput = aColoredPrs->GetCResult()->GetInput(aColoredPrs->GetCMeshName(),
+                                                                      theEntity,
+                                                                      theFieldName,
+                                                                      aTimeStampNumber);
+
+  PField aVectorialField = anInput->GetField(aColoredPrs->GetCMeshName(), aEntity, theFieldName);
+
+  VISU::PUnstructuredGridIDMapper anIDMapper = 
+    anInput->GetTimeStampOnMesh(aColoredPrs->GetCMeshName(),
+                               aEntity,
+                               theFieldName,
+                               aTimeStampNumber);
+  if(GetSpecificDeformedPL() && anIDMapper) {
+    ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, VISU::PUnstructuredGridIDMapper>
+                    (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper));
+    
+    VISU::TSetModified aModified(GetColoredPrs3d());
+    
+    myVectorialEntity = theEntity;
+    myVectorialFieldName = theFieldName;
+    myVectorialField = anIDMapper;
+  }
+};
diff --git a/src/VISU_I/VISU_Deformation_i.hh b/src/VISU_I/VISU_Deformation_i.hh
new file mode 100755 (executable)
index 0000000..821b273
--- /dev/null
@@ -0,0 +1,103 @@
+//  Copyright (C) 2008  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_Deformation_i.hxx
+//  Author : 
+//  Module : VISU
+
+#ifndef VISU_Deformation_i_HeaderFile
+#define VISU_Deformation_i_HeaderFile
+
+#include "VISU_I.hxx"
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_DeformationPL.hxx"
+
+
+
+namespace VISU{
+
+  class VISU_I_EXPORT Deformation_i : public virtual POA_VISU::Deformation
+  {
+    Deformation_i(const Deformation_i&);
+  public:
+    typedef VISU::Deformation TInterface;
+
+    Deformation_i(VISU::ColoredPrs3d_i* theColoredPrs3d);
+    virtual ~Deformation_i();
+
+    virtual 
+    void
+    SetScale(CORBA::Double theScale);
+
+    virtual
+    CORBA::Double 
+    GetScale();
+
+    virtual
+    void
+    DeformationToStream(std::ostringstream& theStr);
+
+    virtual
+    void
+    RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap);
+
+    virtual 
+    void 
+    SameAsDeformation(const Deformation_i *aDeformedPrs);
+
+    virtual
+    VISU::Entity
+    GetVectorialFieldEntity();
+
+    virtual
+    char* 
+    GetVectorialFieldName();
+
+    virtual void SetVectorialField(Entity theEntity, const char* theFieldName);
+
+  protected:
+    virtual
+    void
+    InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine);
+
+    VISU_DeformationPL*
+    GetSpecificDeformedPL() const
+    { 
+      return myDeformationPL; 
+    }
+
+    ColoredPrs3d_i* GetColoredPrs3d(){
+      return myColoredPrs3d;
+    }
+    
+    
+  private:
+    VISU_DeformationPL *myDeformationPL;
+
+    PField myVectorialField;
+    VISU::Entity myVectorialEntity;
+    std::string myVectorialFieldName;
+    ColoredPrs3d_i *myColoredPrs3d;
+    
+  };
+}
+
+#endif
index 84b03f05e72b253bf41bc1f7a0860608e63ea2bc..95e42818b8dd0183d544eb17e15c03c145adcae6 100644 (file)
@@ -652,6 +652,27 @@ namespace VISU
        theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
     }
 
+    theStr<<thePrefix<<theName<<".UseDeformation("<<GetBoolean(theServant->IsDeformed())<<")"<<endl;
+    if(theServant->IsDeformed()){
+      theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<<endl;
+      std::string aStringEntity;
+      VISU::Entity anEntity = theServant->GetVectorialFieldEntity();
+      switch(anEntity){
+      case NODE:
+       aStringEntity = "VISU.NODE";
+       break;
+      case EDGE:
+       aStringEntity = "VISU.EDGE";
+       break;
+      case FACE:
+       aStringEntity = "VISU.FACE";
+       break;
+      case CELL:
+       aStringEntity = "VISU.CELL";
+       break;
+      }
+      theStr<< thePrefix << theName << ".SetVectorialField("<<aStringEntity<<", '" << theServant->GetVectorialFieldName() <<"')"<<endl;
+    }
     return thePrefix;
   }
 
diff --git a/src/VISU_I/VISU_OptionalDeformation_i.cc b/src/VISU_I/VISU_OptionalDeformation_i.cc
new file mode 100755 (executable)
index 0000000..77a1229
--- /dev/null
@@ -0,0 +1,110 @@
+//  Copyright (C) 2008  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_OptionalDeformation_i.cc
+//  Author : 
+//  Module : VISU
+
+#include "VISU_OptionalDeformation_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Prs3dUtils.hh"
+#include "VISUConfig.hh"
+
+#include "VISU_OptionalDeformationPL.hxx"
+
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::ColoredPrs3d_i *theColoredPrs3d):
+  Deformation_i(theColoredPrs3d)
+{
+  if(MYDEBUG) MESSAGE("OptionalDeformation_i::OptionalDeformation_i()");
+}
+
+//---------------------------------------------------------------
+VISU::OptionalDeformation_i::~OptionalDeformation_i()
+{
+  if(MYDEBUG) MESSAGE("OptionalDeformation_i::~OptionalDeformation_i()");
+}
+
+//---------------------------------------------------------------
+void VISU::OptionalDeformation_i::UseDeformation(CORBA::Boolean theFlag){
+  if(MYDEBUG) MESSAGE("OptionalDeformation_i::UseDeformation()");
+
+  VISU::TSetModified aModified(GetColoredPrs3d());
+
+  ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_OptionalDeformationPL, bool>
+                  (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag));
+}
+
+//---------------------------------------------------------------
+CORBA::Boolean VISU::OptionalDeformation_i::IsDeformed(){
+
+  if(MYDEBUG) MESSAGE("OptionalDeformation_i::IsDeformed()");
+  return GetSpecificDeformedPL()->IsDeformed();
+}
+
+
+void VISU::OptionalDeformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
+
+  if(MYDEBUG) MESSAGE("OptionalDeformation_i::InitDeformedPipeLine()");
+  myOptionalDeformationPL = dynamic_cast<VISU_OptionalDeformationPL*>(theDeformedPipeLine);
+
+  TSuperClass::InitDeformedPipeLine(myOptionalDeformationPL);
+}
+
+//---------------------------------------------------------------
+void VISU::OptionalDeformation_i::
+DeformationToStream(std::ostringstream& theStr)
+{
+  Storable::DataToStream(theStr,"IsDeformed", IsDeformed());
+  if(IsDeformed())
+    TSuperClass::DeformationToStream(theStr);
+}
+
+//---------------------------------------------------------------
+void
+VISU::OptionalDeformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+                                               const Storable::TRestoringMap& theMap)
+{
+  UseDeformation(Storable::FindValue(theMap,"IsDeformed").toInt());
+  if(IsDeformed())
+    TSuperClass::RestoreDeformation(theSObject,theMap);
+}
+
+
+
+void 
+VISU::OptionalDeformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
+
+  if(const OptionalDeformation_i* aPrs3d = dynamic_cast<const OptionalDeformation_i*>(aDeformedPrs)){
+    OptionalDeformation_i* anOrigin = const_cast<OptionalDeformation_i*>(aPrs3d);
+    UseDeformation(anOrigin->IsDeformed());
+    
+    if(anOrigin->IsDeformed()){
+      TSuperClass::SameAsDeformation(aDeformedPrs);
+    }
+  }
+}
diff --git a/src/VISU_I/VISU_OptionalDeformation_i.hh b/src/VISU_I/VISU_OptionalDeformation_i.hh
new file mode 100755 (executable)
index 0000000..ac6a08f
--- /dev/null
@@ -0,0 +1,76 @@
+//  Copyright (C) 2008  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_Deformation_i.hxx
+//  Author : 
+//  Module : VISU
+
+#ifndef VISU_OptionalDeformation_i_HeaderFile
+#define VISU_OptionalDeformation_i_HeaderFile
+
+#include "VISU_I.hxx"
+#include "VISU_Deformation_i.hh"
+#include "VISU_OptionalDeformationPL.hxx"
+
+namespace VISU {
+  class VISU_I_EXPORT OptionalDeformation_i : public virtual POA_VISU::OptionalDeformation,
+                                             public virtual Deformation_i
+  {
+    OptionalDeformation_i(const OptionalDeformation_i&);
+  public:
+    typedef VISU::OptionalDeformation TInterface;
+    typedef Deformation_i TSuperClass;
+
+    OptionalDeformation_i(VISU::ColoredPrs3d_i* theModifiedEngine);
+    virtual ~OptionalDeformation_i();
+    
+    virtual void UseDeformation(CORBA::Boolean theFlag);
+    virtual CORBA::Boolean IsDeformed();
+
+
+    virtual
+    void
+    DeformationToStream(std::ostringstream& theStr);
+
+    virtual
+    void
+    RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap);
+
+    virtual 
+    void 
+    SameAsDeformation(const Deformation_i *aDeformedPrs);
+
+  protected:
+    virtual
+    void InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine);
+
+    VISU_OptionalDeformationPL*
+    GetSpecificDeformedPL() const
+    { 
+      return myOptionalDeformationPL;
+    }
+    
+  private:
+    VISU_OptionalDeformationPL* myOptionalDeformationPL;
+    
+  };
+}
+#endif
index 67e6c7111fb06cd33da79f96f33bfa5f286bb2b2..07bac9ec37d8037e3918f25730b77e1c92e0f4c8 100644 (file)
@@ -1002,7 +1002,7 @@ VISU::Result_i
 
   {
     anEntities->length(aMeshOnEntityMap.size());
-    VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.end();
+    VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
     for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
       const VISU::TEntity& anEntity = anIter->first;
       anEntities[anId] = VISU::Entity(anEntity);
@@ -1046,7 +1046,7 @@ VISU::Result_i
     
     {
       aResult->length(aFamilyMap.size());
-      VISU::TFamilyMap::const_iterator anIter = aFamilyMap.end();
+      VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
       for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
        const std::string& aName = anIter->first;
        aResult[anId] = aName.c_str();
@@ -1079,7 +1079,7 @@ VISU::Result_i
 
   {
     aResult->length(aGroupMap.size());
-    VISU::TGroupMap::const_iterator anIter = aGroupMap.end();
+    VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
     for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
       const std::string& aName = anIter->first;
       aResult[anId] = aName.c_str();
@@ -1123,7 +1123,7 @@ VISU::Result_i
     
     {
       aResult->length(aFieldMap.size());
-      VISU::TFieldMap::const_iterator anIter = aFieldMap.end();
+      VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
       for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
        const std::string& aName = anIter->first;
        aResult[anId] = aName.c_str();
@@ -1180,7 +1180,7 @@ VISU::Result_i
 
        {
          aResult->length(aValField.size());
-         VISU::TValField::const_iterator anIter = aValField.end();
+         VISU::TValField::const_iterator anIter = aValField.begin();
          for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
            const vtkIdType& aTimeStampNumber = anIter->first;
            aResult[anId] = aTimeStampNumber;