[MOAB-dev] r3335 - MOAB/trunk

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Nov 12 14:48:49 CST 2009


Author: kraftche
Date: 2009-11-12 14:48:49 -0600 (Thu, 12 Nov 2009)
New Revision: 3335

Modified:
   MOAB/trunk/AEntityFactory.cpp
   MOAB/trunk/AEntityFactory.hpp
Log:
Fix strange split of code between get_adjacencies and get_elements in
AEntityFactory:
  o move handling of non-element target dimensions from get_elements
      to get_adjacencies
  o move activation of vertex-to-element adjacencies from get_adjacencies
      to get_elements
This change avoids the activiation of vertex-to-element adjacencies
when get_adjacencies is asked for something for target entities for
which they are not required (sets, vertices, etc), and avoids the issue
where the public get_elements function does not activate vertex-to-
element adjacencies if necessary.



Modified: MOAB/trunk/AEntityFactory.cpp
===================================================================
--- MOAB/trunk/AEntityFactory.cpp	2009-11-12 19:44:03 UTC (rev 3334)
+++ MOAB/trunk/AEntityFactory.cpp	2009-11-12 20:48:49 UTC (rev 3335)
@@ -93,39 +93,33 @@
 {
   // check for trivial case first
   const MBEntityType source_type = TYPE_FROM_HANDLE(source_entity);
-  const int source_dimension = MBCN::Dimension(source_type);
+  const unsigned source_dimension = MBCN::Dimension(source_type);
 
-  MBErrorCode result;
-  if((unsigned int)source_dimension == target_dimension)
-  {
-    result = MB_FAILURE;
+  if (source_type >= MBENTITYSET || target_dimension < 1 || target_dimension > 3) {
+    return MB_TYPE_OUT_OF_RANGE;
   }
-  else if(target_dimension > 4)
-  {
-    result = MB_TYPE_OUT_OF_RANGE;
+  else if (source_dimension == target_dimension) {
+    target_entities.push_back( source_entity );
+    return MB_SUCCESS;
   }
-  else if(target_dimension == (source_type != MBPOLYHEDRON ? 0 : 2)) 
-  {
-    result = thisMB->get_connectivity(&source_entity, 1, target_entities);
+
+  MBErrorCode result;
+  if(mVertElemAdj == false && target_dimension != 0) {
+    result = create_vert_elem_adjacencies();
+    if (MB_SUCCESS != result) return result;
   }
-  else if( target_dimension == 4 ) //get meshsets 'source' is in
+
+  if(source_dimension == 0)
   {
-    result = get_associated_meshsets( source_entity, target_entities ); 
-  }
-  else if(source_dimension == 0)
-  {
     result = get_zero_to_n_elements(source_entity, target_dimension,
       target_entities, create_if_missing, create_adjacency_option);
   }
-  else if((unsigned int)source_dimension > target_dimension)
+  else if(source_dimension > target_dimension)
   {
-    if (MBPOLYHEDRON == source_type && target_dimension == 0) 
-      result = get_polyhedron_vertices(source_entity, target_entities);
-    else
-      result = get_down_adjacency_elements(source_entity, target_dimension,
-                                           target_entities, create_if_missing, create_adjacency_option);
+    result = get_down_adjacency_elements(source_entity, target_dimension,
+                                         target_entities, create_if_missing, create_adjacency_option);
   }
-  else //if((unsigned int)source_dimension < target_dimension)
+  else //if(source_dimension < target_dimension)
   {
     result = get_up_adjacency_elements( source_entity, target_dimension,
            target_entities, create_if_missing, create_adjacency_option);
@@ -579,26 +573,30 @@
   return result;
 }
 
-MBErrorCode AEntityFactory::get_adjacencies(const MBEntityHandle entity,
-                                             const unsigned int to_dimension,
+MBErrorCode AEntityFactory::get_adjacencies( const MBEntityHandle source_entity,
+                                             const unsigned int target_dimension,
                                              bool create_if_missing,
-                                             std::vector<MBEntityHandle> &adjacent_entities)
+                                             std::vector<MBEntityHandle> &target_entities )
 {
-  MBEntityType ent_type = TYPE_FROM_HANDLE(entity);
+  const MBEntityType source_type = TYPE_FROM_HANDLE(source_entity);
 
-  if (ent_type == MBMAXTYPE) return MB_TYPE_OUT_OF_RANGE;
-  
-  if ((unsigned int)MBCN::Dimension(ent_type) == to_dimension) {
-    adjacent_entities.push_back(entity);
-    return MB_SUCCESS;
+  MBErrorCode result;
+  if (target_dimension == 4) { //get meshsets 'source' is in
+    result = get_associated_meshsets( source_entity, target_entities ); 
   }
-
-  if(mVertElemAdj == false && to_dimension != 0) {
-    MBErrorCode result = create_vert_elem_adjacencies();
-    if (MB_SUCCESS != result) return result;
+  else if (target_dimension == (source_type != MBPOLYHEDRON ? 0 : 2)) {
+    result = thisMB->get_connectivity(&source_entity, 1, target_entities);
   }
-  
-  return get_elements(entity, to_dimension, adjacent_entities, create_if_missing, 0);
+  else if (target_dimension == 0 && source_type == MBPOLYHEDRON) {
+    result = get_polyhedron_vertices(source_entity, target_entities);
+  }
+  else {
+    result = get_elements( source_entity, 
+                           target_dimension,
+                           target_entities,
+                           create_if_missing );
+  }
+  return result;
 }
 
 

Modified: MOAB/trunk/AEntityFactory.hpp
===================================================================
--- MOAB/trunk/AEntityFactory.hpp	2009-11-12 19:44:03 UTC (rev 3334)
+++ MOAB/trunk/AEntityFactory.hpp	2009-11-12 20:48:49 UTC (rev 3335)
@@ -59,7 +59,7 @@
  *
  *\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.
+ *                        be in the range [1,3], 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



More information about the moab-dev mailing list