[MOAB-dev] r5846 - in MOAB/trunk: src src/moab test
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Wed Oct 31 17:25:00 CDT 2012
Author: tautges
Date: 2012-10-31 17:25:00 -0500 (Wed, 31 Oct 2012)
New Revision: 5846
Modified:
MOAB/trunk/src/Core.cpp
MOAB/trunk/src/moab/Range.hpp
MOAB/trunk/test/MBTest.cpp
Log:
Modify behavior of moab::get_coords, to return centroids of non-vertex entities instead of failing.
Tested in moab_test, and passes make check in serial and parallel.
Sorry for the long recompile...
test/MBTest.cpp: test get_coords for non-vertex entities.
src/moab/Range.hpp: make const_pair_iterator::operator* and operator-> return const PairNode*
instead of const std::pair<EH, EH>; the former is derived from the latter, so in the case where
the calling application wants just a std::pair, that's what it'll see. Needed so I can construct
a Range::const_iterator from a const_pair_iterator.
src/Core.cpp: extend all get_coords functions to work for non-vertex entities; coordinates of non-vertex
entities is defined as the centroid of the entity (avg of all vertex positions).
Modified: MOAB/trunk/src/Core.cpp
===================================================================
--- MOAB/trunk/src/Core.cpp 2012-10-31 22:03:37 UTC (rev 5845)
+++ MOAB/trunk/src/Core.cpp 2012-10-31 22:25:00 UTC (rev 5846)
@@ -940,7 +940,7 @@
Range::const_pair_iterator i = entities.const_pair_begin();
EntityHandle first = i->first;
- while (i != entities.const_pair_end()) {
+ while (i != entities.const_pair_end() && TYPE_FROM_HANDLE(i->first) == MBVERTEX) {
seq_iter = vert_data.lower_bound( first );
if (seq_iter == vert_data.end() || first < (*seq_iter)->start_handle())
@@ -974,8 +974,16 @@
}
coords=&coords[ 3*count ];
}
-
- return MB_SUCCESS;
+
+ // for non-vertices...
+ ErrorCode rval = MB_SUCCESS;
+ for (Range::const_iterator rit(&(*i), i->first); rit != entities.end(); rit++) {
+ rval = get_coords(&(*rit), 1, coords);
+ if (MB_SUCCESS != rval) return rval;
+ coords += 3;
+ }
+
+ return rval;
}
/**\author Jason Kraftcheck <kraftche at cae.wisc.edu> - 2007-5-15 */
@@ -989,7 +997,7 @@
Range::const_pair_iterator i = entities.const_pair_begin();
EntityHandle first = i->first;
- while (i != entities.const_pair_end()) {
+ while (i != entities.const_pair_end() && TYPE_FROM_HANDLE(i->first) == MBVERTEX) {
seq_iter = vert_data.lower_bound( first );
if (seq_iter == vert_data.end() || first < (*seq_iter)->start_handle())
@@ -1027,46 +1035,74 @@
}
}
- return MB_SUCCESS;
+ // for non-vertices...
+ ErrorCode rval = MB_SUCCESS;
+ double xyz[3];
+ for (Range::const_iterator rit(&(*i), i->first); rit != entities.end(); rit++) {
+ rval = get_coords(&(*rit), 1, xyz);
More information about the moab-dev
mailing list