[MOAB-dev] r5618 - MOAB/trunk/tools/dagmc

sjackson at mcs.anl.gov sjackson at mcs.anl.gov
Fri Jun 29 15:04:25 CDT 2012


Author: sjackson
Date: 2012-06-29 15:04:24 -0500 (Fri, 29 Jun 2012)
New Revision: 5618

Modified:
   MOAB/trunk/tools/dagmc/DagMC.cpp
   MOAB/trunk/tools/dagmc/DagMC.hpp
Log:
Add two more helper functions for DagMC properties

Valid property values may be looked up by property name, and property-bearing
entities can be looked up by property and, optionally, by property
value.

Modified: MOAB/trunk/tools/dagmc/DagMC.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.cpp	2012-06-29 19:01:12 UTC (rev 5617)
+++ MOAB/trunk/tools/dagmc/DagMC.cpp	2012-06-29 20:04:24 UTC (rev 5618)
@@ -1859,6 +1859,70 @@
 
 }
 
+
+ErrorCode DagMC::get_all_prop_values( const std::string& prop, std::vector<std::string>& return_list )
+{
+  ErrorCode rval;
+  std::map<std::string, Tag>::iterator it = property_tagmap.find(prop);
+  if( it == property_tagmap.end() ){
+    return MB_TAG_NOT_FOUND;
+  }
+  Tag proptag = (*it).second;
+  Range all_ents;
+
+  rval = MBI->get_entities_by_type_and_tag( 0, MBENTITYSET, &proptag, NULL, 1, all_ents );
+  if( MB_SUCCESS != rval ) return rval;
+
+  std::set<std::string> unique_values;
+  for( Range::iterator i = all_ents.begin(); i!= all_ents.end(); ++i){
+    std::vector<std::string> values;
+    rval = prop_values( *i, prop, values );
+    if( MB_SUCCESS != rval ) return rval;
+    unique_values.insert( values.begin(), values.end() );
+  }
+
+  return_list.assign( unique_values.begin(), unique_values.end() );
+  return MB_SUCCESS;
+}
+
+ErrorCode DagMC::entities_by_property( const std::string& prop, std::vector<EntityHandle>& return_list,
+                                       int dimension, const std::string* value )
+{
+  ErrorCode rval;
+  std::map<std::string, Tag>::iterator it = property_tagmap.find(prop);
+  if( it == property_tagmap.end() ){
+    return MB_TAG_NOT_FOUND;
+  }
+  Tag proptag = (*it).second;
+  Range all_ents;
+
+  // Note that we cannot specify values for proptag here-- the passed value,
+  // if it exists, may be only a subset of the packed string representation
+  // of this tag.
+  Tag tags[2] = {proptag, geomTag };
+  void* vals[2] = {NULL, (dimension!=0) ? &dimension : NULL };
+  rval = MBI->get_entities_by_type_and_tag( 0, MBENTITYSET, tags, vals, 2, all_ents );


More information about the moab-dev mailing list