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

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Tue Jan 19 16:23:59 CST 2010


Author: kraftche
Date: 2010-01-19 16:23:58 -0600 (Tue, 19 Jan 2010)
New Revision: 3440

Modified:
   MOAB/trunk/tools/size.cpp
Log:
Include vertex count in mbsize output

Modified: MOAB/trunk/tools/size.cpp
===================================================================
--- MOAB/trunk/tools/size.cpp	2010-01-19 22:20:34 UTC (rev 3439)
+++ MOAB/trunk/tools/size.cpp	2010-01-19 22:23:58 UTC (rev 3440)
@@ -101,6 +101,7 @@
 struct set_stats {
   stat_set stats[MBMAXTYPE];
   stat_set edge_uses;
+  size_t nodes;
   
   void add( const set_stats& other )
   {
@@ -123,6 +124,11 @@
 {
   MBErrorCode rval = MB_SUCCESS;
   
+  int count;
+  rval = moab.get_number_entities_by_type( set, MBVERTEX, count );
+  if (MB_SUCCESS != rval) return rval;
+  stats.nodes = count;
+  
   int edge_vtx_idx[2];
   std::vector<MBEntityHandle> conn;
   std::vector<double> coords;
@@ -176,6 +182,7 @@
 void print_stats( set_stats& stats )
 {
   const char* edge_use_name = "1D Side";
+  const char* vertex_name = "Vertex";
   
   bool have_some = stats.edge_uses.count > 0;
   for (int i = 0; i < MBMAXTYPE; ++i)
@@ -189,12 +196,17 @@
   }
   
     // get field widths
-  unsigned type_width = strlen( edge_use_name );
+  unsigned type_width = std::max( strlen(vertex_name), strlen( edge_use_name ) );
   unsigned count_width = 5;
   unsigned total_width = 5;
   unsigned total_prec = 2;
   unsigned precision = 5;
   int total_log = -10000;
+  
+  unsigned node_count_width = (unsigned)(ceil(log10(stats.nodes))) + 1;
+  if (count_width < node_count_width)
+    count_width = node_count_width;
+  
   for (MBEntityType i = MBEDGE; i < MBMAXTYPE; ++i)
   {
     stat_set& s = (i == MBMAXTYPE) ? stats.edge_uses : stats.stats[i];
@@ -299,6 +311,7 @@
             sqrt(tmp_dbl)
           );
   }
+  printf( "%*s %*lu\n", type_width, vertex_name, count_width, (unsigned long)stats.nodes );
   
   puts("");
 }



More information about the moab-dev mailing list