vtkStandardNewMacro(SVTK_Actor);
SVTK_Actor
-::SVTK_Actor()
+::SVTK_Actor():
+ myUnstructuredGrid(vtkUnstructuredGrid::New())
{
if(MYDEBUG) INFOS("SVTK_Actor - "<<this);
Visibility = Pickable = false;
- myUnstructuredGrid = vtkUnstructuredGrid::New();
+ myUnstructuredGrid->Delete();
myUnstructuredGrid->Allocate();
myIsShrunk = false;
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)
{
if(MYDEBUG) INFOS("~SVTK_Actor()");
- myMapper->RemoveAllInputs();
myMapper->Delete();
- myShrinkFilter->UnRegisterAllOutputs();
myShrinkFilter->Delete();
-
- myUnstructuredGrid->Delete();
}
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();
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();
myUnstructuredGrid->Reset();
vtkDataSet *aSourceDataSet = theMapActor->GetInput();
- CopyPoints(myUnstructuredGrid,aSourceDataSet);
+ CopyPoints(GetSource(),aSourceDataSet);
int iEnd = theMapIndex.Extent();
int aCellId = -1, aCellCounter = 0;
}
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());
+ }
}
}
}
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;
protected:
TColStd_IndexedMapOfInteger myMapIndex;
- vtkUnstructuredGrid* myUnstructuredGrid;
+ vtkSmartPointer<vtkUnstructuredGrid> myUnstructuredGrid;
vtkDataSetMapper* myMapper;
vtkRenderer* myRenderer;