Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:15

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 <TColStd_HSequenceOfInteger.hxx>
0022 #include <TColStd_SequenceOfReal.hxx>
0023 #include <Draw_Interpretor.hxx>
0024 
0025 //! This class checks topology of the mesh presented by
0026 //! triangulations of faces.
0027 //!
0028 //! The following error are reported:
0029 //! - free links. A link is considered free if it has only one
0030 //!   neighboring triangle and at least one of its nodes belongs to
0031 //!   interior of the face rather than to its boundary.
0032 //! - cross face errors. It is a situation when a point on a common
0033 //!   boundary between two faces has different 3d coordinates on each
0034 //!   triangulation. The error is reported if the distance is greater
0035 //!   than a deflection written in triangulations.
0036 //! - asynchronous edges. It is an edge having polygons on two neighboring
0037 //!   triangulations with different number of points in the polygons.
0038 //! - free nodes -- nodes not shared by any triangle.
0039 
0040 class MeshTest_CheckTopology
0041 {
0042 public:
0043   //! constructor
0044   MeshTest_CheckTopology(const TopoDS_Shape& theShape)
0045     : myShape(theShape) {}
0046 
0047   //! performs checking
0048   Standard_EXPORT void Perform(Draw_Interpretor& di);
0049 
0050   //! returns the number of faces with free links
0051   Standard_Integer NbFacesWithFL() const
0052   { return myMapFaceLinks.Extent(); }
0053 
0054   //! returns the number (in the shape) of a face with free links
0055   //! with the given index
0056   Standard_Integer GetFaceNumWithFL(const Standard_Integer theIndex) const
0057   { return myMapFaceLinks.FindKey(theIndex); }
0058 
0059   //! returns the number free links on a face with the given index
0060   Standard_Integer NbFreeLinks(const Standard_Integer theIndex) const
0061   { 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 Standard_Integer theFaceIndex,
0066                    const Standard_Integer theLinkIndex,
0067                    Standard_Integer& theNode1,
0068                    Standard_Integer& theNode2) const;
0069 
0070   //! returns the number of cross face errors
0071   Standard_Integer NbCrossFaceErrors() const
0072   { return myErrorsVal.Length(); }
0073 
0074   //! gets the attributes of a cross face error with the given index
0075   Standard_EXPORT void GetCrossFaceError(const Standard_Integer theIndex,
0076                      Standard_Integer& theFace1,
0077                      Standard_Integer& theNode1,
0078                      Standard_Integer& theFace2,
0079                      Standard_Integer& theNode2,
0080                      Standard_Real&    theValue) const;
0081 
0082   //! returns the number of async edges
0083   Standard_Integer NbAsyncEdges() const
0084   { return myAsyncEdges.Length(); }
0085 
0086   //! returns the number (in the shape) of an async edge with the given index
0087   Standard_Integer GetAsyncEdgeNum(const Standard_Integer theIndex) const
0088   { return myAsyncEdges(theIndex); }
0089 
0090   //! returns the number of free nodes
0091   Standard_Integer NbFreeNodes() const
0092   { return myFreeNodeFaces.Length(); }
0093 
0094   //! returns the number of face containing the Index-th detected free node,
0095   //! and number of this node in the triangulation of that face
0096   void GetFreeNodeNum (const Standard_Integer theIndex, 
0097                        Standard_Integer& theFaceNum, 
0098                Standard_Integer& theNodeNum) const
0099   { 
0100     theFaceNum = myFreeNodeFaces(theIndex);
0101     theNodeNum = myFreeNodeNums(theIndex);
0102   }
0103 
0104   //! Returns number of triangles with null area
0105   Standard_Integer NbSmallTriangles() const
0106   {
0107     return mySmallTrianglesFaces.Length();
0108   }
0109 
0110   //! returns the number of face containing the Index-th detected 
0111   //! small triangle and number of the problematic triangle in
0112   //! this face.
0113   void GetSmallTriangle(const Standard_Integer theIndex,
0114                         Standard_Integer& theFaceNum,
0115                         Standard_Integer& theNodeNum) const
0116   {
0117     theFaceNum = mySmallTrianglesFaces(theIndex);
0118     theNodeNum = mySmallTrianglesTriangles(theIndex);
0119   }
0120 
0121 private:
0122   TopoDS_Shape myShape;
0123   NCollection_IndexedDataMap<Standard_Integer,Handle(TColStd_HSequenceOfInteger)>
0124                myMapFaceLinks;
0125 
0126   TColStd_SequenceOfInteger myErrors;
0127   TColStd_SequenceOfReal    myErrorsVal;
0128 
0129   TColStd_SequenceOfInteger myAsyncEdges;
0130   TColStd_SequenceOfInteger myFreeNodeFaces;
0131   TColStd_SequenceOfInteger myFreeNodeNums;
0132   TColStd_SequenceOfInteger mySmallTrianglesFaces;
0133   TColStd_SequenceOfInteger mySmallTrianglesTriangles;
0134 
0135 };
0136 
0137 #endif