Sierra Toolkit Version of the Day
Iterators.cpp
00001 #include <stk_mesh/base/Iterators.hpp>
00002 
00003 namespace stk {
00004 namespace mesh {
00005 
00006 BucketVectorEntityIteratorRange get_entity_range(const std::vector<Bucket*>& buckets)
00007 {
00008   if ( buckets.empty() ) {
00009     BucketVectorEntityIterator end_itr(buckets.end());
00010     return std::make_pair(end_itr, end_itr);
00011   }
00012   else {
00013     return std::make_pair(BucketVectorEntityIterator(buckets.begin(), BucketPtrIterator((*buckets.begin())->begin()),   buckets.end()),
00014                           BucketVectorEntityIterator(buckets.end()));
00015   }
00016 }
00017 
00018 SelectedBucketVectorEntityIteratorRange get_entity_range(const std::vector<Bucket*>& buckets, const Selector& selector)
00019 {
00020   if ( buckets.empty() ) {
00021     SelectedBucketVectorIterator end_select_itr(buckets.end());
00022     //SelectedBucketVectorIterator end_select_itr(selector, buckets.end(), buckets.end());
00023     SelectedBucketVectorEntityIterator end_itr(end_select_itr);
00024     return std::make_pair(end_itr, end_itr);
00025   }
00026   else {
00027     //SelectedBucketVectorIterator end_select_itr(selector, buckets.end(), buckets.end());
00028     SelectedBucketVectorIterator end_select_itr(buckets.end());
00029     return std::make_pair(SelectedBucketVectorEntityIterator(SelectedBucketVectorIterator(selector, buckets.begin(), buckets.end()),
00030                                                              BucketPtrIterator((*buckets.begin())->begin()),
00031                                                              end_select_itr),
00032                           SelectedBucketVectorEntityIterator(end_select_itr));
00033   }
00034 }
00035 
00036 AllBucketsRange get_bucket_range(const std::vector<std::vector<Bucket*> >& buckets)
00037 {
00038   if (buckets.empty()) {
00039     AllBucketsIterator end_itr(buckets.end());
00040     return std::make_pair(end_itr, end_itr);
00041   }
00042   else {
00043     return std::make_pair(AllBucketsIterator(buckets.begin(), buckets.begin()->begin(), buckets.end()),
00044                           AllBucketsIterator(buckets.end()));
00045   }
00046 }
00047 
00048 AllBucketsRange get_bucket_range(const std::vector<std::vector<Bucket*> >& buckets,
00049                                  std::vector<std::vector<Bucket*> >::const_iterator itr)
00050 {
00051   AllBucketsIterator end_itr(itr+1);
00052   return std::make_pair(AllBucketsIterator(itr, itr->begin(), itr+1),
00053                         end_itr);
00054 }
00055 
00056 AllSelectedBucketsRange get_selected_bucket_range(const AllBucketsRange& bucket_range, const Selector& selector)
00057 {
00058   return std::make_pair(AllSelectedBucketsIterator(selector, bucket_range.first, bucket_range.second),
00059                         AllSelectedBucketsIterator(selector, bucket_range.second, bucket_range.second));
00060 }
00061 
00062 SelectedBucketRangeEntityIteratorRange get_selected_bucket_entity_range(const AllBucketsRange& bucket_range, const Selector& selector)
00063 {
00064   if (bucket_range.first == bucket_range.second) {
00065     AllSelectedBucketsIterator end_select_itr(bucket_range.second);
00066     //AllSelectedBucketsIterator end_select_itr(selector, bucket_range.second, bucket_range.second);
00067     SelectedBucketRangeEntityIterator end_itr(end_select_itr);
00068     return std::make_pair(end_itr, end_itr);
00069   }
00070   else {
00071     AllSelectedBucketsRange selected_bucket_range = get_selected_bucket_range(bucket_range, selector);
00072     return std::make_pair(SelectedBucketRangeEntityIterator(selected_bucket_range.first,
00073                                                             BucketPtrIterator( (*selected_bucket_range.first)->begin()),
00074                                                             selected_bucket_range.second),
00075                           SelectedBucketRangeEntityIterator(selected_bucket_range.second));
00076   }
00077 }
00078 
00079 } //namespace mesh
00080 } //namespace stk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends