[MOAB-dev] r2726 - MOAB/trunk

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Mar 18 13:43:31 CDT 2009


Author: kraftche
Date: 2009-03-18 13:43:31 -0500 (Wed, 18 Mar 2009)
New Revision: 2726

Modified:
   MOAB/trunk/AEntityFactory.cpp
   MOAB/trunk/AEntityFactory.hpp
   MOAB/trunk/MBInterface.hpp
Log:
make MBInterface::get_adjacencies append than assign to the passed std::vector and document that behavior

Modified: MOAB/trunk/AEntityFactory.cpp
===================================================================
--- MOAB/trunk/AEntityFactory.cpp	2009-03-18 17:38:20 UTC (rev 2725)
+++ MOAB/trunk/AEntityFactory.cpp	2009-03-18 18:43:31 UTC (rev 2726)
@@ -100,9 +100,6 @@
 
   if(target_dimension > 4)
     return MB_FAILURE;
-
-  if(!target_entities.empty())
-    target_entities.clear();
   
   std::vector<MBEntityHandle> vertices;
 
@@ -157,8 +154,6 @@
 {
 
   MBErrorCode result;
-  if(!target_entities.empty())
-    target_entities.clear();
   
   const MBEntityHandle* adj_vec;
   int num_adj;
@@ -175,8 +170,7 @@
     std::lower_bound(start_ent, adj_vec+num_adj, CREATE_HANDLE(dim_pair.second, MB_END_ID, dum));
 
   // copy the the meshsets 
-  target_entities.resize(end_ent - start_ent);
-  std::copy(start_ent, end_ent, target_entities.begin());
+  target_entities.insert( target_entities.end(), start_ent, end_ent );
 
   return result; 
 
@@ -875,7 +869,7 @@
   if (MB_SUCCESS != result) return result;
 
   if (target_dimension == 0) {
-    target_entities = vertex_array;
+    target_entities.insert( target_entities.end(), vertex_array.begin(), vertex_array.end() );
     return MB_SUCCESS;
   }
 
@@ -1065,7 +1059,7 @@
     
     it1 = std::lower_bound( end1, vtx_adj->end(), tgt_beg_handle );
     end1 = std::lower_bound( it1, vtx_adj->end(), tgt_end_handle );
-    target_entities.erase( intersect( target_entities.begin(), target_entities.end(),
+    target_entities.erase( intersect( target_entities.begin()+in_size, target_entities.end(),
                            it1, end1 ), target_entities.end() );
   }
   
@@ -1163,7 +1157,7 @@
   std::vector<MBEntityHandle> tmp_vec;
   if (!equiv_entities) {
       // get elems adjacent to each node
-    std::vector<MBEntityHandle> *elems = new std::vector<MBEntityHandle>[num_source_vertices];
+    std::vector< std::vector<MBEntityHandle> > elems(num_source_vertices);
     int i;
     for(i=0; i < num_source_vertices; i++)
     {
@@ -1189,8 +1183,7 @@
     }
 
       // elems[0] contains the intersection, swap with target_entities
-    target_entities.swap(elems[0]);
-    delete [] elems;
+    target_entities.insert( target_entities.end(), elems[0].begin(), elems[0].end() );
   }
   else if (source_type == MBPOLYGON) {
       // get adjacencies using polyhedra's connectivity vectors
@@ -1251,8 +1244,7 @@
     std::copy(start_ent_td, end_ent_td, mb_range_inserter(target_ents));
     
       // now insert the whole thing into the argument vector
-    target_entities.clear();
-    std::copy(target_ents.begin(), target_ents.end(), std::back_inserter(target_entities));
+    target_entities.insert( target_entities.end(), target_ents.begin(), target_ents.end() );
   }
 
   return result;

Modified: MOAB/trunk/AEntityFactory.hpp
===================================================================
--- MOAB/trunk/AEntityFactory.hpp	2009-03-18 17:38:20 UTC (rev 2725)
+++ MOAB/trunk/AEntityFactory.hpp	2009-03-18 18:43:31 UTC (rev 2726)
@@ -52,12 +52,27 @@
 //! remove all adjacencies from from the base_entity.
   MBErrorCode remove_all_adjacencies(MBEntityHandle base_entity,
                                      const bool delete_adj_list = false);
-  
-//! get the elements contained by source_entity, of
-//! type target_type, passing back in target_entities; if create_if_missing
-//! is true and no entity is found, one is created; if create_adjacency_option
-//! is >= 0, adjacencies from entities of that dimension to each target_entity
-//! are created (this function uses AEntityFactory::get_element for each element)
+
+/**\brief Get adjacencies for a single source entity.
+ *
+ * Get adjacent entities.
+ *
+ *\param source_entity    The entity for which to retrieve the adjacencies.
+ *\param target_dimension Retrieve adjacent entities of this dimension.  Must
+ *                        be in the range [0,4], where 4 is used to indicated entity sets.
+ *\param target_entities  Requested adjacent entities will be appended to this list.
+ *\param create_if_missing If true, adjacent elements of the specified dimension will
+ *                        be created if they do not already exist.  If the target dimension
+ *                        is less than the dimension of the input entity and greater than zero, the 
+ *                        elements will be created as required to represent the "sides" of
+ *                        the source element.  If the target dimension is greater than that
+ *                        of the source entity and less than 3, then sides of the specified
+ *                        dimension on that are a) of greater dimension and b) adjacent to
+ *                        the input entity will be created.
+ * \param create_adjacency_option If create_adjacency_option is >= 0, adjacencies from 
+ *                        entities of that dimension to each target_entity are created 
+ *                        (this function uses AEntityFactory::get_element for each element)
+ */
   MBErrorCode get_elements(MBEntityHandle source_entity,
                             const unsigned int target_dimension,
                             std::vector<MBEntityHandle> &target_entities,
@@ -89,6 +104,14 @@
                            const MBEntityHandle source_entity = 0,
                            const int create_adjacency_option = -1);
 
+  /**\brief Get adjacent entities
+   *
+   *\param entity            The source entity for which to retrieve adjacent entities.
+   *\param to_dimension      The adjacent entities to retrieve, specified by dimension.
+   *\param create_if_missing Create adjacent entities that do not already exist.
+   *\param adjacent_entities The resulting adjacent entities are appended to this 
+   *                         list.
+   */
   MBErrorCode get_adjacencies(const MBEntityHandle entity,
                                const unsigned int to_dimension,
                                bool create_if_missing,

Modified: MOAB/trunk/MBInterface.hpp
===================================================================
--- MOAB/trunk/MBInterface.hpp	2009-03-18 17:38:20 UTC (rev 2725)
+++ MOAB/trunk/MBInterface.hpp	2009-03-18 18:43:31 UTC (rev 2726)
@@ -510,7 +510,7 @@
         \param to_dimension Dimension of desired adjacencies
         \param create_if_missing If true, MB will create any entities of the specfied dimension
         which have not yet been created (only useful when <em>to_dimension < dim(*from_entities)</em>)
-        \param adj_entities STL vector in which adjacent entities are returned. 
+        \param adj_entities STL vector to which adjacent entities are appended. 
         \param operation_type Enum of INTERSECT or UNION.  Defines whether to take
         the intersection or union of the set of adjacencies recovered for the from_entities.
 



More information about the moab-dev mailing list