0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / BRepMesh / BRepMesh_FaceChecker.hxx
1 // Created on: 2016-07-04
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _BRepMesh_FaceChecker_HeaderFile
17 #define _BRepMesh_FaceChecker_HeaderFile
18
19 #include <IMeshTools_Parameters.hxx>
20 #include <Standard_Transient.hxx>
21 #include <IMeshData_Face.hxx>
22 #include <Standard_Type.hxx>
23 #include <NCollection_Shared.hxx>
24
25 //! Auxiliary class checking wires of target face for self-intersections.
26 //! Explodes wires of discrete face on sets of segments using tessellation 
27 //! data stored in model. Each segment is then checked for intersection with
28 //! other ones. All collisions are registerd and returned as result of check.
29 class BRepMesh_FaceChecker : public Standard_Transient
30 {
31 public: //! @name mesher API
32
33   //! Identifies segment inside face.
34   struct Segment
35   {
36     IMeshData::IEdgePtr      EdgePtr;
37     gp_Pnt2d*                Point1; // \ Use explicit pointers to points instead of accessing
38     gp_Pnt2d*                Point2; // / using indices.
39
40     Segment()
41     : EdgePtr(NULL),
42       Point1(NULL),
43       Point2(NULL)
44     {
45     }
46
47     Segment(const IMeshData::IEdgePtr& theEdgePtr,
48             gp_Pnt2d*                  thePoint1,
49             gp_Pnt2d*                  thePoint2)
50       : EdgePtr(theEdgePtr)
51       , Point1(thePoint1)
52       , Point2(thePoint2)
53     {
54     }
55   };
56
57   typedef NCollection_Shared<NCollection_Vector<Segment> >                          Segments;
58   typedef NCollection_Shared<NCollection_Array1<Handle(Segments)> >                 ArrayOfSegments;
59   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)> >  ArrayOfBndBoxTree;
60   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::MapOfIEdgePtr)> > ArrayOfMapOfIEdgePtr;
61
62
63   //! Default constructor
64   Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
65                                        const IMeshTools_Parameters&  theParameters);
66
67   //! Destructor
68   Standard_EXPORT virtual ~BRepMesh_FaceChecker();
69
70   //! Performs check wires of the face for intersections.
71   //! @return True if there is no intersection, False elsewhere.
72   Standard_EXPORT Standard_Boolean Perform();
73
74   //! Returns intersecting edges.
75   const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const
76   {
77     return myIntersectingEdges;
78   }
79
80   //! Checks wire with the given index for intersection with others.
81   inline void operator()(const Standard_Integer theWireIndex) const
82   {
83     perform(theWireIndex);
84   }
85
86   DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceChecker, Standard_Transient)
87
88 private:
89
90   //! Returns True in case if check can be performed in parallel mode.
91   inline Standard_Boolean isParallel() const
92   {
93     return (myParameters.InParallel && myDFace->WiresNb() > 1);
94   }
95
96   //! Collects face segments.
97   void collectSegments();
98
99   //! Collects intersecting edges.
100   void collectResult();
101
102   //! Checks wire with the given index for intersection with others.
103   void perform(const Standard_Integer theWireIndex) const;
104
105 private:
106
107   BRepMesh_FaceChecker (const BRepMesh_FaceChecker& theOther);
108
109   void operator=(const BRepMesh_FaceChecker& theOther);
110
111 private:
112
113   IMeshData::IFaceHandle            myDFace;
114   const IMeshTools_Parameters&      myParameters;
115
116   Handle(ArrayOfSegments)           myWiresSegments;
117   Handle(ArrayOfBndBoxTree)         myWiresBndBoxTree;
118   Handle(ArrayOfMapOfIEdgePtr)      myWiresIntersectingEdges;
119   Handle(IMeshData::MapOfIEdgePtr)  myIntersectingEdges;
120
121 };
122
123 #endif