From 9c22ce938994946d22bdcd2ec5a130fe97141011 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 6 Jun 2008 08:18:18 +0000 Subject: [PATCH] Improve the "Cut Planes on Deformed" functionality. --- src/PIPELINE/VISU_CutPlanesPL.cxx | 18 +++++- src/PIPELINE/VISU_CutPlanesPL.hxx | 5 ++ src/PIPELINE/VISU_DeformationPL.cxx | 58 ++++++++--------- src/PIPELINE/VISU_DeformationPL.hxx | 6 +- src/PIPELINE/VISU_OptionalDeformationPL.cxx | 14 +++- src/VISU_I/VISU_CutPlanes_i.cc | 36 ----------- src/VISU_I/VISU_CutPlanes_i.hh | 2 - src/VISU_I/VISU_Deformation_i.cc | 72 +++++++++++++-------- src/VISU_I/VISU_Deformation_i.hh | 17 ++--- src/VISU_I/VISU_OptionalDeformation_i.cc | 6 +- src/VISU_I/VISU_OptionalDeformation_i.hh | 2 +- 11 files changed, 122 insertions(+), 114 deletions(-) diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 796e3f4e..8ec23c76 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -56,6 +56,8 @@ VISU_CutPlanesPL ::VISU_CutPlanesPL(): VISU_OptionalDeformationPL() { + if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::VISU_CutPlanesPL() - "<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); +} diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 2e784575..054b8761 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -188,6 +188,11 @@ public: 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 index d222fd46..2189b228 100755 --- a/src/PIPELINE/VISU_DeformationPL.cxx +++ b/src/PIPELINE/VISU_DeformationPL.cxx @@ -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 @@ -33,13 +35,21 @@ #include #include #include +#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() - "<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() - "<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)); -} diff --git a/src/PIPELINE/VISU_DeformationPL.hxx b/src/PIPELINE/VISU_DeformationPL.hxx index 2521ec87..e18f43e3 100755 --- a/src/PIPELINE/VISU_DeformationPL.hxx +++ b/src/PIPELINE/VISU_DeformationPL.hxx @@ -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 diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.cxx b/src/PIPELINE/VISU_OptionalDeformationPL.cxx index 63f54df4..a4bc4555 100755 --- a/src/PIPELINE/VISU_OptionalDeformationPL.cxx +++ b/src/PIPELINE/VISU_OptionalDeformationPL.cxx @@ -32,16 +32,24 @@ #include #include #include +#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() - "<(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); - -}; diff --git a/src/VISU_I/VISU_CutPlanes_i.hh b/src/VISU_I/VISU_CutPlanes_i.hh index bf4b84a1..8a5f9355 100644 --- a/src/VISU_I/VISU_CutPlanes_i.hh +++ b/src/VISU_I/VISU_CutPlanes_i.hh @@ -115,8 +115,6 @@ namespace VISU { return myCutPlanesPL; } - - virtual void SetVectorialField(Entity theEntity, const char* theFieldName); protected: //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine diff --git a/src/VISU_I/VISU_Deformation_i.cc b/src/VISU_I/VISU_Deformation_i.cc index 7f777e19..8f4c05bc 100755 --- a/src/VISU_I/VISU_Deformation_i.cc +++ b/src/VISU_I/VISU_Deformation_i.cc @@ -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 (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 - (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 + (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 index c574f3d4..821b2735 100755 --- a/src/VISU_I/VISU_Deformation_i.hh +++ b/src/VISU_I/VISU_Deformation_i.hh @@ -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; }; } diff --git a/src/VISU_I/VISU_OptionalDeformation_i.cc b/src/VISU_I/VISU_OptionalDeformation_i.cc index 380db3e4..77a12298 100755 --- a/src/VISU_I/VISU_OptionalDeformation_i.cc +++ b/src/VISU_I/VISU_OptionalDeformation_i.cc @@ -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 (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag)); diff --git a/src/VISU_I/VISU_OptionalDeformation_i.hh b/src/VISU_I/VISU_OptionalDeformation_i.hh index cfe3a71b..ac6a08ff 100755 --- a/src/VISU_I/VISU_OptionalDeformation_i.hh +++ b/src/VISU_I/VISU_OptionalDeformation_i.hh @@ -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); -- 2.39.2