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;
145 Range tris, quad, poly;
160 Range tet, pyr, prism, hex, polyhed;
317 v2hv.resize( nv, 0 );
318 sibhvs.resize( ne * 2, 0 );
337 v2he.resize( nv, 0 );
338 sibhes.resize( nf * nepf, 0 );
347 for(
int i = 0; i <
MAXSIZE; i++ )
373 v2hf.resize( nv, 0 );
374 sibhfs.resize( nc * nfpc, 0 );
383 for(
int i = 0; i <
MAXSIZE; i++ )
399 std::cout <<
"start_edge = " << start_edge << std::endl;
400 std::cout <<
"<SIBHVS_EID,SIBHVS_LVID>" << std::endl;
413 std::cout <<
"Entity = " << *i <<
" :: <" << eid[0] <<
"," << lvid[0] <<
">"
415 <<
"<" << eid[1] <<
"," << lvid[1] <<
">" << std::endl;
418 std::cout <<
"<V2HV_EID, V2HV_LVID>" << std::endl;
426 std::cout <<
"Vertex = " << *i <<
" :: <" << eid <<
"," << lvid <<
">" << std::endl;
434 std::cout <<
"start_face = " << start_face << std::endl;
435 std::cout <<
"<SIBHES_FID,SIBHES_LEID>" << std::endl;
440 std::cout <<
"Entity = " << *i;
441 for(
int j = 0; j < nepf; j++ )
446 std::cout <<
" :: <" << sib <<
"," << lid <<
">"
449 std::cout << std::endl;
452 std::cout <<
"<V2HE_FID, V2HE_LEID>" << std::endl;
460 std::cout <<
"Vertex = " << *i <<
" :: <" << fid <<
"," << lid <<
">" << std::endl;
470 std::cout <<
"start_cell = " << start_cell << std::endl;
471 std::cout <<
"<SIBHES_CID,SIBHES_LFID>" << std::endl;
476 std::cout <<
"Entity = " << *i;
477 for(
int j = 0; j < nfpc; j++ )
482 std::cout <<
" :: <" << sib <<
"," << lid <<
">"
485 std::cout << std::endl;
488 std::cout <<
"<V2HF_CID, V2HF_LFID>" << std::endl;
497 if( hf == 0 && (
v2hfs.find( *i ) !=
v2hfs.end() ) )
499 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
500 std::multimap< EntityHandle, HFacet >::iterator >
502 it_hfs =
v2hfs.equal_range( *i );
504 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hfs.first; it != it_hfs.second; ++it )
509 std::cout <<
"Vertex = " << *i <<
" :: <" << cid <<
"," << lid <<
">" << std::endl;
516 std::cout <<
"Vertex = " << *i <<
" :: <" << cid <<
"," << lid <<
">" << std::endl;
528 const unsigned int target_dimension,
529 std::vector< EntityHandle >& target_entities )
535 assert( ( source_dimension <= target_dimension ) || ( source_dimension > target_dimension ) );
544 int adj_possible =
adjMatrix[mindex].
val[source_dimension][target_dimension];
548 if( source_dimension < target_dimension )
553 else if( source_dimension == target_dimension )
572 std::vector< EntityHandle >& adjents,
573 std::vector< int >* lids )
577 assert( ( in_dim >= 0 && in_dim <= 2 ) && ( out_dim > in_dim ) );
586 else if( out_dim == 2 )
591 else if( out_dim == 3 )
598 else if( ( in_dim == 1 ) && ( out_dim == 2 ) )
603 else if( ( in_dim == 1 ) && ( out_dim == 3 ) )
608 else if( ( in_dim == 2 ) && ( out_dim == 3 ) )
620 assert( in_dim >= 1 && in_dim <= 3 );
628 else if( in_dim == 2 )
633 else if( in_dim == 3 )
645 assert( ( in_dim >= 2 && in_dim <= 3 ) && ( out_dim < in_dim ) );
647 if( ( in_dim == 2 ) && ( out_dim == 1 ) )
652 else if( ( in_dim == 3 ) && ( out_dim == 1 ) )
657 else if( ( in_dim == 3 ) && ( out_dim == 2 ) )
670 nedges[0] = edges.
size();
673 else if( faces.
size() && !cells.
size() )
678 else if( cells.
size() )
694 int nv = verts.
size();
695 std::vector< int > is_index( nv + 1 );
696 for(
int i = 0; i < nv + 1; i++ )
707 is_index[
index + 1] += 1;
709 is_index[
index + 1] += 1;
713 for(
int i = 0; i < nv; i++ )
714 is_index[i + 1] = is_index[i] + is_index[i + 1];
717 std::vector< EntityHandle > v2hv_map_eid( 2 * edges.
size() );
718 std::vector< int > v2hv_map_lvid( 2 * edges.
size() );
727 for(
int j = 0; j < 2; j++ )
729 int v = verts.
index( conn[j] );
730 v2hv_map_eid[is_index[v]] = *eid;
731 v2hv_map_lvid[is_index[v]] = j;
736 for(
int i = nv - 2; i >= 0; i-- )
737 is_index[i + 1] = is_index[i];
743 int v = verts.
index( *vid );
744 int last = is_index[v + 1] - 1;
745 if( last > is_index[v] )
748 int prev_lvid = v2hv_map_lvid[last];
750 for(
int i = is_index[v]; i <= last; i++ )
753 int cur_lvid = v2hv_map_lvid[i];
759 prev_lvid = cur_lvid;
780 for(
int i = 0; i < 2; ++i )
798 std::vector< EntityHandle >& adjents,
799 std::vector< int >* lvids )
802 adjents.reserve( 20 );
804 if( lvids != NULL ) lvids->reserve( 20 );
817 adjents.push_back( eid );
818 if( lvids != NULL ) lvids->push_back( lid );
827 if( ( !eid ) || ( eid == start_eid ) )
break;
829 adjents.push_back( eid );
830 if( lvids != NULL ) lvids->push_back( lid );
840 adjents.reserve( 20 );
846 for(
int lid = 0; lid < 2; ++lid )
854 adjents.push_back( sibhv_eid );
863 if( hv_eid != eid ) adjents.push_back( hv_eid );
868 if(
edge == sibhv_eid )
break;
884 { 3, { 1, 2, 0 }, { 2, 0, 1 } },
886 { 4, { 1, 2, 3, 0 }, { 3, 0, 1, 2 } } };
894 int nfaces = faces.
size();
899 std::vector< int > is_index( nv + 1 );
900 for(
int i = 0; i < nv + 1; i++ )
911 for(
int i = 0; i < nepf; i++ )
914 is_index[
index + 1] += 1;
919 for(
int i = 0; i < nv; i++ )
920 is_index[i + 1] = is_index[i] + is_index[i + 1];
923 std::vector< EntityHandle > v2nv( nepf * nfaces );
924 std::vector< EntityHandle > v2he_map_fid( nepf * nfaces );
925 std::vector< int > v2he_map_leid( nepf * nfaces );
933 for(
int j = 0; j < nepf; j++ )
937 v2nv[is_index[v]] = conn[nidx];
938 v2he_map_fid[is_index[v]] = *fid;
939 v2he_map_leid[is_index[v]] = j;
944 for(
int i = nv - 2; i >= 0; i-- )
945 is_index[i + 1] = is_index[i];
956 for(
int k = 0; k < nepf; k++ )
961 if( sibfid != 0 )
continue;
975 if( v2nv[
index] == conn[k] )
978 int cur_leid = v2he_map_leid[
index];
984 prev_leid = cur_leid;
990 if( ( v2nv[
index] == conn[nidx] ) && ( v2he_map_fid[
index] != *fid ) )
994 int cur_leid = v2he_map_leid[
index];
1000 prev_leid = cur_leid;
1004 if( prev_fid != first_fid )
1022 std::vector< char > markEdges( nepf * faces.
size(), 0 );
1031 for(
int i = 0; i < nepf; ++i )
1037 if( hf == 0 && (
v2hes.empty() || (
v2hes.find( v ) ==
v2hes.end() ) ) )
1048 else if( hf != 0 && !markEdges[nepf * faces.
index( fid ) + i] )
1052 v2hes.insert( std::pair< EntityHandle, HFacet >( v, hf ) );
1059 v2hes.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
1062 else if( hf == 0 && ( !
v2hes.empty() ) && (
v2hes.find( v ) !=
v2hes.end() ) &&
1063 !markEdges[nepf * faces.
index( fid ) + i] )
1073 v2hes.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
1088 std::vector< char >& markHEdgs,
1095 int qsize = 0, count = -1;
1101 while( num_qvals < qsize )
1113 if( !markHEdgs[nepf * faces.
index( curfid ) + curlid] && ( conn[curlid] == vid ) )
1115 markHEdgs[nepf * faces.
index( curfid ) + curlid] = 1;
1126 if( !markHEdgs[nepf * faces.
index( curfid ) + he2_lid] && ( conn[he2_lid] == vid ) )
1128 markHEdgs[nepf * faces.
index( curfid ) + he2_lid] = 1;
1146 for(
int i = 0; i <= qsize; i++ )
1152 for(
int i = 0; i <= count; i++ )
1166 std::vector< EntityHandle > start_fids;
1167 std::vector< int > start_lids;
1169 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) )
1171 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
1173 it_hes =
v2hes.equal_range( vid );
1175 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
1189 int qsize = 0, count = -1;
1192 adjents.reserve( (
int)start_fids.size() );
1194 for(
int i = 0; i < (int)start_fids.size(); i++ )
1196 adjents.push_back( start_fids[i] );
1201 while( num_qvals < qsize )
1222 adjents.push_back( he2_fid );
1226 for(
int i = 0; i <= qsize; i++ )
1232 for(
int i = 0; i <= count; i++ )
1240 std::vector< EntityHandle >& adjents,
1241 std::vector< int >* leids )
1267 std::vector< EntityHandle >& adj_ents,
1268 std::vector< int >* adj_leids,
1269 std::vector< int >* adj_orients )
1277 if( !fid )
return MB_FAILURE;
1278 adj_ents.reserve( 20 );
1280 bool local_id =
false;
1281 bool orient =
false;
1282 if( adj_leids != NULL )
1285 adj_leids->reserve( 20 );
1287 if( adj_orients != NULL )
1290 adj_orients->reserve( 20 );
1295 adj_ents.push_back( fid );
1296 if( local_id ) adj_leids->push_back( leid );
1309 fedge[0] = fid_conn[leid];
1310 fedge[1] = fid_conn[nidx];
1318 while( ( curfid != fid ) && ( curfid != 0 ) )
1320 adj_ents.push_back( curfid );
1322 if( local_id ) adj_leids->push_back( curlid );
1333 if( ( fedge[0] == conn[curlid] ) && ( fedge[1] == conn[nidx] ) )
1334 adj_orients->push_back( 1 );
1335 else if( ( fedge[1] == conn[curlid] ) && ( fedge[0] == conn[nidx] ) )
1336 adj_orients->push_back( 0 );
1340 hf =
sibhes[nepf * cidx + curlid];
1364 if( ( !found_ent ) || ( ( found_ent ) && (
queue_lid[
index] != lid ) ) )
1372 while( ( curfid != fid ) && ( curfid != 0 ) )
1384 hf =
sibhes[nepf * cidx + curlid];
1423 int qsize = 0, count = -1;
1432 for(
int i = 0; i < qsize; i++ )
1438 for(
int i = 0; i <= count; i++ )
1488 if( conn[he_lid] == vid )
1509 int num_qvals = 0, counter = 0;
1511 while( num_qvals < *qsize && counter <
MAXSIZE )
1522 if( ( ( conn[curlid] == edg_vert[0] ) && ( conn[
id] == edg_vert[1] ) ) ||
1523 ( ( conn[curlid] == edg_vert[1] ) && ( conn[
id] == edg_vert[0] ) ) )
1560 for(
int lid = 0; lid < nepf; ++lid )
1575 adjents.reserve( 10 );
1583 std::vector< EntityHandle > temp;
1586 for(
int i = 0; i < 2; i++ )
1590 if( ftype ==
MBTRI )
1607 for(
int k = 0; k < (int)temp.size(); k++ )
1614 if( ( econn[0] == v && econn[1] == vnext ) || ( econn[0] == v && econn[1] == vprev ) ||
1615 ( econn[0] == vnext && econn[1] == v ) || ( econn[0] == vprev && econn[1] == v ) )
1618 for(
int j = 0; j < (int)adjents.size(); j++ )
1620 if( adjents[j] == temp[k] )
1626 if( !found ) adjents.push_back( temp[k] );
1640 int nfaces = faces.
size();
1642 int total_edges = nepf * nfaces;
1644 std::vector< int > trackF( total_edges, 0 );
1645 std::vector< EntityHandle > adj_fids;
1646 std::vector< int > adj_lids;
1650 for(
int l = 0; l < nepf; l++ )
1656 int id = nepf * ( faces.
index( *f ) ) + l;
1662 total_edges -= adj_fids.size();
1664 for(
int i = 0; i < (int)adj_fids.size(); i++ )
1665 trackF[nepf * ( faces.
index( adj_fids[i] ) ) + adj_lids[i]] = 1;
1681 std::vector< EntityHandle > conn;
1685 for(
int i = 0; i < nepf; i++ )
1690 std::vector< EntityHandle > e0, e1, ecom;
1696 std::sort( e0.begin(), e0.end() );
1697 std::sort( e1.begin(), e1.end() );
1698 std::set_intersection( e0.begin(), e0.end(), e1.begin(), e1.end(), std::back_inserter( ecom ) );
1699 assert( ecom.size() == 1 || ecom.size() == 0 );
1700 if( ecom.size() == 0 )
1701 edges.push_back( 0 );
1703 edges.push_back( ecom[0] );
1726 { { 0, 1, 3 }, { 1, 2, 3 }, { 2, 0, 3 }, { 0, 2, 1 } },
1728 { { 0, 2, 3 }, { 0, 1, 3 }, { 1, 2, 3 }, { 0, 1, 2 } },
1729 { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 3 }, { 2, 3 } },
1730 { { 3, 0 }, { 3, 1 }, { 3, 2 }, { 0, 2 }, { 0, 1 }, { 1, 2 } },
1731 { { 0, 4, 3 }, { 1, 5, 4 }, { 2, 3, 5 }, { 2, 1, 0 } },
1732 { { -1, 0, 2, 3 }, { 0, -1, 1, 4 }, { 2, 1, -1, 5 }, { 3, 4, 5, -1 } },
1735 { { 3, 1, 2, 3 }, { 2, 2, 3 }, { 1, 3 } } },
1742 { { 0, 3, 2, 1 }, { 0, 1, 4 }, { 1, 2, 4 }, { 2, 3, 4 }, { 3, 0, 4 } },
1744 { { 0, 1, 4 }, { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 1, 2, 3, 4 } },
1745 { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 4 }, { 1, 4 }, { 2, 4 }, { 3, 4 } },
1746 { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 1, 4 }, { 1, 2 }, { 2, 3 }, { 3, 4 } },
1747 { { 3, 2, 1, 0 }, { 0, 5, 4 }, { 1, 6, 5 }, { 2, 7, 6 }, { 3, 4, 7 } },
1748 { { -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 } },
1751 { { 4, 0, 1, 2, 3 }, { 2, 1, 3 }, { 2, 1, 3 } } },
1758 { { 0, 1, 4, 3 }, { 1, 2, 5, 4 }, { 0, 3, 5, 2 }, { 0, 2, 1 }, { 3, 4, 5 } },
1759 { 3, 3, 3, 3, 3, 3 },
1760 { { 0, 2, 3 }, { 0, 1, 3 }, { 1, 2, 3 }, { 0, 2, 4 }, { 0, 1, 4 }, { 1, 4, 2 } },
1761 { { 0, 1 }, { 1, 2 }, { 2, 0 }, { 0, 3 }, { 1, 4 }, { 2, 5 }, { 3, 4 }, { 4, 5 }, { 5, 3 } },
1762 { { 0, 3 }, { 1, 3 }, { 2, 3 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 4 }, { 1, 4 }, { 2, 4 } },
1763 { { 0, 4, 6, 3 }, { 1, 5, 7, 4 }, { 2, 3, 8, 5 }, { 2, 1, 0 }, { 6, 7, 8 } },
1764 { { -1, 0, 2, 3, -1, -1 },
1765 { 0, -1, 1, -1, 4, -1 },
1766 { 2, 1, -1, -1, -1, 5 },
1767 { 3, -1, -1, -1, 6, 8 },
1768 { -1, 4, -1, 6, -1, 7 },
1769 { -1, -1, 5, 8, 7, -1 } },
1772 { { 3, 1, 2, 3 }, { 3, 2, 4, 3 }, { 2, 3, 1 }, { 1, 2 } } },
1778 { 4, 4, 4, 4, 4, 4 },
1779 { { 0, 1, 5, 4 }, { 1, 2, 6, 5 }, { 2, 3, 7, 6 }, { 3, 0, 4, 7 }, { 0, 3, 2, 1 }, { 4, 5, 6, 7 } },
1780 { 3, 3, 3, 3, 3, 3, 3, 3 },
1781 { { 0, 3, 4 }, { 0, 1, 4 }, { 1, 2, 4 }, { 2, 3, 4 }, { 0, 3, 5 }, { 0, 1, 5 }, { 1, 2, 5 }, { 2, 3, 5 } },
1806 { { 0, 5, 8, 4 }, { 1, 6, 9, 5 }, { 2, 7, 10, 6 }, { 3, 4, 11, 7 }, { 3, 2, 1, 0 }, { 8, 9, 10, 11 } },
1807 { { -1, 0, -1, 3, 4, -1, -1, -1 },
1808 { 0, -1, 1, -1, -1, 5, -1, -1 },
1809 { -1, 1, -1, 2, -1, -1, 6, -1 },
1810 { 3, -1, 2, -1, -1, -1, -1, 7 },
1811 { 4, -1, -1, -1, -1, 8, -1, 11 },
1812 { -1, 5, -1, -1, 8, -1, 9, -1 },
1813 { -1, -1, 6, -1, -1, 9, -1, 10 },
1814 { -1, -1, -1, 7, 11, -1, 10, -1 } },
1817 { { 3, 1, 3, 4 }, { 3, 1, 3, 6 }, { 3, 1, 4, 6 }, { 3, 3, 6, 4 } } } };
1831 std::vector< int > is_index( nv + 1 );
1832 for(
int i = 0; i < nv + 1; i++ )
1843 for(
int i = 0; i < nfpc; ++i )
1847 for(
int k = 0; k < nvF; k++ )
1850 if( v <= conn[
id] ) v = conn[id];
1853 is_index[vindex + 1] += 1;
1858 for(
int i = 0; i < nv; i++ )
1859 is_index[i + 1] = is_index[i] + is_index[i + 1];
1862 std::vector< EntityHandle > v2oe_v1( is_index[nv] );
1863 std::vector< EntityHandle > v2oe_v2( is_index[nv] );
1864 std::vector< EntityHandle > v2hf_map_cid( is_index[nv] );
1865 std::vector< int > v2hf_map_lfid( is_index[nv] );
1873 for(
int i = 0; i < nfpc; i++ )
1876 std::vector< EntityHandle > vs( nvF );
1879 for(
int k = 0; k < nvF; k++ )
1883 if( vmax <= conn[
id] )
1894 v2oe_v1[is_index[v]] = vs[nidx];
1895 v2oe_v2[is_index[v]] = vs[pidx];
1896 v2hf_map_cid[is_index[v]] = *cid;
1897 v2hf_map_lfid[is_index[v]] = i;
1902 for(
int i = nv - 2; i >= 0; i-- )
1903 is_index[i + 1] = is_index[i];
1914 for(
int i = 0; i < nfpc; i++ )
1919 if( sibcid != 0 )
continue;
1922 std::vector< EntityHandle > vs( nvF );
1925 for(
int k = 0; k < nvF; k++ )
1929 if( vmax <= conn[
id] )
1935 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
1943 for(
int ind = is_index[v]; ind <= is_index[v + 1] - 1; ind++ )
1945 if( ( v2oe_v1[ind] == v1 ) && ( v2oe_v2[ind] == v2 ) )
1949 int cur_lfid = v2hf_map_lfid[ind];
1969 std::multimap< EntityHandle, EntityHandle > comps;
1979 for(
int i = 0; i < nvpc; ++i )
1987 if( hf == 0 && !found && (
v2hfs.empty() || (
v2hfs.find( v ) ==
v2hfs.end() ) ) )
1995 else if( hf != 0 && !found )
2001 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, hf ) );
2002 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
2005 else if( hf == 0 && !found && ( !
v2hfs.empty() ) && (
v2hfs.find( v ) !=
v2hfs.end() ) )
2010 v2hfs.insert( std::pair< EntityHandle, HFacet >( v, nwhf ) );
2039 for(
int i = 0; i < nfpc; ++i )
2048 for(
int j = 0; j < nvF; ++j )
2065 std::multimap< EntityHandle, EntityHandle >& comps,
2074 int Stksize = 0, count = -1;
2080 while( Stksize >= 0 )
2092 comps.insert( std::pair< EntityHandle, EntityHandle >( vid, cur_cid ) );
2102 for(
int i = 0; i < nvpc; ++i )
2104 if( conn[i] == vid )
2110 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2117 for(
int i = 0; i < nhf_thisv; ++i )
2120 hf_ngb =
sibhfs[nfpc * cidx + ind];
2139 for(
int i = 0; i < Stksize; i++ )
2142 for(
int i = 0; i <= count; i++ )
2150 std::multimap< EntityHandle, EntityHandle >& comps )
2154 if( comps.empty() )
return found;
2156 std::pair< std::multimap< EntityHandle, EntityHandle >::iterator,
2157 std::multimap< EntityHandle, EntityHandle >::iterator >
2160 rit = comps.equal_range( vid );
2162 for( std::multimap< EntityHandle, EntityHandle >::iterator it = rit.first; it != rit.second; ++it )
2164 if( it->second == cell )
2178 adjents.reserve( 20 );
2185 std::vector< EntityHandle > start_cells;
2186 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) )
2188 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2190 it_hes =
v2hfs.equal_range( vid );
2192 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2206 for(
int i = 0; i < (int)start_cells.size(); i++ )
2207 cellq[i] = start_cells[i];
2209 int qsize = start_cells.size();
2213 while( num_qvals < qsize )
2215 cur_cid =
cellq[num_qvals];
2219 adjents.push_back( cur_cid );
2228 for(
int i = 0; i < nvpc; ++i )
2230 if( conn[i] == vid )
2236 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2243 for(
int i = 0; i < nhf_thisv; ++i )
2246 hf =
sibhfs[nfpc * cidx + ind];
2263 for(
int i = 0; i < qsize; i++ )
2270 std::vector< EntityHandle >& adjents,
2271 std::vector< int >* leids )
2280 adjents.reserve( 20 );
2281 if( leids != NULL ) leids->reserve( 20 );
2294 std::vector< EntityHandle > start_cells;
2298 if( hf1 == 0 && !
v2hfs.empty() )
2300 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2302 it_hes =
v2hfs.equal_range( v_start );
2304 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2314 if( hf2 == 0 && !
v2hfs.empty() )
2316 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2318 it_hes =
v2hfs.equal_range( v_end );
2320 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2332 std::sort( start_cells.begin(), start_cells.end() );
2333 std::vector< EntityHandle >::iterator last = std::unique( start_cells.begin(), start_cells.end() );
2334 start_cells.erase( last, start_cells.end() );
2336 for(
int i = 0; i < (int)start_cells.size(); i++ )
2337 cellq[i] = start_cells[i];
2339 int qsize = start_cells.size();
2342 while( num_qvals < qsize )
2351 int lv0 = -1, lv1 = -1, lv = -1;
2354 for(
int i = 0; i < nvpc; i++ )
2356 if( v_start == conn[i] )
2361 else if( v_end == conn[i] )
2368 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2370 adjents.push_back( cell_id );
2371 if( leids != NULL ) leids->push_back(
lConnMap3D[
index].lookup_leids[lv0][lv1] );
2376 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2379 for(
int i = 0; i < nhf_thisv; i++ )
2398 for(
int i = 0; i < qsize; i++ )
2406 std::vector< EntityHandle >& adjents,
2407 std::vector< int >* leids,
2408 std::vector< int >* adj_orients )
2416 adjents.reserve( 20 );
2421 leids->reserve( 20 );
2423 if( adj_orients != NULL )
2425 adj_orients->clear();
2426 adj_orients->reserve( 20 );
2443 std::vector< EntityHandle > start_cells;
2447 if( hf1 == 0 && !
v2hfs.empty() )
2449 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2451 it_hes =
v2hfs.equal_range( v_start );
2453 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2463 if( hf2 == 0 && !
v2hfs.empty() )
2465 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2467 it_hes =
v2hfs.equal_range( v_end );
2469 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2481 std::sort( start_cells.begin(), start_cells.end() );
2482 std::vector< EntityHandle >::iterator last = std::unique( start_cells.begin(), start_cells.end() );
2483 start_cells.erase( last, start_cells.end() );
2485 for(
int i = 0; i < (int)start_cells.size(); i++ )
2486 cellq[i] = start_cells[i];
2488 int qsize = start_cells.size();
2491 while( num_qvals < qsize )
2500 int lv0 = -1, lv1 = -1, lv = -1;
2503 for(
int i = 0; i < nvpc; i++ )
2505 if( v_start == conn[i] )
2510 else if( v_end == conn[i] )
2517 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2519 adjents.push_back( cell_id );
2520 if( leids != NULL ) leids->push_back(
lConnMap3D[
index].lookup_leids[lv0][lv1] );
2522 if( adj_orients != NULL )
2527 if( ( v_start == conn[id1] ) && ( v_end == conn[id2] ) )
2528 adj_orients->push_back( 1 );
2529 else if( ( v_start == conn[id2] ) && ( v_end == conn[id1] ) )
2530 adj_orients->push_back( 0 );
2533 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2538 for(
int i = 0; i < nhf_thisv; i++ )
2557 for(
int i = 0; i < qsize; i++ )
2565 std::vector< EntityHandle >& adjents,
2566 std::vector< int >* leids,
2567 std::vector< int >* adj_orients )
2575 adjents.reserve( 20 );
2580 leids->reserve( 20 );
2582 if( adj_orients != NULL )
2584 adj_orients->clear();
2585 adj_orients->reserve( 20 );
2602 std::vector< EntityHandle > start_cells;
2606 if( ( hf1 == 0 ) && (
v2hfs.find( v_start ) !=
v2hfs.end() ) && ( hf2 == 0 ) &&
2609 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2611 it_hes =
v2hfs.equal_range( v_start );
2613 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2627 for(
int c = 0; c < (int)start_cells.size(); c++ )
2629 cellq[0] = start_cells[c];
2634 while( num_qvals < qsize )
2643 int lv0 = -1, lv1 = -1, lv = -1;
2646 for(
int i = 0; i < nvpc; i++ )
2648 if( v_start == conn[i] )
2653 else if( v_end == conn[i] )
2660 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2662 adjents.push_back( cell_id );
2663 if( leids != NULL ) leids->push_back(
lConnMap3D[
index].lookup_leids[lv0][lv1] );
2665 if( adj_orients != NULL )
2670 if( ( v_start == conn[id1] ) && ( v_end == conn[id2] ) )
2671 adj_orients->push_back( 1 );
2672 else if( ( v_start == conn[id2] ) && ( v_end == conn[id1] ) )
2673 adj_orients->push_back( 0 );
2676 for(
int i = 0; i < qsize; i++ )
2686 for(
int i = 0; i < nhf_thisv; i++ )
2705 for(
int i = 0; i < qsize; i++ )
2713 std::vector< EntityHandle >& adjents,
2714 std::vector< int >* lfids )
2733 std::vector< EntityHandle >& adjents,
2734 std::vector< int >* lfids )
2742 adjents.reserve( 4 );
2743 adjents.push_back( cid );
2747 lfids->reserve( 4 );
2748 lfids->push_back( lfid );
2758 adjents.push_back( sibcid );
2759 if( lfids != NULL ) lfids->push_back( siblid );
2766 std::vector< EntityHandle >& cid,
2767 std::vector< int >& leid )
2787 std::vector< EntityHandle > start_cells;
2791 int ncomps1 = 0, ncomps2 = 0, ncomp;
2792 if( hf1 == 0 && !
v2hfs.empty() )
2794 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2796 it_hes =
v2hfs.equal_range( v_start );
2798 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2810 if( hf2 == 0 && !
v2hfs.empty() )
2812 std::pair< std::multimap< EntityHandle, HFacet >::iterator, std::multimap< EntityHandle, HFacet >::iterator >
2814 it_hes =
v2hfs.equal_range( v_end );
2816 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
2828 ncomp = std::min( ncomps1, ncomps2 );
2831 if( start_cells.empty() )
return found;
2833 for(
int i = 0; i < (int)start_cells.size(); i++ )
2834 cellq[i] = start_cells[i];
2836 int qsize = start_cells.size();
2839 while( num_qvals < qsize )
2848 int lv0 = -1, lv1 = -1, lv = -1;
2851 for(
int i = 0; i < nvpc; i++ )
2853 if( v_start == conn[i] )
2858 else if( v_end == conn[i] )
2865 if( ( lv0 >= 0 ) && ( lv1 >= 0 ) )
2868 cid.push_back( cell_id );
2871 if( (
int)cid.size() == ncomp )
break;
2877 if( lv < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
2878 for(
int i = 0; i < nhf_thisv; i++ )
2897 for(
int i = 0; i < qsize; i++ )
2918 std::vector< EntityHandle > start_cells;
2919 int vidx, locfv0 = -1;
2922 for(
int i = 0; i < nvF; i++ )
2932 else if( hf == 0 &&
v2hfs.find( fid_verts[i] ) !=
v2hfs.end() )
2934 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
2935 std::multimap< EntityHandle, HFacet >::iterator >
2937 it_hfs =
v2hfs.equal_range( fid_verts[i] );
2939 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hfs.first; it != it_hfs.second; ++it )
2948 if( start_cells.empty() )
return false;
2953 int Stksize = 0, count = -1;
2955 for(
int i = 0; i < (int)start_cells.size(); i++ )
2958 Stksize = start_cells.size() - 1;
2960 while( Stksize >= 0 )
2971 int lv[4] = { -1, -1, -1, -1 };
2973 for(
int i = 0; i < nvpc; i++ )
2975 for(
int j = 0; j < nvF; j++ )
2976 if( conn[i] == fid_verts[j] )
2987 for(
int i = 0; i < nhf_thisv; ++i )
2991 for(
int j = 0; j < nvF; ++j )
2993 for(
int k = 0; k < nvF; ++k )
2998 if( lcnt == nvF )
break;
3008 if( locfv0 < 0 || lv[locfv0] < 0 )
MB_SET_ERR( MB_FAILURE,
"did not find local vertex " );
3014 for(
int i = 0; i < nhf_thisv; ++i )
3017 hf =
sibhfs[nfpc * cidx + ind];
3036 for(
int i = 0; i < Stksize; i++ )
3039 for(
int i = 0; i <= count; i++ )
3048 adjents.reserve( 20 );
3056 for(
int lfid = 0; lfid < nfpc; ++lfid )
3060 if( sibcid != 0 ) adjents.push_back( sibcid );
3073 adjents.reserve( 20 );
3083 std::vector< EntityHandle > temp;
3084 for(
int i = 0; i < ns; i++ )
3093 for(
int j = 0; j < (int)temp.size(); j++ )
3100 for(
int k = 0; k < nle; k++ )
3103 if( ( ( econn[0] == conn[lv0] ) && ( econn[1] == conn[lv1] ) ) ||
3104 ( ( econn[1] == conn[lv0] ) && ( econn[0] == conn[lv1] ) ) )
3106 adjents.push_back( temp[j] );
3110 if( count == nle )
break;
3120 adjents.reserve( 10 );
3132 for(
int i = 0; i < nfpc; i++ )
3135 for(
int j = 0; j < nvf; j++ )
3138 half_faces[i][j] = conn[ind];
3143 int search_verts[2];
3147 std::vector< EntityHandle > temp;
3149 for(
int i = 0; i < 2; i++ )
3152 int lv = search_verts[i];
3157 if( temp.size() == 0 )
continue;
3161 for(
int k = 0; k < (int)temp.size(); k++ )
3168 for(
int j = 0; j < nhfthisv; j++ )
3174 if( fsize != nvF )
continue;
3182 for(
int p = 0; p < (int)adjents.size(); p++ )
3184 if( adjents[p] == temp[k] )
3190 if( !found ) adjents.push_back( temp[k] );
3205 int ncells = cells.
size();
3206 int total_edges = nepc * ncells;
3207 int total_faces = nfpc * ncells;
3209 std::vector< int > trackE( total_edges, 0 );
3210 std::vector< int > trackF( total_faces, 0 );
3212 std::vector< EntityHandle > inc_cids, sib_cids;
3213 std::vector< int > inc_leids, sib_lfids;
3218 for(
int i = 0; i < nepc; i++ )
3223 int id = nepc * ( cells.
index( *it ) ) + i;
3229 total_edges -= inc_cids.size() - 1;
3230 for(
int j = 0; j < (int)inc_cids.size(); j++ )
3231 trackE[nepc * ( cells.
index( inc_cids[j] ) ) + inc_leids[j]] = 1;
3236 for(
int i = 0; i < nfpc; i++ )
3241 int id = nfpc * ( cells.
index( *it ) ) + i;
3247 if( sib_cids.size() == 1 )
continue;
3249 total_faces -= sib_cids.size() - 1;
3250 trackF[nfpc * ( cells.
index( sib_cids[1] ) ) + sib_lfids[1]] = 1;
3255 nedges[0] = total_edges;
3256 nfaces[0] = total_faces;
3268 for(
int i = 0; i <= count; i++ )
3270 if( ent == ent_list[i] )
3273 if( get_index ) *
index = i;
3283 std::vector< EntityHandle >& ents,
3284 std::vector< int >& lids,
3285 std::vector< int >& lfids )
3296 std::vector< EntityHandle > adjents;
3297 std::vector< int > adjlids;
3310 std::vector< int > mark( adjents.size(), 0 );
3313 for(
int k = 0; k < (int)adjents.size(); k++ )
3316 if( mark[k] != 0 )
continue;
3322 for(
int i = 0; i < 2; i++ )
3325 int cur_leid = adjlids[k];
3339 if( ( cur_cell == adjents[k] ) || ( cur_cell == 0 ) )
break;
3347 int lv0 = -1, lv1 = -1, idx = -1;
3348 for(
int j = 0; j < nv_curF; j++ )
3351 if( vstart == sib_conn[idx] ) lv0 = idx;
3352 if( vend == sib_conn[idx] ) lv1 = idx;
3355 assert( ( lv0 >= 0 ) && ( lv1 >= 0 ) );
3360 if( lfid == chk_lfid )
3365 int ind = std::find( adjents.begin(), adjents.end(), cur_cell ) - adjents.begin();
3370 if( cur_cell != 0 )
break;
3375 for(
int c = 0; c < count; c++ )
3377 for(
int i = 0; i < (int)adjents.size(); i++ )
3379 if( mark[i] == c + 1 )
3382 for(
int j = 0; j < nfpc; j++ )
3388 ents.push_back( adjents[i] );
3389 lids.push_back( adjlids[i] );
3390 lfids.push_back( j );
3411 int nwsz = 0, insz = 0;
3419 sibhvs.resize( insz + nwsz, 0 );
3423 if( ( !
v2he.empty() ) )
3425 else if( ( !
v2hf.empty() ) )
3428 MB_SET_ERR( MB_FAILURE,
"Trying to resize ahf maps for a mesh with no edges, faces and cells" );
3437 v2hv.resize( insz + nwsz, 0 );
3448 nwsz = nfaces * nepf;
3450 sibhes.resize( insz + nwsz, 0 );
3457 v2he.resize( insz + nwsz, 0 );
3468 nwsz = ncells * nfpc;
3470 sibhfs.resize( insz + nwsz, 0 );
3477 v2hf.resize( insz + nwsz, 0 );
3485 bool status =
false;
3489 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) ) status =
true;
3494 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) ) status =
true;
3497 MB_SET_ERR( MB_FAILURE,
"Requesting non-manifold vertex checks for either (1) 1D mesh or "
3498 "(2) not-implemented entity types" );
3507 int num_halffacets )
3512 if( num_halffacets != 2 )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfvertices." );
3515 for(
int i = 0; i < 2; i++ )
3526 if( num_halffacets != nepf )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfedges." );
3529 for(
int i = 0; i < nepf; i++ )
3541 if( num_halffacets != nfpc )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halffaces." );
3544 for(
int i = 0; i < nfpc; i++ )
3592 int num_halffacets )
3597 if( num_halffacets != 2 )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfvertices" );
3600 for(
int i = 0; i < 2; i++ )
3608 if( num_halffacets != nepf )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halfedges." );
3611 for(
int i = 0; i < nepf; i++ )
3620 if( num_halffacets != nfpc )
MB_SET_ERR( MB_FAILURE,
"Incorrect number of halffaces." );
3623 for(
int i = 0; i < nfpc; i++ )
3663 std::vector< EntityHandle >& inci_entid,
3664 std::vector< int >& inci_lid )
3678 if( hf == 0 && (
v2hes.find( vid ) !=
v2hes.end() ) )
3680 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
3681 std::multimap< EntityHandle, HFacet >::iterator >
3683 it_hes =
v2hes.equal_range( vid );
3685 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
3696 else if( hf == 0 && (
v2hes.find( vid ) ==
v2hes.end() ) )
3705 if( hf == 0 && (
v2hfs.find( vid ) !=
v2hfs.end() ) )
3707 std::pair< std::multimap< EntityHandle, HFacet >::iterator,
3708 std::multimap< EntityHandle, HFacet >::iterator >
3710 it_hes =
v2hfs.equal_range( vid );
3712 for( std::multimap< EntityHandle, HFacet >::iterator it = it_hes.first; it != it_hes.second; ++it )
3723 else if( hf == 0 && (
v2hfs.find( vid ) ==
v2hfs.end() ) )
3735 std::vector< EntityHandle >& set_entid,
3736 std::vector< int >& set_lid )
3744 if( set_entid.size() == 1 )
3749 for(
int i = 0; i < (int)set_entid.size(); i++ )
3752 v2hes.insert( std::pair< EntityHandle, HFacet >( vid, hf ) );
3758 if( set_entid.size() == 1 )
3767 for(
int i = 0; i < (int)set_entid.size(); i++ )
3770 v2hfs.insert( std::pair< EntityHandle, HFacet >( vid, hf ) );
3808 entity_total = memory_total = 0;
3810 if( !
v2hv.empty() ) entity_total +=
v2hv.capacity() *
sizeof(
HFacet ) +
sizeof(
v2hv );
3814 if( !
v2he.empty() ) entity_total +=
v2he.capacity() *
sizeof(
HFacet ) +
sizeof(
v2he );
3818 if( !
v2hf.empty() ) entity_total +=
v2hf.capacity() *
sizeof(
HFacet ) +
sizeof(
v2hf );
3821 memory_total = entity_total;
3834 if(
id == 0 )
return handle;