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

sjackson at cae.wisc.edu sjackson at cae.wisc.edu
Wed Jul 6 17:03:21 CDT 2011


Author: sjackson
Date: 2011-07-06 17:03:15 -0500 (Wed, 06 Jul 2011)
New Revision: 5044

Modified:
   MOAB/trunk/tools/dagmc/DagMC.cpp
   MOAB/trunk/tools/dagmc/DagMC.hpp
Log:
Add a rollback_last_intersection function to DagMC::RayHistory

This function allows user code to reset the most recently added element
of a ray history without throwing the whole history away.  Two identical
calls to ray_fire that use a history object will return identical results
if rollback_last_intersection is called in between them.

Also improve implementation of RayHistory::reset_to_last_intersection,
allowing it to be safely called on empty histories.

Modified: MOAB/trunk/tools/dagmc/DagMC.cpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.cpp	2011-07-01 19:55:21 UTC (rev 5043)
+++ MOAB/trunk/tools/dagmc/DagMC.cpp	2011-07-06 22:03:15 UTC (rev 5044)
@@ -552,12 +552,19 @@
 }
 
 void DagMC::RayHistory::reset_to_last_intersection() {
-  assert(!prev_facets.empty());
-  const EntityHandle last_facet_hit = prev_facets.back();
-  prev_facets.clear();
-  prev_facets.push_back(last_facet_hit);
+
+  if( prev_facets.size() > 1 ){
+    prev_facets[0] = prev_facets.back();
+    prev_facets.resize( 1 );
+  }
+
 }
 
+void DagMC::RayHistory::rollback_last_intersection() {
+  if( prev_facets.size() )
+    prev_facets.pop_back();
+}
+
 ErrorCode DagMC::ray_fire(const EntityHandle vol, 
                           const double point[3], const double dir[3],
                           EntityHandle& next_surf, double& next_surf_dist,

Modified: MOAB/trunk/tools/dagmc/DagMC.hpp
===================================================================
--- MOAB/trunk/tools/dagmc/DagMC.hpp	2011-07-01 19:55:21 UTC (rev 5043)
+++ MOAB/trunk/tools/dagmc/DagMC.hpp	2011-07-06 22:03:15 UTC (rev 5044)
@@ -120,6 +120,12 @@
      */ 
     void reset_to_last_intersection(); 
 
+    /**
+     * Remove the most recent intersection.  This allows a subsequent call
+     * along the same ray to return the same intersection.
+     */
+    void rollback_last_intersection();
+
   private:    
     std::vector<EntityHandle> prev_facets;
 







More information about the moab-dev mailing list