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 SegmentBRepMesh_FaceChecker::Segment40 Segment() 41 : Point1(NULL) 42 , Point2(NULL) 43 { 44 } 45 SegmentBRepMesh_FaceChecker::Segment46 Segment(const IMeshData::IEdgePtr& theEdgePtr, 47 gp_Pnt2d* thePoint1, 48 gp_Pnt2d* thePoint2) 49 : EdgePtr(theEdgePtr) 50 , Point1(thePoint1) 51 , Point2(thePoint2) 52 { 53 } 54 }; 55 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; 60 61 62 //! Default constructor 63 Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace, 64 const IMeshTools_Parameters& theParameters); 65 66 //! Destructor 67 Standard_EXPORT virtual ~BRepMesh_FaceChecker(); 68 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(); 72 73 //! Returns intersecting edges. Handle(IMeshData::MapOfIEdgePtr)74 const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const 75 { 76 return myIntersectingEdges; 77 } 78 79 //! Checks wire with the given index for intersection with others. operator ()(const Standard_Integer theWireIndex) const80 inline void operator()(const Standard_Integer theWireIndex) const 81 { 82 perform(theWireIndex); 83 } 84 85 DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceChecker, Standard_Transient) 86 87 private: 88 89 //! Returns True in case if check can be performed in parallel mode. isParallel() const90 inline Standard_Boolean isParallel() const 91 { 92 return (myParameters.InParallel && myDFace->WiresNb() > 1); 93 } 94 95 //! Collects face segments. 96 void collectSegments(); 97 98 //! Collects intersecting edges. 99 void collectResult(); 100 101 //! Checks wire with the given index for intersection with others. 102 void perform(const Standard_Integer theWireIndex) const; 103 104 private: 105 106 BRepMesh_FaceChecker (const BRepMesh_FaceChecker& theOther); 107 108 void operator=(const BRepMesh_FaceChecker& theOther); 109 110 private: 111 112 IMeshData::IFaceHandle myDFace; 113 const IMeshTools_Parameters& myParameters; 114 115 Handle(ArrayOfSegments) myWiresSegments; 116 Handle(ArrayOfBndBoxTree) myWiresBndBoxTree; 117 Handle(ArrayOfMapOfIEdgePtr) myWiresIntersectingEdges; 118 Handle(IMeshData::MapOfIEdgePtr) myIntersectingEdges; 119 120 }; 121 122 #endif 123