20 #pragma warning( disable : 4786 )
40 : mMB( MB ), mHONodeAddedRemoved( function_object )
56 unsigned char( &this_map )[8][8] =
mNodeMap[i];
60 unsigned char x = canon_map.
conn[j][0];
61 unsigned char y = canon_map.
conn[j][1];
62 this_map[x][y] = num_node;
63 this_map[y][x] = num_node;
72 const bool mid_edge_nodes,
73 const bool mid_face_nodes,
74 const bool mid_volume_nodes )
78 return convert(
entities, mid_edge_nodes, mid_face_nodes, mid_volume_nodes );
82 const bool mid_edge_nodes,
83 const bool mid_face_nodes,
84 const bool mid_volume_nodes )
97 for( p_iter =
entities.const_pair_begin(); p_iter !=
entities.const_pair_end(); ++p_iter )
101 while( h <= p_iter->second )
117 rval =
convert_sequence( elemseq, h, last, mid_edge_nodes, mid_face_nodes, mid_volume_nodes );
132 bool mid_volume_nodes )
138 switch( seq->
type() )
143 mid_face_nodes =
false;
144 mid_volume_nodes =
false;
148 mid_volume_nodes =
false;
163 if( mid_volume_nodes ) nodes_per_elem += 1;
217 unsigned char marked = 0;
263 EntityType this_type = seq->
type();
271 int new_node_index = num_corner_nodes;
281 for( ; element < end_element; element += nodes_per_element )
284 double tmp_coords[3], sum_coords[3] = { 0, 0, 0 };
286 for(
int i = 0; i < num_corner_nodes; i++ )
288 seq_manager->
find( element[i], eseq );
289 static_cast< VertexSequence*
>( eseq )->get_coordinates( element[i], tmp_coords[0], tmp_coords[1],
291 sum_coords[0] += tmp_coords[0];
292 sum_coords[1] += tmp_coords[1];
293 sum_coords[2] += tmp_coords[2];
295 sum_coords[0] /= num_corner_nodes;
296 sum_coords[1] /= num_corner_nodes;
297 sum_coords[2] /= num_corner_nodes;
312 EntityType this_type = seq->
type();
327 std::vector< EntityHandle > adjacent_entities( 4 );
329 double tmp_coords[3];
332 for( ; element < end_element; element += nodes_per_element )
335 for(
int i = 0; i < num_faces; i++ )
338 if( element[i + num_edges + num_vertices] != 0 )
continue;
340 tmp_face_conn[0] = element[entity_faces.
conn[i][0]];
341 tmp_face_conn[1] = element[entity_faces.
conn[i][1]];
342 tmp_face_conn[2] = element[entity_faces.
conn[i][2]];
344 tmp_face_conn[3] = element[entity_faces.
conn[i][3]];
346 tmp_face_conn[3] = 0;
350 if( already_made_node )
352 element[i + num_edges + num_vertices] = already_made_node;
358 double sum_coords[3] = { 0, 0, 0 };
360 for(
int k = 0; k < max_nodes; k++ )
362 seq_manager->
find( tmp_face_conn[k], tmp_sequence );
364 ->get_coordinates( tmp_face_conn[k], tmp_coords[0], tmp_coords[1], tmp_coords[2] );
365 sum_coords[0] += tmp_coords[0];
366 sum_coords[1] += tmp_coords[1];
367 sum_coords[2] += tmp_coords[2];
370 sum_coords[0] /= max_nodes;
371 sum_coords[1] /= max_nodes;
372 sum_coords[2] /= max_nodes;
390 EntityType this_type = seq->
type();
405 std::vector< EntityHandle > adjacent_entities( 32 );
407 double tmp_coords[3];
410 for( ; element < end_element; element += nodes_per_element )
413 for(
int i = 0; i < num_edges; i++ )
416 if( element[i + num_vertices] != 0 )
continue;
418 tmp_edge_conn[0] = element[entity_edges.
conn[i][0]];
419 tmp_edge_conn[1] = element[entity_edges.
conn[i][1]];
423 if( already_made_node )
425 element[i + num_vertices] = already_made_node;
431 double sum_coords[3] = { 0, 0, 0 };
432 seq_manager->
find( tmp_edge_conn[0], tmp_sequence );
434 ->get_coordinates( tmp_edge_conn[0], tmp_coords[0], tmp_coords[1], tmp_coords[2] );
435 sum_coords[0] += tmp_coords[0];
436 sum_coords[1] += tmp_coords[1];
437 sum_coords[2] += tmp_coords[2];
438 seq_manager->
find( tmp_edge_conn[1], tmp_sequence );
440 ->get_coordinates( tmp_edge_conn[1], tmp_coords[0], tmp_coords[1], tmp_coords[2] );
441 sum_coords[0] = ( sum_coords[0] + tmp_coords[0] ) / 2;
442 sum_coords[1] = ( sum_coords[1] + tmp_coords[1] ) / 2;
443 sum_coords[2] = ( sum_coords[2] + tmp_coords[2] ) / 2;
459 std::vector< EntityHandle >& adj_entities )
462 std::vector< EntityHandle > adj_corner1( 32 );
463 std::vector< EntityHandle > adj_corner2( 32 );
474 adj_entities.clear();
475 std::set_intersection( adj_corner1.begin(), adj_corner1.end(), adj_corner2.begin(), adj_corner2.end(),
476 std::back_inserter< std::vector< EntityHandle > >( adj_entities ) );
481 for( std::vector< EntityHandle >::iterator iter = adj_entities.begin(); iter != adj_entities.end(); )
494 int first_node = std::find( conn, conn + conn_size, corner1 ) - conn;
495 int second_node = std::find( conn, conn + conn_size, corner2 ) - conn;
496 if( first_node == conn_size || second_node == conn_size )
497 assert(
"We should always find our nodes no matter what" == NULL );
498 int high_node_index =
mNodeMap[this_type][first_node][second_node];
499 if( conn[high_node_index] != 0 )
return conn[high_node_index];
504 iter = adj_entities.erase( iter );
514 std::vector< EntityHandle > adj_corner[4];
515 int num_nodes = corners[3] == 0 ? 3 : 4;
522 for( i = 0; i < num_nodes; i++ )
526 for( i = 1; i < num_nodes; i++ )
528 adj_entities.clear();
529 std::set_intersection( adj_corner[i - 1].begin(), adj_corner[i - 1].end(), adj_corner[i].begin(),
530 adj_corner[i].end(), std::back_inserter< std::vector< EntityHandle > >( adj_entities ) );
531 adj_corner[i].swap( adj_entities );
533 adj_entities.swap( adj_corner[i - 1] );
538 for( std::vector< EntityHandle >::iterator iter = adj_entities.begin(); iter != adj_entities.end(); )
556 for( k = 0; k < num_nodes; k++ )
557 indexes[k] = std::find( conn, conn + conn_size, corners[k] ) - conn;
564 int* pivot = std::find( indexes, indexes + num_nodes, entity_faces.
conn[k][0] );
565 if( pivot == indexes + num_nodes )
continue;
567 if( pivot != indexes ) std::rotate( indexes, pivot, indexes + num_nodes );
569 if( std::equal( indexes, indexes + num_nodes, entity_faces.
conn[k] ) )
571 if( conn[k + offset] != 0 )
return conn[k + offset];
576 int temp = indexes[1];
577 indexes[1] = indexes[num_nodes - 1];
578 indexes[num_nodes - 1] = temp;
579 if( std::equal( indexes, indexes + num_nodes, entity_faces.
conn[k] ) )
581 if( conn[k + offset] != 0 )
return conn[k + offset];
590 iter = adj_entities.erase( iter );
604 int first_node = std::find( element_conn, element_conn + conn_size, corner_node1 ) - element_conn;
605 int second_node = std::find( element_conn, element_conn + conn_size, corner_node2 ) - element_conn;
606 if( first_node == conn_size || second_node == conn_size )
607 assert(
"We should always find our nodes no matter what" == NULL );
608 int high_node_index =
mNodeMap[this_type][first_node][second_node];
609 element_conn[high_node_index] = center_node;
616 return copy_nodes( src, dst, num_corners, 0, 0 );
625 return copy_nodes( src, dst, num_edges, num_corners, num_corners );
634 return zero_nodes( dst, num_edges, num_corners );
642 unsigned dst_offset = src_offset;
646 return copy_nodes( src, dst, num_faces, src_offset, dst_offset );
656 return zero_nodes( dst, num_faces, dst_offset );
664 unsigned dst_offset = src_offset;
669 return copy_nodes( src, dst, 1, src_offset, dst_offset );
684 unsigned nodes_per_elem,
686 unsigned dst_offset )
688 if( src->
type() != dst->
type() )
return MB_FAILURE;
694 if( !src_conn || !dst_conn )
return MB_FAILURE;
700 for(
EntityID i = 0; i < count; ++i )
702 for(
unsigned j = 0; j < nodes_per_elem; ++j )
703 dst_conn[j + dst_offset] = src_conn[j + src_offset];
704 src_conn += src_stride;
705 dst_conn += dst_stride;
715 if( !dst_conn )
return MB_FAILURE;
718 for(
EntityID i = 0; i < count; ++i )
720 std::fill( dst_conn + offset, dst_conn + offset + nodes_per_elem, 0 );
721 dst_conn += dst_stride;
730 Tag deletable_nodes )
745 return remove_ho_nodes( seq, start, end, count, offset, deletable_nodes );
751 Tag deletable_nodes )
761 return remove_ho_nodes( seq, start, end, count, offset, deletable_nodes );
767 Tag deletable_nodes )
798 int elem_conn_offset,
799 Tag deletable_nodes )
805 std::set< EntityHandle > nodes_processed;
808 for(
int j = 0; j < nodes_per_elem; ++j )
811 const int conn_idx = j + elem_conn_offset;
813 if( array[index] && nodes_processed.insert( array[index] ).second )
817 unsigned char bit = 0x1;
830 EntityType this_type = seq->
type();
840 bool delete_node =
false;
842 assert( dimension != -1 );
847 std::vector< EntityHandle > connectivity;
848 if( dimension == this_dimension &&
side_number == 0 )
864 connectivity.clear();
869 std::vector< EntityHandle > adj_list_1, adj_list_2, adj_entities;
874 std::remove_if( adj_list_1.begin(), adj_list_1.end(),
875 std::bind( std::greater< EntityHandle >(), std::placeholders::_1, low_meshset ) ),
881 for( i = 1; i < connectivity.size(); i++ )
888 std::remove_if( adj_list_2.begin(), adj_list_2.end(),
889 std::bind( std::greater< EntityHandle >(), std::placeholders::_1, low_meshset ) ),
895 adj_entities.clear();
896 std::set_intersection( adj_list_1.begin(), adj_list_1.end(), adj_list_2.begin(), adj_list_2.end(),
897 std::back_inserter< std::vector< EntityHandle > >( adj_entities ) );
899 adj_list_1 = adj_entities;
902 assert( adj_entities.size() );
905 for( i = 0; i < adj_entities.size(); i++ )