From: apo Date: Mon, 12 Sep 2005 05:20:24 +0000 (+0000) Subject: To introduce segmentation functionality X-Git-Tag: BR-D5-38-2003_D2005-12-09~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4af92a28ededd5541675dd3e05bb01986398b9fb;p=modules%2Fvisu.git To introduce segmentation functionality --- diff --git a/resources/Visu_PlaneSegmentation.png b/resources/Visu_PlaneSegmentation.png new file mode 100644 index 00000000..eb538d00 Binary files /dev/null and b/resources/Visu_PlaneSegmentation.png differ diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index dceb3573..07df18eb 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -34,6 +34,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = \ VISU_Actor.h \ + VISU_ActorFactory.h \ VISU_MeshAct.h \ VISU_ScalarMapAct.h \ VISU_GaussPtsAct.h \ @@ -61,7 +62,7 @@ CPPFLAGS+= $(OCC_INCLUDES) $(VTK_INCLUDES) \ -I${GUI_ROOT_DIR}/include/salome \ $(BOOST_CPPFLAGS) -LDFLAGS+= $(VTK_LIBS) -lSalomeObject -lVisuPipeLine \ +LDFLAGS+= $(VTK_LIBS) -lSalomeObject -lSVTK -lVisuPipeLine \ -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 1b959f19..1a6d565e 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -69,15 +69,17 @@ static int MYDEBUG = 1; static int MYDEBUG = 0; #endif -//======================================================================= +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_Actor); +//---------------------------------------------------------------------------- VISU_Actor::VISU_Actor(): myIsVTKMapping(false), myParent(this), myPrs3d(NULL), myPipeLine(NULL), + myActorFactory(NULL), myMapper(vtkDataSetMapper::New()), myIsShrunk(false), myIsShrinkable(false), @@ -98,7 +100,23 @@ VISU_Actor::VISU_Actor(): myAnnotationActor.GetPointer()->SetVisibility(0); } -VISU_Actor::~VISU_Actor(){ +//---------------------------------------------------------------------------- +void +VISU_Actor +::ShallowCopy(vtkProp *prop) +{ + VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop); + if(anActor != NULL){ + setName(anActor->getName()); + if(anActor->hasIO()) setIO(anActor->getIO()); + } + SALOME_Actor::ShallowCopy(prop); +} + +//---------------------------------------------------------------------------- +VISU_Actor +::~VISU_Actor() +{ SALOME_Actor::SetProperty(NULL); myMapper->Delete(); @@ -109,16 +127,50 @@ VISU_Actor::~VISU_Actor(){ myShrinkFilter->Delete(); } -void VISU_Actor::setIO(const Handle(SALOME_InteractiveObject)& theIO){ +//---------------------------------------------------------------------------- +void +VISU_Actor +::setIO(const Handle(SALOME_InteractiveObject)& theIO) +{ SALOME_Actor::setIO(theIO); myName = theIO->getName(); } -void VISU_Actor::SetPrs3d(VISU::Prs3d_i* thePrs3d){ +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetPrs3d(VISU::Prs3d_i* thePrs3d) +{ myPrs3d = thePrs3d; } -void VISU_Actor::SetPipeLine(VISU_PipeLine* thePipeLine) { +VISU::Prs3d_i* +VISU_Actor +::GetPrs3d() +{ + return myPrs3d; +} + +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetFactory(VISU::TActorFactory* theActorFactory) +{ + myActorFactory = theActorFactory; +} + +VISU::TActorFactory* +VISU_Actor +::GetFactory() +{ + return myActorFactory; +} + +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetPipeLine(VISU_PipeLine* thePipeLine) +{ if (myPipeLine != thePipeLine){ if (myPipeLine != NULL) myPipeLine->UnRegister(this); myPipeLine = thePipeLine; @@ -134,38 +186,68 @@ void VISU_Actor::SetPipeLine(VISU_PipeLine* thePipeLine) { throw std::runtime_error("VISU_Actor::SetPipeLine >> Diagonal of the actor is too large !!!"); if(!aDataSet->GetNumberOfCells()) throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no visible elements"); - //Bug SAL4221: Mesh with less than 10 cells : shrink mode disable - //SetShrinkable(aDataSet->GetNumberOfCells() > 10); SetShrinkable(thePipeLine->IsShrinkable()); - //Now, we use vtkShrinkPolyData (not vtkShrinkFilter), - //and the class there is no such limitation. myMapper->SetInput(aDataSet); SetMapper(myMapper); } } -void VISU_Actor::SetParent(VISU_Actor* theParent){ +VISU_PipeLine* +VISU_Actor +::GetPipeLine() +{ + return myPipeLine; +} + +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetParent(VISU_Actor* theParent) +{ myParent = theParent; } -void VISU_Actor::SetRepresentation(int theMode) { - SALOME_Actor::SetRepresentation(theMode); - if(myRepresentation == VTK_POINTS) - UnShrink(); +VISU_Actor* +VISU_Actor +::GetParent() +{ + return myParent; } -void VISU_Actor::SetOpacity(float theValue){ - GetProperty()->SetOpacity(theValue); + +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetVisibility(int theMode) +{ + SALOME_Actor::SetVisibility(theMode); } -float VISU_Actor::GetOpacity(){ - return GetProperty()->GetOpacity(); +int +VISU_Actor +::GetVisibility() +{ + return SALOME_Actor::GetVisibility(); +} + +void +VISU_Actor +::SetRepresentation(int theMode) +{ + SALOME_Actor::SetRepresentation(theMode); + if(myRepresentation == VTK_POINTS) + UnShrink(); } -void VISU_Actor::SetShrink(){ - if(!myIsShrinkable) return; +//---------------------------------------------------------------------------- +void +VISU_Actor +::SetShrink() +{ + if(!myIsShrinkable) + return; if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ myShrinkFilter->SetInput(aDataSet); myPassFilter[1]->SetInput(myShrinkFilter->GetOutput()); @@ -173,8 +255,12 @@ void VISU_Actor::SetShrink(){ } } -void VISU_Actor::UnShrink(){ - if(!myIsShrunk) return; +void +VISU_Actor +::UnShrink() +{ + if(!myIsShrunk) + return; if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ myPassFilter[1]->SetInput(aDataSet); myPassFilter[1]->Modified(); @@ -183,45 +269,95 @@ void VISU_Actor::UnShrink(){ } } -void VISU_Actor::SetShrinkable(bool theIsShrinkable){ +bool +VISU_Actor +::IsShrunk() +{ + return myIsShrunk; +} + +void +VISU_Actor +::SetShrinkable(bool theIsShrinkable) +{ myIsShrinkable = theIsShrinkable; } -void VISU_Actor::SetShrinkFactor(float theValue){ +bool +VISU_Actor +::IsShrunkable() +{ + return myIsShrinkable; +} + +void +VISU_Actor +::SetShrinkFactor(float theValue) +{ myShrinkFilter->SetShrinkFactor(theValue); Modified(); } -float VISU_Actor::GetShrinkFactor(){ +float +VISU_Actor +::GetShrinkFactor() +{ return myShrinkFilter->GetShrinkFactor(); } //---------------------------------------------------------------------------- -void VISU_Actor::SetVisibility(int theMode){ - SALOME_Actor::SetVisibility(theMode); +void +VISU_Actor +::SetOpacity(float theValue) +{ + GetProperty()->SetOpacity(theValue); } -int VISU_Actor::GetVisibility(){ - return SALOME_Actor::GetVisibility(); +float +VISU_Actor +::GetOpacity() +{ + return GetProperty()->GetOpacity(); } -void VISU_Actor::SetLineWidth(float theLineWidth){ +void +VISU_Actor +::SetLineWidth(float theLineWidth) +{ GetProperty()->SetLineWidth(theLineWidth); } -float VISU_Actor::GetLineWidth(){ +float +VISU_Actor +::GetLineWidth() +{ return GetProperty()->GetLineWidth(); } -//---------------------------------------------------------------------------- -void VISU_Actor::ShallowCopy(vtkProp *prop){ - VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop); - if(anActor != NULL){ - setName(anActor->getName()); - if(anActor->hasIO()) setIO(anActor->getIO()); - } - SALOME_Actor::ShallowCopy(prop); +//================================================================== +// function: AddToRender +// purpose : +//================================================================== +void +VISU_Actor +::AddToRender(vtkRenderer* theRenderer) +{ + Superclass::AddToRender(theRenderer); + theRenderer->AddActor(myAnnotationActor.GetPointer()); +} + +//================================================================== +// function: RemoveFromRender +// purpose : +//================================================================== +void +VISU_Actor +::RemoveFromRender(vtkRenderer* theRenderer) +{ + theRenderer->RemoveActor(myAnnotationActor.GetPointer()); + Superclass::RemoveFromRender(theRenderer); + } //---------------------------------------------------------------------------- @@ -232,6 +368,13 @@ VISU_Actor myIsVTKMapping = theIsVTKMapping; } +bool +VISU_Actor +::IsVTKMapping() const +{ + return myIsVTKMapping; +} + //---------------------------------------------------------------------------- vtkDataSet* VISU_Actor @@ -411,23 +554,3 @@ bool VISU_Actor::PreHighlight( SVTK_Selector* theSelector, return bRet; } -//================================================================== -// function: AddToRender -// purpose : -//================================================================== -void VISU_Actor::AddToRender(vtkRenderer* theRenderer) -{ - - Superclass::AddToRender(theRenderer); - theRenderer->AddActor(myAnnotationActor.GetPointer()); -} -//================================================================== -// function: RemoveFromRender -// purpose : -//================================================================== -void VISU_Actor::RemoveFromRender(vtkRenderer* theRenderer) -{ - theRenderer->RemoveActor(myAnnotationActor.GetPointer()); - Superclass::RemoveFromRender(theRenderer); - -} diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 13c736f2..1b295708 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -30,6 +30,7 @@ #define VISU_ACTOR_H #include "SALOME_Actor.h" +#include "VISU_ActorFactory.h" #include #include @@ -43,10 +44,6 @@ class vtkInteractorStyle; class VTKViewer_ShrinkFilter; class VISU_PipeLine; -namespace VISU { - class Prs3d_i; -} - #ifdef _WIN_32 #define VTKOCC_EXPORT __declspec (dllexport) #else @@ -57,49 +54,126 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { public: vtkTypeMacro(VISU_Actor,SALOME_Actor); - void ShallowCopy(vtkProp *prop); - static VISU_Actor* New(); - virtual ~VISU_Actor(); - virtual void setIO(const Handle(SALOME_InteractiveObject)& theIO); + static + VISU_Actor* + New(); + + void + ShallowCopy(vtkProp *prop); + + virtual + ~VISU_Actor(); + + //---------------------------------------------------------------------------- + virtual + void + setIO(const Handle(SALOME_InteractiveObject)& theIO); + + VISU::Prs3d_i* + GetPrs3d(); + + virtual + void + SetPrs3d(VISU::Prs3d_i* thePrs3d); + + VISU::TActorFactory* + GetFactory(); + + virtual + void + SetFactory(VISU::TActorFactory* theActorFactory); + + virtual + VISU_PipeLine* + GetPipeLine(); + + virtual + void + SetPipeLine(VISU_PipeLine* thePipeLine) ; + + VISU_Actor* + GetParent(); + + virtual + void + SetParent(VISU_Actor* theParent); + + //---------------------------------------------------------------------------- + virtual + void + SetVisibility(int theMode); + + virtual + int + GetVisibility(); + + virtual + void + SetRepresentation(int theMode); + + //---------------------------------------------------------------------------- + virtual + bool + IsShrunkable(); - VISU::Prs3d_i* GetPrs3d(){ return myPrs3d;} - virtual void SetPrs3d(VISU::Prs3d_i* thePrs3d); + virtual + bool + IsShrunk(); - virtual VISU_PipeLine* GetPipeLine() { return myPipeLine;} - virtual void SetPipeLine(VISU_PipeLine* thePipeLine) ; + virtual + void + SetShrink(); + + virtual + void + UnShrink(); - VISU_Actor* GetParent(){ return myParent;} - virtual void SetParent(VISU_Actor* theParent); + virtual + void + SetShrinkable(bool theIsShrinkable); - virtual void SetOpacity(float theValue); - virtual float GetOpacity(); + virtual + void + SetShrinkFactor(float theFactor = 0.8); - virtual void SetRepresentation(int theMode); + virtual + float + GetShrinkFactor(); - virtual bool IsShrunkable() { return myIsShrinkable;} - virtual bool IsShrunk() { return myIsShrunk;} - virtual void SetShrink(); - virtual void UnShrink(); + //---------------------------------------------------------------------------- + virtual + void + SetOpacity(float theValue); - virtual void SetShrinkable(bool theIsShrinkable); - virtual void SetShrinkFactor(float theFactor = 0.8); - virtual float GetShrinkFactor(); + virtual + float + GetOpacity(); - virtual void SetVisibility(int theMode); - virtual int GetVisibility(); + virtual + void + SetLineWidth(float theLineWidth); - virtual void SetLineWidth(float theLineWidth); - virtual float GetLineWidth(); + virtual + float + GetLineWidth(); - virtual void AddToRender( vtkRenderer* ); + //---------------------------------------------------------------------------- + virtual + void + AddToRender( vtkRenderer* ); - virtual void RemoveFromRender( vtkRenderer* ); + virtual + void + RemoveFromRender( vtkRenderer* ); - virtual bool PreHighlight( SVTK_Selector*, - vtkInteractorStyle*, - SVTK_SelectionEvent, - bool ); + //---------------------------------------------------------------------------- + virtual + bool + PreHighlight( SVTK_Selector*, + vtkInteractorStyle*, + SVTK_SelectionEvent, + bool ); virtual void @@ -107,10 +181,7 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor virtual bool - IsVTKMapping() const - { - return myIsVTKMapping; - } + IsVTKMapping() const; virtual vtkDataSet* @@ -148,6 +219,7 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor VISU::Prs3d_i* myPrs3d; VISU_PipeLine* myPipeLine; vtkDataSetMapper* myMapper; + VISU::TActorFactory* myActorFactory; VTKViewer_ShrinkFilter* myShrinkFilter; bool myIsShrinkable; diff --git a/src/OBJECT/VISU_ActorFactory.h b/src/OBJECT/VISU_ActorFactory.h new file mode 100644 index 00000000..db5b570d --- /dev/null +++ b/src/OBJECT/VISU_ActorFactory.h @@ -0,0 +1,59 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : +// Module : VISU +// $Header$ + +#ifndef VISU_ACTOR_FACTORY_H +#define VISU_ACTOR_FACTORY_H + +#include "SALOME_InteractiveObject.hxx" + +class VISU_Actor; +class vtkPlane; + +namespace VISU +{ + class Prs3d_i; + + struct TActorFactory + { + virtual + VISU_Actor* + CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0; + + virtual + bool + AddClippingPlane(VISU_Actor* theActor, + vtkPlane* thePlane) = 0; + + virtual + void + RemoveAllClippingPlanes(VISU_Actor* theActor) = 0; + }; +} + + +#endif //VISU_ACTOR_FACTORY_H diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index c456b71d..2b2393b9 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -214,8 +215,11 @@ int VISU_GPTextActor::RenderOpaqueGeometry(vtkViewport *theViewport) // Superclass::RenderOpaqueGeometry(theViewport); } + + // //VISU_GaussPtsAct +//---------------------------------------------------------------- vtkStandardNewMacro(VISU_GaussPtsAct); VISU_GaussPtsAct @@ -226,8 +230,8 @@ VISU_GaussPtsAct myLastObjPointID(-1), mySphereSource(vtkSphereSource::New()), mySphereMapper(vtkPolyDataMapper::New()), - mySphereActor(vtkActor::New()) - ,myCursorPyramid(VISU_CursorPyramid::New()) + mySphereActor(vtkActor::New()), + myCursorPyramid(VISU_CursorPyramid::New()) { myTextMapper->Delete(); myTextActor->Delete(); @@ -258,6 +262,8 @@ VISU_GaussPtsAct ::~VISU_GaussPtsAct() {} + +//---------------------------------------------------------------- void VISU_GaussPtsAct ::AddToRender(vtkRenderer* theRenderer) @@ -278,6 +284,8 @@ VISU_GaussPtsAct Superclass::RemoveFromRender(theRenderer); } + +//---------------------------------------------------------------- void VISU_GaussPtsAct ::SetPipeLine(VISU_PipeLine* thePipeLine) @@ -286,6 +294,13 @@ VISU_GaussPtsAct Superclass::SetPipeLine(thePipeLine); } +VISU_GaussPointsPL* +VISU_GaussPtsAct +::GetGaussPointsPL() +{ + return myGaussPointsPL.GetPointer(); +} + //---------------------------------------------------------------- bool VISU_GaussPtsAct diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 34c1f8c2..3916fe8a 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -33,6 +33,7 @@ #include class VISU_GaussPointsPL; + class vtkTextMapper; class vtkTextActor; @@ -56,6 +57,9 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct virtual void SetPipeLine(VISU_PipeLine* thePipeLine) ; + + VISU_GaussPointsPL* + GetGaussPointsPL(); virtual void @@ -84,6 +88,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct virtual ~VISU_GaussPtsAct(); vtkSmartPointer myGaussPointsPL; + vtkSmartPointer myTextMapper; vtkSmartPointer myTextActor; vtkIdType myLastObjPointID; diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index d5f2024a..07e19ef7 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -128,6 +128,10 @@ int main(int argc, char** argv){ aPresent->Build(); aPresent->Init(); aPresent->SetSourceRange(); + vtkDataSet* anOutput = aPresent->GetMapper()->GetInput(); + for(int i = 0, iEnd = anOutput->GetNumberOfCells(); i < iEnd; i++){ + cout<GetPointSize(i)<SetNumberOfContours(50); //aPresent->SetNbParts(1); //aPresent->SetOrientation(VISU_CutPlanesPL::XY,0.0,0.0); diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 6dfb8142..4d4dc0d7 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -37,8 +37,10 @@ #include #include +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_GaussPointsPL); +//---------------------------------------------------------------------------- VISU_GaussPointsPL ::VISU_GaussPointsPL(): myRelativeMinSize(0.03), @@ -50,6 +52,29 @@ VISU_GaussPointsPL myGeomFilter = vtkGeometryFilter::New(); } +void +VISU_GaussPointsPL +::ShallowCopy(VISU_PipeLine *thePipeLine) +{ + SetIDMapper(thePipeLine->GetIDMapper()); + myMapper->ShallowCopy(thePipeLine->GetMapper()); + Build(); + + if(VISU_GaussPointsPL *aPipeLine = dynamic_cast(thePipeLine)){ + SetScalarRange(aPipeLine->GetScalarRange()); + SetScalarMode(aPipeLine->GetScalarMode()); + SetNbColors(aPipeLine->GetNbColors()); + SetScaling(aPipeLine->GetScaling()); + + SetGaussMesh(aPipeLine->GetGaussMesh()); + SetRelativeMinSize(aPipeLine->GetRelativeMinSize()); + SetRelativeMaxSize(aPipeLine->GetRelativeMaxSize()); + Init(); + } +} + + +//---------------------------------------------------------------------------- VISU_PipeLine::TMapper* VISU_GaussPointsPL ::GetMapper() @@ -65,12 +90,11 @@ VISU_GaussPointsPL return myPSMapper; } +//---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Build() { - //cout << "VISU_GaussPointsPL::Build" << endl; - myExtractor->SetInput( GetInput2() ); myFieldTransform->SetInput( myExtractor->GetOutput() ); @@ -79,55 +103,9 @@ VISU_GaussPointsPL myGeomFilter->SetInput( myFieldTransform->GetUnstructuredGridOutput() ); myPSMapper->SetInput( myGeomFilter->GetOutput() ); - /* - // Create lots of points - vtkPointSource* blob = vtkPointSource::New(); - blob->SetRadius( 1 ); - blob->SetCenter( 0.0, 0.0, 0.0 ); - blob->SetNumberOfPoints( 10000 ); - blob->SetDistributionToUniform(); - - // Give them some colour - vtkElevationFilter* elev = vtkElevationFilter::New(); - elev->SetInput( blob->GetOutput() ); - elev->SetLowPoint( -1.0, 0.0, 0.0 ); - elev->SetHighPoint( 1.0, 0.0, 0.0 ); - myPSMapper->SetInput( elev->GetPolyDataOutput() ); - */ - // Create a Gaussian splat to use as sprite - vtkImageGaussianSource* gaussian = vtkImageGaussianSource::New(); - gaussian->SetWholeExtent( 0, 63, 0, 63, 0, 0 ); - gaussian->SetCenter( 31.5, 31.5, 0.0 ); - gaussian->SetMaximum( 255 ); - gaussian->SetStandardDeviation( 15 ); - - // Create a sprite mapper. - // Set Accumulate mode rendering - // Use Point fading to reduce size of points to sensible demo size - myPSMapper->SetImmediateModeRendering( 1 ); - myPSMapper->SetRenderModeToAccumulate(); - myPSMapper->SetQuadraticPointDistanceAttenuation( 1.0, 20.0, 0.0 ); - myPSMapper->SetParticleImage( gaussian->GetOutput() ); - /* - // texture for intensity - vtkXMLImageDataReader* aReader1 = vtkXMLImageDataReader::New(); - aReader1->SetFileName( "/dn06/salome/ouv/SALOME3/TextureIntensity.vti" ); - cout << "1st : " << aReader1->GetOutput() << endl; - GLuint textureIntensity = myPSMapper->LoadTexture( aReader1->GetOutput() ); - myPSMapper->SetTextureIntensity( textureIntensity ); - - // texture for alpha channel - vtkXMLImageDataReader* aReader2 = vtkXMLImageDataReader::New(); - aReader2->SetFileName( "/dn06/salome/ouv/SALOME3/TextureAlphaChannel.vti" ); - cout << "2nd : " << aReader2->GetOutput() << endl; - GLuint textureAlphaChannel = myPSMapper->LoadTexture( aReader2->GetOutput() ); - myPSMapper->SetTextureAlphaChannel( textureAlphaChannel ); - - aReader1->Delete(); - aReader2->Delete(); - */ } +//---------------------------------------------------------------------------- void VISU_GaussPointsPL:: Init() @@ -145,6 +123,7 @@ Init() myScalarArray = aCellData->GetScalars(); } +//---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Update() @@ -155,6 +134,7 @@ VISU_GaussPointsPL myPSMapper->SetScalarRange( myMapperTable->GetRange() ); } +//---------------------------------------------------------------------------- VISU_GaussPointsPL ::~VISU_GaussPointsPL() { @@ -170,7 +150,7 @@ VISU_GaussPointsPL } } -//======================================================================= +//---------------------------------------------------------------------------- VISU::TGaussPointID VISU_GaussPointsPL ::GetObjID(vtkIdType theID) const @@ -193,7 +173,7 @@ VISU_GaussPointsPL return myGaussMesh; } -//======================================================================= +//---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetRelativeMinSize(float theRelativeMinSize) @@ -202,6 +182,7 @@ VISU_GaussPointsPL Modified(); } +//---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetRelativeMaxSize(float theRelativeMaxSize) @@ -210,6 +191,7 @@ VISU_GaussPointsPL Modified(); } +//---------------------------------------------------------------------------- float VISU_GaussPointsPL ::GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray) @@ -222,6 +204,7 @@ VISU_GaussPointsPL return aMinSize + aDelta*(aVal - mySourceScalarRange[0])/myDeltaScalarRange; } +//---------------------------------------------------------------------------- float VISU_GaussPointsPL ::GetPointSize(vtkIdType theID) @@ -233,6 +216,7 @@ VISU_GaussPointsPL return GetPointSize(theID,aScalarArray); } +//---------------------------------------------------------------------------- float VISU_GaussPointsPL ::GetMaxPointSize() diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index af7b4384..4abcbb5e 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -49,6 +49,10 @@ public: static VISU_GaussPointsPL* New(); + + virtual + void + ShallowCopy(VISU_PipeLine *thePipeLine); virtual TMapper* @@ -74,7 +78,7 @@ public: SetGaussMesh(const VISU::PGaussMesh& theGaussMesh); const VISU::PGaussMesh& - GetGaussMesh()const; + GetGaussMesh() const; void SetRelativeMinSize(float theRelativeMinSize); diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index e2367b04..c0211b34 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -80,8 +80,11 @@ VISU_PipeLine::~VISU_PipeLine() myMapper->Delete(); } -void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){ - SetInput(thePipeLine->GetInput()); +void +VISU_PipeLine +::ShallowCopy(VISU_PipeLine *thePipeLine) +{ + SetIDMapper(thePipeLine->GetIDMapper()); myMapper->ShallowCopy(thePipeLine->GetMapper()); myExtractGeometry->SetImplicitBoolean(thePipeLine->myExtractGeometry->GetImplicitBoolean()); Build(); diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 5146b570..47ee9d15 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -38,6 +38,7 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif +//---------------------------------------------------------------------------- int VISU::GaussPoints_i ::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -56,20 +57,28 @@ VISU::GaussPoints_i return 0; } +//---------------------------------------------------------------------------- int VISU::GaussPoints_i::myNbPresent = 0; -QString VISU::GaussPoints_i::GenerateName() + +QString +VISU::GaussPoints_i +::GenerateName() { return VISU::GenerateName("Gauss Points",myNbPresent++); } +//---------------------------------------------------------------------------- const string VISU::GaussPoints_i::myComment = "GAUSSPOINTS"; + const char* -VISU::GaussPoints_i::GetComment() const +VISU::GaussPoints_i +::GetComment() const { return myComment.c_str(); } +//---------------------------------------------------------------------------- VISU::GaussPoints_i:: GaussPoints_i(Result_i* theResult, bool theAddToStudy) : @@ -82,6 +91,7 @@ GaussPoints_i(Result_i* theResult, } +//---------------------------------------------------------------------------- VISU::GaussPoints_i:: GaussPoints_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : @@ -94,6 +104,7 @@ GaussPoints_i(Result_i* theResult, } +//---------------------------------------------------------------------------- VISU::Storable* VISU::GaussPoints_i ::Create(const char* theMeshName, VISU::Entity theEntity, @@ -103,6 +114,7 @@ VISU::GaussPoints_i } +//---------------------------------------------------------------------------- VISU::Storable* VISU::GaussPoints_i ::Restore(const Storable::TRestoringMap& theMap) @@ -112,6 +124,7 @@ VISU::GaussPoints_i } +//---------------------------------------------------------------------------- void VISU::GaussPoints_i ::ToStream(std::ostringstream& theStr) @@ -127,6 +140,7 @@ VISU::GaussPoints_i } +//---------------------------------------------------------------------------- void VISU::GaussPoints_i ::DoSetInput(Result_i* theResult) @@ -149,6 +163,7 @@ VISU::GaussPoints_i } +//---------------------------------------------------------------------------- void VISU::GaussPoints_i ::DoHook() @@ -161,6 +176,20 @@ VISU::GaussPoints_i ScalarMap_i::DoHook(); } + +//---------------------------------------------------------------------------- +VISU_PipeLine* +VISU::GaussPoints_i +::GetPipeLine() +{ + VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New(); + aPipeLine->ShallowCopy(myPipeLine); + aPipeLine->Update(); + return aPipeLine; +} + + +//---------------------------------------------------------------------------- VISU_Actor* VISU::GaussPoints_i ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) @@ -179,9 +208,32 @@ VISU::GaussPoints_i } +//---------------------------------------------------------------------------- void VISU::GaussPoints_i ::UpdateActor(VISU_Actor* theActor) { VISU::ScalarMap_i::UpdateActor(theActor); } + + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::RemoveAllClippingPlanes(VISU_Actor* theActor) +{ + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + if(VISU_GaussPointsPL* aPipeLine = anActor->GetGaussPointsPL()) + aPipeLine->RemoveAllClippingPlanes(); +} + +bool +VISU::GaussPoints_i +::AddClippingPlane(VISU_Actor* theActor, + vtkPlane* thePlane) +{ + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + if(VISU_GaussPointsPL* aPipeLine = anActor->GetGaussPointsPL()) + aPipeLine->AddClippingPlane(thePlane); +} + diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 1c80fb61..ea8d52b7 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -57,27 +57,62 @@ namespace VISU virtual void DoSetInput(Result_i* theResult); virtual void DoHook(); + virtual + VISU_PipeLine* + GetPipeLine(); + VISU_GaussPointsPL *myGaussPointsPL; public: - static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration, int isMemoryCheck = true); - virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration); + static + int + IsPossible(Result_i* theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + int theIteration, + int isMemoryCheck = true); + virtual + Storable* + Create(const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + int theIteration); static const std::string myComment; - virtual const char* GetComment() const; - virtual QString GenerateName(); - virtual void ToStream(std::ostringstream& theStr); + virtual + const char* + GetComment() const; + + virtual + QString + GenerateName(); - virtual Storable* Restore(const Storable::TRestoringMap& theMap); + virtual + void + ToStream(std::ostringstream& theStr); + + virtual + Storable* + Restore(const Storable::TRestoringMap& theMap); virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL); - virtual void UpdateActor(VISU_Actor* theActor) ; + virtual + void + UpdateActor(VISU_Actor* theActor); + + virtual + void + RemoveAllClippingPlanes(VISU_Actor* theActor); + + virtual + bool + AddClippingPlane(VISU_Actor* theActor, + vtkPlane* thePlane); }; } diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 5e39d80e..91cb209e 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -41,8 +41,8 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -VISU::Prs3d_i:: -Prs3d_i(Result_i* theResult, +VISU::Prs3d_i +::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : PrsObject_i(theResult->GetStudyDocument()), myResult(theResult), @@ -54,8 +54,8 @@ Prs3d_i(Result_i* theResult, myResult->Register(); } -VISU::Prs3d_i:: -Prs3d_i(Result_i* theResult, +VISU::Prs3d_i +::Prs3d_i(Result_i* theResult, bool theAddToStudy) : PrsObject_i(theResult->GetStudyDocument()), myResult(theResult), @@ -67,7 +67,9 @@ Prs3d_i(Result_i* theResult, myResult->Register(); } -void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin) +void +VISU::Prs3d_i +::SameAs(const Prs3d_i* theOrigin) { if (Prs3d_i* aOrigin = const_cast(theOrigin)) { myPipeLine->SameAs(aOrigin->GetPL()); @@ -75,25 +77,28 @@ void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin) } } -VISU::Prs3d_i::~Prs3d_i() { +VISU::Prs3d_i +::~Prs3d_i() +{ if(MYDEBUG) MESSAGE("~Prs3d_i() - this = "<setIO(anIO); } - // } theActor->SetPipeLine(GetPipeLine()); + theActor->SetFactory(this); theActor->SetPrs3d(this); theActor->SetPosition(myOffset); }catch(std::bad_alloc& ex){ @@ -106,14 +111,19 @@ void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_Intera } } -void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) { +void +VISU::Prs3d_i +::UpdateActor(VISU_Actor* theActor) +{ if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<GetMapper()->ShallowCopy(myPipeLine->GetMapper()); theActor->SetPosition(myOffset); theActor->Modified(); } -VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap) +VISU::Storable* +VISU::Prs3d_i +::Restore(const Storable::TRestoringMap& theMap) { myName = VISU::Storable::FindValue(theMap,"myName").latin1(); myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat(); @@ -122,14 +132,20 @@ VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap) return this; } -void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){ +void +VISU::Prs3d_i +::ToStream(std::ostringstream& theStr) +{ Storable::DataToStream( theStr, "myName", myName.c_str() ); Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] ); Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] ); Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] ); } -void VISU::Prs3d_i::Update() { +void +VISU::Prs3d_i +::Update() +{ if(MYDEBUG) MESSAGE("Prs3d_i::Update() - this = "<Update(); @@ -138,20 +154,31 @@ void VISU::Prs3d_i::Update() { } } -VISU_PipeLine* VISU::Prs3d_i::GetPipeLine(){ +VISU_PipeLine* +VISU::Prs3d_i +::GetPipeLine() +{ return GetPL(); } -VISU_PipeLine* VISU::Prs3d_i::GetPL(){ +VISU_PipeLine* +VISU::Prs3d_i +::GetPL() +{ return myPipeLine; } -vtkUnstructuredGrid* VISU::Prs3d_i::GetInput(){ +vtkUnstructuredGrid* +VISU::Prs3d_i:: +GetInput() +{ return myPipeLine->GetInput(); } -SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){ +SALOMEDS::SObject_var +VISU::Prs3d_i::GetSObject() +{ if (CORBA::is_nil(mySObject.in())) { const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument(); CORBA::String_var anIOR = GetID(); @@ -160,60 +187,104 @@ SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){ return mySObject; } -void VISU::Prs3d_i::GetBounds(float aBounds[6]){ +void +VISU::Prs3d_i +::GetBounds(float aBounds[6]) +{ myPipeLine->GetMapper()->GetBounds(aBounds); } // Clipping planes -void VISU::Prs3d_i::RemoveAllClippingPlanes(){ +void +VISU::Prs3d_i +::RemoveAllClippingPlanes() +{ myPipeLine->RemoveAllClippingPlanes(); } -vtkIdType VISU::Prs3d_i::GetNumberOfClippingPlanes() const{ - return myPipeLine->GetNumberOfClippingPlanes(); +void +VISU::Prs3d_i +::RemoveAllClippingPlanes(VISU_Actor* theActor) +{ + RemoveAllClippingPlanes(); } -bool VISU::Prs3d_i::AddClippingPlane(vtkPlane* thePlane){ +bool +VISU::Prs3d_i +::AddClippingPlane(vtkPlane* thePlane) +{ return myPipeLine->AddClippingPlane(thePlane); } -vtkPlane* VISU::Prs3d_i::GetClippingPlane(vtkIdType theID) const{ +bool +VISU::Prs3d_i +::AddClippingPlane(VISU_Actor* theActor, + vtkPlane* thePlane) +{ + AddClippingPlane(thePlane); +} + +vtkIdType +VISU::Prs3d_i +::GetNumberOfClippingPlanes() const +{ + return myPipeLine->GetNumberOfClippingPlanes(); +} + +vtkPlane* +VISU::Prs3d_i:: +GetClippingPlane(vtkIdType theID) const +{ return myPipeLine->GetClippingPlane(theID); } -void VISU::Prs3d_i::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) { +void +VISU::Prs3d_i +::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) +{ myPipeLine->SetPlaneParam(theDir, theDist, thePlane); } -VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_ptr theSObject){ +VISU::Result_i* +VISU::GetResult(SALOMEDS::SObject_ptr theSObject) +{ VISU::Result_var aResult = FindResult(theSObject); if(!aResult->_is_nil()) return dynamic_cast(VISU::GetServant(aResult.in()).in()); return NULL; } -void VISU::Prs3d_i::SetOffset(const float* theOffsets) +void +VISU::Prs3d_i +::SetOffset(const float* theOffsets) { myOffset[0] = theOffsets[0]; myOffset[1] = theOffsets[1]; myOffset[2] = theOffsets[2]; } -void VISU::Prs3d_i::SetOffset(float theDx, float theDy, float theDz) +void +VISU::Prs3d_i +::SetOffset(float theDx, float theDy, float theDz) { myOffset[0] = theDx; myOffset[1] = theDy; myOffset[2] = theDz; } -void VISU::Prs3d_i::GetOffset(float* theOffsets) +void +VISU::Prs3d_i +::GetOffset(float* theOffsets) { theOffsets[0] = myOffset[0]; theOffsets[1] = myOffset[1]; theOffsets[2] = myOffset[2]; } -void VISU::Prs3d_i::GetOffset(float& theDx, float& theDy, float& theDz) + +void +VISU::Prs3d_i +::GetOffset(float& theDx, float& theDy, float& theDz) { theDx = myOffset[0]; theDy = myOffset[1]; diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 124a97ff..59ffa10b 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -28,10 +28,12 @@ #define VISU_Prs3d_i_HeaderFile #include "VISU_PrsObject_i.hh" -#include "SALOME_GenericObj_i.hh" -#include "Handle_SALOME_InteractiveObject.hxx" +#include "VISU_ActorFactory.h" #include "VISU_Convertor.hxx" +#include "SALOME_GenericObj_i.hh" +#include "SALOME_InteractiveObject.hxx" + #include class VISU_PipeLine; @@ -46,6 +48,7 @@ namespace VISU{ class Prs3d_i : public virtual POA_VISU::Prs3d, public virtual SALOME::GenericObj_i, + public virtual TActorFactory, public virtual PrsObject_i { @@ -59,8 +62,12 @@ namespace VISU{ explicit Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject); - virtual void SameAs(const Prs3d_i* theOrigin); - virtual ~Prs3d_i(); + virtual + void + SameAs(const Prs3d_i* theOrigin); + + virtual + ~Prs3d_i(); protected: bool myAddToStudy; @@ -70,53 +77,116 @@ namespace VISU{ SALOMEDS::SObject_var mySObject; std::string myMeshName; - void CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO = NULL); - virtual VISU_PipeLine* GetPipeLine(); + void + CreateActor(VISU_Actor* theActor, + const Handle(SALOME_InteractiveObject)& theIO = NULL); + + virtual + VISU_PipeLine* + GetPipeLine(); public: - virtual void Update() ; - VISU_PipeLine* GetPL(); + virtual + void + Update(); + + VISU_PipeLine* + GetPL(); + + vtkUnstructuredGrid* + GetInput(); + + void + GetBounds(float aBounds[6]); + + void + SetOffset(const float* theOffsets); - vtkUnstructuredGrid* GetInput(); + virtual + void + SetOffset(float theDx, float theDy, float theDz); - void GetBounds(float aBounds[6]); + void + GetOffset(float* theOffsets); - void SetOffset(const float* theOffsets); - virtual void SetOffset(float theDx, float theDy, float theDz); + virtual + void + GetOffset(float& theDx, float& theDy, float& theDz); - void GetOffset(float* theOffsets); - virtual void GetOffset(float& theDx, float& theDy, float& theDz); + virtual + const char* + GetComment() const = 0; - virtual const char* GetComment() const = 0; - virtual QString GenerateName() = 0; + virtual + QString + GenerateName() = 0; - virtual Storable* Restore(const Storable::TRestoringMap& theMap); + virtual + Storable* + Restore(const Storable::TRestoringMap& theMap); - virtual void ToStream(std::ostringstream& theStr); + virtual + void + ToStream(std::ostringstream& theStr); - virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0; + virtual + VISU_Actor* + CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0; - virtual void UpdateActor(VISU_Actor* theActor) ; + virtual + void + UpdateActor(VISU_Actor* theActor); - Result_i* GetResult() const { return myResult;} - virtual SALOMEDS::SObject_var GetSObject(); - const std::string& GetMeshName() const { return myMeshName; } + Result_i* + GetResult() const + { + return myResult; + } + + virtual + SALOMEDS::SObject_var + GetSObject(); + + const std::string& + GetMeshName() const + { + return myMeshName; + } // Clipping planes - void RemoveAllClippingPlanes(); - vtkIdType GetNumberOfClippingPlanes() const; - bool AddClippingPlane(vtkPlane* thePlane); - vtkPlane* GetClippingPlane(vtkIdType theID) const; + void + RemoveAllClippingPlanes(); + + virtual + void + RemoveAllClippingPlanes(VISU_Actor* theActor); + + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + bool + AddClippingPlane(VISU_Actor* theActor, + vtkPlane* thePlane); + + vtkIdType + GetNumberOfClippingPlanes() const; + + vtkPlane* + GetClippingPlane(vtkIdType theID) const; - void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane); + void + SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane); }; - Result_i* GetResult(SALOMEDS::SObject_ptr theSObject); + Result_i* + GetResult(SALOMEDS::SObject_ptr theSObject); template - Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap) + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const std::string& thePrefix, + const Storable::TRestoringMap& theMap) { VISU::Result_i* pResult = GetResult(theSObject); if(pResult != NULL){