SundanceRivaraElementIterator.cpp
Go to the documentation of this file.
00001 #include "SundanceRivaraElementIterator.hpp"
00002 #include "SundanceRivaraMesh.hpp"
00003 #include "SundanceRivaraElement.hpp"
00004 #include "SundanceRivaraNode.hpp"
00005 
00006 
00007 using namespace Sundance::Rivara;
00008 using namespace Teuchos;
00009 
00010 
00011 ElementIterator::ElementIterator(const RivaraMesh* mesh)
00012   : mesh_(const_cast<RivaraMesh*>(mesh)), rootIndex_(-1), current_(0),
00013     startingNewTree_(true)
00014 {}
00015 
00016 bool ElementIterator::hasMoreElements() const 
00017 {
00018   if (rootIndex_ < mesh_->numRootElements()-1)
00019     {
00020       return true;
00021     }
00022   else if (current_->next() != 0)
00023     {
00024       return true;
00025     }
00026   else return false;
00027 }
00028 
00029 const Element* ElementIterator::getNextElement() const 
00030 {
00031   if (current_==0)
00032     {
00033       current_ = const_cast<Element*>(dynamic_cast<const Element*>(mesh_->element(0)->first()));
00034       rootIndex_ = 0;
00035     }
00036   else if (current_->next() != 0)
00037     {
00038       current_ = const_cast<Element*>(dynamic_cast<const Element*>(current_->next()));
00039     }
00040   else
00041     {
00042       rootIndex_++;
00043       current_ = const_cast<Element*>(dynamic_cast<const Element*>(mesh_->element(rootIndex_)->first()));
00044     }
00045   
00046   return current_;
00047   
00048 }
00049 
00050   

Site Contact