const unsigned* TopologyInfo::side_vertices( EntityTopology topo, unsigned dim, unsigned side, unsigned& count_out, MsqError& err ) { static const unsigned all[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; const unsigned* result; if (dim != 0 && dim == dimension(topo)) { count_out = corners( topo ); result = all; } else if (dim == 1) { count_out = 2; result = edge_vertices( topo, side, err ); } else if( dim == 2) { result = face_vertices( topo, side, count_out, err ); } else { MSQ_SETERR(err)(MsqError::INVALID_ARG); count_out = 0; result = 0; } return result; }
const unsigned* TopologyInfo::side_vertices( EntityTopology topo, unsigned dim, unsigned side, unsigned& count_out ) { static const unsigned all[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; const unsigned* result; if (dim != 0 && dim == dimension(topo)) { count_out = corners( topo ); result = all; } else if (dim == 1) { count_out = 2; result = edge_vertices( topo, side ); } else if( dim == 2) { result = face_vertices( topo, side, count_out ); } else { result = 0; } return result; }
unsigned TopologyInfo::find_face( EntityTopology topo, const unsigned* side_vertices, unsigned num_vertices, bool& reversed_out, MsqError& err ) { if (dimension(topo) <= 2) { MSQ_SETERR(err)(MsqError::INVALID_ARG,"Invalid element dimension"); return (unsigned)-1; } for (unsigned i = 0; i < faces(topo); ++i) { unsigned j, n, offset; const unsigned* face = face_vertices( topo, i, n, err ); MSQ_ERRZERO(err); if (n != num_vertices) continue; for (offset = 0; offset < num_vertices; ++offset) if (face[offset] == side_vertices[0]) break; if (offset == num_vertices) continue; for (j = 1; j < num_vertices; ++j) if (side_vertices[j] != face[(offset + j)%num_vertices]) break; if (j == num_vertices) { reversed_out = false; return i; } for (j = 1; j < num_vertices; ++j) if (side_vertices[j] != face[(offset + num_vertices - j)%num_vertices]) break; if (j == num_vertices) { reversed_out = true; return i; } } MSQ_SETERR(err)(MsqError::INVALID_ARG,"No such face"); return (unsigned)-1; }