SpiecsEngine
 
Loading...
Searching...
No Matches

◆ FindBoundaryPoints()

bool Spices::MeshProcessor::FindBoundaryPoints ( MeshPack * meshPack,
const std::vector< glm::uvec3 > & primVertices,
std::unordered_map< uint32_t, bool > & boundaryPoints,
std::unordered_map< uint32_t, bool > & stableBoundaryPoints,
std::unordered_map< uint32_t, EdgePoint > & boundaryEdgePoints,
std::unordered_map< uint32_t, std::unordered_map< uint32_t, bool > > & pointConnect )
staticprivate

Find Points located in Boundaries.

Parameters
[in]meshPackMeshPack.
[in]primVertices.
[in,out]boundaryPoints.
[in,out]stableBoundaryPoints.
[in,out]boundaryEdgePoints.
[in,out]pointConnect.
Returns
Returns true if succeed.

Get edge connected primitive.

Get pointconnect.

get bound edge points.

only stable points with high curvature.

Get edge connected primitive.

Get pointconnect.

get bound edge points.

only stable points with high curvature.

Definition at line 809 of file MeshProcessor.cpp.

817 {
819
823 std::unordered_map<Edge, uint32_t> edgesConnects;
824 auto& vertices = *meshPack->m_MeshResource.vertices.attributes;
825 for (uint32_t triangleIndex = 0; triangleIndex < primVertices.size(); triangleIndex++)
826 {
827 auto& primVertex = primVertices[triangleIndex];
828 std::array<uint32_t, 3> primVertexArray = { primVertex.x, primVertex.y, primVertex.z };
829
830 for (uint32_t i = 0; i < 3; i++)
831 {
832 Edge edge;
833 edge.first = vertices[primVertexArray[i]].x;
834 edge.second = vertices[primVertexArray[(i + 1) % 3]].x;
835
836 if (edgesConnects.find(edge) == edgesConnects.end())
837 {
838 edgesConnects[edge] = 1;
839 }
840 else
841 {
842 edgesConnects[edge]++;
843 }
844 }
845 }
846
850 for (auto& [edge, connects] : edgesConnects)
851 {
852 pointConnect[edge.first][edge.second] = true;
853 pointConnect[edge.first][edge.first] = true;
854
855 pointConnect[edge.second][edge.first] = true;
856 pointConnect[edge.second][edge.second] = true;
857 }
858
859 /*
860 * @brief remove internal edge.
861 */
862 for (auto first = edgesConnects.begin(), last = edgesConnects.end(); first != last;)
863 {
864 if ((*first).second != 1)
865 {
866 first = edgesConnects.erase(first);
867 }
868 else
869 {
870 ++first;
871 }
872 }
873
874 for (auto& [edge, connects] : edgesConnects)
875 {
876 boundaryPoints[edge.first] = true;
877 boundaryPoints[edge.second] = true;
878 }
879
883 for (auto& [edge, connects] : edgesConnects)
884 {
885 if (boundaryEdgePoints.find(edge.first) == boundaryEdgePoints.end())
886 {
887 boundaryEdgePoints[edge.first].self = edge.first;
888 boundaryEdgePoints[edge.first].next = edge.second;
889 }
890 else
891 {
892 boundaryEdgePoints[edge.first].prev = edge.second;
893 }
894
895 if (boundaryEdgePoints.find(edge.second) == boundaryEdgePoints.end())
896 {
897 boundaryEdgePoints[edge.second].self = edge.second;
898 boundaryEdgePoints[edge.second].next = edge.first;
899 }
900 else
901 {
902 boundaryEdgePoints[edge.second].prev = edge.first;
903 }
904 }
905
909 auto& position = *meshPack->m_MeshResource.positions.attributes;
910 for (auto& pair : boundaryEdgePoints)
911 {
912 if (!pair.second.valid()) continue;
913
914 glm::vec3 l = glm::normalize(position[pair.second.next] - position[pair.first]);
915 glm::vec3 r = glm::normalize(position[pair.second.prev] - position[pair.first]);
916
917 if (glm::dot(l, r) > -0.98f)
918 {
919 stableBoundaryPoints[pair.second.self] = true;
920
921#define ExpandStablePoint
922#ifdef ExpandStablePoint
923
924 stableBoundaryPoints[pair.second.next] = true;
925 stableBoundaryPoints[pair.second.prev] = true;
926
927#endif
928
929 }
930 }
931
932 return true;
933 }
#define SPICES_PROFILE_ZONE