OOF2: The Manual
Name
ElementNodeIterator — Iterate over Nodes in an Element
Synopses
C++ Synopsis
#include "engine/elementnodeiterator.h"
class ElementNodeIterator {Node* node() const;ElementNodeIterator& operator++();virtual bool end() const;virtual void set_start();const MasterCoord& mastercoord() const;
}
Python Synopsis
from oof2.SWIG.engine import elementnodeiterator
class ElementNodeIterator:def node(self)def increment(self)def end(self)def set_start(self)def __getitem__(self, dummyindex)
Description
An ElementNodeIterator is used to loop
over all of the Nodes of an
Element.
ElementNodeIterators should be
created by calling Element::node_iterator,
rather than calling the
ElementNodeIterator constructor
directly.
Here's how to iterate over Nodes in C++:
Element *element; // assume this has been set
for(ElementNodeIterator iter=element->node_iterator(); !iter.end(); ++iter) {
Node *node = iter.node();
// do something with node
} and here's one way to do it in Python:
for nodeiter in element.node_iterator(): node = nodeiter.node() // do something with node
Here's an uglier way to do it in Python, which might be useful in some circumstances:
nodeiter = element.node_iterator()
while not nodeiter.end():
node = nodeiter.node()
// do something with node
nodeiter.increment()
Methods
Only those methods useful to authors of OOF2 extensions are discussed here.
ElementNodeIterator& operator++(), increment()
The C++ function operator++ and the
Python function increment both
advance the iterator to the next
Node. The nodes are visited in an
arbitrary order.
operator++ returns a reference to
the iterator. increment returns
None.
void set_start()
Sometimes it's useful to look for a particular Node in
an Elementand
then to loop over all of the other
Nodes. This can be done by iterating
until the desired Node is found, and
then calling the iterator's
set_start method. This
reinitializes the iterator without changing its current
position. The end
flag won't be set until the iterator returns to its current
position.
const MasterCoord& mastercoord() const
mastercoord returns the master coordinate space
position of the Node that
the iterator currently points to. It's not possible to get
this information directly from the
Node, because a single
Node can be in many Elements,
and have a different master space position in each.
ElementNodeIterators don't have this
problem, because they know which
Element they're looping over.



