1 // Created on: 2004-05-10
2 // Created by: Michael SAZONOV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef MeshTest_CheckTopology_HeaderFile
17 #define MeshTest_CheckTopology_HeaderFile
19 #include <TopoDS_Shape.hxx>
20 #include <NCollection_IndexedDataMap.hxx>
21 #include <TColStd_HSequenceOfInteger.hxx>
22 #include <TColStd_SequenceOfReal.hxx>
23 #include <Draw_Interpretor.hxx>
25 //! This class checks topology of the mesh presented by
26 //! triangulations of faces.
28 //! The following error are reported:
29 //! - free links. A link is considered free if it has only one
30 //! neighboring triangle and at least one of its nodes belongs to
31 //! interior of the face rather than to its boundary.
32 //! - cross face errors. It is a situation when a point on a common
33 //! boundary between two faces has different 3d coordinates on each
34 //! triangulation. The error is reported if the distance is greater
35 //! than a deflection written in triangulations.
36 //! - asynchronous edges. It is an edge having polygons on two neighboring
37 //! triangulations with different number of points in the polygons.
38 //! - free nodes -- nodes not shared by any triangle.
40 class MeshTest_CheckTopology
44 MeshTest_CheckTopology(const TopoDS_Shape& theShape)
45 : myShape(theShape) {}
48 Standard_EXPORT void Perform(Draw_Interpretor& di);
50 //! returns the number of faces with free links
51 Standard_Integer NbFacesWithFL() const
52 { return myMapFaceLinks.Extent(); }
54 //! returns the number (in the shape) of a face with free links
55 //! with the given index
56 Standard_Integer GetFaceNumWithFL(const Standard_Integer theIndex) const
57 { return myMapFaceLinks.FindKey(theIndex); }
59 //! returns the number free links on a face with the given index
60 Standard_Integer NbFreeLinks(const Standard_Integer theIndex) const
61 { return myMapFaceLinks(theIndex)->Length() / 2; }
63 //! gets the numbers of nodes of a free link with the given index
64 //! in the face with the given index
65 Standard_EXPORT void GetFreeLink(const Standard_Integer theFaceIndex,
66 const Standard_Integer theLinkIndex,
67 Standard_Integer& theNode1,
68 Standard_Integer& theNode2) const;
70 //! returns the number of cross face errors
71 Standard_Integer NbCrossFaceErrors() const
72 { return myErrorsVal.Length(); }
74 //! gets the attributes of a cross face error with the given index
75 Standard_EXPORT void GetCrossFaceError(const Standard_Integer theIndex,
76 Standard_Integer& theFace1,
77 Standard_Integer& theNode1,
78 Standard_Integer& theFace2,
79 Standard_Integer& theNode2,
80 Standard_Real& theValue) const;
82 //! returns the number of async edges
83 Standard_Integer NbAsyncEdges() const
84 { return myAsyncEdges.Length(); }
86 //! returns the number (in the shape) of an async edge with the given index
87 Standard_Integer GetAsyncEdgeNum(const Standard_Integer theIndex) const
88 { return myAsyncEdges(theIndex); }
90 //! returns the number of free nodes
91 Standard_Integer NbFreeNodes() const
92 { return myFreeNodeFaces.Length(); }
94 //! returns the number of face containing the Index-th detected free node,
95 //! and number of this node in the triangulation of that face
96 void GetFreeNodeNum (const Standard_Integer theIndex,
97 Standard_Integer& theFaceNum,
98 Standard_Integer& theNodeNum) const
100 theFaceNum = myFreeNodeFaces(theIndex);
101 theNodeNum = myFreeNodeNums(theIndex);
104 //! Returns number of triangles with null area
105 Standard_Integer NbSmallTriangles() const
107 return mySmallTrianglesFaces.Length();
110 //! returns the number of face containing the Index-th detected
111 //! small triangle and number of the problematic triangle in
113 void GetSmallTriangle(const Standard_Integer theIndex,
114 Standard_Integer& theFaceNum,
115 Standard_Integer& theNodeNum) const
117 theFaceNum = mySmallTrianglesFaces(theIndex);
118 theNodeNum = mySmallTrianglesTriangles(theIndex);
122 TopoDS_Shape myShape;
123 NCollection_IndexedDataMap<Standard_Integer,Handle(TColStd_HSequenceOfInteger)>
126 TColStd_SequenceOfInteger myErrors;
127 TColStd_SequenceOfReal myErrorsVal;
129 TColStd_SequenceOfInteger myAsyncEdges;
130 TColStd_SequenceOfInteger myFreeNodeFaces;
131 TColStd_SequenceOfInteger myFreeNodeNums;
132 TColStd_SequenceOfInteger mySmallTrianglesFaces;
133 TColStd_SequenceOfInteger mySmallTrianglesTriangles;