[MOAB-dev] r1471 - MOAB/trunk/tools/qvdual

tautges at mcs.anl.gov tautges at mcs.anl.gov
Fri Dec 14 14:07:07 CST 2007


Author: tautges
Date: 2007-12-14 14:07:07 -0600 (Fri, 14 Dec 2007)
New Revision: 1471

Modified:
   MOAB/trunk/tools/qvdual/DrawDual.cpp
   MOAB/trunk/tools/qvdual/DrawDual.hpp
   MOAB/trunk/tools/qvdual/uiQVDual.ui.h
   MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
   MOAB/trunk/tools/qvdual/vtkMOABUtils.h
Log:
Trying to do a better job of cleaning up vtk data.

Modified: MOAB/trunk/tools/qvdual/DrawDual.cpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.cpp	2007-12-14 20:06:42 UTC (rev 1470)
+++ MOAB/trunk/tools/qvdual/DrawDual.cpp	2007-12-14 20:07:07 UTC (rev 1471)
@@ -78,8 +78,6 @@
 DrawDual::DrawDual(QLineEdit *pickline1, QLineEdit *pickline2) 
     : pickLine1(pickline1), pickLine2(pickline2)
 {
-  dualTool = new DualTool(vtkMOABUtils::mbImpl);
-
     // make sure we have basic tags we need
   MBErrorCode result = MBI->tag_get_handle(DualTool::DUAL_ENTITY_TAG_NAME, 
                                            dualEntityTagHandle);
@@ -121,9 +119,24 @@
 
 DrawDual::~DrawDual() 
 {
-  if (0 != gvEntityHandle)
+  if (0 != gvEntityHandle) {
+    MBRange ents;
+    MBI->get_entities_by_type_and_tag(0, MBVERTEX, &gvEntityHandle,
+                                      NULL, 1, ents, MBInterface::UNION);
+    MBI->get_entities_by_type_and_tag(0, MBEDGE, &gvEntityHandle,
+                                      NULL, 1, ents, MBInterface::UNION);
+    MBI->get_entities_by_type_and_tag(0, MBPOLYGON, &gvEntityHandle,
+                                      NULL, 1, ents, MBInterface::UNION);
+    std::vector<GVEntity*> gvents(ents.size());
+    std::fill(gvents.begin(), gvents.end(), (GVEntity*)NULL);
+    MBErrorCode result = MBI->tag_get_data(gvEntityHandle, ents, &gvents[0]);
+    if (MB_SUCCESS == result) {
+      for (unsigned int i = 0; i < gvents.size(); i++) 
+        delete gvents[i];
+    }
     MBI->tag_delete(gvEntityHandle);
-
+  }
+  
   if (NULL != dualPicker) {
     dualPicker->Delete();
     dualPicker = NULL;
@@ -135,7 +148,6 @@
   }
   
   if (NULL != gDrawDual) gDrawDual = NULL;
-  if (NULL != dualTool) delete dualTool;
 
 }
 
@@ -368,6 +380,8 @@
       mapper->SetInput(pd);
       mit->second.pickActor = vtkActor::New();
       mit->second.pickActor->SetMapper(mapper);
+      pd->FastDelete();
+      mapper->FastDelete();
     }
     else
       vtkPolyData::SafeDownCast(mit->second.pickActor->GetMapper()->GetInput())->Reset();
@@ -409,6 +423,7 @@
       this_style->HighlightProp(gw.pickActor);
     }
   }
+  id_list->FastDelete();
 }
 
 MBEntityHandle DrawDual::get_picked_cell(MBEntityHandle cell_set,
@@ -419,9 +434,9 @@
   MBRange cells;
   MBErrorCode result;
   if (1 == dim)
-    result = dualTool->get_dual_entities(cell_set, NULL, &cells, NULL, NULL, NULL);
+    result = vtkMOABUtils::dualTool->get_dual_entities(cell_set, NULL, &cells, NULL, NULL, NULL);
   else if (2 == dim)
-    result = dualTool->get_dual_entities(cell_set, &cells, NULL, NULL, NULL, NULL);
+    result = vtkMOABUtils::dualTool->get_dual_entities(cell_set, &cells, NULL, NULL, NULL, NULL);
   else
     assert(false);
   
@@ -483,6 +498,9 @@
     this_gw.sheetDiagram->sheet_diagram()->GetRenderWindow()->Render();
     pngw->Write();
   }
+
+  wtif->Delete();
+  pngw->Delete();
   
   return (MB_SUCCESS == success ? true : false);
 }
@@ -540,7 +558,7 @@
 
     // 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, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
                                                    &dverts, &face_verts, &loop_edges);
   if (MB_SUCCESS != result) return result;
 
@@ -606,6 +624,8 @@
     // 6. draw labels for dual surface, points, dual curves
   success = draw_labels(dual_surf, pd, new_pd);
   if (MB_SUCCESS != success) return success;
+  pd->FastDelete();
+  new_pd->FastDelete();
 
     // 7. add a picker
   add_picker(this_ren);
@@ -626,7 +646,7 @@
     // make sure the mid-pt of degenerate blind chord segments is on the correct
     // side of the other chord it splits
   MBRange dcells, dedges, dverts, face_verts, loop_edges;
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
                                                    &dverts, &face_verts, &loop_edges); RR;
   
   MBRange tmp_edges, degen_2cells;
@@ -668,7 +688,7 @@
     if (MB_SUCCESS != result) return result;
 
       // decide whether this sheet is blind or not
-    bool sheet_is_blind = dualTool->is_blind(dual_surf);
+    bool sheet_is_blind = vtkMOABUtils::dualTool->is_blind(dual_surf);
     
       // branch depending on what kind of arrangement we have
     if (adj_2cells.size() == 2 && !sheet_is_blind) {
@@ -679,10 +699,10 @@
       result = MBI->get_adjacencies(adj_2cells, 1, false, dum); RR;
       assert(1 == dum.size());
       MBEntityHandle middle_edge = *dum.begin();
-      MBEntityHandle chord = dualTool->get_dual_hyperplane(middle_edge);
+      MBEntityHandle chord = vtkMOABUtils::dualTool->get_dual_hyperplane(middle_edge);
       assert(0 != chord);
       MBEntityHandle verts[2];
-      result = dualTool->get_opposite_verts(middle_edge, chord, verts); RR;
+      result = vtkMOABUtils::dualTool->get_opposite_verts(middle_edge, chord, verts); RR;
 
         // get the gv points for the four vertices
       void *next_points[2], *points[2];
@@ -840,7 +860,7 @@
           // align them such that chord_edges[0][0] and chord_edges[1][0] do not share a 2cell 
           // on this sheet; arbitrarily choose chord_edges[0][0] to be left-most
         MBEntityHandle shared_2cell = mtu.common_entity(chord_edges[0][0], chord_edges[1][0], 2);
-        if (0 != shared_2cell && dualTool->get_dual_hyperplane(shared_2cell) == dual_surf) {
+        if (0 != shared_2cell && vtkMOABUtils::dualTool->get_dual_hyperplane(shared_2cell) == dual_surf) {
           shared_2cell = chord_edges[0][0];
           chord_edges[0][0] = chord_edges[0][1];
           chord_edges[0][1] = shared_2cell;
@@ -940,7 +960,7 @@
 {
     // get the cells and vertices on this dual surface
   MBRange dcells, dverts, dverts_loop, dedges, dedges_loop;
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, &dcells, &dedges, 
                                                    &dverts, &dverts_loop, &dedges_loop);
   if (MB_SUCCESS != result) return result;
 
@@ -972,6 +992,7 @@
   pd->GetCellData()->AddArray(color_ids);
   pd->GetCellData()->SetScalars(color_ids);
   pd->GetCellData()->SetActiveAttribute("ColorId", 0);
+  color_ids->FastDelete();
 
     // make the 1d cells chord by chord
   std::vector<MBEntityHandle> chords;
@@ -988,7 +1009,7 @@
 
       // get edges in this chord
     MBRange dedges;
-    result = dualTool->get_dual_entities(*vit, NULL, &dedges, NULL, NULL, NULL);
+    result = vtkMOABUtils::dualTool->get_dual_entities(*vit, NULL, &dedges, NULL, NULL, NULL);
     if (MB_SUCCESS != result) return result;
     
       // construct a new polydata, and borrow the points from the sheet's pd
@@ -1009,6 +1030,9 @@
       // now make the 1-cells
     result = make_vtk_cells(dedges, 1, (float) global_id,
                             dual_surf, vert_gv_map, chord_pd, NULL);
+    chord_pd->FastDelete();
+    chord_actor->FastDelete();
+    chord_mapper->FastDelete();
     if (MB_SUCCESS != result) return result;
   }
 
@@ -1201,7 +1225,7 @@
   x_xform = y_xform = 1.0;
   return MB_SUCCESS;
 
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, NULL, NULL, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, NULL, NULL, 
                                                    &face_verts_dum, &face_verts, NULL);
   if (MB_SUCCESS != result) return result;
   
@@ -1282,6 +1306,7 @@
       vtkCoordinate *this_coord = vtkCoordinate::New();
       this_coord->SetCoordinateSystemToWorld();
       this_mapper->SetTransformCoordinate(this_coord);
+      this_coord->FastDelete();
 
       this_mapper->ScalarVisibilityOn();
       this_mapper->SetLookupTable(vtkMOABUtils::lookupTable);
@@ -1293,6 +1318,7 @@
       ee->SetInput(pd);
       this_mapper->SetInput(ee->GetOutput());
       this_mapper->SetInput(pd);
+      ee->FastDelete();
 
       vtkActor2D *this_actor = vtkActor2D::New();
       this_actor->PickableOn();
@@ -1301,6 +1327,8 @@
       this_actor->SetMapper(this_mapper);
       this_actor->GetProperty()->SetLineWidth(2.0);
       this_ren->AddActor(this_actor);
+      this_actor->FastDelete();
+      this_mapper->FastDelete();
     }
     else {
         // the easy route - just make new stuff
@@ -1326,6 +1354,7 @@
       this_actor->PickableOn();
       vtkMOABUtils::propSetMap[this_actor] = dual_surf;
       this_actor->SetMapper(this_mapper);
+      this_mapper->FastDelete();
       this_actor->GetProperty()->SetLineWidth(2.0);
 
       double red, green, blue;
@@ -1354,7 +1383,10 @@
     this_sdpopup->show();
   
     this_ren->ResetCamera();
+    this_ren->FastDelete();
 
+    camera->Delete();
+    
     return;
   }
   
@@ -1637,7 +1669,7 @@
       loop_vs.push_back(this_v);
       temp_face_verts.insert(this_v);
       MBEntityHandle temp_v = this_v;
-      this_v = dualTool->next_loop_vertex(last_v, this_v, dual_surf);
+      this_v = vtkMOABUtils::dualTool->next_loop_vertex(last_v, this_v, dual_surf);
       assert(0 != this_v);
       last_v = temp_v;
     }
@@ -1853,6 +1885,7 @@
   text_actor->GetTextProperty()->SetColor(1.0, 1.0, 1.0);
   text_actor->GetTextProperty()->BoldOn();
   ren->AddActor(text_actor);
+  text_actor->FastDelete();
 
     // now vertex ids
 
@@ -1871,6 +1904,9 @@
     // set label actor to be non-pickable
   lda2->PickableOff();
 
+  os_labels->FastDelete();
+  lda2->FastDelete();
+
   return MB_SUCCESS;
 }
 
@@ -1915,7 +1951,7 @@
 
       // create a series of edges in the original pd
     dedges.clear(); dverts.clear(); dverts_loop.clear();
-    tmp_result = dualTool->get_dual_entities(*vit1, NULL, &dedges, &dverts, &dverts_loop, 
+    tmp_result = vtkMOABUtils::dualTool->get_dual_entities(*vit1, NULL, &dedges, &dverts, &dverts_loop, 
                                              NULL);
     if (MB_SUCCESS != tmp_result) {
       result = tmp_result;
@@ -1967,6 +2003,7 @@
   new_pd->GetPointData()->AddArray(id_array);
   new_pd->GetPointData()->SetScalars(id_array);
   new_pd->GetPointData()->SetActiveAttribute("LoopVertexIds", 0);
+  id_array->FastDelete();
 
   return result;
 }
@@ -1982,7 +2019,7 @@
     // get the cells and vertices on this dual surface
   MBRange dcells, dverts, face_verts;
 
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, NULL, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, &dcells, NULL, 
                                                    &dverts, &face_verts, NULL);
   if (MB_SUCCESS != result) return;
   
@@ -2043,6 +2080,11 @@
 
     // set label actor to be non-pickable
   lda->PickableOff();
+
+  label_pd->FastDelete();
+  int_ids->FastDelete();
+  ldm->FastDelete();
+  lda->FastDelete();
 }
 
 MBEntityHandle DrawDual::other_sheet(const MBEntityHandle this_chord,
@@ -2290,7 +2332,7 @@
       result = mtu.get_bridge_adjacencies(this_point, 1, 0, nverts); RR;
       if (!(4 == nverts.size() || 3 == nverts.size())) {
         std::cerr << "Smoothing sheet failed; dumping file." << std::endl;
-        dualTool->delete_whole_dual();
+        vtkMOABUtils::dualTool->delete_whole_dual();
         MBEntityHandle save_set;
         MBErrorCode result = vtkMOABUtils::mbImpl->create_meshset(MESHSET_SET, save_set);
         if (MB_SUCCESS != result) return MB_FAILURE;
@@ -2372,7 +2414,7 @@
 {
     // get vertices on interior of 3d sheet
   MBRange int_verts, face_verts;
-  MBErrorCode result = dualTool->get_dual_entities(dual_surf, NULL, NULL, 
+  MBErrorCode result = vtkMOABUtils::dualTool->get_dual_entities(dual_surf, NULL, NULL, 
                                                    &int_verts, &face_verts, NULL);
   int_verts = int_verts.subtract(face_verts);
   

Modified: MOAB/trunk/tools/qvdual/DrawDual.hpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.hpp	2007-12-14 20:06:42 UTC (rev 1470)
+++ MOAB/trunk/tools/qvdual/DrawDual.hpp	2007-12-14 20:07:07 UTC (rev 1471)
@@ -12,7 +12,6 @@
 #include <map>
 #include <vector>
 
-class DualTool;
 class vtkPolyData;
 class vtkRenderer;
 class vtkCellPicker;
@@ -54,7 +53,6 @@
 private:
 
   static DrawDual *gDrawDual;
-  DualTool *dualTool;
   QLineEdit *pickLine1, *pickLine2;
 
   static bool useGraphviz;

Modified: MOAB/trunk/tools/qvdual/uiQVDual.ui.h
===================================================================
--- MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-12-14 20:06:42 UTC (rev 1470)
+++ MOAB/trunk/tools/qvdual/uiQVDual.ui.h	2007-12-14 20:07:07 UTC (rev 1471)
@@ -77,6 +77,8 @@
   // need to update here, in case we're doing something else which requires moab data
   reader->Update();
 
+  vtkMOABUtils::assign_global_ids();
+  
   vtkMOABUtils::update_display(reader->GetOutput());
   
     // compute dual, if requested
@@ -106,8 +108,7 @@
 
   resetDisplay();
   
-  DualTool dt(vtkMOABUtils::mbImpl);
-  dt.delete_whole_dual();
+  vtkMOABUtils::dualTool->delete_whole_dual();
 
   computeDual = false;
 
@@ -197,8 +198,7 @@
 void uiQVDual::constructDual()
 {
   // tell MOAB to construct the dual first
-  DualTool dt(vtkMOABUtils::mbImpl);
-  MBErrorCode result = dt.construct_hex_dual(NULL, 0);
+  MBErrorCode result = vtkMOABUtils::dualTool->construct_hex_dual(NULL, 0);
 
   redrawDisplay();
   
@@ -215,12 +215,13 @@
   }
 
   MBRange sheet_sets;
-  result = dt.get_dual_hyperplanes(vtkMOABUtils::mbImpl, 2, sheet_sets);
+  result = vtkMOABUtils::dualTool->get_dual_hyperplanes(vtkMOABUtils::mbImpl, 2, sheet_sets);
   if (MB_SUCCESS != result) return;
 
   if (!sheet_sets.empty()) {
       // draw the first sheet
-    if (NULL == vtkMOABUtils::drawDual) vtkMOABUtils::drawDual = new DrawDual(pickline1, pickline2);
+    if (NULL == vtkMOABUtils::drawDual) vtkMOABUtils::drawDual = 
+                                            new DrawDual(pickline1, pickline2);
     vtkMOABUtils::drawDual->draw_dual_surf(*sheet_sets.begin());
   }
 }
@@ -278,7 +279,11 @@
 
     // create a parent tag item
     tags_item = new QListViewItem(TagListView1, tag_name.c_str());
-    tags_item->setOpen(false);
+    if (tag_name != "DUAL_SURFACE")
+      tags_item->setOpen(false);
+    else
+      tags_item->setOpen(true);
+
     itemSetMap[tags_item] = 0;
 
     int i;
@@ -699,7 +704,7 @@
 
   cropToolPopup->show();
     */
-  DualTool(vtkMOABUtils::mbImpl).check_dual_adjs();
+  vtkMOABUtils::dualTool->check_dual_adjs();
 }
 
 
@@ -710,12 +715,11 @@
 
     // get selected sets which are dual surfaces
   MBRange dual_surfs;
-  DualTool dual_tool(vtkMOABUtils::mbImpl);
   MBEntityHandle dum_tag;
   MBErrorCode result;
   for (MBRange::iterator rit = selected.begin(); rit != selected.end(); rit++) {
-    result = vtkMOABUtils::mbImpl->tag_get_data(dual_tool.dualSurface_tag(), &(*rit), 1,
-                                                &dum_tag);
+    result = vtkMOABUtils::mbImpl->tag_get_data(vtkMOABUtils::dualTool->dualSurface_tag(), 
+                                                &(*rit), 1, &dum_tag);
     if (MB_SUCCESS == result && 0 != dum_tag)
       dual_surfs.insert(*rit);
   }
@@ -744,20 +748,19 @@
     return;
   }
 
-  DualTool dt(vtkMOABUtils::mbImpl);
-
   MBErrorCode result = vtkMOABUtils::drawDual->reset_drawn_sheets();
 
     // otherwise, do the AP
   MBEntityHandle quad1, quad2;
-  result = dt.atomic_pillow(edge, quad1, quad2);
+  result = vtkMOABUtils::dualTool->atomic_pillow(edge, quad1, quad2);
   if (MB_SUCCESS != result) {
     std::cerr << "AP failed." << std::endl;
     return;
   }
 
     // get the dual surfaces for those quads
-  MBEntityHandle chord = dt.get_dual_hyperplane(dt.get_dual_entity(quad1));
+  MBEntityHandle chord = vtkMOABUtils::dualTool->
+      get_dual_hyperplane(vtkMOABUtils::dualTool->get_dual_entity(quad1));
   if (0 == chord) return;
   
   std::vector<MBEntityHandle> sheets;
@@ -792,12 +795,10 @@
     return;
   }
 
-  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);
+  MBEntityHandle sheet = vtkMOABUtils::dualTool->get_dual_hyperplane(tcell);
   MBRange chords;
   result = vtkMOABUtils::mbImpl->get_child_meshsets(sheet, chords);
   if (MB_SUCCESS != result) {
@@ -822,7 +823,7 @@
   
     // otherwise, do the -AP
   
-  result = dt.rev_atomic_pillow(sheet, chords);
+  result = vtkMOABUtils::dualTool->rev_atomic_pillow(sheet, chords);
   if (MB_SUCCESS != result) {
     std::cerr << "-AP failed." << std::endl;
     return;
@@ -848,7 +849,6 @@
     return;
   }
 
-  DualTool dt(vtkMOABUtils::mbImpl);
   MeshTopoUtil mtu(vtkMOABUtils::mbImpl);
   if (0 == mtu.common_entity(edge1, edge2, 2)) {
     std::cerr << "Dual edges don't share a common 2-cell." << std::endl;
@@ -864,7 +864,7 @@
   }
 
     // save the quad from edge1, 'cuz the dual sheets/chord might change;
-  MBEntityHandle quad = dt.get_dual_entity(edge1);
+  MBEntityHandle quad = vtkMOABUtils::dualTool->get_dual_entity(edge1);
   assert(0 != quad);
 
     // reset any drawn sheets (will get redrawn later)
@@ -872,7 +872,7 @@
   result = vtkMOABUtils::drawDual->reset_drawn_sheets(&drawn_sheets);
   
     // otherwise, do the FOC
-  result = dt.face_open_collapse(edge1, edge2);
+  result = vtkMOABUtils::dualTool->face_open_collapse(edge1, edge2);
   if (MB_SUCCESS != result) {
     std::cerr << "FOC failed." << std::endl;
     return;
@@ -883,8 +883,8 @@
   redrawDisplay();
 
     // get the dual surfaces for the edges
-  edge1 = dt.get_dual_entity(quad);
-  MBEntityHandle chord = dt.get_dual_hyperplane(edge1);
+  edge1 = vtkMOABUtils::dualTool->get_dual_entity(quad);
+  MBEntityHandle chord = vtkMOABUtils::dualTool->get_dual_hyperplane(edge1);
   MBRange sheets;
   result = vtkMOABUtils::mbImpl->get_parent_meshsets(chord, sheets);
   if (MB_SUCCESS == result) drawn_sheets.merge(sheets);
@@ -916,10 +916,8 @@
     return;
   }
 
-  DualTool dt(vtkMOABUtils::mbImpl);
-
     // save the quad, 'cuz the dual sheets/chord might change
-  MBEntityHandle quad = dt.get_dual_entity(edge);
+  MBEntityHandle quad = vtkMOABUtils::dualTool->get_dual_entity(edge);
   assert(0 != quad);
 
     // reset any drawn sheets (will get redrawn later)
@@ -927,7 +925,7 @@
   MBErrorCode result = vtkMOABUtils::drawDual->reset_drawn_sheets(&drawn_sheets);
   
     // otherwise, do the FS
-  result = dt.face_shrink(edge);
+  result = vtkMOABUtils::dualTool->face_shrink(edge);
   if (MB_SUCCESS != result) {
     std::cerr << "FS failed." << std::endl;
     return;
@@ -938,8 +936,8 @@
   redrawDisplay();
 
     // get the dual surfaces for that edge
-  edge = dt.get_dual_entity(quad);
-  MBEntityHandle chord = dt.get_dual_hyperplane(edge);
+  edge = vtkMOABUtils::dualTool->get_dual_entity(quad);
+  MBEntityHandle chord = vtkMOABUtils::dualTool->get_dual_hyperplane(edge);
   MBRange sheets;
   std::vector<MBEntityHandle> dum_sheets;
   result = vtkMOABUtils::mbImpl->get_parent_meshsets(chord, sheets);
@@ -981,10 +979,9 @@
     return;
   }
 
-  DualTool dt(vtkMOABUtils::mbImpl);
 
     // save the quad, 'cuz the dual sheets/chord might change
-  MBEntityHandle quad = dt.get_dual_entity(edge);
+  MBEntityHandle quad = vtkMOABUtils::dualTool->get_dual_entity(edge);
   assert(0 != quad);
 
     // reset any drawn sheets (will get redrawn later)
@@ -992,7 +989,7 @@
   MBErrorCode result = vtkMOABUtils::drawDual->reset_drawn_sheets(&drawn_sheets);
   
     // otherwise, do the rev FS
-  result = dt.rev_face_shrink(edge);
+  result = vtkMOABUtils::dualTool->rev_face_shrink(edge);
   if (MB_SUCCESS != result) {
     std::cerr << "Reverse FS failed." << std::endl;
     vtkMOABUtils::drawDual->draw_dual_surfs(drawn_sheets);
@@ -1004,8 +1001,8 @@
   std::cerr << "Reverse FS succeeded." << std::endl;
 
     // get the dual surfaces for that edge
-  edge = dt.get_dual_entity(quad);
-  MBEntityHandle chord = dt.get_dual_hyperplane(edge);
+  edge = vtkMOABUtils::dualTool->get_dual_entity(quad);
+  MBEntityHandle chord = vtkMOABUtils::dualTool->get_dual_hyperplane(edge);
   MBRange sheets;
   std::vector<MBEntityHandle> dum_sheets;
   result = vtkMOABUtils::mbImpl->get_parent_meshsets(chord, sheets);
@@ -1096,7 +1093,6 @@
   if (cell_ents.size() < 2) PR("(not a dual entity!)");
 
   MBErrorCode result;
-  DualTool dt(vtkMOABUtils::mbImpl);
   if (cell_ents.size() > 2) {
       // assume it's a dual 2-cell
     result = vtkMOABUtils::mbImpl->get_adjacencies(cell_ents, 1, false, 
@@ -1109,7 +1105,7 @@
     if (picked_ents.empty()) PR("(not a dual 1-cell!)");
   }
   
-  MBEntityHandle dual_ent = dt.get_dual_entity(*picked_ents.begin());
+  MBEntityHandle dual_ent = vtkMOABUtils::dualTool->get_dual_entity(*picked_ents.begin());
   if (0 ==  dual_ent) PR("(no dual entity!)");
   picked_ents.clear();
   picked_ents.insert(dual_ent);
@@ -1125,12 +1121,11 @@
 
     // get selected sets which are dual surfaces
   MBRange dual_surfs;
-  DualTool dual_tool(vtkMOABUtils::mbImpl);
   MBEntityHandle dum_tag;
   MBErrorCode result;
   for (MBRange::iterator rit = selected.begin(); rit != selected.end(); rit++) {
-    result = vtkMOABUtils::mbImpl->tag_get_data(dual_tool.dualSurface_tag(), &(*rit), 1,
-                                                &dum_tag);
+    result = vtkMOABUtils::mbImpl->tag_get_data(vtkMOABUtils::dualTool->dualSurface_tag(), 
+                                                &(*rit), 1, &dum_tag);
     if (MB_SUCCESS == result && 0 != dum_tag)
       dual_surfs.insert(*rit);
   }

Modified: MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
===================================================================
--- MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx	2007-12-14 20:06:42 UTC (rev 1470)
+++ MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx	2007-12-14 20:07:07 UTC (rev 1471)
@@ -54,6 +54,9 @@
   //! static interface pointer, use this when accessing MOAB within vtk
 MBInterface *vtkMOABUtils::mbImpl = NULL;
 
+  //! static interface pointer, use this when accessing MOAB within vtk
+DualTool *vtkMOABUtils::dualTool = NULL;
+
     //! static pointer to the renderer
 vtkRenderer *vtkMOABUtils::myRen = NULL;
   
@@ -137,6 +140,9 @@
     vtkMOABUtils::mbImpl = impl;
   }
 
+  if (NULL == dualTool)
+    dualTool = new DualTool(mbImpl);
+
   MBErrorCode result = create_tags();
   
   make_properties();
@@ -378,12 +384,11 @@
 
     // finally, the sets
   MBRange chord_sets, sheet_sets;
-  DualTool dt(mbImpl);
   
-  result = dt.get_dual_hyperplanes(vtkMOABUtils::mbImpl, 1, chord_sets);
+  result = dualTool->get_dual_hyperplanes(vtkMOABUtils::mbImpl, 1, chord_sets);
   if (MB_SUCCESS != result) return result;
 
-  result = dt.get_dual_hyperplanes(vtkMOABUtils::mbImpl, 2, sheet_sets);
+  result = dualTool->get_dual_hyperplanes(vtkMOABUtils::mbImpl, 2, sheet_sets);
   if (MB_SUCCESS != result) return result;
 
   result = vtkMOABUtils::update_set_actors(chord_sets, vtkMOABUtils::myUG, true, false, true);
@@ -518,7 +523,9 @@
 //      this_mapper->UseLookupTableScalarRangeOn();
 //    }
 
-      ids->Delete();
+    ids->Delete();
+    this_mapper->Delete();
+    ec->Delete();
   }
   
   return result;
@@ -1186,6 +1193,14 @@
   //! get rid of all the vtk drawing stuff
 void vtkMOABUtils::reset_drawing_data() 
 {
+  MBRange these_sets;
+  MBErrorCode result;
+  dualTool->get_dual_hyperplanes(vtkMOABUtils::mbImpl, 1, these_sets);
+  dualTool->get_dual_hyperplanes(vtkMOABUtils::mbImpl, 2, these_sets);
+
+  for (MBRange::iterator rit = these_sets.begin(); rit != these_sets.end(); rit++)
+    vtkMOABUtils::get_actor(*rit)->Delete();
+
   actorProperties.clear();
 
     //! map between props (actor2d's and actors) and sets they represent (0 if no set, 
@@ -1216,7 +1231,7 @@
   if (NULL == mbImpl) return;
   
   //! tag indicating whether a given set is in top contains assy
-  MBErrorCode result = mbImpl->tag_delete(vtkTopContainsTag);
+  result = mbImpl->tag_delete(vtkTopContainsTag);
   if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) 
     std::cout << "Trouble deleting tag." << std::endl;
   vtkTopContainsTag = NULL;
@@ -1248,29 +1263,36 @@
 
 void vtkMOABUtils::assign_global_ids()
 {
-  MBRange ents;
   std::vector<int> ids;
   MBTag gid = globalId_tag();
   MBErrorCode result;
+
+  MBEntityType types[] = {MBVERTEX, MBEDGE, MBQUAD, MBHEX};
   
-  result = mbImpl->get_entities_by_handle(0, ents);
-  if (MB_SUCCESS != result) return;
+  for (unsigned int j = 0; j <= 3; j++) {
+    MBRange ents;
+    result = mbImpl->get_entities_by_type(0, types[j], ents);
+    if (MB_SUCCESS != result) return;
   
-  ids.resize(ents.size());
-  std::fill(ids.begin(), ids.end(), 0);
-  mbImpl->tag_get_data(gid, ents, &ids[0]);
+    ids.resize(ents.size());
+    std::fill(ids.begin(), ids.end(), -1);
+    mbImpl->tag_get_data(gid, ents, &ids[0]);
 
-  bool need_set = false;
+    bool need_set = false;
   
-  unsigned int i = 0;
-  MBRange::iterator rit = ents.begin();
-  
-  for (; i < ids.size(); i++, rit++) {
-    if (0 == ids[i]) {
-      ids[i] = mbImpl->id_from_handle(*rit);
-      need_set = true;
+      // get max id
+    int max_id = -1;
+    for (unsigned int i = 0; i < ids.size(); i++)
+      if (ids[i] > max_id) max_id = ids[i];
+
+    for (unsigned int i = 0; i < ids.size(); i++) {
+      if (ids[i] == 0) {
+        ids[i] = ++max_id;
+        need_set = true;
+      }
     }
+
+    if (need_set) mbImpl->tag_set_data(gid, ents, &ids[0]);
   }
-  
-  if (need_set) mbImpl->tag_set_data(gid, ents, &ids[0]);
+
 }

Modified: MOAB/trunk/tools/qvdual/vtkMOABUtils.h
===================================================================
--- MOAB/trunk/tools/qvdual/vtkMOABUtils.h	2007-12-14 20:06:42 UTC (rev 1470)
+++ MOAB/trunk/tools/qvdual/vtkMOABUtils.h	2007-12-14 20:07:07 UTC (rev 1471)
@@ -24,6 +24,7 @@
 class vtkImplicitFunction;
 class vtkLookupTable;
 class DrawDual;
+class DualTool;
 
 class VTK_EXPORT vtkMOABUtils //: public vtkObject
 {
@@ -35,6 +36,9 @@
     //! static interface pointer, use this when accessing MOAB within vtk
   static MBInterface *mbImpl;
 
+    //! static dualtool ptr
+  static DualTool *dualTool;
+
     //! static pointer to the renderer
   static vtkRenderer *myRen;
 




More information about the moab-dev mailing list