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 registered 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.
47 Segment(const IMeshData::IEdgePtr& theEdgePtr,
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;
63 //! Default constructor
64 Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
65 const IMeshTools_Parameters& theParameters);
68 Standard_EXPORT virtual ~BRepMesh_FaceChecker();
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();
74 //! Returns intersecting edges.
75 const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const
77 return myIntersectingEdges;
80 //! Checks wire with the given index for intersection with others.
81 void operator()(const Standard_Integer theWireIndex) const
83 perform(theWireIndex);
86 DEFINE_STANDARD_RTTIEXT(BRepMesh_FaceChecker, Standard_Transient)
90 //! Returns True in case if check can be performed in parallel mode.
91 Standard_Boolean isParallel() const
93 return (myParameters.InParallel && myDFace->WiresNb() > 1);
96 //! Collects face segments.
97 void collectSegments();
99 //! Collects intersecting edges.
100 void collectResult();
102 //! Checks wire with the given index for intersection with others.
103 void perform(const Standard_Integer theWireIndex) const;
107 BRepMesh_FaceChecker (const BRepMesh_FaceChecker& theOther);
109 void operator=(const BRepMesh_FaceChecker& theOther);
113 IMeshData::IFaceHandle myDFace;
114 const IMeshTools_Parameters& myParameters;
116 Handle(ArrayOfSegments) myWiresSegments;
117 Handle(ArrayOfBndBoxTree) myWiresBndBoxTree;
118 Handle(ArrayOfMapOfIEdgePtr) myWiresIntersectingEdges;
119 Handle(IMeshData::MapOfIEdgePtr) myIntersectingEdges;