46 : thismeshtype(
CURVE ),
mb( impl ), pcomm( comm ), _rset( rset ), _filterghost( filter_ghosts )
48 assert( NULL != impl );
60 if( nverts && nedges && ( !nfaces ) && ( !ncells ) )
62 else if( nverts && !nedges && nfaces && !ncells )
64 else if( nverts && nedges && nfaces && !ncells )
66 else if( nverts && !nedges && !nfaces && ncells )
68 else if( nverts && nedges && !nfaces && ncells )
70 else if( nverts && !nedges && nfaces && ncells )
72 else if( nverts && nedges && nfaces && ncells )
81 { { { 0, 1, 0, 0 }, { 1, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } } },
84 { { { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 1, 0, 1, 0 }, { 0, 0, 0, 0 } } },
87 { { { 0, 1, 1, 0 }, { 1, 1, 1, 0 }, { 1, 1, 1, 0 }, { 0, 0, 0, 0 } } },
90 { { { 0, 0, 0, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 0, 0, 1 } } },
93 { { { 0, 1, 0, 1 }, { 1, 1, 0, 1 }, { 0, 0, 0, 0 }, { 1, 1, 0, 1 } } },
96 { { { 0, 0, 1, 1 }, { 0, 0, 0, 0 }, { 1, 0, 1, 1 }, { 1, 0, 1, 1 } } },
99 { { { 0, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 } } } };
138 Range felems, celems;
144 Range tris, quad, poly;
158 Range tet, pyr, prism, hex, polyhed;
285 v2hv.resize( nv, 0 );
286 sibhvs.resize( ne * 2, 0 );
303 v2he.resize( nv, 0 );
304 sibhes.resize( nf * nepf, 0 );
311 for(
int i = 0; i <
MAXSIZE; i++ )
337 v2hf.resize( nv, 0 );
338 sibhfs.resize( nc * nfpc, 0 );
345 for(
int i = 0; i <
MAXSIZE; i++ )
361 std::cout <<
"start_edge = " << start_edge << std::endl;
362 std::cout <<
"<SIBHVS_EID,SIBHVS_LVID>" << std::endl;
375 std::cout <<
"Entity = " << *i <<
" :: <" << eid[0] <<
"," << lvid[0] <<
">"
377 <<
"<" << eid[1] <<
"," << lvid[1] <<
">" << std::endl;
380 std::cout <<
"<V2HV_EID, V2HV_LVID>" << std::endl;
388 std::cout <<
"Vertex = " << *i <<
" :: <" << eid <<
"," << lvid <<
">" << std::endl;
396 std::cout <<
"start_face = " << start_face << std::endl;
397 std::cout <<
"<SIBHES_FID,SIBHES_LEID>" << std::endl;
402 std::cout <<
"Entity = " << *i;
403 for(
int j = 0; j < nepf; j++ )
408 std::cout <<
" :: <" << sib <<
"," << lid <<
">"
411 std::cout << std::endl;
414 std::cout <<
"<V2HE_FID, V2HE_LEID>" << std::endl;
422 std::cout <<
"Vertex = " << *i <<
" :: <" << fid <<
"," << lid <<
">" << std::endl;
432 std::cout <<
"start_cell = " << start_cell << std::endl;
433 std::cout <<
"<SIBHES_CID,SIBHES_LFID>" << std::endl;
438 std::cout <<
"Entity = " << *i;
439 for(
int j = 0; j < nfpc; j++ )
444 std::cout <<
" :: <" << sib <<
"," << lid <<
">"
447 std::cout << std::endl;
450 std::cout <<
"<V2HF_CID, V2HF_LFID>" << std::endl;
459 if( hf == 0 && (
v2hfs.find( *i ) !=
v2hfs.end() ) )
461 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
462 std::multimap< EntityHandle, HFacet >::iterator >
464 it_hfs =
v2hfs.equal_range( *i );
466 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hfs.first; it != it_hfs.second; ++it )
471 std::cout <<
"Vertex = " << *i <<
" :: <" << cid <<
"," << lid <<
">" << std::endl;
478 std::cout <<
"Vertex = " << *i <<
" :: <" << cid <<
"," << lid <<
">" << std::endl;
490 const unsigned int target_dimension,
491 std::vector< EntityHandle >& target_entities )
497 assert( ( source_dimension <= target_dimension ) || ( source_dimension > target_dimension ) );
505 int adj_possible =
adjMatrix[mindex].
val[source_dimension][target_dimension];
509 if( source_dimension < target_dimension )
513 else if( source_dimension == target_dimension )
530 std::vector< EntityHandle >& adjents,
531 std::vector< int >* lids )
535 assert( ( in_dim >= 0 && in_dim <= 2 ) && ( out_dim > in_dim ) );
543 else if( out_dim == 2 )
547 else if( out_dim == 3 )
553 else if( ( in_dim == 1 ) && ( out_dim == 2 ) )
557 else if( ( in_dim == 1 ) && ( out_dim == 3 ) )
561 else if( ( in_dim == 2 ) && ( out_dim == 3 ) )
572 assert( in_dim >= 1 && in_dim <= 3 );
579 else if( in_dim == 2 )
583 else if( in_dim == 3 )
594 assert( ( in_dim >= 2 && in_dim <= 3 ) && ( out_dim < in_dim ) );
596 if( ( in_dim == 2 ) && ( out_dim == 1 ) )
600 else if( ( in_dim == 3 ) && ( out_dim == 1 ) )
604 else if( ( in_dim == 3 ) && ( out_dim == 2 ) )
616 nedges[0] = edges.
size();
619 else if( faces.
size() && !cells.
size() )
624 else if( cells.
size() )
639 int nv = verts.
size();
640 std::vector< int > is_index( nv + 1 );
641 for(
int i = 0; i < nv + 1; i++ )
650 int index = verts.
index( conn[0] );
651 is_index[index + 1] += 1;
652 index = verts.
index( conn[1] );
653 is_index[index + 1] += 1;
657 for(
int i = 0; i < nv; i++ )
658 is_index[i + 1] = is_index[i] + is_index[i + 1];
661 std::vector< EntityHandle > v2hv_map_eid( 2 * edges.
size() );
662 std::vector< int > v2hv_map_lvid( 2 * edges.
size() );
670 for(
int j = 0; j < 2; j++ )
672 int v = verts.
index( conn[j] );
673 v2hv_map_eid[is_index[v]] = *eid;
674 v2hv_map_lvid[is_index[v]] = j;
679 for(
int i = nv - 2; i >= 0; i-- )
680 is_index[i + 1] = is_index[i];
686 int v = verts.
index( *vid );
687 int last = is_index[v + 1] - 1;
688 if( last > is_index[v] )
691 int prev_lvid = v2hv_map_lvid[last];
693 for(
int i = is_index[v]; i <= last; i++ )
696 int cur_lvid = v2hv_map_lvid[i];
702 prev_lvid = cur_lvid;
722 for(
int i = 0; i < 2; ++i )
740 std::vector< EntityHandle >& adjents,
741 std::vector< int >* lvids )
744 adjents.reserve( 20 );
746 if( lvids != NULL ) lvids->reserve( 20 );
759 adjents.push_back( eid );
760 if( lvids != NULL ) lvids->push_back( lid );
769 if( ( !eid ) || ( eid == start_eid ) )
break;
771 adjents.push_back( eid );
772 if( lvids != NULL ) lvids->push_back( lid );
782 adjents.reserve( 20 );
788 for(
int lid = 0; lid < 2; ++lid )
796 adjents.push_back( sibhv_eid );
805 if( hv_eid != eid ) adjents.push_back( hv_eid );
810 if(
edge == sibhv_eid )
break;
826 { 3, { 1, 2, 0 }, { 2, 0, 1 } },
828 { 4, { 1, 2, 3, 0 }, { 3, 0, 1, 2 } } };
836 int nfaces = faces.
size();
841 std::vector< int > is_index( nv + 1 );
842 for(
int i = 0; i < nv + 1; i++ )
852 for(
int i = 0; i < nepf; i++ )
855 is_index[index + 1] += 1;
860 for(
int i = 0; i < nv; i++ )
861 is_index[i + 1] = is_index[i] + is_index[i + 1];
864 std::vector< EntityHandle > v2nv( nepf * nfaces );
865 std::vector< EntityHandle > v2he_map_fid( nepf * nfaces );
866 std::vector< int > v2he_map_leid( nepf * nfaces );
873 for(
int j = 0; j < nepf; j++ )
877 v2nv[is_index[v]] = conn[nidx];
878 v2he_map_fid[is_index[v]] = *fid;
879 v2he_map_leid[is_index[v]] = j;
884 for(
int i = nv - 2; i >= 0; i-- )
885 is_index[i + 1] = is_index[i];
895 for(
int k = 0; k < nepf; k++ )
900 if( sibfid != 0 )
continue;
912 for( index = is_index[vn]; index <= is_index[vn + 1] - 1; index++ )
914 if( v2nv[index] == conn[k] )
917 int cur_leid = v2he_map_leid[index];
923 prev_leid = cur_leid;
927 for( index = is_index[v]; index <= is_index[v + 1] - 1; index++ )
929 if( ( v2nv[index] == conn[nidx] ) && ( v2he_map_fid[index] != *fid ) )
933 int cur_leid = v2he_map_leid[index];
939 prev_leid = cur_leid;
943 if( prev_fid != first_fid )
961 std::vector< char > markEdges( nepf * faces.
size(), 0 );
969 for(
int i = 0; i < nepf; ++i )
975 if( hf == 0 && (
v2hes.empty() || (
v2hes.find( v ) ==
v2hes.end() ) ) )
985 else if( hf != 0 && !markEdges[nepf * faces.
index( fid ) + i] )
989 v2hes.insert( std::pair< EntityHandle, HFacet >( v, hf ) );
995 v2hes.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
998 else if( hf == 0 && ( !
v2hes.empty() ) && (
v2hes.find( v ) !=
v2hes.end() ) &&
999 !markEdges[nepf * faces.
index( fid ) + i] )
1008 v2hes.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
1023 std::vector< char >& markHEdgs,
1030 int qsize = 0, count = -1;
1035 while( num_qvals < qsize )
1046 if( !markHEdgs[nepf * faces.
index( curfid ) + curlid] && ( conn[curlid] == vid ) )
1048 markHEdgs[nepf * faces.
index( curfid ) + curlid] = 1;
1058 if( !markHEdgs[nepf * faces.
index( curfid ) + he2_lid] && ( conn[he2_lid] == vid ) )
1060 markHEdgs[nepf * faces.
index( curfid ) + he2_lid] = 1;
1077 for(
int i = 0; i <= qsize; i++ )
1083 for(
int i = 0; i <= count; i++ )
1097 std::vector< EntityHandle > start_fids;
1098 std::vector< int > start_lids;
1100 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) )
1102 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
1104 it_hes =
v2hes.equal_range( vid );
1106 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
1120 int qsize = 0, count = -1;
1123 adjents.reserve( (
int)start_fids.size() );
1125 for(
int i = 0; i < (int)start_fids.size(); i++ )
1127 adjents.push_back( start_fids[i] );
1131 while( num_qvals < qsize )
1150 adjents.push_back( he2_fid );
1154 for(
int i = 0; i <= qsize; i++ )
1160 for(
int i = 0; i <= count; i++ )
1168 std::vector< EntityHandle >& adjents,
1169 std::vector< int >* leids )
1194 std::vector< EntityHandle >& adj_ents,
1195 std::vector< int >* adj_leids,
1196 std::vector< int >* adj_orients )
1204 if( !fid )
return MB_FAILURE;
1205 adj_ents.reserve( 20 );
1207 bool local_id =
false;
1208 bool orient =
false;
1209 if( adj_leids != NULL )
1212 adj_leids->reserve( 20 );
1214 if( adj_orients != NULL )
1217 adj_orients->reserve( 20 );
1222 adj_ents.push_back( fid );
1223 if( local_id ) adj_leids->push_back( leid );
1235 fedge[0] = fid_conn[leid];
1236 fedge[1] = fid_conn[nidx];
1244 while( ( curfid != fid ) && ( curfid != 0 ) )
1246 adj_ents.push_back( curfid );
1248 if( local_id ) adj_leids->push_back( curlid );
1258 if( ( fedge[0] == conn[curlid] ) && ( fedge[1] == conn[nidx] ) )
1259 adj_orients->push_back( 1 );
1260 else if( ( fedge[1] == conn[curlid] ) && ( fedge[0] == conn[nidx] ) )
1261 adj_orients->push_back( 0 );
1265 hf =
sibhes[nepf * cidx + curlid];
1289 if( ( !found_ent ) || ( ( found_ent ) && (
queue_lid[index] != lid ) ) )
1297 while( ( curfid != fid ) && ( curfid != 0 ) )
1309 hf =
sibhes[nepf * cidx + curlid];
1347 int qsize = 0, count = -1;
1354 for(
int i = 0; i < qsize; i++ )
1360 for(
int i = 0; i <= count; i++ )
1406 if( conn[he_lid] == vid )
1427 int num_qvals = 0, counter = 0;
1429 while( num_qvals < *qsize && counter <
MAXSIZE )
1439 if( ( ( conn[curlid] == edg_vert[0] ) && ( conn[
id] == edg_vert[1] ) ) ||
1440 ( ( conn[curlid] == edg_vert[1] ) && ( conn[
id] == edg_vert[0] ) ) )
1475 for(
int lid = 0; lid < nepf; ++lid )
1489 adjents.reserve( 10 );
1496 std::vector< EntityHandle > temp;
1499 for(
int i = 0; i < 2; i++ )
1503 if( ftype ==
MBTRI )
1519 for(
int k = 0; k < (int)temp.size(); k++ )
1525 if( ( econn[0] == v && econn[1] == vnext ) || ( econn[0] == v && econn[1] == vprev ) ||
1526 ( econn[0] == vnext && econn[1] == v ) || ( econn[0] == vprev && econn[1] == v ) )
1529 for(
int j = 0; j < (int)adjents.size(); j++ )
1531 if( adjents[j] == temp[k] )
1537 if( !found ) adjents.push_back( temp[k] );
1551 int nfaces = faces.
size();
1553 int total_edges = nepf * nfaces;
1555 std::vector< int > trackF( total_edges, 0 );
1556 std::vector< EntityHandle > adj_fids;
1557 std::vector< int > adj_lids;
1561 for(
int l = 0; l < nepf; l++ )
1567 int id = nepf * ( faces.
index( *f ) ) + l;
1572 total_edges -= adj_fids.size();
1574 for(
int i = 0; i < (int)adj_fids.size(); i++ )
1575 trackF[nepf * ( faces.
index( adj_fids[i] ) ) + adj_lids[i]] = 1;
1591 std::vector< EntityHandle > conn;
1594 for(
int i = 0; i < nepf; i++ )
1599 std::vector< EntityHandle > e0, e1, ecom;
1603 std::sort( e0.begin(), e0.end() );
1604 std::sort( e1.begin(), e1.end() );
1605 std::set_intersection( e0.begin(), e0.end(), e1.begin(), e1.end(), std::back_inserter( ecom ) );
1606 assert( ecom.size() == 1 || ecom.size() == 0 );
1607 if( ecom.size() == 0 )
1608 edges.push_back( 0 );
1610 edges.push_back( ecom[0] );
1633 { { 0, 1, 3 }, { 1, 2, 3 }, { 2, 0, 3 }, { 0, 2, 1 } },
1635 { { 0, 2, 3 }, { 0, 1, 3 }, { 1, 2, 3 }, { 0, 1, 2 } },
1636 { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 3 }, { 2, 3 } },
1637 { { 3, 0 }, { 3, 1 }, { 3, 2 }, { 0, 2 }, { 0, 1 }, { 1, 2 } },
1638 { { 0, 4, 3 }, { 1, 5, 4 }, { 2, 3, 5 }, { 2, 1, 0 } },
1639 { { -1, 0, 2, 3 }, { 0, -1, 1, 4 }, { 2, 1, -1, 5 }, { 3, 4, 5, -1 } },
1642 { { 3, 1, 2, 3 }, { 2, 2, 3 }, { 1, 3 } } },
1649 { { 0, 3, 2, 1 }, { 0, 1, 4 }, { 1, 2, 4 }, { 2, 3, 4 }, { 3, 0, 4 } },
1651 { { 0, 1, 4 }, { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 1, 2, 3, 4 } },
1652 { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 } },
1653 { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 1, 4 }, { 1, 2 }, { 2, 3 }, { 3, 4 } },
1654 { { 3, 2, 1, 0 }, { 0, 5, 4 }, { 1, 6, 5 }, { 2, 7, 6 }, { 3, 4, 7 } },
1655 { { -1, 0, -1, 3, 4 }, { 0, -1, 1, -1, 5 }, { -1, 1, -1, 2, 6 }, { 3, -1, 2, -1, 7 }, { 4, 5, 6, 7, -1 } },
1658 { { 4, 0, 1, 2, 3 }, { 2, 1, 3 }, { 2, 1, 3 } } },
1665 { { 0, 1, 4, 3 }, { 1, 2, 5, 4 }, { 0, 3, 5, 2 }, { 0, 2, 1 }, { 3, 4, 5 } },
1666 { 3, 3, 3, 3, 3, 3 },
1667 { { 0, 2, 3 }, { 0, 1, 3 }, { 1, 2, 3 }, { 0, 2, 4 }, { 0, 1, 4 }, { 1, 4, 2 } },
1668 { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 4 }, { 2, 5 }, { 3, 4 }, { 4, 5 }, { 5, 3 } },
1669 { { 0, 3 }, { 1, 3 }, { 2, 3 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 4 }, { 1, 4 }, { 2, 4 } },
1670 { { 0, 4, 6, 3 }, { 1, 5, 7, 4 }, { 2, 3, 8, 5 }, { 2, 1, 0 }, { 6, 7, 8 } },
1671 { { -1, 0, 2, 3, -1, -1 },
1672 { 0, -1, 1, -1, 4, -1 },
1673 { 2, 1, -1, -1, -1, 5 },
1674 { 3, -1, -1, -1, 6, 8 },
1675 { -1, 4, -1, 6, -1, 7 },
1676 { -1, -1, 5, 8, 7, -1 } },
1679 { { 3, 1, 2, 3 }, { 3, 2, 4, 3 }, { 2, 3, 1 }, { 1, 2 } } },
1685 { 4, 4, 4, 4, 4, 4 },
1686 { { 0, 1, 5, 4 }, { 1, 2, 6, 5 }, { 2, 3, 7, 6 }, { 3, 0, 4, 7 }, { 0, 3, 2, 1 }, { 4, 5, 6, 7 } },
1687 { 3, 3, 3, 3, 3, 3, 3, 3 },
1688 { { 0, 3, 4 }, { 0, 1, 4 }, { 1, 2, 4 }, { 2, 3, 4 }, { 0, 3, 5 }, { 0, 1, 5 }, { 1, 2, 5 }, { 2, 3, 5 } },
1713 { { 0, 5, 8, 4 }, { 1, 6, 9, 5 }, { 2, 7, 10, 6 }, { 3, 4, 11, 7 }, { 3, 2, 1, 0 }, { 8, 9, 10, 11 } },
1714 { { -1, 0, -1, 3, 4, -1, -1, -1 },
1715 { 0, -1, 1, -1, -1, 5, -1, -1 },
1716 { -1, 1, -1, 2, -1, -1, 6, -1 },
1717 { 3, -1, 2, -1, -1, -1, -1, 7 },
1718 { 4, -1, -1, -1, -1, 8, -1, 11 },
1719 { -1, 5, -1, -1, 8, -1, 9, -1 },
1720 { -1, -1, 6, -1, -1, 9, -1, 10 },
1721 { -1, -1, -1, 7, 11, -1, 10, -1 } },
1724 { { 3, 1, 3, 4 }, { 3, 1, 3, 6 }, { 3, 1, 4, 6 }, { 3, 3, 6, 4 } } } };
1738 std::vector< int > is_index( nv + 1 );
1739 for(
int i = 0; i < nv + 1; i++ )
1749 for(
int i = 0; i < nfpc; ++i )
1753 for(
int k = 0; k < nvF; k++ )
1756 if( v <= conn[
id] ) v = conn[id];
1759 is_index[vindex + 1] += 1;
1764 for(
int i = 0; i < nv; i++ )
1765 is_index[i + 1] = is_index[i] + is_index[i + 1];
1768 std::vector< EntityHandle > v2oe_v1( is_index[nv] );
1769 std::vector< EntityHandle > v2oe_v2( is_index[nv] );
1770 std::vector< EntityHandle > v2hf_map_cid( is_index[nv] );
1771 std::vector< int > v2hf_map_lfid( is_index[nv] );
1778 for(
int i = 0; i < nfpc; i++ )
1781 std::vector< EntityHandle > vs( nvF );
1784 for(
int k = 0; k < nvF; k++ )
1788 if( vmax <= conn[
id] )
1799 v2oe_v1[is_index[v]] = vs[nidx];
1800 v2oe_v2[is_index[v]] = vs[pidx];
1801 v2hf_map_cid[is_index[v]] = *cid;
1802 v2hf_map_lfid[is_index[v]] = i;
1807 for(
int i = nv - 2; i >= 0; i-- )
1808 is_index[i + 1] = is_index[i];
1818 for(
int i = 0; i < nfpc; i++ )
1823 if( sibcid != 0 )
continue;
1826 std::vector< EntityHandle > vs( nvF );
1829 for(
int k = 0; k < nvF; k++ )
1833 if( vmax <= conn[
id] )
1839 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
1847 for(
int ind = is_index[v]; ind <= is_index[v + 1] - 1; ind++ )
1849 if( ( v2oe_v1[ind] == v1 ) && ( v2oe_v2[ind] == v2 ) )
1853 int cur_lfid = v2hf_map_lfid[ind];
1873 std::multimap< EntityHandle, EntityHandle > comps;
1882 for(
int i = 0; i < nvpc; ++i )
1890 if( hf == 0 && !found && (
v2hfs.empty() || (
v2hfs.find( v ) ==
v2hfs.end() ) ) )
1897 else if( hf != 0 && !found )
1902 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, hf ) );
1903 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
1906 else if( hf == 0 && !found && ( !
v2hfs.empty() ) && (
v2hfs.find( v ) !=
v2hfs.end() ) )
1910 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
1938 for(
int i = 0; i < nfpc; ++i )
1947 for(
int j = 0; j < nvF; ++j )
1963 std::multimap< EntityHandle, EntityHandle >& comps,
1972 int Stksize = 0, count = -1;
1978 while( Stksize >= 0 )
1990 comps.insert( std::pair< EntityHandle, EntityHandle >( vid, cur_cid ) );
1999 for(
int i = 0; i < nvpc; ++i )
2001 if( conn[i] == vid )
2007 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2014 for(
int i = 0; i < nhf_thisv; ++i )
2017 hf_ngb =
sibhfs[nfpc * cidx + ind];
2036 for(
int i = 0; i < Stksize; i++ )
2039 for(
int i = 0; i <= count; i++ )
2047 std::multimap< EntityHandle, EntityHandle >& comps )
2051 if( comps.empty() )
return found;
2053 std::pair< std::multimap< EntityHandle, EntityHandle >::iterator,
2054 std::multimap< EntityHandle, EntityHandle >::iterator >
2057 rit = comps.equal_range( vid );
2059 for( std::multimap< EntityHandle, EntityHandle >::iterator it = rit.first; it != rit.second; ++it )
2061 if( it->second == cell )
2075 adjents.reserve( 20 );
2082 std::vector< EntityHandle > start_cells;
2083 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) )
2085 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2087 it_hes =
v2hfs.equal_range( vid );
2089 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2103 for(
int i = 0; i < (int)start_cells.size(); i++ )
2104 cellq[i] = start_cells[i];
2106 int qsize = start_cells.size();
2110 while( num_qvals < qsize )
2112 cur_cid =
cellq[num_qvals];
2116 adjents.push_back( cur_cid );
2124 for(
int i = 0; i < nvpc; ++i )
2126 if( conn[i] == vid )
2132 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2139 for(
int i = 0; i < nhf_thisv; ++i )
2142 hf =
sibhfs[nfpc * cidx + ind];
2159 for(
int i = 0; i < qsize; i++ )
2166 std::vector< EntityHandle >& adjents,
2167 std::vector< int >* leids )
2176 adjents.reserve( 20 );
2177 if( leids != NULL ) leids->reserve( 20 );
2189 std::vector< EntityHandle > start_cells;
2193 if( hf1 == 0 && !
v2hfs.empty() )
2195 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2197 it_hes =
v2hfs.equal_range( v_start );
2199 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2209 if( hf2 == 0 && !
v2hfs.empty() )
2211 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2213 it_hes =
v2hfs.equal_range( v_end );
2215 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2227 std::sort( start_cells.begin(), start_cells.end() );
2228 std::vector< EntityHandle >::iterator last = std::unique( start_cells.begin(), start_cells.end() );
2229 start_cells.erase( last, start_cells.end() );
2231 for(
int i = 0; i < (int)start_cells.size(); i++ )
2232 cellq[i] = start_cells[i];
2234 int qsize = start_cells.size();
2237 while( num_qvals < qsize )
2245 int lv0 = -1, lv1 = -1, lv = -1;
2248 for(
int i = 0; i < nvpc; i++ )
2250 if( v_start == conn[i] )
2255 else if( v_end == conn[i] )
2262 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2264 adjents.push_back( cell_id );
2265 if( leids != NULL ) leids->push_back(
lConnMap3D[index].lookup_leids[lv0][lv1] );
2270 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2273 for(
int i = 0; i < nhf_thisv; i++ )
2292 for(
int i = 0; i < qsize; i++ )
2300 std::vector< EntityHandle >& adjents,
2301 std::vector< int >* leids,
2302 std::vector< int >* adj_orients )
2310 adjents.reserve( 20 );
2315 leids->reserve( 20 );
2317 if( adj_orients != NULL )
2319 adj_orients->clear();
2320 adj_orients->reserve( 20 );
2336 std::vector< EntityHandle > start_cells;
2340 if( hf1 == 0 && !
v2hfs.empty() )
2342 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2344 it_hes =
v2hfs.equal_range( v_start );
2346 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2356 if( hf2 == 0 && !
v2hfs.empty() )
2358 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2360 it_hes =
v2hfs.equal_range( v_end );
2362 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2374 std::sort( start_cells.begin(), start_cells.end() );
2375 std::vector< EntityHandle >::iterator last = std::unique( start_cells.begin(), start_cells.end() );
2376 start_cells.erase( last, start_cells.end() );
2378 for(
int i = 0; i < (int)start_cells.size(); i++ )
2379 cellq[i] = start_cells[i];
2381 int qsize = start_cells.size();
2384 while( num_qvals < qsize )
2392 int lv0 = -1, lv1 = -1, lv = -1;
2395 for(
int i = 0; i < nvpc; i++ )
2397 if( v_start == conn[i] )
2402 else if( v_end == conn[i] )
2409 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2411 adjents.push_back( cell_id );
2412 if( leids != NULL ) leids->push_back(
lConnMap3D[index].lookup_leids[lv0][lv1] );
2414 if( adj_orients != NULL )
2419 if( ( v_start == conn[id1] ) && ( v_end == conn[id2] ) )
2420 adj_orients->push_back( 1 );
2421 else if( ( v_start == conn[id2] ) && ( v_end == conn[id1] ) )
2422 adj_orients->push_back( 0 );
2425 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2430 for(
int i = 0; i < nhf_thisv; i++ )
2449 for(
int i = 0; i < qsize; i++ )
2457 std::vector< EntityHandle >& adjents,
2458 std::vector< int >* leids,
2459 std::vector< int >* adj_orients )
2467 adjents.reserve( 20 );
2472 leids->reserve( 20 );
2474 if( adj_orients != NULL )
2476 adj_orients->clear();
2477 adj_orients->reserve( 20 );
2493 std::vector< EntityHandle > start_cells;
2497 if( ( hf1 == 0 ) && (
v2hfs.find( v_start ) !=
v2hfs.end() ) && ( hf2 == 0 ) &&
2500 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2502 it_hes =
v2hfs.equal_range( v_start );
2504 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2518 for(
int c = 0; c < (int)start_cells.size(); c++ )
2520 cellq[0] = start_cells[c];
2525 while( num_qvals < qsize )
2533 int lv0 = -1, lv1 = -1, lv = -1;
2536 for(
int i = 0; i < nvpc; i++ )
2538 if( v_start == conn[i] )
2543 else if( v_end == conn[i] )
2550 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2552 adjents.push_back( cell_id );
2553 if( leids != NULL ) leids->push_back(
lConnMap3D[index].lookup_leids[lv0][lv1] );
2555 if( adj_orients != NULL )
2560 if( ( v_start == conn[id1] ) && ( v_end == conn[id2] ) )
2561 adj_orients->push_back( 1 );
2562 else if( ( v_start == conn[id2] ) && ( v_end == conn[id1] ) )
2563 adj_orients->push_back( 0 );
2566 for(
int i = 0; i < qsize; i++ )
2576 for(
int i = 0; i < nhf_thisv; i++ )
2595 for(
int i = 0; i < qsize; i++ )
2603 std::vector< EntityHandle >& adjents,
2604 std::vector< int >* lfids )
2622 std::vector< EntityHandle >& adjents,
2623 std::vector< int >* lfids )
2631 adjents.reserve( 4 );
2632 adjents.push_back( cid );
2636 lfids->reserve( 4 );
2637 lfids->push_back( lfid );
2647 adjents.push_back( sibcid );
2648 if( lfids != NULL ) lfids->push_back( siblid );
2655 std::vector< EntityHandle >& cid,
2656 std::vector< int >& leid )
2675 std::vector< EntityHandle > start_cells;
2679 int ncomps1 = 0, ncomps2 = 0, ncomp;
2680 if( hf1 == 0 && !
v2hfs.empty() )
2682 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2684 it_hes =
v2hfs.equal_range( v_start );
2686 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2698 if( hf2 == 0 && !
v2hfs.empty() )
2700 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2702 it_hes =
v2hfs.equal_range( v_end );
2704 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2716 ncomp = std::min( ncomps1, ncomps2 );
2719 if( start_cells.empty() )
return found;
2721 for(
int i = 0; i < (int)start_cells.size(); i++ )
2722 cellq[i] = start_cells[i];
2724 int qsize = start_cells.size();
2727 while( num_qvals < qsize )
2735 int lv0 = -1, lv1 = -1, lv = -1;
2738 for(
int i = 0; i < nvpc; i++ )
2740 if( v_start == conn[i] )
2745 else if( v_end == conn[i] )
2752 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2755 cid.push_back( cell_id );
2756 leid.push_back(
lConnMap3D[index].lookup_leids[lv0][lv1] );
2758 if( (
int)cid.size() == ncomp )
break;
2764 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2765 for(
int i = 0; i < nhf_thisv; i++ )
2784 for(
int i = 0; i < qsize; i++ )
2804 std::vector< EntityHandle > start_cells;
2805 int vidx, locfv0 = -1;
2808 for(
int i = 0; i < nvF; i++ )
2818 else if( hf == 0 &&
v2hfs.find( fid_verts[i] ) !=
v2hfs.end() )
2820 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
2821 std::multimap< EntityHandle, HFacet >::iterator >
2823 it_hfs =
v2hfs.equal_range( fid_verts[i] );
2825 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hfs.first; it != it_hfs.second; ++it )
2834 if( start_cells.empty() )
return false;
2839 int Stksize = 0, count = -1;
2841 for(
int i = 0; i < (int)start_cells.size(); i++ )
2844 Stksize = start_cells.size() - 1;
2846 while( Stksize >= 0 )
2856 int lv[4] = { -1, -1, -1, -1 };
2858 for(
int i = 0; i < nvpc; i++ )
2860 for(
int j = 0; j < nvF; j++ )
2861 if( conn[i] == fid_verts[j] )
2872 for(
int i = 0; i < nhf_thisv; ++i )
2876 for(
int j = 0; j < nvF; ++j )
2878 for(
int k = 0; k < nvF; ++k )
2880 if( lv[k] ==
lConnMap3D[index].hf2v[lfid][j] ) lcnt += 1;
2883 if( lcnt == nvF )
break;
2893 if( locfv0 < 0 || lv[locfv0] < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2899 for(
int i = 0; i < nhf_thisv; ++i )
2902 hf =
sibhfs[nfpc * cidx + ind];
2921 for(
int i = 0; i < Stksize; i++ )
2924 for(
int i = 0; i <= count; i++ )
2933 adjents.reserve( 20 );
2941 for(
int lfid = 0; lfid < nfpc; ++lfid )
2945 if( sibcid != 0 ) adjents.push_back( sibcid );
2958 adjents.reserve( 20 );
2967 std::vector< EntityHandle > temp;
2968 for(
int i = 0; i < ns; i++ )
2976 for(
int j = 0; j < (int)temp.size(); j++ )
2982 for(
int k = 0; k < nle; k++ )
2985 if( ( ( econn[0] == conn[lv0] ) && ( econn[1] == conn[lv1] ) ) ||
2986 ( ( econn[1] == conn[lv0] ) && ( econn[0] == conn[lv1] ) ) )
2988 adjents.push_back( temp[j] );
2992 if( count == nle )
break;
3002 adjents.reserve( 10 );
3013 for(
int i = 0; i < nfpc; i++ )
3016 for(
int j = 0; j < nvf; j++ )
3019 half_faces[i][j] = conn[ind];
3024 int search_verts[2];
3028 std::vector< EntityHandle > temp;
3030 for(
int i = 0; i < 2; i++ )
3033 int lv = search_verts[i];
3037 if( temp.size() == 0 )
continue;
3041 for(
int k = 0; k < (int)temp.size(); k++ )
3047 for(
int j = 0; j < nhfthisv; j++ )
3053 if( fsize != nvF )
continue;
3061 for(
int p = 0; p < (int)adjents.size(); p++ )
3063 if( adjents[p] == temp[k] )
3069 if( !found ) adjents.push_back( temp[k] );
3084 int ncells = cells.
size();
3085 int total_edges = nepc * ncells;
3086 int total_faces = nfpc * ncells;
3088 std::vector< int > trackE( total_edges, 0 );
3089 std::vector< int > trackF( total_faces, 0 );
3091 std::vector< EntityHandle > inc_cids, sib_cids;
3092 std::vector< int > inc_leids, sib_lfids;
3097 for(
int i = 0; i < nepc; i++ )
3102 int id = nepc * ( cells.
index( *it ) ) + i;
3107 total_edges -= inc_cids.size() - 1;
3108 for(
int j = 0; j < (int)inc_cids.size(); j++ )
3109 trackE[nepc * ( cells.
index( inc_cids[j] ) ) + inc_leids[j]] = 1;
3114 for(
int i = 0; i < nfpc; i++ )
3119 int id = nfpc * ( cells.
index( *it ) ) + i;
3124 if( sib_cids.size() == 1 )
continue;
3126 total_faces -= sib_cids.size() - 1;
3127 trackF[nfpc * ( cells.
index( sib_cids[1] ) ) + sib_lfids[1]] = 1;
3132 nedges[0] = total_edges;
3133 nfaces[0] = total_faces;
3145 for(
int i = 0; i <= count; i++ )
3147 if( ent == ent_list[i] )
3150 if( get_index ) *index = i;
3160 std::vector< EntityHandle >& ents,
3161 std::vector< int >& lids,
3162 std::vector< int >& lfids )
3173 std::vector< EntityHandle > adjents;
3174 std::vector< int > adjlids;
3185 std::vector< int > mark( adjents.size(), 0 );
3188 for(
int k = 0; k < (int)adjents.size(); k++ )
3191 if( mark[k] != 0 )
continue;
3197 for(
int i = 0; i < 2; i++ )
3200 int cur_leid = adjlids[k];
3214 if( ( cur_cell == adjents[k] ) || ( cur_cell == 0 ) )
break;
3221 int lv0 = -1, lv1 = -1, idx = -1;
3222 for(
int j = 0; j < nv_curF; j++ )
3225 if( vstart == sib_conn[idx] ) lv0 = idx;
3226 if( vend == sib_conn[idx] ) lv1 = idx;
3229 assert( ( lv0 >= 0 ) && ( lv1 >= 0 ) );
3234 if( lfid == chk_lfid )
3239 int ind = std::find( adjents.begin(), adjents.end(), cur_cell ) - adjents.begin();
3244 if( cur_cell != 0 )
break;
3249 for(
int c = 0; c < count; c++ )
3251 for(
int i = 0; i < (int)adjents.size(); i++ )
3253 if( mark[i] == c + 1 )
3256 for(
int j = 0; j < nfpc; j++ )
3262 ents.push_back( adjents[i] );
3263 lids.push_back( adjlids[i] );
3264 lfids.push_back( j );
3285 int nwsz = 0, insz = 0;
3293 sibhvs.resize( insz + nwsz, 0 );
3297 if( ( !
v2he.empty() ) )
3299 else if( ( !
v2hf.empty() ) )
3302 MB_SET_ERR( MB_FAILURE,
"Trying to resize ahf maps for a mesh with no edges, faces and cells" );
3311 v2hv.resize( insz + nwsz, 0 );
3322 nwsz = nfaces * nepf;
3324 sibhes.resize( insz + nwsz, 0 );
3331 v2he.resize( insz + nwsz, 0 );
3342 nwsz = ncells * nfpc;
3344 sibhfs.resize( insz + nwsz, 0 );
3351 v2hf.resize( insz + nwsz, 0 );
3359 bool status =
false;
3363 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) ) status =
true;
3368 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) ) status =
true;
3371 MB_SET_ERR( MB_FAILURE,
"Requesting non-manifold vertex checks for either (1) 1D mesh or "
3372 "(2) not-implemented entity types" );
3381 int num_halffacets )
3386 if( num_halffacets != 2 )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfvertices." );
3389 for(
int i = 0; i < 2; i++ )
3400 if( num_halffacets != nepf )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfedges." );
3403 for(
int i = 0; i < nepf; i++ )
3415 if( num_halffacets != nfpc )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halffaces." );
3418 for(
int i = 0; i < nfpc; i++ )
3466 int num_halffacets )
3471 if( num_halffacets != 2 )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfvertices" );
3474 for(
int i = 0; i < 2; i++ )
3482 if( num_halffacets != nepf )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfedges." );
3485 for(
int i = 0; i < nepf; i++ )
3494 if( num_halffacets != nfpc )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halffaces." );
3497 for(
int i = 0; i < nfpc; i++ )
3537 std::vector< EntityHandle >& inci_entid,
3538 std::vector< int >& inci_lid )
3552 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) )
3554 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
3555 std::multimap< EntityHandle, HFacet >::iterator >
3557 it_hes =
v2hes.equal_range( vid );
3559 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
3570 else if( hf == 0 && (
v2hes.find( vid ) ==
v2hes.end() ) )
3579 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) )
3581 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
3582 std::multimap< EntityHandle, HFacet >::iterator >
3584 it_hes =
v2hfs.equal_range( vid );
3586 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
3597 else if( hf == 0 && (
v2hfs.find( vid ) ==
v2hfs.end() ) )
3609 std::vector< EntityHandle >& set_entid,
3610 std::vector< int >& set_lid )
3618 if( set_entid.size() == 1 )
3623 for(
int i = 0; i < (int)set_entid.size(); i++ )
3626 v2hes.insert( std::pair< EntityHandle, HFacet >( vid, hf ) );
3632 if( set_entid.size() == 1 )
3641 for(
int i = 0; i < (int)set_entid.size(); i++ )
3644 v2hfs.insert( std::pair< EntityHandle, HFacet >( vid, hf ) );
3678 entity_total = memory_total = 0;
3680 if( !
v2hv.empty() ) entity_total +=
v2hv.capacity() *
sizeof(
HFacet ) +
sizeof(
v2hv );
3684 if( !
v2he.empty() ) entity_total +=
v2he.capacity() *
sizeof(
HFacet ) +
sizeof(
v2he );
3688 if( !
v2hf.empty() ) entity_total +=
v2hf.capacity() *
sizeof(
HFacet ) +
sizeof(
v2hf );
3691 memory_total = entity_total;
3704 if(
id == 0 )
return handle;