[MOAB-dev] r1267 - in MOAB/trunk: . tools/qvdual

tautges at mcs.anl.gov tautges at mcs.anl.gov
Tue Sep 11 17:36:39 CDT 2007


Author: tautges
Date: 2007-09-11 17:36:39 -0500 (Tue, 11 Sep 2007)
New Revision: 1267

Modified:
   MOAB/trunk/DualTool.cpp
   MOAB/trunk/tools/qvdual/moc_uiQVDual.cpp
   MOAB/trunk/tools/qvdual/uiQVDual.h
   MOAB/trunk/tools/qvdual/uiQVDual.ui.h
   MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
   MOAB/trunk/tools/qvdual/vtkMOABUtils.h
Log:
Various fixes for qvdual and hex mod operations in DualTool.



Modified: MOAB/trunk/DualTool.cpp
===================================================================
--- MOAB/trunk/DualTool.cpp	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/DualTool.cpp	2007-09-11 22:36:39 UTC (rev 1267)
@@ -2558,9 +2558,13 @@
   MBEntityHandle quads[4], hexes[2];
   std::vector<MBEntityHandle> connects[4], side_quads[2];
 
+    // get three quads (shared quad & 2 end quads), hexes, and quad
+    // connects
   MBErrorCode result = fs_get_quads(odedge, quads, hexes, connects);
   if (MB_SUCCESS != result) return result;
   
+    // adjust sense & rotation so they're aligned, together & wrt first
+    // hex
   result = fs_check_quad_sense(hexes[0], quads[0], connects);
   if (MB_SUCCESS != result) return result;
 
@@ -2615,25 +2619,40 @@
     }
   }
     
-    // delete the interior entities
-  result = mbImpl->delete_entities(adj_ents);
-  if (MB_SUCCESS != result) return result;
-  
-    // re-build the two hexes
+    // before re-connecting two hexes, check for existing quad on 4th quad vertices; 
+    // if there is a quad there, need to add explicit adjs to any adj hexes, since
+    // by definition there'll be another quad on those vertices
+  bool need_explicit = false;
+  MBRange adj_quads;
+  result = mbImpl->get_adjacencies(&connects[3][0], 4, 2, false, adj_quads);
+  if (MB_MULTIPLE_ENTITIES_FOUND == result || !adj_quads.empty()) {
+      // there's already a quad for these 4 vertices; by definition,
+      // we'll be creating equivalent entities, so that original quad
+      // needs explicit adj's to its bounding elements
+    need_explicit = true;
+    for (MBRange::iterator rit = adj_quads.begin(); rit != adj_quads.end(); 
+         rit++) {
+      MBRange adj_hexes;
+      result = mbImpl->get_adjacencies(&(*rit), 1, 3, false, adj_hexes); RR;
+      result = mbImpl->add_adjacencies(*rit, adj_hexes, false); RR;
+    }
+  }
+    
+    // re-connect the two hexes
   std::vector<MBEntityHandle> new_connect;
   std::copy(connects[3].begin(), connects[3].end(), std::back_inserter(new_connect));
   std::copy(connects[2].begin(), connects[2].end(), std::back_inserter(new_connect));
-  result = mbImpl->create_element(MBHEX, &new_connect[0], 8, hexes[0]);
+  result = mbImpl->set_connectivity(hexes[0], &new_connect[0], 8);
   if (MB_SUCCESS != result) return result;
 
   new_connect.clear();
   std::copy(connects[0].begin(), connects[0].end(), std::back_inserter(new_connect));
   std::copy(connects[3].begin(), connects[3].end(), std::back_inserter(new_connect));
-  result = mbImpl->create_element(MBHEX, &new_connect[0], 8, hexes[1]);
+  result = mbImpl->set_connectivity(hexes[1], &new_connect[0], 8);
   if (MB_SUCCESS != result) return result;
 
-    // test for equiv entities from the side quads, and make explicit adjacencies
-    // if there are any
+    // test for equiv entities from the side quads, and make explicit 
+    // adjacencies if there are any
   MeshTopoUtil mtu(mbImpl);
   for (int j = 0; j < 2; j++) {
     for (int i = 0; i < 4; i++) {
@@ -2644,12 +2663,20 @@
     }
   }
   
-    // check for and fix any explicit adjacencies on either end quad
-  if (mtu.equivalent_entities(quads[0]))
-      mbImpl->add_adjacencies(quads[0], &hexes[1], 1, false);
-  if (mtu.equivalent_entities(quads[2]))
-      mbImpl->add_adjacencies(quads[2], &hexes[0], 1, false);
+    // remove hexes we want to keep
+  adj_ents.erase(hexes[0]);
+  adj_ents.erase(hexes[1]);
+  
+    // delete the other interior entities
+  result = mbImpl->delete_entities(adj_ents);
+  if (MB_SUCCESS != result) return result;
 
+  MBEntityHandle new_quad;
+  result = mbImpl->create_element(MBQUAD, &connects[3][0], 4, new_quad); RR;
+  if (need_explicit) {
+    result = mbImpl->add_adjacencies(new_quad, hexes, 2, false); RR;
+  }
+  
   if (debug_ap) ((MBCore*)mbImpl)->check_adjacencies();
 
     // now update the dual
@@ -2666,67 +2693,18 @@
     // where the fourth is really the 4 vertices originally shared by the 2 hexes
     // before the face shrink on them
 
-    // get all verts in quads 0 and 2
-  MBRange outside_verts, all_verts;
-  std::copy(connects[0].begin(), connects[0].end(), mb_range_inserter(outside_verts));
-  std::copy(connects[2].begin(), connects[2].end(), mb_range_inserter(outside_verts));
-    // get all verts in all hexes by getting bridge adjacencies from inner quad;
-    // only need to do 2 verts, since that covers all the hexes
-  MeshTopoUtil mtu(mbImpl);
-  MBErrorCode result = mtu.get_bridge_adjacencies(connects[1][0], 3, 0, all_verts);
-  if (MB_SUCCESS != result) return result;
-  result = mtu.get_bridge_adjacencies(connects[1][2], 3, 0, all_verts);
-  if (MB_SUCCESS != result) return result;
-  for (int i = 0; i < 4; i++)
-    all_verts.erase(connects[1][i]);
-    // outside 4 verts are just difference
-  all_verts = all_verts.subtract(outside_verts);
-  if (all_verts.size() != 4) return MB_FAILURE;
-  std::copy(all_verts.begin(), all_verts.end(), std::back_inserter(connects[3]));
-  
-    // now align with other quads
-    // first get them in the right sequence by verifying shared edges
-  if (0 == mtu.common_entity(connects[3][0], connects[3][1], 1)) {
-    MBEntityHandle dum = connects[3][1];
-    connects[3][1] = connects[3][2];
-    connects[3][2] = dum;
-  }
-  if (0 == mtu.common_entity(connects[3][1], connects[3][2], 1)) {
-    MBEntityHandle dum = connects[3][2];
-    connects[3][2] = connects[3][3];
-    connects[3][3] = dum;
-  }
-  assert(0 != mtu.common_entity(connects[3][0], connects[3][1], 1) &&
-         0 == mtu.common_entity(connects[3][0], connects[3][2], 1));
-  
-    // now get offset, sense
-  int index = -1, sense = 0;
+    // vertex on 4th quad is in quad adj to other 3 verts
   for (int i = 0; i < 4; i++) {
-    if (0 != mtu.common_entity(connects[0][0], connects[3][i], 1)) {
-      index = i;
-      if (0 != mtu.common_entity(connects[0][1], connects[3][(i+1)%4], 1))
-        sense = 1;
-      else if (0 != mtu.common_entity(connects[0][1], connects[3][(i+4-1)%4], 1))
-        sense = -1;
-      break;
-    }
+    MBRange start_verts, tmp_verts, quads;
+    for (int j = 0; j < 3; j++) start_verts.insert(connects[j][i]);
+    MBErrorCode result = mbImpl->get_adjacencies(start_verts, 2, false, quads);
+    if (MB_SUCCESS != result) return result;
+    assert(quads.size() == 1);
+    result = mbImpl->get_adjacencies(&(*quads.begin()), 1, 0, false, tmp_verts); RR;
+    tmp_verts = tmp_verts.subtract(start_verts);
+    assert(1 == tmp_verts.size());
+    connects[3].push_back(*tmp_verts.begin());
   }
-
-  assert(index != -1 && sense != 0);
-  
-  if (sense == -1) {
-    MBEntityHandle dumh = connects[3][0];
-    connects[3][0] = connects[3][2];
-    connects[3][2] = dumh;
-    index = (index + 2)%4;
-  }
-
-  if (index != 0) {
-    std::vector<MBEntityHandle> tmpc;
-    for (int i = 0; i < 4; i++)
-      tmpc.push_back(connects[3][(index+i)%4]);
-    connects[3].swap(tmpc);
-  }
     
     // now get the side quads
   for (int i = 0; i < 4; i++) {
@@ -2734,7 +2712,7 @@
     dum_ents.insert(connects[1][i]);
     dum_ents.insert(connects[1][(i+1)%4]);
     dum_ents.insert(connects[3][i]);
-    result = mbImpl->get_adjacencies(dum_ents, 3, false, hexes);
+    MBErrorCode result = mbImpl->get_adjacencies(dum_ents, 3, false, hexes);
     if (MB_SUCCESS != result) return result;
     assert(1 == hexes.size());
     

Modified: MOAB/trunk/tools/qvdual/moc_uiQVDual.cpp
===================================================================
--- MOAB/trunk/tools/qvdual/moc_uiQVDual.cpp	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/tools/qvdual/moc_uiQVDual.cpp	2007-09-11 22:36:39 UTC (rev 1267)
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** uiQVDual meta object code from reading C++ file 'uiQVDual.h'
 **
-** Created: Wed Aug 22 09:12:40 2007
+** Created: Mon Sep 10 16:49:21 2007
 **      by: The Qt MOC ($Id: qt/moc_yacc.cpp   3.3.7   edited Oct 19 16:22 $)
 **
 ** WARNING! All changes made in this file will be lost!

Modified: MOAB/trunk/tools/qvdual/uiQVDual.h
===================================================================
--- MOAB/trunk/tools/qvdual/uiQVDual.h	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/tools/qvdual/uiQVDual.h	2007-09-11 22:36:39 UTC (rev 1267)
@@ -1,7 +1,7 @@
 /****************************************************************************
 ** Form interface generated from reading ui file 'uiQVDual.ui'
 **
-** Created: Wed Aug 8 03:15:38 2007
+** Created: Mon Sep 10 16:49:13 2007
 **      by: The User Interface Compiler ($Id: qt/main.cpp   3.3.7   edited Aug 31 2005 $)
 **
 ** WARNING! All changes made in this file will be lost!

Modified: MOAB/trunk/tools/qvdual/uiQVDual.ui.h
===================================================================
--- MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-09-11 22:36:39 UTC (rev 1267)
@@ -106,12 +106,13 @@
 
   resetDisplay();
   
-  DualTool(vtkMOABUtils::mbImpl).delete_whole_dual();
+  DualTool dt(vtkMOABUtils::mbImpl);
+  dt.delete_whole_dual();
 
   computeDual = false;
 
   vtkMOABUtils::assign_global_ids();
-  
+
   vtkMOABUtils::mbImpl->write_mesh(filename.ascii());
 
   redrawDisplay();
@@ -1039,28 +1040,17 @@
   bool save_compute = computeDual;
 
   if (NULL != vtkMOABUtils::drawDual) {
-    MBRange sheets;
-    vtkMOABUtils::drawDual->reset_drawn_sheets(&sheets);
-
+    vtkMOABUtils::drawDual->reset_drawn_sheets();
   }
 
   vtkMOABUtils::reset_drawing_data();
 
-  if (NULL != vtkWidget) {
-    delete vtkWidget;
-    vtkWidget = NULL;
-  }
-
   computeDual = save_compute;
 }
 
 
 void uiQVDual::redrawDisplay()
 {
-    //resetDisplay();
-  
-    //this->init();
-  
   vtkMOABUtils::update_display();
 
   this->updateMesh();

Modified: MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
===================================================================
--- MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx	2007-09-11 22:36:39 UTC (rev 1267)
@@ -137,6 +137,15 @@
     vtkMOABUtils::mbImpl = impl;
   }
 
+  MBErrorCode result = create_tags();
+  
+  make_properties();
+
+  return result;
+}
+
+MBErrorCode vtkMOABUtils::create_tags() 
+{
   MBErrorCode result = vtkMOABUtils::mbImpl->tag_get_handle(vtkCellTagName, vtkCellTag);
   if (MB_TAG_NOT_FOUND == result) {
     int def_val = -1;
@@ -179,9 +188,7 @@
                                 vtkPointAllocatedTag, &def_val);
   }
 
-  make_properties();
-
-  return result;
+  return MB_SUCCESS;
 }
 
 void vtkMOABUtils::make_properties() 
@@ -1106,7 +1113,7 @@
                                                             NULL, 0, &mesh_actor);
 
     if (MB_SUCCESS != result) {
-      std::cerr << "Failed to set actor for mesh in vtkMOABReader::Execute()." << std::endl;
+      std::cerr << "Failed to set actor for mesh in vtkMOABUtils::update_display()." << std::endl;
       return;
     }
     
@@ -1179,23 +1186,6 @@
   //! get rid of all the vtk drawing stuff
 void vtkMOABUtils::reset_drawing_data() 
 {
-  if (NULL != myRen) {
-    myRen->Delete();
-    myRen = NULL;
-  }
-
-  //! the default property
-  if (NULL != topProperty) {
-    topProperty->Delete();
-    topProperty = NULL;
-  }
-  
-  //! the highlight property
-  if (NULL != highlightProperty) {
-    highlightProperty->Delete();
-    highlightProperty = NULL;
-  }
-  
   actorProperties.clear();
 
     //! map between props (actor2d's and actors) and sets they represent (0 if no set, 
@@ -1213,11 +1203,6 @@
     topParentAssy = NULL;
   }
 
-  if (NULL != lookupTable) {
-    lookupTable->Delete();
-    lookupTable = NULL;
-  }
-  
   if (NULL != drawDual) {
     delete drawDual;
     drawDual = NULL;
@@ -1234,24 +1219,31 @@
   MBErrorCode result = mbImpl->tag_delete(vtkTopContainsTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkTopContainsTag = NULL;
 
   //! tag indicating whether a given set is in top parent assy
   result = mbImpl->tag_delete(vtkTopParentTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkTopParentTag = NULL;
   result = mbImpl->tag_delete(vtkCellTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkCellTag = NULL;
   result = mbImpl->tag_delete(vtkSetActorTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkSetActorTag = NULL;
   result = mbImpl->tag_delete(vtkSetPropAssemblyTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkSetPropAssemblyTag = NULL;
   result = mbImpl->tag_delete(vtkPointAllocatedTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
+  vtkPointAllocatedTag = NULL;
 
+  create_tags();
 }
 
 void vtkMOABUtils::assign_global_ids()

Modified: MOAB/trunk/tools/qvdual/vtkMOABUtils.h
===================================================================
--- MOAB/trunk/tools/qvdual/vtkMOABUtils.h	2007-08-31 16:38:22 UTC (rev 1266)
+++ MOAB/trunk/tools/qvdual/vtkMOABUtils.h	2007-09-11 22:36:39 UTC (rev 1267)
@@ -246,6 +246,8 @@
     //! debug parameter
   static bool debug;
   
+  static MBErrorCode create_tags();
+  
 private:
     //! private constructor so nobody can construct one
   vtkMOABUtils();




More information about the moab-dev mailing list