[MOAB-dev] r1352 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Fri Nov 2 11:15:55 CDT 2007


Author: kraftche
Date: 2007-11-02 11:15:54 -0500 (Fri, 02 Nov 2007)
New Revision: 1352

Modified:
   MOAB/trunk/EntitySequence.hpp
   MOAB/trunk/MBCore.cpp
   MOAB/trunk/MBCore.hpp
   MOAB/trunk/MBInterface.hpp
   MOAB/trunk/PolyEntitySequence.cpp
   MOAB/trunk/PolyEntitySequence.hpp
   MOAB/trunk/ScdElementSeq.hpp
Log:
Add optional storage argument to pointer get_connectivity, allowing it to be used with structured elements

Modified: MOAB/trunk/EntitySequence.hpp
===================================================================
--- MOAB/trunk/EntitySequence.hpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/EntitySequence.hpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -199,7 +199,8 @@
   virtual MBErrorCode get_connectivity(MBEntityHandle entity, 
                                         const MBEntityHandle*& connectivity,
                                         int &num_vertices,
-                                       const bool topological_connectivity = false) const;
+                                       const bool topological_connectivity = false,
+                                       std::vector<MBEntityHandle>* storage = 0) const;
 
   virtual MBErrorCode set_connectivity(MBEntityHandle entity, const MBEntityHandle *conn,
                                 const int num_vertices);
@@ -299,7 +300,8 @@
 inline MBErrorCode ElementEntitySequence::get_connectivity(MBEntityHandle entity,
                                                            const MBEntityHandle*& conn,
                                                            int &num_vertices,
-                                                           const bool topological_connectivity) const
+                                                           const bool topological_connectivity,
+                                                           std::vector<MBEntityHandle>* ) const
 {
   num_vertices = mNodesPerElement;
   int index = entity - mStartEntityHandle;

Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/MBCore.cpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -902,7 +902,8 @@
 MBErrorCode MBCore::get_connectivity(const MBEntityHandle entity_handle, 
                                      const MBEntityHandle*& connectivity,
                                      int& number_nodes,
-                                     bool topological_connectivity) const
+                                     bool topological_connectivity,
+                                     std::vector<MBEntityHandle>* storage) const
 {
 
   MBErrorCode status;
@@ -928,7 +929,8 @@
 
   return static_cast<ElementEntitySequence*>(seq)->get_connectivity(entity_handle, connectivity,
                                                                     number_nodes,
-                                                                    topological_connectivity);
+                                                                    topological_connectivity,
+                                                                    storage);
 }
 
 //! set the connectivity for element handles.  For non-element handles, return an error

Modified: MOAB/trunk/MBCore.hpp
===================================================================
--- MOAB/trunk/MBCore.hpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/MBCore.hpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -205,11 +205,23 @@
           Example: \code 
           const MBEntityHandle* conn;
           int number_nodes = 0;
-          get_connectivity( entity_handle, conn, number_nodes ); \endcode */
-    virtual MBErrorCode  get_connectivity(const MBEntityHandle entity_handle, 
+          get_connectivity( entity_handle, conn, number_nodes ); \endcode 
+          
+          Example2: \code
+          std::vector<MBEntityHandle> sm_storage;
+          const MBEntityHandle* conn;
+          int number_nodes;
+          get_connectivity( handle, conn, number_nodes, false, &sm_storage );
+          if (conn == &sm_storage[0])
+            std::cout << "Structured mesh element" << std::endl;
+          \endcode
+        */
+    virtual MBErrorCode  get_connectivity( const MBEntityHandle entity_handle, 
                                            const MBEntityHandle *&connectivity, 
                                            int &num_nodes, 
-                                           bool topological_connectivity = false) const;
+                                           bool topological_connectivity = false,
+                                           std::vector<MBEntityHandle>* storage = 0
+                                          ) const;
 
       //! Sets the connectivity for an MBEntityHandle.  For non-element handles, return an error.
       /** Connectivity is stored exactly as it is ordered in vector <em>connectivity</em>. 

Modified: MOAB/trunk/MBInterface.hpp
===================================================================
--- MOAB/trunk/MBInterface.hpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/MBInterface.hpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -449,16 +449,41 @@
         entity_handle </em>.  Faster then the other <em>get_connectivity</em> function because no
         data is copied.  The nodes in 'connectivity' are properly ordered according to the 
         element's canonical ordering.
+        
+
+          Example: \code 
+          const MBEntityHandle* conn;
+          int number_nodes = 0;
+          get_connectivity( entity_handle, conn, number_nodes ); \endcode 
+          
+          Example2: \code
+          std::vector<MBEntityHandle> sm_storage;
+          const MBEntityHandle* conn;
+          int number_nodes;
+          get_connectivity( handle, conn, number_nodes, false, &sm_storage );
+          if (conn == &sm_storage[0])
+            std::cout << "Structured mesh element" << std::endl;
+          \endcode
+        
         \param entity_handle MBEntityHandle to get connectivity of.
         \param connectivity Array in which connectivity of <em>entity_handle</em> is returned.
         \param num_nodes Number of MeshVertices in array <em>connectivity</em>. 
         \param topological_connectivity If true, num_nodes will be set to number of corner vertices
         for that element type.
+        \param storage Some elements (e.g. structured mesh) may not have an
+                       explicit connectivity list.  This function will normally
+                       return MB_NOT_IMPLEMENTED for such elements.  However,
+                       if the caller passes in a non-null value for this 
+                       argument, space will be allocated in this vector for
+                       the connectivity data and the connectivity pointer will
+                       be set to the data in this vector.
     */
   virtual MBErrorCode  get_connectivity(const MBEntityHandle entity_handle, 
                                         const MBEntityHandle *&connectivity, 
                                         int &num_nodes, 
-                                        bool topological_connectivity = false) const =0;
+                                        bool topological_connectivity = false,
+                                        std::vector<MBEntityHandle>* storage = 0
+                                        ) const =0;
 
     //! Sets the connectivity for an MBEntityHandle.  For non-element handles, return an error.
     /** Connectivity is stored exactly as it is ordered in vector <em>connectivity</em>. 

Modified: MOAB/trunk/PolyEntitySequence.cpp
===================================================================
--- MOAB/trunk/PolyEntitySequence.cpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/PolyEntitySequence.cpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -49,7 +49,8 @@
 MBErrorCode PolyEntitySequence::get_connectivity(MBEntityHandle entity,
                                                  const MBEntityHandle*& conn,
                                                  int &num_vertices,
-                                                 const bool /*topological_connectivity*/) const
+                                                 const bool /*topological_connectivity*/,
+                                                 std::vector<MBEntityHandle>* ) const
 {
   MBEntityID index = entity - mStartEntityHandle;
   if (!is_valid_entity(entity))

Modified: MOAB/trunk/PolyEntitySequence.hpp
===================================================================
--- MOAB/trunk/PolyEntitySequence.hpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/PolyEntitySequence.hpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -53,7 +53,8 @@
   virtual MBErrorCode get_connectivity(MBEntityHandle entity, 
                                        const MBEntityHandle*& connectivity,
                                        int &num_vertices,
-                                       const bool topological_connectivity = false) const;
+                                       const bool topological_connectivity = false,
+                                       std::vector<MBEntityHandle>* storage = 0) const;
 
   MBErrorCode set_connectivity(MBEntityHandle entity, const MBEntityHandle *conn,
                                const int num_vertices);

Modified: MOAB/trunk/ScdElementSeq.hpp
===================================================================
--- MOAB/trunk/ScdElementSeq.hpp	2007-11-02 14:51:58 UTC (rev 1351)
+++ MOAB/trunk/ScdElementSeq.hpp	2007-11-02 16:15:54 UTC (rev 1352)
@@ -139,7 +139,8 @@
   virtual MBErrorCode get_connectivity(MBEntityHandle entity, 
                                        const MBEntityHandle*& connectivity,
                                        int &num_vertices,
-                                       const bool topological_connectivity = false) const;
+                                       const bool topological_connectivity = false,
+                                       std::vector<MBEntityHandle>* stroage = 0) const;
 
     //! get connectivity of an entity given entity's parameters
   inline MBErrorCode get_params_connectivity(const int i, const int j, const int k,
@@ -326,13 +327,19 @@
   return get_params_connectivity(i, j, k, connectivity);
 }
 
-inline MBErrorCode ScdElementSeq::get_connectivity(MBEntityHandle , 
-                                                   const MBEntityHandle*& ,
-                                                   int &,
-                                                   const bool) const 
+inline MBErrorCode ScdElementSeq::get_connectivity(MBEntityHandle handle, 
+                                                   const MBEntityHandle*& conn,
+                                                   int &len,
+                                                   const bool topo,
+                                                   std::vector<MBEntityHandle>* storage) const 
 {
-    // this version of get_connectivity isn't supported yet!
-  return MB_NOT_IMPLEMENTED;
+  if (!storage)
+    return MB_NOT_IMPLEMENTED;
+    
+  MBErrorCode result = get_connectivity( handle, *storage, topo );
+  conn = &(*storage)[0];
+  len = storage->size();
+  return result;
 }
 
 inline MBEntityHandle ScdElementSeq::get_vertex(const HomCoord &coords) const




More information about the moab-dev mailing list