[MOAB-dev] r5181 - MOAB/trunk/src
iulian at mcs.anl.gov
iulian at mcs.anl.gov
Thu Sep 29 16:08:52 CDT 2011
Author: iulian
Date: 2011-09-29 16:08:52 -0500 (Thu, 29 Sep 2011)
New Revision: 5181
Modified:
MOAB/trunk/src/GeomTopoTool.cpp
Log:
another lesson learned the hard way:
reverting an edge orientation with set_connectivity seems easy
enough.
this code
const EntityHandle * conn2;
int nnodes;
mb->get_connectivity(edge, conn2, nnodes);
EntityHandle newConn[2] = {conn2[1], conn2[0]};
mb->set_connectivity(edge, newConn, 2);
gets what you need. the edge will be reverted!
What I didn't realize was that conn2 changes!!!!
The contents of newConn will be copied in the conn2 memory location!
Even though conn2 is declared const EntityHandle * !
Modified: MOAB/trunk/src/GeomTopoTool.cpp
===================================================================
--- MOAB/trunk/src/GeomTopoTool.cpp 2011-09-29 17:21:31 UTC (rev 5180)
+++ MOAB/trunk/src/GeomTopoTool.cpp 2011-09-29 21:08:52 UTC (rev 5181)
@@ -858,6 +858,8 @@
// we may even have to
// proper care has to be given to the orientation, material to the left!!!
// at some point we may have to reorient triangles, not only edges, for proper definition
+ bool debugFlag = false;
+
Range surface_ents, edge_ents, loop_range;
// most of these should be triangles and quads
@@ -896,6 +898,16 @@
rval = tool.find_skin(surface_ents, 1, edge_ents);
if (MB_SUCCESS != rval)
return rval;
+ if (debugFlag)
+ {
+ std::cout<< "skinning edges: " << edge_ents.size() << "\n";
+ for (Range::iterator it= edge_ents.begin(); it!=edge_ents.end(); it++)
+ {
+ EntityHandle ed=*it;
+ std::cout<< "edge: " << mdbImpl->id_from_handle(ed) << " type:" << mdbImpl->type_from_handle(ed)<< "\n" ;
+ std::cout << mdbImpl->list_entity(ed);
+ }
+ }
std::vector<EntityHandle> edges_loop;
@@ -907,6 +919,11 @@
{
// get the first edge, and start a loop with it
EntityHandle current_edge = pool_of_edges[0];
+ if (debugFlag)
+ {
+ std::cout << "Start current edge: "<< mdbImpl->id_from_handle(current_edge) <<"\n ";
+ std::cout << mdbImpl->list_entity(current_edge);
+ }
// get its triangle / quad and see its orientation
std::vector<EntityHandle> tris;
rval = mdbImpl->get_adjacencies(¤t_edge, 1, 2, false, tris);
@@ -935,8 +952,11 @@
rval = mdbImpl-> set_connectivity(current_edge, nn2, 2);
if (MB_SUCCESS != rval)
return rval;
- start_node = conn2[1]; // or nn2[0]
- next_node = conn2[0];// or nn2[1]
+ start_node = nn2[0]; // or conn2[0] !!! beware: conn2 is modified
+ next_node = nn2[1];// or conn2[1] !!!
+ // reset conectivity of edge
More information about the moab-dev
mailing list