]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Improve the "Cut Planes on Deformed" functionality. BR_Deformed_CutPlanes
authorrnv <rnv@opencascade.com>
Fri, 6 Jun 2008 08:18:18 +0000 (08:18 +0000)
committerrnv <rnv@opencascade.com>
Fri, 6 Jun 2008 08:18:18 +0000 (08:18 +0000)
src/PIPELINE/VISU_CutPlanesPL.cxx
src/PIPELINE/VISU_CutPlanesPL.hxx
src/PIPELINE/VISU_DeformationPL.cxx
src/PIPELINE/VISU_DeformationPL.hxx
src/PIPELINE/VISU_OptionalDeformationPL.cxx
src/VISU_I/VISU_CutPlanes_i.cc
src/VISU_I/VISU_CutPlanes_i.hh
src/VISU_I/VISU_Deformation_i.cc
src/VISU_I/VISU_Deformation_i.hh
src/VISU_I/VISU_OptionalDeformation_i.cc
src/VISU_I/VISU_OptionalDeformation_i.hh

index 796e3f4e6c84c7ba7ea7c9a3070511271b2cfd44..8ec23c7658d9eecdddfde5168722807a46f5f60d 100644 (file)
@@ -56,6 +56,8 @@ VISU_CutPlanesPL
 ::VISU_CutPlanesPL():
   VISU_OptionalDeformationPL()
 {
+  if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::VISU_CutPlanesPL() - "<<this);
+  
   SetIsShrinkable(false);
 
   myAppendPolyData = vtkAppendPolyData::New();
@@ -77,6 +79,7 @@ VISU_CutPlanesPL
 VISU_CutPlanesPL
 ::~VISU_CutPlanesPL()
 {
+  if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::~VISU_CutPlanesPL() - "<<this);
   myAppendPolyData->Delete();
   myAppendPolyData = NULL;
 }
@@ -173,10 +176,12 @@ VISU_CutPlanesPL
   
   vtkFloatingPointType aBounds[6];
 
-  GetMergeFilterOutput()->GetBounds(aBounds);
+  vtkDataSet* aFilterOutput = GetMergeFilterOutput();
+  
+  aFilterOutput->GetBounds(aBounds);
 
   CutWithPlanes(myAppendPolyData,
-               GetMergeFilterOutput(),
+                aFilterOutput,
                myNbParts,
                aDir,
                aBounds,
@@ -599,7 +604,6 @@ VISU_CutPlanesPL
 
 
 //----------------------------------------------------------------------------
-
 void
 VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper)
 {  
@@ -617,8 +621,16 @@ VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper)
   Modified();
 }
 
+//----------------------------------------------------------------------------
 VISU::PUnstructuredGridIDMapper VISU_CutPlanesPL::
 getVectorialField()
 {
   return myVectorialField;
 }
+
+//----------------------------------------------------------------------------
+void VISU_CutPlanesPL::SetMapScale(vtkFloatingPointType theMapScale){
+  Superclass::SetMapScale(theMapScale);
+  if(IsDeformed())
+    VISU_OptionalDeformationPL::SetMapScale(theMapScale);
+}
index 2e7845750cca8017d2f1142a92c1443a77879863..054b8761deae1b9e8910131484264b8515b68d41 100644 (file)
@@ -188,6 +188,11 @@ public:
   virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper);
   VISU::PUnstructuredGridIDMapper getVectorialField();
 
+  virtual
+  void
+  SetMapScale(vtkFloatingPointType theMapScale = 1.0);
+
+
 protected:
   VISU_CutPlanesPL();
 
index d222fd468ec4edfe898e1a8543ebacfbac89ce2c..2189b2287df0e7baf464e8939673620c531ad360 100755 (executable)
@@ -26,6 +26,8 @@
 //Salome includes
 #include "VISU_DeformationPL.hxx"
 #include "VISU_MergeFilter.hxx"
+#include "VISU_DeformedShapePL.hxx"
+#include "VISU_PipeLineUtils.hxx"
 
 //VTK includes
 #include <vtkDataSet.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()
+VISU_DeformationPL::VISU_DeformationPL():
+  myScaleFactor(1.0),
+  myMapScaleFactor(1.0)
 {
+  if(MYDEBUG) MESSAGE("VISU_DeformationPL()::VISU_DeformationPL() - "<<this);
   myWarpVector = vtkWarpVector::New();
-  myWarpVector->SetScaleFactor(0.0);
+  myWarpVector->SetScaleFactor(myScaleFactor);
   
   myVectorMergeFilter = VISU_MergeFilter::New();
   myVectorMergeFilter->SetMergingInputs(true);
@@ -60,6 +70,7 @@ VISU_DeformationPL::VISU_DeformationPL()
 //----------------------------------------------------------------------------
 VISU_DeformationPL::~VISU_DeformationPL()
 {
+  if(MYDEBUG) MESSAGE("VISU_DeformationPL()::~VISU_DeformationPL() - "<<this);
   myWarpVector->Delete();
   myVectorMergeFilter->Delete();
   myInputPassFilter->Delete();
@@ -82,12 +93,25 @@ VISU_DeformationPL::GetMTime(){
 //----------------------------------------------------------------------------
 void VISU_DeformationPL::SetScale(vtkFloatingPointType theScaleFactor)
 {
-  myWarpVector->SetScaleFactor(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 myWarpVector->GetScaleFactor();
+  return myScaleFactor;
 }
 
 //----------------------------------------------------------------------------
@@ -131,33 +155,9 @@ vtkFloatingPointType VISU_DeformationPL::GetDefaultScaleFactor(VISU_DeformationP
   static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
   if(fabs(aSourceRange[1]) > EPS){
     vtkDataSet* aDataSet = thePipeLine->GetMergeFilterOutput();
-    vtkFloatingPointType aScaleFactor = VISU_DeformationPL::ComputeScaleFactor(aDataSet);
+    vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor(aDataSet);
     return aScaleFactor / aSourceRange[1];
   }
   return 0.0;
 }
 
-//----------------------------------------------------------------------------
-vtkFloatingPointType VISU_DeformationPL::ComputeScaleFactor(vtkDataSet* theDataSet)
-{
-  if(!theDataSet)
-    return 0.0;
-
-  theDataSet->Update();
-  
-  int aNbCells = theDataSet->GetNumberOfCells();
-  int aNbPoints = theDataSet->GetNumberOfPoints();
-  int aNbElem = aNbCells? aNbCells: aNbPoints;
-  
-  vtkFloatingPointType* aBounds = theDataSet->GetBounds();
-  vtkFloatingPointType aVolume = 1, aVol, idim = 0;
-  for(int i = 0; i < 6; i += 2){
-    aVol = fabs(aBounds[i+1] - aBounds[i]);
-    if(aVol > 0) {
-      idim++;
-      aVolume *= aVol;
-    }
-  }
-  aVolume /= aNbElem;
-  return pow(aVolume, vtkFloatingPointType(1.0/idim));
-}
index 2521ec87cd08eeca2e8e130512a875a1fb2f1aae..e18f43e3fab84b3186e3a0bae3be051cab32de60 100755 (executable)
@@ -44,6 +44,7 @@ public:
 
   //-----------------------------------------------------------
   virtual void SetScale(vtkFloatingPointType theScaleFactor);
+  virtual void SetMapScale(vtkFloatingPointType theMapScaleFactor);
   virtual vtkFloatingPointType GetScale();
 
   //-----------------------------------------------------------
@@ -58,7 +59,6 @@ public:
   GetMTime();
 
   static vtkFloatingPointType GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine);
-  static vtkFloatingPointType ComputeScaleFactor(vtkDataSet* theDataSet);
 
   void SetWarpVectorInput(vtkDataSet *theInput);
   vtkDataSet* GetWarpVectorOutput();
@@ -78,6 +78,10 @@ protected:
   vtkPassThroughFilter *myOutputPassFiler;
   vtkCellDataToPointData *myCellDataToPointData;
 
+private:
+  vtkFloatingPointType myScaleFactor;
+  vtkFloatingPointType myMapScaleFactor;
+
 };
 
 #endif
index 63f54df47dafe8022f4178b730af28b62730c887..a4bc4555af7738beb030858cfd73548ae411ba31 100755 (executable)
 #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(){
-
+VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL()
+{
+  if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::~VISU_OptionalDeformationPL() - "<<this);
 }
 
 //----------------------------------------------------------------------------
index 703b3d7d5fe9907bfdd4567f2bfda94977938e71..dfbb7d00707bd23b74feca7ec2feb5753edb1226 100644 (file)
@@ -365,39 +365,3 @@ SameAs(const Prs3d_i* theOrigin){
   TSuperClass::SameAs(theOrigin);
   OptionalDeformation_i::SameAsDeformation(dynamic_cast<const Deformation_i*>(theOrigin));
 }
-
-void VISU::CutPlanes_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;
-  
-  int aTimeStampNumber = GetTimeStampNumber();
-
-  VISU::TEntity aEntity = VISU::TEntity(theEntity);
-  VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
-                                                         theEntity,
-                                                         theFieldName,
-                                                         aTimeStampNumber);
-
-  PField aVectorialField = anInput->GetField(GetCMeshName(), aEntity, theFieldName);
-
-  VISU::PUnstructuredGridIDMapper anIDMapper = 
-    anInput->GetTimeStampOnMesh(GetCMeshName(),
-                               aEntity,
-                               theFieldName,
-                               aTimeStampNumber);
-  
-  SetVField(theEntity,
-          theFieldName,
-          anIDMapper,
-          aVectorialField);
-  
-};
index bf4b84a1c45e4d902a60b46f70c2b093d404a1e3..8a5f9355d9510828ba3c478b92509e46fb287650 100644 (file)
@@ -115,8 +115,6 @@ namespace VISU
     { 
       return myCutPlanesPL; 
     }
-
-    virtual void SetVectorialField(Entity theEntity, const char* theFieldName);
     
   protected:
     //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
index 7f777e195bb4d65c216ca1b1888e70a85262260a..8f4c05bc030c40a5ab7210882e2db9da8084254f 100755 (executable)
@@ -38,8 +38,8 @@ static int MYDEBUG = 0;
 #endif
 
 //---------------------------------------------------------------
-VISU::Deformation_i::Deformation_i(VISU::Prs3d_i *theModifiedEngine):
-  myModifiedEngine(theModifiedEngine)
+VISU::Deformation_i::Deformation_i(VISU::ColoredPrs3d_i *thePrs3d):
+  myColoredPrs3d(thePrs3d)
 {
   if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()");
 }
@@ -55,7 +55,7 @@ void VISU::Deformation_i::SetScale(CORBA::Double theScale)
 {
   if(MYDEBUG) MESSAGE("Deformation_i::SetScale()");
 
-  VISU::TSetModified aModified(GetModifiedEngine());
+  VISU::TSetModified aModified(GetColoredPrs3d());
 
   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, vtkFloatingPointType>
                   (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale));
@@ -77,28 +77,6 @@ VISU::Deformation_i
   return GetSpecificDeformedPL()->GetScale();
 }
 
-//---------------------------------------------------------------
-void VISU::
-Deformation_i::SetVField(VISU::Entity theEntity,
-                                const char* theFieldName,
-                                VISU::PUnstructuredGridIDMapper anIDMapper,
-                                PField theVectorialField)
-{
-  
-  if(MYDEBUG) MESSAGE("Deformation_i::SetVField()");
-  
-  
-  VISU::TSetModified aModified(GetModifiedEngine());
-  myVectorialField = theVectorialField;
-  if(GetSpecificDeformedPL() && anIDMapper)
-    ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, VISU::PUnstructuredGridIDMapper>
-                    (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper));
-  
-  myVectorialEntity = theEntity;
-  myVectorialFieldName = theFieldName;
-}
-
-
 //---------------------------------------------------------------
 VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){
   return myVectorialEntity;
@@ -122,7 +100,7 @@ DeformationToStream(std::ostringstream& theStr)
 //---------------------------------------------------------------
 void
 VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
-                            const Storable::TRestoringMap& theMap)
+                                       const Storable::TRestoringMap& theMap)
 {
   SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
   VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt());
@@ -144,3 +122,45 @@ VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
     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;
+  }
+};
index c574f3d46d651e14b8743f971ea9dc25eca14cbe..821b2735e149228d0f00541f2c348a83bd8b49ac 100755 (executable)
@@ -26,7 +26,7 @@
 #define VISU_Deformation_i_HeaderFile
 
 #include "VISU_I.hxx"
-#include "VISU_Prs3d_i.hh"
+#include "VISU_ColoredPrs3d_i.hh"
 #include "VISU_DeformationPL.hxx"
 
 
@@ -39,7 +39,7 @@ namespace VISU{
   public:
     typedef VISU::Deformation TInterface;
 
-    Deformation_i(Prs3d_i* theModifiedEngine);
+    Deformation_i(VISU::ColoredPrs3d_i* theColoredPrs3d);
     virtual ~Deformation_i();
 
     virtual 
@@ -71,6 +71,8 @@ namespace VISU{
     char* 
     GetVectorialFieldName();
 
+    virtual void SetVectorialField(Entity theEntity, const char* theFieldName);
+
   protected:
     virtual
     void
@@ -82,13 +84,8 @@ namespace VISU{
       return myDeformationPL; 
     }
 
-    void SetVField(VISU::Entity theEntity,
-                          const char* theFieldName,
-                          PUnstructuredGridIDMapper,
-                          PField theVectorialField);
-
-    Prs3d_i* GetModifiedEngine(){
-      return myModifiedEngine;
+    ColoredPrs3d_i* GetColoredPrs3d(){
+      return myColoredPrs3d;
     }
     
     
@@ -98,7 +95,7 @@ namespace VISU{
     PField myVectorialField;
     VISU::Entity myVectorialEntity;
     std::string myVectorialFieldName;
-    Prs3d_i *myModifiedEngine;
+    ColoredPrs3d_i *myColoredPrs3d;
     
   };
 }
index 380db3e46a06da723d683832c03bce5587929dd3..77a122982e71fb6027f26cccf114e1107b8f008b 100755 (executable)
@@ -37,8 +37,8 @@ static int MYDEBUG = 0;
 #endif
 
 //---------------------------------------------------------------
-VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::Prs3d_i *theModifiedEngine):
-  Deformation_i(theModifiedEngine)
+VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::ColoredPrs3d_i *theColoredPrs3d):
+  Deformation_i(theColoredPrs3d)
 {
   if(MYDEBUG) MESSAGE("OptionalDeformation_i::OptionalDeformation_i()");
 }
@@ -53,7 +53,7 @@ VISU::OptionalDeformation_i::~OptionalDeformation_i()
 void VISU::OptionalDeformation_i::UseDeformation(CORBA::Boolean theFlag){
   if(MYDEBUG) MESSAGE("OptionalDeformation_i::UseDeformation()");
 
-  VISU::TSetModified aModified(GetModifiedEngine());
+  VISU::TSetModified aModified(GetColoredPrs3d());
 
   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_OptionalDeformationPL, bool>
                   (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag));
index cfe3a71bde80d979e151e8206c42a59959bceda0..ac6a08ffd6ff4a4561b09d2b6e05797297368554 100755 (executable)
@@ -38,7 +38,7 @@ namespace VISU {
     typedef VISU::OptionalDeformation TInterface;
     typedef Deformation_i TSuperClass;
 
-    OptionalDeformation_i(Prs3d_i* theModifiedEngine);
+    OptionalDeformation_i(VISU::ColoredPrs3d_i* theModifiedEngine);
     virtual ~OptionalDeformation_i();
     
     virtual void UseDeformation(CORBA::Boolean theFlag);