0030281: Regression to 7.2.0: Modeling Algorithms - Wrong result of CUT operation
[occt.git] / src / MeshTest / MeshTest_CheckTopology.hxx
CommitLineData
b311480e 1// Created on: 2004-05-10
2// Created by: Michael SAZONOV
973c2be1 3// Copyright (c) 2004-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#ifndef MeshTest_CheckTopology_HeaderFile
17#define MeshTest_CheckTopology_HeaderFile
18
19#include <TopoDS_Shape.hxx>
20#include <NCollection_IndexedDataMap.hxx>
e3a6386d 21#include <TColStd_HSequenceOfInteger.hxx>
7fd59977 22#include <TColStd_SequenceOfReal.hxx>
d2c43192 23#include <Draw_Interpretor.hxx>
7fd59977 24
446e11f3
A
25//! This class checks topology of the mesh presented by
26//! triangulations of faces.
27//!
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.
7fd59977 39
40class MeshTest_CheckTopology
41{
42public:
446e11f3 43 //! constructor
7fd59977 44 MeshTest_CheckTopology(const TopoDS_Shape& theShape)
45 : myShape(theShape) {}
7fd59977 46
446e11f3 47 //! performs checking
d2c43192 48 Standard_EXPORT void Perform(Draw_Interpretor& di);
7fd59977 49
446e11f3 50 //! returns the number of faces with free links
7fd59977 51 Standard_Integer NbFacesWithFL() const
52 { return myMapFaceLinks.Extent(); }
7fd59977 53
446e11f3
A
54 //! returns the number (in the shape) of a face with free links
55 //! with the given index
7fd59977 56 Standard_Integer GetFaceNumWithFL(const Standard_Integer theIndex) const
57 { return myMapFaceLinks.FindKey(theIndex); }
7fd59977 58
446e11f3 59 //! returns the number free links on a face with the given index
7fd59977 60 Standard_Integer NbFreeLinks(const Standard_Integer theIndex) const
e3a6386d 61 { return myMapFaceLinks(theIndex)->Length() / 2; }
7fd59977 62
446e11f3
A
63 //! gets the numbers of nodes of a free link with the given index
64 //! in the face with the given index
7fd59977 65 Standard_EXPORT void GetFreeLink(const Standard_Integer theFaceIndex,
66 const Standard_Integer theLinkIndex,
67 Standard_Integer& theNode1,
68 Standard_Integer& theNode2) const;
7fd59977 69
446e11f3 70 //! returns the number of cross face errors
7fd59977 71 Standard_Integer NbCrossFaceErrors() const
72 { return myErrorsVal.Length(); }
7fd59977 73
446e11f3 74 //! gets the attributes of a cross face error with the given index
7fd59977 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;
7fd59977 81
446e11f3 82 //! returns the number of async edges
7fd59977 83 Standard_Integer NbAsyncEdges() const
84 { return myAsyncEdges.Length(); }
7fd59977 85
446e11f3 86 //! returns the number (in the shape) of an async edge with the given index
7fd59977 87 Standard_Integer GetAsyncEdgeNum(const Standard_Integer theIndex) const
88 { return myAsyncEdges(theIndex); }
446e11f3
A
89
90 //! returns the number of free nodes
91 Standard_Integer NbFreeNodes() const
92 { return myFreeNodeFaces.Length(); }
93
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
99 {
100 theFaceNum = myFreeNodeFaces(theIndex);
101 theNodeNum = myFreeNodeNums(theIndex);
102 }
7fd59977 103
104private:
105 TopoDS_Shape myShape;
e3a6386d 106 NCollection_IndexedDataMap<Standard_Integer,Handle(TColStd_HSequenceOfInteger)>
7fd59977 107 myMapFaceLinks;
446e11f3 108
7fd59977 109 TColStd_SequenceOfInteger myErrors;
110 TColStd_SequenceOfReal myErrorsVal;
446e11f3 111
7fd59977 112 TColStd_SequenceOfInteger myAsyncEdges;
446e11f3
A
113 TColStd_SequenceOfInteger myFreeNodeFaces;
114 TColStd_SequenceOfInteger myFreeNodeNums;
7fd59977 115};
116
117#endif