1 // Created on: 2016-07-04
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
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 _BRepMesh_FaceChecker_HeaderFile
17 #define _BRepMesh_FaceChecker_HeaderFile
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>
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
31 public: //! @name mesher API
33 //! Identifies segment inside face.
36 IMeshData::IEdgePtr EdgePtr;
37 gp_Pnt2d* Point1; // \ Use explicit pointers to points instead of accessing
38 gp_Pnt2d* Point2; // / using indices.
46 Segment(const IMeshData::IEdgePtr& theEdgePtr,
56 typedef NCollection_Shared<NCollection_Vector<Segment> > Segments;
57 typedef NCollection_Shared<NCollection_Array1<Handle(Segments)> > ArrayOfSegments;
58 typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)> > ArrayOfBndBoxTree;
59 typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::MapOfIEdgePtr)> > ArrayOfMapOfIEdgePtr;
62 //! Default constructor
63 Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
64 const IMeshTools_Parameters& theParameters);
67 Standard_EXPORT virtual ~BRepMesh_FaceChecker();
69 //! Performs check wires of the face for intersections.
70 //! @return True if there is no intersection, False elsewhere.
71 Standard_EXPORT Standard_Boolean Perform();
73 //! Returns intersecting edges.
74 const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const
76 return myIntersectingEdges;
79 //! Checks wire with the given index for intersection with others.
80 inline void operator()(const Standard_Integer theWireIndex) const
82 perform(theWireIndex);
85 DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceChecker, Standard_Transient)
89 //! Returns True in case if check can be performed in parallel mode.
90 inline Standard_Boolean isParallel() const
92 return (myParameters.InParallel && myDFace->WiresNb() > 1);
95 //! Collects face segments.
96 void collectSegments();
98 //! Collects intersecting edges.
101 //! Checks wire with the given index for intersection with others.
102 void perform(const Standard_Integer theWireIndex) const;
106 BRepMesh_FaceChecker (const BRepMesh_FaceChecker& theOther);
108 void operator=(const BRepMesh_FaceChecker& theOther);
112 IMeshData::IFaceHandle myDFace;
113 const IMeshTools_Parameters& myParameters;
115 Handle(ArrayOfSegments) myWiresSegments;
116 Handle(ArrayOfBndBoxTree) myWiresBndBoxTree;
117 Handle(ArrayOfMapOfIEdgePtr) myWiresIntersectingEdges;
118 Handle(IMeshData::MapOfIEdgePtr) myIntersectingEdges;