Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:20:34

0001 // Created on: 2004-05-10
0002 // Created by: Michael SAZONOV
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef MeshTest_CheckTopology_HeaderFile
0017 #define MeshTest_CheckTopology_HeaderFile
0018 
0019 #include <TopoDS_Shape.hxx>
0020 #include <NCollection_IndexedDataMap.hxx>
0021 #include <Standard_Integer.hxx>
0022 #include <NCollection_Sequence.hxx>
0023 #include <NCollection_HSequence.hxx>
0024 #include <Draw_Interpretor.hxx>
0025 
0026 //! This class checks topology of the mesh presented by
0027 //! triangulations of faces.
0028 //!
0029 //! The following error are reported:
0030 //! - free links. A link is considered free if it has only one
0031 //!   neighboring triangle and at least one of its nodes belongs to
0032 //!   interior of the face rather than to its boundary.
0033 //! - cross face errors. It is a situation when a point on a common
0034 //!   boundary between two faces has different 3d coordinates on each
0035 //!   triangulation. The error is reported if the distance is greater
0036 //!   than a deflection written in triangulations.
0037 //! - asynchronous edges. It is an edge having polygons on two neighboring
0038 //!   triangulations with different number of points in the polygons.
0039 //! - free nodes -- nodes not shared by any triangle.
0040 
0041 class MeshTest_CheckTopology
0042 {
0043 public:
0044   //! constructor
0045   MeshTest_CheckTopology(const TopoDS_Shape& theShape)
0046       : myShape(theShape)
0047   {
0048   }
0049 
0050   //! performs checking
0051   Standard_EXPORT void Perform(Draw_Interpretor& di);
0052 
0053   //! returns the number of faces with free links
0054   int NbFacesWithFL() const { return myMapFaceLinks.Extent(); }
0055 
0056   //! returns the number (in the shape) of a face with free links
0057   //! with the given index
0058   int GetFaceNumWithFL(const int theIndex) const { return myMapFaceLinks.FindKey(theIndex); }
0059 
0060   //! returns the number free links on a face with the given index
0061   int NbFreeLinks(const int theIndex) const { return myMapFaceLinks(theIndex)->Length() / 2; }
0062 
0063   //! gets the numbers of nodes of a free link with the given index
0064   //! in the face with the given index
0065   Standard_EXPORT void GetFreeLink(const int theFaceIndex,
0066                                    const int theLinkIndex,
0067                                    int&      theNode1,
0068                                    int&      theNode2) const;
0069 
0070   //! returns the number of cross face errors
0071   int NbCrossFaceErrors() const { return myErrorsVal.Length(); }
0072 
0073   //! gets the attributes of a cross face error with the given index
0074   Standard_EXPORT void GetCrossFaceError(const int theIndex,
0075                                          int&      theFace1,
0076                                          int&      theNode1,
0077                                          int&      theFace2,
0078                                          int&      theNode2,
0079                                          double&   theValue) const;
0080 
0081   //! returns the number of async edges
0082   int NbAsyncEdges() const { return myAsyncEdges.Length(); }
0083 
0084   //! returns the number (in the shape) of an async edge with the given index
0085   int GetAsyncEdgeNum(const int theIndex) const { return myAsyncEdges(theIndex); }
0086 
0087   //! returns the number of free nodes
0088   int NbFreeNodes() const { return myFreeNodeFaces.Length(); }
0089 
0090   //! returns the number of face containing the Index-th detected free node,
0091   //! and number of this node in the triangulation of that face
0092   void GetFreeNodeNum(const int theIndex, int& theFaceNum, int& theNodeNum) const
0093   {
0094     theFaceNum = myFreeNodeFaces(theIndex);
0095     theNodeNum = myFreeNodeNums(theIndex);
0096   }
0097 
0098   //! Returns number of triangles with null area
0099   int NbSmallTriangles() const { return mySmallTrianglesFaces.Length(); }
0100 
0101   //! returns the number of face containing the Index-th detected
0102   //! small triangle and number of the problematic triangle in
0103   //! this face.
0104   void GetSmallTriangle(const int theIndex, int& theFaceNum, int& theNodeNum) const
0105   {
0106     theFaceNum = mySmallTrianglesFaces(theIndex);
0107     theNodeNum = mySmallTrianglesTriangles(theIndex);
0108   }
0109 
0110 private:
0111   TopoDS_Shape                                                             myShape;
0112   NCollection_IndexedDataMap<int, occ::handle<NCollection_HSequence<int>>> myMapFaceLinks;
0113 
0114   NCollection_Sequence<int>    myErrors;
0115   NCollection_Sequence<double> myErrorsVal;
0116 
0117   NCollection_Sequence<int> myAsyncEdges;
0118   NCollection_Sequence<int> myFreeNodeFaces;
0119   NCollection_Sequence<int> myFreeNodeNums;
0120   NCollection_Sequence<int> mySmallTrianglesFaces;
0121   NCollection_Sequence<int> mySmallTrianglesTriangles;
0122 };
0123 
0124 #endif