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

tautges at mcs.anl.gov tautges at mcs.anl.gov
Thu Aug 23 07:18:55 CDT 2007


Author: tautges
Date: 2007-08-23 07:18:54 -0500 (Thu, 23 Aug 2007)
New Revision: 1247

Modified:
   MOAB/trunk/DualTool.cpp
   MOAB/trunk/MBCore.cpp
   MOAB/trunk/tools/qvdual/DrawDual.cpp
   MOAB/trunk/tools/qvdual/DrawDual.hpp
   MOAB/trunk/tools/qvdual/uiQVDual.ui.h
Log:
qvdual: fixing lots of bugs, redid picking and sheet drawing.

DualTool: fixing assignment of sheet ids; fixing reverse face shrink;
fixing atomic pillow adjacencies betw quads and hexes

MBCore: don't evaluate adjacencies for sets in check_adjacencies



Modified: MOAB/trunk/DualTool.cpp
===================================================================
--- MOAB/trunk/DualTool.cpp	2007-08-20 14:08:44 UTC (rev 1246)
+++ MOAB/trunk/DualTool.cpp	2007-08-23 12:18:54 UTC (rev 1247)
@@ -31,6 +31,7 @@
 #include <assert.h>
 
 #define RR if (MB_SUCCESS != result) return result
+#define SWAP(a,b) {MBEntityHandle tmp_ent = a; a = b; b = tmp_ent;}
 
 bool debug = false;
 bool debug_ap = true;
@@ -1056,7 +1057,12 @@
   if (-1 == id) {
     MBRange all_hyperplanes;
     result = get_dual_hyperplanes(mbImpl, dim, all_hyperplanes); RR;
-    id = all_hyperplanes.size() + 1;
+    std::vector<int> gids(all_hyperplanes.size());
+    result = mbImpl->tag_get_data(globalIdTag, all_hyperplanes, &gids[0]); RR;
+    for (unsigned int i = 0; i < gids.size(); i++) 
+      if (gids[i] > id) id = gids[i];
+    id++;
+    if (0 == id) id++;
   }
     
   result = mbImpl->tag_set_data(globalId_tag(), &new_hyperplane, 1, &id); RR;
@@ -1464,22 +1470,34 @@
     RR;
   }
   
-    // create the new, outer quad, and make it explicitly adjacent to 1st hex
-  result = mbImpl->create_element(MBQUAD, &verts[0], 4, quad2); RR;
-  result = mbImpl->add_adjacencies(quad2, &(*hexes.begin()), 1, false); RR;
+    // create the new, outer quad, and make it explicitly adjacent to 1st hex;
+    // make the connectivity of this quad reversed from the original one
+  std::vector<MBEntityHandle> tmp_verts;
+  std::copy(verts.begin(), verts.end(), std::back_inserter(tmp_verts));
+  std::reverse(tmp_verts.begin(), tmp_verts.begin()+4);
+  std::reverse(tmp_verts.begin()+4, tmp_verts.end());
   
-    // now make two inner hexes, connect each to one of the quads; note connectivity
-    // array is flipped for the two hexes
+  result = mbImpl->create_element(MBQUAD, &tmp_verts[0], 4, quad2); RR;
+  
+    // now make two inner hexes; note connectivity array is flipped for the two hexes
   MBEntityHandle new_hexes[2];
   result = mbImpl->create_element(MBHEX, &verts[0], 8, new_hexes[0]); RR;
+  result = mbImpl->create_element(MBHEX, &tmp_verts[0], 8, new_hexes[1]); RR;
+
+    // by definition, quad1 is adj to new_hexes[0]
   result = mbImpl->add_adjacencies(quad1, &new_hexes[0], 1, false); RR;
-  
-    // reverse the connectivities for the 2nd hex
-  std::reverse(verts.begin(), verts.begin()+4);
-  std::reverse(verts.begin()+4, verts.end());
-  result = mbImpl->create_element(MBHEX, &verts[0], 8, new_hexes[1]); RR;
   result = mbImpl->add_adjacencies(quad2, &new_hexes[1], 1, false); RR;
 
+    // not sure for this one, should be opposite sense with quad
+  int side_no, sense, offset;
+  result = mbImpl->side_number(*hexes.begin(), quad1, side_no, sense, offset); RR;
+  if (sense == 1) {
+    result = mbImpl->add_adjacencies(quad1, &(*hexes.begin()), 1, false); RR;
+  }
+  else {
+    result = mbImpl->add_adjacencies(quad2, &(*hexes.begin()), 1, false); RR;
+  }
+
   if (debug_ap) ((MBCore*)mbImpl)->check_adjacencies();
 
     // now update the dual
@@ -2644,7 +2662,10 @@
 MBErrorCode DualTool::fsr_get_fourth_quad(std::vector<MBEntityHandle> *connects,
                                           std::vector<MBEntityHandle> *side_quads) 
 {
-    // given the first three quad connectivities in ordered vectors, get the fourth
+    // given the first three quad connectivities in ordered vectors, get the fourth,
+    // 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));
@@ -2666,10 +2687,18 @@
     // 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][0];
-    connects[3][0] = connects[3][1];
-    connects[3][1] = dum;
+    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;
   for (int i = 0; i < 4; i++) {

Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp	2007-08-20 14:08:44 UTC (rev 1246)
+++ MOAB/trunk/MBCore.cpp	2007-08-23 12:18:54 UTC (rev 1247)
@@ -2489,6 +2489,8 @@
     }
 
     else {
+      if (TYPE_FROM_HANDLE(this_ent) == MBENTITYSET) continue;
+      
         // get adjacencies for this entity
       MBRange adjs;
       for (int dim = 0; dim <= 3; dim++) {

Modified: MOAB/trunk/tools/qvdual/DrawDual.cpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.cpp	2007-08-20 14:08:44 UTC (rev 1246)
+++ MOAB/trunk/tools/qvdual/DrawDual.cpp	2007-08-23 12:18:54 UTC (rev 1247)
@@ -61,6 +61,8 @@
 
 #define MBI vtkMOABUtils::mbImpl
 #define RR if (MB_SUCCESS != result) return result
+#define SWAP(a,b) {MBEntityHandle tmp_ent = a; a = b; b = tmp_ent;}
+
 vtkCellPicker *DrawDual::dualPicker = NULL;
 
 MBTag DrawDual::dualCurveTagHandle = 0;
@@ -220,10 +222,6 @@
 
       if (!picked_ents.empty()) {
           // now update the highlighted polydata
-        gDrawDual->update_high_polydatas();
-
-        gDrawDual->secondLastPickedEnt = gDrawDual->lastPickedEnt;
-        gDrawDual->lastPickedEnt = *picked_ents.begin();
       }
 
       rwi->EndPickCallback();
@@ -341,6 +339,8 @@
 
       gDrawDual->secondLastPickedEnt = gDrawDual->lastPickedEnt;
       gDrawDual->lastPickedEnt = picked_ent;
+
+      gDrawDual->update_high_polydatas();
     }
   }
 }
@@ -425,29 +425,39 @@
 }
 
 bool DrawDual::draw_dual_surfs(MBRange &dual_surfs,
-                               const bool use_offsets) 
+                               const bool /*use_offsets*/) 
 {
   MBErrorCode success = MB_SUCCESS;
   int offset = 0;
   for (MBRange::reverse_iterator rit = dual_surfs.rbegin(); rit != dual_surfs.rend(); rit++) {
-    MBErrorCode tmp_success = draw_dual_surf(*rit, offset);
+    MBEntityHandle dum_handle = 0;
+    MBErrorCode tmp_success = MBI->tag_get_data(dualSurfaceTagHandle, &(*rit), 1, 
+                                           &dum_handle);
+    if (MB_TAG_NOT_FOUND == tmp_success || dum_handle == 0) continue;
+  
+    tmp_success = draw_dual_surf(*rit, offset);
     if (MB_SUCCESS != tmp_success) success = tmp_success;
-    if (use_offsets) offset++;
+      // if (use_offsets) offset++;
   }
   
   return (MB_SUCCESS == success ? true : false);
 }
 
 bool DrawDual::draw_dual_surfs(std::vector<MBEntityHandle> &dual_surfs,
-                               const bool use_offsets) 
+                               const bool /*use_offsets*/) 
 {
   MBErrorCode success = MB_SUCCESS;
   int offset = 0;
   for (std::vector<MBEntityHandle>::reverse_iterator vit = dual_surfs.rbegin();
        vit != dual_surfs.rend(); vit++) {
-    MBErrorCode tmp_success = draw_dual_surf(*vit, offset);
+    MBEntityHandle dum_handle = 0;
+    MBErrorCode tmp_success = MBI->tag_get_data(dualSurfaceTagHandle, &(*vit), 1, 
+                                           &dum_handle);
+    if (MB_TAG_NOT_FOUND == tmp_success || dum_handle == 0) continue;
+  
+    tmp_success = draw_dual_surf(*vit, offset);
     if (MB_SUCCESS != tmp_success) success = tmp_success;
-    if (use_offsets) offset++;
+      //if (use_offsets) offset++;
   }
   
   return (MB_SUCCESS == success ? true : false);
@@ -465,8 +475,17 @@
   
   this_gw.sheetDiagram->show();
 
+    // get the cells and vertices on this dual surface
+  MBRange dcells, dedges, dverts, face_verts, loop_edges;
+  MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
+                                                   &dverts, &face_verts, &loop_edges);
+  if (MB_SUCCESS != result) return result;
+
+  if (dcells.empty() || dedges.empty() || dverts.empty()) return MB_FAILURE;
+  
     // 1. gather/construct data for graphviz
-  MBErrorCode success = construct_graphviz_data(dual_surf);
+  MBErrorCode success = construct_graphviz_data(dual_surf, dcells, dedges, dverts, 
+                                                face_verts, loop_edges);
   if (MB_SUCCESS != success) return success;
 
 
@@ -479,7 +498,8 @@
   }
 //  neato_init_graph(this_gw.gvizGraph);
   if (useGraphviz) gvLayout(gvContext(), this_gw.gvizGraph, "neato");
-  else smooth_dual_surf(dual_surf);
+  else smooth_dual_surf(dual_surf, dcells, dedges, dverts, 
+                        face_verts, loop_edges);
   
   if (my_debug) {
     std::cout << "After layout, before vtk:" << std::endl;
@@ -502,7 +522,7 @@
 
     // 5. generate "other sheet" labels
   vtkPolyData *new_pd;
-  MBErrorCode result = label_other_sheets(dual_surf, pd, new_pd);
+  result = label_other_sheets(dual_surf, pd, new_pd);
   if (MB_SUCCESS != result) return result;
 
   pd->Update();
@@ -648,8 +668,8 @@
             avg_pos1[1] += dum_pos0[1];
           }
         }
-        avg_pos1[0] = (.2*avg_pos1[0]/(num_connect-2) + .8*avg_pos0[0]);
-        avg_pos1[1] = (.2*avg_pos1[1]/(num_connect-2) + .8*avg_pos0[1]);
+        avg_pos1[0] = (.4*avg_pos1[0]/(num_connect-2) + .6*avg_pos0[0]);
+        avg_pos1[1] = (.4*avg_pos1[1]/(num_connect-2) + .6*avg_pos0[1]);
         get_graph_points(&(*rit), 1, true, dual_surf, &tc_points[0]);
         set_graphpoint_pos(tc_points[0], avg_pos1);
       }
@@ -724,13 +744,13 @@
         }
       
         get_graph_points(&edges[0], 4, true, dual_surf, edge_pts);
-        dum_pos0[0] = CENT_X; dum_pos0[1] = CENT_Y+.5*RAD_PTS;
-        dum_pos1[0] = CENT_X; dum_pos1[1] = CENT_Y-.5*RAD_PTS;
+        dum_pos0[0] = CENT_X; dum_pos0[1] = CENT_Y+RAD_PTS;
+        dum_pos1[0] = CENT_X; dum_pos1[1] = CENT_Y-RAD_PTS;
         set_graphpoint_pos(vert_pts[0], dum_pos0);
         set_graphpoint_pos(vert_pts[1], dum_pos1);
         for (int i = 0; i < 4; i++) {
-          dum_pos0[0] = CENT_X; dum_pos0[1] = (i+1)*SHEET_WINDOW_SIZE/5.0;
-          set_graphpoint_pos(edge_pts[i], dum_pos1);
+          dum_pos0[1] = CENT_Y; dum_pos0[0] = CENT_X + (2*i-3)*2*RAD_PTS/5.0;
+          set_graphpoint_pos(edge_pts[i], dum_pos0);
         }
       }
       else if (3 == chords.size()) {
@@ -1274,10 +1294,13 @@
   pd = get_polydata(this_sdpopup);
   assert(NULL != pd);
     // re-initialize the data, then we're done
-//  pd->Initialize();
+  pd->Initialize();
 }
 
-MBErrorCode DrawDual::construct_graphviz_data(MBEntityHandle dual_surf) 
+MBErrorCode DrawDual::construct_graphviz_data(MBEntityHandle dual_surf,
+                                              MBRange &dcells, MBRange &dedges,
+                                              MBRange &dverts, MBRange &face_verts,
+                                              MBRange &loop_edges) 
 {
     // gather/construct the data for graphviz
 
@@ -1291,17 +1314,9 @@
     if (this_gw.gvizGraph == NULL) return MB_FAILURE;
   }
     
-    // get the cells and vertices on this dual surface
-  MBRange dcells, dedges, dverts, face_verts, loop_edges;
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
-                                                   &dverts, &face_verts, &loop_edges);
-  if (MB_SUCCESS != result) return result;
-
-  if (dcells.empty() || dedges.empty() || dverts.empty()) return MB_FAILURE;
-  
     // for each vertex, allocate a graphviz point if it doesn't already have one
   GVEntity **dvert_gv = new GVEntity*[dverts.size()];
-  result = MBI->tag_get_data(gvEntityHandle, dverts, dvert_gv); RR;
+  MBErrorCode result = MBI->tag_get_data(gvEntityHandle, dverts, dvert_gv); RR;
   Agsym_t *asym_pos = (useGraphviz ? get_asym(dual_surf, 0, "pos") : NULL);
 
   result = construct_graphviz_points(dual_surf, dverts, asym_pos, dvert_gv); RR;
@@ -1313,10 +1328,6 @@
   result = construct_graphviz_edges(dual_surf, dedges, face_verts, asym_pos, 
                                     dvert_gv, dedge_gv); RR;
   
-    // compute the starting positions of the boundary points, and fix them;
-    // has to come after construct_graphviz_edges 'cuz we need edge gventities for 2-pt loops
-  result = compute_fixed_points(dual_surf, dverts, face_verts, loop_edges); RR;
-
   delete [] dvert_gv;
   delete [] dedge_gv;
 
@@ -1540,20 +1551,21 @@
                                            MBRange &face_verts, MBRange &loop_edges) 
 {
   std::vector<std::vector<MBEntityHandle> > loops;
+  MBRange new_face_verts(face_verts);
 
-  while (!face_verts.empty()) {
+  while (!new_face_verts.empty()) {
       // get the next first vertex on the loop
-    MBEntityHandle this_v = *face_verts.begin();
+    MBEntityHandle this_v = *new_face_verts.begin();
     MBEntityHandle first_v = 0, last_v = 0;
     std::vector<MBEntityHandle> loop_vs;
     MBRange temp_face_verts;
 
-    if (face_verts.size() == 2) {
+    if (new_face_verts.size() == 2) {
         // quick way to do this, assuming both vertices are on the loop
-      loop_vs.push_back(*face_verts.begin());
-      loop_vs.push_back(*face_verts.rbegin());
-      temp_face_verts.insert(*face_verts.begin());
-      temp_face_verts.insert(*face_verts.rbegin());
+      loop_vs.push_back(*new_face_verts.begin());
+      loop_vs.push_back(*new_face_verts.rbegin());
+      temp_face_verts.insert(*new_face_verts.begin());
+      temp_face_verts.insert(*new_face_verts.rbegin());
       this_v = first_v;
     }
     
@@ -1573,8 +1585,8 @@
     loops.push_back(loop_vs);
     
       // ok, we've got them all; first, remove them from face_verts
-    MBRange temp_range = face_verts.subtract(temp_face_verts);
-    face_verts.swap(temp_range);
+    MBRange temp_range = new_face_verts.subtract(temp_face_verts);
+    new_face_verts.swap(temp_range);
   }
   
     // now compute vertex coordinates for each loop
@@ -1583,6 +1595,9 @@
     asym_pos = get_asym(dual_surf, 0, "pos");
     asym_pin = get_asym(dual_surf, 0, "pin", "false");
   }
+
+  if (loops.empty()) 
+    return compute_pillow_fixed_points(dual_surf, face_verts, loop_edges);
   
   char tmp_pos[80];
   int loop_num, num_loops = loops.size();
@@ -1676,6 +1691,56 @@
   return MB_SUCCESS;
 }
 
+MBErrorCode DrawDual::compute_pillow_fixed_points(MBEntityHandle dual_surf, 
+                                                  MBRange &face_verts, 
+                                                  MBRange &face_edges) 
+{
+    // find the points we'll call fixed for this sheet
+    // first, get the chords, in an ordered list
+  std::vector<MBEntityHandle> chords;
+  MBErrorCode result = MBI->get_child_meshsets(dual_surf, chords);
+  if (MB_SUCCESS != result) return result;
+
+    // if there are only two, don't bother, they'll get fixed up later
+  if (chords.size() <= 2) return MB_SUCCESS;
+  
+    // if more, get the first two vertices on the first chord, then a 3rd
+    // from another that's not in the 1st set
+  MBEntityHandle dum_verts[3];
+  MBRange tmp_range;
+  result = MBI->get_entities_by_dimension(chords[0], 1, tmp_range); RR;
+  assert(3 < tmp_range.size());
+  const MBEntityHandle *connect;
+  int num_connect;
+  result = MBI->get_connectivity(*tmp_range.begin(), connect, num_connect); RR;
+  face_verts.insert(connect[0]);
+  face_verts.insert(connect[1]);
+  tmp_range.clear();
+  MBRange tmp_verts;
+  result = MBI->get_entities_by_dimension(chords[1], 1, tmp_range); RR;
+  result = MBI->get_adjacencies(tmp_range, 0, false, tmp_verts, MBInterface::UNION); RR;
+  tmp_verts = tmp_verts.subtract(face_verts);
+  assert(!tmp_verts.empty());
+  face_verts.insert(*tmp_verts.begin());
+  
+    // should have 3; put at equal angles round the circle
+//  double PI = acos(-1.0);
+  double dum_pos[9];
+  dum_pos[0] = CENT_X;
+  dum_pos[1] = RAD_PTS;
+  dum_pos[3] = CENT_X - RAD_PTS*cos(PI/6.0);
+  dum_pos[4] = CENT_Y - RAD_PTS*sin(PI/6.0);
+  dum_pos[6] = CENT_X + RAD_PTS*cos(PI/6.0);
+  dum_pos[7] = dum_pos[4];
+  dum_pos[2] = dum_pos[5] = dum_pos[8] = 0.0;
+
+  std::vector<MBEntityHandle> graph_points(face_verts.size());
+  get_graph_points(face_verts, false, dual_surf, (void**) &graph_points[0]);
+  result = MBI->set_coords(&graph_points[0], face_verts.size(), dum_pos); RR;
+  
+  return result;
+}
+
 void DrawDual::get_loop_vertex_pos(unsigned int vert_num, 
                                    unsigned int loop_num, 
                                    unsigned int num_loops, 
@@ -1967,16 +2032,34 @@
   MBErrorCode result = MB_SUCCESS, tmp_result;
   for (std::map<MBEntityHandle,GraphWindows>::iterator mit = surfDrawrings.begin();
        mit != surfDrawrings.end(); mit++) {
-    if (NULL != (*mit).second.sheetDiagram) {
-      if (NULL != drawn_sheets) drawn_sheets->insert((*mit).first);
-      tmp_result = reset_drawing_data((*mit).first);
-      if (MB_SUCCESS != tmp_result) result = tmp_result;
-    }
+    if (NULL != drawn_sheets &&
+        NULL != (*mit).second.sheetDiagram) 
+      drawn_sheets->insert((*mit).first);
+    tmp_result = (*mit).second.reset((*mit).first);
+    if (MB_SUCCESS != tmp_result) result = tmp_result;
   }
   
   return tmp_result;
 }
 
+MBErrorCode DrawDual::GraphWindows::reset(MBEntityHandle dual_surf) 
+{
+  MBErrorCode result = MB_SUCCESS;
+  
+  if (sheetDiagram) {
+    result = gDrawDual->reset_drawing_data(dual_surf);
+    delete sheetDiagram;
+    sheetDiagram = NULL;
+  }
+  
+  if (pickActor) {
+    pickActor->Delete();
+    pickActor = NULL;
+  }
+
+  return result;
+}
+
 MBErrorCode DrawDual::reset_drawing_data(MBEntityHandle dual_surf) 
 {
     // deleting a sheet drawing; reset the data on moab tags so it'll draw right
@@ -2014,7 +2097,7 @@
   result = MBI->get_adjacencies(tcells, 1, false, all_cells, MBInterface::UNION);
   if (MB_SUCCESS != result) return result;
   
-  for (MBRange::iterator rit = all_cells.begin(); rit != all_cells.end(); rit++) {
+  for (MBRange::const_reverse_iterator rit = all_cells.rbegin(); rit != all_cells.rend(); rit++) {
       // get the GVEntity
     GVEntity *gv_ent;
     result = MBI->tag_get_data(gvEntityHandle, &(*rit), 1, &gv_ent);
@@ -2050,18 +2133,31 @@
     // use gvizEdges to tell whether we're an edge or not
   if (0 == dim) {
     if (gvizPoints[index]) {
-      free(gvizPoints[index]);
+      if (useGraphviz)
+        free(gvizPoints[index]);
+      else 
+        MBI->delete_entities((MBEntityHandle*)&gvizPoints[index], 1);
       gvizPoints[index] = NULL;
     }
   }
   else if (1 == dim) {
     vtkEntityIds[index+2] = -1;
     if (gvizEdges[index]) {
-      free(gvizEdges[index]);
+      if (useGraphviz)
+        free(gvizEdges[index]);
+      else {
+        assert(gvizEdges[index]);
+        MBI->delete_entities((MBEntityHandle*)&gvizEdges[index], 1);
+      }
       gvizEdges[index] = NULL;
     }
     if (gvizEdges[index+2]) {
-      free(gvizEdges[index+2]);
+      if (useGraphviz)
+        free(gvizEdges[index+2]);
+      else {
+        assert(gvizEdges[index+2]);
+        MBI->delete_entities((MBEntityHandle*)&gvizEdges[index+2], 1);
+      }
       gvizEdges[index+2] = NULL;
     }
   }
@@ -2101,23 +2197,26 @@
   }
 }
 
-MBErrorCode DrawDual::smooth_dual_surf(MBEntityHandle dual_surf) 
+MBErrorCode DrawDual::smooth_dual_surf(MBEntityHandle dual_surf, 
+                                       MBRange &dcells,
+                                       MBRange &dedges, MBRange &dverts,
+                                       MBRange &face_verts, MBRange &loop_edges) 
 {
-  MBRange all_verts, face_verts;
+    // compute the starting positions of the boundary points, and fix them;
+    // has to come after construct_graphviz_edges 'cuz we need edge gventities for 2-pt loops
+    // copy face_verts 'cuz compute_fixed_points may add face verts for pillow sheets
+  MBErrorCode result = compute_fixed_points(dual_surf, dverts, 
+                                            face_verts, loop_edges); RR;
 
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, NULL, NULL, 
-                                                   &all_verts, &face_verts, NULL);
-  if (MB_SUCCESS != result) return result;
-  
   const int num_its = 10;
   
-  all_verts = all_verts.subtract(face_verts);
-  std::vector<double> new_coords(3*all_verts.size()), old_coords(3*all_verts.size());
+  dverts = dverts.subtract(face_verts);
+  std::vector<double> new_coords(3*dverts.size()), old_coords(3*dverts.size());
   double tmp_coords[12];
   MeshTopoUtil mtu(vtkMOABUtils::mbImpl);
 
-  std::vector<MBEntityHandle> graph_points(all_verts.size());
-  get_graph_points(all_verts, false, dual_surf, (void**) &graph_points[0]);
+  std::vector<MBEntityHandle> graph_points(dverts.size());
+  get_graph_points(dverts, false, dual_surf, (void**) &graph_points[0]);
   
   for (int i = 0; i < num_its; i++) {
       // get starting coords for all verts
@@ -2128,7 +2227,7 @@
     else old_coords.swap(new_coords);
 
     
-    for (unsigned int j = 0; j < all_verts.size(); j++) {
+    for (unsigned int j = 0; j < dverts.size(); j++) {
       MBEntityHandle this_point = graph_points[j];
       
         // get all neighbor verts
@@ -2214,21 +2313,24 @@
     // should only be 2 distinct curves; don't handle all dual curves the same
     // for now, to avoid geometric check
   assert((dual_curves[0] == dual_curves[1] && dual_curves[0] != dual_curves[2]) ||
-         (dual_curves[0] == dual_curves[2]) && dual_curves[0] != dual_curves[1]);
+         (dual_curves[0] == dual_curves[2]) && dual_curves[0] != dual_curves[1] ||
+         (dual_curves[0] == dual_curves[3]) && dual_curves[0] != dual_curves[1]);
   
     // if same curves are next to each other, switch edges
   if (dual_curves[0] == dual_curves[1]) {
-    MBEntityHandle tmp_handle = conn_edges[1];
-    conn_edges[1] = conn_edges[2];
-    conn_edges[2] = tmp_handle;
-    tmp_handle = dual_curves[1];
-    dual_curves[1] = dual_curves[2];
-    dual_curves[2] = tmp_handle;
-    tmp_handle = dual_edges_3d[1];
-    dual_edges_3d[1] = dual_edges_3d[2];
-    dual_edges_3d[2] = tmp_handle;
+    SWAP(conn_edges[1], conn_edges[2]);
+    SWAP(dual_curves[1], dual_curves[2]);
+    SWAP(dual_edges_3d[1], dual_edges_3d[2]);
   }
 
+  else if (dual_curves[1] == dual_curves[2]) {
+    SWAP(conn_edges[0], conn_edges[1]);
+    SWAP(dual_curves[0], dual_curves[1]);
+    SWAP(dual_edges_3d[0], dual_edges_3d[1]);
+  }
+  assert(dual_curves[0] == dual_curves[2] &&
+         dual_curves[1] == dual_curves[3]);
+
     // get connected points & their coords
   for (int i = 0; i < 4; i++) {
     const MBEntityHandle *connect;
@@ -2280,8 +2382,10 @@
   std::map<MBEntityHandle, GraphWindows>::iterator mit;
   
   for (mit = surfDrawrings.begin(); mit != surfDrawrings.end(); mit++) {
-    vtkRenderer *gw_ren = (*mit).second.sheetDiagram->sheet_diagram()->GetRenderWindow()->
-      GetRenderers()->GetFirstRenderer();    
+    vtkRenderer *gw_ren = NULL;
+    if ((*mit).second.sheetDiagram) 
+      gw_ren = (*mit).second.sheetDiagram->sheet_diagram()->GetRenderWindow()->
+        GetRenderers()->GetFirstRenderer();    
     if (gw_ren == this_ren) return (*mit).first;
   }
   

Modified: MOAB/trunk/tools/qvdual/DrawDual.hpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.hpp	2007-08-20 14:08:44 UTC (rev 1246)
+++ MOAB/trunk/tools/qvdual/DrawDual.hpp	2007-08-23 12:18:54 UTC (rev 1247)
@@ -100,15 +100,24 @@
     vtkActor *pickActor;
 
     GraphWindows() : gvizGraph(NULL), sheetDiagram(NULL), pickActor(NULL) {}
+    MBErrorCode reset(MBEntityHandle dual_surf);
   };
   
     //! make sure all dual vertices and edges have graphviz nodes and edges
-  MBErrorCode construct_graphviz_data(MBEntityHandle dual_surf);
+  MBErrorCode construct_graphviz_data(MBEntityHandle dual_surf,
+                                      MBRange &dcells, MBRange &dedges,
+                                      MBRange &dverts, MBRange &face_verts,
+                                      MBRange &loop_edges);
   
     //! given the loop vertices, compute and fix their points
   MBErrorCode compute_fixed_points(MBEntityHandle dual_surf, MBRange &dverts,
                                    MBRange &face_verts, MBRange &loop_edges);
 
+    //! compute fixed points for a pillow sheet
+  MBErrorCode compute_pillow_fixed_points(MBEntityHandle dual_surf, 
+                                          MBRange &face_verts, 
+                                          MBRange &face_edges);
+  
     //! compute the position on the loop, accounting for multiple loops
   void get_loop_vertex_pos(unsigned int vert_num, 
                            unsigned int loop_num, 
@@ -229,7 +238,10 @@
                   MBEntityHandle dual_surf, Agnode_t **points);
 
     //! smooth the points in the dual surface using length-weighted laplacian smoothing
-  MBErrorCode smooth_dual_surf(MBEntityHandle dual_surf);
+  MBErrorCode smooth_dual_surf(MBEntityHandle dual_surf,
+                               MBRange &dcells, MBRange &dedges,
+                               MBRange &dverts, MBRange &face_verts,
+                               MBRange &loop_edges);
   
   MBErrorCode set_graphpoint_pos(void *point, double *pos);
   

Modified: MOAB/trunk/tools/qvdual/uiQVDual.ui.h
===================================================================
--- MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-08-20 14:08:44 UTC (rev 1246)
+++ MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-08-23 12:18:54 UTC (rev 1247)
@@ -733,9 +733,11 @@
 
   DualTool dt(vtkMOABUtils::mbImpl);
 
+  MBErrorCode result = vtkMOABUtils::drawDual->reset_drawn_sheets();
+
     // otherwise, do the AP
   MBEntityHandle quad1, quad2;
-  MBErrorCode result = dt.atomic_pillow(edge, quad1, quad2);
+  result = dt.atomic_pillow(edge, quad1, quad2);
   if (MB_SUCCESS != result) {
     std::cerr << "AP failed." << std::endl;
     return;
@@ -779,10 +781,12 @@
 
   DualTool dt(vtkMOABUtils::mbImpl);
 
+  MBErrorCode result = vtkMOABUtils::drawDual->reset_drawn_sheets();
+
     // get the dual surface containing that 2cell
   MBEntityHandle sheet = dt.get_dual_hyperplane(tcell);
   MBRange chords;
-  MBErrorCode result = vtkMOABUtils::mbImpl->get_child_meshsets(sheet, chords);
+  result = vtkMOABUtils::mbImpl->get_child_meshsets(sheet, chords);
   if (MB_SUCCESS != result) {
     std::cerr << "Couldn't get child dual chords of dual surface." << std::endl;
     return;
@@ -805,13 +809,6 @@
   
     // otherwise, do the -AP
   
-    // reset the drawing for the pillow sheet
-  result = vtkMOABUtils::drawDual->reset_drawing_data(sheet);
-  if (MB_SUCCESS != result) {
-    std::cerr << "Couldn't reset drawing data, exiting." << std::endl;
-    return;
-  }
-
   result = dt.rev_atomic_pillow(sheet, chords);
   if (MB_SUCCESS != result) {
     std::cerr << "-AP failed." << std::endl;




More information about the moab-dev mailing list