Skip to content

Commit

Permalink
Implement makeOrientedNormals via autoOrientLocalTriangulations (Mesh…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedr authored Feb 15, 2024
1 parent 45dac14 commit 55bd6af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions source/MRMesh/MRPointCloudMakeNormals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,15 @@ std::optional<VertNormals> makeOrientedNormals( const PointCloud& pointCloud,
}

std::optional<VertNormals> makeOrientedNormals( const PointCloud& pointCloud,
const AllLocalTriangulations& triangs, const ProgressCallback & progress )
AllLocalTriangulations& triangs, const ProgressCallback & progress )
{
MR_TIMER

auto optNormals = makeUnorientedNormals( pointCloud, triangs, subprogress( progress, 0.0f, 0.1f ) );
if ( !optNormals )
return optNormals;

if ( !orientNormals( pointCloud, *optNormals, triangs, subprogress( progress, 0.1f, 1.0f ) ) )
optNormals.reset();
if ( !autoOrientLocalTriangulations( pointCloud, triangs, subprogress( progress, 0.0f, 0.9f ) ) )
return {};

return optNormals;
// since triangulations are oriented then normals will be oriented as well
return makeUnorientedNormals( pointCloud, triangs, subprogress( progress, 0.9f, 1.0f ) );
}

VertNormals makeNormals( const PointCloud& pointCloud, int avgNeighborhoodSize )
Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRPointCloudMakeNormals.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ MRMESH_API bool orientNormals( const PointCloud& pointCloud, VertNormals& normal
float radius, const ProgressCallback & progress = {} );

/// \brief Makes normals for valid points of given point cloud; directions of close points are selected to be consistent;
/// \triangs triangulation neighbours of each point
/// \triangs triangulation neighbours of each point, which are oriented during the call as well
/// \return nullopt if progress returned false
/// \ingroup PointCloudGroup
[[nodiscard]] MRMESH_API std::optional<VertNormals> makeOrientedNormals( const PointCloud& pointCloud,
const AllLocalTriangulations& triangs, const ProgressCallback & progress = {} );
AllLocalTriangulations& triangs, const ProgressCallback & progress = {} );

/// \brief Makes consistent normals for valid points of given point cloud
/// \param avgNeighborhoodSize avg num of neighbors of each individual point
Expand Down

0 comments on commit 55bd6af

Please sign in to comment.