Add GetElementsByNodes() that return elements including all given nodes.
Mesh generation on the geometry is performed in the bottom-up
flow: nodes on vertices are created first, then edges are divided into
-segments using nodes on vertices; the node of segments are then
+segments using nodes on vertices; the nodes of segments are then
used to mesh faces; then the nodes of faces are used to mesh
solids. This automatically assures the conformity of the mesh.
*/
long FindElementByNodes(in long_array nodes);
+ /*!
+ * Return elements including all given nodes.
+ */
+ long_array GetElementsByNodes(in long_array nodes, in ElementType elem_type);
+
/*!
* Returns true if given element is polygon
*/
return NULL;
}
+//================================================================================
+/*!
+ * \brief Return elements including all given nodes
+ * \param [in] nodes - nodes to find elements around
+ * \param [out] foundElems - the found elements
+ * \param [in] type - type of elements to find
+ * \return int - a number of found elements
+ */
+//================================================================================
+
+int SMDS_Mesh::GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
+ std::vector<const SMDS_MeshElement *>& foundElems,
+ const SMDSAbs_ElementType type)
+{
+ // chose a node with minimal number of inverse elements
+ const SMDS_MeshNode* n0 = nodes[0];
+ int minNbInverse = n0 ? n0->NbInverseElements( type ) : 1000;
+ for ( size_t i = 1; i < nodes.size(); ++i )
+ if ( nodes[i] && nodes[i]->NbInverseElements( type ) < minNbInverse )
+ {
+ n0 = nodes[i];
+ minNbInverse = n0->NbInverseElements( type );
+ }
+
+ foundElems.clear();
+ if ( n0 )
+ {
+ foundElems.reserve( minNbInverse );
+ SMDS_ElemIteratorPtr eIt = n0->GetInverseElementIterator( type );
+ while ( eIt->more() )
+ {
+ const SMDS_MeshElement* e = eIt->next();
+ bool includeAll = true;
+ for ( size_t i = 0; i < nodes.size() && includeAll; ++i )
+ if ( nodes[i] != n0 && e->GetNodeIndex( nodes[i] ) < 0 )
+ includeAll = false;
+ if ( includeAll )
+ foundElems.push_back( e );
+ }
+ }
+ return foundElems.size();
+}
+
//=======================================================================
//function : DumpNodes
//purpose :
static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
const SMDSAbs_ElementType type=SMDSAbs_All,
const bool noMedium=true);
+ static int GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
+ std::vector<const SMDS_MeshElement *>& foundElems,
+ const SMDSAbs_ElementType type=SMDSAbs_All);
/*!
* \brief Raise an exception if free memory (ram+swap) too low
return elemID;
}
+//================================================================================
+/*!
+ * \brief Return elements including all given nodes.
+ */
+//================================================================================
+
+SMESH::long_array* SMESH_Mesh_i::GetElementsByNodes(const SMESH::long_array& nodes,
+ SMESH::ElementType elemType)
+{
+ if ( _preMeshInfo )
+ _preMeshInfo->FullLoadFromFile();
+
+ SMESH::long_array_var result = new SMESH::long_array();
+
+ if ( SMESHDS_Mesh* mesh = _impl->GetMeshDS() )
+ {
+ vector< const SMDS_MeshNode * > nn( nodes.length() );
+ for ( CORBA::ULong i = 0; i < nodes.length(); ++i )
+ nn[i] = mesh->FindNode( nodes[i] );
+
+ std::vector<const SMDS_MeshElement *> elems;
+ mesh->GetElementsByNodes( nn, elems, (SMDSAbs_ElementType) elemType );
+ result->length( elems.size() );
+ for ( size_t i = 0; i < elems.size(); ++i )
+ result[i] = elems[i]->GetID();
+ }
+ return result._retn();
+}
+
//=============================================================================
/*!
* Returns true if given element is polygon
* Returns true if given node is medium node
* in one of quadratic elements
*/
- CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
- SMESH::ElementType theElemType);
+ CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
+ SMESH::ElementType elemType);
/*!
* Returns number of edges for given element
*/
CORBA::Long FindElementByNodes(const SMESH::long_array& nodes);
+ /*!
+ * Return elements including all given nodes.
+ */
+ SMESH::long_array* GetElementsByNodes(const SMESH::long_array& nodes,
+ SMESH::ElementType elemType);
+
/*!
* Returns true if given element is polygon
*/