Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:57:18

0001 // Created on: 2016-07-04
0002 // Copyright (c) 2016 OPEN CASCADE SAS
0003 // Created by: Oleg AGASHIN
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 _BRepMesh_FaceChecker_HeaderFile
0017 #define _BRepMesh_FaceChecker_HeaderFile
0018 
0019 #include <IMeshTools_Parameters.hxx>
0020 #include <Standard_Transient.hxx>
0021 #include <IMeshData_Face.hxx>
0022 #include <Standard_Type.hxx>
0023 #include <NCollection_Shared.hxx>
0024 
0025 //! Auxiliary class checking wires of target face for self-intersections.
0026 //! Explodes wires of discrete face on sets of segments using tessellation
0027 //! data stored in model. Each segment is then checked for intersection with
0028 //! other ones. All collisions are registered and returned as result of check.
0029 class BRepMesh_FaceChecker : public Standard_Transient
0030 {
0031 public: //! @name mesher API
0032   //! Identifies segment inside face.
0033   struct Segment
0034   {
0035     IMeshData::IEdgePtr EdgePtr;
0036     gp_Pnt2d*           Point1; // \ Use explicit pointers to points instead of accessing
0037     gp_Pnt2d*           Point2; // / using indices.
0038 
0039     Segment()
0040         : EdgePtr(nullptr),
0041           Point1(nullptr),
0042           Point2(nullptr)
0043     {
0044     }
0045 
0046     Segment(const IMeshData::IEdgePtr& theEdgePtr, gp_Pnt2d* thePoint1, gp_Pnt2d* thePoint2)
0047         : EdgePtr(theEdgePtr),
0048           Point1(thePoint1),
0049           Point2(thePoint2)
0050     {
0051     }
0052   };
0053 
0054   typedef NCollection_Shared<NCollection_DynamicArray<Segment>>                   Segments;
0055   typedef NCollection_Shared<NCollection_Array1<occ::handle<Segments>>>           ArrayOfSegments;
0056   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)>> ArrayOfBndBoxTree;
0057   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::MapOfIEdgePtr)>>
0058     ArrayOfMapOfIEdgePtr;
0059 
0060   //! Default constructor
0061   Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
0062                                        const IMeshTools_Parameters&  theParameters);
0063 
0064   //! Destructor
0065   Standard_EXPORT ~BRepMesh_FaceChecker() override;
0066 
0067   //! Performs check wires of the face for intersections.
0068   //! @return True if there is no intersection, False elsewhere.
0069   Standard_EXPORT bool Perform();
0070 
0071   //! Returns intersecting edges.
0072   const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const
0073   {
0074     return myIntersectingEdges;
0075   }
0076 
0077   //! Checks wire with the given index for intersection with others.
0078   void operator()(const int theWireIndex) const { perform(theWireIndex); }
0079 
0080   DEFINE_STANDARD_RTTIEXT(BRepMesh_FaceChecker, Standard_Transient)
0081 
0082 private:
0083   //! Returns True in case if check can be performed in parallel mode.
0084   bool isParallel() const { return (myParameters.InParallel && myDFace->WiresNb() > 1); }
0085 
0086   //! Collects face segments.
0087   void collectSegments();
0088 
0089   //! Collects intersecting edges.
0090   void collectResult();
0091 
0092   //! Checks wire with the given index for intersection with others.
0093   void perform(const int theWireIndex) const;
0094 
0095 private:
0096   BRepMesh_FaceChecker(const BRepMesh_FaceChecker& theOther) = delete;
0097 
0098   void operator=(const BRepMesh_FaceChecker& theOther) = delete;
0099 
0100 private:
0101   IMeshData::IFaceHandle       myDFace;
0102   const IMeshTools_Parameters& myParameters;
0103 
0104   occ::handle<ArrayOfSegments>      myWiresSegments;
0105   occ::handle<ArrayOfBndBoxTree>    myWiresBndBoxTree;
0106   occ::handle<ArrayOfMapOfIEdgePtr> myWiresIntersectingEdges;
0107   Handle(IMeshData::MapOfIEdgePtr)  myIntersectingEdges;
0108 };
0109 
0110 #endif