}
}
- meshSimplePolygon( thePolygon, thePolyBoxes );
+ BRepMesh::SequenceOfInteger* aPolygon1 = &thePolygon;
+ BRepMesh::SequenceOfBndB2d* aPolyBoxes1 = &thePolyBoxes;
+
+ BRepMesh::HSequenceOfInteger aPolygon2 = new BRepMesh::SequenceOfInteger;
+ BRepMesh::HSequenceOfBndB2d aPolyBoxes2 = new BRepMesh::SequenceOfBndB2d;
+
+ NCollection_Sequence<BRepMesh::HSequenceOfInteger> aPolyStack;
+ NCollection_Sequence<BRepMesh::HSequenceOfBndB2d> aPolyBoxStack;
+ for (;;)
+ {
+ decomposeSimplePolygon(*aPolygon1, *aPolyBoxes1, *aPolygon2, *aPolyBoxes2);
+ if (!aPolygon2->IsEmpty())
+ {
+ aPolyStack.Append(aPolygon2);
+ aPolyBoxStack.Append(aPolyBoxes2);
+
+ aPolygon2 = new BRepMesh::SequenceOfInteger;
+ aPolyBoxes2 = new BRepMesh::SequenceOfBndB2d;
+ }
+
+ if (aPolygon1->IsEmpty())
+ {
+ if (!aPolyStack.IsEmpty() && aPolygon1 == &(*aPolyStack.First()))
+ {
+ aPolyStack.Remove(1);
+ aPolyBoxStack.Remove(1);
+ }
+
+ if (aPolyStack.IsEmpty())
+ return;
+
+ aPolygon1 = &(*aPolyStack.ChangeFirst());
+ aPolyBoxes1 = &(*aPolyBoxStack.ChangeFirst());
+ }
+ }
}
//=======================================================================
//=======================================================================
//function : meshSimplePolygon
-//purpose : Triangulatiion of a closed simple polygon (polygon without
-// glued edges and loops) described by the list of indexes of
-// its edges in the structure.
-// (negative index means reversed edge)
+//purpose :
//=======================================================================
-void BRepMesh_Delaun::meshSimplePolygon(BRepMesh::SequenceOfInteger& thePolygon,
- BRepMesh::SequenceOfBndB2d& thePolyBoxes )
+void BRepMesh_Delaun::decomposeSimplePolygon(
+ BRepMesh::SequenceOfInteger& thePolygon,
+ BRepMesh::SequenceOfBndB2d& thePolyBoxes,
+ BRepMesh::SequenceOfInteger& thePolygonCut,
+ BRepMesh::SequenceOfBndB2d& thePolyBoxesCut)
{
// Check is the given polygon elementary
if ( meshElementaryPolygon( thePolygon ) )
+ {
+ thePolygon.Clear();
+ thePolyBoxes.Clear();
return;
-
+ }
// Polygon contains more than 3 links
Standard_Integer aFirstEdgeInfo = thePolygon(1);
Standard_Real aRefEdgeLen = aRefEdgeDir.Magnitude();
if ( aRefEdgeLen < Precision )
+ {
+ thePolygon.Clear();
+ thePolyBoxes.Clear();
return;
+ }
aRefEdgeDir /= aRefEdgeLen;
}
if ( aUsedLinkId == 0 )
+ {
+ thePolygon.Clear();
+ thePolyBoxes.Clear();
return;
+ }
BRepMesh_Edge aNewEdges[2] = {
// polygon.
if ( aUsedLinkId < aPolyLen )
{
- BRepMesh::SequenceOfInteger aRightPolygon;
- thePolygon.Split( aUsedLinkId, aRightPolygon );
- aRightPolygon.Prepend( -aNewEdgesInfo[2] );
-
- BRepMesh::SequenceOfBndB2d aRightPolyBoxes;
- thePolyBoxes.Split( aUsedLinkId, aRightPolyBoxes );
+ thePolygon.Split(aUsedLinkId, thePolygonCut);
+ thePolygonCut.Prepend( -aNewEdgesInfo[2] );
+ thePolyBoxes.Split(aUsedLinkId, thePolyBoxesCut);
Bnd_B2d aBox;
aBox.Add( aRefVertices[0] );
aBox.Add( aRefVertices[2] );
- aRightPolyBoxes.Prepend( aBox );
-
- meshSimplePolygon( aRightPolygon, aRightPolyBoxes );
+ thePolyBoxesCut.Prepend( aBox );
}
else
{
aBox.Add( aRefVertices[2] );
thePolyBoxes.SetValue( 1, aBox );
-
- meshSimplePolygon( thePolygon, thePolyBoxes );
}
}
BRepMesh::SequenceOfBndB2d& thePolyBoxes,
BRepMesh::HMapOfInteger theSkipped = NULL);
- //! Triangulatiion of a closed simple polygon (polygon without glued edges and loops)
- //! described by the list of indexes of its edges in the structure.
- //! (negative index means reversed edge)
- void meshSimplePolygon (BRepMesh::SequenceOfInteger& thePolygon,
- BRepMesh::SequenceOfBndB2d& thePolyBoxes);
+ //! Decomposes the given closed simple polygon (polygon without glued edges
+ //! and loops) on two simpler ones by adding new link at the most thin part
+ //! in respect to end point of the first link.
+ //! In case if source polygon consists of three links, creates new triangle
+ //! and clears source container.
+ //! @param thePolygon source polygon to be decomposed (first part of decomposition).
+ //! @param thePolyBoxes bounding boxes corresponded to source polygon's links.
+ //! @param thePolygonCut product of decomposition of source polygon (second part of decomposition).
+ //! @param thePolyBoxesCut bounding boxes corresponded to resulting polygon's links.
+ void decomposeSimplePolygon (
+ BRepMesh::SequenceOfInteger& thePolygon,
+ BRepMesh::SequenceOfBndB2d& thePolyBoxes,
+ BRepMesh::SequenceOfInteger& thePolygonCut,
+ BRepMesh::SequenceOfBndB2d& thePolyBoxesCut);
//! Triangulation of closed polygon containing only three edges.
inline Standard_Boolean meshElementaryPolygon (const BRepMesh::SequenceOfInteger& thePolygon);