mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0023409: Tricheck command doesn't report problem when triangulation has unexpected holes
Tricheck command improvement for checking triangulation holes on free links More obvious error message Added test case bugs demo CR23409 Modified test case offset wire_closed_outside_0_005 G7
This commit is contained in:
@@ -44,6 +44,12 @@
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_Polygon2D.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <BRepMesh_Edge.hxx>
|
||||
#include <NCollection_Map.hxx>
|
||||
|
||||
static Standard_Integer mpnames (Draw_Interpretor& , Standard_Integer , const char** );
|
||||
static Standard_Integer mpsetdefaultname (Draw_Interpretor& , Standard_Integer , const char** );
|
||||
@@ -330,6 +336,11 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
|
||||
}
|
||||
|
||||
//#######################################################################
|
||||
Standard_Boolean IsEqual(const BRepMesh_Edge& theFirst, const BRepMesh_Edge& theSecond)
|
||||
{
|
||||
return theFirst.IsEqual(theSecond);
|
||||
}
|
||||
|
||||
static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
@@ -354,12 +365,15 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
|
||||
Standard_Integer iF = aCheck.GetFaceNumWithFL(k);
|
||||
nbFree += nbEdge;
|
||||
di << "free links of face " << iF << "\n";
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iF));
|
||||
|
||||
const TopoDS_Shape& aShape = aMapF.FindKey(iF);
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aShape);
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
|
||||
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
|
||||
const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
|
||||
const gp_Trsf& trsf = aLoc.Transformation();
|
||||
|
||||
TColgp_Array1OfPnt pnts(1,2);
|
||||
TColgp_Array1OfPnt2d pnts2d(1,2);
|
||||
for (i=1; i <= nbEdge; i++) {
|
||||
@@ -420,11 +434,87 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
|
||||
}
|
||||
|
||||
// output errors summary to DRAW
|
||||
if ( nbFree > 0 || nbErr > 0 || nbAsync > 0 || nbFreeNodes > 0 )
|
||||
if ( nbFree > 0 || nbErr > 0 || nbAsync > 0 || nbFreeNodes > 0)
|
||||
di << "Free_links " << nbFree
|
||||
<< " Cross_face_errors " << nbErr
|
||||
<< " Async_edges " << nbAsync
|
||||
<< " Free_nodes " << nbFreeNodes << "\n";
|
||||
|
||||
|
||||
Standard_Integer aFaceId = 1;
|
||||
TopExp_Explorer aFaceExp(shape, TopAbs_FACE);
|
||||
for ( ; aFaceExp.More(); aFaceExp.Next(), ++aFaceId)
|
||||
{
|
||||
const TopoDS_Shape& aShape = aFaceExp.Current();
|
||||
const TopoDS_Face& aFace = TopoDS::Face(aShape);
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
|
||||
|
||||
// Iterate boundary edges
|
||||
NCollection_Map<BRepMesh_Edge> aBoundaryEdgeMap;
|
||||
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
|
||||
for ( ; anExp.More(); anExp.Next() )
|
||||
{
|
||||
TopLoc_Location anEdgeLoc;
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
|
||||
Handle(Poly_PolygonOnTriangulation) aPoly = BRep_Tool::PolygonOnTriangulation(anEdge, aT, aLoc);
|
||||
if (aPoly.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const TColStd_Array1OfInteger& anIndices = aPoly->Nodes();
|
||||
Standard_Integer aLower = anIndices.Lower();
|
||||
Standard_Integer anUpper = anIndices.Upper();
|
||||
|
||||
Standard_Integer aPrevNode = -1;
|
||||
for (Standard_Integer i = aLower; i <= anUpper; ++i)
|
||||
{
|
||||
Standard_Integer aNodeIdx = anIndices.Value(i);
|
||||
if (i != aLower)
|
||||
{
|
||||
BRepMesh_Edge aLink(aPrevNode, aNodeIdx, BRepMesh_Frontier);
|
||||
aBoundaryEdgeMap.Add(aLink);
|
||||
}
|
||||
aPrevNode = aNodeIdx;
|
||||
}
|
||||
}
|
||||
|
||||
if (aBoundaryEdgeMap.Size() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const Poly_Array1OfTriangle& aTris = aT->Triangles();
|
||||
NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
|
||||
Standard_Integer aTriNum = aTris.Length();
|
||||
for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
|
||||
{
|
||||
const Poly_Triangle& aTri = aTris(aTriIndx);
|
||||
Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
|
||||
|
||||
for (Standard_Integer i = 1; i <= 3; ++i)
|
||||
{
|
||||
Standard_Integer aLastId = aTriNodes[i % 3];
|
||||
Standard_Integer aFirstId = aTriNodes[i - 1];
|
||||
|
||||
BRepMesh_Edge aLink(aFirstId, aLastId, BRepMesh_Free);
|
||||
if (!aBoundaryEdgeMap.Contains(aLink))
|
||||
{
|
||||
if (!aFreeEdgeMap.Add(aLink))
|
||||
{
|
||||
aFreeEdgeMap.Remove(aLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aFreeEdgeMap.Size() != 0)
|
||||
{
|
||||
di << "Not connected mesh inside face " << aFaceId << "\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user