From: apo Date: Mon, 26 Sep 2005 14:20:00 +0000 (+0000) Subject: To introduce outisde/inside representation of the Gauss Points X-Git-Tag: BR-D5-38-2003_D2005-12-10~137 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d13a3cfdc2cc10581dafa78377bed78acbc72f6;p=modules%2Fvisu.git To introduce outisde/inside representation of the Gauss Points --- diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index add0114e..3e35e780 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -48,6 +48,7 @@ LIB_SRC = \ VISU_Actor.cxx \ VISU_MeshAct.cxx \ VISU_ScalarMapAct.cxx \ + VISU_GaussPtsDeviceActor.cxx \ VISU_GaussPtsAct.cxx \ VISU_VectorsAct.cxx diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 6afb6871..1f455ff8 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -118,6 +118,19 @@ VISU_Actor Superclass::ShallowCopy(prop); } +void +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_Actor ::~VISU_Actor() diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 7aae1496..cf8efe7d 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -69,6 +69,10 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor void ShallowCopy(vtkProp *prop); + virtual + void + ShallowCopyPL(VISU_PipeLine* thePipeLine); + //---------------------------------------------------------------------------- virtual void @@ -106,7 +110,7 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor virtual void - SetPipeLine(VISU_PipeLine* thePipeLine) ; + SetPipeLine(VISU_PipeLine* thePipeLine); //---------------------------------------------------------------------------- virtual diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 76ae269c..36c8b75a 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -28,6 +28,8 @@ #include "VISU_GaussPtsAct.h" #include "VISU_GaussPointsPL.hxx" +#include "VISU_GaussPtsDeviceActor.h" +#include "VISU_ImplicitFunctionWidget.h" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "SVTK_Actor.h" @@ -65,6 +67,12 @@ #include #include +#include +#include +#include + +#include + #include "utilities.h" #ifdef _DEBUG_ @@ -73,181 +81,169 @@ static int MYDEBUG = 1; static int MYDEBUG = 0; #endif -// -/////////////////////////////////////////////////////////////////////////// -// -// class: VISU_CursorPyramid -// -class vtkConeSource; -class vtkRenderer; -class vtkPolyDataMapper; -class vtkActor; - -class VISU_CursorPyramid : public vtkObject { - +//---------------------------------------------------------------- +class VISU_CursorPyramid : public vtkObject +{ public: - void SetColor(const float theColor[3]); - - void SetColor(const float theR, - const float theG, - const float theB); - - float* Color(); - - void SetRadius(const float theR); - - float Radius()const; - - void SetResolution(const int theResolution); - - int Resolution()const; - - void SetAngle(const float theAngle); - - float Angle()const; - - void SetHeight(const float theHeight); - - float Height()const; - - void AddToRender(vtkRenderer* theRenderer); + vtkTypeMacro(VISU_CursorPyramid, vtkObject); - void RemoveFromRender(vtkRenderer* theRenderer); + static + VISU_CursorPyramid* + New(); - void SetVisibility (int); + void + AddToRender(vtkRenderer* theRenderer) + { + for(int i = 0; i < myNbCones; ++i) + theRenderer->AddActor(myActors[i].GetPointer()); + } - int GetVisibility () const; + void + RemoveFromRender(vtkRenderer* theRenderer) + { + for(int i = 0; i < myNbCones; ++i) + theRenderer->RemoveActor(myActors[i].GetPointer()); + } - void SetPosition(float theX, float theY, float theZ); + void + SetVisibility(int theVisibility) + { + for(int i = 0; i < myNbCones; ++i) + myActors[i]->SetVisibility(theVisibility); + } - void SetPosition(float thePosition[3]); + void + Init(float theHeight, + float theRadius, + float thePos[3], + float theColor[3]) + { + for(int i = 0; i < myNbCones; ++i){ + mySources[i]->SetHeight(theHeight); + // Set the angle of the cone. As a side effect, the angle plus height sets + // the base radius of the cone. + mySources[i]->SetAngle(20.0); + + myActors[i]->SetPosition(thePos[0],thePos[1],thePos[2]); + myActors[i]->GetProperty()->SetColor(theColor); + } + + float aD = -0.5*theHeight - theRadius; - void Init(); - // - vtkTypeMacro(VISU_CursorPyramid, vtkObject); + // X + mySources[0]->SetCenter(aD, 0.,0.); + mySources[1]->SetCenter(aD, 0.,0.); - static VISU_CursorPyramid* New(); - // + // Y + mySources[2]->SetDirection(0., 1., 0.); + mySources[2]->SetCenter(0, aD, 0.); -protected: - VISU_CursorPyramid(); + mySources[3]->SetDirection(0., 1., 0.); + mySources[3]->SetCenter(0., aD, 0.); - virtual ~VISU_CursorPyramid(); + // Z + mySources[4]->SetDirection(0., 0., 1.); + mySources[4]->SetCenter(0, 0., aD); + mySources[5]->SetDirection(0., 0., 1.); + mySources[5]->SetCenter(0., 0., aD); + } protected: - // sphere parameters - float myRadius; - // cone parameters - int myResolution; - float myAngle; - float myHeight; - // + VISU_CursorPyramid(): + myNbCones(6) + { + for(int i = 0; i < myNbCones; i++){ + vtkConeSource* aConeSource = vtkConeSource::New(); + aConeSource->SetResolution(4); + + vtkPolyDataMapper* aPolyDataMapper = vtkPolyDataMapper::New(); + aPolyDataMapper->SetInput(aConeSource->GetOutput()); + aConeSource->Delete(); + + vtkActor* anActor = vtkActor::New(); + anActor->SetMapper(aPolyDataMapper); + anActor->SetVisibility(0); + anActor->SetPickable(0); + aPolyDataMapper->Delete(); + + mySources[i] = aConeSource; + myMappers[i] = aPolyDataMapper; + myActors[i] = anActor; + anActor->Delete(); + } + + myActors[1]->SetOrientation(0. ,180.,0.); + myActors[3]->SetOrientation(0. , 0. ,180.); + myActors[5]->SetOrientation(180., 0. ,0.); + } + int myNbCones; - float myColor[3]; vtkSmartPointer mySources[6]; vtkSmartPointer myMappers[6]; vtkSmartPointer myActors[6]; }; -// -/////////////////////////////////////////////////////////////////////////// -// -// class: VISU_GPTextActor -// -class vtkViewport; +vtkStandardNewMacro(VISU_CursorPyramid); + + +//---------------------------------------------------------------- class VISU_GPTextActor : public vtkTextActor { -protected: - VISU_GPTextActor(); - virtual ~VISU_GPTextActor(); - public: vtkTypeMacro(VISU_GPTextActor, vtkTextActor); - static VISU_GPTextActor* New(); - // - void SetWorldPoint(const float theCoord[4]); - - float* WorldPoint(); - virtual int RenderOpaqueGeometry(vtkViewport *theViewport); + static + VISU_GPTextActor* + New(); + + void + Init(const float theWorldPoint[4], + const float theDistance = 10.0) + { + for(int i = 0; i < 4; i++) + myWorldPoint[i] = theWorldPoint[i]; + } + + virtual + int + RenderOpaqueGeometry(vtkViewport *theViewport) + { + float aSelectionPoint[3]; + theViewport->SetWorldPoint(myWorldPoint); + theViewport->WorldToDisplay(); + theViewport->GetDisplayPoint(aSelectionPoint); + + aSelectionPoint[0] += myDistance; + aSelectionPoint[1] += myDistance; + + SetPosition(aSelectionPoint); + Superclass::RenderOpaqueGeometry(theViewport); + } protected: - float myWorldPoint[4]; + float myWorldPoint[4]; + float myDistance; }; -// -/////////////////////////////////////////////////////////////////////////// -// -// class: VISU_CursorPyramid -// -#include -vtkStandardNewMacro(VISU_GPTextActor);// <- static VISU_GPTextActor* New() +vtkStandardNewMacro(VISU_GPTextActor); -//================================================================== -// function : Constructor -// purpose : -//================================================================== -VISU_GPTextActor::VISU_GPTextActor() -{ - float aCoord[]={0.,0.,0.,1}; - // - SetWorldPoint(aCoord); -} -//================================================================== -// function : ~ -// purpose : -//================================================================== -VISU_GPTextActor::~VISU_GPTextActor() -{ -} -//================================================================== -// function : SetWorldPoint -// purpose : -//================================================================== -void VISU_GPTextActor::SetWorldPoint(const float theCoord[4]) -{ - int i; - // - for (i=0; i<4; ++i){ - myWorldPoint[i]=theCoord[i]; - } -} -//================================================================== -// function : WorldPoint -// purpose : -//================================================================== -float* VISU_GPTextActor::WorldPoint() -{ - return myWorldPoint; -} -//================================================================== -// function : RenderOpaqueGeometry -// purpose : -//================================================================== -int VISU_GPTextActor::RenderOpaqueGeometry(vtkViewport *theViewport) + +//---------------------------------------------------------------- +VISU_GaussPtsAct* +VISU_GaussPtsAct +::New(bool theIsSegmented) { - float aSelectionPoint[3]; - // - theViewport->SetWorldPoint(myWorldPoint); - theViewport->WorldToDisplay(); - theViewport->GetDisplayPoint(aSelectionPoint); - SetPosition(aSelectionPoint); - // - Superclass::RenderOpaqueGeometry(theViewport); + return new VISU_GaussPtsAct(theIsSegmented); } - -// -//VISU_GaussPtsAct //---------------------------------------------------------------- -vtkStandardNewMacro(VISU_GaussPtsAct); - VISU_GaussPtsAct -::VISU_GaussPtsAct(): +::VISU_GaussPtsAct(bool theIsSegmented): myEventCallbackCommand(vtkCallbackCommand::New()), - myPSMapper(VISU_OpenGLPointSpriteMapper::New()), + myIsSegmented(theIsSegmented), + myWidget(NULL), myGaussPointsPL(NULL), myTextMapper(vtkTextMapper::New()), myTextActor(VISU_GPTextActor::New()), @@ -264,9 +260,27 @@ VISU_GaussPtsAct myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents); + if(!theIsSegmented){ + myDeviceActor = VISU_GaussPtsDeviceActor::New(); + myDeviceActor->SetProperty(GetProperty()); + myDeviceActor->SetVisibility(true); + myDeviceActor->SetPickable(false); + myDeviceActor->Delete(); + + myOutsideDeviceActor = VISU_GaussPtsDeviceActor::New(); + myOutsideDeviceActor->SetProperty(GetProperty()); + myOutsideDeviceActor->SetVisibility(false); + myOutsideDeviceActor->SetPickable(false); + myOutsideDeviceActor->Delete(); + } + myInsideDeviceActor = VISU_GaussPtsDeviceActor::New(); + myInsideDeviceActor->SetProperty(GetProperty()); + myInsideDeviceActor->SetVisibility(theIsSegmented); + myInsideDeviceActor->SetPickable(false); + myInsideDeviceActor->Delete(); + myTextMapper->Delete(); myTextActor->Delete(); - myPSMapper->Delete(); vtkTextProperty* aTextProperty = myTextMapper->GetTextProperty(); aTextProperty->SetVerticalJustification(VTK_TEXT_BOTTOM); @@ -288,37 +302,35 @@ VISU_GaussPtsAct // myCursorPyramid->Delete(); // - mySphereSourceSelected=vtkSphereSource::New(); - mySphereMapperSelected=vtkPolyDataMapper::New(); - mySphereActorSelected=vtkActor::New(); - // + mySphereSourceSelected = vtkSphereSource::New(); mySphereSourceSelected->Delete(); + + mySphereMapperSelected = vtkPolyDataMapper::New(); mySphereMapperSelected->Delete(); - mySphereActorSelected->Delete(); - // mySphereMapperSelected->SetInput(mySphereSourceSelected->GetOutput()); + + mySphereActorSelected = vtkActor::New(); + mySphereActorSelected->Delete(); mySphereActorSelected->SetMapper(mySphereMapperSelected.GetPointer()); mySphereActorSelected->SetVisibility(false); mySphereActorSelected->SetPickable(false); - float aColorSelected[3]={1.,1.,1.}; + float aColorSelected[3] = {1.,1.,1.}; mySphereActorSelected->GetProperty()->SetColor(aColorSelected); // // Cell myCellSource = vtkUnstructuredGrid::New(); - myCellSource->Allocate(); myCellSource->Delete(); + myCellSource->Allocate(); // myCellMapper = vtkDataSetMapper::New(); myCellMapper->Delete(); + myCellMapper->SetInput(myCellSource.GetPointer()); // myCellActor = vtkActor::New(); myCellActor->Delete(); - // - myCellMapper->SetInput(myCellSource.GetPointer()); myCellActor->SetMapper(myCellMapper.GetPointer()); myCellActor->SetVisibility(0); myCellActor->SetPickable(0); - // myCellActor->GetProperty()->SetAmbient(1.0); myCellActor->GetProperty()->SetDiffuse(0.0); myCellActor->GetProperty()->SetRepresentationToWireframe(); @@ -326,14 +338,60 @@ VISU_GaussPtsAct VISU_GaussPtsAct ::~VISU_GaussPtsAct() -{} +{ + if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<GetPSMapper(); + else + return myInsideDeviceActor->GetPSMapper(); +} + +void +VISU_GaussPtsAct +::ShallowCopyPL(VISU_PipeLine* thePipeLine) +{ + Superclass::ShallowCopyPL(thePipeLine); + + vtkPolyData* aDatsSet = GetPSMapper()->GetInput(); + GetPSMapper()->ShallowCopy(thePipeLine->GetMapper()); + + // To restore mapper input from pipeline + GetPSMapper()->SetInput(aDatsSet); + + if(VISU_GaussPointsPL* aPipeLine = dynamic_cast(thePipeLine)){ + if(!myIsSegmented){ + myDeviceActor->ShallowCopyPL(aPipeLine); + myOutsideDeviceActor->ShallowCopyPL(aPipeLine); + } + myInsideDeviceActor->ShallowCopyPL(aPipeLine); + + // Restore implicit function + if(myWidget){ + vtkImplicitFunction* aFunction = myWidget->ImplicitFunction(); + if(!myIsSegmented){ + myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(aFunction); + myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true); + myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff(); + } + myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(aFunction); + } + } +} + +vtkDataSet* +VISU_GaussPtsAct +::GetInput() +{ + vtkDataSet* aDataSet = GetMapper()->GetInput(); + aDataSet->Update(); + return aDataSet; } //---------------------------------------------------------------- @@ -342,37 +400,136 @@ VISU_GaussPtsAct ::AddToRender(vtkRenderer* theRenderer) { Superclass::AddToRender(theRenderer); + + if(!myIsSegmented){ + myDeviceActor->AddToRender(theRenderer); + myOutsideDeviceActor->AddToRender(theRenderer); + } + myInsideDeviceActor->AddToRender(theRenderer); + theRenderer->AddActor(myTextActor.GetPointer()); theRenderer->AddActor(mySphereActor.GetPointer()); theRenderer->AddActor(mySphereActorSelected.GetPointer()); - myCursorPyramid->AddToRender(theRenderer); theRenderer->AddActor(myCellActor.GetPointer()); + + myCursorPyramid->AddToRender(theRenderer); } void VISU_GaussPtsAct ::RemoveFromRender(vtkRenderer* theRenderer) { - myCursorPyramid->RemoveFromRender(theRenderer); + Superclass::RemoveFromRender(theRenderer); + + if(!myIsSegmented){ + myDeviceActor->RemoveFromRender(theRenderer); + myOutsideDeviceActor->RemoveFromRender(theRenderer); + } + myInsideDeviceActor->RemoveFromRender(theRenderer); + theRenderer->RemoveActor(mySphereActor.GetPointer()); theRenderer->RemoveActor(myTextActor.GetPointer()); theRenderer->RemoveActor(mySphereActorSelected.GetPointer()); - Superclass::RemoveFromRender(theRenderer); theRenderer->RemoveActor(myCellActor.GetPointer()); + + myCursorPyramid->RemoveFromRender(theRenderer); +} + +void +VISU_GaussPtsAct +::SetTransform(VTKViewer_Transform* theTransform) +{ + if(!myIsSegmented){ + myDeviceActor->SetTransform(theTransform); + myOutsideDeviceActor->SetTransform(theTransform); + } + myInsideDeviceActor->SetTransform(theTransform); + + Superclass::SetTransform(theTransform); + Modified(); +} + +int +VISU_GaussPtsAct +::RenderOpaqueGeometry(vtkViewport *viewport) +{ + return 1; +} + +int +VISU_GaussPtsAct +::RenderTranslucentGeometry(vtkViewport *viewport) +{ + return 1; +} + + +//---------------------------------------------------------------- +void +VISU_GaussPtsAct +::SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget) +{ + myWidget = theWidget; + theWidget->AddObserver(vtkCommand::EnableEvent, + myEventCallbackCommand.GetPointer(), + 0.0); + theWidget->AddObserver(vtkCommand::DisableEvent, + myEventCallbackCommand.GetPointer(), + 0.0); + if(!myIsSegmented) + myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction()); + myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction()); + + if(myWidget->IsEnabled()) + OnInteractorEvent(vtkCommand::EnableEvent); + else + OnInteractorEvent(vtkCommand::DisableEvent); } //---------------------------------------------------------------- +namespace +{ + VISU_GaussPointsPL* + CreatePipeLine(VISU_GaussPointsPL* thePipeLine) + { + VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New(); + aPipeLine->ShallowCopy(thePipeLine); + aPipeLine->Update(); + return thePipeLine; + } +} + void VISU_GaussPtsAct ::SetMapperInput(vtkDataSet* theDataSet) { if(vtkPolyData* aPolyData = dynamic_cast(theDataSet)){ - myPSMapper->SetInput(aPolyData); - SetMapper(myPSMapper.GetPointer()); + if(!myIsSegmented){ + myDeviceActor->SetPipeLine(GetGaussPointsPL()); + if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){ + myInsideDeviceActor->SetPipeLine(aPipeLine); + aPipeLine->Delete(); + } + if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){ + myOutsideDeviceActor->SetPipeLine(aPipeLine); + myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff(); + myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true); + aPipeLine->Delete(); + } + }else + myInsideDeviceActor->SetPipeLine(GetGaussPointsPL()); + vtkLODActor::SetMapper(GetMapper()); } } +vtkMapper* +VISU_GaussPtsAct +::GetMapper() +{ + return GetPSMapper(); +} + void VISU_GaussPtsAct ::SetPipeLine(VISU_PipeLine* thePipeLine) @@ -422,6 +579,13 @@ VISU_GaussPtsAct ::SetVisibility(int theMode) { Superclass::SetVisibility(theMode); + + if(!myIsSegmented){ + myDeviceActor->SetVisibility(GetVisibility() && !myWidget->IsEnabled()); + myOutsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled()); + } + myInsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled()); + mySetVisibilitySignal(GetVisibility()); } @@ -485,8 +649,19 @@ VISU_GaussPtsAct return; } myUpdatePrs3dSignal(this); - return; + break; } + case vtkCommand::EnableEvent: + case vtkCommand::DisableEvent: + if(!myIsSegmented){ + myDeviceActor->SetVisibility(GetVisibility() && !myWidget->IsEnabled()); + myOutsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled()); + myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true); + myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff(); + } + myInsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled()); + break; + default: break; } } @@ -538,7 +713,7 @@ VISU_GaussPtsAct // To calculate display (2D) position of the annotation float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0}; - myTextActor->SetWorldPoint(aWorldCoord); + myTextActor->Init(aWorldCoord); // To prepare the annotation text std::ostringstream aStr; aStr<<"Global ID: "<GetMapperTable(); aLookupTable->GetColor(aVal,aColor); mySphereActor->GetProperty()->SetColor(aColor); - // - float aMaxPointSize; - // - aMaxPointSize=myGaussPointsPL->GetMaxPointSize(); - - myCursorPyramid->SetHeight(aMaxPointSize); - myCursorPyramid->SetRadius(aRadius); - myCursorPyramid->SetColor(aColor); - myCursorPyramid->SetPosition(aNodeCoord); - myCursorPyramid->Init(); + + myCursorPyramid->Init(myGaussPointsPL->GetMaxPointSize(), + aRadius, + aNodeCoord, + aColor); } if(vtkDataArray *aVectorArray = aCellData->GetVectors()){ @@ -592,7 +762,7 @@ VISU_GaussPtsAct myTextActor->SetVisibility(true); mySphereActor->SetVisibility(true); - myCursorPyramid->SetVisibility(1); + myCursorPyramid->SetVisibility(true); myIsPreselected = theIsHighlight; anIsChanged = true; } @@ -668,11 +838,8 @@ VISU_GaussPtsAct theSelector->AddIObject(this); } // - float *aNodeCoord, aRadius, aDollyWas; - // - aNodeCoord = GetNodeCoord(anObjId); - // - aDollyWas = anIteractor->GetDolly(); + float* aNodeCoord = GetNodeCoord(anObjId); + float aDollyWas = anIteractor->GetDolly(); anIteractor->SetDolly(0.0); anIteractor->FlyTo(aRenderer,aNodeCoord); aRenderer->ResetCameraClippingRange(); @@ -680,28 +847,24 @@ VISU_GaussPtsAct // // To calculate display (2D) position of the annotation float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; - myTextActor->SetWorldPoint(aWorldCoord); + myTextActor->Init(aWorldCoord); // // Selected mySphereSourceSelected->SetCenter(aNodeCoord); // vtkDataSet* aDataSet = GetInput(); vtkCellData* aCellData = aDataSet->GetCellData(); - vtkDataArray *aScalarArray = aCellData->GetScalars(); - // - aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray); - mySphereSourceSelected->SetRadius(aRadius); - // - if (theSelector->HasIndex(myIO)) { - mySphereActorSelected->SetVisibility(1); - } - else { - mySphereActorSelected->SetVisibility(0); - mySphereActor->SetVisibility(1); + if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ + float aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray); + mySphereSourceSelected->SetRadius(aRadius); + if(theSelector->HasIndex(myIO)){ + mySphereActorSelected->SetVisibility(1); + }else{ + mySphereActorSelected->SetVisibility(0); + mySphereActor->SetVisibility(1); + } + myTextActor->SetVisibility(1); } - // - myTextActor->SetVisibility(1); - // if(aSelectionMode == CellSelection){ // Hilighting an element from the parent Mesh if(theSelector->HasIndex(myIO)){ @@ -839,289 +1002,3 @@ VISU_GaussPtsAct //mySphereActor->SetVisibility(aSphereVisibility); return bRet; } -// -/////////////////////////////////////////////////////////////////////////// -// -// class: VISU_CursorPyramid -// -#include -#include -#include - -vtkStandardNewMacro(VISU_CursorPyramid); - -//================================================================== -// function : Constructor -// purpose : -//================================================================== -VISU_CursorPyramid::VISU_CursorPyramid() -{ - int i; - // - myResolution=4; - myAngle=20.; - myHeight=1.; - myRadius=4.; - myNbCones=6; - // - for (i=0; iDelete(); - mySources[i]->Delete(); - myActors [i]->Delete(); - // - myMappers[i]->SetInput(mySources[i]->GetOutput()); - myActors [i]->SetMapper(myMappers[i].GetPointer()); - myActors [i]->SetPickable(0); - } - // - SetVisibility(0); - SetPosition(0.,0.,0.); - SetColor (1.,1.,1.); - // - myActors[1]->SetOrientation(0. ,180.,0.); - myActors[3]->SetOrientation(0. , 0. ,180.); - myActors[5]->SetOrientation(180., 0. ,0.); - // - Init(); -} -//================================================================== -// function : Init -// purpose : -//================================================================== -void VISU_CursorPyramid::Init() -{ - float aD; - // - SetResolution(myResolution); - SetAngle(myAngle); - SetHeight(myHeight); - // - aD=-0.5*myHeight-myRadius; - // - // X - //mySources[0]->SetDirection(1., 0., 0.); - mySources[0]->SetCenter(aD, 0.,0.); - //myActors [0]->GetProperty()->SetColor(myColor); - // - //mySources[1]->SetDirection(1., 0., 0.); - mySources[1]->SetCenter(aD, 0.,0.); - //myActors [1]->GetProperty()->SetColor(myColor); - // - // Y - mySources[2]->SetDirection(0., 1., 0.); - mySources[2]->SetCenter(0, aD, 0.); - //myActors [2]->GetProperty()->SetColor(myColor); - // - mySources[3]->SetDirection(0., 1., 0.); - mySources[3]->SetCenter(0., aD, 0.); - //myActors [3]->GetProperty()->SetColor(myColor); - // - // Z - mySources[4]->SetDirection(0., 0., 1.); - mySources[4]->SetCenter(0, 0., aD); - //myActors [4]->GetProperty()->SetColor(myColor); - // - mySources[5]->SetDirection(0., 0., 1.); - mySources[5]->SetCenter(0., 0., aD); - //myActors [5]->GetProperty()->SetColor(myColor); -} -//================================================================== -// function : SetColor -// purpose : -//================================================================== -void VISU_CursorPyramid::SetColor(const float theR, - const float theG, - const float theB) -{ - float aColor[3]; - // - aColor[0]=theR; - aColor[1]=theG; - aColor[2]=theB; - SetColor(aColor); -} -//================================================================== -// function : SetColor -// purpose : -//================================================================== -void VISU_CursorPyramid::SetColor(const float theColor[3]) -{ - int i; - // - for (i=0; i<3; ++i) { - myColor[i]=theColor[i]; - } - for (i=0; iGetProperty()->SetColor(myColor); - } -} -//================================================================== -// function : Color -// purpose : -//================================================================== - float* VISU_CursorPyramid::Color() -{ - return myColor; -} -//================================================================== -// function : SetRadius -// purpose : -//================================================================== -void VISU_CursorPyramid::SetRadius(const float theR) -{ - myRadius=theR; - //Init(); -} -//================================================================== -// function : Radius -// purpose : -//================================================================== -float VISU_CursorPyramid::Radius()const -{ - return myRadius; -} -//================================================================== -// function : SetResolution -// purpose : -//================================================================== -void VISU_CursorPyramid::SetResolution(const int theResolution) -{ - int i; - // - myResolution=theResolution; - // - for (i=0; iSetResolution(myResolution); - } -} -//================================================================== -// function : Resolution -// purpose : -//================================================================== -int VISU_CursorPyramid::Resolution()const -{ - return myResolution; -} -//================================================================== -// function : SetAngle -// purpose : -//================================================================== -void VISU_CursorPyramid::SetAngle(const float theAngle) -{ - int i; - // - myAngle=theAngle; - // - for (i=0; iSetAngle(myAngle); - } -} -//================================================================== -// function : Angle -// purpose : -//================================================================== -float VISU_CursorPyramid::Angle()const -{ - return myAngle; -} -//================================================================== -// function : SetHeight -// purpose : -//================================================================== -void VISU_CursorPyramid::SetHeight(const float theHeight) -{ - int i; - // - myHeight=theHeight; - // - for (i=0; iSetHeight(myHeight); - } -} -//================================================================== -// function : Height -// purpose : -//================================================================== -float VISU_CursorPyramid::Height()const -{ - return myHeight; -} -//================================================================== -// function : SetVisibility -// purpose : -//================================================================== -void VISU_CursorPyramid::SetVisibility(const int theVisibility) -{ - int i; - // - for (i=0; iSetVisibility(theVisibility); - } -} -//================================================================== -// function : GetVisibility -// purpose : -//================================================================== -int VISU_CursorPyramid::GetVisibility()const -{ - return myActors[0]->GetVisibility(); -} -//================================================================== -// function : AddToRender -// purpose : -//================================================================== -void VISU_CursorPyramid::AddToRender(vtkRenderer* theRenderer) -{ - int i; - // - for (i=0; iAddActor(myActors[i].GetPointer()); - } -} -//================================================================== -// function : RemoveFromRender -// purpose : -//================================================================== -void VISU_CursorPyramid::RemoveFromRender(vtkRenderer* theRenderer) -{ - int i; - // - for (i=0; iRemoveActor(myActors[i].GetPointer()); - } -} -//================================================================== -// function : SetPosition -// purpose : -//================================================================== -void VISU_CursorPyramid::SetPosition(float theX, - float theY, - float theZ) -{ - int i; - // - for (i=0; iSetPosition(theX,theY, theZ); - } -} -//================================================================== -// function : SetPosition -// purpose : -//================================================================== -void VISU_CursorPyramid::SetPosition(float thePosition[3]) -{ - SetPosition(thePosition[0], - thePosition[1], - thePosition[2]); -} -//================================================================== -// function : ~ -// purpose : -//================================================================== -VISU_CursorPyramid::~VISU_CursorPyramid() -{ -} diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index f32454e8..e68c056f 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -35,6 +35,7 @@ #include class VISU_GaussPointsPL; +class VISU_ImplicitFunctionWidget; class VISU_OpenGLPointSpriteMapper; class vtkTextMapper; @@ -45,6 +46,7 @@ class vtkPolyDataMapper; class vtkActor; class vtkInteractorStyle; +class VISU_GaussPtsDeviceActor; class VISU_CursorPyramid; class VISU_GPTextActor; @@ -62,19 +64,28 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct static VISU_GaussPtsAct* - New(); - - VISU_OpenGLPointSpriteMapper* - GetPSMapper(); + New(bool theIsSegmented = false); //---------------------------------------------------------------------------- virtual void SetPipeLine(VISU_PipeLine* thePipeLine) ; + virtual + void + ShallowCopyPL(VISU_PipeLine* thePipeLine); + VISU_GaussPointsPL* GetGaussPointsPL(); + VISU_OpenGLPointSpriteMapper* + GetPSMapper(); + + virtual + vtkDataSet* + GetInput(); + + //---------------------------------------------------------------------------- virtual void SetFactory(VISU::TActorFactory* theActorFactory); @@ -106,6 +117,25 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct void SetInteractor(vtkRenderWindowInteractor* theInteractor); + virtual + void + SetTransform(VTKViewer_Transform* theTransform); + + virtual + vtkMapper* + GetMapper(); + + virtual + int + RenderOpaqueGeometry(vtkViewport *viewport); + + virtual + int + RenderTranslucentGeometry(vtkViewport *viewport); + + void + SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget); + //---------------------------------------------------------------------------- virtual bool @@ -120,9 +150,9 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight); - //---------------------------------------------------------------------------- protected: - VISU_GaussPtsAct(); + //---------------------------------------------------------------------------- + VISU_GaussPtsAct(bool theIsSegmented = false); virtual ~VISU_GaussPtsAct(); @@ -150,7 +180,14 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct bool myChangeMagnification; //---------------------------------------------------------------------------- - vtkSmartPointer myPSMapper; + typedef vtkSmartPointer PDeviceActor; + PDeviceActor myDeviceActor; + + VISU_ImplicitFunctionWidget* myWidget; + PDeviceActor myOutsideDeviceActor; + PDeviceActor myInsideDeviceActor; + bool myIsSegmented; + vtkSmartPointer myGaussPointsPL; vtkSmartPointer myTextMapper; @@ -168,8 +205,8 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct vtkSmartPointer mySphereActorSelected; vtkSmartPointer myCellSource; - vtkSmartPointer myCellMapper; - vtkSmartPointer myCellActor; + vtkSmartPointer myCellMapper; + vtkSmartPointer myCellActor; }; #endif diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx new file mode 100644 index 00000000..938dcdfb --- /dev/null +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -0,0 +1,161 @@ +// SMESH OBJECT : interactive object for SMESH visualization +// +// 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 : +// $Header$ + + +#include "VISU_GaussPtsDeviceActor.h" + +#include "VISU_GaussPointsPL.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" + +#include "VTKViewer_Transform.h" +#include "VTKViewer_TransformFilter.h" +#include "VTKViewer_PassThroughFilter.h" + +#include +#include +#include + +#include "utilities.h" + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; + + +//---------------------------------------------------------------- +vtkStandardNewMacro(VISU_GaussPtsDeviceActor); + + +VISU_GaussPtsDeviceActor +::VISU_GaussPtsDeviceActor(): + myMapper(VISU_OpenGLPointSpriteMapper::New()), + myGeomFilter(VTKViewer_GeometryFilter::New()), + myTransformFilter(VTKViewer_TransformFilter::New()) +{ + if(MYDEBUG) MESSAGE("VISU_GaussPtsDeviceActor - "<Delete(); + myGeomFilter->Delete(); + myTransformFilter->Delete(); + + for(int i = 0; i < 3; i++){ + PPassThroughFilter aFilter(VTKViewer_PassThroughFilter::New()); + myPassFilter.push_back(aFilter); + aFilter->Delete(); + } +} + + +VISU_GaussPtsDeviceActor +::~VISU_GaussPtsDeviceActor() +{ + if(MYDEBUG) MESSAGE("~VISU_GaussPtsDeviceActor - "<AddActor(this); +} + +void +VISU_GaussPtsDeviceActor +::RemoveFromRender(vtkRenderer* theRenderer) +{ + theRenderer->RemoveActor(this); +} + + +//---------------------------------------------------------------- +void +VISU_GaussPtsDeviceActor +::SetDataSet(vtkPolyData* theDataSet) +{ + int anId = 0; + myPassFilter[ anId ]->SetInput( theDataSet ); + myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); + + anId++; + myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); + + anId++; + myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() ); + + myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); + + vtkLODActor::SetMapper( myMapper.GetPointer() ); +} + +void +VISU_GaussPtsDeviceActor +::SetTransform(VTKViewer_Transform* theTransform) +{ + myTransformFilter->SetTransform(theTransform); +} + +VISU_OpenGLPointSpriteMapper* +VISU_GaussPtsDeviceActor +::GetPSMapper() +{ + return myMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- +void +VISU_GaussPtsDeviceActor +::SetPipeLine(VISU_GaussPointsPL* thePipeLine) +{ + myPipeLine = thePipeLine; + SetDataSet(thePipeLine->GetPSMapper()->GetInput()); +} + +VISU_GaussPointsPL* +VISU_GaussPtsDeviceActor +::GetPipeLine() +{ + return myPipeLine.GetPointer(); +} + +void +VISU_GaussPtsDeviceActor +::ShallowCopyPL(VISU_GaussPointsPL* thePipeLine) +{ + myPipeLine->ShallowCopy(thePipeLine); + GetPSMapper()->ShallowCopy(thePipeLine->GetMapper()); + + // To restore mapper input from pipeline + SetDataSet(myPipeLine->GetPSMapper()->GetInput()); +} diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h new file mode 100644 index 00000000..c26b6fb8 --- /dev/null +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -0,0 +1,100 @@ +// SMESH OBJECT : interactive object for SMESH visualization +// +// 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 : +// $Header$ + +#ifndef VISU_GAUSS_PTS_DEVICE_ACTOR_H +#define VISU_GAUSS_PTS_DEVICE_ACTOR_H + +#include "VTKViewer_GeometryFilter.h" + +#include +#include + +class VTKViewer_Transform; +class VTKViewer_TransformFilter; +class VTKViewer_PassThroughFilter; + +class VISU_OpenGLPointSpriteMapper; +class VISU_GaussPointsPL; + + +//---------------------------------------------------------------------------- +class VISU_GaussPtsDeviceActor: public vtkLODActor +{ + public: + vtkTypeMacro(VISU_GaussPtsDeviceActor,vtkLODActor); + + static + VISU_GaussPtsDeviceActor* + New(); + + //---------------------------------------------------------------------------- + void + AddToRender(vtkRenderer* theRenderer); + + void + RemoveFromRender(vtkRenderer* theRenderer); + + void + SetTransform(VTKViewer_Transform* theTransform); + + //---------------------------------------------------------------------------- + VISU_GaussPointsPL* + GetPipeLine(); + + void + SetPipeLine(VISU_GaussPointsPL* thePipeLine) ; + + void + ShallowCopyPL(VISU_GaussPointsPL* thePipeLine); + + VISU_OpenGLPointSpriteMapper* + GetPSMapper(); + + protected: + //---------------------------------------------------------------------------- + void + SetDataSet(vtkPolyData* theDataSet); + + vtkSmartPointer myPipeLine; + vtkSmartPointer myMapper; + vtkSmartPointer myGeomFilter; + vtkSmartPointer myTransformFilter; + + typedef vtkSmartPointer PPassThroughFilter; + std::vector myPassFilter; + + VISU_GaussPtsDeviceActor(); + ~VISU_GaussPtsDeviceActor(); + + VISU_GaussPtsDeviceActor(const VISU_GaussPtsDeviceActor&); // Not implemented + void operator=(const VISU_GaussPtsDeviceActor&); // Not implemented + +}; + + +#endif //VISU_GAUSS_PTS_DEVICE_ACTOR_H