Labels visability, highlight od elements

This commit is contained in:
Viktor Uzlov 2021-03-05 08:48:23 +03:00
parent 44811efade
commit b744097301
5 changed files with 20 additions and 14 deletions

View File

@ -43,6 +43,7 @@
#include <vtkRenderer.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellData.h>
#include <iostream>
vtkStandardNewMacro(SMESH_CellLabelActor)
@ -156,18 +157,21 @@ void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled)
{
myCellsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myCellsNumDataSet;
int aNbElem = aDataSet->GetNumberOfCells();
vtkIntArray *anArray = vtkIntArray::New();
vtkIdType aNbElem = aDataSet->GetNumberOfCells();
vtkIdTypeArray *anArray = vtkIdTypeArray::New();
//
std::cout << "\n\n\n***********\nSizeof vtkIdType: " << sizeof(vtkIdType) << "\nSizeof smIdType: " << sizeof(smIdType) << "\n";
//
anArray->SetNumberOfValues(aNbElem);
myExtractUnstructuredGrid->BuildOut2InMap();
for(int anId = 0; anId < aNbElem; anId++)
for(vtkIdType 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);
vtkIdType aSMDSId = myVisualObj->GetElemObjId(id);
anArray->SetValue(anId,aSMDSId);
}
aDataSet->GetCellData()->SetScalars(anArray);

View File

@ -58,16 +58,16 @@ SMESH_ExtractGeometry::SMESH_ExtractGeometry()
SMESH_ExtractGeometry::~SMESH_ExtractGeometry()
{}
vtkIdType SMESH_ExtractGeometry::GetElemObjId(int theVtkID)
vtkIdType SMESH_ExtractGeometry::GetElemObjId(vtkIdType theVtkID)
{
if( theVtkID < 0 || theVtkID >= (int)myElemVTK2ObjIds.size()) return -1;
if( theVtkID < 0 || theVtkID >= myElemVTK2ObjIds.size()) return -1;
return myElemVTK2ObjIds[theVtkID];
}
vtkIdType SMESH_ExtractGeometry::GetNodeObjId(int theVtkID)
vtkIdType SMESH_ExtractGeometry::GetNodeObjId(vtkIdType theVtkID)
{
if ( theVtkID < 0 || theVtkID >= (int)myNodeVTK2ObjIds.size()) return -1;
if ( theVtkID < 0 || theVtkID >= myNodeVTK2ObjIds.size()) return -1;
return myNodeVTK2ObjIds[theVtkID];
}

View File

@ -42,8 +42,8 @@ public:
}
bool GetStoreMapping(){ return myStoreMapping;}
virtual vtkIdType GetNodeObjId(int theVtkID);
virtual vtkIdType GetElemObjId(int theVtkID);
virtual vtkIdType GetNodeObjId(vtkIdType theVtkID);
virtual vtkIdType GetElemObjId(vtkIdType theVtkID);
protected:
SMESH_ExtractGeometry();

View File

@ -146,14 +146,14 @@ void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled)
myPointsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myPointsNumDataSet;
int aNbElem = aDataSet->GetNumberOfPoints();
vtkIdType aNbElem = aDataSet->GetNumberOfPoints();
vtkIntArray *anArray = vtkIntArray::New();
vtkIdTypeArray *anArray = vtkIdTypeArray::New();
anArray->SetNumberOfValues( aNbElem );
for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
{
int aSMDSId = myVisualObj->GetNodeObjId( anId );
vtkIdType aSMDSId = myVisualObj->GetNodeObjId( anId );
anArray->SetValue( anId, aSMDSId );
}

View File

@ -1096,7 +1096,9 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
double r = double( nbSegPerDiap * ( iDiap + 1 )) / double( nbTot );
double parI = par0 + ( par1 - par0 ) * r;
Params.InsertBefore( i, parI );
nbsegs.insert( nbsegs.begin() + i-2 + iDiap, nbSegPerDiap );
auto it = nbsegs.begin();
auto incr_it = i - 2 + iDiap;
nbsegs.insert( it + incr_it, nbSegPerDiap );
}
nbsegs[ i-2 + nbDiapason - 1 ] = nbSegPerDiap + nbTot % nbDiapason;
}