Salome HOME
projects
/
modules
/
smesh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BoostTxtArchive minor changes
[modules/smesh.git]
/
src
/
SMDS
/
SMDS_ElementFactory.cxx
diff --git
a/src/SMDS/SMDS_ElementFactory.cxx
b/src/SMDS/SMDS_ElementFactory.cxx
index 48d25afb5abfab665e54f53b71377ac9d64e92e0..c3ab97c8c9444829f709486d0806ab1f3b60f812 100644
(file)
--- a/
src/SMDS/SMDS_ElementFactory.cxx
+++ b/
src/SMDS/SMDS_ElementFactory.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2007-20
16
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-20
21
CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-104,15
+104,15
@@
int SMDS_ElementFactory::ChunkSize()
//================================================================================
/*!
* \brief Return minimal ID of a non-used element
//================================================================================
/*!
* \brief Return minimal ID of a non-used element
- * \return
int
- minimal element ID
+ * \return
smIdType
- minimal element ID
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementFactory::GetFreeID()
+
smIdType
SMDS_ElementFactory::GetFreeID()
{
if ( myChunksWithUnused.empty() )
{
{
if ( myChunksWithUnused.empty() )
{
-
int
id0 = myChunks.size() * theChunkSize + 1;
+
smIdType
id0 = myChunks.size() * theChunkSize + 1;
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
SMDS_ElementChunk * chunk = (*myChunksWithUnused.begin());
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
SMDS_ElementChunk * chunk = (*myChunksWithUnused.begin());
@@
-122,15
+122,15
@@
int SMDS_ElementFactory::GetFreeID()
//================================================================================
/*!
* \brief Return maximal ID of an used element
//================================================================================
/*!
* \brief Return maximal ID of an used element
- * \return
int
- element ID
+ * \return
smIdType
- element ID
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementFactory::GetMaxID()
+
smIdType
SMDS_ElementFactory::GetMaxID()
{
{
-
int
id = 0;
+
smIdType
id = 0;
TIndexRanges usedRanges;
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;
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
{
int index = usedRanges.back().second-1;
@@
-143,13
+143,13
@@
int SMDS_ElementFactory::GetMaxID()
//================================================================================
/*!
* \brief Return minimal ID of an used element
//================================================================================
/*!
* \brief Return minimal ID of an used element
- * \return
int
- element ID
+ * \return
smIdType
- element ID
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementFactory::GetMinID()
+
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 ))
TIndexRanges usedRanges;
for ( size_t i = 0; i < myChunks.size(); ++i )
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
@@
-169,20
+169,20
@@
int SMDS_ElementFactory::GetMinID()
*/
//================================================================================
*/
//================================================================================
-SMDS_MeshElement* SMDS_ElementFactory::NewElement( const
int
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
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;
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
}
- SMDS_MeshElement* e = myChunks[iChunk].Element(
index
);
+ SMDS_MeshElement* e = myChunks[iChunk].Element(
FromSmIdType<int>(index)
);
if ( !e->IsNull() )
return 0; // element with given ID already exists
if ( !e->IsNull() )
return 0; // element with given ID already exists
- myChunks[iChunk].UseElement(
index
);
+ myChunks[iChunk].UseElement(
FromSmIdType<int>(index)
);
++myNbUsedElements;
e->myHolder = & myChunks[iChunk];
++myNbUsedElements;
e->myHolder = & myChunks[iChunk];
@@
-200,15
+200,15
@@
SMDS_MeshElement* SMDS_ElementFactory::NewElement( const int id )
*/
//================================================================================
*/
//================================================================================
-const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const
int
id ) const
+const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const
smIdType
id ) const
{
if ( id > 0 )
{
{
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(
FromSmIdType<int>(index)
);
return e->IsNull() ? 0 : e;
}
}
return e->IsNull() ? 0 : e;
}
}
@@
-218,12
+218,12
@@
const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const int id ) const
//================================================================================
/*!
* \brief Return an SMDS ID by a Vtk one
//================================================================================
/*!
* \brief Return an SMDS ID by a Vtk one
- * \param [in
out
] vtkID - Vtk ID
- * \return
int
- SMDS ID
+ * \param [in] vtkID - Vtk ID
+ * \return
smIdType
- SMDS ID
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementFactory::FromVtkToSmds( vtkIdType vtkID )
+
smIdType
SMDS_ElementFactory::FromVtkToSmds( vtkIdType vtkID )
{
if ( vtkID >= 0 && vtkID < (vtkIdType)mySmdsIDs.size() )
return mySmdsIDs[vtkID] + 1;
{
if ( vtkID >= 0 && vtkID < (vtkIdType)mySmdsIDs.size() )
return mySmdsIDs[vtkID] + 1;
@@
-239,6
+239,9
@@
int SMDS_ElementFactory::FromVtkToSmds( vtkIdType vtkID )
void SMDS_ElementFactory::Free( const SMDS_MeshElement* e )
{
void SMDS_ElementFactory::Free( const SMDS_MeshElement* e )
{
+ if ( e != FindElement( e->GetID() ))
+ SALOME_Exception("SMDS_ElementFactory::Free(): element of other mesh");
+
if ( !myVtkIDs.empty() )
{
size_t id = e->GetID() - 1;
if ( !myVtkIDs.empty() )
{
size_t id = e->GetID() - 1;
@@
-278,11
+281,11
@@
void SMDS_ElementFactory::Clear()
*/
//================================================================================
*/
//================================================================================
-void SMDS_ElementFactory::Compact( std::vector<
int
>& theVtkIDsNewToOld )
+void SMDS_ElementFactory::Compact( std::vector<
smIdType
>& theVtkIDsNewToOld )
{
{
-
int
newNbCells = NbUsedElements();
-
int
maxCellID = GetMaxID();
-
int
newNbChunks = newNbCells / theChunkSize + bool ( newNbCells % theChunkSize );
+
smIdType
newNbCells = NbUsedElements();
+
smIdType
maxCellID = GetMaxID();
+
smIdType
newNbChunks = newNbCells / theChunkSize + bool ( newNbCells % theChunkSize );
theVtkIDsNewToOld.resize( newNbCells );
theVtkIDsNewToOld.resize( newNbCells );
@@
-292,7
+295,7
@@
void SMDS_ElementFactory::Compact( std::vector<int>& theVtkIDsNewToOld )
}
else if ( newNbCells == maxCellID ) // no holes
{
}
else if ( newNbCells == maxCellID ) // no holes
{
-
int
newID, minLastID = std::min( myVtkIDs.size(), theVtkIDsNewToOld.size() );
+
smIdType
newID, minLastID = std::min( myVtkIDs.size(), theVtkIDsNewToOld.size() );
for ( newID = 0; newID < minLastID; ++newID )
theVtkIDsNewToOld[ newID ] = myVtkIDs[ newID ];
for ( ; newID < newNbCells; ++newID )
for ( newID = 0; newID < minLastID; ++newID )
theVtkIDsNewToOld[ newID ] = myVtkIDs[ newID ];
for ( ; newID < newNbCells; ++newID )
@@
-300,8
+303,8
@@
void SMDS_ElementFactory::Compact( std::vector<int>& theVtkIDsNewToOld )
}
else // there are holes in SMDS IDs
{
}
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;
{
const SMDS_MeshElement* oldElem = FindElement( oldID );
if ( !oldElem ) continue;
@@
-374,16
+377,16
@@
SMDS_NodeFactory::~SMDS_NodeFactory()
*/
//================================================================================
*/
//================================================================================
-void SMDS_NodeFactory::Compact( std::vector<
int
>& theVtkIDsOldToNew )
+void SMDS_NodeFactory::Compact( std::vector<
smIdType
>& theVtkIDsOldToNew )
{
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes"
// in the chunks. So we remove holes and report relocation in theVtkIDsOldToNew:
// theVtkIDsOldToNew[ old VtkID ] = new VtkID
{
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes"
// 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 );
-
int
maxNodeID = GetMaxID();
+
smIdType
oldNbNodes = myMesh->GetGrid()->GetNumberOfPoints();
+
smIdType
newNbNodes = NbUsedElements();
+
smIdType
newNbChunks = newNbNodes / theChunkSize + bool ( newNbNodes % theChunkSize );
+
smIdType
maxNodeID = GetMaxID();
theVtkIDsOldToNew.resize( oldNbNodes, -1 );
theVtkIDsOldToNew.resize( oldNbNodes, -1 );
@@
-405,13
+408,13
@@
void SMDS_NodeFactory::Compact( std::vector<int>& theVtkIDsOldToNew )
const SMDS_MeshElement* newNode = FindElement( newID+1 );
if ( !newNode )
newNode = NewElement( newID+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 )
{
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 )
TParam* oldPos = myChunks[ iChunkOld ].GetPositionPtr( oldNode );
TParam* newPos = myChunks[ iChunk ].GetPositionPtr( newNode, /*allocate=*/true );
if ( oldPos )
@@
-428,7
+431,7
@@
void SMDS_NodeFactory::Compact( std::vector<int>& theVtkIDsOldToNew )
}
else // no holes
{
}
else // no holes
{
- for (
int
i = 0; i < newNbNodes; ++i )
+ for (
smIdType
i = 0; i < newNbNodes; ++i )
theVtkIDsOldToNew[ i ] = i;
}
myChunks.resize( newNbChunks );
theVtkIDsOldToNew[ i ] = i;
}
myChunks.resize( newNbChunks );
@@
-511,7
+514,7
@@
void SMDS_NodeFactory::SetShapeDim( int shapeID, int dim )
*/
//================================================================================
*/
//================================================================================
-SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory,
int
id0 ):
+SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory,
smIdType
id0 ):
myFactory( factory ),
my1stID( id0 )//,
//mySubIDSet( 0 )
myFactory( factory ),
my1stID( id0 )//,
//mySubIDSet( 0 )
@@
-562,7
+565,7
@@
void SMDS_ElementChunk::UseElement( const int index )
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementChunk::GetUnusedID() const
+
smIdType
SMDS_ElementChunk::GetUnusedID() const
{
TUsedRangeSet::set_iterator r = myUsedRanges.mySet.begin();
for ( ; r != myUsedRanges.mySet.end(); ++r )
{
TUsedRangeSet::set_iterator r = myUsedRanges.mySet.begin();
for ( ; r != myUsedRanges.mySet.end(); ++r )
@@
-600,7
+603,7
@@
void SMDS_ElementChunk::Free( const SMDS_MeshElement* e )
*/
//================================================================================
*/
//================================================================================
-
int
SMDS_ElementChunk::GetID( const SMDS_MeshElement* e ) const
+
smIdType
SMDS_ElementChunk::GetID( const SMDS_MeshElement* e ) const
{
return my1stID + Index( e );
}
{
return my1stID + Index( e );
}
@@
-615,11
+618,12
@@
void SMDS_ElementChunk::SetVTKID( const SMDS_MeshElement* e, const vtkIdType vtk
{
if ( e->GetID() - 1 != vtkID )
{
{
if ( e->GetID() - 1 != vtkID )
{
- if ((
int
) myFactory->myVtkIDs.size() <= e->GetID() - 1 )
+ if ((
smIdType
) myFactory->myVtkIDs.size() <= e->GetID() - 1 )
{
{
-
size_t i =
myFactory->myVtkIDs.size();
+
vtkIdType i = (vtkIdType)
myFactory->myVtkIDs.size();
myFactory->myVtkIDs.resize( e->GetID() + 100 );
myFactory->myVtkIDs.resize( e->GetID() + 100 );
- for ( ; i < myFactory->myVtkIDs.size(); ++i )
+ vtkIdType newSize = (vtkIdType) myFactory->myVtkIDs.size();
+ for ( ; i < newSize; ++i )
myFactory->myVtkIDs[i] = i;
}
myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID;
myFactory->myVtkIDs[i] = i;
}
myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID;
@@
-641,10
+645,10
@@
void SMDS_ElementChunk::SetVTKID( const SMDS_MeshElement* e, const vtkIdType vtk
*/
//================================================================================
*/
//================================================================================
-
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 = FromSmIdType<vtkIdType>(e->GetID() - 1)
;
+ return ( dfltVtkID <
(vtkIdType)
myFactory->myVtkIDs.size() ) ? myFactory->myVtkIDs[ dfltVtkID ] : dfltVtkID;
}
//================================================================================
}
//================================================================================