10 if( MB_SUCCESS != result ) return result
27 result = mbImpl->get_entities_by_type( 0,
MBVERTEX, all_verts );
RR;
36 result = compute_nodes( 1 );
RR;
37 result = compute_nodes( 2 );
RR;
38 result = compute_nodes( 3 );
RR;
41 std::vector< EntityHandle > sphere_hexes, interstic_hexes;
42 result = build_hexes( sphere_hexes, interstic_hexes );
RR;
44 result = mbImpl->tag_delete( subdivVerticesTag );
RR;
57 result = mbImpl->add_entities( *hex_set, &sphere_hexes[0], sphere_hexes.size() );
RR;
58 result = mbImpl->add_entities( *hex_set, &interstic_hexes[0], interstic_hexes.size() );
RR;
70 ErrorCode result = mbImpl->get_entities_by_dimension( 0,
dim, these_ents );
RR;
71 assert( mbImpl->type_from_handle( *these_ents.
begin() ) == the_types[
dim] &&
72 mbImpl->type_from_handle( *these_ents.
rbegin() ) == the_types[
dim] );
76 double avg_pos[3], vert_pos[12], new_vert_pos[12], new_new_vert_pos[3];
77 double radii[4], unitv[3];
86 result = mbImpl->get_connectivity( *rit, connect, num_connect );
RR;
92 result = mbImpl->create_vertex( avg_pos, subdiv_vertices[num_verts] );
RR;
95 result = mbImpl->get_coords( connect, num_connect, vert_pos );
RR;
98 result = mbImpl->tag_get_data( sphereRadiiTag, connect, num_connect, radii );
RR;
101 for(
int i = 0; i < num_verts; i++ )
103 for(
int j = 0; j < 3; j++ )
104 unitv[j] = avg_pos[j] - vert_pos[3 * i + j];
105 double vlength = sqrt( unitv[0] * unitv[0] + unitv[1] * unitv[1] + unitv[2] * unitv[2] );
106 if( vlength < radii[i] )
108 std::cout <<
"Radius too large at vertex " << i << std::endl;
113 for(
int j = 0; j < 3; j++ )
116 for(
int j = 0; j < 3; j++ )
117 new_vert_pos[3 * i + j] = vert_pos[3 * i + j] + radii[i] * unitv[j];
120 ErrorCode tmp_result = mbImpl->create_vertex( &new_vert_pos[3 * i], subdiv_vertices[i] );
121 if(
MB_SUCCESS != tmp_result ) result = tmp_result;
128 for(
int i = 0; i < num_verts; i++ )
130 for(
int j = 0; j < 3; j++ )
131 new_new_vert_pos[j] = .5 * ( vert_pos[3 * i + j] + new_vert_pos[3 * i + j] );
133 result = mbImpl->create_vertex( new_new_vert_pos, subdiv_vertices[num_verts + 1 + i] );
137 result = mbImpl->tag_set_data( subdivVerticesTag, &( *rit ), 1, subdiv_vertices );
RR;
144 std::vector< EntityHandle >& interstic_hexes )
152 result = subdivide_tet( *vit, sphere_hexes, interstic_hexes );
RR;
159 std::vector< EntityHandle >& sphere_hexes,
160 std::vector< EntityHandle >& interstic_hexes )
166 std::vector< EntityHandle > tet_conn;
167 ErrorCode result = mbImpl->get_connectivity( &tet, 1, tet_conn );
RR;
172 std::vector< EntityHandle > ents;
175 result = mbImpl->get_adjacencies( &tet, 1,
dim,
false, ents );
RR;
178 ents.push_back( tet );
181 for( std::vector< EntityHandle >::iterator vit = ents.begin(); vit != ents.end(); ++vit )
183 result = retrieve_subdiv_verts( tet, *vit, &tet_conn[0],
dim, subdiv_verts );
RR;
234 #define CV( a ) tet_conn[a]
235 #define ESV( a, b ) subdiv_verts[(a)*9 + ( b )]
236 #define FSV( a, b ) subdiv_verts[54 + (a)*9 + ( b )]
237 #define TSV( a, b ) subdiv_verts[90 + (a)*9 + ( b )]
252 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
253 interstic_hexes.push_back( this_hex );
264 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
265 interstic_hexes.push_back( this_hex );
276 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
277 interstic_hexes.push_back( this_hex );
289 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
290 interstic_hexes.push_back( this_hex );
301 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
302 interstic_hexes.push_back( this_hex );
313 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
314 interstic_hexes.push_back( this_hex );
326 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
327 interstic_hexes.push_back( this_hex );
338 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
339 interstic_hexes.push_back( this_hex );
350 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
351 interstic_hexes.push_back( this_hex );
363 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
364 interstic_hexes.push_back( this_hex );
375 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
376 interstic_hexes.push_back( this_hex );
387 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
388 interstic_hexes.push_back( this_hex );
402 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
403 sphere_hexes.push_back( this_hex );
414 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
415 sphere_hexes.push_back( this_hex );
426 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
427 sphere_hexes.push_back( this_hex );
438 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
439 sphere_hexes.push_back( this_hex );
451 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
452 sphere_hexes.push_back( this_hex );
463 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
464 sphere_hexes.push_back( this_hex );
475 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
476 sphere_hexes.push_back( this_hex );
487 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
488 sphere_hexes.push_back( this_hex );
500 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
501 sphere_hexes.push_back( this_hex );
512 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
513 sphere_hexes.push_back( this_hex );
524 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
525 sphere_hexes.push_back( this_hex );
536 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
537 sphere_hexes.push_back( this_hex );
549 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
550 sphere_hexes.push_back( this_hex );
561 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
562 sphere_hexes.push_back( this_hex );
573 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
574 sphere_hexes.push_back( this_hex );
585 result = mbImpl->create_element(
MBHEX, this_connect, 8, this_hex );
RR;
586 sphere_hexes.push_back( this_hex );
601 if( tet == this_ent )
603 result = mbImpl->tag_get_data( subdivVerticesTag, &this_ent, 1, &subdiv_verts[90] );
609 std::vector< EntityHandle > this_conn;
610 result = mbImpl->get_connectivity( &this_ent, 1, this_conn );
RR;
613 std::vector< int > conn_tet_indices( this_conn.size() );
614 for(
size_t i = 0; i < this_conn.size(); ++i )
615 conn_tet_indices[i] = std::find( tet_conn, tet_conn + 4, this_conn[i] ) - tet_conn;
616 int sense, side_no, offset;
617 int success =
CN::SideNumber(
MBTET, &conn_tet_indices[0], this_conn.size(),
dim, side_no, sense, offset );
618 if( -1 == success )
return MB_FAILURE;
622 EntityHandle* subdiv_start = &subdiv_verts[( (
dim - 1 ) * 6 + side_no ) * 9];
625 result = mbImpl->tag_get_data( subdivVerticesTag, &this_ent, 1, subdiv_start );
628 #define SWITCH( a, b ) \
630 EntityHandle tmp_handle = a; \
632 ( b ) = tmp_handle; \
637 if( offset != 0 || sense == -1 )
639 SWITCH( subdiv_start[0], subdiv_start[1] );
640 SWITCH( subdiv_start[3], subdiv_start[4] );
647 std::rotate( subdiv_start, subdiv_start + offset, subdiv_start + 3 );
648 std::rotate( subdiv_start + 4, subdiv_start + 4 + offset, subdiv_start + 7 );
653 SWITCH( subdiv_start[1], subdiv_start[2] );
654 SWITCH( subdiv_start[5], subdiv_start[6] );