//
#include "SMESH_CellLabelActor.h"
+#include "SMESH_ExtractGeometry.h"
+
#include <VTKViewer_TransformFilter.h>
#include <VTKViewer_CellCenters.h>
#include <VTKViewer_ExtractUnstructuredGrid.h>
/*!
Constructor.
*/
-SMESH_CellLabelActor::SMESH_CellLabelActor() {
- //Definition of cells numbering pipeline
+SMESH_CellLabelActor::SMESH_CellLabelActor()
+{
+ //Definition of cells numbering pipeline
//---------------------------------------
myCellsNumDataSet = vtkUnstructuredGrid::New();
myClsMaskPoints = vtkMaskPoints::New();
myClsMaskPoints->SetInputConnection(myCellCenters->GetOutputPort());
myClsMaskPoints->SetOnRatio(1);
-
+
myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
myClsSelectVisiblePoints->SetInputConnection(myClsMaskPoints->GetOutputPort());
myClsSelectVisiblePoints->SelectInvisibleOff();
myClsSelectVisiblePoints->SetTolerance(0.1);
-
+
myClsLabeledDataMapper = vtkLabeledDataMapper::New();
myClsLabeledDataMapper->SetInputConnection(myClsSelectVisiblePoints->GetOutputPort());
myClsLabeledDataMapper->SetLabelFormat("%d");
myClsLabeledDataMapper->SetLabelModeToLabelScalars();
-
+
myClsTextProp = vtkTextProperty::New();
myClsTextProp->SetFontFamilyToTimes();
myClsTextProp->SetFontSize(12);
/*!
Destructor.
*/
-SMESH_CellLabelActor::~SMESH_CellLabelActor() {
+SMESH_CellLabelActor::~SMESH_CellLabelActor()
+{
//Deleting of cells numbering pipeline
//---------------------------------------
myCellsNumDataSet->Delete();
myClsTextProp->SetColor( r, g, b );
}
-void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled) {
+void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled)
+{
myTransformFilter->Update();
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput());
- if(!aGrid)
+ if ( !aGrid )
return;
myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
- if(myIsCellsLabeled){
+ if ( myIsCellsLabeled )
+ {
myCellsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myCellsNumDataSet;
int aNbElem = aDataSet->GetNumberOfCells();
vtkIntArray *anArray = vtkIntArray::New();
anArray->SetNumberOfValues(aNbElem);
- for(int anId = 0; anId < aNbElem; anId++){
- vtkIdType id = myExtractUnstructuredGrid->GetInputId(anId);
- id = (id >=0) ? id : anId;
+ myExtractUnstructuredGrid->BuildOut2InMap();
+ for(int anId = 0; anId < aNbElem; anId++)
+ {
+ vtkIdType id = anId;
+ if(IsImplicitFunctionUsed())
+ id = myExtractGeometry->GetElemObjId(id);
+ id = myExtractUnstructuredGrid->GetInputId(id);
+ id = (id >=0) ? id : anId;
int aSMDSId = myVisualObj->GetElemObjId(id);
anArray->SetValue(anId,aSMDSId);
}