| 15 | } |
| 16 | |
| 17 | void VertexIdentifier::addTriangles( const std::vector<Triangle3f> & buffer ) |
| 18 | { |
| 19 | MR_TIMER; |
| 20 | assert ( t_.size() + buffer.size() <= t_.capacity() ); |
| 21 | vertsInHMap_.resize( buffer.size() ); |
| 22 | |
| 23 | for (;;) |
| 24 | { |
| 25 | auto buckets0 = hmap_.bucket_count(); |
| 26 | |
| 27 | const auto subcnt = hmap_.subcnt(); |
| 28 | ParallelFor( size_t( 0 ), subcnt, [&]( size_t myPartId ) |
| 29 | { |
| 30 | for ( size_t j = 0; j < buffer.size(); ++j ) |
| 31 | { |
| 32 | const auto & st = buffer[j]; |
| 33 | auto & it = vertsInHMap_[j]; |
| 34 | for ( int k = 0; k < 3; ++k ) |
| 35 | { |
| 36 | const auto & p = st[k]; |
| 37 | auto hashval = hmap_.hash( p ); |
| 38 | auto idx = hmap_.subidx( hashval ); |
| 39 | if ( idx != myPartId ) |
| 40 | continue; |
| 41 | it[k] = &hmap_[ p ]; |
| 42 | } |
| 43 | } |
| 44 | } ); |
| 45 | |
| 46 | if ( buckets0 == hmap_.bucket_count() ) |
| 47 | break; // the number of buckets has not changed - all pointers are valid |
| 48 | } |
| 49 | |
| 50 | for ( size_t j = 0; j < buffer.size(); ++j ) |
| 51 | { |
| 52 | const auto & st = buffer[j]; |
| 53 | const auto & it = vertsInHMap_[j]; |
| 54 | for ( int k = 0; k < 3; ++k ) |
| 55 | { |
| 56 | if ( !it[k]->valid() ) |
| 57 | { |
| 58 | *it[k] = VertId( (int)points_.size() ); |
| 59 | points_.push_back( st[k] ); |
| 60 | } |
| 61 | } |
| 62 | t_.push_back( { *it[0], *it[1], *it[2] } ); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } //namespace MeshBuilder |
| 67 | |