From e03ca4b3c4ad44429cf18125dea9a81792407c16 Mon Sep 17 00:00:00 2001 From: smh Date: Thu, 29 Jan 2004 13:03:19 +0000 Subject: [PATCH] MPV: Merge V1_2d --- src/PIPELINE/Makefile.in | 2 +- src/PIPELINE/VISUPipeLine.cxx | 3 +- src/PIPELINE/VISU_CutLinesPL.cxx | 5 +- src/PIPELINE/VISU_CutPlanesPL.cxx | 35 ++- src/PIPELINE/VISU_CutPlanesPL.hxx | 15 +- src/PIPELINE/VISU_DeformedShapePL.cxx | 7 +- src/PIPELINE/VISU_DeformedShapePL.hxx | 4 +- src/PIPELINE/VISU_Extractor.cxx | 12 +- src/PIPELINE/VISU_Extractor.hxx | 2 +- src/PIPELINE/VISU_FieldTransform.cxx | 33 +- src/PIPELINE/VISU_IsoSurfacesPL.cxx | 13 +- src/PIPELINE/VISU_IsoSurfacesPL.hxx | 2 + src/PIPELINE/VISU_PipeLine.cxx | 29 +- src/PIPELINE/VISU_PipeLine.hxx | 6 +- src/PIPELINE/VISU_PipeLineUtils.hxx | 37 ++- src/PIPELINE/VISU_ScalarMapPL.cxx | 6 +- src/PIPELINE/VISU_StreamLinesPL.cxx | 404 +++++++++++++++++-------- src/PIPELINE/VISU_StreamLinesPL.hxx | 71 +++-- src/PIPELINE/VISU_UsedPointsFilter.cxx | 17 +- src/PIPELINE/VISU_VectorsPL.cxx | 87 ++++-- src/PIPELINE/VISU_VectorsPL.hxx | 12 + 21 files changed, 533 insertions(+), 269 deletions(-) diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index 7cdd24fb..81cbfc26 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -60,6 +60,6 @@ BIN_SRC = CPPFLAGS+= $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+= $(VTK_LIBS) -lSalomeVTKFilter -lVisuConvertor \ - -L${KERNEL_ROOT_DIR}/lib/salome + -L${KERNEL_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 1b5181a6..f89dc7ef 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -34,7 +34,7 @@ #include "VISU_VectorsPL.hxx" #include "VISU_StreamLinesPL.hxx" -typedef VISU_StreamLinesPL TPresent; +typedef VISU_ScalarMapPL TPresent; #include #include @@ -107,6 +107,7 @@ int main(int argc, char** argv){ aPresent->SetInput(aDataSet); aPresent->Build(); aPresent->Init(); + aPresent->SetSourceRange(); //aPresent->SetPartDefault(0); //aPresent->SetScalarMin(0.01); //aPresent->SetScaling(VTK_SCALE_LOG10); diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 367139fa..21b5004f 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -39,12 +39,11 @@ VISU_CutLinesPL::VISU_CutLinesPL(){} void VISU_CutLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ VISU_CutPlanesPL::ShallowCopy(thePipeLine); if(VISU_CutLinesPL *aPipeLine = dynamic_cast(thePipeLine)){ - SetPlaneOrientation(aPipeLine->GetPlaneOrientation(1),1); + SetOrientation(aPipeLine->GetPlaneOrientation(1), + aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1); SetDisplacement(aPipeLine->GetDisplacement(1),1); SetDefault(); if (!aPipeLine->IsDefault()) SetPosition(aPipeLine->GetPosition()); - SetRotateX(aPipeLine->GetRotateX(1),1); - SetRotateY(aPipeLine->GetRotateY(1),1); } } diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index a6cb0665..2cbdba57 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -50,13 +50,12 @@ VISU_CutPlanesPL::~VISU_CutPlanesPL(){ void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ VISU_ScalarMapPL::ShallowCopy(thePipeLine); if(VISU_CutPlanesPL *aPipeLine = dynamic_cast(thePipeLine)){ - SetPlaneOrientation(aPipeLine->GetPlaneOrientation()); + SetOrientation(aPipeLine->GetPlaneOrientation(), + aPipeLine->GetRotateX(),aPipeLine->GetRotateY()); SetDisplacement(aPipeLine->GetDisplacement()); SetNbParts(aPipeLine->GetNbParts()); for (int i = 0, iend = GetNbParts(); i < iend; i++) if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i)); - SetRotateX(aPipeLine->GetRotateX()); - SetRotateY(aPipeLine->GetRotateY()); } } @@ -150,14 +149,28 @@ void VISU_CutPlanesPL::GetBoundProject(float BoundPrj[3], const float BoundBox[6 BoundPrj[2] = BoundPrj[1] - BoundPrj[0]; } -void VISU_CutPlanesPL::SetRotateX(float theAng, int theNum){ + +void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, + float theXAng, float theYAng, int theNum) +{ + myBasePlane[theNum] = theOrient; + switch(myBasePlane[theNum]){ + case XY: myAng[theNum][0] = theXAng; break; + case YZ: myAng[theNum][1] = theXAng; break; + case ZX: myAng[theNum][2] = theXAng; break; + } switch(myBasePlane[theNum]){ - case XY: myAng[theNum][0] = theAng; break; - case YZ: myAng[theNum][1] = theAng; break; - case ZX: myAng[theNum][2] = theAng; break; + case XY: myAng[theNum][1] = theYAng; break; + case YZ: myAng[theNum][2] = theYAng; break; + case ZX: myAng[theNum][0] = theYAng; break; } } + +const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){ + return myBasePlane[theNum]; +} + float VISU_CutPlanesPL::GetRotateX(int theNum){ switch(myBasePlane[theNum]){ case XY: return myAng[theNum][0]; @@ -166,14 +179,6 @@ float VISU_CutPlanesPL::GetRotateX(int theNum){ } } -void VISU_CutPlanesPL::SetRotateY(float theAng, int theNum){ - switch(myBasePlane[theNum]){ - case XY: myAng[theNum][1] = theAng; break; - case YZ: myAng[theNum][2] = theAng; break; - case ZX: myAng[theNum][0] = theAng; break; - } -} - float VISU_CutPlanesPL::GetRotateY(int theNum){ switch(myBasePlane[theNum]){ case XY: return myAng[theNum][1]; diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 73b42cdf..094c9463 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -44,11 +44,13 @@ public: virtual void ShallowCopy(VISU_PipeLine *thePipeLine); enum PlaneOrientation {XY, YZ, ZX}; - virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0) { return myBasePlane[theNum];} - virtual void SetPlaneOrientation(const PlaneOrientation& theOrient, int theNum = 0) { - myBasePlane[theNum] = theOrient; - } + virtual void SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, + float theXAng, float theYAng, int theNum = 0); + virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0); + virtual float GetRotateX(int theNum = 0); + virtual float GetRotateY(int theNum = 0); + virtual float GetDisplacement(int theNum = 0) { return myDisplacement[theNum];} virtual void SetDisplacement(float theDisp, int theNum = 0) { myDisplacement[theNum] = theDisp;} @@ -58,11 +60,6 @@ public: virtual void SetPartDefault(int thePartNumber); virtual int IsPartDefault(int thePartNumber); - virtual void SetRotateX(float theAngle, int theNum = 0); - virtual float GetRotateX(int theNum = 0); - virtual void SetRotateY(float theAngle, int theNum = 0); - virtual float GetRotateY(int theNum = 0); - virtual void SetNbParts(int theNb); virtual int GetNbParts(){ return myNbParts;} diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index e125c4f9..9b200331 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -41,10 +41,15 @@ vtkStandardNewMacro(VISU_DeformedShapePL); VISU_DeformedShapePL::VISU_DeformedShapePL(){ myWarpVector = vtkWarpVector::New(); + myCellDataToPointData = vtkCellDataToPointData::New(); } VISU_DeformedShapePL::~VISU_DeformedShapePL(){ + myWarpVector->UnRegisterAllOutputs(); myWarpVector->Delete(); + + myCellDataToPointData->UnRegisterAllOutputs(); + myCellDataToPointData->Delete(); } void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){ @@ -92,7 +97,7 @@ void VISU_DeformedShapePL::Init(){ } VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){ - VISU::CellDataToPoint(myWarpVector,myInput,myFieldTransform); + VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform); return myWarpVector->GetOutput(); } diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index f555faef..9c2f95a7 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -29,6 +29,7 @@ #include "VISU_ScalarMapPL.hxx" +class vtkCellDataToPointData; class SALOME_Transform; class vtkWarpVector; @@ -55,8 +56,9 @@ public: protected: virtual THook* DoHook(); - vtkWarpVector *myWarpVector; float myScaleFactor; + vtkWarpVector *myWarpVector; + vtkCellDataToPointData* myCellDataToPointData; }; diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 0b3f7859..683f8d6f 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -24,6 +24,9 @@ // Module : VISU #include "VISU_Extractor.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include #include #include @@ -33,7 +36,7 @@ using namespace std; -#ifdef DEBUG +#ifdef _DEBUG_ static int MYDEBUG = 0; #else static int MYDEBUG = 0; @@ -46,7 +49,8 @@ VISU_Extractor::VISU_Extractor(){ myScalarMode = 0; } -VISU_Extractor::~VISU_Extractor() {} +VISU_Extractor::~VISU_Extractor(){ +} void VISU_Extractor::SetScalarMode(int theScalarMode){ if(myScalarMode != theScalarMode){ @@ -62,7 +66,9 @@ execute(int theNbComp, int theScalarMode, TypeData* theInputData, TypeData* theO if ( !inVectors || theNbComp < 1 ) return; vtkFloatArray *newScalars = vtkFloatArray::New(); - //newScalars->SetName(inVectors->GetName()); + ostringstream aName; + aName<GetName(); aName<<", "; aName<SetName(aName.str().c_str()); newScalars->SetNumberOfComponents(1); newScalars->SetNumberOfTuples(theNbComp); for (int ptId = 0; ptId < theNbComp; ptId++) { diff --git a/src/PIPELINE/VISU_Extractor.hxx b/src/PIPELINE/VISU_Extractor.hxx index 6889b7a9..7ab876d6 100644 --- a/src/PIPELINE/VISU_Extractor.hxx +++ b/src/PIPELINE/VISU_Extractor.hxx @@ -33,7 +33,6 @@ class VTK_EXPORT VISU_Extractor : public vtkPointSetToPointSetFilter{ public: vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter); static VISU_Extractor *New(); - ~VISU_Extractor(); virtual int GetScalarMode(){ return myScalarMode;} virtual void SetScalarMode(int theScalarMode = 0); @@ -41,6 +40,7 @@ public: protected: VISU_Extractor(); VISU_Extractor(const VISU_Extractor&); + ~VISU_Extractor(); virtual void Execute(); diff --git a/src/PIPELINE/VISU_FieldTransform.cxx b/src/PIPELINE/VISU_FieldTransform.cxx index ea239eb2..2bb7f974 100644 --- a/src/PIPELINE/VISU_FieldTransform.cxx +++ b/src/PIPELINE/VISU_FieldTransform.cxx @@ -39,7 +39,9 @@ VISU_FieldTransform::VISU_FieldTransform(){ myTransform = NULL; } -VISU_FieldTransform::~VISU_FieldTransform() {} +VISU_FieldTransform::~VISU_FieldTransform() { + SetSpaceTransform(NULL); +} void VISU_FieldTransform::Update(){ @@ -84,6 +86,7 @@ void VISU_FieldTransform::SetScalarMax(float theValue){ SetScalarRange(aScalarRange); } + template void ExecVectors(VISU_FieldTransform::TTransformFun theFunction, SALOME_Transform* theTransform, @@ -103,15 +106,25 @@ ExecVectors(VISU_FieldTransform::TTransformFun theFunction, aScale[1] = theTransform->GetScale()[1]; aScale[2] = theTransform->GetScale()[2]; } - for (int ptId = 0; ptId < theNbComponent; ptId++) { - V = inVectors->GetTuple3(ptId); - vMag = vtkMath::Norm(V); - vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag; - if(vMag <= 0.0) vMag = 0.0; - v[0] = V[0]*vMag*aScale[0]; - v[1] = V[1]*vMag*aScale[1]; - v[2] = V[2]*vMag*aScale[2]; - newVectors->SetTuple3(ptId, v[0], v[1], v[2]); + if(theFunction == &(VISU_FieldTransform::Ident)){ + for (int ptId = 0; ptId < theNbComponent; ptId++) { + V = inVectors->GetTuple3(ptId); + v[0] = V[0]*aScale[0]; + v[1] = V[1]*aScale[1]; + v[2] = V[2]*aScale[2]; + newVectors->SetTuple3(ptId, v[0], v[1], v[2]); + } + }else{ + for (int ptId = 0; ptId < theNbComponent; ptId++) { + V = inVectors->GetTuple3(ptId); + vMag = vtkMath::Norm(V); + vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag; + if(vMag <= 0.0) vMag = 0.0; + v[0] = V[0]*vMag*aScale[0]; + v[1] = V[1]*vMag*aScale[1]; + v[2] = V[2]*vMag*aScale[2]; + newVectors->SetTuple3(ptId, v[0], v[1], v[2]); + } } theOutputData->SetVectors(newVectors); newVectors->Delete(); diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index ecd27659..b6bbb643 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -31,18 +31,19 @@ #include -VISU_IsoSurfacesPL* VISU_IsoSurfacesPL::New(){ - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_IsoSurfacesPL"); - if(ret) return (VISU_IsoSurfacesPL*)ret; - return new VISU_IsoSurfacesPL; -} +vtkStandardNewMacro(VISU_IsoSurfacesPL); VISU_IsoSurfacesPL::VISU_IsoSurfacesPL(){ myContourFilter = vtkContourFilter::New(); + myCellDataToPointData = vtkCellDataToPointData::New(); } VISU_IsoSurfacesPL::~VISU_IsoSurfacesPL(){ + myContourFilter->UnRegisterAllOutputs(); myContourFilter->Delete(); + + myCellDataToPointData->UnRegisterAllOutputs(); + myCellDataToPointData->Delete(); } void VISU_IsoSurfacesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ @@ -100,7 +101,7 @@ VISU_ScalarMapPL::THook* VISU_IsoSurfacesPL::DoHook(){ void VISU_IsoSurfacesPL::Update(){ - VISU::CellDataToPoint(myContourFilter,myInput,myFieldTransform); + VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform); SetMapScale(); VISU_ScalarMapPL::Update(); diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 6eeb4564..68732e37 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -30,6 +30,7 @@ #include "VISU_ScalarMapPL.hxx" class vtkContourFilter; +class vtkCellDataToPointData; class VISU_IsoSurfacesPL : public VISU_ScalarMapPL{ protected: @@ -58,6 +59,7 @@ public: protected: int myNbParts; float myRange[2]; + vtkCellDataToPointData* myCellDataToPointData; vtkContourFilter *myContourFilter; }; diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index d4354e35..e128b708 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -27,11 +27,16 @@ #include "VISU_PipeLine.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include #include #include #include +static int MYVTKDEBUG = 0; + #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -43,11 +48,14 @@ static int MYDEBUGWITHFILES = 0; VISU_PipeLine::VISU_PipeLine(){ myMapper = TMapper::New(); myInput = NULL; + SetDebug(MYVTKDEBUG); } VISU_PipeLine::~VISU_PipeLine(){ - myMapper->Delete(); + if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<GetReferenceCount()); SetInput(NULL); + myMapper->RemoveAllInputs(); + myMapper->Delete(); } void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){ @@ -57,13 +65,14 @@ void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){ } void VISU_PipeLine::SetInput(TInput* theInput){ - if (myInput != theInput){ + if(myInput != theInput){ if (myInput != NULL) myInput->UnRegister(this); myInput = theInput; - if (myInput != NULL) { + if(myInput != NULL){ myInput->Register(this); myInput->Update(); - } + }else + myMapper->SetInput(NULL); Modified(); } } @@ -84,23 +93,25 @@ void VISU_PipeLine::Update(){ } -size_t VISU_PipeLine::CheckAvailableMemory(const size_t& theSize){ +int VISU_PipeLine::CheckAvailableMemory(const float& theSize){ try{ - char *aCheck = new char[theSize]; + if(theSize > ULONG_MAX) return 0; + size_t aSize = size_t(theSize); + char *aCheck = new char[aSize]; if(aCheck) delete [] aCheck; if(MYDEBUG && aCheck == NULL) - cout<<"VISU_PipeLine::CheckAvailableMemory("< theMinSize) theSize /= 2; diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 21a8b24d..1a55be8e 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -55,9 +55,9 @@ public: virtual void Init() = 0; virtual void Update(); - static size_t CheckAvailableMemory(const size_t& theSize); - static size_t GetAvailableMemory(size_t theSize = 16*1024*1024, - size_t theMinSize = 1024*1024); + static int CheckAvailableMemory(const float& theSize); + static float GetAvailableMemory(float theSize = 16*1024*1024.0, + float theMinSize = 1024*1024.0); protected: virtual void Build() = 0; diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index a6242399..df7c8219 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -44,34 +44,43 @@ #include +#ifndef MESSAGE +#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"< void CellDataToPoint(TItem* theTItem, vtkDataSet* theDataSet, + template void CellDataToPoint(TItem* theTItem, + vtkCellDataToPointData *theFilter, + vtkDataSet* theDataSet, VISU_FieldTransform *theFieldTransform) { if(theDataSet->GetCellData()->GetNumberOfArrays()){ - vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - aFilter->PassCellDataOn(); - theTItem->SetInput(aFilter->GetUnstructuredGridOutput()); - aFilter->Register(theTItem); - aFilter->Delete(); + theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theFilter->PassCellDataOn(); + theTItem->SetInput(theFilter->GetUnstructuredGridOutput()); }else theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); } - template void ToCellCenters(TItem* theTItem, vtkDataSet* theDataSet, + template void ToCellCenters(TItem* theTItem, + vtkCellCenters *theFilter, + vtkDataSet* theDataSet, VISU_FieldTransform *theFieldTransform) { if(theDataSet->GetCellData()->GetNumberOfArrays()){ - vtkCellCenters *aCenters = vtkCellCenters::New(); // for vectors on cells - aCenters->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - aCenters->VertexCellsOn(); - theTItem->SetInput(aCenters->GetOutput()); - aCenters->Register(theTItem); - aCenters->Delete(); + theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theFilter->VertexCellsOn(); + theTItem->SetInput(theFilter->GetOutput()); }else theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); } diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 5025d98e..d7b7b4a6 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -40,6 +40,7 @@ vtkStandardNewMacro(VISU_ScalarMapPL); VISU_ScalarMapPL::VISU_ScalarMapPL(){ myFieldTransform = VISU_FieldTransform::New(); + //myFieldTransform->DebugOn(); myMapperTable = VISU_LookupTable::New(); myMapperTable->SetScale(VTK_SCALE_LINEAR); @@ -50,13 +51,16 @@ VISU_ScalarMapPL::VISU_ScalarMapPL(){ myBarTable->SetHueRange(0.667,0.0); myExtractor = VISU_Extractor::New(); + //myExtractor->DebugOn(); } VISU_ScalarMapPL::~VISU_ScalarMapPL(){ + myFieldTransform->UnRegisterAllOutputs(); myFieldTransform->Delete(); myMapperTable->Delete();; myBarTable->Delete(); + myExtractor->UnRegisterAllOutputs(); myExtractor->Delete(); } @@ -156,8 +160,6 @@ void VISU_ScalarMapPL::Update() { myMapper->SetLookupTable(myMapperTable); myMapper->SetScalarRange(aScalarRange); - myFieldTransform->Update(); - VISU_PipeLine::Update(); } diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index fabf6993..f219d4a3 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -30,102 +30,214 @@ #include "VISU_UsedPointsFilter.hxx" #include "SALOME_GeometryFilter.h" +#include + +#include #include #include #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif -static float EPS = 1.0e-20; -int VISU_StreamLinesPL::myMaxIncrementMemorySize = 64; - -void SetStreamerSource(vtkStreamer *theStreamer, vtkPointSet* theDataSet, float thePercents){ - theDataSet->Update(); - VISU_UsedPointsFilter* anUsedPointsFilter = VISU_UsedPointsFilter::New(); - anUsedPointsFilter->SetInput(theDataSet); - anUsedPointsFilter->SetPercentsOfUsedPoints(thePercents); - theStreamer->SetSource(anUsedPointsFilter->GetOutput()); - anUsedPointsFilter->Register(theStreamer); - anUsedPointsFilter->Delete(); -} +static float EPS = 1.0e-7; +static float aMinNbOfSteps = 1.0E+2; +static float aMaxNbOfSteps = 1.0E+3; +static float aCoeffOfIntStep = 1.0E+1; vtkStandardNewMacro(VISU_StreamLinesPL); VISU_StreamLinesPL::VISU_StreamLinesPL(){ myStream = vtkStreamLine::New(); + myCenters = vtkCellCenters::New(); myGeomFilter = SALOME_GeometryFilter::New(); + myPointsFilter = VISU_UsedPointsFilter::New(); + myPercents = 0.3; mySource = NULL; } VISU_StreamLinesPL::~VISU_StreamLinesPL(){ - myStream->Delete(); + myPointsFilter->UnRegisterAllOutputs(); + myPointsFilter->Delete(); + + myCenters->UnRegisterAllOutputs(); + myCenters->Delete(); + + myGeomFilter->UnRegisterAllOutputs(); myGeomFilter->Delete(); - SetSource(NULL); + + myStream->UnRegisterAllOutputs(); + myStream->Delete(); } void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ VISU_DeformedShapePL::ShallowCopy(thePipeLine); - if(VISU_StreamLinesPL *aPipeLine = dynamic_cast(thePipeLine)){ + if(VISU_StreamLinesPL *aPipeLine = dynamic_cast(thePipeLine)) + SetParams(aPipeLine->GetIntegrationStep(), + aPipeLine->GetPropagationTime(), + aPipeLine->GetStepLength(), + aPipeLine->GetSource(), + aPipeLine->GetUsedPoints(), + aPipeLine->GetDirection()); +} + - //Order of setting of the values are important - SetUsedPoints(aPipeLine->GetUsedPoints()); - SetSource(aPipeLine->GetSource()); +float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength, + float thePropogationTime, float thePercents) +{ + static float aStreamPointSize = sizeof(float)*15 + sizeof(vtkIdType)*2; + static float aStreamArraySize = aStreamPointSize*1024; // == 69632 - SetDirection(aPipeLine->GetDirection()); + float aNbCells = thePercents*theNbOfPoints*2.0; + float aNbPointsPerCell = thePropogationTime/theStepLength; + float aCellsSize = aNbCells*(1+aNbPointsPerCell); + float aPointsSize = aCellsSize*3.0*sizeof(float); - //Order of setting of the values are important - SetIntegrationStep(aPipeLine->GetIntegrationStep()); - SetPropagationTime(aPipeLine->GetPropagationTime()); - SetStepLength(aPipeLine->GetStepLength()); + float aConnectivitySize = aCellsSize*sizeof(vtkIdType); + float aTypesSize = aNbCells*sizeof(char); + float aLocationsSize = aNbCells*sizeof(int); + float aNbCellsPerPoint = aCellsSize / aNbCells - 1; + float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize; + + float anAssignedDataSize = aCellsSize*4.0*sizeof(float); + float anOutputDataSetSize = aMeshSize + anAssignedDataSize; + + float aResult = aStreamArraySize*aNbCells + anOutputDataSetSize; + return aResult; +} + +int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength, + float& thePropogationTime, float& thePercents) +{ + static float aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0; + vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints(); + float aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents); + int isPoss = CheckAvailableMemory(aSize); + if(!isPoss){ + float aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime); + float aMinStepLength = GetMinStepLength(theDataSet); + float aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease; + for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){ + float aStepLength = theStepLength + aDeltaStepLength; + if(aStepLength < aMaxStepLength) theStepLength = aStepLength; + else if(aStepChanged){ + aStepLength = aMaxStepLength; + aStepChanged = 0; + } + float aPercents = thePercents /= aPercentsDecrease; + if(aPercents*aNbOfPoints > 1) thePercents = aPercents; + else if(aPerecentsChanged) { + thePercents = 1.1 / aNbOfPoints; + aPerecentsChanged = 0; + } + aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents); + if(CheckAvailableMemory(aSize)){ + isPoss = i; + break; + } + } } + if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<GetNumberOfPoints(); + float aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents); + float aRealSize = GetAvailableMemory(aSize); float anAverageVolume = aVolume / aRealSize; float aStep = pow(double(anAverageVolume), double(1.0/double(degree))); return aStep; } +float VISU_StreamLinesPL::GetMinIntegrationStep(){ + return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints()); +} -float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet) { - if(!theDataSet) return 0.0; + +float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) { + if(!theDataSet) return -1.0; theDataSet->Update(); - float* aScalarRange = theDataSet->GetScalarRange(); - return theDataSet->GetLength()/fabs(aScalarRange[1] + aScalarRange[0])*2.0; + float aLength = theDataSet->GetLength(); + float* aBounds = theDataSet->GetBounds(); + float aMaxSizeY = (aBounds[3]-aBounds[2])/aLength; + float aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength; + float aMinMax = (aBounds[1] - aBounds[0])/aLength; + if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY; + if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ; + return aMinMax*aLength/2.0; +} +float VISU_StreamLinesPL::GetMaxIntegrationStep(){ + return GetMaxIntegrationStep(myExtractor->GetOutput()); } - -int VISU_StreamLinesPL::GetDirection(){ - return myStream->GetIntegrationDirection(); +float VISU_StreamLinesPL::GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents){ + theDataSet->Update(); + float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents); + float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet); + float anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep; + float aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints(); + if(aMinMax > anIntegrationStep) + anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep; + if(aMinIntegrationStep > anIntegrationStep) + anIntegrationStep = aMinIntegrationStep; + return anIntegrationStep; } -void VISU_StreamLinesPL::SetDirection(int theDirection){ - myStream->SetIntegrationDirection(theDirection); - Modified(); + +float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){ + theDataSet->Update(); + float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents); + float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet); + if(aMinIntegrationStep > theStep) + theStep = aMinIntegrationStep; + if(aMaxIntegrationStep < theStep) + theStep = aMaxIntegrationStep; + return theStep; } -float VISU_StreamLinesPL::GetPropagationTime() { - return myStream->GetMaximumPropagationTime(); +float VISU_StreamLinesPL::GetMinPropagationTime(vtkPointSet* theDataSet){ + if(!theDataSet) return -1.0; + return GetMinStepLength(theDataSet); } -void VISU_StreamLinesPL::SetPropagationTime(float theTime) { - if(myStream->GetMaximumPropagationTime() == theTime) return; - myStream->SetMaximumPropagationTime(theTime); - Modified(); +float VISU_StreamLinesPL::GetMinPropagationTime(){ + return GetMinPropagationTime(myExtractor->GetOutput()); } +float VISU_StreamLinesPL::GetMaxPropagationTime(vtkPointSet* theDataSet){ + if(!theDataSet) return -1.0; + return GetBasePropagationTime(theDataSet)*aMinNbOfSteps; +} +float VISU_StreamLinesPL::GetMaxPropagationTime(){ + return GetMaxPropagationTime(myExtractor->GetOutput()); +} -float VISU_StreamLinesPL::GetIntegrationStep(){ - return myStream->GetIntegrationStepLength(); +float VISU_StreamLinesPL::CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet){ + float aMinPropagationTime = GetMinPropagationTime(theDataSet); + float aMaxPropagationTime = GetMaxPropagationTime(theDataSet); + if(aMinPropagationTime > thePropagationTime) + thePropagationTime = aMinPropagationTime; + if(aMaxPropagationTime < thePropagationTime) + thePropagationTime = aMaxPropagationTime; + return thePropagationTime; } -float VISU_StreamLinesPL::SetIntegrationStep(float theStep){ - if(myStream->GetIntegrationStepLength() == theStep) return theStep; - myExtractor->Update(); - vtkPointSet* aDataSet = GetSource(); - aDataSet->Update(); - float anIntegrationStep = theStep; - float aMinIntegrationStep = GetMinIntegrationStep(aDataSet); - float aMaxIntegrationStep = GetMaxIntegrationStep(aDataSet); - if(aMinIntegrationStep < anIntegrationStep && anIntegrationStep < aMaxIntegrationStep){ - myStream->SetIntegrationStepLength(theStep); - Modified(); - }else{ - anIntegrationStep = aMaxIntegrationStep / 10.0; - float aMinMax = aDataSet->GetLength()/myInput->GetNumberOfPoints(); - if(aMinMax > anIntegrationStep) - anIntegrationStep = (anIntegrationStep*9.0+aMinMax)/10.0; - if(aMinIntegrationStep > anIntegrationStep) - anIntegrationStep = aMinIntegrationStep; - } - return anIntegrationStep; +float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet){ + if(!theDataSet) return -1.0; + theDataSet->Update(); + float aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet); + return aPropagationTime; +} +float VISU_StreamLinesPL::GetBasePropagationTime(){ + return GetBasePropagationTime(myExtractor->GetOutput()); } -float VISU_StreamLinesPL::GetStepLength() { - return myStream->GetStepLength(); +float VISU_StreamLinesPL::GetMinStepLength(vtkPointSet* theDataSet){ + static float aNbOfStepsOfIntStep = 1.0E+1; + float anIntStep = GetMinIntegrationStep(theDataSet); + float aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet); + return aStepLength; } -float VISU_StreamLinesPL::GetMinStepLength(float theIntegrationStep){ - return theIntegrationStep*2.0; +float VISU_StreamLinesPL::GetMinStepLength(){ + return GetMinStepLength(myExtractor->GetOutput()); +} + +float VISU_StreamLinesPL::GetMaxStepLength(vtkPointSet* theDataSet){ + float aStepLength = GetBasePropagationTime(theDataSet); + return aStepLength; } -float VISU_StreamLinesPL::GetMaxStepLength(float thePropagationTime){ - return thePropagationTime/100.0; +float VISU_StreamLinesPL::GetMaxStepLength(){ + return GetMaxStepLength(myExtractor->GetOutput()); } -float VISU_StreamLinesPL::CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime){ - float aMinStep = GetMinStepLength(theIntegrationStep); + +float VISU_StreamLinesPL::CorrectStepLength(float theStep, vtkPointSet* theDataSet){ + float aMinStep = GetMinStepLength(theDataSet); if(theStep < aMinStep) theStep = aMinStep; - float aMaxStep = GetMaxStepLength(thePropagationTime); + float aMaxStep = GetMaxStepLength(theDataSet); if(theStep > aMaxStep) theStep = aMaxStep; return theStep; } -float VISU_StreamLinesPL::SetStepLength(float theStep){ - if(myStream->GetStepLength() == theStep) return theStep; - float aStepLength = CorrectStepLength(theStep,GetIntegrationStep(),GetPropagationTime()); - if(aStepLength == theStep){ - myStream->SetStepLength(theStep); - Modified(); - } +float VISU_StreamLinesPL::GetBaseStepLength(vtkPointSet* theDataSet){ + static float anAvgNbOfSteps = 1.0E+2; + float aPropagationTime = GetBasePropagationTime(theDataSet); + float aStepLength = aPropagationTime/anAvgNbOfSteps; + aStepLength = CorrectStepLength(aStepLength,theDataSet); return aStepLength; } void VISU_StreamLinesPL::Init(){ VISU_ScalarMapPL::Init(); - - SetDirection(VTK_INTEGRATE_BOTH_DIRECTIONS); - vtkPointSet* aDataSet = myExtractor->GetOutput(); - //Order of setting of the values are important - myPercents = 0.3; - SetSource(NULL); - - SetIntegrationStep(SetIntegrationStep(GetMaxIntegrationStep(aDataSet)/10.0)); - SetPropagationTime(GetBasePropagationTime(aDataSet)); - SetStepLength(SetStepLength(GetPropagationTime()/20.)); + vtkPointSet* aDataSet = myExtractor->GetOutput(); + float anIntStep = GetBaseIntegrationStep(aDataSet); + float aPropagationTime = GetBasePropagationTime(aDataSet); + float aStepLength = GetBaseStepLength(aDataSet); + SetParams(anIntStep,aPropagationTime,aStepLength); } VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){ - SetSource(NULL); myInput->Update(); + VISU::CellDataToPoint(myStream,myCellDataToPointData,myInput,myFieldTransform); float *aBounds = myInput->GetBounds(); myGeomFilter->SetExtent(aBounds); myGeomFilter->ExtentClippingOn(); diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index ab56a041..6e9bc413 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -31,7 +31,9 @@ #include class vtkPointSet; +class vtkCellCenters; class SALOME_GeometryFilter; +class VISU_UsedPointsFilter; class VISU_StreamLinesPL : public VISU_DeformedShapePL{ protected: @@ -43,27 +45,32 @@ public: virtual ~VISU_StreamLinesPL(); virtual void ShallowCopy(VISU_PipeLine *thePipeLine); - virtual int GetDirection(); - virtual void SetDirection(int theDirection); - - virtual float GetStepLength(); - virtual float SetStepLength(float theStep); - + virtual int SetParams(float theIntStep, + float thePropogationTime, + float theStepLength, + vtkPointSet* theSource = NULL, + float thePercents = 0.3, + int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS, + int isOnlyTry = false); + virtual vtkPointSet* GetSource(); + virtual float GetUsedPoints(); + virtual float GetIntegrationStep(); virtual float GetPropagationTime(); - virtual void SetPropagationTime(float theTime); + virtual float GetStepLength(); + virtual int GetDirection(); - virtual float GetIntegrationStep(); - virtual float SetIntegrationStep(float theStep); + virtual vtkDataSet* GetStreamerSource(); + virtual float GetVelocityCoeff(); - virtual void SetSource(vtkPointSet* theSource); - virtual vtkPointSet* GetSource() {return mySource;} + virtual float GetMaxIntegrationStep(); + virtual float GetMinIntegrationStep(); - virtual void SetUsedPoints(float thePercents) { myPercents = thePercents;} - virtual float GetUsedPoints() { return myPercents;} + virtual float GetMinStepLength(); + virtual float GetMaxStepLength(); - virtual float GetMaxIntegrationStep(){ return GetMaxIntegrationStep(GetSource());} - virtual float GetMinIntegrationStep(){ return GetMinIntegrationStep(GetSource());} - virtual float GetBasePropagationTime(){ return GetBasePropagationTime(GetSource());}; + virtual float GetMinPropagationTime(); + virtual float GetMaxPropagationTime(); + virtual float GetBasePropagationTime(); public: virtual THook* DoHook(); @@ -72,22 +79,40 @@ public: virtual void SetMapScale(float theMapScale = 1.0); public: - static int myMaxIncrementMemorySize; - - static float GetMinStepLength(float theIntegrationStep); - static float GetMaxStepLength(float thePropagationTime); - static float CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime); - static float GetMaxIntegrationStep(vtkPointSet* theDataSet); - static float GetMinIntegrationStep(vtkPointSet* theDataSet); + static float GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3); + static float GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3); + + static float GetMinPropagationTime(vtkPointSet* theDataSet); + static float GetMaxPropagationTime(vtkPointSet* theDataSet); static float GetBasePropagationTime(vtkPointSet* theDataSet); + static float GetMinStepLength(vtkPointSet* theDataSet); + static float GetMaxStepLength(vtkPointSet* theDataSet); + static float GetBaseStepLength(vtkPointSet* theDataSet); + + static float GetVelocityCoeff(vtkPointSet* theDataSet); + + static int IsPossible(vtkPointSet* theDataSet, float thePercents = 0.3); + protected: + static float GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength, + float thePropogationTime, float thePercents = 0.3); + static int FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength, + float& thePropogationTime, float& thePercents); + + static float CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents = 0.3); + static float CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet); + static float CorrectStepLength(float theStep, vtkPointSet* theDataSet); + vtkStreamLine* myStream; vtkPointSet* mySource; + vtkCellCenters* myCenters; SALOME_GeometryFilter *myGeomFilter; + VISU_UsedPointsFilter *myPointsFilter; float myPercents; }; #endif + diff --git a/src/PIPELINE/VISU_UsedPointsFilter.cxx b/src/PIPELINE/VISU_UsedPointsFilter.cxx index 9e2e2612..6c52da23 100644 --- a/src/PIPELINE/VISU_UsedPointsFilter.cxx +++ b/src/PIPELINE/VISU_UsedPointsFilter.cxx @@ -43,7 +43,7 @@ static int MYDEBUG = 0; vtkStandardNewMacro(VISU_UsedPointsFilter); VISU_UsedPointsFilter::VISU_UsedPointsFilter(){ - PercentsOfUsedPoints = 0.1; + PercentsOfUsedPoints = 1.0; } VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){} @@ -52,6 +52,8 @@ void VISU_UsedPointsFilter::Execute(){ vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput(); anOutput->GetPointData()->CopyAllOff(); anOutput->GetCellData()->CopyAllOff(); + anOutput->CopyStructure(anInput); + vtkPoints* aPoints = vtkPoints::New(); vtkIdType aCellSize = anInput->GetMaxCellSize(); vtkIdList *anIdList = vtkIdList::New(); @@ -61,18 +63,15 @@ void VISU_UsedPointsFilter::Execute(){ if(anIdList->GetNumberOfIds() > 0) aPoints->InsertNextPoint(anInput->GetPoint(i)); } - static float EPS = 1E-5; - if(PercentsOfUsedPoints < EPS){ - anOutput->SetPoints(aPoints); - }else{ - vtkPoints* aNewPoints = vtkPoints::New(); - iEnd = aPoints->GetNumberOfPoints(); + vtkPoints* aNewPoints = vtkPoints::New(); + iEnd = aPoints->GetNumberOfPoints(); + if (PercentsOfUsedPoints > 0){ vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints); if(anOffset < 1) anOffset = 1; for(vtkIdType i = 0; i < iEnd; i += anOffset) aNewPoints->InsertNextPoint(aPoints->GetPoint(i)); - anOutput->SetPoints(aNewPoints); - aNewPoints->Delete(); } + anOutput->SetPoints(aNewPoints); + aNewPoints->Delete(); aPoints->Delete(); } diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 786f7ec0..ddb703b5 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -39,11 +39,32 @@ vtkStandardNewMacro(VISU_VectorsPL); VISU_VectorsPL::VISU_VectorsPL(){ myGlyph = vtkGlyph3D::New(); + + myGlyphSource = vtkGlyphSource2D::New(); + myConeSource = vtkConeSource::New(); + myLineSource = vtkLineSource::New(); + + myCenters = vtkCellCenters::New(); myTransformFilter = SALOME_TransformFilter::New(); } VISU_VectorsPL::~VISU_VectorsPL(){ + myGlyph->UnRegisterAllOutputs(); myGlyph->Delete(); + + myCenters->UnRegisterAllOutputs(); + myCenters->Delete(); + + myGlyphSource->UnRegisterAllOutputs(); + myGlyphSource->Delete(); + + myConeSource->UnRegisterAllOutputs(); + myConeSource->Delete(); + + myLineSource->UnRegisterAllOutputs(); + myLineSource->Delete(); + + myTransformFilter->UnRegisterAllOutputs(); myTransformFilter->Delete(); } @@ -86,7 +107,7 @@ void VISU_VectorsPL::Init(){ VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){ - VISU::ToCellCenters(myTransformFilter,myInput,myFieldTransform); + VISU::ToCellCenters(myTransformFilter,myCenters,myInput,myFieldTransform); myGlyph->SetInput(myTransformFilter->GetOutput()); myGlyph->SetVectorModeToUseVector(); myGlyph->SetScaleModeToScaleByVector(); @@ -98,44 +119,54 @@ VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){ void VISU_VectorsPL::Update(){ switch (myTypeGlyph) { case ARROW: { - vtkGlyphSource2D *aGlyphSource = vtkGlyphSource2D::New(); - aGlyphSource->SetGlyphTypeToArrow(); - aGlyphSource->SetFilled(0); - if(myPosGlyph == TAIL) - aGlyphSource->SetCenter(0.5, 0.0, 0.0); - else if(myPosGlyph == HEAD) - aGlyphSource->SetCenter(-0.5, 0.0, 0.0); - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + myGlyphSource->SetGlyphTypeToArrow(); + myGlyphSource->SetFilled(0); + switch (myPosGlyph) { + case TAIL: + myGlyphSource->SetCenter(0.5, 0.0, 0.0); + break; + case HEAD: + myGlyphSource->SetCenter(-0.5, 0.0, 0.0); + break; + case CENTER: + myGlyphSource->SetCenter(0.0, 0.0, 0.0); + } +// if(myPosGlyph == TAIL) +// myGlyphSource->SetCenter(0.5, 0.0, 0.0); +// else if(myPosGlyph == HEAD) +// myGlyphSource->SetCenter(-0.5, 0.0, 0.0); + myGlyph->SetSource(myGlyphSource->GetOutput()); } break; case CONE2: case CONE6: { - vtkConeSource *aGlyphSource = vtkConeSource::New(); //by default if (myTypeGlyph == CONE2) - aGlyphSource->SetResolution(3); + myConeSource->SetResolution(3); else - aGlyphSource->SetResolution(7); - aGlyphSource->SetHeight(1.0); - aGlyphSource->SetRadius(.1); - - if(myPosGlyph == TAIL) - aGlyphSource->SetCenter(0.5, 0.0, 0.0); - else if(myPosGlyph == HEAD) - aGlyphSource->SetCenter(-0.5, 0.0, 0.0); + myConeSource->SetResolution(7); + myConeSource->SetHeight(1.0); + myConeSource->SetRadius(.1); - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + switch (myPosGlyph) { + case TAIL: + myConeSource->SetCenter(0.5, 0.0, 0.0); + break; + case HEAD: + myConeSource->SetCenter(-0.5, 0.0, 0.0); + break; + case CENTER: + myConeSource->SetCenter(0.0, 0.0, 0.0); + } +// if(myPosGlyph == TAIL) +// myConeSource->SetCenter(0.5, 0.0, 0.0); +// else if(myPosGlyph == HEAD) +// myConeSource->SetCenter(-0.5, 0.0, 0.0); + myGlyph->SetSource(myConeSource->GetOutput()); } break; case NONE: default: { - vtkLineSource *aGlyphSource = vtkLineSource::New(); - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + myGlyph->SetSource(myLineSource->GetOutput()); } } diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 81a1f33b..e4af6d62 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -31,6 +31,12 @@ class SALOME_TransformFilter; class SALOME_Transform; +class vtkCellCenters; + +class vtkGlyphSource2D; +class vtkConeSource; +class vtkLineSource; + class vtkGlyph3D; class VISU_VectorsPL : public VISU_DeformedShapePL{ @@ -68,6 +74,12 @@ protected: GlyphType myTypeGlyph; GlyphPos myPosGlyph; vtkGlyph3D *myGlyph; + + vtkGlyphSource2D *myGlyphSource; + vtkLineSource *myLineSource; + vtkConeSource *myConeSource; + + vtkCellCenters* myCenters; SALOME_TransformFilter *myTransformFilter; }; -- 2.39.2