void MeshSimplifier::identifySubBoundaries()

in source/render/MeshSimplifier.cpp [277:316]


void MeshSimplifier::identifySubBoundaries(const int begin, const int end) {
  for (int i = begin; i < end; ++i) {
    vertexes[i].isBoundary = false;
  }

  for (int i = begin; i < end; ++i) {
    // Ignore if it has already been marked as boundary
    if (vertexes[i].isBoundary) {
      continue;
    }

    // If it only has one face, it is a boundary
    if (vertexes[i].facesIdx.size() == 1) {
      vertexes[i].isBoundary = true;
      continue;
    }

    bool isBorder = false;
    std::set<int> vertexesVisited;
    for (auto& faceIdx : vertexes[i].facesIdx) {
      for (int j = 0; j < NUM_VERTEXES_FACE; ++j) {
        const int vIdx = faces[faceIdx].vertexesIdx[j];
        if (vIdx != i) {
          // Check if we already visited this vertex on a previous face
          if (vertexesVisited.count(vIdx) == 0) {
            vertexesVisited.insert(vIdx);
            if (vertexes[vIdx].facesIdx.size() == 1 || commonFaces(i, vIdx).size() == 1) {
              vertexes[vIdx].isBoundary = true;
              isBorder = true;
              continue;
            }
          }
        }
      }
    }
    if (isBorder) {
      vertexes[i].isBoundary = true;
    }
  }
}