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

Function findSignedDistanceOneWay

source/MRMesh/MRMeshMeshDistance.cpp:158–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156};
157
158InternalZoneWithProjections findSignedDistanceOneWay( const MeshPart & a, const MeshPart & b,
159 const std::vector<FaceFace>& collisions,
160 bool bIsRef = false,
161 const AffineXf3f* rigidB2A = nullptr )
162{
163 const auto& ref = bIsRef ? b : a;
164 const auto& test = bIsRef ? a : b;
165
166 FaceBitSet refFaces;
167 refFaces.resize( ref.mesh.topology.edgePerFace().size() );
168
169 for ( const auto& ff : collisions )
170 refFaces.set( bIsRef ? ff.bFace : ff.aFace );
171
172 auto ref2Test = rigidB2A ? ( bIsRef ? *rigidB2A : rigidB2A->inverse() ) : AffineXf3f();
173 VertBitSet refRegionVerts;
174 if ( ref.region )
175 refRegionVerts = getIncidentVerts( ref.mesh.topology, *ref.region );
176 VertBitSet queue = getIncidentVerts( ref.mesh.topology, refFaces );
177
178 InternalZoneWithProjections res;
179 res.projectons.resize( ref.mesh.points.size(), { {}, 0.0f } );
180
181 while ( queue.any() )
182 {
183 tbb::enumerable_thread_specific<std::vector<VertId>> threadData;
184 BitSetParallelFor( queue, threadData, [&]( VertId id, auto& localData )
185 {
186 const auto point = rigidB2A ? ref2Test( ref.mesh.points[id] ) : ref.mesh.points[id];
187 auto projectRes = findProjection( point, test.mesh );
188 if ( !contains( test.region, projectRes.proj.face ) )
189 return;
190 const auto distance = test.mesh.signedDistance( point, projectRes );
191 if ( distance > 0.0f )
192 return;
193 res.projectons[id] = std::make_pair( projectRes.proj, distance );
194
195 for ( EdgeId e : orgRing( ref.mesh.topology, id ) )
196 {
197 const auto v = ref.mesh.topology.dest( e );
198 if ( !ref.region || refRegionVerts.test( v ) )
199 localData.push_back( v );
200 }
201 } );
202 res.vertBS |= queue;
203 queue.reset();
204 for ( const auto& verts : threadData )
205 for ( auto v : verts )
206 queue.set( v );
207 queue -= res.vertBS;
208 }
209
210 return res;
211}
212
213MeshMeshSignedDistanceResult findSignedDistance( const MeshPart & a, const MeshPart & b, const AffineXf3f* rigidB2A, float upDistLimitSq )
214{

Callers 1

findSignedDistanceFunction · 0.85

Calls 15

getIncidentVertsFunction · 0.85
BitSetParallelForFunction · 0.85
findProjectionFunction · 0.85
orgRingFunction · 0.85
signedDistanceMethod · 0.80
push_backMethod · 0.80
containsFunction · 0.70
resizeMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45
inverseMethod · 0.45
anyMethod · 0.45

Tested by

no test coverage detected