| 43 | } |
| 44 | |
| 45 | VertBitSet 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 | |
| 96 | VertBitSet getPointsForRefineFeature( const PointCloud& pointCloud, const FeatureObject& feature, float distanceEps, float normalEps ) |
| 97 | { |
no test coverage detected