#include <iostream>
#include <cstdlib>
#include "MBCore.hpp"
#include "MBRange.hpp"
#include "MBTagConventions.hpp"
Go to the source code of this file.
|
int | compare_edge (const void *a, const void *b) |
|
MBErrorCode | skin_tris (MBInterface *mb, MBRange tris, MBRange &skin_edges) |
|
int | main (int argc, char **argv) |
|
◆ compare_edge()
int compare_edge |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 134 of file SkinMesh.cpp.
138 std::cout <<
"Usage: " << argv[0] <<
" <filename>" << std::endl;
143 MBCore*
mb =
new MBCore();
144 MBErrorCode rval =
mb->load_file( argv[1] );
149 rval =
mb->get_entities_by_type( 0,
MBEDGE, edges );
151 if( !edges.empty() ) std::cout <<
"Warning: deleting all MBEdges" << std::endl;
152 rval =
mb->delete_entities( edges );
161 void*
dim[] = { &two };
162 rval =
mb->get_entities_by_type_and_tag( 0,
MBENTITYSET, &geom_tag,
dim, 1, surf_sets );
166 for( MBRange::iterator i = surf_sets.begin(); i != surf_sets.end(); ++i )
171 rval =
mb->get_entities_by_type( *i,
MBTRI, tris );
180 std::cout <<
"surface has " << skin_edges.size() <<
" skin edges" << std::endl;
183 rval =
mb->delete_entities( skin_edges );
References dim, GEOM_DIMENSION_TAG_NAME, mb, MB_SUCCESS, MB_TYPE_INTEGER, MBEDGE, MBENTITYSET, MBTRI, and skin_tris().
◆ skin_tris()
MBErrorCode skin_tris |
( |
MBInterface * |
mb, |
|
|
MBRange |
tris, |
|
|
MBRange & |
skin_edges |
|
) |
| |
Definition at line 32 of file SkinMesh.cpp.
38 if( !tris.all_of_type(
MBTRI ) )
return MB_FAILURE;
42 MBErrorCode rval =
mb->get_number_entities_by_type( 0,
MBEDGE, n_edges );
46 std::cerr <<
"skin_tris: failed because " << n_edges <<
" edges exist in the MOAB instance" << std::endl;
51 edge* edges =
new edge[3 * tris.size()];
54 for( MBRange::iterator i = tris.begin(); i != tris.end(); ++i )
56 const MBEntityHandle* conn;
57 rval =
mb->get_connectivity( *i, conn, n_verts );
59 if( 3 != n_verts )
return MB_FAILURE;
61 if( conn[0] == conn[1] || conn[1] == conn[2] || conn[2] == conn[0] )
63 std::cerr <<
"skin_tris: degenerate triangle" << std::endl;
68 edges[3 * ii + 0].
v0 = conn[0];
69 edges[3 * ii + 0].
v1 = conn[1];
70 edges[3 * ii + 1].
v0 = conn[1];
71 edges[3 * ii + 1].
v1 = conn[2];
72 edges[3 * ii + 2].
v0 = conn[2];
73 edges[3 * ii + 2].
v1 = conn[0];
78 for(
unsigned int i = 0; i < 3 * tris.size(); ++i )
80 if( edges[i].v0 > edges[i].v1 )
82 MBEntityHandle temp = edges[i].
v0;
83 edges[i].
v0 = edges[i].
v1;
92 for(
unsigned int i = 0; i < 3 * tris.size(); i++ )
96 if( 3 * tris.size() - 1 == i )
98 const MBEntityHandle conn[2] = { edges[i].
v0, edges[i].
v1 };
102 skin_edges.insert(
edge );
106 else if( edges[i].v0 == edges[i + 1].v0 && edges[i].v1 == edges[i + 1].v1 )
110 while( edges[i].v0 == edges[i + 1].v0 && edges[i].v1 == edges[i + 1].v1 )
112 std::cout <<
"find_skin WARNING: non-manifold edge" << std::endl;
113 mb->list_entity( edges[i].v0 );
114 mb->list_entity( edges[i].v1 );
121 const MBEntityHandle conn[2] = { edges[i].
v0, edges[i].
v1 };
125 skin_edges.insert(
edge );
References compare_edge(), mb, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBEDGE, MBTRI, edge::v0, and edge::v1.
Referenced by main().