From fcada13e9b9eb73e10d07530f452fd36cf492217 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 28 Sep 2005 08:52:41 +0000 Subject: [PATCH] To implement DebugOn/DebugOff virtual functions for the pipeline class hierarchy --- src/PIPELINE/VISU_PipeLine.cxx | 142 +++++++++++++++++++++++---------- src/PIPELINE/VISU_PipeLine.hxx | 110 +++++++++++++++++++------ 2 files changed, 186 insertions(+), 66 deletions(-) diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index be88e0b5..2ab8cd2c 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -52,15 +52,18 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -VISU_PipeLine::VISU_PipeLine() +VISU_PipeLine +::VISU_PipeLine(): + myMapper(vtkDataSetMapper::New()), + myExtractGeometry(SALOME_ExtractGeometry::New()) { - if(MYDEBUG) MESSAGE("VISU_PipeLine - "<Delete(); + // Clipping planes - myExtractGeometry = SALOME_ExtractGeometry::New(); myExtractGeometry->Delete(); - //myExtractGeometry->DebugOn(); myExtractGeometry->SetExtractInside(0); //myExtractGeometry->SetReleaseDataFlag(true); @@ -69,18 +72,32 @@ VISU_PipeLine::VISU_PipeLine() anImplicitBoolean->SetOperationTypeToIntersection(); anImplicitBoolean->Delete(); - // Mapper - myMapper = vtkDataSetMapper::New(); - myInput = NULL; - myIsShrinkable = false; } -VISU_PipeLine::~VISU_PipeLine() +VISU_PipeLine +::~VISU_PipeLine() { - if(MYDEBUG) MESSAGE("~VISU_PipeLine - "<Delete(); + if(MYDEBUG) MESSAGE("VISU_PipeLine::~VISU_PipeLine - "<DebugOn(); + Superclass::DebugOn(); +} + +// Turn debugging output off. +void +VISU_PipeLine +::DebugOff() +{ + myExtractGeometry->DebugOff(); + Superclass::DebugOff(); } void @@ -102,33 +119,42 @@ VISU_PipeLine void VISU_PipeLine::SameAs(VISU_PipeLine *thePipeLine){ ShallowCopy(thePipeLine); - vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); - SetImplicitFunction(anImplicitBoolean); - anImplicitBoolean->Delete(); + SetImplicitFunction(vtkImplicitBoolean::New()); + GetImplicitFunction()->Delete(); } -TInput* VISU_PipeLine::GetInput() const +TInput* +VISU_PipeLine +::GetInput() const { - return myInput; + return myInput.GetPointer(); } -TInput* VISU_PipeLine::GetInput2() const +TInput* +VISU_PipeLine +::GetInput2() const { vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput(); aDataSet->Update(); return aDataSet; } -void VISU_PipeLine::SetInput(TInput* theInput) +void +VISU_PipeLine +::SetInput(TInput* theInput) { + if(theInput) + theInput->Update(); + myExtractGeometry->SetInput(theInput); - if((myInput = theInput)) - myInput->Update(); + myInput = theInput; Modified(); } -VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper() +VISU_PipeLine::TMapper* +VISU_PipeLine +::GetMapper() { if(GetInput()){ if(!myMapper->GetInput()){ @@ -137,15 +163,19 @@ VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper() } myMapper->Update(); } - return myMapper; + return myMapper.GetPointer(); } -void VISU_PipeLine::Update() +void +VISU_PipeLine +::Update() { myMapper->Update(); } -int VISU_PipeLine::CheckAvailableMemory(const float& theSize) +int +VISU_PipeLine +::CheckAvailableMemory(const float& theSize) { try{ if(theSize > ULONG_MAX) return 0; @@ -166,7 +196,10 @@ int VISU_PipeLine::CheckAvailableMemory(const float& theSize) return 0; } -float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize) +float +VISU_PipeLine +::GetAvailableMemory(float theSize, + float theMinSize) { while(!CheckAvailableMemory(theSize)) if(theSize > theMinSize) @@ -177,8 +210,9 @@ float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize) } //------------------------ Clipping planes ----------------------------------- - -bool VISU_PipeLine::AddClippingPlane(vtkPlane* thePlane) +bool +VISU_PipeLine +::AddClippingPlane(vtkPlane* thePlane) { if (thePlane) { if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) { @@ -196,7 +230,9 @@ bool VISU_PipeLine::AddClippingPlane(vtkPlane* thePlane) return true; } -vtkPlane* VISU_PipeLine::GetClippingPlane(vtkIdType theID) const +vtkPlane* +VISU_PipeLine +::GetClippingPlane(vtkIdType theID) const { vtkPlane* aPlane = NULL; if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ @@ -212,7 +248,9 @@ vtkPlane* VISU_PipeLine::GetClippingPlane(vtkIdType theID) const return aPlane; } -void VISU_PipeLine::RemoveAllClippingPlanes() +void +VISU_PipeLine +::RemoveAllClippingPlanes() { if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); @@ -221,7 +259,9 @@ void VISU_PipeLine::RemoveAllClippingPlanes() } } -vtkIdType VISU_PipeLine::GetNumberOfClippingPlanes() const +vtkIdType +VISU_PipeLine +::GetNumberOfClippingPlanes() const { if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); @@ -230,9 +270,13 @@ vtkIdType VISU_PipeLine::GetNumberOfClippingPlanes() const return 0; } -static void ComputeBoundsParam (vtkDataSet* theDataSet, - float theDirection[3], float theMinPnt[3], - float& theMaxBoundPrj, float& theMinBoundPrj) +static +void +ComputeBoundsParam (vtkDataSet* theDataSet, + float theDirection[3], + float theMinPnt[3], + float& theMaxBoundPrj, + float& theMinBoundPrj) { float aBounds[6]; theDataSet->GetBounds(aBounds); @@ -274,8 +318,12 @@ static void ComputeBoundsParam (vtkDataSet* theDataSet, theMinPnt[2] = aMinPnt[2]; } -static void DistanceToPosition (vtkDataSet* theDataSet, - float theDirection[3], float theDist, float thePos[3]) +static +void +DistanceToPosition(vtkDataSet* theDataSet, + float theDirection[3], + float theDist, + float thePos[3]) { float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); @@ -285,8 +333,12 @@ static void DistanceToPosition (vtkDataSet* theDataSet, thePos[2] = aMinPnt[2]-theDirection[2]*aLength; } -static void PositionToDistance (vtkDataSet* theDataSet, - float theDirection[3], float thePos[3], float& theDist) +static +void +PositionToDistance (vtkDataSet* theDataSet, + float theDirection[3], + float thePos[3], + float& theDist) { float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); @@ -294,7 +346,11 @@ static void PositionToDistance (vtkDataSet* theDataSet, theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj); } -void VISU_PipeLine::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) +void +VISU_PipeLine +::SetPlaneParam(float theDir[3], + float theDist, + vtkPlane* thePlane) { thePlane->SetNormal(theDir); float anOrigin[3]; @@ -302,7 +358,11 @@ void VISU_PipeLine::SetPlaneParam (float theDir[3], float theDist, vtkPlane* the thePlane->SetOrigin(anOrigin); } -void VISU_PipeLine::GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane) +void +VISU_PipeLine +::GetPlaneParam(float theDir[3], + float& theDist, + vtkPlane* thePlane) { thePlane->GetNormal(theDir); @@ -315,7 +375,9 @@ void VISU_PipeLine::GetPlaneParam (float theDir[3], float& theDist, vtkPlane* th //function : IsPlanarInput //purpose : //======================================================================= -bool VISU_PipeLine::IsPlanarInput() const +bool +VISU_PipeLine +::IsPlanarInput() const { float aBounds[6]; GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 5f840922..09945f79 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -83,37 +83,85 @@ typedef VISU::TVTKOutput TInput; class VISU_PipeLine : public vtkObject{ public: vtkTypeMacro(VISU_PipeLine,vtkObject); - virtual ~VISU_PipeLine(); + virtual + ~VISU_PipeLine(); + + virtual + void + DebugOn(); + + virtual + void + DebugOff(); + + virtual + void + ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void ShallowCopy(VISU_PipeLine *thePipeLine); - virtual void SameAs(VISU_PipeLine *thePipeLine); + virtual + void + SameAs(VISU_PipeLine *thePipeLine); public: - virtual void SetInput(TInput* theInput); - virtual TInput* GetInput() const; + virtual + void + SetInput(TInput* theInput); - bool IsPlanarInput() const; + virtual + TInput* + GetInput() const; + + bool + IsPlanarInput() const; typedef vtkMapper TMapper; - virtual TMapper* GetMapper(); - virtual void Init() = 0; - virtual void Update(); + virtual + TMapper* + GetMapper(); + + virtual + void + Init() = 0; - static int CheckAvailableMemory(const float& theSize); - static float GetAvailableMemory(float theSize = 16*1024*1024.0, - float theMinSize = 1024*1024.0); + virtual + void + Update(); + + static + int + CheckAvailableMemory(const float& theSize); + + static + float + GetAvailableMemory(float theSize = 16*1024*1024.0, + float theMinSize = 1024*1024.0); // Clipping planes - void RemoveAllClippingPlanes(); - vtkIdType GetNumberOfClippingPlanes() const; - bool AddClippingPlane(vtkPlane* thePlane); - vtkPlane* GetClippingPlane(vtkIdType theID) const; + void + RemoveAllClippingPlanes(); + + vtkIdType + GetNumberOfClippingPlanes() const; + + bool + AddClippingPlane(vtkPlane* thePlane); - void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane); - void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane); + vtkPlane* + GetClippingPlane(vtkIdType theID) const; - bool IsShrinkable() { return myIsShrinkable; } + void + SetPlaneParam(float theDir[3], + float theDist, + vtkPlane* thePlane); + + void + GetPlaneParam(float theDir[3], + float& theDist, + vtkPlane* thePlane); + + bool + IsShrinkable() { return myIsShrinkable; } virtual vtkIdType @@ -145,22 +193,32 @@ public: const VISU::PIDMapper& GetIDMapper()const; - void SetImplicitFunction(vtkImplicitFunction *theFunction); - vtkImplicitFunction* GetImplicitFunction(); - void SetExtractInside (int); + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + vtkImplicitFunction* + GetImplicitFunction(); + + void + SetExtractInside(int); protected: VISU_PipeLine(); VISU_PipeLine(const VISU_PipeLine&); - virtual TInput* GetInput2() const; - virtual void Build() = 0; + virtual + TInput* + GetInput2() const; + + virtual + void + Build() = 0; bool myIsShrinkable; - TInput *myInput; + TVTKSmartPtr myInput; VISU::PIDMapper myIDMapper; - vtkDataSetMapper *myMapper; + TVTKSmartPtr myMapper; // Clipping planes TVTKSmartPtr myExtractGeometry; -- 2.39.2