Check types in SMDS and SMESHDS

This commit is contained in:
eap 2021-02-04 18:26:09 +03:00
parent dd3be60637
commit 81147ab62f
18 changed files with 97 additions and 99 deletions

View File

@ -25,7 +25,7 @@
#include "SMDS_CellOfNodes.hxx" #include "SMDS_CellOfNodes.hxx"
SMDS_CellOfNodes::SMDS_CellOfNodes( smIdType id, smIdType shapeID ) SMDS_CellOfNodes::SMDS_CellOfNodes( smIdType id, int shapeID )
: myID( id ) : myID( id )
{ {
setShapeID( shapeID ); setShapeID( shapeID );
@ -41,12 +41,12 @@ smIdType SMDS_CellOfNodes::GetID() const
return myID; return myID;
} }
void SMDS_CellOfNodes::setShapeID( const smIdType shapeID ) void SMDS_CellOfNodes::setShapeID( const int shapeID )
{ {
myShapeID = ( shapeID << BITS_SHIFT ) | ( myShapeID & BIT_IS_MARKED ); myShapeID = ( shapeID << BITS_SHIFT ) | ( myShapeID & BIT_IS_MARKED );
} }
smIdType SMDS_CellOfNodes::GetShapeID() const int SMDS_CellOfNodes::GetShapeID() const
{ {
return myShapeID >> BITS_SHIFT; return myShapeID >> BITS_SHIFT;
} }

View File

@ -45,7 +45,7 @@ class SMDS_EXPORT SMDS_CellOfNodes : public SMDS_MeshElement
public: public:
virtual smIdType GetID() const; virtual smIdType GetID() const;
virtual smIdType GetShapeID() const; virtual int GetShapeID() const;
virtual void setIsMarked( bool is ) const; virtual void setIsMarked( bool is ) const;
virtual bool isMarked() const; virtual bool isMarked() const;
@ -54,13 +54,13 @@ public:
protected: protected:
SMDS_CellOfNodes( smIdType id = -1, smIdType shapeID = 0); SMDS_CellOfNodes( smIdType id = -1, int shapeID = 0);
virtual void setID( const smIdType id); virtual void setID( const smIdType id);
virtual void setShapeID( const smIdType shapeID ); virtual void setShapeID( const int shapeID );
smIdType myID; smIdType myID;
smIdType myShapeID; int myShapeID;
enum Bits { // use the 1st right bit of myShapeId to set/unset a mark enum Bits { // use the 1st right bit of myShapeId to set/unset a mark
BIT_IS_MARKED = 1, BIT_IS_MARKED = 1,

View File

@ -104,7 +104,7 @@ 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
*/ */
//================================================================================ //================================================================================
@ -133,7 +133,7 @@ smIdType SMDS_ElementFactory::GetMaxID()
for ( smIdType i = myChunks.size() - 1; i >= 0; --i ) for ( smIdType i = myChunks.size() - 1; i >= 0; --i )
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges )) if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
{ {
smIdType index = usedRanges.back().second-1; int index = usedRanges.back().second-1;
id = myChunks[i].Get1stID() + index; id = myChunks[i].Get1stID() + index;
break; break;
} }
@ -149,7 +149,7 @@ smIdType SMDS_ElementFactory::GetMaxID()
smIdType SMDS_ElementFactory::GetMinID() smIdType SMDS_ElementFactory::GetMinID()
{ {
int id = 0; smIdType id = 0;
TIndexRanges usedRanges; TIndexRanges usedRanges;
for ( size_t i = 0; i < myChunks.size(); ++i ) for ( size_t i = 0; i < myChunks.size(); ++i )
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges )) if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
@ -173,7 +173,7 @@ SMDS_MeshElement* SMDS_ElementFactory::NewElement( const smIdType id )
{ {
smIdType iChunk = ( id - 1 ) / theChunkSize; smIdType iChunk = ( id - 1 ) / theChunkSize;
smIdType index = ( id - 1 ) % theChunkSize; smIdType index = ( id - 1 ) % theChunkSize;
while ((int) myChunks.size() <= iChunk ) while ((smIdType) myChunks.size() <= iChunk )
{ {
smIdType 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 ));
@ -206,7 +206,7 @@ const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const smIdType id ) co
{ {
smIdType iChunk = ( id - 1 ) / theChunkSize; smIdType iChunk = ( id - 1 ) / theChunkSize;
smIdType index = ( id - 1 ) % theChunkSize; smIdType index = ( id - 1 ) % theChunkSize;
if ( iChunk < (int) myChunks.size() ) if ( iChunk < (smIdType) myChunks.size() )
{ {
const SMDS_MeshElement* e = myChunks[iChunk].Element( index ); const SMDS_MeshElement* e = myChunks[iChunk].Element( index );
return e->IsNull() ? 0 : e; return e->IsNull() ? 0 : e;
@ -303,8 +303,8 @@ void SMDS_ElementFactory::Compact( std::vector<smIdType>& theVtkIDsNewToOld )
} }
else // there are holes in SMDS IDs else // there are holes in SMDS IDs
{ {
int newVtkID = 0; // same as new smds ID (-1) smIdType newVtkID = 0; // same as new smds ID (-1)
for ( int oldID = 1; oldID <= maxCellID; ++oldID ) // smds IDs for ( smIdType oldID = 1; oldID <= maxCellID; ++oldID ) // smds IDs
{ {
const SMDS_MeshElement* oldElem = FindElement( oldID ); const SMDS_MeshElement* oldElem = FindElement( oldID );
if ( !oldElem ) continue; if ( !oldElem ) continue;
@ -408,9 +408,9 @@ void SMDS_NodeFactory::Compact( std::vector<smIdType>& theVtkIDsOldToNew )
const SMDS_MeshElement* newNode = FindElement( newID+1 ); const SMDS_MeshElement* newNode = FindElement( newID+1 );
if ( !newNode ) if ( !newNode )
newNode = NewElement( newID+1 ); newNode = NewElement( newID+1 );
smIdType shapeID = oldNode->GetShapeID(); int shapeID = oldNode->GetShapeID();
int shapeDim = GetShapeDim( shapeID ); int shapeDim = GetShapeDim( shapeID );
smIdType iChunk = newID / theChunkSize; smIdType iChunk = newID / theChunkSize;
myChunks[ iChunk ].SetShapeID( newNode, shapeID ); myChunks[ iChunk ].SetShapeID( newNode, shapeID );
if ( shapeDim == 2 || shapeDim == 1 ) if ( shapeDim == 2 || shapeDim == 1 )
{ {
@ -431,7 +431,7 @@ void SMDS_NodeFactory::Compact( std::vector<smIdType>& theVtkIDsOldToNew )
} }
else // no holes else // no holes
{ {
for ( int i = 0; i < newNbNodes; ++i ) for ( smIdType i = 0; i < newNbNodes; ++i )
theVtkIDsOldToNew[ i ] = i; theVtkIDsOldToNew[ i ] = i;
} }
myChunks.resize( newNbChunks ); myChunks.resize( newNbChunks );
@ -618,12 +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(); size_t i = myFactory->myVtkIDs.size();
myFactory->myVtkIDs.resize( e->GetID() + 100 ); myFactory->myVtkIDs.resize( e->GetID() + 100 );
for ( ; i < myFactory->myVtkIDs.size(); ++i ) for ( ; i < myFactory->myVtkIDs.size(); ++i )
myFactory->myVtkIDs[i] = FromIdType<int>(i); myFactory->myVtkIDs[i] = FromIdType<vtkIdType>(i);
} }
myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID; myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID;
@ -644,10 +644,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; vtkIdType dfltVtkID = e->GetID() - 1;
return ( dfltVtkID < myFactory->myVtkIDs.size() ) ? FromIdType<int>(myFactory->myVtkIDs[ dfltVtkID ]) : FromIdType<int>(dfltVtkID); return ( dfltVtkID < (vtkIdType)myFactory->myVtkIDs.size() ) ? myFactory->myVtkIDs[ dfltVtkID ] : dfltVtkID;
} }
//================================================================================ //================================================================================

View File

@ -70,7 +70,7 @@ protected:
TChunkPtrSet myChunksWithUnused; // sorted chunks having unused elements TChunkPtrSet myChunksWithUnused; // sorted chunks having unused elements
std::vector< vtkIdType > myVtkIDs; // myVtkIDs[ smdsID-1 ] == vtkID std::vector< vtkIdType > myVtkIDs; // myVtkIDs[ smdsID-1 ] == vtkID
std::vector< smIdType > mySmdsIDs; // mySmdsIDs[ vtkID ] == smdsID - 1 std::vector< smIdType > mySmdsIDs; // mySmdsIDs[ vtkID ] == smdsID - 1
int myNbUsedElements; // counter of elements smIdType myNbUsedElements; // counter of elements
friend class SMDS_ElementChunk; friend class SMDS_ElementChunk;
@ -279,7 +279,7 @@ struct _RangeSet
rNext = mySet.upper_bound( theIndex ); rNext = mySet.upper_bound( theIndex );
r = rNext - 1; r = rNext - 1;
} }
smIdType rSize = Size( r ); // range size int rSize = Size( r ); // range size
attr_t rValue = r->myValue; attr_t rValue = r->myValue;
if ( rValue == theValue ) if ( rValue == theValue )
return rValue; // it happens while compacting return rValue; // it happens while compacting
@ -433,7 +433,7 @@ public:
smIdType GetID( const SMDS_MeshElement* e ) const; smIdType GetID( const SMDS_MeshElement* e ) const;
int GetVtkID( const SMDS_MeshElement* e ) const; vtkIdType GetVtkID( const SMDS_MeshElement* e ) const;
void SetVTKID( const SMDS_MeshElement* e, const vtkIdType id ); void SetVTKID( const SMDS_MeshElement* e, const vtkIdType id );
int GetShapeID( const SMDS_MeshElement* e ) const; int GetShapeID( const SMDS_MeshElement* e ) const;

View File

@ -59,8 +59,7 @@ SMDS_ElementHolder::~SMDS_ElementHolder()
void SMDS_ElementHolder::beforeCompacting() void SMDS_ElementHolder::beforeCompacting()
{ {
int i = 0; for ( SMDS_ElemIteratorPtr it = getElements(); it->more() )
for ( SMDS_ElemIteratorPtr it = getElements(); it->more(); ++i )
{ {
const SMDS_MeshElement* e = it->next(); const SMDS_MeshElement* e = it->next();
if ( !e ) continue; if ( !e ) continue;
@ -94,21 +93,21 @@ void SMDS_ElementHolder::restoreElements( const std::vector<smIdType>& idNodesOl
std::vector< bool >::iterator isNode = myIsNode.begin(); std::vector< bool >::iterator isNode = myIsNode.begin();
for ( size_t i = 0; i < myVtkIDs.size(); ++i, ++isNode ) for ( size_t i = 0; i < myVtkIDs.size(); ++i, ++isNode )
{ {
int vtkID = myVtkIDs[i]; vtkIdType vtkID = myVtkIDs[i];
if ( vtkID < 0 ) if ( vtkID < 0 )
{ {
elem = myExternalElems[ (-vtkID)-1 ]; elem = myExternalElems[ (-vtkID)-1 ];
} }
else if ( *isNode ) else if ( *isNode )
{ {
if ( vtkID < (int)idNodesOldToNew.size() ) if ( vtkID < (vtkIdType)idNodesOldToNew.size() )
elem = myMesh->FindNodeVtk( idNodesOldToNew[ vtkID ]); elem = myMesh->FindNodeVtk( idNodesOldToNew[ vtkID ]);
else else
elem = myMesh->FindNodeVtk( vtkID ); elem = myMesh->FindNodeVtk( vtkID );
} }
else else
{ {
if ( vtkID < (int)idCellsOldToNew.size() ) if ( vtkID < (vtkIdType)idCellsOldToNew.size() )
elem = myMesh->FindElementVtk( idCellsOldToNew[ vtkID ]); elem = myMesh->FindElementVtk( idCellsOldToNew[ vtkID ]);
else else
elem = myMesh->FindElementVtk( vtkID ); elem = myMesh->FindElementVtk( vtkID );

View File

@ -87,7 +87,7 @@ class SMDS_EXPORT SMDS_ElementHolder
std::vector<const SMDS_MeshElement*> myExternalElems; //!< elements not contained in the mesh std::vector<const SMDS_MeshElement*> myExternalElems; //!< elements not contained in the mesh
std::vector< int > myVtkIDs; //!< vtk IDs of elements std::vector< vtkIdType > myVtkIDs; //!< vtk IDs of elements
std::vector< bool > myIsNode; std::vector< bool > myIsNode;
std::set< SMDS_ElementHolder* >::iterator myPtrInMesh; std::set< SMDS_ElementHolder* >::iterator myPtrInMesh;
}; };

View File

@ -998,12 +998,12 @@ const SMDS_MeshNode * SMDS_Mesh::FindNode(smIdType ID) const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Return the node whose VTK ID is 'vtkId'. /// Return the node whose VTK ID is 'vtkId'.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
const SMDS_MeshNode * SMDS_Mesh::FindNodeVtk(int vtkId) const const SMDS_MeshNode * SMDS_Mesh::FindNodeVtk(vtkIdType vtkId) const
{ {
return myNodeFactory->FindNode( vtkId + 1 ); return myNodeFactory->FindNode( vtkId + 1 );
} }
const SMDS_MeshElement * SMDS_Mesh::FindElementVtk(int IDelem) const const SMDS_MeshElement * SMDS_Mesh::FindElementVtk(vtkIdType IDelem) const
{ {
return myCellFactory->FindElement( FromVtkToSmds( IDelem )); return myCellFactory->FindElement( FromVtkToSmds( IDelem ));
} }
@ -1874,7 +1874,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
n->RemoveInverseElement((*it)); n->RemoveInverseElement((*it));
} }
int vtkid = (*it)->GetVtkID(); vtkIdType vtkid = (*it)->GetVtkID();
switch ((*it)->GetType()) { switch ((*it)->GetType()) {
case SMDSAbs_Node: case SMDSAbs_Node:
@ -1919,7 +1919,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
{ {
const int vtkId = elem->GetVtkID(); const vtkIdType vtkId = elem->GetVtkID();
SMDSAbs_ElementType aType = elem->GetType(); SMDSAbs_ElementType aType = elem->GetType();
if ( aType == SMDSAbs_Node ) if ( aType == SMDSAbs_Node )
{ {
@ -2991,7 +2991,7 @@ void SMDS_Mesh::CompactMesh()
idCellsOldToNew.resize( oldCellSize, oldCellSize ); idCellsOldToNew.resize( oldCellSize, oldCellSize );
for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); ++iNew ) for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); ++iNew )
{ {
if ( idCellsNewToOld[ iNew ] >= (int) idCellsOldToNew.size() ) if ( idCellsNewToOld[ iNew ] >= (smIdType) idCellsOldToNew.size() )
idCellsOldToNew.resize( ( 1 + idCellsNewToOld[ iNew ]) * 1.5, oldCellSize ); idCellsOldToNew.resize( ( 1 + idCellsNewToOld[ iNew ]) * 1.5, oldCellSize );
idCellsOldToNew[ idCellsNewToOld[ iNew ]] = iNew; idCellsOldToNew[ idCellsNewToOld[ iNew ]] = iNew;
} }

View File

@ -127,7 +127,7 @@ void SMDS_MeshElement::setShapeID( const int shapeID ) const
*/ */
//================================================================================ //================================================================================
smIdType SMDS_MeshElement::GetShapeID() const int SMDS_MeshElement::GetShapeID() const
{ {
return myHolder->GetShapeID( this ); return myHolder->GetShapeID( this );
} }
@ -138,7 +138,7 @@ smIdType SMDS_MeshElement::GetShapeID() const
*/ */
//================================================================================ //================================================================================
int SMDS_MeshElement::GetVtkID() const vtkIdType SMDS_MeshElement::GetVtkID() const
{ {
return myHolder->GetVtkID( this ); return myHolder->GetVtkID( this );
} }
@ -171,7 +171,7 @@ bool SMDS_MeshElement::isMarked() const
*/ */
//================================================================================ //================================================================================
void SMDS_MeshElement::setVtkID( const int vtkID ) void SMDS_MeshElement::setVtkID( const vtkIdType vtkID )
{ {
myHolder->SetVTKID( this, vtkID ); myHolder->SetVTKID( this, vtkID );
} }

View File

@ -128,10 +128,10 @@ public:
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const; virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
virtual smIdType GetID() const; virtual smIdType GetID() const;
virtual int GetVtkID() const; virtual vtkIdType GetVtkID() const;
virtual smIdType getshapeId() const { return GetShapeID(); } virtual smIdType getshapeId() const { return GetShapeID(); }
virtual smIdType GetShapeID() const; virtual smIdType GetShapeID() const;
// mark this element; to be used in algos // mark this element; to be used in algos
virtual void setIsMarked( bool is ) const; virtual void setIsMarked( bool is ) const;
@ -183,7 +183,7 @@ public:
SMDS_MeshElement(); SMDS_MeshElement();
void setVtkID(const int vtkID ); void setVtkID(const vtkIdType vtkID );
virtual void setShapeID( const int shapeID ) const; virtual void setShapeID( const int shapeID ) const;
SMDS_UnstructuredGrid* getGrid() const; SMDS_UnstructuredGrid* getGrid() const;

View File

@ -80,7 +80,7 @@ private:
// methods to count NOT POLY elements // methods to count NOT POLY elements
inline void remove(const SMDS_MeshElement* el); inline void remove(const SMDS_MeshElement* el);
inline void add (const SMDS_MeshElement* el); inline void add (const SMDS_MeshElement* el);
inline smIdType index(SMDSAbs_ElementType type, smIdType nbNodes) const; inline smIdType index(SMDSAbs_ElementType type, int nbNodes) const;
// methods to remove elements of ANY kind // methods to remove elements of ANY kind
inline void RemoveEdge(const SMDS_MeshElement* el); inline void RemoveEdge(const SMDS_MeshElement* el);
inline void RemoveFace(const SMDS_MeshElement* el); inline void RemoveFace(const SMDS_MeshElement* el);
@ -214,7 +214,7 @@ SMDS_MeshInfo::Clear()
} }
inline smIdType // index inline smIdType // index
SMDS_MeshInfo::index(SMDSAbs_ElementType type, smIdType nbNodes) const SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes) const
{ return nbNodes + myShift[ type ]; } { return nbNodes + myShift[ type ]; }
inline void // remove inline void // remove

View File

@ -123,7 +123,7 @@ namespace
{ {
for (int i = 0; i < ncells; i++) for (int i = 0; i < ncells; i++)
{ {
int vtkId = cells[i]; vtkIdType vtkId = cells[i];
smIdType smdsId = myMesh->FromVtkToSmds( vtkId ); smIdType smdsId = myMesh->FromVtkToSmds( vtkId );
const SMDS_MeshElement* elem = myMesh->FindElement( smdsId ); const SMDS_MeshElement* elem = myMesh->FindElement( smdsId );
if ( elem->GetType() == type ) if ( elem->GetType() == type )
@ -142,7 +142,7 @@ namespace
const SMDS_MeshElement* next() const SMDS_MeshElement* next()
{ {
int vtkId = myCellList[ myIter++ ]; vtkIdType vtkId = myCellList[ myIter++ ];
smIdType smdsId = myMesh->FromVtkToSmds( vtkId ); smIdType smdsId = myMesh->FromVtkToSmds( vtkId );
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (!elem) if (!elem)

View File

@ -135,7 +135,7 @@ vtkPoints* SMDS_UnstructuredGrid::GetPoints()
return this->Points; return this->Points;
} }
int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts) vtkIdType SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts)
{ {
if ( !this->Links ) // don't create Links until they are needed if ( !this->Links ) // don't create Links until they are needed
{ {
@ -146,7 +146,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p
return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts);
// --- type = VTK_POLYHEDRON // --- type = VTK_POLYHEDRON
int cellid = this->InsertNextCell(type, npts, pts); vtkIdType cellid = this->InsertNextCell(type, npts, pts);
std::set<vtkIdType> setOfNodes; std::set<vtkIdType> setOfNodes;
setOfNodes.clear(); setOfNodes.clear();
@ -183,7 +183,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes" in SMDS numeration. // IDs of VTK nodes always correspond to SMDS IDs but there can be "holes" in SMDS numeration.
// We compact only if there were holes // We compact only if there were holes
int oldNodeSize = this->GetNumberOfPoints(); vtkIdType oldNodeSize = this->GetNumberOfPoints();
bool updateNodes = ( oldNodeSize > newNodeSize ); bool updateNodes = ( oldNodeSize > newNodeSize );
if ( true /*updateNodes*/ ) if ( true /*updateNodes*/ )
{ {
@ -193,17 +193,17 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
newPoints->SetDataType( VTK_DOUBLE ); newPoints->SetDataType( VTK_DOUBLE );
newPoints->SetNumberOfPoints( FromIdType<int>(newNodeSize) ); newPoints->SetNumberOfPoints( FromIdType<int>(newNodeSize) );
int i = 0, alreadyCopied = 0; int vtkIdType = 0, alreadyCopied = 0;
while ( i < oldNodeSize ) while ( i < oldNodeSize )
{ {
// skip a hole if any // skip a hole if any
while ( i < oldNodeSize && idNodesOldToNew[i] < 0 ) while ( i < oldNodeSize && idNodesOldToNew[i] < 0 )
++i; ++i;
int startBloc = i; vtkIdType startBloc = i;
// look for a block end // look for a block end
while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 ) while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 )
++i; ++i;
int endBloc = i; vtkIdType endBloc = i;
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
} }
this->SetPoints(newPoints); this->SetPoints(newPoints);
@ -217,9 +217,9 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
// Compact cells if VTK IDs do not correspond to SMDS IDs or nodes compacted // Compact cells if VTK IDs do not correspond to SMDS IDs or nodes compacted
int oldCellSize = this->Types->GetNumberOfTuples(); vtkIdType oldCellSize = this->Types->GetNumberOfTuples();
bool updateCells = ( updateNodes || newCellSize != oldCellSize ); bool updateCells = ( updateNodes || newCellSize != oldCellSize );
for ( int newID = 0, nbIDs = idCellsNewToOld.size(); newID < nbIDs && !updateCells; ++newID ) for ( vtkIdType newID = 0, nbIDs = idCellsNewToOld.size(); newID < nbIDs && !updateCells; ++newID )
updateCells = ( idCellsNewToOld[ newID ] != newID ); updateCells = ( idCellsNewToOld[ newID ] != newID );
if ( false /*!updateCells*/ ) // no holes in elements if ( false /*!updateCells*/ ) // no holes in elements
@ -236,18 +236,18 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
return; return;
} }
if ((int) idNodesOldToNew.size() < oldNodeSize ) if ((vtkIdType) idNodesOldToNew.size() < oldNodeSize )
{ {
idNodesOldToNew.reserve( oldNodeSize ); idNodesOldToNew.reserve( oldNodeSize );
for ( int i = idNodesOldToNew.size(); i < oldNodeSize; ++i ) for ( vvtkIdType i = idNodesOldToNew.size(); i < oldNodeSize; ++i )
idNodesOldToNew.push_back( i ); idNodesOldToNew.push_back( i );
} }
// --- create new compacted Connectivity, Locations and Types // --- create new compacted Connectivity, Locations and Types
int newConnectivitySize = this->Connectivity->GetNumberOfConnectivityEntries(); vvtkIdType newConnectivitySize = this->Connectivity->GetNumberOfConnectivityEntries();
if ( newCellSize != oldCellSize ) if ( newCellSize != oldCellSize )
for ( int i = 0; i < oldCellSize - 1; ++i ) for ( vvtkIdType i = 0; i < oldCellSize - 1; ++i )
if ( this->Types->GetValue( i ) == VTK_EMPTY_CELL ) if ( this->Types->GetValue( i ) == VTK_EMPTY_CELL )
newConnectivitySize -= this->Connectivity->GetCellSize( i ); newConnectivitySize -= this->Connectivity->GetCellSize( i );
@ -257,11 +257,11 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New(); vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New();
newTypes->Initialize(); newTypes->Initialize();
newTypes->SetNumberOfValues(FromIdType<int>(newCellSize)); newTypes->SetNumberOfValues(FromIdType<vtkIdType>(newCellSize));
vtkIdTypeArray *newLocations = vtkIdTypeArray::New(); vtkIdTypeArray *newLocations = vtkIdTypeArray::New();
newLocations->Initialize(); newLocations->Initialize();
newLocations->SetNumberOfValues(FromIdType<int>(newCellSize)); newLocations->SetNumberOfValues(FromIdType<vtkIdType>(newCellSize));
std::vector< vtkIdType > pointsCell(1024); // --- points id to fill a new cell std::vector< vtkIdType > pointsCell(1024); // --- points id to fill a new cell
@ -273,11 +273,11 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
{ {
vtkDoubleArray* newDiameters = vtkDoubleArray::New(); vtkDoubleArray* newDiameters = vtkDoubleArray::New();
newDiameters->SetNumberOfComponents(1); newDiameters->SetNumberOfComponents(1);
for ( int newCellID = 0; newCellID < newCellSize; newCellID++ ) for ( vvtkIdType newCellID = 0; newCellID < newCellSize; newCellID++ )
{ {
if ( newTypes->GetValue( newCellID ) == VTK_POLY_VERTEX ) if ( newTypes->GetValue( newCellID ) == VTK_POLY_VERTEX )
{ {
int oldCellID = idCellsNewToOld[ newCellID ]; vvtkIdType oldCellID = idCellsNewToOld[ newCellID ];
newDiameters->InsertValue( newCellID, diameters->GetValue( oldCellID )); newDiameters->InsertValue( newCellID, diameters->GetValue( oldCellID ));
} }
vtkDataSet::CellData->SetScalars( newDiameters ); vtkDataSet::CellData->SetScalars( newDiameters );
@ -292,14 +292,14 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
vtkIdTypeArray *newFaces = vtkIdTypeArray::New(); vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
newFaces->Initialize(); newFaces->Initialize();
newFaces->Allocate(this->Faces->GetSize()); newFaces->Allocate(this->Faces->GetSize());
for ( int newCellID = 0; newCellID < newCellSize; newCellID++ ) for ( vvtkIdType newCellID = 0; newCellID < newCellSize; newCellID++ )
{ {
if ( newTypes->GetValue( newCellID ) == VTK_POLYHEDRON ) if ( newTypes->GetValue( newCellID ) == VTK_POLYHEDRON )
{ {
int oldCellId = idCellsNewToOld[ newCellID ]; smIdType oldCellId = idCellsNewToOld[ newCellID ];
newFaceLocations->InsertNextValue( newFaces->GetMaxId()+1 ); newFaceLocations->InsertNextValue( newFaces->GetMaxId()+1 );
int oldFaceLoc = this->FaceLocations->GetValue( oldCellId ); smIdType oldFaceLoc = this->FaceLocations->GetValue( oldCellId );
int nCellFaces = this->Faces->GetValue( oldFaceLoc++ ); smIdType nCellFaces = this->Faces->GetValue( oldFaceLoc++ );
newFaces->InsertNextValue( nCellFaces ); newFaces->InsertNextValue( nCellFaces );
for ( int n = 0; n < nCellFaces; n++ ) for ( int n = 0; n < nCellFaces; n++ )
{ {
@ -307,7 +307,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
newFaces->InsertNextValue( nptsInFace ); newFaces->InsertNextValue( nptsInFace );
for ( int k = 0; k < nptsInFace; k++ ) for ( int k = 0; k < nptsInFace; k++ )
{ {
int oldpt = this->Faces->GetValue( oldFaceLoc++ ); vtkIdType oldpt = this->Faces->GetValue( oldFaceLoc++ );
newFaces->InsertNextValue( idNodesOldToNew[ oldpt ]); newFaces->InsertNextValue( idNodesOldToNew[ oldpt ]);
} }
} }
@ -337,13 +337,13 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<smIdType>& idNodesOldToNew,
void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints, void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints,
std::vector<smIdType>& /*idNodesOldToNew*/, std::vector<smIdType>& /*idNodesOldToNew*/,
int& alreadyCopied, vvtkIdType& alreadyCopied,
int start, vvtkIdType start,
int end) vvtkIdType end)
{ {
void *target = newPoints->GetVoidPointer(3 * alreadyCopied); void *target = newPoints->GetVoidPointer(3 * alreadyCopied);
void *source = this->Points->GetVoidPointer(3 * start); void *source = this->Points->GetVoidPointer(3 * start);
int nbPoints = end - start; vvtkIdType nbPoints = end - start;
if (nbPoints > 0) if (nbPoints > 0)
{ {
memcpy(target, source, 3 * sizeof(double) * nbPoints); memcpy(target, source, 3 * sizeof(double) * nbPoints);
@ -360,7 +360,7 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray * newTypes,
{ {
for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); iNew++ ) for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); iNew++ )
{ {
int iOld = idCellsNewToOld[ iNew ]; vvtkIdType iOld = idCellsNewToOld[ iNew ];
newTypes->SetValue( iNew, this->Types->GetValue( iOld )); newTypes->SetValue( iNew, this->Types->GetValue( iOld ));
vtkIdType oldLoc = ((vtkIdTypeArray *)(this->Connectivity->GetOffsetsArray()))->GetValue( iOld ); vtkIdType oldLoc = ((vtkIdTypeArray *)(this->Connectivity->GetOffsetsArray()))->GetValue( iOld );
@ -371,25 +371,25 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray * newTypes,
pointsCell.resize( nbpts ); pointsCell.resize( nbpts );
for ( int l = 0; l < nbpts; l++ ) for ( int l = 0; l < nbpts; l++ )
{ {
int oldval = oldPtsCell[l]; vvtkIdType oldval = oldPtsCell[l];
pointsCell[l] = idNodesOldToNew[oldval]; pointsCell[l] = idNodesOldToNew[oldval];
} }
/*int newcnt = */newConnectivity->InsertNextCell( nbpts, pointsCell.data() ); /*vvtkIdType newcnt = */newConnectivity->InsertNextCell( nbpts, pointsCell.data() );
int newLoc = newConnectivity->GetInsertLocation( nbpts ); vvtkIdType newLoc = newConnectivity->GetInsertLocation( nbpts );
newLocations->SetValue( iNew, newLoc ); newLocations->SetValue( iNew, newLoc );
} }
} }
int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId) int SMDS_UnstructuredGrid::CellIdToDownId(vtkIdType vtkCellId)
{ {
if ((vtkCellId < 0) || (vtkCellId >= (int)_cellIdToDownId.size())) if ((vtkCellId < 0) || (vtkCellId >= (vvtkIdType)_cellIdToDownId.size()))
{ {
return -1; return -1;
} }
return _cellIdToDownId[vtkCellId]; return _cellIdToDownId[vtkCellId];
} }
void SMDS_UnstructuredGrid::setCellIdToDownId(int vtkCellId, int downId) void SMDS_UnstructuredGrid::setCellIdToDownId(vvtkIdType vtkCellId, int downId)
{ {
// ASSERT((vtkCellId >= 0) && (vtkCellId < _cellIdToDownId.size())); // ASSERT((vtkCellId >= 0) && (vtkCellId < _cellIdToDownId.size()));
_cellIdToDownId[vtkCellId] = downId; _cellIdToDownId[vtkCellId] = downId;

View File

@ -81,7 +81,7 @@ public:
virtual vtkMTimeType GetMTime(); virtual vtkMTimeType GetMTime();
virtual vtkPoints *GetPoints(); virtual vtkPoints *GetPoints();
int InsertNextLinkedCell(int type, int npts, vtkIdType *pts); vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
int CellIdToDownId(int vtkCellId); int CellIdToDownId(int vtkCellId);
void setCellIdToDownId(int vtkCellId, int downId); void setCellIdToDownId(int vtkCellId, int downId);

View File

@ -30,7 +30,6 @@
#define SMDS_VolumeTool_HeaderFile #define SMDS_VolumeTool_HeaderFile
#include "SMESH_SMDS.hxx" #include "SMESH_SMDS.hxx"
#include <smIdType.hxx>
class SMDS_MeshElement; class SMDS_MeshElement;
class SMDS_MeshNode; class SMDS_MeshNode;

View File

@ -218,9 +218,9 @@ void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z
bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[], const SMDS_MeshNode * nodes[],
const smIdType nbnodes) const int nbnodes)
{ {
if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, FromIdType<int>(nbnodes) )) if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
return false; return false;
std::vector<smIdType> IDs( nbnodes ); std::vector<smIdType> IDs( nbnodes );
@ -2262,7 +2262,7 @@ void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges)
* @param localClonedNodeIds map old node id to new node id. * @param localClonedNodeIds map old node id to new node id.
* @return ok if success. * @return ok if success.
*/ */
bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNodeIds) bool SMESHDS_Mesh::ModifyCellNodes(vtkIdType vtkVolId, std::map<int,int> localClonedNodeIds)
{ {
myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds); myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);
return true; return true;

View File

@ -594,14 +594,14 @@ class SMESHDS_EXPORT SMESHDS_Mesh : public SMDS_Mesh
bool ChangeElementNodes(const SMDS_MeshElement * elem, bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[], const SMDS_MeshNode * nodes[],
const smIdType nbnodes); const int nbnodes);
bool ChangePolygonNodes(const SMDS_MeshElement * elem, bool ChangePolygonNodes(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes); std::vector<const SMDS_MeshNode*> nodes);
bool ChangePolyhedronNodes(const SMDS_MeshElement * elem, bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
const std::vector<const SMDS_MeshNode*>& nodes, const std::vector<const SMDS_MeshNode*>& nodes,
const std::vector<int>& quantities); const std::vector<int>& quantities);
bool ModifyCellNodes(int smdsVolId, std::map<int,int> localClonedNodeIds); bool ModifyCellNodes(vtkIdType smdsVolId, std::map<int,int> localClonedNodeIds);
void Renumber (const bool isNodes, const int startID=1, const int deltaID=1); void Renumber (const bool isNodes, const smIdType startID=1, const smIdType deltaID=1);
void SetNodeInVolume(const SMDS_MeshNode * aNode, const TopoDS_Shell & S); void SetNodeInVolume(const SMDS_MeshNode * aNode, const TopoDS_Shell & S);
void SetNodeInVolume(const SMDS_MeshNode * aNode, const TopoDS_Solid & S); void SetNodeInVolume(const SMDS_MeshNode * aNode, const TopoDS_Solid & S);

View File

@ -106,7 +106,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * elem)
AddNode( static_cast< const SMDS_MeshNode* >( elem )); AddNode( static_cast< const SMDS_MeshNode* >( elem ));
return; return;
} }
smIdType oldShapeId = elem->GetShapeID(); int oldShapeId = elem->GetShapeID();
if ( oldShapeId > 0 ) if ( oldShapeId > 0 )
{ {
if (oldShapeId != myIndex) if (oldShapeId != myIndex)
@ -235,12 +235,12 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_SubMesh::NbElements() const smIdType SMESHDS_SubMesh::NbElements() const
{ {
if ( !IsComplexSubmesh() ) if ( !IsComplexSubmesh() )
return myNbElements; return myNbElements;
int nbElems = 0; smIdType nbElems = 0;
TSubMeshSet::const_iterator it = mySubMeshes.begin(); TSubMeshSet::const_iterator it = mySubMeshes.begin();
for ( ; it != mySubMeshes.end(); it++ ) for ( ; it != mySubMeshes.end(); it++ )
nbElems += (*it)->NbElements(); nbElems += (*it)->NbElements();
@ -253,12 +253,12 @@ int SMESHDS_SubMesh::NbElements() const
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_SubMesh::NbNodes() const smIdType SMESHDS_SubMesh::NbNodes() const
{ {
if ( !IsComplexSubmesh() ) if ( !IsComplexSubmesh() )
return myNbNodes; return myNbNodes;
int nbElems = 0; smIdType nbElems = 0;
TSubMeshSet::const_iterator it = mySubMeshes.begin(); TSubMeshSet::const_iterator it = mySubMeshes.begin();
for ( ; it != mySubMeshes.end(); it++ ) for ( ; it != mySubMeshes.end(); it++ )
nbElems += (*it)->NbNodes(); nbElems += (*it)->NbNodes();

View File

@ -67,8 +67,8 @@ class SMESHDS_EXPORT SMESHDS_SubMesh : public SMDS_ElementHolder
SMESHDS_SubMeshIteratorPtr GetSubMeshIterator() const; SMESHDS_SubMeshIteratorPtr GetSubMeshIterator() const;
// for both types // for both types
virtual int NbElements() const; virtual smIdType NbElements() const;
virtual int NbNodes() const; virtual smIdType NbNodes() const;
virtual SMDS_ElemIteratorPtr GetElements() const; virtual SMDS_ElemIteratorPtr GetElements() const;
virtual SMDS_NodeIteratorPtr GetNodes() const; virtual SMDS_NodeIteratorPtr GetNodes() const;
virtual bool Contains(const SMDS_MeshElement * ME) const; // check if elem or node is in virtual bool Contains(const SMDS_MeshElement * ME) const; // check if elem or node is in
@ -90,8 +90,8 @@ class SMESHDS_EXPORT SMESHDS_SubMesh : public SMDS_ElementHolder
private: private:
int myIndex; int myIndex;
int myNbElements; smIdType myNbElements;
int myNbNodes; smIdType myNbNodes;
const SMDS_MeshElement* my1stElemNode[2]; // elem and node with least ID, to optimize iteration const SMDS_MeshElement* my1stElemNode[2]; // elem and node with least ID, to optimize iteration
const SMESHDS_Mesh * myParent; const SMESHDS_Mesh * myParent;
TSubMeshSet mySubMeshes; TSubMeshSet mySubMeshes;