Update with new UG faces API for VTK master

This commit is contained in:
Louis Gombert 2024-08-08 21:27:52 +00:00
parent 08f42ae643
commit 7a70a55209

View File

@ -227,11 +227,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
this->Connectivity->Squeeze(); this->Connectivity->Squeeze();
this->CellLocations->Squeeze(); this->CellLocations->Squeeze();
this->Types->Squeeze(); this->Types->Squeeze();
if ( this->FaceLocations )
{
this->FaceLocations->Squeeze();
this->Faces->Squeeze();
}
this->Connectivity->Modified(); this->Connectivity->Modified();
return; return;
} }
@ -284,30 +279,30 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
} }
} }
if (this->FaceLocations) if (this->GetFaceLocations())
{ {
vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New(); vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New();
newFaceLocations->Initialize(); newFaceLocations->Initialize();
newFaceLocations->Allocate(newTypes->GetSize()); newFaceLocations->Allocate(newTypes->GetSize());
vtkIdTypeArray *newFaces = vtkIdTypeArray::New(); vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
newFaces->Initialize(); newFaces->Initialize();
newFaces->Allocate(this->Faces->GetSize()); newFaces->Allocate(this->GetFaces()->GetSize());
for ( vtkIdType newCellID = 0; newCellID < newCellSize; newCellID++ ) for ( vtkIdType newCellID = 0; newCellID < newCellSize; newCellID++ )
{ {
if ( newTypes->GetValue( newCellID ) == VTK_POLYHEDRON ) if ( newTypes->GetValue( newCellID ) == VTK_POLYHEDRON )
{ {
smIdType oldCellId = idCellsNewToOld[ newCellID ]; smIdType oldCellId = idCellsNewToOld[ newCellID ];
newFaceLocations->InsertNextValue( newFaces->GetMaxId()+1 ); newFaceLocations->InsertNextValue( newFaces->GetMaxId()+1 );
smIdType oldFaceLoc = this->FaceLocations->GetValue( FromSmIdType<vtkIdType>(oldCellId) ); smIdType oldFaceLoc = this->GetFaceLocations()->GetValue( FromSmIdType<vtkIdType>(oldCellId) );
smIdType nCellFaces = this->Faces->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) ); smIdType nCellFaces = this->GetFaces()->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) );
newFaces->InsertNextValue( FromSmIdType<vtkIdType>(nCellFaces) ); newFaces->InsertNextValue( FromSmIdType<vtkIdType>(nCellFaces) );
for ( int n = 0; n < nCellFaces; n++ ) for ( int n = 0; n < nCellFaces; n++ )
{ {
int nptsInFace = this->Faces->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) ); int nptsInFace = this->GetFaces()->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) );
newFaces->InsertNextValue( nptsInFace ); newFaces->InsertNextValue( nptsInFace );
for ( int k = 0; k < nptsInFace; k++ ) for ( int k = 0; k < nptsInFace; k++ )
{ {
vtkIdType oldpt = this->Faces->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) ); vtkIdType oldpt = this->GetFaces()->GetValue( FromSmIdType<vtkIdType>(oldFaceLoc++) );
newFaces->InsertNextValue( idNodesOldToNew[ oldpt ]); newFaces->InsertNextValue( idNodesOldToNew[ oldpt ]);
} }
} }
@ -319,14 +314,14 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
} }
newFaceLocations->Squeeze(); newFaceLocations->Squeeze();
newFaces->Squeeze(); newFaces->Squeeze();
this->SetCells( newTypes, newLocations, newConnectivity, newFaceLocations, newFaces ); this->SetCells( newTypes, newConnectivity, newFaceLocations, newFaces );
this->CellLocations = newLocations; this->CellLocations = newLocations;
newFaceLocations->Delete(); newFaceLocations->Delete();
newFaces->Delete(); newFaces->Delete();
} }
else else
{ {
this->SetCells( newTypes, newLocations, newConnectivity, FaceLocations, Faces ); this->SetCells( newTypes, newConnectivity, this->GetFaceLocations(), this->GetFaces() );
this->CellLocations = newLocations; this->CellLocations = newLocations;
} }