0

看起来 FreeCAD 源代码中存在差异。

代码语句

FreeCAD 有这个修复网格的代码:

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;

// ...

  }

}

区别

上述语句包含对该方法的两次调用,但MeshKernel::DeleteFacet有以下区别:

  • 第一次调用在调用 delete 方法之前隔离了 facet
  • 在调用 delete 方法之前,第二次调用不会隔离构面

笔记

需要注意的是,删除方法本身依赖于邻域数据来重新调整邻域,所以通过隔离一个方面,我们基本上是在丢弃它的邻域数据。因此,它的邻域不能重新调整:

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;
                }
            }
        }
    }

    // ...
}

问题

为什么删除分面时会存在上述差异?有什么具体原因吗?

4

0 回答 0