Fix for id shitf +2147483647

This commit is contained in:
eap 2021-03-03 18:34:42 +03:00
parent 9216aa146e
commit 44811efade
3 changed files with 8 additions and 6 deletions

View File

@ -39,8 +39,6 @@ namespace
const int theDefaultShapeDim = 3;
const smIdType idShift = 2147483647;
// classes allowing to modify parameters of SMDS_Position stored in SMDS_ElementFactory
struct _EdgePosition : public SMDS_EdgePosition
@ -230,7 +228,7 @@ const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const smIdType ID ) co
smIdType SMDS_ElementFactory::FromVtkToSmds( vtkIdType VTKID )
{
vtkIdType vtkID = VTKID - idShift;
vtkIdType vtkID = VTKID;
if ( vtkID >= 0 && vtkID < (vtkIdType)mySmdsIDs.size() )
return mySmdsIDs[vtkID] + 1;
return vtkID + 1 + idShift;
@ -251,7 +249,7 @@ void SMDS_ElementFactory::Free( const SMDS_MeshElement* e )
if ( !myVtkIDs.empty() )
{
size_t id = e->GetID() - 1 - idShift;
size_t vtkID = e->GetVtkID() - idShift;
size_t vtkID = e->GetVtkID();
if ( id < myVtkIDs.size() )
myVtkIDs[ id ] = -1;
if ( vtkID < mySmdsIDs.size() )

View File

@ -53,6 +53,10 @@ struct _ChunkCompare {
typedef boost::ptr_vector<SMDS_ElementChunk> TChunkVector;
typedef std::set<SMDS_ElementChunk*,_ChunkCompare> TChunkPtrSet;
const smIdType idShift = 2147483647;
//------------------------------------------------------------------------------------
/*!
* \brief Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's )
@ -565,7 +569,7 @@ SMDS_ElementFactory::GetShapeIterator( int shapeID,
size_t nbElemsToReturn,
const SMDS_MeshElement* sm1stElem )
{
smIdType iChunk = sm1stElem ? (( sm1stElem->GetID() - 1 ) / ChunkSize()) : 0;
smIdType iChunk = sm1stElem ? (( sm1stElem->GetID() - 1 - idShift) / ChunkSize()) : 0;
typedef _ChunkIterator< ElemIterator, TSubIDRangeSet > TChuckIterator;
return boost::make_shared< TChuckIterator >( myChunks,
& SMDS_ElementChunk::GetSubIDRangesMinMax,

View File

@ -1000,7 +1000,7 @@ const SMDS_MeshNode * SMDS_Mesh::FindNode(smIdType ID) const
///////////////////////////////////////////////////////////////////////////////
const SMDS_MeshNode * SMDS_Mesh::FindNodeVtk(vtkIdType vtkId) const
{
return myNodeFactory->FindNode( vtkId + 1 );
return myNodeFactory->FindNode( FromVtkToSmds( vtkId ));
}
const SMDS_MeshElement * SMDS_Mesh::FindElementVtk(vtkIdType IDelem) const