How to get external and internal boundary (holes) edges for mesh face

Hello, Has OpenCascade Functional, which:

1. allows to get the external and internal borders of the mesh (see image "Edges" below)?

2. Fill polygonal Holee (see image "Fill the Hole" below)?

qa qa's picture

Hello Vitaut,

There is no such functionality out of box. Two different ways can be proposed to solve your problem:

1) Write pure mesh-based algorithm to find inner and outer contours from scratch. After that it is possible to create planar faces on inner contours and create mesh on them.

2) Convert your mesh elements to the topological faces. Sew them. After these steps you can use ShapeAnalysis_FreeBounds class to find outer and inner contours. After that you can use algorithm proposed above.


qa, qa.

Vitaut Tryputsin's picture

Thank you for Your Answer. Can You give Sample of the code how to get outer and inner contours using ShapeAnalysis_FreeBounds class from TopoDS_Shape, or what functions from this class it need to use? Sorry i'm new in opencascad and I do not clearly understand  some from it.

qa qa's picture

Here it is:

  ShapeAnalysis_FreeBounds shapeAnalyzer(inputShape, 0.1);
  const TopoDS_Compound& wires = shapeAnalyzer.GetClosedWires();

  // Get the biggest wire from compound.
  // We suppose that outerWire have the biggest AABB.
  // Other wires will be considered as internal ones.
  TopoDS_Shape outerContour;
  double biggestAABB = -1.0;
  for(TopExp_Explorer iter(wires, TopAbs_WIRE); iter.More() ; iter.Next())
    Bnd_Box box;
    BRepBndLib::Add(iter.Current(), box); // Use triangulation in this case.

    if ( biggestAABB < box.SquareExtent() )
      biggestAABB = box.SquareExtent();
      outerContour= iter.Current();

This piece of code shows how to get outer wire from shape. All other wires are inner.

Vitaut Tryputsin's picture

Thank you. I'm understand. Your Idea is cool.