Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright (c) 2013 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepMesh_CircleTool_HeaderFile
0015 #define _BRepMesh_CircleTool_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Macro.hxx>
0020 
0021 #include <Standard_Real.hxx>
0022 #include <BRepMesh_CircleInspector.hxx>
0023 #include <gp_XY.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_Boolean.hxx>
0026 #include <IMeshData_Types.hxx>
0027 #include <NCollection_Array1.hxx>
0028 
0029 class gp_Circ2d;
0030 
0031 //! Create sort and destroy the circles used in triangulation. <br>
0032 class BRepMesh_CircleTool
0033 {
0034 public:
0035 
0036   DEFINE_STANDARD_ALLOC
0037   
0038   //! Constructor.
0039   //! @param theAllocator memory allocator to be used by internal structures.
0040   Standard_EXPORT BRepMesh_CircleTool(
0041   const Handle(NCollection_IncAllocator)& theAllocator);
0042 
0043   //! Constructor.
0044   //! @param theReservedSize size to be reserved for vector of circles.
0045   //! @param theAllocator memory allocator to be used by internal structures.
0046   Standard_EXPORT BRepMesh_CircleTool(
0047     const Standard_Integer                  theReservedSize,
0048     const Handle(NCollection_IncAllocator)& theAllocator);
0049 
0050   //! Initializes the tool.
0051   //! @param theReservedSize size to be reserved for vector of circles.
0052   void Init(const Standard_Integer /*theReservedSize*/)
0053   {
0054     myTolerance = Precision::PConfusion();
0055   }
0056 
0057   //! Sets new size for cell filter.
0058   //! @param theSize cell size to be set for X and Y dimensions.
0059   void SetCellSize(const Standard_Real theSize)
0060   {
0061     myCellFilter.Reset(theSize, myAllocator);
0062   }
0063 
0064   //! Sets new size for cell filter.
0065   //! @param theSizeX cell size to be set for X dimension.
0066   //! @param theSizeY cell size to be set for Y dimension.
0067   void SetCellSize(const Standard_Real theSizeX,
0068                    const Standard_Real theSizeY)
0069   {
0070     Standard_Real aCellSizeC[2] = { theSizeX, theSizeY };
0071     NCollection_Array1<Standard_Real> aCellSize(aCellSizeC[0], 1, 2);
0072     myCellFilter.Reset(aCellSize, myAllocator);
0073   }
0074 
0075   //! Sets limits of inspection area.
0076   //! @param theMin bottom left corner of inspection area.
0077   //! @param theMax top right corner of inspection area.
0078   void SetMinMaxSize(const gp_XY& theMin,
0079                      const gp_XY& theMax)
0080   {
0081     myFaceMin = theMin;
0082     myFaceMax = theMax;
0083   }
0084 
0085   //! Returns true if cell filter contains no circle.
0086   Standard_Boolean IsEmpty () const
0087   {
0088     return mySelector.Circles ().IsEmpty ();
0089   }
0090 
0091   //! Binds the circle to the tool.
0092   //! @param theIndex index a circle should be bound with.
0093   //! @param theCircle circle to be bound.
0094   Standard_EXPORT void Bind(const Standard_Integer theIndex,
0095                             const gp_Circ2d&       theCircle);
0096 
0097   //! Computes circle on three points.
0098   //! @param thePoint1 first point.
0099   //! @param thePoint2 second point.
0100   //! @param thePoint3 third point.
0101   //! @param[out] theLocation center of computed circle.
0102   //! @param[out] theRadius radius of computed circle.
0103   //! @return FALSE in case of impossibility to build a circle 
0104   //! on the given points, TRUE elsewhere.
0105   Standard_EXPORT static Standard_Boolean MakeCircle(const gp_XY&   thePoint1,
0106                                                      const gp_XY&   thePoint2,
0107                                                      const gp_XY&   thePoint3,
0108                                                      gp_XY&         theLocation,
0109                                                      Standard_Real& theRadius);
0110 
0111   //! Computes circle on three points and bind it to the tool.
0112   //! @param theIndex index a circle should be bound with.
0113   //! @param thePoint1 first point.
0114   //! @param thePoint2 second point.
0115   //! @param thePoint3 third point.
0116   //! @return FALSE in case of impossibility to build a circle 
0117   //! on the given points, TRUE elsewhere.
0118   Standard_EXPORT Standard_Boolean Bind(const Standard_Integer theIndex,
0119                                         const gp_XY&           thePoint1,
0120                                         const gp_XY&           thePoint2,
0121                                         const gp_XY&           thePoint3);
0122 
0123   //! Binds implicit zero circle.
0124   //! @param theIndex index a zero circle should be bound with.
0125   Standard_EXPORT void MocBind(const Standard_Integer theIndex);
0126 
0127   //! Deletes a circle from the tool.
0128   //! @param theIndex index of a circle to be removed.
0129   Standard_EXPORT void Delete(const Standard_Integer theIndex);
0130 
0131   //! Select the circles shot by the given point.
0132   //! @param thePoint bullet point.
0133   Standard_EXPORT IMeshData::ListOfInteger& Select(const gp_XY& thePoint);
0134 
0135 private:
0136 
0137   //! Creates circle with the given parameters and binds it to the tool.
0138   //! @param theIndex index a circle should be bound with.
0139   //! @param theLocation location of a circle.
0140   //! @param theRadius radius of a circle.
0141   void bind(const Standard_Integer theIndex,
0142             const gp_XY&           theLocation,
0143             const Standard_Real    theRadius);
0144 
0145 private:
0146 
0147   Standard_Real                     myTolerance;
0148   Handle(NCollection_IncAllocator)  myAllocator;
0149   IMeshData::CircleCellFilter       myCellFilter;
0150   BRepMesh_CircleInspector          mySelector;
0151   gp_XY                             myFaceMax;
0152   gp_XY                             myFaceMin;
0153 };
0154 
0155 #endif