<p dir="ltr">Iulian/Rajeev, we need to start reviewing the error handling branch and merge into master for the next release. </p>
<p dir="ltr">Danqing, please update the branch with any other pending changes. I would like to bring all the other codes up to date also and test them on buildbot for various configurations before the release. </p>
<p dir="ltr">Vijay</p>
<div class="gmail_quote">On Mar 27, 2014 1:50 PM,  <<a href="mailto:commits-noreply@bitbucket.org">commits-noreply@bitbucket.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
1 new commit in MOAB:<br>
<br>
<a href="https://bitbucket.org/fathomteam/moab/commits/5d3eb97e31f9/" target="_blank">https://bitbucket.org/fathomteam/moab/commits/5d3eb97e31f9/</a><br>
Changeset:   5d3eb97e31f9<br>
Branch:      error_handling_enhancement<br>
User:        danwu<br>
Date:        2014-03-27 19:50:43<br>
Summary:     Merged master into error_handling_enhancement<br>
Affected #:  14 files<br>
<br>
diff --git a/.gitignore b/.gitignore<br>
index 4b78fb6..8acb6bb 100644<br>
--- a/.gitignore<br>
+++ b/.gitignore<br>
@@ -130,6 +130,9 @@ test/bsp_tree_test<br>
 test/CMakeLists.txt<br>
 test/coords_connect_iterate<br>
 test/cropvol_test<br>
+test/dagmc/dagmc_pointinvol_test<br>
+test/dagmc/dagmc_rayfire_test<br>
+test/dagmc/dagmc_simple_test<br>
 test/dual/dual_test<br>
 test/elem_eval_test<br>
 test/file_options_test<br>
@@ -156,8 +159,10 @@ test/io/gmsh_test<br>
 test/io/ideas_test<br>
 test/io/nastran_test<br>
 test/io/read_cgm_basic_test<br>
+test/io/read_cgm_connectivity_test<br>
+test/io/read_cgm_group_test<br>
 test/io/read_cgm_load_test<br>
-test/io/read_cgm_test<br>
+test/io/read_cgm_senses_test<br>
 test/io/read_mpas_nc<br>
 test/io/read_nc<br>
 test/io/read_ucd_nc<br>
<br>
diff --git a/MeshFiles/unittest/Makefile.am b/MeshFiles/unittest/Makefile.am<br>
index ab3e23e..bc4f522 100644<br>
--- a/MeshFiles/unittest/Makefile.am<br>
+++ b/MeshFiles/unittest/Makefile.am<br>
@@ -1,4 +1,4 @@<br>
-SUBDIRS = io<br>
+SUBDIRS = io dagmc iGeom<br>
<br>
 EXTRA_DIST  = 125hex.g \<br>
               16_unmerged_hex.h5m \<br>
<br>
diff --git a/MeshFiles/unittest/dagmc/Makefile.am b/MeshFiles/unittest/dagmc/Makefile.am<br>
new file mode 100644<br>
index 0000000..0643ad9<br>
--- /dev/null<br>
+++ b/MeshFiles/unittest/dagmc/Makefile.am<br>
@@ -0,0 +1 @@<br>
+EXTRA_DIST =  test_geom.h5m<br>
<br>
diff --git a/MeshFiles/unittest/dagmc/test_geom.h5m b/MeshFiles/unittest/dagmc/test_geom.h5m<br>
new file mode 100644<br>
index 0000000..18e1d36<br>
Binary files /dev/null and b/MeshFiles/unittest/dagmc/test_geom.h5m differ<br>
<br>
diff --git a/MeshFiles/unittest/iGeom/Makefile.am b/MeshFiles/unittest/iGeom/Makefile.am<br>
new file mode 100644<br>
index 0000000..203b676<br>
--- /dev/null<br>
+++ b/MeshFiles/unittest/iGeom/Makefile.am<br>
@@ -0,0 +1 @@<br>
+EXTRA_DIST = shell.h5m<br>
<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 82bf72b..83d8ea5 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -1223,6 +1223,7 @@ AC_CONFIG_FILES([Makefile<br>
                  src/parallel/Makefile<br>
                  src/oldinc/Makefile<br>
                  test/Makefile<br>
+                test/dagmc/Makefile<br>
                  test/h5file/Makefile<br>
                  test/dual/Makefile<br>
                  test/obb/Makefile<br>
@@ -1254,6 +1255,8 @@ AC_CONFIG_FILES([Makefile<br>
                  MeshFiles/Makefile<br>
                  MeshFiles/unittest/Makefile<br>
                  MeshFiles/unittest/io/Makefile<br>
+                 MeshFiles/unittest/iGeom/Makefile<br>
+                 MeshFiles/unittest/dagmc/Makefile<br>
                  ])<br>
 AC_CONFIG_COMMANDS([src/MOAB_FCDefs.h],<br>
   [sed -e "s/FC_FUNC/MOAB_FC_FUNC/" src/FCDefs.h >src/MOAB_FCDefs.h])<br>
<br>
diff --git a/test/Makefile.am b/test/Makefile.am<br>
index 4797a49..cf79fd3 100644<br>
--- a/test/Makefile.am<br>
+++ b/test/Makefile.am<br>
@@ -1,4 +1,4 @@<br>
-SUBDIRS = . io dual obb perf<br>
+SUBDIRS = . io dual obb perf dagmc<br>
 if HDF5_FILE<br>
   SUBDIRS += h5file<br>
 endif<br>
<br>
diff --git a/test/dagmc/Makefile.am b/test/dagmc/Makefile.am<br>
new file mode 100644<br>
index 0000000..d092176<br>
--- /dev/null<br>
+++ b/test/dagmc/Makefile.am<br>
@@ -0,0 +1,28 @@<br>
+LDADD = $(top_builddir)/src/libMOAB.la $(top_builddir)/tools/dagmc/DagMC.lo<br>
+<br>
+MESHDIR = $(top_srcdir)/MeshFiles/unittest<br>
+<br>
+AM_CPPFLAGS += -DSRCDIR=$(srcdir) \<br>
+               -DMESHDIR=$(MESHDIR) \<br>
+               -I$(builddir) -I.. -I$(srcdir)/.. \<br>
+               -I$(top_builddir)/src \<br>
+               -I$(top_srcdir)/src \<br>
+               -I$(top_srcdir)/src/io \<br>
+               -I$(top_srcdir)/src/parallel \<br>
+               -I$(top_srcdir)/tools/dagmc<br>
+TESTS =<br>
+if HDF5_FILE<br>
+ TESTS += dagmc_simple_test \<br>
+        dagmc_rayfire_test \<br>
+        dagmc_pointinvol_test<br>
+endif<br>
+check_PROGRAMS = $(TESTS)<br>
+<br>
+dagmc_simple_test_SOURCES = $(srcdir)/../TestUtil.hpp dagmc_simple_test.cpp<br>
+dagmc_simple_test_CXXFLAGS = $(CGM_CPPFLAGS) $(CXXFLAGS) $(CGM_LIBS)<br>
+dagmc_rayfire_test_SOURCES = $(srcdir)/../TestUtil.hpp dagmc_rayfire_test.cpp<br>
+dagmc_rayfire_test_CXXFLAGS = $(CGM_CPPFLAGS) $(CXXFLAGS) $(CGM_LIBS)<br>
+dagmc_pointinvol_test_SOURCES = $(srcdir)/../TestUtil.hpp dagmc_pointinvol_test.cpp<br>
+dagmc_pointinvol_test_CXXFLAGS = $(CGM_CPPFLAGS) $(CXXFLAGS) $(CGM_LIBS)<br>
+<br>
+<br>
<br>
diff --git a/test/dagmc/dagmc_pointinvol_test.cpp b/test/dagmc/dagmc_pointinvol_test.cpp<br>
new file mode 100644<br>
index 0000000..47ee7c1<br>
--- /dev/null<br>
+++ b/test/dagmc/dagmc_pointinvol_test.cpp<br>
@@ -0,0 +1,283 @@<br>
+#include <iostream><br>
+#include "moab/Interface.hpp"<br>
+#ifndef IS_BUILDING_MB<br>
+#define IS_BUILDING_MB<br>
+#endif<br>
+#include "TestUtil.hpp"<br>
+#include "Internals.hpp"<br>
+#include "moab/Core.hpp"<br>
+<br>
+#include "DagMC.hpp"<br>
+<br>
+using namespace moab;<br>
+<br>
+using moab::DagMC;<br>
+<br>
+#define DAG DagMC::instance()<br>
+<br>
+#define CHKERR(A) do { if (MB_SUCCESS != (A)) { \<br>
+  std::cerr << "Failure (error code " << (A) << ") at " __FILE__ ":" \<br>
+            << __LINE__ << std::endl; \<br>
+  return A; } } while(false)<br>
+<br>
+#ifdef MESHDIR<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#else<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#endif<br>
+<br>
+<br>
+void dagmc_setup_test()<br>
+{<br>
+  ErrorCode rval = DAG->load_file(input_file); // open the Dag file<br>
+  CHECK_ERR(rval);<br>
+  rval = DAG->init_OBBTree();<br>
+  CHECK_ERR(rval);<br>
+<br>
+  int num_vols = DAG->num_entities(3);<br>
+  EntityHandle vol;<br>
+  for ( int i = 0 ; i < num_vols ; i++ )<br>
+    {<br>
+      vol = DAG->entity_by_index(3,i);<br>
+    }<br>
+  //EntityHandle volume = 12682136550675316765;<br>
+  //CHECK_EQUAL(volume,vol);<br>
+}<br>
+<br>
+void dagmc_point_in()<br>
+{<br>
+  int result = 0;<br>
+  int expected_result=1;<br>
+  double xyz[3]={0.0,0.0,0.0};<br>
+  int vol_idx=1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  ErrorCode rval = DAG->point_in_volume(vol_h,xyz,result);<br>
+  CHECK_ERR(rval);<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+int dagmc_point_in_vol_dir(double origin[3],double dir[3],int vol_idx)<br>
+{<br>
+  int result = 0;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double xyz[3];<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+<br>
+  // normalise the vector<br>
+  double dir_norm = (dir[0]*dir[0])+(dir[1]*dir[1])+(dir[2]*dir[2]);<br>
+<br>
+  dir[0]=dir[0]/sqrt(dir_norm);<br>
+  dir[1]=dir[1]/sqrt(dir_norm);<br>
+  dir[2]=dir[2]/sqrt(dir_norm);<br>
+<br>
+  ErrorCode rval = DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);<br>
+<br>
+  xyz[0]=origin[0]+(next_surf_dist*dir[0]);<br>
+  xyz[1]=origin[1]+(next_surf_dist*dir[1]);<br>
+  xyz[2]=origin[2]+(next_surf_dist*dir[2]);<br>
+<br>
+  std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;<br>
+<br>
+  rval = DAG->point_in_volume(vol_h,xyz,result,dir);<br>
+  CHECK_ERR(rval);<br>
+  return result;<br>
+}<br>
+<br>
+void dagmc_point_in_vol_1()<br>
+{<br>
+  double dir[3]={ -1.0,0.0,0.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+  int vol_idx=1;<br>
+  int expected_result=1;<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+  CHECK_EQUAL(expected_result,result);<br>
+<br>
+}<br>
+<br>
+void dagmc_point_in_vol_2()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 1.0,0.0,0.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_in_vol_3()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 0.0,-1.0,0.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_in_vol_4()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 0.0,1.0,0.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+<br>
+}<br>
+<br>
+void dagmc_point_in_vol_5()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 0.0,0.0,-1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_in_vol_6()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 0.0,0.0,1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+<br>
+}<br>
+<br>
+void dagmc_point_on_corner_1()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 1.0,1.0,1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_2()<br>
+{<br>
+  int expected_result=1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ -1.0,1.0,1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_3()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 1.0,1.0,-1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_4()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ -1.0,1.0,-1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_5()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 1.0,-1.0,1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_6()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ -1.0,-1.0,1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_7()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ 1.0,-1.0,-1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+void dagmc_point_on_corner_8()<br>
+{<br>
+  int expected_result = 1;<br>
+  int vol_idx=1;<br>
+  double dir[3]={ -1.0,-1.0,-1.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+<br>
+  int result = dagmc_point_in_vol_dir(origin,dir,vol_idx);<br>
+<br>
+  CHECK_EQUAL(expected_result,result);<br>
+}<br>
+<br>
+int main(int /* argc */, char** /* argv */)<br>
+{<br>
+  int result = 0;<br>
+  result += RUN_TEST( dagmc_setup_test );     // setup problem<br>
+  result += RUN_TEST( dagmc_point_in );       // point in centre<br>
+  // rays fired along cardinal directions<br>
+  result += RUN_TEST( dagmc_point_in_vol_1);       // point in centre<br>
+  result += RUN_TEST( dagmc_point_in_vol_2);       // point in centre<br>
+  result += RUN_TEST( dagmc_point_in_vol_3);       // point in centre<br>
+  result += RUN_TEST( dagmc_point_in_vol_4);       // point in centre<br>
+  result += RUN_TEST( dagmc_point_in_vol_5);       // point in centre<br>
+  result += RUN_TEST( dagmc_point_in_vol_6);       // point in centre<br>
+  // rays fired at nodes<br>
+  result += RUN_TEST( dagmc_point_on_corner_1);<br>
+  result += RUN_TEST( dagmc_point_on_corner_2);<br>
+  result += RUN_TEST( dagmc_point_on_corner_3);<br>
+  result += RUN_TEST( dagmc_point_on_corner_4);<br>
+<br>
+                     //  result += RUN_TEST( dagmc_point_in({0.0,0.0,5.0});       // point in centre<br>
+                     //  result += RUN_TEST( dagmc_point_in({0.0,0.0,-5.0});       // point in centre<br>
+                     //  result += RUN_TEST( dagmc_point_in({0.0,5.0,0.0});       // point in centre<br>
+                     //  result += RUN_TEST( dagmc_point_in({0.0,-5.0,0.0});       // point in centre<br>
+                     //  result += RUN_TEST( dagmc_point_in({5.0,0.0,0.0});       // point in centre<br>
+                     //  result += RUN_TEST( dagmc_point_in({-5.0,0.0,0.0});       // point in centre<br>
+<br>
+  return result;<br>
+}<br>
<br>
diff --git a/test/dagmc/dagmc_rayfire_test.cpp b/test/dagmc/dagmc_rayfire_test.cpp<br>
new file mode 100644<br>
index 0000000..57aa625<br>
--- /dev/null<br>
+++ b/test/dagmc/dagmc_rayfire_test.cpp<br>
@@ -0,0 +1,180 @@<br>
+#include <iostream><br>
+#include "moab/Interface.hpp"<br>
+#ifndef IS_BUILDING_MB<br>
+#define IS_BUILDING_MB<br>
+#endif<br>
+#include "TestUtil.hpp"<br>
+#include "Internals.hpp"<br>
+#include "moab/Core.hpp"<br>
+<br>
+#include "DagMC.hpp"<br>
+<br>
+using namespace moab;<br>
+<br>
+using moab::DagMC;<br>
+<br>
+#define DAG DagMC::instance()<br>
+<br>
+#define CHKERR(A) do { if (MB_SUCCESS != (A)) { \<br>
+  std::cerr << "Failure (error code " << (A) << ") at " __FILE__ ":" \<br>
+            << __LINE__ << std::endl; \<br>
+  return A; } } while(false)<br>
+<br>
+#ifdef MESHDIR<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#else<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#endif<br>
+<br>
+double eps = 1.0e-6;<br>
+<br>
+void dagmc_setup_test()<br>
+{<br>
+  ErrorCode rval = DAG->load_file(input_file); // open the Dag file<br>
+  CHECK_ERR(rval);<br>
+  rval = DAG->init_OBBTree();<br>
+  CHECK_ERR(rval);<br>
+<br>
+  int num_vols = DAG->num_entities(3);<br>
+  EntityHandle vol_h;<br>
+  for ( int i = 0 ; i < num_vols ; i++ )<br>
+    {<br>
+      vol_h = DAG->entity_by_index(3,i);<br>
+    }<br>
+  // EntityHandle volume = 12682136550675316765;<br>
+  // CHECK_EQUAL(volume,vol);<br>
+}<br>
+<br>
+void dagmc_origin_face_rayfire()<br>
+{<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={-1.0,0.0,0.0};<br>
+  double origin[3]={0.0,0.0,0.0};<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);<br>
+  double expected_next_surf_dist=5.0;<br>
+  CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);<br>
+}<br>
+<br>
+void dagmc_outside_face_rayfire()<br>
+{<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={1.0,0.0,0.0}; // ray along x direction<br>
+  double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist);<br>
+  std::cout << next_surf_dist << std::endl;<br>
+  double expected_next_surf_dist=15.0;<br>
+  CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);<br>
+}<br>
+<br>
+void dagmc_outside_face_rayfire_orient_exit()<br>
+{<br>
+  DagMC::RayHistory history;<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={1.0,0.0,0.0}; // ray along x direction<br>
+  double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);<br>
+  std::cout << next_surf_dist << std::endl;<br>
+  double expected_next_surf_dist=15.0;<br>
+  CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);<br>
+}<br>
+<br>
+void dagmc_outside_face_rayfire_orient_entrance()<br>
+{<br>
+  DagMC::RayHistory history;<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={1.0,0.0,0.0}; // ray along x direction<br>
+  double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0.0,-1);<br>
+  std::cout << next_surf_dist << std::endl;<br>
+  double expected_next_surf_dist=5.0;<br>
+  CHECK_REAL_EQUAL(expected_next_surf_dist,next_surf_dist,eps);<br>
+}<br>
+<br>
+void dagmc_outside_face_rayfire_history_fail()<br>
+{<br>
+  DagMC::RayHistory history;<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={1.0,0.0,0.0}; // ray along x direction<br>
+  double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0<br>
+  double xyz[3];<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+<br>
+  history.reset();<br>
+<br>
+  // ray fired exactly along boundary shared by 2 facets on a single surface,<br>
+  // needs two ray_fires to cross, this is expected and ok<br>
+<br>
+  // first ray fire with history<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);<br>
+  // second ray fire with history<br>
+  DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);<br>
+  // this fire should hit graveyard, i.e. next_surf = 0<br>
+  DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);<br>
+<br>
+  // using history with this geom, there should be no next surface, i.e. 0<br>
+  EntityHandle ZERO = 0;<br>
+  CHECK_EQUAL(ZERO ,next_surf);<br>
+}<br>
+<br>
+void dagmc_outside_face_rayfire_history()<br>
+{<br>
+  DagMC::RayHistory history;<br>
+  int vol_idx = 1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  double dir[3]={1.0,0.0,0.0}; // ray along x direction<br>
+  double origin[3]={-10.0,0.0,0.0}; // origin at -10 0 0<br>
+  double xyz[3];<br>
+  double next_surf_dist;<br>
+  EntityHandle next_surf;<br>
+<br>
+  history.reset();<br>
+  // first ray fire with history<br>
+  DAG->ray_fire(vol_h,origin,dir,next_surf,next_surf_dist,&history,0,1);<br>
+  std::cout << next_surf << " " << history.size() << std::endl;<br>
+  // second ray fire with history<br>
+<br>
+  xyz[0]=origin[0]+(next_surf_dist*dir[0]);<br>
+  xyz[1]=origin[1]+(next_surf_dist*dir[1]);<br>
+  xyz[2]=origin[2]+(next_surf_dist*dir[2]);<br>
+<br>
+  // ray fired execacyl<br>
+<br>
+  DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);<br>
+<br>
+  DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist,&history,0,1);<br>
+<br>
+<br>
+  // using history with this geom, there should be no next surface, i.e. 0<br>
+  EntityHandle ZERO = 0;<br>
+  CHECK_EQUAL(ZERO ,next_surf);<br>
+}<br>
+<br>
+<br>
+int main(int /* argc */, char** /* argv */)<br>
+{<br>
+  int result = 0;<br>
+  result += RUN_TEST( dagmc_setup_test );     // setup problem<br>
+  // rays fired along cardinal directions<br>
+  result += RUN_TEST( dagmc_origin_face_rayfire );       // point in centre<br>
+  result += RUN_TEST( dagmc_outside_face_rayfire );<br>
+  result += RUN_TEST( dagmc_outside_face_rayfire_orient_exit ); // fire ray from point outside volume looking for exit intersections<br>
+  result += RUN_TEST( dagmc_outside_face_rayfire_orient_entrance ); // fire ray from point outside volume looking for entrance intersection<br>
+  result += RUN_TEST( dagmc_outside_face_rayfire_history_fail ); // fire ray from point outside geometry using ray history<br>
+  result += RUN_TEST( dagmc_outside_face_rayfire_history ); // fire ray from point outside geometry using ray history<br>
+<br>
+  return result;<br>
+}<br>
<br>
diff --git a/test/dagmc/dagmc_simple_test.cpp b/test/dagmc/dagmc_simple_test.cpp<br>
new file mode 100644<br>
index 0000000..bf253f6<br>
--- /dev/null<br>
+++ b/test/dagmc/dagmc_simple_test.cpp<br>
@@ -0,0 +1,137 @@<br>
+#include <iostream><br>
+#include "moab/Interface.hpp"<br>
+#ifndef IS_BUILDING_MB<br>
+#define IS_BUILDING_MB<br>
+#endif<br>
+#include "TestUtil.hpp"<br>
+#include "Internals.hpp"<br>
+#include "moab/Core.hpp"<br>
+<br>
+#include "DagMC.hpp"<br>
+<br>
+using namespace moab;<br>
+<br>
+using moab::DagMC;<br>
+<br>
+#define DAG DagMC::instance()<br>
+<br>
+#define CHKERR(A) do { if (MB_SUCCESS != (A)) { \<br>
+  std::cerr << "Failure (error code " << (A) << ") at " __FILE__ ":" \<br>
+            << __LINE__ << std::endl; \<br>
+  return A; } } while(false)<br>
+<br>
+#ifdef MESHDIR<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#else<br>
+static const char input_file[] = STRINGIFY(MESHDIR) "/dagmc/test_geom.h5m";<br>
+#endif<br>
+<br>
+<br>
+void dagmc_load_file()<br>
+{<br>
+  ErrorCode rval = DAG->load_file(input_file); // open the Dag file<br>
+  CHECK_ERR(rval);<br>
+}<br>
+<br>
+void dagmc_build_obb()<br>
+{<br>
+  ErrorCode rval = DAG->init_OBBTree();<br>
+  CHECK_ERR(rval);<br>
+}<br>
+<br>
+void dagmc_num_vols()<br>
+{<br>
+  int expect_num_vols=2;<br>
+  int num_vols = DAG->num_entities(3);<br>
+  CHECK_EQUAL(expect_num_vols,num_vols);<br>
+}<br>
+<br>
+void dagmc_entity_handle()<br>
+{<br>
+  int num_vols = DAG->num_entities(3);<br>
+  EntityHandle vol_h;<br>
+  for ( int i = 0 ; i < num_vols ; i++ )<br>
+    {<br>
+      vol_h = DAG->entity_by_index(3,i);<br>
+    }<br>
+  //EntityHandle expect_vol_h = 12682136550675316765;<br>
+  //CHECK_EQUAL(expect_vol_h,vol_h);<br>
+}<br>
+<br>
+void dagmc_point_in()<br>
+{<br>
+  int result = 0;<br>
+  int expect_result=1;<br>
+  int vol_idx=1;<br>
+  double xyz[3]={0.0,0.0,0.0};<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  ErrorCode rval = DAG->point_in_volume(vol_h,xyz,result);<br>
+  CHECK_EQUAL(expect_result,result);<br>
+}<br>
+<br>
+void dagmc_rayfire()<br>
+{<br>
+  const double eps = 1e-6; // epsilon for test, faceting tol?<br>
+<br>
+  int vol_idx=1;<br>
+  // note model is cube of side 10, centred at 0,0,0, so ray fire along<br>
+  // any unit direction should be exactly 5.0<br>
+  double xyz[3]={0.0,0.0,0.0};<br>
+  double dir[3]={0.0,0.0,1.0};<br>
+  EntityHandle next_surf;<br>
+  double next_surf_dist;<br>
+  double expect_next_surf_dist=5.0;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+<br>
+  ErrorCode rval = DAG->ray_fire(vol_h,xyz,dir,next_surf,next_surf_dist);<br>
+  CHECK_REAL_EQUAL(expect_next_surf_dist,next_surf_dist,eps);<br>
+}<br>
+<br>
+void dagmc_closest_to()<br>
+{<br>
+  const double eps = 1e-6; // epsilon for test, faceting tol?<br>
+<br>
+  int vol_idx=1;<br>
+  // note model is cube of side 10, centred at 0,0,0, so ray fire along<br>
+  // any unit direction should be exactly 5.0<br>
+  double xyz[3]={-6.0,0.0,0.0};<br>
+  double distance; // distance from point to nearest surface<br>
+  double expect_distance=1.0;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+<br>
+  ErrorCode rval = DAG->closest_to_location(vol_h,xyz,distance);<br>
+  // distance should be 1.0 cm<br>
+  CHECK_REAL_EQUAL(expect_distance,distance,eps);<br>
+}<br>
+<br>
+void dagmc_test_boundary()<br>
+{<br>
+  int vol_idx=1;<br>
+  EntityHandle vol_h = DAG->entity_by_index(3,vol_idx);<br>
+  int surf_idx=1;<br>
+  EntityHandle surf_h = DAG->entity_by_index(2,surf_idx);<br>
+<br>
+  double xyz[3]={0.0,0.0,5.0};<br>
+  double dir[3]={0.0,0.0,1.0};<br>
+  int result;<br>
+  int expect_result=0;<br>
+<br>
+  ErrorCode rval = DAG->test_volume_boundary(vol_h,surf_h,xyz,dir,result);<br>
+  // check ray leaving volume<br>
+  CHECK_EQUAL(expect_result,result);<br>
+}<br>
+<br>
+int main(int /* argc */, char** /* argv */)<br>
+{<br>
+  int result = 0;<br>
+  result += RUN_TEST( dagmc_load_file );     // test ray fire<br>
+  result += RUN_TEST( dagmc_build_obb );     // build the obb<br>
+  result += RUN_TEST( dagmc_num_vols  );     // make sure the num of vols correct<br>
+  // result += RUN_TEST( dagmc_entity_handle);  // check the entity handle correct<br>
+  result += RUN_TEST( dagmc_point_in);       // check entity by point<br>
+  result += RUN_TEST( dagmc_rayfire ) ;      // ensure ray fire distance is correct<br>
+  result += RUN_TEST( dagmc_closest_to );    // check the distance to surface nearest point<br>
+  result += RUN_TEST( dagmc_test_boundary ); // check particle entering leaving<br>
+<br>
+  return result;<br>
+}<br>
<br>
diff --git a/tools/dagmc/DagMC.cpp b/tools/dagmc/DagMC.cpp<br>
index 87f84cb..6e2260a 100755<br>
--- a/tools/dagmc/DagMC.cpp<br>
+++ b/tools/dagmc/DagMC.cpp<br>
@@ -536,6 +536,7 @@ ErrorCode DagMC::ray_fire(const EntityHandle vol,<br>
                           const double point[3], const double dir[3],<br>
                           EntityHandle& next_surf, double& next_surf_dist,<br>
                           RayHistory* history, double user_dist_limit,<br>
+                         int ray_orientation,<br>
                           OrientedBoxTreeTool::TrvStats* stats ) {<br>
<br>
   // take some stats that are independent of nps<br>
@@ -591,9 +592,6 @@ ErrorCode DagMC::ray_fire(const EntityHandle vol,<br>
   // min_tolerance_intersections is passed but not used in this call<br>
   const int min_tolerance_intersections = 0;<br>
<br>
-  // only get exit intersections<br>
-  const int desired_orientation = 1;<br>
-<br>
   // numericalPrecision is used for box.intersect_ray and find triangles in the<br>
   // neighborhood of edge/node intersections.<br>
   rval = obbTree.ray_intersect_sets( dists, surfs, facets,<br>
@@ -601,7 +599,7 @@ ErrorCode DagMC::ray_fire(const EntityHandle vol,<br>
                                      min_tolerance_intersections,<br>
                                      point, dir, &nonneg_ray_len,<br>
                                      stats, &neg_ray_len, &vol, &senseTag,<br>
-                                     &desired_orientation,<br>
+                                     &ray_orientation,<br>
                                      history ? &(history->prev_facets) : NULL );<br>
   assert( MB_SUCCESS == rval );<br>
   if(MB_SUCCESS != rval) return rval;<br>
<br>
diff --git a/tools/dagmc/DagMC.hpp b/tools/dagmc/DagMC.hpp<br>
index 9e71601..fe39082 100755<br>
--- a/tools/dagmc/DagMC.hpp<br>
+++ b/tools/dagmc/DagMC.hpp<br>
@@ -170,6 +170,9 @@ public:<br>
    *                by this query will also be added to the history.<br>
    * @param dist_limit Optional distance limit.  If provided and > 0, no intersections at a<br>
    *                distance further than this value will be returned.<br>
+   * @param ray_orientation Optional ray orientation. If provided determines intersections<br>
+   *                along the normal provided, e.g. if -1 allows intersections back along the<br>
+   *                the ray direction, Default is 1, i.e. exit intersections<br>
    * @param stats Optional TrvStats object used to measure performance of underlying OBB<br>
    *              ray-firing query.  See OrientedBoxTreeTool.hpp for details.<br>
    *<br>
@@ -178,6 +181,7 @@ public:<br>
                      const double ray_start[3], const double ray_dir[3],<br>
                      EntityHandle& next_surf, double& next_surf_dist,<br>
                      RayHistory* history = NULL, double dist_limit = 0,<br>
+                    int ray_orientation = 1,<br>
                      OrientedBoxTreeTool::TrvStats* stats = NULL );<br>
<br>
   /**\brief Test if a point is inside or outside a volume<br>
<br>
diff --git a/tools/dagmc/ray_fire_test.cc b/tools/dagmc/ray_fire_test.cc<br>
index 7e5ce30..cc73a38 100644<br>
--- a/tools/dagmc/ray_fire_test.cc<br>
+++ b/tools/dagmc/ray_fire_test.cc<br>
@@ -277,7 +277,8 @@ int main( int argc, char* argv[] )<br>
       ray_t ray = rays[i];<br>
       std::cout << " Ray: point = " << ray.p << " dir = " << ray.v << std::endl;<br>
<br>
-      rval = dagmc.ray_fire( vol, ray.p.array(), ray.v.array(), surf, dist, NULL, 0, trv_stats );<br>
+      // added ray orientation<br>
+      rval = dagmc.ray_fire( vol, ray.p.array(), ray.v.array(), surf, dist, NULL, 0, 1, trv_stats );<br>
<br>
       if(MB_SUCCESS != rval) {<br>
         std::cerr << "ERROR: ray_fire() failed!" << std::endl;<br>
@@ -326,8 +327,8 @@ int main( int argc, char* argv[] )<br>
               << " " << uvw << " " << uvw%uvw << std::endl;<br>
     uavg += uvw[0]; vavg += uvw[1]; wavg += uvw[2];<br>
 #endif<br>
-<br>
-    dagmc.ray_fire(vol, xyz.array(), uvw.array(), surf, dist, NULL, 0, trv_stats );<br>
+    // added ray orientation<br>
+    dagmc.ray_fire(vol, xyz.array(), uvw.array(), surf, dist, NULL, 0, 1, trv_stats );<br>
<br>
     if( surf == 0){ random_rays_missed++; }<br>
<br>
Repository URL: <a href="https://bitbucket.org/fathomteam/moab/" target="_blank">https://bitbucket.org/fathomteam/moab/</a><br>
<br>
--<br>
<br>
This is a commit notification from <a href="http://bitbucket.org" target="_blank">bitbucket.org</a>. You are receiving<br>
this because you have the service enabled, addressing the recipient of<br>
this email.<br>
</blockquote></div>