-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020 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
*/
//================================================================================
-int SMDS_Mesh::CheckMemory(const bool doNotRaise) throw (std::bad_alloc)
+int SMDS_Mesh::CheckMemory(const bool doNotRaise)
{
return -1;
#if !defined WIN32 && !defined __APPLE__
{
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if ( nodes.empty() )
+ throw std::invalid_argument("Polygon without nodes is forbidden");
if ( SMDS_MeshCell* cell = myCellFactory->NewCell( ID ))
{
cell->init( SMDSEntity_Polygon, nodes );
const int ID)
{
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if ( nodes.empty() )
+ throw std::invalid_argument("Polygon without nodes is forbidden");
if ( SMDS_MeshCell* cell = myCellFactory->NewCell( ID ))
{
cell->init( SMDSEntity_Quad_Polygon, nodes );
return found;
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose :
+//=======================================================================
+
+bool SMDS_Mesh::ChangePolyhedronNodes(const SMDS_MeshElement * element,
+ const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities)
+{
+ // keep current nodes of element
+ std::set<const SMDS_MeshNode*> oldNodes( element->begin_nodes(), element->end_nodes() );
+
+ // change nodes
+ bool Ok = false;
+ if ( const SMDS_MeshVolume* vol = DownCast<SMDS_MeshVolume>( element ))
+ Ok = vol->ChangeNodes( nodes, quantities );
+
+ if ( Ok )
+ {
+ setMyModified();
+ updateInverseElements( element, &nodes[0], nodes.size(), oldNodes );
+ }
+ return Ok;
+}
+
//=======================================================================
//function : ChangeElementNodes
//purpose :
Ok = cell->ChangeNodes(nodes, nbnodes);
if ( Ok )
+ {
setMyModified();
+ updateInverseElements( element, nodes, nbnodes, oldNodes );
+ }
+ return Ok;
+}
+
+//=======================================================================
+//function : updateInverseElements
+//purpose : update InverseElements when element changes node
+//=======================================================================
- if ( Ok && GetGrid()->HasLinks() ) // update InverseElements
+void SMDS_Mesh::updateInverseElements( const SMDS_MeshElement * element,
+ const SMDS_MeshNode* const* nodes,
+ const int nbnodes,
+ std::set<const SMDS_MeshNode*>& oldNodes )
+{
+ if ( GetGrid()->HasLinks() ) // update InverseElements
{
std::set<const SMDS_MeshNode*>::iterator it;
// AddInverseElement to new nodes
- for ( int i = 0; i < nbnodes; i++ ) {
+ for ( int i = 0; i < nbnodes; i++ )
+ {
it = oldNodes.find( nodes[i] );
if ( it == oldNodes.end() )
// new node
}
}
- return Ok;
}
const SMDS_Mesh0DElement* SMDS_Mesh::Find0DElement(const SMDS_MeshNode * node)