//================================================================================
/*!
* \brief Return minimal ID of a non-used element
- * \return int - minimal element ID
+ * \return smIdType - minimal element ID
*/
//================================================================================
{
if ( myChunksWithUnused.empty() )
{
- int id0 = myChunks.size() * theChunkSize + 1;
+ smIdType id0 = myChunks.size() * theChunkSize + 1;
+ id0 += idShift;
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
SMDS_ElementChunk * chunk = (*myChunksWithUnused.begin());
smIdType SMDS_ElementFactory::GetMaxID()
{
- int id = 0;
+ smIdType id = 0;
TIndexRanges usedRanges;
- for ( int i = myChunks.size() - 1; i >= 0; --i )
+ for ( smIdType i = myChunks.size() - 1; i >= 0; --i )
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
{
int index = usedRanges.back().second-1;
smIdType SMDS_ElementFactory::GetMinID()
{
- int id = 0;
+ smIdType id = 0;
TIndexRanges usedRanges;
for ( size_t i = 0; i < myChunks.size(); ++i )
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
*/
//================================================================================
-SMDS_MeshElement* SMDS_ElementFactory::NewElement( const smIdType id )
+SMDS_MeshElement* SMDS_ElementFactory::NewElement( const smIdType ID )
{
- int iChunk = ( id - 1 ) / theChunkSize;
- int index = ( id - 1 ) % theChunkSize;
- while ((int) myChunks.size() <= iChunk )
+ smIdType id = ID > idShift ? ID - idShift : ID;
+ smIdType iChunk = ( id - 1 ) / theChunkSize;
+ smIdType index = ( id - 1 ) % theChunkSize;
+ while ((smIdType) myChunks.size() <= iChunk )
{
- int id0 = myChunks.size() * theChunkSize + 1;
+ smIdType id0 = myChunks.size() * theChunkSize + 1 + idShift;
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
- SMDS_MeshElement* e = myChunks[iChunk].Element( index );
+ SMDS_MeshElement* e = myChunks[iChunk].Element( FromIdType<int>(index) );
if ( !e->IsNull() )
return 0; // element with given ID already exists
- myChunks[iChunk].UseElement( index );
+ myChunks[iChunk].UseElement( FromIdType<int>(index) );
++myNbUsedElements;
e->myHolder = & myChunks[iChunk];
*/
//================================================================================
-const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const smIdType id ) const
+const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const smIdType ID ) const
{
+ smIdType id = ID -idShift;
if ( id > 0 )
{
- int iChunk = ( id - 1 ) / theChunkSize;
- int index = ( id - 1 ) % theChunkSize;
- if ( iChunk < (int) myChunks.size() )
+ smIdType iChunk = ( id - 1 ) / theChunkSize;
+ smIdType index = ( id - 1 ) % theChunkSize;
+ if ( iChunk < (smIdType) myChunks.size() )
{
- const SMDS_MeshElement* e = myChunks[iChunk].Element( index );
+ const SMDS_MeshElement* e = myChunks[iChunk].Element( FromIdType<int>(index) );
return e->IsNull() ? 0 : e;
}
}
/*!
* \brief Return an SMDS ID by a Vtk one
* \param [inout] vtkID - Vtk ID
- * \return int - SMDS ID
+ * \return smIdType - SMDS ID
*/
//================================================================================
-int SMDS_ElementFactory::FromVtkToSmds( vtkIdType vtkID )
+smIdType SMDS_ElementFactory::FromVtkToSmds( vtkIdType VTKID )
{
+ vtkIdType vtkID = VTKID;
if ( vtkID >= 0 && vtkID < (vtkIdType)mySmdsIDs.size() )
return mySmdsIDs[vtkID] + 1;
- return vtkID + 1;
+ return vtkID + 1 + idShift;
}
//================================================================================
if ( !myVtkIDs.empty() )
{
- size_t id = e->GetID() - 1;
+ size_t id = e->GetID() - 1 - idShift;
size_t vtkID = e->GetVtkID();
if ( id < myVtkIDs.size() )
myVtkIDs[ id ] = -1;
{
smIdType newNbCells = NbUsedElements();
smIdType maxCellID = GetMaxID();
- int newNbChunks = newNbCells / theChunkSize + bool ( newNbCells % theChunkSize );
+ smIdType newNbChunks = newNbCells / theChunkSize + bool ( newNbCells % theChunkSize );
theVtkIDsNewToOld.resize( newNbCells );
}
else // there are holes in SMDS IDs
{
- int newVtkID = 0; // same as new smds ID (-1)
- for ( int oldID = 1; oldID <= maxCellID; ++oldID ) // smds IDs
+ smIdType newVtkID = 0; // same as new smds ID (-1)
+ for ( smIdType oldID = 1; oldID <= maxCellID; ++oldID ) // smds IDs
{
const SMDS_MeshElement* oldElem = FindElement( oldID );
if ( !oldElem ) continue;
// in the chunks. So we remove holes and report relocation in theVtkIDsOldToNew:
// theVtkIDsOldToNew[ old VtkID ] = new VtkID
- int oldNbNodes = myMesh->GetGrid()->GetNumberOfPoints();
- int newNbNodes = NbUsedElements();
- int newNbChunks = newNbNodes / theChunkSize + bool ( newNbNodes % theChunkSize );
+ smIdType oldNbNodes = myMesh->GetGrid()->GetNumberOfPoints();
+ smIdType newNbNodes = NbUsedElements();
+ smIdType newNbChunks = newNbNodes / theChunkSize + bool ( newNbNodes % theChunkSize );
smIdType maxNodeID = GetMaxID();
theVtkIDsOldToNew.resize( oldNbNodes, -1 );
const SMDS_MeshElement* newNode = FindElement( newID+1 );
if ( !newNode )
newNode = NewElement( newID+1 );
- int shapeID = oldNode->GetShapeID();
- int shapeDim = GetShapeDim( shapeID );
- int iChunk = newID / theChunkSize;
+ int shapeID = oldNode->GetShapeID();
+ int shapeDim = GetShapeDim( shapeID );
+ smIdType iChunk = newID / theChunkSize;
myChunks[ iChunk ].SetShapeID( newNode, shapeID );
if ( shapeDim == 2 || shapeDim == 1 )
{
- int iChunkOld = oldID / theChunkSize;
+ smIdType iChunkOld = oldID / theChunkSize;
TParam* oldPos = myChunks[ iChunkOld ].GetPositionPtr( oldNode );
TParam* newPos = myChunks[ iChunk ].GetPositionPtr( newNode, /*allocate=*/true );
if ( oldPos )
}
else // no holes
{
- for ( int i = 0; i < newNbNodes; ++i )
+ for ( smIdType i = 0; i < newNbNodes; ++i )
theVtkIDsOldToNew[ i ] = i;
}
myChunks.resize( newNbChunks );
*/
//================================================================================
-SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory, int id0 ):
+SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory, smIdType id0 ):
myFactory( factory ),
my1stID( id0 )//,
//mySubIDSet( 0 )
void SMDS_ElementChunk::SetVTKID( const SMDS_MeshElement* e, const vtkIdType vtkID )
{
- if ( e->GetID() - 1 != vtkID )
+ smIdType id = e->GetID() - idShift;
+ if ( id - 1 != vtkID )
{
- if ((int) myFactory->myVtkIDs.size() <= e->GetID() - 1 )
+ if ((smIdType) myFactory->myVtkIDs.size() <= id - 1 )
{
- size_t i = myFactory->myVtkIDs.size();
- myFactory->myVtkIDs.resize( e->GetID() + 100 );
- for ( ; i < myFactory->myVtkIDs.size(); ++i )
+ vtkIdType i = (vtkIdType) myFactory->myVtkIDs.size();
+ myFactory->myVtkIDs.resize( id + 100 );
+ vtkIdType newSize = (vtkIdType) myFactory->myVtkIDs.size();
+ for ( ; i < newSize; ++i )
myFactory->myVtkIDs[i] = i;
}
- myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID;
+ myFactory->myVtkIDs[ id - 1 ] = vtkID;
if ((vtkIdType) myFactory->mySmdsIDs.size() <= vtkID )
{
*/
//================================================================================
-int SMDS_ElementChunk::GetVtkID( const SMDS_MeshElement* e ) const
+vtkIdType SMDS_ElementChunk::GetVtkID( const SMDS_MeshElement* e ) const
{
- size_t dfltVtkID = e->GetID() - 1;
- return ( dfltVtkID < myFactory->myVtkIDs.size() ) ? myFactory->myVtkIDs[ dfltVtkID ] : dfltVtkID;
+ vtkIdType dfltVtkID = FromIdType<vtkIdType>(e->GetID() - 1) - idShift;
+ return ( dfltVtkID < (vtkIdType)myFactory->myVtkIDs.size() ) ? myFactory->myVtkIDs[ dfltVtkID ] : dfltVtkID;
}
//================================================================================