From: apo Date: Mon, 5 Dec 2005 15:29:08 +0000 (+0000) Subject: Fix for [Bug GVIEW10709] X-Git-Tag: TG-D5-38-2003_D2005-29-12~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de49b659eba3434f411fcd6bd67d7aeaba61f5d1;p=modules%2Fgui.git Fix for [Bug GVIEW10709] wrong presentation of quadratic mesh elements --- 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..3c9b3f759 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -40,21 +40,49 @@ 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; const TColStd_IndexedMapOfInteger& GetMapIndex() const; @@ -62,7 +90,7 @@ public: protected: TColStd_IndexedMapOfInteger myMapIndex; - vtkUnstructuredGrid* myUnstructuredGrid; + vtkSmartPointer myUnstructuredGrid; vtkDataSetMapper* myMapper; vtkRenderer* myRenderer;