[MOAB-dev] r3656 - in MOAB/trunk: . examples examples/FileReader examples/GeomSetHierarchy examples/GetEntities examples/SetsNTags examples/SkinMesh examples/SurfArea

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Mar 17 16:50:02 CDT 2010


Author: kraftche
Date: 2010-03-17 16:50:02 -0500 (Wed, 17 Mar 2010)
New Revision: 3656

Added:
   MOAB/trunk/examples/FileRead.cpp
   MOAB/trunk/examples/GeomSetHierarchy.cpp
   MOAB/trunk/examples/GetEntities.cpp
   MOAB/trunk/examples/SetsNTags.cpp
   MOAB/trunk/examples/SkinMesh.cpp
   MOAB/trunk/examples/SurfArea.cpp
   MOAB/trunk/examples/examples.make.in
Removed:
   MOAB/trunk/examples/FileReader/FileRead.cpp
   MOAB/trunk/examples/FileReader/Makefile
   MOAB/trunk/examples/GeomSetHierarchy/GeomSetHierarchy.cpp
   MOAB/trunk/examples/GeomSetHierarchy/Makefile
   MOAB/trunk/examples/GetEntities/GetEntities.cpp
   MOAB/trunk/examples/GetEntities/Makefile
   MOAB/trunk/examples/SetsNTags/Makefile
   MOAB/trunk/examples/SetsNTags/SetsNTags.cpp
   MOAB/trunk/examples/SkinMesh/Makefile
   MOAB/trunk/examples/SkinMesh/SkinMesh.cpp
   MOAB/trunk/examples/SurfArea/Makefile
   MOAB/trunk/examples/SurfArea/SurfArea.cpp
Modified:
   MOAB/trunk/Makefile.am
   MOAB/trunk/configure.ac
Log:
o Move all examples to top directory (will move one back as Tim requested)
o Add automake build system for examples (build all examples for 'make check')
o Install examples with working makefile in $(docdir)/examples
o Fix build issues in examples (should probably change them to use namespaced API)


Modified: MOAB/trunk/Makefile.am
===================================================================
--- MOAB/trunk/Makefile.am	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/Makefile.am	2010-03-17 21:50:02 UTC (rev 3656)
@@ -5,7 +5,7 @@
 ACLOCAL_AMFLAGS = -I config
 
 # Subdirectories to build
-SUBDIRS = src test $(itaps_dir) tools doc
+SUBDIRS = src test $(itaps_dir) tools doc examples
 
 if ENABLE_igeom
   itaps_dir_igeom = itaps

Modified: MOAB/trunk/configure.ac
===================================================================
--- MOAB/trunk/configure.ac	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/configure.ac	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1004,6 +1004,14 @@
 ################################################################################
 #                           Output Files
 ################################################################################
+
+# Some old versions of autoconf don't define docdir.  
+# Define it if autoconf did not.
+if test "x" = "x$docdir"; then
+  docdir='${datadir}/doc/moab'
+  AC_SUBST(docdir)
+fi
+
 AC_SUBST([AM_CPPFLAGS])
 AM_LDFLAGS="$AM_LDFLAGS $EXPORT_LTFLAGS $EXPORT_LDFLAGS"
 AC_SUBST([AM_LDFLAGS])
@@ -1050,6 +1058,8 @@
                  tools/dagmc/Makefile
                  doc/Makefile
                  doc/user.dox
+                 examples/Makefile
+                 examples/examples.make
                  ])
 AC_CONFIG_COMMANDS([src/MOAB_FCDefs.h],
   [sed -e "s/FC_FUNC/MOAB_FC_FUNC/" src/FCDefs.h >src/MOAB_FCDefs.h])

Copied: MOAB/trunk/examples/FileRead.cpp (from rev 3643, MOAB/trunk/examples/FileReader/FileRead.cpp)
===================================================================
--- MOAB/trunk/examples/FileRead.cpp	                        (rev 0)
+++ MOAB/trunk/examples/FileRead.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,160 @@
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <sstream> 
+
+#include "MBCore.hpp"
+#include "MBReadUtilIface.hpp"
+
+using namespace std;
+
+int comment(string & line)
+{
+    // if a line starts with '#' is a comment
+    // eat white space characters
+    int found=line.find_first_not_of(" \t");
+    if (found==string::npos)
+	return 1; // empty line
+    if ('#'==line[found])
+        return 1; // a comment indeed
+    return 0; // a line with some data in it, then
+
+}
+MBErrorCode ReadTriangleOutput( MBCore *mb, std::string fileBase ) {    
+  
+  //
+  // get the read interface from moab
+  void* ptr = 0;
+  mb->query_interface("MBReadUtilIface", &ptr);
+  MBReadUtilIface *iface = reinterpret_cast<MBReadUtilIface*>(ptr);
+  //
+  if (NULL == iface)
+     {
+        cout<<"Can't get interface.\n";
+        return MB_FAILURE;
+     }
+  // Triangle default <name>.node
+  string nodeFileName = fileBase+".node";
+  ifstream nodeFile (nodeFileName.c_str());
+  if (!nodeFile.is_open())
+  {
+     cout<<"can't open node file .\n";
+     return MB_FILE_DOES_NOT_EXIST;
+  }
+  cout << "reading nodes from file " << nodeFileName.c_str() << endl;
+  
+  string eleFileName = fileBase+".ele";
+  ifstream eleFile (eleFileName.c_str());
+  if (!eleFile.is_open())
+  {
+     cout<<"can't open element file .\n";
+     return MB_FILE_DOES_NOT_EXIST;
+  }
+  cout << "reading elements from file " << eleFileName.c_str() << endl;
+
+  string line;
+  
+  // ignore comment lines that start with #
+  
+  int num_nodes=0, num_triangles=0;
+  while(num_nodes==0)
+    {
+      getline(nodeFile, line);
+      if (comment(line))
+	continue;
+      stringstream tks(line);
+      tks >> num_nodes; // ignore the rest of the first line
+                        // maybe will read attributes some other time
+      cout << "num nodes:" << num_nodes << endl; 
+    }
+  
+  //  allocate a block of vertex handles and read xyz’s into them
+  //  we know the size of the node arrays, and this call will allocate 
+  //   needed arrays, coordinate arrays
+  //   also, it will return a starting handle for the node sequence
+  vector<double*> arrays;
+  MBEntityHandle startv, *starth;
+  MBErrorCode rval = iface->get_node_arrays(2, num_nodes, 0, startv, arrays);
+  for (int i = 0; i < num_nodes; i++)
+    {
+      getline(nodeFile, line);
+      if (comment(line))
+      {
+        i--;// read one more line
+	continue;
+      }
+      stringstream tokens(line);
+      int nodeId;
+      tokens >> nodeId >> arrays[0][i] >> arrays[1][i] ;
+    }
+  
+  // now read the element data from a different file
+  // first, find out how many elements are out there
+  // first line with data should have it
+  while(num_triangles==0)
+    {
+      getline(eleFile, line);
+      if (comment(line))
+	continue;
+      stringstream tks(line);
+      tks >> num_triangles; // ignore the rest of the line
+      cout << "num triangles:" << num_nodes << endl; 
+    }
+
+  MBEntityHandle starte;
+  // allocate block of triangle handles and read connectivity into them
+  rval = iface->get_element_array(num_triangles, 3, MBTRI, 0, starte, starth);
+  
+  for (int j = 0; j < num_triangles; j++)
+    {
+      getline(eleFile, line);
+      if (comment(line))
+      {
+        j--;// read one more line
+	continue;
+      }
+      stringstream tokens(line);
+      int eleId, node;
+      tokens >> eleId;
+      for (int k=0; k<3; k++)
+	{
+	  tokens >> node;
+          // vertex handles start at startv
+          starth[3*j+k] = (MBEntityHandle)(node + (int)startv-1 );
+        }
+    }
+
+  //       
+  return MB_SUCCESS;
+}
+
+
+// .
+//  Read Triangle output files 
+//  Assume that the format is <filename>.node and <filename>.ele
+//   see  http://www.cs.cmu.edu/~quake/triangle.html for details
+//
+int main(int argc, char **argv) {
+  if (3!=argc) {
+    cout << "Usage: " << argv[0] << " <filename>  <outFile> " << endl;
+    cout << "       <filename>  is the base file name; *.ele and *.node file are read; outFile is a file with an extension recognized by MOAB " << endl;
+    return 0;
+  }     
+
+  string filename = argv[1];
+  char * outfile = argv[2];
+  
+
+  // get MOAB instance and read the file                                                                                                  
+  MBCore *mb = new MBCore();
+
+   MBErrorCode rval = ReadTriangleOutput(mb, filename);
+
+   if (rval==MB_SUCCESS)
+   {
+     cout << "Writing output file " << outfile << endl;
+     mb->write_file(outfile); 
+   }
+   return 0;
+}  


Property changes on: MOAB/trunk/examples/FileRead.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Deleted: MOAB/trunk/examples/FileReader/FileRead.cpp
===================================================================
--- MOAB/trunk/examples/FileReader/FileRead.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/FileReader/FileRead.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,160 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <string>
-#include <sstream> 
-
-#include "MBCore.hpp"
-#include "MBReadUtilIface.hpp"
-
-using namespace std;
-
-int comment(string & line)
-{
-    // if a line starts with '#' is a comment
-    // eat white space characters
-    int found=line.find_first_not_of(" \t");
-    if (found==string::npos)
-	return 1; // empty line
-    if ('#'==line[found])
-        return 1; // a comment indeed
-    return 0; // a line with some data in it, then
-
-}
-MBErrorCode ReadTriangleOutput( MBCore *mb, std::string fileBase ) {    
-  
-  //
-  // get the read interface from moab
-  void* ptr = 0;
-  mb->query_interface("MBReadUtilIface", &ptr);
-  MBReadUtilIface *iface = reinterpret_cast<MBReadUtilIface*>(ptr);
-  //
-  if (NULL == iface)
-     {
-        cout<<"Can't get interface.\n";
-        return MB_FAILURE;
-     }
-  // Triangle default <name>.node
-  string nodeFileName = fileBase+".node";
-  ifstream nodeFile (nodeFileName.c_str());
-  if (!nodeFile.is_open())
-  {
-     cout<<"can't open node file .\n";
-     return MB_FILE_DOES_NOT_EXIST;
-  }
-  cout << "reading nodes from file " << nodeFileName.c_str() << endl;
-  
-  string eleFileName = fileBase+".ele";
-  ifstream eleFile (eleFileName.c_str());
-  if (!eleFile.is_open())
-  {
-     cout<<"can't open element file .\n";
-     return MB_FILE_DOES_NOT_EXIST;
-  }
-  cout << "reading elements from file " << eleFileName.c_str() << endl;
-
-  string line;
-  
-  // ignore comment lines that start with #
-  
-  int num_nodes=0, num_triangles=0;
-  while(num_nodes==0)
-    {
-      getline(nodeFile, line);
-      if (comment(line))
-	continue;
-      stringstream tks(line);
-      tks >> num_nodes; // ignore the rest of the first line
-                        // maybe will read attributes some other time
-      cout << "num nodes:" << num_nodes << endl; 
-    }
-  
-  //  allocate a block of vertex handles and read xyz’s into them
-  //  we know the size of the node arrays, and this call will allocate 
-  //   needed arrays, coordinate arrays
-  //   also, it will return a starting handle for the node sequence
-  vector<double*> arrays;
-  MBEntityHandle startv, *starth;
-  MBErrorCode rval = iface->get_node_arrays(2, num_nodes, 0, startv, arrays);
-  for (int i = 0; i < num_nodes; i++)
-    {
-      getline(nodeFile, line);
-      if (comment(line))
-      {
-        i--;// read one more line
-	continue;
-      }
-      stringstream tokens(line);
-      int nodeId;
-      tokens >> nodeId >> arrays[0][i] >> arrays[1][i] ;
-    }
-  
-  // now read the element data from a different file
-  // first, find out how many elements are out there
-  // first line with data should have it
-  while(num_triangles==0)
-    {
-      getline(eleFile, line);
-      if (comment(line))
-	continue;
-      stringstream tks(line);
-      tks >> num_triangles; // ignore the rest of the line
-      cout << "num triangles:" << num_nodes << endl; 
-    }
-
-  MBEntityHandle starte;
-  // allocate block of triangle handles and read connectivity into them
-  rval = iface->get_element_array(num_triangles, 3, MBTRI, 0, starte, starth);
-  
-  for (int j = 0; j < num_triangles; j++)
-    {
-      getline(eleFile, line);
-      if (comment(line))
-      {
-        j--;// read one more line
-	continue;
-      }
-      stringstream tokens(line);
-      int eleId, node;
-      tokens >> eleId;
-      for (int k=0; k<3; k++)
-	{
-	  tokens >> node;
-          // vertex handles start at startv
-          starth[3*j+k] = (MBEntityHandle)(node + (int)startv-1 );
-        }
-    }
-
-  //       
-  return MB_SUCCESS;
-}
-
-
-// .
-//  Read Triangle output files 
-//  Assume that the format is <filename>.node and <filename>.ele
-//   see  http://www.cs.cmu.edu/~quake/triangle.html for details
-//
-int main(int argc, char **argv) {
-  if (3!=argc) {
-    cout << "Usage: " << argv[0] << " <filename>  <outFile> " << endl;
-    cout << "       <filename>  is the base file name; *.ele and *.node file are read; outFile is a file with an extension recognized by MOAB " << endl;
-    return 0;
-  }     
-
-  string filename = argv[1];
-  char * outfile = argv[2];
-  
-
-  // get MOAB instance and read the file                                                                                                  
-  MBCore *mb = new MBCore();
-
-   MBErrorCode rval = ReadTriangleOutput(mb, filename);
-
-   if (rval==MB_SUCCESS)
-   {
-     cout << "Writing output file " << outfile << endl;
-     mb->write_file(outfile); 
-   }
-   return 0;
-}  

Deleted: MOAB/trunk/examples/FileReader/Makefile
===================================================================
--- MOAB/trunk/examples/FileReader/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/FileReader/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,10 +0,0 @@
-MOAB_LIB_DIR = /homes/iulian/lib/MOAB/lib
-CXX=/homes/sharp/3rdparty/mpich2/mpich2-1.1.1p1/gcc/bin/mpicxx
-include ${MOAB_LIB_DIR}/moab.make
-
-fread : FileRead.o
-	${CXX} -g $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} -g ${MOAB_INCLUDES} -c $<
-

Deleted: MOAB/trunk/examples/GeomSetHierarchy/GeomSetHierarchy.cpp
===================================================================
--- MOAB/trunk/examples/GeomSetHierarchy/GeomSetHierarchy.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/GeomSetHierarchy/GeomSetHierarchy.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,42 +0,0 @@
-#include "moab/MBCore.hpp"
-#include "moab/MBRange.hpp"
-#include <iostream>
-
-int main(int argc, char **argv) {
-  if (1 == argc) {
-    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
-    return 0;
-  }
-  
-    // instantiate & load a file
-  MBInterface *mb = new MBCore();
-  MBErrorCode rval = mb->load_file(argv[1]);
-
-    // get the geometric topology tag handle
-  MBTag geom_tag;
-  rval = mb->tag_get_handle("GEOM_DIMENSION", geom_tag);
-
-    // traverse the model, from dimension 3 downward
-  MBRange psets, chsets;
-  int dim;
-  void *dim_ptr = &dim;
-  for (dim = 3; dim >= 0; dim--) {
-      // get parents at this dimension
-    psets.clear();
-    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, 
-                                            &geom_tag, &dim_ptr, 1, 
-                                            psets, 1, false);
-
-      // for each parent, get children and do something with them
-    MBRange::iterator par_it;
-    for (par_it = psets.begin(); par_it != psets.end(); par_it++) {
-        // get the children and put in child set list
-      chsets.clear();
-      rval = mb ->get_child_meshsets(*par_it, chsets);
-
-        // print # children
-      std::cout << "d=" << dim << " entity has " << chsets.size() 
-                << " children." << std::endl;
-    }
-  } 
-}

Deleted: MOAB/trunk/examples/GeomSetHierarchy/Makefile
===================================================================
--- MOAB/trunk/examples/GeomSetHierarchy/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/GeomSetHierarchy/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,8 +0,0 @@
-include ${MOAB_LIB_DIR}/moab.make
-
-GeomSetHierarchy : GeomSetHierarchy.o
-	${CXX} $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} ${MOAB_INCLUDES} -c $<
-

Copied: MOAB/trunk/examples/GeomSetHierarchy.cpp (from rev 3643, MOAB/trunk/examples/GeomSetHierarchy/GeomSetHierarchy.cpp)
===================================================================
--- MOAB/trunk/examples/GeomSetHierarchy.cpp	                        (rev 0)
+++ MOAB/trunk/examples/GeomSetHierarchy.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,43 @@
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include "MBCN.hpp"
+#include <iostream>
+
+int main(int argc, char **argv) {
+  if (1 == argc) {
+    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+    return 0;
+  }
+  
+    // instantiate & load a file
+  MBInterface *mb = new MBCore();
+  MBErrorCode rval = mb->load_file(argv[1]);
+
+    // get the geometric topology tag handle
+  MBTag geom_tag;
+  rval = mb->tag_get_handle("GEOM_DIMENSION", geom_tag);
+
+    // traverse the model, from dimension 3 downward
+  MBRange psets, chsets;
+  int dim;
+  void *dim_ptr = &dim;
+  for (dim = 3; dim >= 0; dim--) {
+      // get parents at this dimension
+    psets.clear();
+    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, 
+                                            &geom_tag, &dim_ptr, 1, 
+                                            psets, 1, false);
+
+      // for each parent, get children and do something with them
+    MBRange::iterator par_it;
+    for (par_it = psets.begin(); par_it != psets.end(); par_it++) {
+        // get the children and put in child set list
+      chsets.clear();
+      rval = mb ->get_child_meshsets(*par_it, chsets);
+
+        // print # children
+      std::cout << "d=" << dim << " entity has " << chsets.size() 
+                << " children." << std::endl;
+    }
+  } 
+}


Property changes on: MOAB/trunk/examples/GeomSetHierarchy.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Deleted: MOAB/trunk/examples/GetEntities/GetEntities.cpp
===================================================================
--- MOAB/trunk/examples/GetEntities/GetEntities.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/GetEntities/GetEntities.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,27 +0,0 @@
-#include "moab/MBCore.hpp"
-#include "moab/MBRange.hpp"
-#include <iostream>
-
-int main(int argc, char **argv) {
-  if (1 == argc) {
-    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
-    return 0;
-  }
-
-    // instantiate & load a mesh from a file
-  MBCore *mb = new MBCore();
-  MBErrorCode rval = mb->load_mesh(argv[1]);
-
-  MBRange ents;
-
-    // iterate over dimensions
-  for (int d = 0; d <= 3; d++) {
-    rval = mb->get_entities_by_dimension(0, d, ents);
-    for (MBRange::iterator it = ents.begin(); it != ents.end(); it++) {
-      MBEntityHandle ent = *it;
-      std::cout << "Found d=" << d << " entity " 
-                << mb->id_from_handle(ent) << "." << std::endl;
-    }
-  }
-  return 0;
-}

Deleted: MOAB/trunk/examples/GetEntities/Makefile
===================================================================
--- MOAB/trunk/examples/GetEntities/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/GetEntities/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,8 +0,0 @@
-include ${MOAB_LIB_DIR}/moab.make
-
-GetEntities : GetEntities.o
-	${CXX} $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} ${MOAB_INCLUDES} -c $<
-

Copied: MOAB/trunk/examples/GetEntities.cpp (from rev 3645, MOAB/trunk/examples/GetEntities/GetEntities.cpp)
===================================================================
--- MOAB/trunk/examples/GetEntities.cpp	                        (rev 0)
+++ MOAB/trunk/examples/GetEntities.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,27 @@
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include <iostream>
+
+int main(int argc, char **argv) {
+  if (1 == argc) {
+    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+    return 0;
+  }
+
+    // instantiate & load a mesh from a file
+  MBCore *mb = new MBCore();
+  MBErrorCode rval = mb->load_mesh(argv[1]);
+
+  MBRange ents;
+
+    // iterate over dimensions
+  for (int d = 0; d <= 3; d++) {
+    rval = mb->get_entities_by_dimension(0, d, ents);
+    for (MBRange::iterator it = ents.begin(); it != ents.end(); it++) {
+      MBEntityHandle ent = *it;
+      std::cout << "Found d=" << d << " entity " 
+                << mb->id_from_handle(ent) << "." << std::endl;
+    }
+  }
+  return 0;
+}


Property changes on: MOAB/trunk/examples/GetEntities.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Deleted: MOAB/trunk/examples/SetsNTags/Makefile
===================================================================
--- MOAB/trunk/examples/SetsNTags/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SetsNTags/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,8 +0,0 @@
-include ${MOAB_LIB_DIR}/moab.make
-
-SetsNTags : SetsNTags.o
-	${CXX} $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} ${MOAB_INCLUDES} -c $<
-

Deleted: MOAB/trunk/examples/SetsNTags/SetsNTags.cpp
===================================================================
--- MOAB/trunk/examples/SetsNTags/SetsNTags.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SetsNTags/SetsNTags.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,48 +0,0 @@
-#include "moab/MBCore.hpp"
-#include "moab/MBRange.hpp"
-#include <iostream>
-
-int main(int argc, char **argv) {
-  if (1 == argc) {
-    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
-    return 0;
-  }
-
-    // get the material set tag handle
-  MBTag mtag;
-  MBErrorCode rval;
-  const char *tag_nms[] = {"MATERIAL_SET", "DIRICHLET_SET", 
-                           "NEUMANN_SET"};
-  MBRange sets, set_ents;
-
-    // instantiate & load a file
-  MBInterface *mb = new MBCore();
-  rval = mb->load_file(argv[1]);
-
-    // loop over set types
-  for (int i = 0; i < 3; i++) {
-    rval = mb->tag_get_handle(tag_nms[i], mtag);
-
-      // get all the sets of that type in the mesh
-    sets.clear();
-    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &mtag,
-                                            NULL, 1, sets);
-
-      // iterate over each set, getting entities
-    MBRange::iterator set_it;
-    for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
-      MBEntityHandle this_set = *set_it;
-
-        // get the id for this set
-      int set_id;
-      rval = mb->tag_get_data(mtag, &this_set, 1, &set_id);
-
-        // get the entities in the set, recursively
-      rval = mb->get_entities_by_handle(this_set, set_ents, true);
-
-      std::cout << tag_nms[i] << " " << set_id << " has " 
-                << set_ents.size() << " entities." << std::endl;
-      set_ents.clear();
-    }
-  }
-}

Copied: MOAB/trunk/examples/SetsNTags.cpp (from rev 3645, MOAB/trunk/examples/SetsNTags/SetsNTags.cpp)
===================================================================
--- MOAB/trunk/examples/SetsNTags.cpp	                        (rev 0)
+++ MOAB/trunk/examples/SetsNTags.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,48 @@
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include <iostream>
+
+int main(int argc, char **argv) {
+  if (1 == argc) {
+    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+    return 0;
+  }
+
+    // get the material set tag handle
+  MBTag mtag;
+  MBErrorCode rval;
+  const char *tag_nms[] = {"MATERIAL_SET", "DIRICHLET_SET", 
+                           "NEUMANN_SET"};
+  MBRange sets, set_ents;
+
+    // instantiate & load a file
+  MBInterface *mb = new MBCore();
+  rval = mb->load_file(argv[1]);
+
+    // loop over set types
+  for (int i = 0; i < 3; i++) {
+    rval = mb->tag_get_handle(tag_nms[i], mtag);
+
+      // get all the sets of that type in the mesh
+    sets.clear();
+    rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &mtag,
+                                            NULL, 1, sets);
+
+      // iterate over each set, getting entities
+    MBRange::iterator set_it;
+    for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
+      MBEntityHandle this_set = *set_it;
+
+        // get the id for this set
+      int set_id;
+      rval = mb->tag_get_data(mtag, &this_set, 1, &set_id);
+
+        // get the entities in the set, recursively
+      rval = mb->get_entities_by_handle(this_set, set_ents, true);
+
+      std::cout << tag_nms[i] << " " << set_id << " has " 
+                << set_ents.size() << " entities." << std::endl;
+      set_ents.clear();
+    }
+  }
+}


Property changes on: MOAB/trunk/examples/SetsNTags.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Deleted: MOAB/trunk/examples/SkinMesh/Makefile
===================================================================
--- MOAB/trunk/examples/SkinMesh/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SkinMesh/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,8 +0,0 @@
-include ${MOAB_LIB_DIR}/moab.make
-
-SkinMesh : SkinMesh.o
-	${CXX} $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} ${MOAB_INCLUDES} -c $<
-

Deleted: MOAB/trunk/examples/SkinMesh/SkinMesh.cpp
===================================================================
--- MOAB/trunk/examples/SkinMesh/SkinMesh.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SkinMesh/SkinMesh.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,169 +0,0 @@
-#include <iostream>
-#include <stdlib.h>
-#include "MBCore.hpp"
-#include "MBRange.hpp"
-#include "MBTagConventions.hpp"
-
-// Hold edges in an array of vertex handles.
-struct edge {
-  MBEntityHandle v0;                                                                                                                      
-  MBEntityHandle v1;
-};
-                                                                                                                                         
-// edge structure comparision function for qsort
-// If the first vertex handle is the same, compare the second.
-int compare_edge(const void *a, const void *b) {
-  struct edge *ia = (struct edge *)a;
-  struct edge *ib = (struct edge *)b;
-  if(ia->v0 == ib->v0) {
-    return (int)(100.f*ia->v1 - 100.f*ib->v1);
-  } else {
-    return (int)(100.f*ia->v0 - 100.f*ib->v0);
-  }
-}
-
-// This skinner is fast partly because it assumes that no edges exist in the MOAB 
-// instance. Checking to see if an edge exists before creating a new one is slow. 
-MBErrorCode skin_tris( MBInterface *mb, MBRange tris, MBRange &skin_edges ) {    
-  
-  // Empty the output range and make sure that the input range is only tris
-  skin_edges.clear(); 
-  if(tris.empty()) return MB_ENTITY_NOT_FOUND;
-  if(!tris.all_of_type(MBTRI)) return MB_FAILURE;
-
-  // Remove edges from the instance.
-  int n_edges;
-  MBErrorCode rval = mb->get_number_entities_by_type( 0, MBEDGE, n_edges );
-  if(MB_SUCCESS != rval) return rval;
-  if(0 != n_edges) {
-    std::cerr << "skin_tris: failed because " << n_edges 
-              << " edges exist in the MOAB instance" << std::endl;
-    return MB_FAILURE;
-  }      
-
-  // Get connectivity. Do not create MBEdges.
-  edge *edges = new edge[3*tris.size()];
-  int n_verts;
-  int ii = 0;
-  for(MBRange::iterator i=tris.begin(); i!=tris.end(); i++) {
-    const MBEntityHandle *conn;
-    rval = mb->get_connectivity( *i, conn, n_verts );
-    if(MB_SUCCESS != rval) return rval;
-    if(3 != n_verts) return MB_FAILURE;
-    // points should not be degenerate
-    if(conn[0]==conn[1] || conn[1]==conn[2] || conn[2]==conn[0]) {
-      std::cerr << "skin_tris: degenerate triangle" << std::endl;
-      return MB_FAILURE;
-    }
-
-    // make edges
-    edges[3*ii+0].v0 = conn[0];
-    edges[3*ii+0].v1 = conn[1];
-    edges[3*ii+1].v0 = conn[1];
-    edges[3*ii+1].v1 = conn[2];
-    edges[3*ii+2].v0 = conn[2];
-    edges[3*ii+2].v1 = conn[0];
-    ii++;
-  }
-
-  // Ensure that the first vertex handle is the lowest
-  for(unsigned int i=0; i<3*tris.size(); ++i) {
-    if(edges[i].v0 > edges[i].v1) {
-      MBEntityHandle temp = edges[i].v0;
-      edges[i].v0 = edges[i].v1;
-      edges[i].v1 = temp;
-    }
-  }
-
-  // Sort by first handle, then second handle.
-  qsort(edges, 3*tris.size(), sizeof(struct edge), compare_edge);    
-
-  // Go through array, saving edges that are not paired.
-  for(unsigned int i=0; i<3*tris.size(); i++) {
-    // If the last edge has not been paired, create it. This avoids overrunning
-    // the edges array with i+1.
-    if(3*tris.size()-1 == i) {
-      const MBEntityHandle conn[2] = {edges[i].v0, edges[i].v1};
-      MBEntityHandle edge;
-      rval = mb->create_element( MBEDGE, conn, 2, edge );
-      if(MB_SUCCESS != rval) return rval;
-      skin_edges.insert(edge);
-    
-    // If a match exists, skip ahead
-    } else if(edges[i].v0==edges[i+1].v0 && edges[i].v1==edges[i+1].v1) {
-      i++;
-      // test to make sure surface is manifold
-      while( edges[i].v0==edges[i+1].v0 && edges[i].v1==edges[i+1].v1 ) {
-        std::cout << "find_skin WARNING: non-manifold edge" << std::endl;
-        mb->list_entity( edges[i].v0 );
-        mb->list_entity( edges[i].v1 );
-        ++i;
-      }
-    // otherwise a skin edge has been found
-    } else {
-      const MBEntityHandle conn[2] = {edges[i].v0, edges[i].v1};
-      MBEntityHandle edge;
-      rval = mb->create_element( MBEDGE, conn, 2, edge );
-      if(MB_SUCCESS != rval) return rval;
-      skin_edges.insert( edge );
-    } 
-  }
-  delete[] edges;
-  return MB_SUCCESS;
-}
-
-
-// Skin triangles to recover edges.
-// Triangles are contained in surface sets.
-int main(int argc, char **argv) {
-  if (1 == argc) {
-  std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
-    return 0;
-  }     
-
-  // get MOAB instance and read the file                                                                                                  
-  MBCore *mb = new MBCore();
-  MBErrorCode rval = mb->load_file(argv[1]);
-  if(MB_SUCCESS != rval) return 0;
-
-  // this optimized skinner requires removing all MBEdges from the MOAB instance
-  MBRange edges;
-  rval = mb->get_entities_by_type( 0, MBEDGE, edges );
-  if(MB_SUCCESS != rval) return 0;
-  if( !edges.empty() ) std::cout << "Warning: deleting all MBEdges" << std::endl;
-  rval = mb->delete_entities( edges );
-  if(MB_SUCCESS != rval) return 0;
-
-  // get surface sets
-  MBTag geom_tag;
-  rval = mb->tag_create( GEOM_DIMENSION_TAG_NAME, sizeof(int), MB_TAG_DENSE,
-                         MB_TYPE_INTEGER, geom_tag, 0, true );
-  if(MB_SUCCESS != rval) return 0;
-  MBRange surf_sets;
-  int two = 2;
-  void *dim[] = {&two};                                                                                   
-  rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag,                                                                
-                                           dim, 1, surf_sets );
-  if(MB_SUCCESS != rval) return 0;
-
-  // skin each surface
-  for(MBRange::iterator i=surf_sets.begin(); i!=surf_sets.end(); ++i) {
-
-    // get triangles in the surface set
-    MBRange tris;
-    rval = mb->get_entities_by_type( *i, MBTRI, tris );
-    if(MB_SUCCESS != rval) return 0;
-
-    // call the skinning function
-    MBRange skin_edges;
-    rval = skin_tris( mb, tris, skin_edges );
-    if(MB_SUCCESS != rval) return 0;
-
-    // do something with the result
-    std::cout << "surface has " << skin_edges.size() << " skin edges" << std::endl;
-
-    // remove the edges for the optimized skinner
-    rval = mb->delete_entities( skin_edges );
-    if(MB_SUCCESS != rval) return 0;    
-  }
-}  

Copied: MOAB/trunk/examples/SkinMesh.cpp (from rev 3645, MOAB/trunk/examples/SkinMesh/SkinMesh.cpp)
===================================================================
--- MOAB/trunk/examples/SkinMesh.cpp	                        (rev 0)
+++ MOAB/trunk/examples/SkinMesh.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,169 @@
+#include <iostream>
+#include <stdlib.h>
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include "MBTagConventions.hpp"
+
+// Hold edges in an array of vertex handles.
+struct edge {
+  MBEntityHandle v0;                                                                                                                      
+  MBEntityHandle v1;
+};
+                                                                                                                                         
+// edge structure comparision function for qsort
+// If the first vertex handle is the same, compare the second.
+int compare_edge(const void *a, const void *b) {
+  struct edge *ia = (struct edge *)a;
+  struct edge *ib = (struct edge *)b;
+  if(ia->v0 == ib->v0) {
+    return (int)(100.f*ia->v1 - 100.f*ib->v1);
+  } else {
+    return (int)(100.f*ia->v0 - 100.f*ib->v0);
+  }
+}
+
+// This skinner is fast partly because it assumes that no edges exist in the MOAB 
+// instance. Checking to see if an edge exists before creating a new one is slow. 
+MBErrorCode skin_tris( MBInterface *mb, MBRange tris, MBRange &skin_edges ) {    
+  
+  // Empty the output range and make sure that the input range is only tris
+  skin_edges.clear(); 
+  if(tris.empty()) return MB_ENTITY_NOT_FOUND;
+  if(!tris.all_of_type(MBTRI)) return MB_FAILURE;
+
+  // Remove edges from the instance.
+  int n_edges;
+  MBErrorCode rval = mb->get_number_entities_by_type( 0, MBEDGE, n_edges );
+  if(MB_SUCCESS != rval) return rval;
+  if(0 != n_edges) {
+    std::cerr << "skin_tris: failed because " << n_edges 
+              << " edges exist in the MOAB instance" << std::endl;
+    return MB_FAILURE;
+  }      
+
+  // Get connectivity. Do not create MBEdges.
+  edge *edges = new edge[3*tris.size()];
+  int n_verts;
+  int ii = 0;
+  for(MBRange::iterator i=tris.begin(); i!=tris.end(); i++) {
+    const MBEntityHandle *conn;
+    rval = mb->get_connectivity( *i, conn, n_verts );
+    if(MB_SUCCESS != rval) return rval;
+    if(3 != n_verts) return MB_FAILURE;
+    // points should not be degenerate
+    if(conn[0]==conn[1] || conn[1]==conn[2] || conn[2]==conn[0]) {
+      std::cerr << "skin_tris: degenerate triangle" << std::endl;
+      return MB_FAILURE;
+    }
+
+    // make edges
+    edges[3*ii+0].v0 = conn[0];
+    edges[3*ii+0].v1 = conn[1];
+    edges[3*ii+1].v0 = conn[1];
+    edges[3*ii+1].v1 = conn[2];
+    edges[3*ii+2].v0 = conn[2];
+    edges[3*ii+2].v1 = conn[0];
+    ii++;
+  }
+
+  // Ensure that the first vertex handle is the lowest
+  for(unsigned int i=0; i<3*tris.size(); ++i) {
+    if(edges[i].v0 > edges[i].v1) {
+      MBEntityHandle temp = edges[i].v0;
+      edges[i].v0 = edges[i].v1;
+      edges[i].v1 = temp;
+    }
+  }
+
+  // Sort by first handle, then second handle.
+  qsort(edges, 3*tris.size(), sizeof(struct edge), compare_edge);    
+
+  // Go through array, saving edges that are not paired.
+  for(unsigned int i=0; i<3*tris.size(); i++) {
+    // If the last edge has not been paired, create it. This avoids overrunning
+    // the edges array with i+1.
+    if(3*tris.size()-1 == i) {
+      const MBEntityHandle conn[2] = {edges[i].v0, edges[i].v1};
+      MBEntityHandle edge;
+      rval = mb->create_element( MBEDGE, conn, 2, edge );
+      if(MB_SUCCESS != rval) return rval;
+      skin_edges.insert(edge);
+    
+    // If a match exists, skip ahead
+    } else if(edges[i].v0==edges[i+1].v0 && edges[i].v1==edges[i+1].v1) {
+      i++;
+      // test to make sure surface is manifold
+      while( edges[i].v0==edges[i+1].v0 && edges[i].v1==edges[i+1].v1 ) {
+        std::cout << "find_skin WARNING: non-manifold edge" << std::endl;
+        mb->list_entity( edges[i].v0 );
+        mb->list_entity( edges[i].v1 );
+        ++i;
+      }
+    // otherwise a skin edge has been found
+    } else {
+      const MBEntityHandle conn[2] = {edges[i].v0, edges[i].v1};
+      MBEntityHandle edge;
+      rval = mb->create_element( MBEDGE, conn, 2, edge );
+      if(MB_SUCCESS != rval) return rval;
+      skin_edges.insert( edge );
+    } 
+  }
+  delete[] edges;
+  return MB_SUCCESS;
+}
+
+
+// Skin triangles to recover edges.
+// Triangles are contained in surface sets.
+int main(int argc, char **argv) {
+  if (1 == argc) {
+  std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+    return 0;
+  }     
+
+  // get MOAB instance and read the file                                                                                                  
+  MBCore *mb = new MBCore();
+  MBErrorCode rval = mb->load_file(argv[1]);
+  if(MB_SUCCESS != rval) return 0;
+
+  // this optimized skinner requires removing all MBEdges from the MOAB instance
+  MBRange edges;
+  rval = mb->get_entities_by_type( 0, MBEDGE, edges );
+  if(MB_SUCCESS != rval) return 0;
+  if( !edges.empty() ) std::cout << "Warning: deleting all MBEdges" << std::endl;
+  rval = mb->delete_entities( edges );
+  if(MB_SUCCESS != rval) return 0;
+
+  // get surface sets
+  MBTag geom_tag;
+  rval = mb->tag_create( GEOM_DIMENSION_TAG_NAME, sizeof(int), MB_TAG_DENSE,
+                         MB_TYPE_INTEGER, geom_tag, 0, true );
+  if(MB_SUCCESS != rval) return 0;
+  MBRange surf_sets;
+  int two = 2;
+  void *dim[] = {&two};                                                                                   
+  rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag,                                                                
+                                           dim, 1, surf_sets );
+  if(MB_SUCCESS != rval) return 0;
+
+  // skin each surface
+  for(MBRange::iterator i=surf_sets.begin(); i!=surf_sets.end(); ++i) {
+
+    // get triangles in the surface set
+    MBRange tris;
+    rval = mb->get_entities_by_type( *i, MBTRI, tris );
+    if(MB_SUCCESS != rval) return 0;
+
+    // call the skinning function
+    MBRange skin_edges;
+    rval = skin_tris( mb, tris, skin_edges );
+    if(MB_SUCCESS != rval) return 0;
+
+    // do something with the result
+    std::cout << "surface has " << skin_edges.size() << " skin edges" << std::endl;
+
+    // remove the edges for the optimized skinner
+    rval = mb->delete_entities( skin_edges );
+    if(MB_SUCCESS != rval) return 0;    
+  }
+}  


Property changes on: MOAB/trunk/examples/SkinMesh.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Deleted: MOAB/trunk/examples/SurfArea/Makefile
===================================================================
--- MOAB/trunk/examples/SurfArea/Makefile	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SurfArea/Makefile	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,8 +0,0 @@
-include ${MOAB_LIB_DIR}/moab.make
-
-SurfArea : SurfArea.o
-	${CXX} $< ${MOAB_LIBS_LINK} -o $@
-
-.cpp.o : 
-	${CXX} ${MOAB_INCLUDES} -c $<
-

Deleted: MOAB/trunk/examples/SurfArea/SurfArea.cpp
===================================================================
--- MOAB/trunk/examples/SurfArea/SurfArea.cpp	2010-03-17 21:40:52 UTC (rev 3655)
+++ MOAB/trunk/examples/SurfArea/SurfArea.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -1,117 +0,0 @@
-/* 
-   This example takes a .cub mesh file as input and prints out the total area of 
-   meshes in each surface of the model. It works for tri and quad elements.
-   It makes use of CUBIT's reserved tag - GEOM_DIMENSION and GLOBAL_ID tag.
-   Both GLOBAL_ID & GEOM_DIMENSION tag are associated with all the geometric 
-   entities in a .cub file. Note: The program would give incorrect result for a 
-   non-convex element, since it breaks polygons into triangles for computing the area
-*/
-
-#include "moab/MBCore.hpp"
-#include "moab/MBRange.hpp"
-#include "MBCartVect.hpp"
-#include <iostream>
-
-
-double compute_area(std::vector<MBEntityHandle>&);
-
-// instantiate
-MBInterface *mb;
-
-int main(int argc, char **argv) {
-  if (1 == argc) {
-    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
-    return 0;
-  }
-  
-  // get tag 
-  MBTag gtag, idtag;
-  MBErrorCode rval;
-  const char *tag_geom = "GEOM_DIMENSION";
-  const char *tag_gid = "GLOBAL_ID";
-  MBRange sets;
-  std::vector<MBEntityHandle> ents;
-  
-  // load a file
-  mb = new MBCore();
-  rval = mb->load_file(argv[1]);
-
-  // get the tag handle for the tags
-  rval = mb->tag_get_handle(tag_geom, gtag);
-  rval = mb->tag_get_handle(tag_gid, idtag);
-
-  // get all the sets with GEOM_DIMESION tag
-  rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &gtag,
-					  NULL, 1, sets);
- 
-  // iterate over each set, getting entities
-  MBRange::iterator set_it;
-    
-  // loop thru all the geometric entity sets
-  for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
-
-    MBEntityHandle this_set = *set_it;
-    
-    // get the id for this set
-    int set_id;
-    rval = mb->tag_get_data(gtag, &this_set, 1, &set_id);
-
-    // check if it is a surface entities (GEOM_DIMENSION 2) then compute area
-    if (set_id ==2){
-      
-      // area of a surface
-      double total_area=0.0;
-
-      //get the global id of this surface
-      int gid = 0;
-      rval = mb->tag_get_data(idtag, &this_set, 1, &gid);
-
-      // get all entities with dimension 2 in ents
-      rval = mb->get_entities_by_dimension(this_set, 2, ents);
- 
-      // compute the area
-      total_area = compute_area(ents);
-
-      ents.clear();
-      
-      std::cout << "Total area of meshes in surface " << gid << " =  " << total_area << std::endl;
-    }
-  }
-}
-
-// This routine takes all the element entities in a face as input and computes the surface area
-// iterating over each element
-double compute_area(std::vector<MBEntityHandle> & entities){
- 
-  int rval= 0;
-  double area = 0.0;
-  double coord[9];
- 
-  // loop thro' all the elements
-  for (int i=0;i<entities.size();i++){
-    std::vector<MBEntityHandle> conn;
-    MBEntityHandle handle = entities[i];
-
-    // get the connectivity of this element
-    rval = mb->get_connectivity(&handle, 1, conn);
-
-    // break polygon into triangles and sum the area - Limitation: Convex polygon
-    for (int j = 2; j<=conn.size(); ++j){
-
-      MBEntityHandle vertices[3]={conn[0], conn[j-1],  conn[j-2]};
-      MBCartVect coords[3];
-      
-      // get 3 coordinates forming the triangle
-      rval = mb->get_coords(vertices, 3, coords[0].array());
-      
-      MBCartVect edge0 = coords[1] - coords [0];
-      MBCartVect edge1 = coords [2] - coords[0];
-      
-      // using MBCarVect overloaded operators and computing triangle area
-      area+=(edge0*edge1).length()/2.0;
-    }
-  }
-  // clear the entities, else old entities remain
-  entities.clear();
-  return area;
-}

Copied: MOAB/trunk/examples/SurfArea.cpp (from rev 3645, MOAB/trunk/examples/SurfArea/SurfArea.cpp)
===================================================================
--- MOAB/trunk/examples/SurfArea.cpp	                        (rev 0)
+++ MOAB/trunk/examples/SurfArea.cpp	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,117 @@
+/* 
+   This example takes a .cub mesh file as input and prints out the total area of 
+   meshes in each surface of the model. It works for tri and quad elements.
+   It makes use of CUBIT's reserved tag - GEOM_DIMENSION and GLOBAL_ID tag.
+   Both GLOBAL_ID & GEOM_DIMENSION tag are associated with all the geometric 
+   entities in a .cub file. Note: The program would give incorrect result for a 
+   non-convex element, since it breaks polygons into triangles for computing the area
+*/
+
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include "MBCartVect.hpp"
+#include <iostream>
+
+
+double compute_area(std::vector<MBEntityHandle>&);
+
+// instantiate
+MBInterface *mb;
+
+int main(int argc, char **argv) {
+  if (1 == argc) {
+    std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+    return 0;
+  }
+  
+  // get tag 
+  MBTag gtag, idtag;
+  MBErrorCode rval;
+  const char *tag_geom = "GEOM_DIMENSION";
+  const char *tag_gid = "GLOBAL_ID";
+  MBRange sets;
+  std::vector<MBEntityHandle> ents;
+  
+  // load a file
+  mb = new MBCore();
+  rval = mb->load_file(argv[1]);
+
+  // get the tag handle for the tags
+  rval = mb->tag_get_handle(tag_geom, gtag);
+  rval = mb->tag_get_handle(tag_gid, idtag);
+
+  // get all the sets with GEOM_DIMESION tag
+  rval = mb->get_entities_by_type_and_tag(0, MBENTITYSET, &gtag,
+					  NULL, 1, sets);
+ 
+  // iterate over each set, getting entities
+  MBRange::iterator set_it;
+    
+  // loop thru all the geometric entity sets
+  for (set_it = sets.begin(); set_it != sets.end(); set_it++)  {
+
+    MBEntityHandle this_set = *set_it;
+    
+    // get the id for this set
+    int set_id;
+    rval = mb->tag_get_data(gtag, &this_set, 1, &set_id);
+
+    // check if it is a surface entities (GEOM_DIMENSION 2) then compute area
+    if (set_id ==2){
+      
+      // area of a surface
+      double total_area=0.0;
+
+      //get the global id of this surface
+      int gid = 0;
+      rval = mb->tag_get_data(idtag, &this_set, 1, &gid);
+
+      // get all entities with dimension 2 in ents
+      rval = mb->get_entities_by_dimension(this_set, 2, ents);
+ 
+      // compute the area
+      total_area = compute_area(ents);
+
+      ents.clear();
+      
+      std::cout << "Total area of meshes in surface " << gid << " =  " << total_area << std::endl;
+    }
+  }
+}
+
+// This routine takes all the element entities in a face as input and computes the surface area
+// iterating over each element
+double compute_area(std::vector<MBEntityHandle> & entities){
+ 
+  int rval= 0;
+  double area = 0.0;
+  double coord[9];
+ 
+  // loop thro' all the elements
+  for (int i=0;i<entities.size();i++){
+    std::vector<MBEntityHandle> conn;
+    MBEntityHandle handle = entities[i];
+
+    // get the connectivity of this element
+    rval = mb->get_connectivity(&handle, 1, conn);
+
+    // break polygon into triangles and sum the area - Limitation: Convex polygon
+    for (int j = 2; j<=conn.size(); ++j){
+
+      MBEntityHandle vertices[3]={conn[0], conn[j-1],  conn[j-2]};
+      MBCartVect coords[3];
+      
+      // get 3 coordinates forming the triangle
+      rval = mb->get_coords(vertices, 3, coords[0].array());
+      
+      MBCartVect edge0 = coords[1] - coords [0];
+      MBCartVect edge1 = coords [2] - coords[0];
+      
+      // using MBCarVect overloaded operators and computing triangle area
+      area+=(edge0*edge1).length()/2.0;
+    }
+  }
+  // clear the entities, else old entities remain
+  entities.clear();
+  return area;
+}


Property changes on: MOAB/trunk/examples/SurfArea.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Added: MOAB/trunk/examples/examples.make.in
===================================================================
--- MOAB/trunk/examples/examples.make.in	                        (rev 0)
+++ MOAB/trunk/examples/examples.make.in	2010-03-17 21:50:02 UTC (rev 3656)
@@ -0,0 +1,29 @@
+exec_prefix = @exec_prefix@
+prefix = @prefix@
+libdir = @libdir@
+include $(libdir)/moab.make
+
+CPPFLAGS = ${MOAB_INCLUDES}
+CXXFLAGS = -g
+
+default: all
+
+all: FileRead GeomSetHierarchy GetEntities SetsNTags SkinMesh SurfArea
+
+FileRead: FileRead.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
+
+GeomSetHierarchy: GeomSetHierarchy.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
+
+GetEntities: GetEntities.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
+
+SetsNTags: SetsNTags.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
+
+SkinMesh: SkinMesh.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
+
+SurfArea: SurfArea.o
+	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)



More information about the moab-dev mailing list