1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

0032254: Refactor frontierAdjust function; Use abs angle

This commit is contained in:
Dzmitry Razmyslovich
2021-03-27 20:29:35 +01:00
parent 4a837ecec2
commit c1a8dfe3be
2 changed files with 75 additions and 51 deletions

View File

@@ -377,7 +377,7 @@ void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
createTriangles( theVertexIndexes( anVertexIdx ), aLoopEdges ); createTriangles( theVertexIndexes( anVertexIdx ), aLoopEdges );
// Add other nodes to the mesh // Add other nodes to the mesh
createTrianglesOnNewVertices (theVertexIndexes, Message_ProgressRange()); createTrianglesOnNewVertices (theVertexIndexes, Message_ProgressRange(), Standard_True);
} }
RemoveAuxElements (); RemoveAuxElements ();
@@ -544,7 +544,8 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer theVertexI
//======================================================================= //=======================================================================
void BRepMesh_Delaun::createTrianglesOnNewVertices( void BRepMesh_Delaun::createTrianglesOnNewVertices(
IMeshData::VectorOfInteger& theVertexIndexes, IMeshData::VectorOfInteger& theVertexIndexes,
const Message_ProgressRange& theRange) const Message_ProgressRange& theRange,
Standard_Boolean doFrontierAdjust)
{ {
Handle(NCollection_IncAllocator) aAllocator = Handle(NCollection_IncAllocator) aAllocator =
new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
@@ -633,7 +634,13 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
} }
} }
ProcessConstraints(); insertInternalEdges ();
if (doFrontierAdjust)
{
// Adjustment of meshes to boundary edges
frontierAdjust ();
}
} }
//======================================================================= //=======================================================================
@@ -869,44 +876,49 @@ void BRepMesh_Delaun::frontierAdjust()
IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
Handle(IMeshData::MapOfInteger) aIntFrontierEdges = new IMeshData::MapOfInteger; Handle(IMeshData::MapOfInteger) aIntFrontierEdges = new IMeshData::MapOfInteger;
for ( Standard_Integer aPass = 1; aPass <= 2; ++aPass ) IMeshData::MapOfInteger aTrianglesList;
Standard_Boolean isModified = Standard_True;
Standard_Integer aPass = 1;
for ( ; isModified; ++aPass )
{ {
// 1 pass): find external triangles on boundary edges; isModified = Standard_False;
// 2 pass): find external triangles on boundary edges appeared aFailedFrontiers.Clear ();
// during triangles replacement.
IMeshData::IteratorOfMapOfInteger aFrontierIt (*aFrontier); IMeshData::IteratorOfMapOfInteger aFrontierIt (*aFrontier);
for (; aFrontierIt.More (); aFrontierIt.Next ()) for (; aFrontierIt.More (); aFrontierIt.Next ())
{ {
Standard_Integer aFrontierId = aFrontierIt.Key (); Standard_Integer aFrontierId = aFrontierIt.Key ();
const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo (aFrontierId); const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo (aFrontierId);
Standard_Integer aNbElem = aPair.Extent();
for( Standard_Integer aElemIt = 1; aElemIt <= aNbElem; ++aElemIt ) for( Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j )
{ {
const Standard_Integer aPriorElemId = aPair.Index( aElemIt ); const Standard_Integer aPriorElemId = aPair.Index(j);
if( aPriorElemId < 0 ) if( aPriorElemId < 0 )
continue; continue;
const BRepMesh_Triangle& aElement = GetTriangle(aPriorElemId); Standard_Integer e[3];
const Standard_Integer(&e)[3] = aElement.myEdges; Standard_Boolean o[3];
const Standard_Boolean(&o)[3] = aElement.myOrientations; GetTriangle( aPriorElemId ).Edges( e, o );
Standard_Boolean isTriangleFound = Standard_False;
for ( Standard_Integer n = 0; n < 3; ++n ) for ( Standard_Integer n = 0; n < 3; ++n )
{ {
if ( aFrontierId == e[n] && !o[n] ) if ( aFrontierIt.Key() == e[n] && !o[n] )
{ {
// Destruction of external triangles on boundary edges if ( !aTrianglesList.Contains(aPriorElemId) )
isTriangleFound = Standard_True; aTrianglesList.Add( aPriorElemId );
deleteTriangle( aPriorElemId, aLoopEdges );
break; break;
} }
} }
}
}
if ( isTriangleFound ) // destruction of external triangles on boundary edges
break; IMeshData::IteratorOfMapOfInteger anTriangleIt( aTrianglesList );
} for ( ; anTriangleIt.More(); anTriangleIt.Next() )
} deleteTriangle( anTriangleIt.Key(), aLoopEdges );
aTrianglesList.Clear();
// destrucrion of remaining hanging edges : // destrucrion of remaining hanging edges :
IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt (aLoopEdges); IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt (aLoopEdges);
@@ -916,20 +928,31 @@ void BRepMesh_Delaun::frontierAdjust()
if (myMeshData->ElementsConnectedTo (aLoopEdgeId).IsEmpty ()) if (myMeshData->ElementsConnectedTo (aLoopEdgeId).IsEmpty ())
myMeshData->RemoveLink (aLoopEdgeId); myMeshData->RemoveLink (aLoopEdgeId);
} }
aLoopEdges.Clear ();
// destruction of triangles crossing the boundary edges and // Now analyze the frontier and build the missing triangles
// their replacement by makeshift triangles aFrontierIt.Reset ();
for ( aFrontierIt.Reset(); aFrontierIt.More(); aFrontierIt.Next() ) for ( ; aFrontierIt.More(); aFrontierIt.Next() )
{ {
Standard_Integer aFrontierId = aFrontierIt.Key (); Standard_Integer aFrontierId = aFrontierIt.Key ();
if ( !myMeshData->ElementsConnectedTo( aFrontierId ).IsEmpty() ) const BRepMesh_Edge& anEdge = GetEdge(aFrontierId);
continue;
if ( myMeshData->ElementsConnectedTo(aFrontierId).IsEmpty() && (anEdge.FirstNode() != anEdge.LastNode())) // we fix mesh only for non-zero edges
{
Standard_Boolean isSuccess = Standard_Boolean isSuccess =
meshLeftPolygonOf (aFrontierId, Standard_True, aIntFrontierEdges); meshLeftPolygonOf (aFrontierId, Standard_True, aIntFrontierEdges);
if ( aPass == 2 && !isSuccess ) if (!isSuccess)
aFailedFrontiers.Append (aFrontierId); aFailedFrontiers.Append (aFrontierId);
else
isModified = Standard_True;
}
}
aIntFrontierEdges->Clear ();
if ( aPass > 1 ) {
isModified = Standard_False;
} }
} }
@@ -1501,7 +1524,7 @@ Standard_Boolean BRepMesh_Delaun::isVertexInsidePolygon(
aPrevVertexDir = aCurVertexDir; aPrevVertexDir = aCurVertexDir;
} }
if ( Abs( Angle2PI - aTotalAng ) > Precision::Angular() ) if ( Abs( Angle2PI - Abs (aTotalAng) ) > Precision::Angular() )
return Standard_False; return Standard_False;
return Standard_True; return Standard_True;

View File

@@ -298,7 +298,8 @@ private:
//! Creates the triangles on new nodes. //! Creates the triangles on new nodes.
void createTrianglesOnNewVertices (IMeshData::VectorOfInteger& theVertexIndices, void createTrianglesOnNewVertices (IMeshData::VectorOfInteger& theVertexIndices,
const Message_ProgressRange& theRange); const Message_ProgressRange& theRange,
Standard_Boolean doFrontierAdjust = Standard_False);
//! Cleanup mesh from the free triangles. //! Cleanup mesh from the free triangles.
void cleanupMesh(); void cleanupMesh();