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

Function getVertsForRefineFeature

source/MRMesh/MRFeatureRefine.cpp:45–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45VertBitSet getVertsForRefineFeature( const Mesh& mesh, const FeatureObject& feature, float distanceEps, float normalEps )
46{
47 VertBitSet detectedVerts;
48 detectedVerts.resize( mesh.topology.lastValidVert() + 1, false );
49
50 const auto distanceEpsSq = distanceEps * distanceEps;
51 const auto cosNormalEps = std::cos( normalEps / 180.0f * PI_F );
52
53 BitSetParallelForAll( mesh.topology.getValidVerts(), [&] ( VertId v )
54 {
55 const auto proj = feature.projectPoint( mesh.points[v] );
56 const auto lenSq = ( proj.point - mesh.points[v] ).lengthSq();
57 if ( lenSq >= distanceEpsSq )
58 return;
59
60 if ( !proj.normal )
61 {
62 detectedVerts.set( v, true ); // normals are not support for current feature type;
63 return;
64 }
65
66 const auto& worldNormal = *proj.normal;
67
68 // check vert normal.
69 if ( std::abs( dot( worldNormal, mesh.normal( v ) ) ) >= cosNormalEps )
70 {
71 detectedVerts.set( v, true );
72 return;
73 }
74
75 // Also check the face normals surrounding the current vertex.
76 // If at least one face has a correct normal, add the vertex to the list.
77 // It is required for working with meshes created by CAD (like STEP files or create primitives),
78 // where almost all verts located at the sharp edged and have normals which is not correlated with surrounded faces.
79 for ( const auto e : orgRing( mesh.topology, v ) )
80 {
81 const auto f = mesh.topology.left( e );
82 if ( !f.valid() )
83 continue;
84
85 if ( std::abs( dot( worldNormal, mesh.normal( f ) ) ) >= cosNormalEps )
86 {
87 detectedVerts.set( v, true );
88 return;
89 }
90 }
91 } );
92
93 return detectedVerts;
94}
95
96VertBitSet getPointsForRefineFeature( const PointCloud& pointCloud, const FeatureObject& feature, float distanceEps, float normalEps )
97{

Callers 1

refineFeatureObjectFunction · 0.85

Calls 12

BitSetParallelForAllFunction · 0.85
absFunction · 0.85
orgRingFunction · 0.85
normalMethod · 0.80
leftMethod · 0.80
dotFunction · 0.70
resizeMethod · 0.45
lastValidVertMethod · 0.45
projectPointMethod · 0.45
lengthSqMethod · 0.45
setMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected