-
-ostream & operator <<(ostream & OS, const SMDS_MeshElement * ME)
-{
- ME->Print(OS);
- return OS;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-/// Create an iterator which iterate on nodes owned by the element.
-/// This method call elementsIterator().
-///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::nodesIterator() const
-{
- return elementsIterator(SMDSAbs_Node);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-/// Create an iterator which iterate on edges linked with or owned by the element.
-/// This method call elementsIterator().
-///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::edgesIterator() const
-{
- return elementsIterator(SMDSAbs_Edge);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-/// Create an iterator which iterate on faces linked with or owned by the element.
-/// This method call elementsIterator().
-///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::facesIterator() const
-{
- return elementsIterator(SMDSAbs_Face);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///Return The number of nodes owned by the current element
-///////////////////////////////////////////////////////////////////////////////
-int SMDS_MeshElement::NbNodes() const
-{
- int nbnodes=0;
- SMDS_Iterator<const SMDS_MeshElement *> * it=nodesIterator();
- while(it->more())
- {
- it->next();
- nbnodes++;
- }
- delete it;
- return nbnodes;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///Return the number of edges owned by or linked with the current element
-///////////////////////////////////////////////////////////////////////////////
-int SMDS_MeshElement::NbEdges() const
-{
- int nbedges=0;
- SMDS_Iterator<const SMDS_MeshElement *> * it=edgesIterator();
- while(it->more())
- {
- it->next();
- nbedges++;
- }
- delete it;
- return nbedges;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///Return the number of faces owned by or linked with the current element
-///////////////////////////////////////////////////////////////////////////////
-int SMDS_MeshElement::NbFaces() const
-{
- int nbfaces=0;
- SMDS_Iterator<const SMDS_MeshElement *> * it=facesIterator();
- while(it->more())
- {
- it->next();
- nbfaces++;
- }
- delete it;
- return nbfaces;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///Create and iterator which iterate on elements linked with the current element.
-///The iterator must be free by the caller (call delete myIterator).
-///@param type The of elements on which you want to iterate
-///@return An iterator, that you must free when you no longer need it
-///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::
- elementsIterator(SMDSAbs_ElementType type) const
-{
- /** @todo Check that iterator in the child classes return elements
- in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
- and SMDS_VolumeOfFaces */
- class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
- {
- const SMDS_MeshElement * myElement;
- bool myMore;
- public:
- MyIterator(const SMDS_MeshElement * element):
- myElement(element),myMore(true)
- {
- }
-
- bool more()
- {
- return myMore;
- }
-
- const SMDS_MeshElement* next()
- {
- myMore=false;
- return myElement;
- }
- };
-
- if(type==GetType()) return new MyIterator(this);
- else
- {
- MESSAGE("Iterator not implemented");
- return NULL;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///Return the ID of the element
-///////////////////////////////////////////////////////////////////////////////
+
+//================================================================================
+/*!
+ * \brief Check if a node belongs to the element
+ * \param node - the node to check
+ * \retval int - node index within the element, -1 if not found
+ */
+//================================================================================
+
+int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const
+{
+ SMDS_ElemIteratorPtr nIt = nodesIterator();
+ for ( int i = 0; nIt->more(); ++i )
+ if ( nIt->next() == node )
+ return i;
+ return -1;
+}
+
+//================================================================================
+/*!
+ * \brief Return ID of an element
+ */
+//================================================================================
+