MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / addTriangles

Method addTriangles

source/MRMesh/MRIdentifyVertices.cpp:17–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17void 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

Callers 3

fromBinaryStlFunction · 0.80
fromASCIIStlFunction · 0.80
fromPointTriplesMethod · 0.80

Calls 6

ParallelForFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
capacityMethod · 0.45
resizeMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected