0

Looks like there is a discrepancy in the FreeCAD source code.

Code statements

FreeCAD has this code for repairing mesh:

https://github.com/FreeCAD/FreeCAD/blob/5d49bf78de785a536f941f1a6d06d432582a95d3/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp#L1410

void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index)
{
  // coincident corners (either topological or geometrical)
  for (int i=0; i<3; i++) {
  
      // ...
  
      // isolate the face and remove it
      rFace._aulNeighbours[0] = ULONG_MAX;
      rFace._aulNeighbours[1] = ULONG_MAX;
      rFace._aulNeighbours[2] = ULONG_MAX;
      _rclMesh.DeleteFacet(index); // *** Facet is isolated before deleting
      return;
      
      // ...
  }  
  
  // We have a facet of the form
  // P0 +----+------+P2
  //         P1
  for (int j=0; j<3; j++) {
  
  // ...
  
      else
        _rclMesh.DeleteFacet(index); // *** Facet is NOT isolated before deleting
      return;

// ...

  }

}

Difference

The above statements contain two calls to this method MeshKernel::DeleteFacet with this difference:

  • The first call isolates the facet before calling delete method
  • The second call doesn't isolate the facet before calling delete method

Note

It should be noted that the delete method itself depends upon neighborhood data to re-adjust neighbors, so by isolating a facet, we are basically throwing away its neighborhood data. Hence, its neighborhood cannot be re-adjusted:

bool MeshKernel::DeleteFacet (const MeshFacetIterator &rclIter)
{
    // ...
    
    // *** The following loop depends upon the neighborhood data.
    // *** So if facet is isolated before calling this method,
    // *** the following loop is skipped and the neighborhood cannot be re-adjusted.
    // *** Am I right?
    
    // invalidate neighbour indices of the neighbour facet to this facet
    for (i = 0; i < 3; i++) {
        ulNFacet = rclIter._clIter->_aulNeighbours[i];
        if (ulNFacet != ULONG_MAX) {
            for (j = 0; j < 3; j++) {
                if (_aclFacetArray[ulNFacet]._aulNeighbours[j] == ulInd) {
                    _aclFacetArray[ulNFacet]._aulNeighbours[j] = ULONG_MAX;
                    break;
                }
            }
        }
    }

    // ...
}

Question

Why does the above difference exist when deleting facets? Is there any specific reason for it?

Megidd
  • 7,089
  • 6
  • 65
  • 142

0 Answers0