[MOAB-dev] commit/MOAB: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed May 8 22:04:57 CDT 2013


2 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/bb733f73b7ef/
Changeset:   bb733f73b7ef
Branch:      None
User:        iulian07
Date:        2013-05-09 04:50:46
Summary:     fix edge adjacency for polygons and polyhedra, if "create_if_missing" is true
it will create the edges for polygons in the loop if they are missing (by default
moab allows one loop for a polygon, so no internal loops)
a moab test is added for a polyhedra, to determine the edges too.

Affected #:  3 files

diff --git a/src/AEntityFactory.cpp b/src/AEntityFactory.cpp
index 3d04244..577162e 100644
--- a/src/AEntityFactory.cpp
+++ b/src/AEntityFactory.cpp
@@ -788,7 +788,7 @@ ErrorCode AEntityFactory::get_down_adjacency_elements(EntityHandle source_entity
 ErrorCode AEntityFactory::get_down_adjacency_elements_poly(EntityHandle source_entity,
                                                              const unsigned int target_dimension,
                                                              std::vector<EntityHandle> &target_entities,
-                                                             const bool /*create_if_missing*/,
+                                                             const bool create_if_missing,
                                                              const int /*create_adjacency_option*/)
 {
 
@@ -843,6 +843,34 @@ ErrorCode AEntityFactory::get_down_adjacency_elements_poly(EntityHandle source_e
           target_entities.push_back(*adj_edges.begin());
         }
       }
+      else
+      {
+        // we have no adjacent edge yet; we need to create one and also add
+        // them to the adjacency of the vertices
+        if (create_if_missing)
+        {
+          EntityHandle newEdge;
+          EntityHandle v[2] = {vertex_array[i], vertex_array[i+1]};
+          result = thisMB->create_element(MBEDGE, v, 2,
+                                               newEdge);
+          if (MB_SUCCESS!=result)
+            return result;
+          // we also need to add explicit adjacency, so next time we do not
+          // create again (because we do not find the edge if it is not adjacent to the
+          // vertices
+         // if (create_adjacency_option >= 0)
+          //{
+          result = add_adjacency(v[0],newEdge);
+          if (MB_SUCCESS!=result)
+            return result;
+          result = add_adjacency(v[1],newEdge);
+          if (MB_SUCCESS!=result)
+            return result;
+          target_entities.push_back(newEdge);
+          //}
+
+        }
+      }
     }
     return result;
   }
@@ -855,7 +883,7 @@ ErrorCode AEntityFactory::get_down_adjacency_elements_poly(EntityHandle source_e
       std::vector<EntityHandle> dum_vec;
       result = thisMB->get_connectivity(&source_entity, 1, dum_vec);
       if (MB_SUCCESS != result) return result;
-      result = thisMB->get_adjacencies(&dum_vec[0], dum_vec.size(), 1, false,
+      result = thisMB->get_adjacencies(&dum_vec[0], dum_vec.size(), 1, create_if_missing,
                                        target_entities, Interface::UNION);
       return result;
     }

diff --git a/test/MBTest.cpp b/test/MBTest.cpp
index e695f99..7394c63 100644
--- a/test/MBTest.cpp
+++ b/test/MBTest.cpp
@@ -5950,6 +5950,97 @@ ErrorCode mb_poly_adjacency_test()
   return moab.check_adjacencies();
 }
 
+ErrorCode mb_poly_adjacency_test2()
+{
+  ErrorCode rval;
+  Core moab;
+  Interface *mbImpl = &moab;
+
+    // make a polyhedra in shape of a cube with a corner cut
+
+  /*
+   *
+   *             7   -------------   8
+   *          .  |               .   |
+   *       .                  .      |  initial cube had 8 vertices; box [000 - 222]
+   *    5   -------------   6        |   cut a triangle 123 on lower corner
+   *    |        |          |        |
+   *    |                   |        |   faces of the polyhedra (pointing outward)
+   *    |        |          |        |   (123) (24653) (4 10 8 6)
+   *    3                   |        |   (9 10 4 2 1) (7 8 10 9)  (5687)
+   *     \       |          |        |   (1 3 5 7 9)
+   *             9   -  -  -|  -    10
+   *       \  .             |     .
+   *        1,              |  .
+   *  (000)      '2 ----    4
+   *
+   */
+  double coords[] = {0, 1, 0,   // vertex 1
+                     1, 0, 0,   // vertex 2
+                     0, 0 ,1,   // vertex 3
+                     2, 0, 0,
+                     0, 0, 2,
+                     2, 0, 2,   // vertex 6
+                     0, 2, 2,
+                     2, 2, 2,   // vertex 8
+                     0, 2, 0,   // vertex 9
+                     2, 2, 0    // vertex 9
+
+  };
+  EntityHandle verts[10], polygons[7], polyhedron;
+
+  for (int i = 0; i < 10; i++) {
+    rval = mbImpl->create_vertex(&coords[3*i], verts[i]);
+    if (MB_SUCCESS != rval)
+      return rval;
+  }
+
+  EntityHandle connect[]= {1, 2, 3,       // poly 1
+                           2, 4, 6, 5, 3,  // poly 2
+                           4, 10, 8, 6,    // polygon 3...
+                           9, 10, 4, 2, 1,
+                           7, 8, 10, 9,
+                           5, 6, 8, 7,
+                           1, 3, 5, 7, 9   // polygon 7
+                           }; // we know the handles directly
+
+  int num_verts[7]={3, 5, 4, 5, 4, 4, 5};
+  int start_indx[7];
+  start_indx[0]= 0;
+  for (int i=0; i<6; i++)
+    start_indx[i+1]=start_indx[i]+num_verts[i];
+  for (int j = 0; j < 7; j++) {
+    rval = mbImpl->create_element(MBPOLYGON, &connect[start_indx[j]],
+        num_verts[j], polygons[j]);
+    if (MB_SUCCESS != rval)
+      return rval;
+  }
+  rval = mbImpl->create_element(MBPOLYHEDRON, polygons, 7, polyhedron);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+    // create the aentities
+  Range dum_range;
+  for (int dim = 0; dim < 3; dim++) {
+    dum_range.clear();
+    rval = mbImpl->get_adjacencies(&polyhedron, 1, dim, true, dum_range, Interface::UNION);
+    if (MB_SUCCESS != rval)
+      return rval;
+    std::cout << "\n dimension:" << dim << " " << dum_range.size() << " entities";
+  }
+  std::cout << "\n";
+  /*rval=mbImpl->write_mesh("polyhedra.vtk");
+  if (MB_SUCCESS != rval)
+    return rval;*/
+    // delete the polyhedron
+  rval = mbImpl->delete_entities(&polyhedron, 1);
+  if (MB_SUCCESS != rval)
+    return rval;
+
+    // check adjacencies
+  return moab.check_adjacencies();
+}
+
 ErrorCode mb_memory_use_test() 
 {
   Core mb;
@@ -8152,6 +8243,7 @@ int main(int argc, char* argv[])
   RUN_TEST( mb_split_test );
   RUN_TEST( mb_range_seq_intersect_test );
   RUN_TEST( mb_poly_adjacency_test );
+  RUN_TEST( mb_poly_adjacency_test2 );
   RUN_TEST( mb_memory_use_test );
   RUN_TEST( mb_skin_curve_test );
   RUN_TEST( mb_skin_curve_adj_test );

diff --git a/tools/mbcslam/intx_in_plane_test.cpp b/tools/mbcslam/intx_in_plane_test.cpp
index 774e583..d91ea79 100644
--- a/tools/mbcslam/intx_in_plane_test.cpp
+++ b/tools/mbcslam/intx_in_plane_test.cpp
@@ -25,6 +25,7 @@ int main(int argc, char* argv[])
   const char *filename_mesh1 = STRINGIFY(SRCDIR) "/m1.vtk";
   const char *filename_mesh2 = STRINGIFY(SRCDIR) "/m2.vtk";
   const char *newFile = "intx1.vtk";
+  const char *edgesFile = "polyWithEdges.vtk";
   if (argc == 4)
   {
     filename_mesh1 = argv[1];
@@ -86,6 +87,13 @@ int main(int argc, char* argv[])
      return 1;
 
   std::cout << "number of edges:" << edges.size() << "\n";
+  // add edges to the output set
+  rval = mb->add_entities(outputSet, edges);
+  if (MB_SUCCESS != rval)
+    return 1;
+  rval = mb->write_mesh(edgesFile, &outputSet, 1);
+  if (MB_SUCCESS != rval)
+    return 1;
   return 0;
 
 


https://bitbucket.org/fathomteam/moab/commits/a095324ead75/
Changeset:   a095324ead75
Branch:      master
User:        iulian07
Date:        2013-05-09 05:04:28
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  1 file

diff --git a/examples/HelloMOAB.cpp b/examples/HelloMOAB.cpp
index ee81de9..ebab971 100644
--- a/examples/HelloMOAB.cpp
+++ b/examples/HelloMOAB.cpp
@@ -8,13 +8,15 @@
 
 
 #include "moab/Core.hpp"
+#include <iostream>
+#include <assert.h>
 
 using namespace moab;
 using namespace std;
 
 string test_file_name = string(MESH_DIR) + string("/3k-tri-sphere.vtk");
 
-int main( int argc, char** argv[] )
+int main( int argc, char** argv )
 {
   Interface *iface = new Core;
 
@@ -24,7 +26,7 @@ int main( int argc, char** argv[] )
     test_file_name = argv[1];
   }  
     //load the mesh from vtk file
-  ErrorCode rval = iface->load_mesh( test_file_name );
+  ErrorCode rval = iface->load_mesh( test_file_name.c_str() );
   assert( rval == MB_SUCCESS);
 
     //get verts entities

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list