moab
|
00001 #include "moab/Interface.hpp" 00002 #include "moab/BoundBox.hpp" 00003 00004 namespace moab 00005 { 00006 ErrorCode BoundBox::update(Interface &iface, const Range& elems) 00007 { 00008 ErrorCode rval; 00009 bMin = CartVect(HUGE_VAL); 00010 bMax = CartVect(-HUGE_VAL); 00011 00012 CartVect coords; 00013 EntityHandle const *conn, *conn2; 00014 int len, len2; 00015 Range::const_iterator i; 00016 00017 // vertices 00018 const Range::const_iterator elem_begin = elems.lower_bound( MBEDGE ); 00019 for (i = elems.begin(); i != elem_begin; ++i) { 00020 rval = iface.get_coords( &*i, 1, coords.array() ); 00021 if (MB_SUCCESS != rval) 00022 return rval; 00023 update_min(coords.array()); 00024 update_max(coords.array()); 00025 } 00026 00027 // elements with vertex-handle connectivity list 00028 const Range::const_iterator poly_begin = elems.lower_bound( MBPOLYHEDRON, elem_begin ); 00029 std::vector<EntityHandle> dum_vector; 00030 for (i = elem_begin; i != poly_begin; ++i) { 00031 rval = iface.get_connectivity( *i, conn, len, true, &dum_vector); 00032 if (MB_SUCCESS != rval) 00033 return rval; 00034 00035 for (int j = 0; j < len; ++j) { 00036 rval = iface.get_coords( conn+j, 1, coords.array() ); 00037 if (MB_SUCCESS != rval) 00038 return rval; 00039 update_min(coords.array()); 00040 update_max(coords.array()); 00041 } 00042 } 00043 00044 // polyhedra 00045 const Range::const_iterator set_begin = elems.lower_bound( MBENTITYSET, poly_begin ); 00046 for (i = poly_begin; i != set_begin; ++i) { 00047 rval = iface.get_connectivity( *i, conn, len, true ); 00048 if (MB_SUCCESS != rval) 00049 return rval; 00050 00051 for (int j = 0; j < len; ++j) { 00052 rval = iface.get_connectivity( conn[j], conn2, len2 ); 00053 for (int k = 0; k < len2; ++k) { 00054 rval = iface.get_coords( conn2+k, 1, coords.array() ); 00055 if (MB_SUCCESS != rval) 00056 return rval; 00057 update_min(coords.array()); 00058 update_max(coords.array()); 00059 } 00060 } 00061 } 00062 00063 // sets 00064 BoundBox box; 00065 for (i = set_begin; i != elems.end(); ++i) { 00066 Range tmp_elems; 00067 rval = iface.get_entities_by_handle(*i, tmp_elems); 00068 if (MB_SUCCESS != rval) return rval; 00069 rval = box.update(iface, tmp_elems); 00070 if (MB_SUCCESS != rval) return rval; 00071 00072 update(box); 00073 } 00074 00075 return MB_SUCCESS; 00076 } 00077 00078 }