2023-06-17 00:28:19 +05:00
|
|
|
// Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
|
2017-12-22 16:14:24 +05:00
|
|
|
//
|
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
//
|
|
|
|
// File : SMDS_ElementHolder.cxx
|
|
|
|
// Module : SMESH
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "SMDS_ElementHolder.hxx"
|
|
|
|
|
|
|
|
#include "ObjectPool.hxx"
|
|
|
|
#include "SMDS_CellOfNodes.hxx"
|
|
|
|
#include "SMDS_Mesh.hxx"
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : SMDS_ElementHolder
|
|
|
|
//purpose : register self in the mesh
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
SMDS_ElementHolder::SMDS_ElementHolder( const SMDS_Mesh* mesh )
|
|
|
|
: myMesh( const_cast< SMDS_Mesh* >( mesh ))
|
|
|
|
{
|
2018-08-08 18:55:53 +05:00
|
|
|
if ( myMesh )
|
|
|
|
myPtrInMesh = myMesh->myElemHolders.insert( this ).first;
|
2017-12-22 16:14:24 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : ~SMDS_ElementHolder
|
|
|
|
//purpose : un-register self from the mesh
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
SMDS_ElementHolder::~SMDS_ElementHolder()
|
|
|
|
{
|
2018-08-08 18:55:53 +05:00
|
|
|
if ( myMesh )
|
|
|
|
myMesh->myElemHolders.erase( myPtrInMesh );
|
2017-12-22 16:14:24 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : beforeCompacting
|
|
|
|
//purpose : store vtkIDs of elements
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
void SMDS_ElementHolder::beforeCompacting()
|
|
|
|
{
|
2021-03-17 19:11:57 +05:00
|
|
|
for ( SMDS_ElemIteratorPtr it = getElements(); it->more(); )
|
2017-12-22 16:14:24 +05:00
|
|
|
{
|
|
|
|
const SMDS_MeshElement* e = it->next();
|
|
|
|
if ( !e ) continue;
|
|
|
|
if ( e->IsNull() && !dynamic_cast<const SMDS_CellOfNodes*>( e ))
|
|
|
|
continue; // removed element
|
|
|
|
myIsNode.push_back( e->GetType() == SMDSAbs_Node );
|
|
|
|
if ( myMesh->Contains( e ))
|
|
|
|
{
|
|
|
|
myVtkIDs.push_back( e->GetVtkID() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myExternalElems.push_back( e );
|
2021-03-17 19:11:57 +05:00
|
|
|
myVtkIDs.push_back( -1 * (vtkIdType) myExternalElems.size() );
|
2017-12-22 16:14:24 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : restoreElements
|
|
|
|
//purpose : restore pointers to elements
|
|
|
|
//=======================================================================
|
|
|
|
|
2021-03-17 19:11:57 +05:00
|
|
|
void SMDS_ElementHolder::restoreElements( const std::vector<smIdType>& idNodesOldToNew,
|
|
|
|
const std::vector<smIdType>& idCellsOldToNew )
|
2017-12-22 16:14:24 +05:00
|
|
|
{
|
|
|
|
tmpClear();
|
|
|
|
|
|
|
|
const SMDS_MeshElement* elem;
|
|
|
|
|
|
|
|
std::vector< bool >::iterator isNode = myIsNode.begin();
|
|
|
|
for ( size_t i = 0; i < myVtkIDs.size(); ++i, ++isNode )
|
|
|
|
{
|
2021-03-17 19:11:57 +05:00
|
|
|
vtkIdType vtkID = myVtkIDs[i];
|
2017-12-22 16:14:24 +05:00
|
|
|
if ( vtkID < 0 )
|
|
|
|
{
|
|
|
|
elem = myExternalElems[ (-vtkID)-1 ];
|
|
|
|
}
|
|
|
|
else if ( *isNode )
|
|
|
|
{
|
2021-03-17 19:11:57 +05:00
|
|
|
if ( vtkID < (vtkIdType)idNodesOldToNew.size() )
|
2017-12-22 16:14:24 +05:00
|
|
|
elem = myMesh->FindNodeVtk( idNodesOldToNew[ vtkID ]);
|
|
|
|
else
|
|
|
|
elem = myMesh->FindNodeVtk( vtkID );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-17 19:11:57 +05:00
|
|
|
if ( vtkID < (vtkIdType)idCellsOldToNew.size() )
|
2017-12-22 16:14:24 +05:00
|
|
|
elem = myMesh->FindElementVtk( idCellsOldToNew[ vtkID ]);
|
|
|
|
else
|
|
|
|
elem = myMesh->FindElementVtk( vtkID );
|
|
|
|
}
|
|
|
|
if ( elem )
|
|
|
|
add( elem );
|
|
|
|
}
|
|
|
|
clearVector( myExternalElems );
|
|
|
|
clearVector( myVtkIDs );
|
|
|
|
clearVector( myIsNode );
|
|
|
|
|
|
|
|
compact();
|
|
|
|
}
|