From cf8e0aa5e92ae3b33d9176db2dc4858b25464b29 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 5 Dec 2005 15:26:46 +0000 Subject: [PATCH] Fix for Bug GVIEW10709 wrong presentation of quadratic mesh elements --- src/SVTK/SALOME_Actor.cxx | 2 + src/SVTK/SVTK_Actor.cxx | 86 +++++++++++++++++++++++++++------------ src/SVTK/SVTK_Actor.h | 45 +++++++++++++++----- 3 files changed, 96 insertions(+), 37 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 66a735010..5e4064ddd 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -165,10 +165,12 @@ SALOME_Actor myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); myPreHighlightActor->Delete(); + myPreHighlightActor->Initialize(); myPreHighlightActor->PickableOff(); myPreHighlightActor->SetVisibility( false ); myHighlightActor->Delete(); + myHighlightActor->Initialize(); myHighlightActor->PickableOff(); myHighlightActor->SetVisibility( false ); diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index b633626b2..f78ecc1e8 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -61,7 +61,8 @@ CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet) vtkStandardNewMacro(SVTK_Actor); SVTK_Actor -::SVTK_Actor() +::SVTK_Actor(): + myUnstructuredGrid(vtkUnstructuredGrid::New()) { if(MYDEBUG) INFOS("SVTK_Actor - "<Delete(); myUnstructuredGrid->Allocate(); myIsShrunk = false; @@ -79,12 +80,45 @@ SVTK_Actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInput(myUnstructuredGrid); + SetResolveCoincidentTopology(false); +} + +//---------------------------------------------------------------------------- +void +SVTK_Actor +::Initialize() +{ + myMapper->SetInput(GetSource()); Superclass::InitPipeLine(myMapper); +} - SetResolveCoincidentTopology(false); + +//---------------------------------------------------------------------------- +void +SVTK_Actor +::SetSource(vtkUnstructuredGrid* theUnstructuredGrid) +{ + if(GetSource() == theUnstructuredGrid) + return; + + myUnstructuredGrid = theUnstructuredGrid; + + myMapper->SetInput(theUnstructuredGrid); + + Superclass::InitPipeLine(myMapper); + + Modified(); +} + +vtkUnstructuredGrid* +SVTK_Actor +::GetSource() +{ + return myUnstructuredGrid.GetPointer(); } + +//---------------------------------------------------------------------------- void SVTK_Actor ::SetShrinkFactor(float theValue) @@ -127,13 +161,9 @@ SVTK_Actor { if(MYDEBUG) INFOS("~SVTK_Actor()"); - myMapper->RemoveAllInputs(); myMapper->Delete(); - myShrinkFilter->UnRegisterAllOutputs(); myShrinkFilter->Delete(); - - myUnstructuredGrid->Delete(); } @@ -155,13 +185,13 @@ SVTK_Actor myUnstructuredGrid->Reset(); vtkDataSet *aSourceDataSet = theMapActor->GetInput(); - CopyPoints(myUnstructuredGrid,aSourceDataSet); + CopyPoints(GetSource(),aSourceDataSet); int aNbOfParts = theMapIndex.Extent(); for(int ind = 1; ind <= aNbOfParts; ind++){ int aPartId = theMapIndex( ind ); - vtkCell* aCell = theMapActor->GetElemCell(aPartId); - myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + if(vtkCell* aCell = theMapActor->GetElemCell(aPartId)) + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); } UnShrink(); @@ -186,9 +216,10 @@ SVTK_Actor aPoints->SetNumberOfPoints(aNbOfParts); for(int i = 0; i < aNbOfParts; i++){ int aPartId = theMapIndex( i+1 ); - float* aCoord = theMapActor->GetNodeCoord(aPartId); - aPoints->SetPoint(i,aCoord); - myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i); + if(float* aCoord = theMapActor->GetNodeCoord(aPartId)){ + aPoints->SetPoint(i,aCoord); + myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i); + } } myUnstructuredGrid->SetPoints(aPoints); aPoints->Delete(); @@ -209,7 +240,7 @@ SVTK_Actor myUnstructuredGrid->Reset(); vtkDataSet *aSourceDataSet = theMapActor->GetInput(); - CopyPoints(myUnstructuredGrid,aSourceDataSet); + CopyPoints(GetSource(),aSourceDataSet); int iEnd = theMapIndex.Extent(); int aCellId = -1, aCellCounter = 0; @@ -222,18 +253,19 @@ SVTK_Actor } if(aCellCounter == 1){ - vtkCell* aCell = theMapActor->GetElemCell(aCellId); - if(aCell->GetCellType() <= VTK_LINE){ - myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); - }else{ - int aNbOfParts = aCell->GetNumberOfEdges(); - for(int i = 1; i <= iEnd; i++){ - int aPartId = theMapIndex(i); - if( aPartId < 0){ - aPartId = -aPartId-1; - if(0 > aPartId || aPartId >= aNbOfParts) break; - vtkCell* anEdgeCell = aCell->GetEdge(aPartId); - myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds()); + if(vtkCell* aCell = theMapActor->GetElemCell(aCellId)){ + if(aCell->GetCellType() <= VTK_LINE){ + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + }else{ + int aNbOfParts = aCell->GetNumberOfEdges(); + for(int i = 1; i <= iEnd; i++){ + int aPartId = theMapIndex(i); + if( aPartId < 0){ + aPartId = -aPartId-1; + if(0 > aPartId || aPartId >= aNbOfParts) break; + if(vtkCell* anEdgeCell = aCell->GetEdge(aPartId)) + myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds()); + } } } } diff --git a/src/SVTK/SVTK_Actor.h b/src/SVTK/SVTK_Actor.h index d43ca24d6..cfb4d4b94 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -40,21 +40,46 @@ public: vtkTypeMacro(SVTK_Actor,VTKViewer_Actor); - void SetShrinkFactor(float value); - virtual void SetShrink(); - virtual void UnShrink(); + //! Initialiaze the instance completely + void + Initialize(); + + //! Allows to set an external source + void + SetSource(vtkUnstructuredGrid* theUnstructuredGrid); + + //! Get its internal data set + vtkUnstructuredGrid* + GetSource(); + + //! To manage shrink functionality + void + SetShrinkFactor(float value); + + //! To manage shrink functionality + virtual + void + SetShrink(); + + //! To manage shrink functionality + virtual + void + UnShrink(); //! Allow to recostruct selected cells from source SALOME_Actor and map of subindexes - void MapCells(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + void + MapCells(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); //! Allow to recostruct selected points from source SALOME_Actor and map of subindexes - void MapPoints(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + void + MapPoints(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes - void MapEdge(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + void + MapEdge(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); const TColStd_IndexedMapOfInteger& GetMapIndex() const; @@ -62,7 +87,7 @@ public: protected: TColStd_IndexedMapOfInteger myMapIndex; - vtkUnstructuredGrid* myUnstructuredGrid; + vtkSmartPointer myUnstructuredGrid; vtkDataSetMapper* myMapper; vtkRenderer* myRenderer; -- 2.39.2