From 323e6801b4c1618b1db088b15a6c23fdd93ace1a Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 4 Dec 2006 17:01:39 +0000 Subject: [PATCH] To implement more accurate Mapper's coping --- src/OBJECT/VISU_Actor.cxx | 9 +-- src/PIPELINE/VISU_CutLinesPL.cxx | 6 +- src/PIPELINE/VISU_CutLinesPL.hxx | 14 ++-- src/PIPELINE/VISU_CutPlanesPL.cxx | 4 +- src/PIPELINE/VISU_CutPlanesPL.hxx | 8 +-- src/PIPELINE/VISU_DeformedShapePL.cxx | 12 ++-- src/PIPELINE/VISU_DeformedShapePL.hxx | 21 +++--- src/PIPELINE/VISU_GaussPointsPL.cxx | 20 ++++-- src/PIPELINE/VISU_GaussPointsPL.hxx | 47 +++++++----- src/PIPELINE/VISU_IsoSurfacesPL.cxx | 12 ++-- src/PIPELINE/VISU_IsoSurfacesPL.hxx | 21 +++--- src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx | 33 +++------ src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx | 2 - src/PIPELINE/VISU_PipeLine.cxx | 29 +++++--- src/PIPELINE/VISU_PipeLine.hxx | 8 +++ src/PIPELINE/VISU_PipeLineUtils.cxx | 71 +++++++++++++++++++ src/PIPELINE/VISU_PipeLineUtils.hxx | 21 ++++++ src/PIPELINE/VISU_Plot3DPL.cxx | 4 +- src/PIPELINE/VISU_Plot3DPL.hxx | 19 ++--- .../VISU_ScalarMapOnDeformedShapePL.cxx | 7 +- .../VISU_ScalarMapOnDeformedShapePL.hxx | 20 +++--- src/PIPELINE/VISU_ScalarMapPL.cxx | 30 ++++---- src/PIPELINE/VISU_ScalarMapPL.hxx | 8 +-- src/PIPELINE/VISU_StreamLinesPL.cxx | 15 ++-- src/PIPELINE/VISU_StreamLinesPL.hxx | 8 +-- src/PIPELINE/VISU_VectorsPL.cxx | 4 +- src/PIPELINE/VISU_VectorsPL.hxx | 8 +-- 27 files changed, 291 insertions(+), 170 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index b7e5202e..c03cb0de 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -32,6 +32,8 @@ #include "VTKViewer_GeometryFilter.h" #include "VTKViewer_PassThroughFilter.h" +#include "VISU_PipeLineUtils.hxx" + #include #include @@ -131,12 +133,7 @@ VISU_Actor ::ShallowCopyPL(VISU_PipeLine* thePipeLine) { myPipeLine->ShallowCopy(thePipeLine); - - vtkDataSet* aDatsSet = myMapper->GetInput(); - GetMapper()->ShallowCopy(thePipeLine->GetMapper()); - - // To restore mapper input from pipeline - myMapper->SetInput(aDatsSet); + VISU::CopyMapper(GetMapper(), thePipeLine->GetMapper()); } //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index cefa247f..2a278253 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -43,7 +43,7 @@ VISU_CutLinesPL void VISU_CutLinesPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_CutLinesPL *aPipeLine = dynamic_cast(thePipeLine)){ SetOrientation(aPipeLine->GetPlaneOrientation(1), @@ -54,14 +54,14 @@ VISU_CutLinesPL else SetPosition(aPipeLine->GetPosition()); } - VISU_CutPlanesPL::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } void VISU_CutLinesPL ::Init() { - VISU_CutPlanesPL::Init(); + Superclass::Init(); myBasePlane[0] = XY; myBasePlane[1] = YZ; diff --git a/src/PIPELINE/VISU_CutLinesPL.hxx b/src/PIPELINE/VISU_CutLinesPL.hxx index a151f616..b72654c0 100644 --- a/src/PIPELINE/VISU_CutLinesPL.hxx +++ b/src/PIPELINE/VISU_CutLinesPL.hxx @@ -33,9 +33,6 @@ class vtkAppendPolyData; class VISU_CutLinesPL : public VISU_CutPlanesPL { -protected: - VISU_CutLinesPL(); - VISU_CutLinesPL(const VISU_CutLinesPL&); public: vtkTypeMacro(VISU_CutLinesPL,VISU_CutPlanesPL); @@ -43,10 +40,6 @@ public: VISU_CutLinesPL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void SetPosition(vtkFloatingPointType thePosition); @@ -125,6 +118,13 @@ public: } protected: + VISU_CutLinesPL(); + VISU_CutLinesPL(const VISU_CutLinesPL&); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + vtkFloatingPointType myDirLn[3]; vtkFloatingPointType myRealDirLn[3]; vtkFloatingPointType myBoundPrjLn[3]; diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 745206d8..a96b049a 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -64,7 +64,7 @@ VISU_CutPlanesPL void VISU_CutPlanesPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_CutPlanesPL *aPipeLine = dynamic_cast(thePipeLine)){ SetOrientation(aPipeLine->GetPlaneOrientation(), @@ -74,7 +74,7 @@ VISU_CutPlanesPL for (int i = 0, iend = GetNbParts(); i < iend; i++) if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i)); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } void diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 5d0da26f..79a59ad1 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -45,10 +45,6 @@ public: virtual ~VISU_CutPlanesPL(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - enum PlaneOrientation {XY, YZ, ZX}; virtual @@ -188,6 +184,10 @@ protected: THook* DoHook(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + void SetPartPosition(int theNum = 0); diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 8a8cc06d..d3d431a3 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -52,12 +52,12 @@ VISU_DeformedShapePL void VISU_DeformedShapePL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_DeformedShapePL *aPipeLine = dynamic_cast(thePipeLine)){ SetScale(aPipeLine->GetScale()); } - VISU_ScalarMapPL::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } vtkFloatingPointType @@ -104,7 +104,7 @@ void VISU_DeformedShapePL ::Init() { - VISU_ScalarMapPL::Init(); + Superclass::Init(); vtkFloatingPointType aScalarRange[2]; GetSourceRange(aScalarRange); @@ -132,7 +132,7 @@ void VISU_DeformedShapePL ::Update() { - VISU_ScalarMapPL::Update(); + Superclass::Update(); } //---------------------------------------------------------------------------- @@ -141,7 +141,7 @@ VISU_DeformedShapePL ::GetMemorySize() { unsigned long int aSize = 0; - if(vtkDataSet* aDataSet = myWarpVector->GetInput()) + if(myWarpVector->GetInput()) if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; @@ -160,7 +160,7 @@ void VISU_DeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { - VISU_ScalarMapPL::SetMapScale(theMapScale); + Superclass::SetMapScale(theMapScale); myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); Modified(); diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index 4049c668..e842588b 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -35,13 +35,6 @@ class vtkWarpVector; class VISU_DeformedShapePL : public VISU_ScalarMapPL { -protected: - VISU_DeformedShapePL(); - VISU_DeformedShapePL(const VISU_DeformedShapePL&); - - virtual - ~VISU_DeformedShapePL(); - public: vtkTypeMacro(VISU_DeformedShapePL,VISU_ScalarMapPL); @@ -49,10 +42,6 @@ public: VISU_DeformedShapePL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void SetScale(vtkFloatingPointType theScale); @@ -84,10 +73,20 @@ public: GetScaleFactor(vtkDataSet* theDataSet); protected: + VISU_DeformedShapePL(); + VISU_DeformedShapePL(const VISU_DeformedShapePL&); + + virtual + ~VISU_DeformedShapePL(); + virtual THook* DoHook(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; vtkCellDataToPointData* myCellDataToPointData; diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 65c7ab7e..f3edad74 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -138,14 +138,9 @@ CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest ) //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_GaussPointsPL *aPipeLine = dynamic_cast(thePipeLine)){ - // To restore mapper input from pipeline - vtkPolyData* aDatsSet = myPSMapper->GetInput(); - myPSMapper->ShallowCopy(aPipeLine->GetPSMapper()); - myPSMapper->SetInput(aDatsSet); - SetPrimitiveType(aPipeLine->GetPrimitiveType()); SetBicolor(aPipeLine->GetBicolor()); SetClamp(aPipeLine->GetClamp()); @@ -163,7 +158,18 @@ VISU_GaussPointsPL mySphereSource->SetRadius( aPipeLine->mySphereSource->GetRadius() ); CopyGlyph( aPipeLine->myGlyph, this->myGlyph ); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); +} + + +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::DoCopyMapper(VISU_PipeLine *thePipeLine) +{ + if(VISU_GaussPointsPL* aPipeLine = dynamic_cast(thePipeLine)){ + VISU::CopyPointSpriteDataMapper(GetPSMapper(), aPipeLine->GetPSMapper()); + } } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 7f5f1ca7..da77134c 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -54,12 +54,6 @@ class SALOME_Transform; */ class VISU_GaussPointsPL : public VISU_ScalarMapPL { -protected: - VISU_GaussPointsPL(); - - virtual - ~VISU_GaussPointsPL(); - public: vtkTypeMacro(VISU_GaussPointsPL,VISU_ScalarMapPL); @@ -70,10 +64,6 @@ public: unsigned long int GetMTime(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - //! Get the native mapper. virtual TMapper* @@ -268,14 +258,40 @@ public: const char* theAlphaTexture ); public: - virtual void SetIsDeformed( bool theIsDeformed ); - virtual bool GetIsDeformed() const; + virtual + void + SetIsDeformed( bool theIsDeformed ); + + virtual + bool + GetIsDeformed() const; + + virtual + void + SetScale( vtkFloatingPointType theScale ); - virtual void SetScale( vtkFloatingPointType theScale ); - virtual vtkFloatingPointType GetScale(); - virtual void SetMapScale( vtkFloatingPointType theMapScale = 1.0 ); + virtual + vtkFloatingPointType + GetScale(); + + virtual + void + SetMapScale( vtkFloatingPointType theMapScale = 1.0 ); protected: + VISU_GaussPointsPL(); + + virtual + ~VISU_GaussPointsPL(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + + virtual + void + DoCopyMapper(VISU_PipeLine *thePipeLine); + bool myIsDeformed; vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; @@ -286,7 +302,6 @@ protected: vtkSphereSource* mySphereSource; int myResolution; -protected: VISU_OpenGLPointSpriteMapper* myPSMapper; VISU::PGaussPtsIDMapper myGaussPtsIDMapper; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index aa932005..43894fbe 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -53,14 +53,14 @@ VISU_IsoSurfacesPL void VISU_IsoSurfacesPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast(thePipeLine)){ SetNbParts(aPipeLine->GetNbParts()); vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()}; SetRange(aRange); } - VISU_ScalarMapPL::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } int @@ -82,7 +82,7 @@ void VISU_IsoSurfacesPL ::SetScaling(int theScaling) { - VISU_ScalarMapPL::SetScaling(theScaling); + Superclass::SetScaling(theScaling); SetRange(myRange); } void @@ -118,7 +118,7 @@ void VISU_IsoSurfacesPL ::Init() { - VISU_ScalarMapPL::Init(); + Superclass::Init(); SetNbParts(10); vtkFloatingPointType aScalarRange[2]; @@ -139,7 +139,7 @@ void VISU_IsoSurfacesPL ::Update() { - VISU_ScalarMapPL::Update(); + Superclass::Update(); } //---------------------------------------------------------------------------- @@ -166,7 +166,7 @@ void VISU_IsoSurfacesPL ::SetMapScale(vtkFloatingPointType theMapScale) { - VISU_ScalarMapPL::SetMapScale(theMapScale); + Superclass::SetMapScale(theMapScale); vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()}; vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]}; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 1ecc5ed0..2422746d 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -34,13 +34,6 @@ class vtkCellDataToPointData; class VISU_IsoSurfacesPL : public VISU_ScalarMapPL { -protected: - VISU_IsoSurfacesPL(); - VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&); - - virtual - ~VISU_IsoSurfacesPL(); - public: vtkTypeMacro(VISU_IsoSurfacesPL,VISU_ScalarMapPL); @@ -48,10 +41,6 @@ public: VISU_IsoSurfacesPL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual int GetNbParts(); @@ -99,6 +88,16 @@ public: SetMapScale(vtkFloatingPointType theMapScale = 1.0); protected: + VISU_IsoSurfacesPL(); + VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&); + + virtual + ~VISU_IsoSurfacesPL(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + int myNbParts; vtkFloatingPointType myRange[2]; vtkCellDataToPointData* myCellDataToPointData; diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index 680a21ab..af693934 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -205,7 +205,7 @@ bool InitializeARB() }; static bool IsARBInitialized = InitializeARB(); -static float Tolerance = 1.0 / VTK_LARGE_FLOAT; +static vtkFloatingPointType Tolerance = 1.0 / VTK_LARGE_FLOAT; //----------------------------------------------------------------------------- // Construct empty object. @@ -252,31 +252,7 @@ VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper() if( this->TempMapper ) this->TempMapper->Delete(); } -//----------------------------------------------------------------------------- -void VISU_OpenGLPointSpriteMapper::ShallowCopy( vtkAbstractMapper* mapper ) -{ - VISU_OpenGLPointSpriteMapper* m = VISU_OpenGLPointSpriteMapper::SafeDownCast(mapper); - if( m != NULL ) - { - this->SetPrimitiveType( m->GetPrimitiveType() ); - - this->SetPointSpriteMode( m->GetPointSpriteMode() ); - - this->SetPointSpriteClamp( m->GetPointSpriteClamp() ); - this->SetPointSpriteSize( m->GetPointSpriteSize() ); - this->SetPointSpriteMinSize( m->GetPointSpriteMinSize() ); - this->SetPointSpriteMaxSize( m->GetPointSpriteMaxSize() ); - this->SetPointSpriteMagnification( m->GetPointSpriteMagnification() ); - this->SetImageData( m->GetImageData() ); - this->SetPointSpriteAlphaThreshold( m->GetPointSpriteAlphaThreshold() ); - } - - this->TempMapper->ShallowCopy( m ); - this->TempMapper->SetInput( this->GetInput() ); - Superclass::ShallowCopy( this->TempMapper ); - -} //----------------------------------------------------------------------------- char* readFromFile( std::string fileName ) { @@ -554,6 +530,13 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) act->GetProperty()->GetMTime() > this->BuildTime || ren->GetRenderWindow() != this->LastWindow) { + /* To contol when the mapper is recalculated + cout<<"VISU_OpenGLPointSpriteMapper::RenderPiece - " + <<(this->GetMTime() > this->BuildTime)<<"; " + <<(input->GetMTime() > this->BuildTime)<<"; " + <<(act->GetProperty()->GetMTime() > this->BuildTime)<<"; " + <Colors as side effect this->MapScalars( act->GetProperty()->GetOpacity() ); diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index 7af9a27a..6f99d0b0 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -90,8 +90,6 @@ public: static VISU_OpenGLPointSpriteMapper *New(); vtkTypeRevisionMacro(VISU_OpenGLPointSpriteMapper,MAPPER_SUPERCLASS); - void ShallowCopy(vtkAbstractMapper*); - //! Set the initial point size to be used. /*! * This value forms the base upon which the distance attenuation acts. diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 91c453a7..bc6944a6 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -98,7 +98,7 @@ void VISU_PipeLine ::DebugOn() { - myExtractGeometry->DebugOn(); + //myExtractGeometry->DebugOn(); Superclass::DebugOn(); } @@ -108,7 +108,7 @@ void VISU_PipeLine ::DebugOff() { - myExtractGeometry->DebugOff(); + //myExtractGeometry->DebugOff(); Superclass::DebugOff(); } @@ -118,23 +118,32 @@ VISU_PipeLine ::ShallowCopy(VISU_PipeLine *thePipeLine) { SetImplicitFunction(thePipeLine->GetImplicitFunction()); + DoShallowCopy(thePipeLine); +} - // To restore mapper input from pipeline - vtkDataSet* aDatsSet = myMapper->GetInput(); - GetMapper()->ShallowCopy(thePipeLine->GetMapper()); - myMapper->SetInput(aDatsSet); - +//---------------------------------------------------------------------------- +void +VISU_PipeLine +::DoShallowCopy(VISU_PipeLine *thePipeLine) +{ + DoCopyMapper(thePipeLine); Build(); } +//---------------------------------------------------------------------------- +void +VISU_PipeLine +::DoCopyMapper(VISU_PipeLine *thePipeLine) +{ + VISU::CopyMapper(GetMapper(), thePipeLine->GetMapper()); +} + //---------------------------------------------------------------------------- void VISU_PipeLine ::SameAs(VISU_PipeLine *thePipeLine) { - ShallowCopy(thePipeLine); - SetImplicitFunction(vtkImplicitBoolean::New()); - GetImplicitFunction()->Delete(); + DoShallowCopy(thePipeLine); } //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 95bf380e..251637ff 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -227,6 +227,14 @@ protected: virtual ~VISU_PipeLine(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + + virtual + void + DoCopyMapper(VISU_PipeLine *thePipeLine); + virtual TInput* GetInput2() const; diff --git a/src/PIPELINE/VISU_PipeLineUtils.cxx b/src/PIPELINE/VISU_PipeLineUtils.cxx index 9becc0c2..3e67f0d5 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.cxx +++ b/src/PIPELINE/VISU_PipeLineUtils.cxx @@ -26,6 +26,11 @@ #include "VISU_PipeLineUtils.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" + +#include +#include + void VISU::Mul(const vtkFloatingPointType A[3], vtkFloatingPointType b, @@ -42,3 +47,69 @@ VISU::Sub(const vtkFloatingPointType A[3], for(int i = 0; i < 3; i++) C[i] = A[i] - B[i]; } +namespace VISU +{ + bool + CheckIsSameRange(vtkFloatingPointType* theTarget, + vtkFloatingPointType* theSource) + { + static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT; + return std::abs(theTarget[0] - theSource[0]) + std::abs(theTarget[1] - theSource[1]) < TOL; +} + + void + CopyMapper(vtkMapper* theTarget, + vtkMapper* theSource) + { + // To customize vtkMapper::ShallowCopy ... + theTarget->SetLookupTable(theSource->GetLookupTable()); + theTarget->SetScalarVisibility(theSource->GetScalarVisibility()); + if(!CheckIsSameRange(theTarget->GetScalarRange(), theSource->GetScalarRange())) + theTarget->SetScalarRange(theSource->GetScalarRange()); + theTarget->SetColorMode(theSource->GetColorMode()); + theTarget->SetScalarMode(theSource->GetScalarMode()); + theTarget->SetImmediateModeRendering(theSource->GetImmediateModeRendering()); + theTarget->SetUseLookupTableScalarRange(theSource->GetUseLookupTableScalarRange()); + if(theSource->GetArrayAccessMode() == VTK_GET_ARRAY_BY_ID) + theTarget->ColorByArrayComponent(theSource->GetArrayId(), theSource->GetArrayComponent()); + else + theTarget->ColorByArrayComponent(theSource->GetArrayName(), theSource->GetArrayComponent()); + + // To customize vtkAbstractMapper3D::ShallowCopy ... + theTarget->SetClippingPlanes(theSource->GetClippingPlanes()); + } + + void + CopyPolyDataMapper(vtkPolyDataMapper* theTarget, + vtkPolyDataMapper* theSource) + { + // To customize vtkPolyDataMapper::ShallowCopy ... + //aTargetMapper->SetInput(aMapper->GetInput()); + theTarget->SetGhostLevel(theSource->GetGhostLevel()); + theTarget->SetNumberOfPieces(theSource->GetNumberOfPieces()); + theTarget->SetNumberOfSubPieces(theSource->GetNumberOfSubPieces()); + + CopyMapper(theTarget, theSource); + } + + void + CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget, + VISU_OpenGLPointSpriteMapper* theSource) + { + // To customize VISU_OpenGLPointSpriteMapper::ShallowCopy ... + theTarget->SetPrimitiveType( theSource->GetPrimitiveType() ); + + theTarget->SetPointSpriteMode( theSource->GetPointSpriteMode() ); + + theTarget->SetPointSpriteClamp( theSource->GetPointSpriteClamp() ); + theTarget->SetPointSpriteSize( theSource->GetPointSpriteSize() ); + theTarget->SetPointSpriteMinSize( theSource->GetPointSpriteMinSize() ); + theTarget->SetPointSpriteMaxSize( theSource->GetPointSpriteMaxSize() ); + theTarget->SetPointSpriteMagnification( theSource->GetPointSpriteMagnification() ); + + theTarget->SetImageData( theSource->GetImageData() ); + theTarget->SetPointSpriteAlphaThreshold( theSource->GetPointSpriteAlphaThreshold() ); + + CopyPolyDataMapper(theTarget, theSource); + } +} diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index 57e6347b..e4a655e9 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -55,6 +55,8 @@ #endif +class VISU_OpenGLPointSpriteMapper; + namespace VISU { void @@ -96,6 +98,25 @@ namespace VISU }else theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); } + + //! Checks whether the scalar range is the same or not + bool + CheckIsSameRange(vtkFloatingPointType* theTarget, + vtkFloatingPointType* theSource); + + //! Customizes vtkMapper::ShallowCopy + void + CopyMapper(vtkMapper* theTarget, vtkMapper* theSource); + + //! Customizes vtkPolyDataMapper::ShallowCopy + void + CopyPolyDataMapper(vtkPolyDataMapper* theTarget, + vtkPolyDataMapper* theSource); + + //! Customizes VISU_OpenGLPointSpriteMapper::ShallowCopy + void + CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget, + VISU_OpenGLPointSpriteMapper* theSource); } #endif diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 54f4c0c2..dbdf62ab 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -66,7 +66,7 @@ VISU_Plot3DPL::~VISU_Plot3DPL() void VISU_Plot3DPL:: -ShallowCopy(VISU_PipeLine *thePipeLine) +DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_Plot3DPL *aPipeLine = dynamic_cast(thePipeLine)){ SetOrientation (aPipeLine->GetPlaneOrientation(), @@ -77,7 +77,7 @@ ShallowCopy(VISU_PipeLine *thePipeLine) SetContourPrs( aPipeLine->GetIsContourPrs() ); SetNumberOfContours( aPipeLine->GetNumberOfContours() ); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } VISU_CutPlanesPL::PlaneOrientation diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index d2fd79fb..733f65be 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -37,19 +37,11 @@ class vtkCellDataToPointData; class VISU_Plot3DPL : public VISU_ScalarMapPL { -protected: - VISU_Plot3DPL(); - VISU_Plot3DPL(const VISU_Plot3DPL&); - public: vtkTypeMacro(VISU_Plot3DPL,VISU_ScalarMapPL); static VISU_Plot3DPL* New(); virtual ~VISU_Plot3DPL(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - VISU_CutPlanesPL::PlaneOrientation GetPlaneOrientation() const; @@ -125,7 +117,16 @@ public: void SetMapScale(vtkFloatingPointType theMapScale); protected: - virtual THook* DoHook(); + VISU_Plot3DPL(); + VISU_Plot3DPL(const VISU_Plot3DPL&); + + virtual + THook* + DoHook(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); vtkFloatingPointType myAngle[3]; bool myIsRelative, myIsContour; diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx index ec75b087..73922a8b 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx @@ -194,17 +194,16 @@ VISU_ScalarMapOnDeformedShapePL */ void VISU_ScalarMapOnDeformedShapePL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { - VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast(thePipeLine); - if(aPipeLine){ + if(VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast(thePipeLine)){ SetScale(aPipeLine->GetScale()); SetScalars(aPipeLine->GetScalars()); vtkFloatingPointType aRange[2]; aPipeLine->GetSourceRange(aRange); SetScalarRange(aRange); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } /*! diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx index fa990596..b57f0c1b 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx @@ -38,11 +38,6 @@ class vtkPointDataToCellData; class VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL { protected: - VISU_ScalarMapOnDeformedShapePL(); - - virtual ~VISU_ScalarMapOnDeformedShapePL(); - - VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); public: vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_ScalarMapPL); @@ -50,10 +45,6 @@ public: VISU_ScalarMapOnDeformedShapePL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void SetScale(vtkFloatingPointType theScale); @@ -112,6 +103,17 @@ public: SetMapScale(vtkFloatingPointType theMapScale = 1.0); protected: + VISU_ScalarMapOnDeformedShapePL(); + + virtual + ~VISU_ScalarMapOnDeformedShapePL(); + + VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + vtkFloatingPointType myScaleFactor; vtkWarpVector *myDeformVectors; vtkMergeFilter *myMergeFilter; diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 755e4575..e915b3c4 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -70,7 +70,7 @@ VISU_ScalarMapPL //---------------------------------------------------------------------------- void VISU_ScalarMapPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_ScalarMapPL *aPipeLine = dynamic_cast(thePipeLine)){ SetScalarRange(aPipeLine->GetScalarRange()); @@ -79,7 +79,7 @@ VISU_ScalarMapPL SetScaling(aPipeLine->GetScaling()); SetMapScale(aPipeLine->GetMapScale()); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } @@ -153,9 +153,10 @@ void VISU_ScalarMapPL ::SetScalarRange(vtkFloatingPointType theRange[2]) { - myFieldTransform->SetScalarRange(theRange); - myBarTable->SetRange(theRange); - Modified(); + if(!VISU::CheckIsSameRange(GetScalarRange(), theRange)){ + myFieldTransform->SetScalarRange(theRange); + myBarTable->SetRange(theRange); + } } void @@ -163,7 +164,8 @@ VISU_ScalarMapPL ::SetScalarMin(vtkFloatingPointType theValue) { vtkFloatingPointType aScalarRange[2] = {theValue, GetScalarRange()[1]}; - SetScalarRange(aScalarRange); + if(!VISU::CheckIsSameRange(GetScalarRange(), aScalarRange)) + SetScalarRange(aScalarRange); } void @@ -171,7 +173,8 @@ VISU_ScalarMapPL ::SetScalarMax(vtkFloatingPointType theValue) { vtkFloatingPointType aScalarRange[2] = {GetScalarRange()[0], theValue}; - SetScalarRange(aScalarRange); + if(!VISU::CheckIsSameRange(GetScalarRange(), aScalarRange)) + SetScalarRange(aScalarRange); } @@ -244,19 +247,22 @@ void VISU_ScalarMapPL ::Update() { - vtkFloatingPointType *aRange = myFieldTransform->GetScalarRange(); + vtkFloatingPointType *aRange = GetScalarRange(); vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; if(myBarTable->GetScale() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); - myMapperTable->SetRange(aScalarRange); + VISU_LookupTable::ComputeLogRange(aRange, aScalarRange); + + if(!VISU::CheckIsSameRange(myMapperTable->GetTableRange(), aScalarRange)) + myMapperTable->SetRange(aScalarRange); myMapperTable->Build(); myBarTable->Build(); myMapper->SetLookupTable(myMapperTable); - myMapper->SetScalarRange(aScalarRange); + if(!VISU::CheckIsSameRange(myMapper->GetScalarRange(), aScalarRange)) + myMapper->SetScalarRange(aScalarRange); - VISU_PipeLine::Update(); + Superclass::Update(); } diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index fb7be40a..97720d68 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -56,10 +56,6 @@ public: VISU_ScalarMapPL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - //---------------------------------------------------------------------------- virtual int @@ -148,6 +144,10 @@ protected: typedef vtkDataSet THook; virtual THook* DoHook(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + VISU_LookupTable* myMapperTable; VISU_LookupTable* myBarTable; VISU_FieldTransform* myFieldTransform; diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index 62cd50b4..b0b23805 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -50,7 +50,9 @@ static vtkFloatingPointType aCoeffOfIntStep = 1.0E+1; vtkStandardNewMacro(VISU_StreamLinesPL); -VISU_StreamLinesPL::VISU_StreamLinesPL(){ +VISU_StreamLinesPL +::VISU_StreamLinesPL() +{ myStream = vtkStreamLine::New(); myCenters = vtkCellCenters::New(); myGeomFilter = VTKViewer_GeometryFilter::New(); @@ -59,7 +61,9 @@ VISU_StreamLinesPL::VISU_StreamLinesPL(){ mySource = NULL; } -VISU_StreamLinesPL::~VISU_StreamLinesPL(){ +VISU_StreamLinesPL +::~VISU_StreamLinesPL() +{ myPointsFilter->UnRegisterAllOutputs(); myPointsFilter->Delete(); @@ -73,7 +77,10 @@ VISU_StreamLinesPL::~VISU_StreamLinesPL(){ myStream->Delete(); } -void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ +void +VISU_StreamLinesPL +::DoShallowCopy(VISU_PipeLine *thePipeLine) +{ if(VISU_StreamLinesPL *aPipeLine = dynamic_cast(thePipeLine)){ SetParams(aPipeLine->GetIntegrationStep(), aPipeLine->GetPropagationTime(), @@ -82,7 +89,7 @@ void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){ aPipeLine->GetUsedPoints(), aPipeLine->GetDirection()); } - VISU_DeformedShapePL::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index bf45db45..35cee6ab 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -53,10 +53,6 @@ public: VISU_StreamLinesPL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual size_t SetParams(vtkFloatingPointType theIntStep, @@ -197,6 +193,10 @@ public: vtkFloatingPointType thePercents = 0.3); protected: + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + static size_t GetNecasseryMemorySize(vtkIdType theNbOfPoints, diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index f6976ad3..813b4116 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -72,13 +72,13 @@ VISU_VectorsPL void VISU_VectorsPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine) { if(VISU_VectorsPL *aPipeLine = dynamic_cast(thePipeLine)){ SetGlyphType(aPipeLine->GetGlyphType()); SetGlyphPos(aPipeLine->GetGlyphPos()); } - Superclass::ShallowCopy(thePipeLine); + Superclass::DoShallowCopy(thePipeLine); } diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 38f8baaa..b8b3e6ea 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -55,10 +55,6 @@ public: VISU_VectorsPL* New(); - virtual - void - ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void SetScale(vtkFloatingPointType theScale); @@ -121,6 +117,10 @@ protected: THook* DoHook(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine); + GlyphType myTypeGlyph; GlyphPos myPosGlyph; vtkGlyph3D *myBaseGlyph; -- 2.39.2