[MOAB-dev] r3870 - MOAB/trunk/tools

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon May 10 08:56:37 CDT 2010


Author: kraftche
Date: 2010-05-10 08:56:37 -0500 (Mon, 10 May 2010)
New Revision: 3870

Modified:
   MOAB/trunk/tools/size.cpp
Log:
add new mode to mbsize that prints all tags and for each tag the count of each entity type with the tag set

Modified: MOAB/trunk/tools/size.cpp
===================================================================
--- MOAB/trunk/tools/size.cpp	2010-05-10 13:55:42 UTC (rev 3869)
+++ MOAB/trunk/tools/size.cpp	2010-05-10 13:56:37 UTC (rev 3870)
@@ -51,6 +51,7 @@
   std::cerr << "Usage: " << exe << " [-g] [-m] [-l] [-ll] <mesh file list>" << std::endl
             << "-g  : print counts by geometric owner" << std::endl
             << "-m  : print counts per block/boundary" << std::endl
+            << "-t  : print counts by tag" << std::endl
             << "-l  : print counts of mesh" << std::endl
             << "-ll : verbose listing of every entity" << std::endl
             ;
@@ -172,6 +173,48 @@
   return MB_SUCCESS;
 }
 
+struct TagCounts {
+  TagCounts(std::string n) : name(n) 
+    { std::fill(counts, counts+MBMAXTYPE, 0); }
+  std::string name;
+  int counts[MBMAXTYPE];
+};
+ErrorCode gather_tag_counts( EntityHandle set, 
+                             std::vector<TagCounts>& counts )
+{
+  std::vector<Tag> tags;
+  mb.tag_get_tags( tags );
+  for (size_t i = 0; i < tags.size(); ++i) {
+    std::string name;
+    ErrorCode rval = mb.tag_get_name( tags[i], name );
+    if (MB_SUCCESS != rval || name.empty())
+      continue;
+    
+    counts.push_back( name );
+    for (EntityType t = MBVERTEX; t != MBMAXTYPE; ++t) 
+      mb.get_number_entities_by_type_and_tag( set, t, &tags[i], 0, 1, counts.back().counts[t] );
+  }
+  
+  return MB_SUCCESS;
+}
+
+void add_tag_counts( std::vector<TagCounts>& counts,
+                     const std::vector<TagCounts>& add )
+{
+  for (size_t i = 0; i < add.size(); ++i) {
+    size_t j;
+    for (j = 0; j < counts.size(); ++j)
+      if (add[i].name == counts[j].name)
+        break;
+    if (j == counts.size()) {
+      counts.push_back( add[i] );


More information about the moab-dev mailing list