Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:14

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 
0033   //! Identifies segment inside face.
0034   struct Segment
0035   {
0036     IMeshData::IEdgePtr      EdgePtr;
0037     gp_Pnt2d*                Point1; // \ Use explicit pointers to points instead of accessing
0038     gp_Pnt2d*                Point2; // / using indices.
0039 
0040     Segment()
0041     : EdgePtr(NULL),
0042       Point1(NULL),
0043       Point2(NULL)
0044     {
0045     }
0046 
0047     Segment(const IMeshData::IEdgePtr& theEdgePtr,
0048             gp_Pnt2d*                  thePoint1,
0049             gp_Pnt2d*                  thePoint2)
0050       : EdgePtr(theEdgePtr)
0051       , Point1(thePoint1)
0052       , Point2(thePoint2)
0053     {
0054     }
0055   };
0056 
0057   typedef NCollection_Shared<NCollection_Vector<Segment> >                          Segments;
0058   typedef NCollection_Shared<NCollection_Array1<Handle(Segments)> >                 ArrayOfSegments;
0059   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)> >  ArrayOfBndBoxTree;
0060   typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::MapOfIEdgePtr)> > ArrayOfMapOfIEdgePtr;
0061 
0062 
0063   //! Default constructor
0064   Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
0065                                        const IMeshTools_Parameters&  theParameters);
0066 
0067   //! Destructor
0068   Standard_EXPORT virtual ~BRepMesh_FaceChecker();
0069 
0070   //! Performs check wires of the face for intersections.
0071   //! @return True if there is no intersection, False elsewhere.
0072   Standard_EXPORT Standard_Boolean Perform();
0073 
0074   //! Returns intersecting edges.
0075   const Handle(IMeshData::MapOfIEdgePtr)& GetIntersectingEdges() const
0076   {
0077     return myIntersectingEdges;
0078   }
0079 
0080   //! Checks wire with the given index for intersection with others.
0081   void operator()(const Standard_Integer theWireIndex) const
0082   {
0083     perform(theWireIndex);
0084   }
0085 
0086   DEFINE_STANDARD_RTTIEXT(BRepMesh_FaceChecker, Standard_Transient)
0087 
0088 private:
0089 
0090   //! Returns True in case if check can be performed in parallel mode.
0091   Standard_Boolean isParallel() const
0092   {
0093     return (myParameters.InParallel && myDFace->WiresNb() > 1);
0094   }
0095 
0096   //! Collects face segments.
0097   void collectSegments();
0098 
0099   //! Collects intersecting edges.
0100   void collectResult();
0101 
0102   //! Checks wire with the given index for intersection with others.
0103   void perform(const Standard_Integer theWireIndex) const;
0104 
0105 private:
0106 
0107   BRepMesh_FaceChecker (const BRepMesh_FaceChecker& theOther);
0108 
0109   void operator=(const BRepMesh_FaceChecker& theOther);
0110 
0111 private:
0112 
0113   IMeshData::IFaceHandle            myDFace;
0114   const IMeshTools_Parameters&      myParameters;
0115 
0116   Handle(ArrayOfSegments)           myWiresSegments;
0117   Handle(ArrayOfBndBoxTree)         myWiresBndBoxTree;
0118   Handle(ArrayOfMapOfIEdgePtr)      myWiresIntersectingEdges;
0119   Handle(IMeshData::MapOfIEdgePtr)  myIntersectingEdges;
0120 
0121 };
0122 
0123 #endif