From b7f07a6875e0ed9ff96a5b252e2da02a195c2b05 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 5 Jun 2008 12:12:05 +0000 Subject: [PATCH] *** empty log message *** --- src/OBJECT/VISU_Actor.cxx | 5 +++ src/OBJECT/VISU_Actor.h | 3 ++ src/OBJECT/VISU_DataSetActor.cxx | 7 ++-- src/OBJECT/VISU_DataSetActor.h | 4 +-- src/OBJECT/VISU_ScalarMapAct.cxx | 20 +++++++---- src/PIPELINE/VISU_DataSetMapperHolder.cxx | 14 ++++++++ src/PIPELINE/VISU_DataSetMapperHolder.hxx | 2 ++ src/PIPELINE/VISU_MapperHolder.hxx | 2 ++ src/PIPELINE/VISU_PipeLine.cxx | 6 ++++ src/PIPELINE/VISU_PipeLine.hxx | 2 ++ src/PIPELINE/VISU_PolyDataMapperHolder.cxx | 13 ++++++++ src/PIPELINE/VISU_PolyDataMapperHolder.hxx | 2 ++ src/VISUGUI/VisuGUI_ClippingDlg.cxx | 15 ++++----- src/VISUGUI/VisuGUI_ClippingDlg.h | 6 ++-- src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx | 39 ++++++++++------------ src/VISUGUI/VisuGUI_ClippingPlaneMgr.h | 8 ++--- src/VISUGUI/VisuGUI_SegmentationMgr.cxx | 22 ++++++++---- src/VISUGUI/VisuGUI_SegmentationMgr.h | 2 ++ 18 files changed, 119 insertions(+), 53 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index ac5501ab..5621c531 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -717,6 +717,11 @@ vtkPlane* VISU_Actor::GetClippingPlane(vtkIdType theID) return NULL; } +vtkImplicitFunctionCollection* VISU_Actor::GetClippingPlanes() +{ + return NULL; +} + //---------------------------------------------------------------------------- template std::string getScalar(TData* theData, int theId) { diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 688c3d85..e4e26779 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -47,6 +47,7 @@ class vtkCallbackCommand; class VTKViewer_ShrinkFilter; class VISU_PipeLine; class vtkPlane; +class vtkImplicitFunctionCollection; class VISU_FramedTextActor; @@ -265,6 +266,8 @@ class VTKOCC_EXPORT VISU_Actor : virtual vtkPlane* GetClippingPlane(vtkIdType theID); + virtual vtkImplicitFunctionCollection* GetClippingPlanes(); + //---------------------------------------------------------------------------- //! Apply the picking settings on the actor. void diff --git a/src/OBJECT/VISU_DataSetActor.cxx b/src/OBJECT/VISU_DataSetActor.cxx index 2ac67770..ca3891ac 100644 --- a/src/OBJECT/VISU_DataSetActor.cxx +++ b/src/OBJECT/VISU_DataSetActor.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -55,14 +55,14 @@ VISU_DataSetActor ::VISU_DataSetActor(): myMapper(vtkDataSetMapper::New()), myExtractor(SALOME_ExtractGeometry::New()), - myPolyDataExtractor(vtkExtractPolyDataGeometry::New()), + myPolyDataExtractor(SALOME_ExtractPolyDataGeometry::New()), myFunction(vtkImplicitBoolean::New()) { if(MYDEBUG) MESSAGE("VISU_DataSetActor::VISU_DataSetActor - this = "<SetImplicitFunction(myFunction); myPolyDataExtractor->SetImplicitFunction(myFunction); - //myExtractor->ExtractBoundaryCellsOn(); + myExtractor->ExtractBoundaryCellsOn(); myFunction->SetOperationTypeToIntersection(); @@ -105,6 +105,7 @@ VISU_DataSetActor myExtractor->SetInput(theDataSet); myMapper->SetInput(myExtractor->GetOutput()); } + // myMapper->SetInput(theDataSet); SetMapper(myMapper.GetPointer()); } diff --git a/src/OBJECT/VISU_DataSetActor.h b/src/OBJECT/VISU_DataSetActor.h index 65804229..4af55e3e 100644 --- a/src/OBJECT/VISU_DataSetActor.h +++ b/src/OBJECT/VISU_DataSetActor.h @@ -32,7 +32,7 @@ class vtkDataSetMapper; class SALOME_ExtractGeometry; -class vtkExtractPolyDataGeometry; +class SALOME_ExtractPolyDataGeometry; class vtkImplicitBoolean; class vtkImplicitFunctionCollection; @@ -85,7 +85,7 @@ class VTKOCC_EXPORT VISU_DataSetActor : public VISU_Actor //---------------------------------------------------------------------------- vtkSmartPointer myMapper; vtkSmartPointer myExtractor; - vtkSmartPointer myPolyDataExtractor; + vtkSmartPointer myPolyDataExtractor; vtkSmartPointer myFunction; }; diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 5f1774be..670a6f14 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -37,6 +37,7 @@ #include "VISU_PipeLineUtils.hxx" #include +#include #include #include @@ -276,12 +277,19 @@ VISU_ScalarMapAct { Superclass::SetMapperInput( theDataSet ); -// myPointsActor->SetInput( theDataSet ); -// mySurfaceActor->SetInput( theDataSet ); -// myEdgeActor->SetInput( theDataSet ); - myPointsActor->SetInput( myExtractor->GetOutput() ); - mySurfaceActor->SetInput( myExtractor->GetOutput() ); - myEdgeActor->SetInput( myExtractor->GetOutput() ); +// myPointsActor->SetInput( theDataSet ); +// mySurfaceActor->SetInput( theDataSet ); +// myEdgeActor->SetInput( theDataSet ); + + if (theDataSet->IsA("vtkPolyData")) { + myPointsActor->SetInput( myPolyDataExtractor->GetOutput() ); + mySurfaceActor->SetInput( myPolyDataExtractor->GetOutput() ); + myEdgeActor->SetInput( myPolyDataExtractor->GetOutput() ); + } else { + myPointsActor->SetInput( myExtractor->GetOutput() ); + mySurfaceActor->SetInput( myExtractor->GetOutput() ); + myEdgeActor->SetInput( myExtractor->GetOutput() ); + } } //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx index 313c6d68..0bc9e0de 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.cxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -297,6 +297,7 @@ VISU_DataSetMapperHolder if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) { vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); aFunction->AddItem(thePlane); + aBoolean->Modified(); // Check, that at least one cell present after clipping. // This check was introduced because of bug IPAL8849. vtkDataSet* aClippedDataSet = GetClippedInput(); @@ -326,6 +327,19 @@ VISU_DataSetMapperHolder return aPlane; } +//---------------------------------------------------------------------------- +void VISU_DataSetMapperHolder::RemoveClippingPlane(vtkIdType theID) +{ + if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ + if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunctions = aBoolean->GetFunction(); + aFunctions->RemoveItem(theID); + aBoolean->Modified(); + } + } +} + + //---------------------------------------------------------------------------- void VISU_DataSetMapperHolder diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx index 45fa07fe..d1980248 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.hxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -130,6 +130,8 @@ public: vtkPlane* GetClippingPlane(vtkIdType theID); + virtual void RemoveClippingPlane(vtkIdType theID); + protected: //---------------------------------------------------------------------------- VISU_DataSetMapperHolder(); diff --git a/src/PIPELINE/VISU_MapperHolder.hxx b/src/PIPELINE/VISU_MapperHolder.hxx index 756abdee..3a87d47c 100644 --- a/src/PIPELINE/VISU_MapperHolder.hxx +++ b/src/PIPELINE/VISU_MapperHolder.hxx @@ -139,6 +139,8 @@ public: vtkPlane* GetClippingPlane(vtkIdType theID) = 0; + virtual void RemoveClippingPlane(vtkIdType theID) = 0; + //---------------------------------------------------------------------------- virtual void diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index ea165bc0..4128c982 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -347,6 +347,12 @@ VISU_PipeLine return GetMapperHolder()->GetClippingPlane(theID); } +//---------------------------------------------------------------------------- +void VISU_PipeLine::RemoveClippingPlane(vtkIdType theID) +{ + return GetMapperHolder()->RemoveClippingPlane(theID); +} + //---------------------------------------------------------------------------- vtkDataSet* VISU_PipeLine diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 53015937..038e8dbe 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -159,6 +159,8 @@ public: vtkPlane* GetClippingPlane(vtkIdType theID); + virtual void RemoveClippingPlane(vtkIdType theID); + virtual void SetPlaneParam(vtkFloatingPointType theDir[3], diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.cxx b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx index 0b9cd227..55abef80 100644 --- a/src/PIPELINE/VISU_PolyDataMapperHolder.cxx +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx @@ -257,6 +257,7 @@ VISU_PolyDataMapperHolder if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) { vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); aFunction->AddItem(thePlane); + aBoolean->Modified(); // Check, that at least one cell present after clipping. // This check was introduced because of bug IPAL8849. vtkDataSet* aClippedDataSet = GetClippedInput(); @@ -286,6 +287,18 @@ VISU_PolyDataMapperHolder return aPlane; } +//---------------------------------------------------------------------------- +void VISU_PolyDataMapperHolder::RemoveClippingPlane(vtkIdType theID) +{ + if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunctions = aBoolean->GetFunction(); + aFunctions->RemoveItem(theID); + aBoolean->Modified(); + } + } +} + //---------------------------------------------------------------------------- void VISU_PolyDataMapperHolder diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.hxx b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx index dc9848ec..10ff1a4a 100644 --- a/src/PIPELINE/VISU_PolyDataMapperHolder.hxx +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx @@ -129,6 +129,8 @@ public: virtual vtkPlane* GetClippingPlane(vtkIdType theID); + + void RemoveClippingPlane(vtkIdType theID); protected: //---------------------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 0daf34c9..e3bab7c3 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -649,8 +649,10 @@ void VisuGUI_ClippingDlg::applyGlobalPlanes() VisuGUI_SegmentationMgr* aSegmentationMgr = aVisuExtender->getSegmentationMgr(aViewWindow); myDSActor->RemoveAllClippingPlanes(); + const QListOfPlanes& aPlanes = aSegmentationMgr->getPlanes(); PlaneDef aPlane; + for (int i = 0; i < myGlobalPlanes->count(); i++) { if (myGlobalPlanes->item(i)->checkState() == Qt::Checked) { aPlane = aPlanes.at(i); @@ -1383,8 +1385,8 @@ void VisuGUI_ClippingDlg::initGlobalPlanes() QListWidgetItem* aItem = new QListWidgetItem(aPlane.name, myGlobalPlanes); if (aPlane.isAuto) aItem->setFlags(0); - else - aItem->setCheckState(Qt::Unchecked); + // else + aItem->setCheckState(Qt::Unchecked); myGlobalPlanes->addItem(aItem); //Create preview @@ -1408,7 +1410,7 @@ void VisuGUI_ClippingDlg::initGlobalPlanes() break; } } - } + } } @@ -1416,7 +1418,7 @@ void VisuGUI_ClippingDlg::initGlobalPlanes() // function : initGlobalPlanes() // purpose : //================================================================================= -VISU_DataSetActor* VisuGUI_ClippingDlg::getSelectedActor() +VISU_Actor* VisuGUI_ClippingDlg::getSelectedActor() { SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI); @@ -1431,10 +1433,7 @@ VISU_DataSetActor* VisuGUI_ClippingDlg::getSelectedActor() if (!aPrs) return 0; VISU_Actor* aActor = VISU::FindActor(aViewWindow, aPrs); - if (!aActor) return 0; - - VISU_DataSetActor* aDSActor = dynamic_cast(aActor); - return aDSActor; + return aActor; } //================================================================================= diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.h b/src/VISUGUI/VisuGUI_ClippingDlg.h index f53bc1ec..87e14e86 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.h +++ b/src/VISUGUI/VisuGUI_ClippingDlg.h @@ -58,7 +58,7 @@ class VisuGUI; class vtkPlaneSource; class vtkDataSetMapper; class OrientedPlane; -class VISU_DataSetActor; +class VISU_Actor; class PreviewPlane; namespace VISU { @@ -140,7 +140,7 @@ private: void initGlobalPlanes(); bool hasGlobalPlanes(); - VISU_DataSetActor* getSelectedActor(); + VISU_Actor* getSelectedActor(); void applyLocalPlanes(); void applyGlobalPlanes(); @@ -193,7 +193,7 @@ private: QButtonGroup* myPlaneTypeGrp; QListWidget* myGlobalPlanes; bool myHasGlobalPl; - VISU_DataSetActor* myDSActor; + VISU_Actor* myDSActor; QList myPreviewList; protected: diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx index a0e1440f..c75610f6 100644 --- a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx @@ -23,7 +23,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" -#include "VISU_DataSetActor.h" +#include "VISU_Actor.h" #include #include @@ -288,22 +288,19 @@ void VisuGUI_ClippingPlaneMgr::saveState() while ( (aActor = anActors->GetNextActor()) ) { VISU_Actor* vActor = VISU_Actor::SafeDownCast( aActor ); if (vActor) { - VISU_DataSetActor* aDSActor = dynamic_cast(vActor); - if (aDSActor) { - ListOfvtkPlanes aList; - vtkImplicitFunctionCollection* aFunctions = aDSActor->GetClippingPlanes(); - aFunctions->InitTraversal(); - vtkImplicitFunction* aItem; - while ((aItem = aFunctions->GetNextItem())) { - for (int i = 0; i < myPlanes.size(); i++) { - aPlane = myPlanes.at(i); - if (aPlane.plane.GetPointer() == aItem) - aList.append(aPlane.plane); - } + ListOfvtkPlanes aList; + vtkImplicitFunctionCollection* aFunctions = vActor->GetClippingPlanes(); + aFunctions->InitTraversal(); + vtkImplicitFunction* aItem; + while ((aItem = aFunctions->GetNextItem())) { + for (int i = 0; i < myPlanes.size(); i++) { + aPlane = myPlanes.at(i); + if (aPlane.plane.GetPointer() == aItem) + aList.append(aPlane.plane); } - myActorsMap[aDSActor] = aList; - aDSActor->RemoveAllClippingPlanes(); } + myActorsMap[vActor] = aList; + vActor->RemoveAllClippingPlanes(); } } myCopyActorsMap = myActorsMap; @@ -313,8 +310,8 @@ void VisuGUI_ClippingPlaneMgr::saveState() void VisuGUI_ClippingPlaneMgr::deletePlaneFromActors(int thePlaneId) { vtkPlane* aPl = myPlanes.at(thePlaneId).plane; - QList aActors = myActorsMap.keys(); - VISU_DataSetActor* aActor; + QList aActors = myActorsMap.keys(); + VISU_Actor* aActor; vtkPlane* aPlane; for (int i = 0; i < aActors.size(); i++) { aActor = aActors.at(i); @@ -331,12 +328,12 @@ void VisuGUI_ClippingPlaneMgr::deletePlaneFromActors(int thePlaneId) //**************************************************************** -void VisuGUI_ClippingPlaneMgr::restoreState(const QMap& theState) +void VisuGUI_ClippingPlaneMgr::restoreState(const QMap& theState) { - QList aActors = theState.keys(); - VISU_DataSetActor* aActor; + QList aActors = theState.keys(); + VISU_Actor* aActor; vtkPlane* aPlane; - QMapIterator aIt(theState); + QMapIterator aIt(theState); while (aIt.hasNext()) { aIt.next(); aActor = aIt.key(); diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h index bacc1d6e..b6c57ba1 100644 --- a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h @@ -36,7 +36,7 @@ class PreviewPlane; class vtkImplicitPlaneWidget; class vtkCallbackCommand; -class VISU_DataSetActor; +class VISU_Actor; #include #include @@ -89,7 +89,7 @@ private slots: void saveState(); void deletePlaneFromActors(int thePlaneId); - void restoreState(const QMap& theState); + void restoreState(const QMap& theState); VisuGUI_SegmentationMgr* mySegmentationMgr; @@ -120,8 +120,8 @@ private slots: vtkSmartPointer myCallback; //Stores Actors and Ids of applied planes (position in myPlanes) - QMap myActorsMap; - QMap myCopyActorsMap; + QMap myActorsMap; + QMap myCopyActorsMap; double myBounds[6]; diff --git a/src/VISUGUI/VisuGUI_SegmentationMgr.cxx b/src/VISUGUI/VisuGUI_SegmentationMgr.cxx index 3e768972..e90d25b6 100644 --- a/src/VISUGUI/VisuGUI_SegmentationMgr.cxx +++ b/src/VISUGUI/VisuGUI_SegmentationMgr.cxx @@ -187,6 +187,20 @@ CutPlaneFunction::~CutPlaneFunction() { } +// void CutPlaneFunction::removeCutPlaneFunctions(VISU_Actor* theActor) +// { +// VISU_PipeLine* aPL = theActor->GetPipeLine(); +// vtkIdType aNbPlanes = aPL->GetNumberOfClippingPlanes(); +// CutPlaneFunction* aPlane = 0; +// printf("#### Before delete Nb = %i\n", aNbPlanes); +// for (vtkIdType i = aNbPlanes - 1; i >= 0; i--) { +// aPlane = dynamic_cast(aPL->GetClippingPlane(i)); +// if (aPlane) { +// aPL->RemoveClippingPlane(i); +// } +// } +// printf("#### After delete Nb = %i\n", aPL->GetNumberOfClippingPlanes()); +// } @@ -194,7 +208,7 @@ CutPlaneFunction::~CutPlaneFunction() //**************************************************************** //**************************************************************** VisuGUI_SegmentationMgr::VisuGUI_SegmentationMgr(VisuGUI* theModule, SVTK_ViewWindow* theWindow): - myIsPlanesNonActive(true), + myIsPlanesNonActive(false), myIsPlanesVisible(false), myWindow(theWindow), myModule(theModule), @@ -312,7 +326,6 @@ void VisuGUI_SegmentationMgr::setPlanesNonActive(bool theNonActive) aPlane.plane->setActive(!theNonActive); } myWindow->Repaint(); - } //**************************************************************** @@ -354,10 +367,7 @@ bool VisuGUI_SegmentationMgr::isPlanesVisible() const //**************************************************************** bool VisuGUI_SegmentationMgr::isContainsPlane(VISU_Actor* theActor, vtkPlane* thePlane) { - VISU_DataSetActor* aDSActor = dynamic_cast(theActor); - if (!aDSActor) return false; - - vtkImplicitFunctionCollection* aFunctions = aDSActor->GetClippingPlanes(); + vtkImplicitFunctionCollection* aFunctions = theActor->GetClippingPlanes(); aFunctions->InitTraversal(); vtkImplicitFunction* aItem; while ((aItem = aFunctions->GetNextItem())) { diff --git a/src/VISUGUI/VisuGUI_SegmentationMgr.h b/src/VISUGUI/VisuGUI_SegmentationMgr.h index c9e7a70f..9c072073 100644 --- a/src/VISUGUI/VisuGUI_SegmentationMgr.h +++ b/src/VISUGUI/VisuGUI_SegmentationMgr.h @@ -58,6 +58,8 @@ public: void setActive(bool theActive); bool isActive() const { return myIsActive; } + //static void removeCutPlaneFunctions(VISU_Actor* theActor); + protected: CutPlaneFunction(); ~CutPlaneFunction(); -- 2.39.2