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

View File

@ -58,16 +58,16 @@ SMESH_ExtractGeometry::SMESH_ExtractGeometry()
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]; 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]; return myNodeVTK2ObjIds[theVtkID];
} }

View File

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

View File

@ -146,14 +146,14 @@ void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled)
myPointsNumDataSet->ShallowCopy(aGrid); myPointsNumDataSet->ShallowCopy(aGrid);
vtkUnstructuredGrid *aDataSet = myPointsNumDataSet; vtkUnstructuredGrid *aDataSet = myPointsNumDataSet;
int aNbElem = aDataSet->GetNumberOfPoints(); vtkIdType aNbElem = aDataSet->GetNumberOfPoints();
vtkIntArray *anArray = vtkIntArray::New(); vtkIdTypeArray *anArray = vtkIdTypeArray::New();
anArray->SetNumberOfValues( aNbElem ); anArray->SetNumberOfValues( aNbElem );
for ( vtkIdType anId = 0; anId < aNbElem; anId++ ) for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
{ {
int aSMDSId = myVisualObj->GetNodeObjId( anId ); vtkIdType aSMDSId = myVisualObj->GetNodeObjId( anId );
anArray->SetValue( anId, aSMDSId ); 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 r = double( nbSegPerDiap * ( iDiap + 1 )) / double( nbTot );
double parI = par0 + ( par1 - par0 ) * r; double parI = par0 + ( par1 - par0 ) * r;
Params.InsertBefore( i, parI ); 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; nbsegs[ i-2 + nbDiapason - 1 ] = nbSegPerDiap + nbTot % nbDiapason;
} }