[MOAB-dev] r1417 - in MOAB/trunk: . tools/qvdual
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Wed Nov 21 07:17:58 CST 2007
Author: tautges
Date: 2007-11-21 07:17:58 -0600 (Wed, 21 Nov 2007)
New Revision: 1417
Modified:
MOAB/trunk/DualTool.cpp
MOAB/trunk/DualTool.hpp
MOAB/trunk/tools/qvdual/DrawDual.cpp
MOAB/trunk/tools/qvdual/DrawDual.hpp
MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
Log:
tools/qvdual/DrawDual: putting extra vertices at index 0 on the edge instead of 3, since there aren't any other vertices for edges; also fixed several compile warnings
vtkMOABUtils: a few more 64-bit related corrections.
DualTool:
- better organization of split_pair_nonmanifold
- simpler algorithm for foc_get_addl_ents; just gets all edges connected to half-star faces and split vertex; may not catch case where a face isn't in the half-star
Modified: MOAB/trunk/DualTool.cpp
===================================================================
--- MOAB/trunk/DualTool.cpp 2007-11-20 22:15:01 UTC (rev 1416)
+++ MOAB/trunk/DualTool.cpp 2007-11-21 13:17:58 UTC (rev 1417)
@@ -1653,30 +1653,41 @@
result = foc_delete_dual(split_quads, split_edges, hexes);
if (MB_SUCCESS != result) return result;
- std::vector<MBEntityHandle> merge_ents;
- result = split_pair_nonmanifold(split_quads, split_edges, split_node, hexes,
- other_edges, other_nodes, merge_ents);
+ MBEntityHandle new_quads[2], new_edges[2], new_node;
+ result = split_pair_nonmanifold(split_quads, split_edges, split_node,
+ other_edges, other_nodes,
+ new_quads, new_edges, new_node);
if (MB_SUCCESS != result) return result;
- // put the other entities to be merged on the list
- for (int i = 0; i < 4; i++) merge_ents.push_back(other_edges[i]);
- if (!split_node)
- for (int i = 4; i < 6; i++) merge_ents.push_back(other_edges[i]);
- for (int i = 2; i < 4; i++) merge_ents.push_back(other_nodes[i]);
- if (!split_node)
- for (int i = 4; i < 6; i++) merge_ents.push_back(other_nodes[i]);
+ // now merge entities, the C of foc
+ MBEntityHandle keepit, deleteit;
+#define MIN(a,b) (a < b ? a : b)
+#define MAX(a,b) (a > b ? a : b)
+#define KEEP_DELETE(a,b,c,d) {c = MIN(a,b); d = MAX(a,b);}
+ // first the node(s)
+
+ KEEP_DELETE(other_nodes[2], other_nodes[3], keepit, deleteit);
+ result = mbImpl->merge_entities(keepit, deleteit, false, true); RR;
+
+ if (!split_edges[1]) {
+ KEEP_DELETE(other_nodes[4], other_nodes[5], keepit, deleteit);
+ result = mbImpl->merge_entities(keepit, deleteit, false, true); RR;
+ }
- // now merge them
- for (std::vector<MBEntityHandle>::reverse_iterator vit = merge_ents.rbegin();
- vit != merge_ents.rend(); vit+=2) {
- if (*vit > *(vit+1))
- result = mbImpl->merge_entities(*(vit+1), *vit, false, true);
- else
- result = mbImpl->merge_entities(*vit, *(vit+1), false, true);
- if (MB_SUCCESS != result) return result;
+ // now the edges
+ int limit = (split_edges[1] ? 2 : 3);
+ for (int i = 0; i < limit; i++) {
+ KEEP_DELETE(other_edges[2*i], other_edges[2*i+1], keepit, deleteit);
+ result = mbImpl->merge_entities(keepit, deleteit, false, true); RR;
}
+
+ // now the faces
+ KEEP_DELETE(split_quads[0], split_quads[1], keepit, deleteit);
+ result = mbImpl->merge_entities(keepit, deleteit, false, true); RR;
+ result = mbImpl->merge_entities(new_quads[0], new_quads[1], false, true); RR;
+
if (debug_ap) ((MBCore*)mbImpl)->check_adjacencies();
// reconstruct dual
@@ -1749,7 +1760,7 @@
split_edges[0], other_edges[2+i]); RR;
// last other node is opposite split node on split quad
result = mtu.opposite_entity(split_quads[i], split_node,
- other_nodes[i]); RR;
+ other_nodes[2+i]); RR;
}
other_edges[4] = other_edges[5] = 0;
}
@@ -1801,10 +1812,11 @@
MBErrorCode DualTool::split_pair_nonmanifold(MBEntityHandle *split_quads,
MBEntityHandle *split_edges,
MBEntityHandle split_node,
- MBRange &hexes,
MBEntityHandle *other_edges,
MBEntityHandle *other_nodes,
- std::vector<MBEntityHandle> &merge_ents)
+ MBEntityHandle *new_quads,
+ MBEntityHandle *new_edges,
+ MBEntityHandle &new_node)
{
// if there's a bdy in the star around the shared edge(s), get the quads on that
@@ -1815,106 +1827,101 @@
// get star entities around edges, separated into halves
std::vector<MBEntityHandle> star_dp1[2], star_dp2[2];
result = foc_get_stars(split_quads, split_edges, star_dp1, star_dp2); RR;
-
+
+ //=============== split faces
+
// split manifold each of the split_quads, and put the results on the merge list
- MBEntityHandle new_quads[2];
result = mtu.split_entities_manifold(split_quads, 2, new_quads, NULL); RR;
- for (int i = 0; i < 2; i++) merge_ents.push_back(split_quads[i]);
- for (int i = 0; i < 2; i++) merge_ents.push_back(new_quads[i]);
- // if we're splitting 2 edges, there might be other edges that have the split
- // node; also need to know which side they're on
- MBRange addl_ents[2];
- if (split_node) {
- result = foc_get_addl_ents(star_dp1, star_dp2, split_node, addl_ents); RR;
+ // make ranges of faces which need to be explicitly adj to old, new
+ // edge; faces come from stars and new_quads (which weren't in the stars)
+ MBRange tmp_addl_faces[2];
+ for (int i = 0; i < 2; i++) {
+ std::copy(star_dp1[i].begin(), star_dp1[i].end(),
+ mb_range_inserter(tmp_addl_faces[i]));
+ tmp_addl_faces[0].insert(new_quads[i]);
}
- // also need to put old/new quads on the addl_ents lists so they get adjs to
- // split edges correctly
+ //=============== split 1st edge
+
+ // filter add'l faces to only those adj to split_edges[0]
+ MBRange addl_faces[2] = {tmp_addl_faces[0], tmp_addl_faces[1]};
for (int i = 0; i < 2; i++) {
- addl_ents[0].insert(new_quads[i]);
- addl_ents[1].insert(split_quads[i]);
+ result = mbImpl->get_adjacencies(&split_edges[0], 1, 2, false,
+ addl_faces[i]); RR;
}
- // now split the edges; just add the star ents to addl_ents to pass into
- // split_nonmanifold
- for (int i = 0; i < 2; i++)
- std::copy(star_dp1[i].begin(), star_dp1[i].end(),
- mb_range_inserter(addl_ents[i]));
+ // split the first edge
+ result = mtu.split_entity_nonmanifold(split_edges[0], addl_faces[1],
+ addl_faces[0], new_edges[0]); RR;
+
+ if (!split_edges[1]) return MB_SUCCESS;
+
+ //=============== split 2nd edge
+
+ // filter add'l faces to only those adj to split_edges[1]
+ addl_faces[0] = tmp_addl_faces[0]; addl_faces[1] = tmp_addl_faces[1];
+ for (int i = 0; i < 2; i++) {
+ result = mbImpl->get_adjacencies(&split_edges[1], 1, 2, false,
+ addl_faces[i]); RR;
+ }
- MBEntityHandle new_entity;
- // pass addl_ents[1] in with split edge so that split edge remains
- // on a bdy if it was before
- result = mtu.split_entity_nonmanifold(split_edges[0], addl_ents[1],
- addl_ents[0], new_entity); RR;
- addl_ents[1].insert(split_edges[0]); addl_ents[0].insert(new_entity);
+ // split 2nd edge; again send old edge with addl_ents[1] to keep
+ // on bdy
+ result = mtu.split_entity_nonmanifold(split_edges[1], addl_faces[1],
+ addl_faces[0], new_edges[1]); RR;
+
+ //=============== split node
- if (split_edges[1]) {
- // split 2nd edge; again send old edge with addl_ents[1] to keep
- // on bdy
- result = mtu.split_entity_nonmanifold(split_edges[1], addl_ents[1],
- addl_ents[0], new_entity); RR;
- addl_ents[1].insert(split_edges[1]); addl_ents[0].insert(new_entity);
+ //=============== prepare for splitting 2 edges/1 node part
- // now split the node too
- result = mtu.split_entity_nonmanifold(split_node, addl_ents[1],
- addl_ents[0], new_entity); RR;
+ // if we're splitting 2 edges, there might be other edges that have the split
+ // node; also need to know which side they're on
+ MBRange addl_edges[2];
+ result = foc_get_addl_ents(star_dp1, star_dp2, split_edges,
+ split_node, addl_edges); RR;
+
+ // also, we need to know which of the split/new edges go
+ // with the split/new node; new edges go with side 0, split with 1
+ for (int i = 0; i < 2; i++) {
+ addl_edges[0].insert(new_edges[i]);
+ addl_edges[1].insert(split_edges[i]);
}
+
+ // now split the node too
+ result = mtu.split_entity_nonmanifold(split_node, addl_edges[1],
+ addl_edges[0], new_node); RR;
return MB_SUCCESS;
}
MBErrorCode DualTool::foc_get_addl_ents(std::vector<MBEntityHandle> *star_dp1,
std::vector<MBEntityHandle> *star_dp2,
+ MBEntityHandle *split_edges,
MBEntityHandle split_node,
MBRange *addl_ents)
{
// if we're splitting 2 edges, there might be other edges that have the split
// node; also need to know which side they're on
- // algorithm:
- // - start with star entities on search list
- // - while (search list not empty):
- // . take face off search list, put on result list
- // . get all edge-adj faces also adj to split node
- // . for each of these, if face is not on result list, put on search list
- // - for each entity on result list:
- // . get all entities also adj to split node & put on result list
+ // algorithm: for a given star_dp1 (faces) on a side:
+ // - get all edges adj to all faces -> R1
+ // - get all edges adj to split_node -> R2
+ // - R3 = R1 & R2 (edges connected to split_node & adj to a star face)
+ // - R3 -= split_edges (take split edges off addl_ents)
- MBRange node_faces;
+ MBRange R2;
MeshTopoUtil mtu(mbImpl);
- MBErrorCode result = mbImpl->get_adjacencies(&split_node, 1, 2, false, node_faces); RR;
+ MBErrorCode result = mbImpl->get_adjacencies(&split_node, 1, 1, false, R2); RR;
MBRange::iterator rit;
for (int i = 0; i < 2; i++) {
- MBRange slist, rlist, tmp_list;
- std::copy(star_dp1[i].begin(), star_dp1[i].end(), mb_range_inserter(slist));
- while (!slist.empty()) {
- MBEntityHandle this_ent = slist.pop_front();
- rlist.insert(this_ent);
- tmp_list.clear();
- result = mtu.get_bridge_adjacencies(this_ent, 1, 2, tmp_list); RR;
- tmp_list = tmp_list.intersect(node_faces);
- for (rit = tmp_list.begin(); rit != tmp_list.end(); rit++)
- if (rlist.find(*rit) == rlist.end()) slist.insert(*rit);
- }
- MBEntityHandle tmp_ents[2];
- tmp_ents[0] = split_node;
- MBRange rlist2;
- for (rit = rlist.begin(); rit != rlist.end(); rit++) {
- tmp_list.clear();
- tmp_ents[1] = *rit;
- result = mbImpl->get_adjacencies(tmp_ents, 2, 1, false, tmp_list); RR;
- rlist2.merge(tmp_list);
- tmp_list.clear();
- result = mbImpl->get_adjacencies(tmp_ents, 2, 3, false, tmp_list); RR;
- rlist2.merge(tmp_list);
- }
-
- for (rit = rlist.begin(); rit != rlist.end(); rit++)
- if (std::find(star_dp1[i].begin(), star_dp1[i].end(), *rit) ==
- star_dp1[i].end()) addl_ents[i].insert(*rit);
- addl_ents[i].merge(rlist2);
+ MBRange R1, R3;
+ result = mbImpl->get_adjacencies(&star_dp1[i][0], star_dp1[i].size(), 1, false,
+ R1, MBInterface::UNION); RR;
+ R3 = R1.intersect(R2);
+ R3.erase(split_edges[0]); R3.erase(split_edges[1]);
+ addl_ents[i].merge(R3);
}
return MB_SUCCESS;
Modified: MOAB/trunk/DualTool.hpp
===================================================================
--- MOAB/trunk/DualTool.hpp 2007-11-20 22:15:01 UTC (rev 1416)
+++ MOAB/trunk/DualTool.hpp 2007-11-21 13:17:58 UTC (rev 1417)
@@ -334,15 +334,17 @@
MBErrorCode split_pair_nonmanifold(MBEntityHandle *split_quads,
MBEntityHandle *split_edges,
MBEntityHandle split_node,
- MBRange &hexes,
MBEntityHandle *other_edges,
MBEntityHandle *other_nodes,
- std::vector<MBEntityHandle> &merge_ents);
+ MBEntityHandle *new_quads,
+ MBEntityHandle *new_edges,
+ MBEntityHandle &new_node);
//! for foc's splitting two shared edges, there might be additional entities
//! connected to the split node that also have to be updated
MBErrorCode foc_get_addl_ents(std::vector<MBEntityHandle> *star_dp1,
std::vector<MBEntityHandle> *star_dp2,
+ MBEntityHandle *split_edges,
MBEntityHandle split_node,
MBRange *addl_ents);
Modified: MOAB/trunk/tools/qvdual/DrawDual.cpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.cpp 2007-11-20 22:15:01 UTC (rev 1416)
+++ MOAB/trunk/tools/qvdual/DrawDual.cpp 2007-11-21 13:17:58 UTC (rev 1417)
@@ -622,10 +622,10 @@
// get the gv points for the four vertices
void *next_points[2], *points[2];
- get_graph_points(verts, 2, false, dual_surf, next_points);
+ get_graph_points(verts, 2, dual_surf, next_points);
assert(next_points[0] != NULL && next_points[1] != NULL);
result = MBI->get_connectivity(middle_edge, connect, num_connect); RR;
- get_graph_points(connect, 2, false, dual_surf, points);
+ get_graph_points(connect, 2, dual_surf, points);
assert(points[0] != NULL && points[1] != NULL);
// now space points along the line segment joining the next_points
@@ -643,7 +643,7 @@
// also fix the middle point on this edge
points[0] = NULL;
- get_graph_points(&middle_edge, 1, true, dual_surf, points);
+ get_graph_points(&middle_edge, 1, dual_surf, points);
set_graphpoint_pos(points[0], avg_pos0);
// now fix the other 2 dedges
@@ -658,7 +658,7 @@
const MBEntityHandle *connect2;
result = MBI->get_connectivity(*dum.begin(), connect2, num_connect); RR;
std::vector<void*> tc_points(num_connect);
- get_graph_points(connect2, num_connect, false, dual_surf, &tc_points[0]);
+ get_graph_points(connect2, num_connect, dual_surf, &tc_points[0]);
avg_pos1[0] = avg_pos1[1] = avg_pos1[2] = 0.0;
for (int i = 0; i < num_connect; i++) {
if (connect2[i] != connect[0] && connect2[i] != connect[1]) {
@@ -669,7 +669,7 @@
}
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]);
+ get_graph_points(&(*rit), 1, dual_surf, &tc_points[0]);
set_graphpoint_pos(tc_points[0], avg_pos1);
}
}
@@ -680,7 +680,7 @@
const MBEntityHandle *connect;
result = MBI->get_connectivity(*adj_2cells.begin(), connect, num_connect); RR;
std::vector<void*> tc_points(num_connect);
- get_graph_points(connect, num_connect, false, dual_surf, &tc_points[0]);
+ get_graph_points(connect, num_connect, dual_surf, &tc_points[0]);
get_graphpoint_pos(tc_points[0], dum_pos0);
get_graphpoint_pos(tc_points[1], dum_pos1);
@@ -699,7 +699,7 @@
const MBEntityHandle *connect;
result = MBI->get_connectivity(*dum.begin(), connect, num_connect); RR;
std::vector<void*> tc_points(num_connect);
- get_graph_points(connect, num_connect, false, dual_surf, &tc_points[0]);
+ get_graph_points(connect, num_connect, dual_surf, &tc_points[0]);
avg_pos1[0] = avg_pos1[1] = avg_pos1[2] = 0.0;
for (int i = 0; i < num_connect; i++) {
get_graphpoint_pos(tc_points[i], dum_pos0);
@@ -708,7 +708,7 @@
}
avg_pos1[0] = (.2*avg_pos1[0]/num_connect + .8*avg_pos0[0]);
avg_pos1[1] = (.2*avg_pos1[1]/num_connect + .8*avg_pos0[1]);
- get_graph_points(&(*rit), 1, true, dual_surf, &tc_points[0]);
+ get_graph_points(&(*rit), 1, dual_surf, &tc_points[0]);
set_graphpoint_pos(tc_points[0], avg_pos1);
}
}
@@ -727,7 +727,7 @@
int num_connect;
result = MBI->get_connectivity(*adj_1cells.begin(), connect, num_connect); RR;
void *vert_pts[2], *edge_pts[4];
- get_graph_points(connect, 2, false, dual_surf, vert_pts);
+ get_graph_points(connect, 2, dual_surf, vert_pts);
std::vector<MBEntityHandle> edges;
std::copy(adj_1cells.begin(), adj_1cells.end(), std::back_inserter(edges));
@@ -742,7 +742,7 @@
edges[2] = dum_h;
}
- get_graph_points(&edges[0], 4, true, dual_surf, edge_pts);
+ get_graph_points(&edges[0], 4, dual_surf, edge_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);
@@ -804,9 +804,9 @@
// get the points for the two vertices and the 3 edges
// non-middle chord; get the edges too
void *vert_pts[2], *edge_pts[3];
- get_graph_points(connect, 2, false, dual_surf, vert_pts);
- get_graph_points(&chord_edges[i][0], 2, true, dual_surf, edge_pts);
- get_graph_points(&(*middle_edges.begin()), 1, true, dual_surf, &edge_pts[2]);
+ get_graph_points(connect, 2, dual_surf, vert_pts);
+ get_graph_points(&chord_edges[i][0], 2, dual_surf, edge_pts);
+ get_graph_points(&(*middle_edges.begin()), 1, dual_surf, &edge_pts[2]);
dum_pos0[0] = xpos; xpos += xdelta;
dum_pos2[0] = (xpos < xcent ? xpos-xdelta/2 : xpos+xdelta/2);
@@ -876,7 +876,7 @@
MBErrorCode result = dualTool->get_dual_entities(dual_surf, &dcells, &dedges,
&dverts, &dverts_loop, &dedges_loop);
if (MB_SUCCESS != result) return result;
-
+
// get the GVEntity for each entity
std::map<MBEntityHandle, GVEntity *> vert_gv_map;
@@ -905,7 +905,7 @@
pd->GetCellData()->AddArray(color_ids);
pd->GetCellData()->SetScalars(color_ids);
pd->GetCellData()->SetActiveAttribute("ColorId", 0);
-
+
// make the 1d cells chord by chord
std::vector<MBEntityHandle> chords;
result = MBI->get_child_meshsets(dual_surf, chords);
@@ -1006,7 +1006,7 @@
this_gv = vert_gv_map[this_edge];
assert(this_gv != NULL);
index = this_gv->get_index(dual_surf);
- assert(index >= 0 && this_gv->gvizPoints[index+2] != NULL);
+ assert(index >= 0 && this_gv->gvizPoints[index] != NULL);
cell_points[num_pts++] = this_gv->vtkEntityIds[index+2];
}
}
@@ -1109,12 +1109,12 @@
assert(NULL != gv_verts[i]);
int index = gv_verts[i]->get_index(dual_surf);
assert(index >= 0);
- if (NULL != gv_verts[i]->gvizPoints[index+2] &&
+ if (NULL != gv_verts[i]->gvizPoints[index] &&
gv_verts[i]->vtkEntityIds[index+2] == -1) {
- get_graphpoint_pos(gv_verts[i]->gvizPoints[index+2], dum_pos);
+ get_graphpoint_pos(gv_verts[i]->gvizPoints[index], dum_pos);
if (useGraphviz) {
sprintf(dum_str, "%d,%d", (int)(dum_pos[0]*x_xform), (int)(dum_pos[1]*y_xform));
- agxset(gv_verts[i]->gvizPoints[index+2], asym_pos->index, dum_str);
+ agxset(gv_verts[i]->gvizPoints[index], asym_pos->index, dum_str);
}
gv_verts[i]->vtkEntityIds[index+2] =
@@ -1310,7 +1310,7 @@
GraphWindows &this_gw = surfDrawrings[dual_surf];
if (useGraphviz && NULL == this_gw.gvizGraph) {
// allocate a new graph and create a new window
- sprintf(dum_str, "%d", MBI->id_from_handle(dual_surf));
+ sprintf(dum_str, "%d", (int)MBI->id_from_handle(dual_surf));
this_gw.gvizGraph = agopen(dum_str, AGRAPH);
if (this_gw.gvizGraph == NULL) return MB_FAILURE;
}
@@ -1373,7 +1373,7 @@
int index0 = dvert_gv[0]->get_index(dual_surf);
int index1 = dvert_gv[1]->get_index(dual_surf);
assert(index0 >= 0 && index1 >= 0);
- sprintf(dum_str, "%d", *rit);
+ sprintf(dum_str, "%d", (int)*rit);
// first, check to see if it's degenerate; if so, add a mid-pt
MBRange tmp_edges;
@@ -1382,8 +1382,8 @@
if (useGraphviz) {
// add a graphviz pt for the edge
Agnode_t *mid_gvpt = agnode(this_gw.gvizGraph, dum_str);
- sprintf(dum_str, "%up", MBI->id_from_handle(*rit));
- this_gv->gvizPoints[dsindex+2] = mid_gvpt;
+ sprintf(dum_str, "%up", (int)MBI->id_from_handle(*rit));
+ this_gv->gvizPoints[dsindex] = mid_gvpt;
Agedge_t *this_gved = agedge(this_gw.gvizGraph,
(Agnode_t*)dvert_gv[0]->gvizPoints[index0],
@@ -1397,12 +1397,12 @@
}
else {
// add a vertex for the edge
- sprintf(dum_str, "%up", MBI->id_from_handle(*rit));
+ sprintf(dum_str, "%up", (unsigned int) MBI->id_from_handle(*rit));
MBEntityHandle mid_vert, edge1, edge2, edge_verts[2];
double dum_pos[] = {CENT_X, CENT_Y, 0.0};
result = MBI->create_vertex(dum_pos, mid_vert);
if (MB_SUCCESS != result) return result;
- this_gv->gvizPoints[dsindex+2] = (void*)mid_vert;
+ this_gv->gvizPoints[dsindex] = (void*)mid_vert;
edge_verts[0] = (MBEntityHandle) dvert_gv[0]->gvizPoints[index0];
edge_verts[1] = (MBEntityHandle) mid_vert;
@@ -1490,7 +1490,7 @@
dsindex = -dsindex - 1;
if (useGraphviz) {
// need to make a graphviz point
- sprintf(dum_str, "%u", *rit);
+ sprintf(dum_str, "%u", (unsigned int)*rit);
Agnode_t *this_gvpt = agnode(this_gw.gvizGraph, dum_str);
if (NULL == this_gvpt) return MB_FAILURE;
this_gv->gvizPoints[dsindex] = this_gvpt;
@@ -1654,11 +1654,11 @@
MBErrorCode result = MBI->tag_get_data(gvEntityHandle, &(*rit), 1, &this_gv);
if (MB_SUCCESS != result) continue;
int index = this_gv->get_index(dual_surf);
- assert(index >= 0 && this_gv->gvizPoints[index+2] != NULL);
+ assert(index >= 0 && this_gv->gvizPoints[index] != NULL);
get_loop_vertex_pos(1+2*offset, loop_num, num_loops, .5*angle, xpos_pts, ypos_pts);
if (useGraphviz) {
- Agnode_t *this_gpt = (Agnode_t*)this_gv->gvizPoints[index+2];
+ Agnode_t *this_gpt = (Agnode_t*)this_gv->gvizPoints[index];
sprintf(tmp_pos, "%d,%d!", xpos_pts, ypos_pts);
agxset(this_gpt, asym_pos->index, tmp_pos);
agxset(this_gpt, asym_pin->index, "true");
@@ -1669,7 +1669,7 @@
ND_pinned(this_gpt) = true;
}
else {
- MBEntityHandle this_vert = (MBEntityHandle) this_gv->gvizPoints[index+2];
+ MBEntityHandle this_vert = (MBEntityHandle) this_gv->gvizPoints[index];
double dum_pos[] = {xpos_pts, ypos_pts, 0.0};
result = MBI->set_coords(&this_vert, 1, dum_pos);
if (MB_SUCCESS != result) return result;
@@ -1728,7 +1728,7 @@
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]);
+ get_graph_points(face_verts, dual_surf, (void**) &graph_points[0]);
result = MBI->set_coords(&graph_points[0], face_verts.size(), dum_pos); RR;
return result;
@@ -2135,6 +2135,7 @@
}
else if (1 == dim) {
vtkEntityIds[index+2] = -1;
+ vtkEntityIds[index+3] = -1;
if (gvizEdges[index]) {
if (useGraphviz)
free(gvizEdges[index]);
@@ -2145,13 +2146,18 @@
gvizEdges[index] = NULL;
}
if (gvizEdges[index+2]) {
- if (useGraphviz)
+ if (useGraphviz) {
free(gvizEdges[index+2]);
+ if (gvizPoints[index]) free(gvizPoints[index]);
+ }
else {
assert(gvizEdges[index+2]);
MBI->delete_entities((MBEntityHandle*)&gvizEdges[index+2], 1);
+ if (gvizPoints[index])
+ MBI->delete_entities((MBEntityHandle*)&gvizPoints[index], 1);
}
gvizEdges[index+2] = NULL;
+ gvizPoints[index] = NULL;
}
}
@@ -2159,35 +2165,31 @@
}
void DrawDual::get_graph_points(const MBEntityHandle *ents, const int num_ents,
- const bool extra,
MBEntityHandle dual_surf, void **points)
{
std::vector<GVEntity *> gvs(num_ents);
MBErrorCode result = MBI->tag_get_data(gvEntityHandle, ents, num_ents, &gvs[0]);
if (MB_SUCCESS != result) return;
- int offset = (extra ? 2 : 0);
for (int i = 0; i < num_ents; i++) {
assert(NULL != gvs[i]);
int index = gvs[i]->get_index(dual_surf);
assert(index >= 0 && index < 3);
- points[i] = gvs[i]->gvizPoints[index+offset];
+ points[i] = gvs[i]->gvizPoints[index];
}
}
void DrawDual::get_graph_points(MBRange ents,
- const bool extra,
MBEntityHandle dual_surf, void **points)
{
std::vector<GVEntity *> gvs(ents.size());
MBErrorCode result = MBI->tag_get_data(gvEntityHandle, ents, &gvs[0]);
if (MB_SUCCESS != result) return;
- int offset = (extra ? 2 : 0);
for (unsigned int i = 0; i < ents.size(); i++) {
int index = gvs[i]->get_index(dual_surf);
assert(index >= 0 && index < 3);
- points[i] = gvs[i]->gvizPoints[index+offset];
+ points[i] = gvs[i]->gvizPoints[index];
}
}
@@ -2210,7 +2212,7 @@
MeshTopoUtil mtu(vtkMOABUtils::mbImpl);
std::vector<MBEntityHandle> graph_points(dverts.size());
- get_graph_points(dverts, false, dual_surf, (void**) &graph_points[0]);
+ get_graph_points(dverts, dual_surf, (void**) &graph_points[0]);
for (int i = 0; i < num_its; i++) {
// get starting coords for all verts
@@ -2275,7 +2277,7 @@
// get vertices on sheet drawing for that sheet, and their positions
std::vector<MBEntityHandle> int_points(int_verts.size());
- get_graph_points(int_verts, false, dual_surf, (void**) &int_points[0]);
+ get_graph_points(int_verts, dual_surf, (void**) &int_points[0]);
std::vector<double> point_coords(3*int_verts.size());
result = MBI->get_coords(&int_points[0], int_points.size(),
&point_coords[0]); RR;
Modified: MOAB/trunk/tools/qvdual/DrawDual.hpp
===================================================================
--- MOAB/trunk/tools/qvdual/DrawDual.hpp 2007-11-20 22:15:01 UTC (rev 1416)
+++ MOAB/trunk/tools/qvdual/DrawDual.hpp 2007-11-21 13:17:58 UTC (rev 1417)
@@ -245,11 +245,9 @@
MBErrorCode get_graphpoint_pos(void *point, double *pos);
void get_graph_points(const MBEntityHandle *ents, const int gnum_ents,
- const bool extra,
MBEntityHandle dual_surf, void **points);
void get_graph_points(MBRange ents,
- const bool extra,
MBEntityHandle dual_surf, void **points);
//! given a renderer, return the sheet that this renderer renders
Modified: MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx
===================================================================
--- MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx 2007-11-20 22:15:01 UTC (rev 1416)
+++ MOAB/trunk/tools/qvdual/vtkMOABUtils.cxx 2007-11-21 13:17:58 UTC (rev 1417)
@@ -148,7 +148,7 @@
{
MBErrorCode result = vtkMOABUtils::mbImpl->tag_get_handle(vtkCellTagName, vtkCellTag);
if (MB_TAG_NOT_FOUND == result) {
- int def_val = -1;
+ vtkIdType def_val = -1;
result = vtkMOABUtils::mbImpl->tag_create(vtkCellTagName, sizeof(vtkIdType), MB_TAG_DENSE,
vtkCellTag, &def_val);
}
@@ -156,14 +156,14 @@
result = vtkMOABUtils::mbImpl->tag_get_handle(vtkTopContainsTagName, vtkTopContainsTag);
if (MB_TAG_NOT_FOUND == result) {
unsigned char def_val = 0x0;
- result = vtkMOABUtils::mbImpl->tag_create(vtkTopContainsTagName, 1, MB_TAG_BIT,
+ result = vtkMOABUtils::mbImpl->tag_create(vtkTopContainsTagName, sizeof(unsigned char), MB_TAG_BIT,
vtkTopContainsTag, &def_val);
}
result = vtkMOABUtils::mbImpl->tag_get_handle(vtkTopParentTagName, vtkTopParentTag);
if (MB_TAG_NOT_FOUND == result) {
unsigned char def_val = 0x0;
- result = vtkMOABUtils::mbImpl->tag_create(vtkTopParentTagName, 1, MB_TAG_BIT,
+ result = vtkMOABUtils::mbImpl->tag_create(vtkTopParentTagName, sizeof(unsigned char), MB_TAG_BIT,
vtkTopParentTag, &def_val);
}
More information about the moab-dev
mailing list