00001 #ifndef OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_IGNORE_REGION_H 00002 #define OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_IGNORE_REGION_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 namespace OpenTissue 00013 { 00014 namespace grid 00015 { 00016 00020 struct inside_region_tag {}; 00021 00025 struct outside_region_tag {}; 00026 00027 00035 template<typename grid_type> 00036 inline void ignore_region(grid_type & phi, inside_region_tag const & /*region*/) 00037 { 00038 typedef typename grid_type::value_type value_type; 00039 typedef typename grid_type::index_iterator iterator; 00040 00041 value_type unused = phi.unused(); 00042 iterator end = phi.end(); 00043 iterator p = phi.begin(); 00044 for(;p!=end;++p) 00045 if(*p < 0 ) 00046 *p = unused; 00047 } 00048 00056 template<typename grid_type> 00057 inline void ignore_region(grid_type & phi, outside_region_tag const & /*region*/) 00058 { 00059 typedef typename grid_type::value_type value_type; 00060 typedef typename grid_type::index_iterator iterator; 00061 00062 value_type unused = phi.unused(); 00063 iterator end = phi.end(); 00064 iterator p = phi.begin(); 00065 for(;p!=end;++p) 00066 if(*p > 0 ) 00067 *p = unused; 00068 } 00069 00070 } // namespace grid 00071 } // namespace OpenTissue 00072 00073 // OPENTISSUE_CORE_CONTAINERS_GRID_UTIL_GRID_IGNORE_REGION_H 00074 #endif