1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _BRepMesh_CircleTool_HeaderFile
15 #define _BRepMesh_CircleTool_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_DefineAlloc.hxx>
19 #include <Standard_Macro.hxx>
21 #include <Standard_Real.hxx>
22 #include <BRepMesh_CircleInspector.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <BRepMesh.hxx>
28 #include <NCollection_Array1.hxx>
32 //! Create sort and destroy the circles used in triangulation. <br>
33 class BRepMesh_CircleTool
40 //! @param theAllocator memory allocator to be used by internal structures.
41 Standard_EXPORT BRepMesh_CircleTool(
42 const Handle(NCollection_IncAllocator)& theAllocator);
45 //! @param theReservedSize size to be reserved for vector of circles.
46 //! @param theAllocator memory allocator to be used by internal structures.
47 Standard_EXPORT BRepMesh_CircleTool(
48 const Standard_Integer theReservedSize,
49 const Handle(NCollection_IncAllocator)& theAllocator);
51 //! Initializes the tool.
52 //! @param theReservedSize size to be reserved for vector of circles.
53 inline void Init(const Standard_Integer /*theReservedSize*/)
55 myTolerance = Precision::PConfusion() * Precision::PConfusion();
58 //! Sets new size for cell filter.
59 //! @param theSize cell size to be set for X and Y dimensions.
60 inline void SetCellSize(const Standard_Real theSize)
62 myCellFilter.Reset(theSize, myAllocator);
65 //! Sets new size for cell filter.
66 //! @param theSizeX cell size to be set for X dimension.
67 //! @param theSizeY cell size to be set for Y dimension.
68 inline void SetCellSize(const Standard_Real theSizeX,
69 const Standard_Real theSizeY)
71 Standard_Real aCellSizeC[2] = { theSizeX, theSizeY };
72 NCollection_Array1<Standard_Real> aCellSize(aCellSizeC[0], 1, 2);
73 myCellFilter.Reset(aCellSize, myAllocator);
76 //! Sets limits of inspection area.
77 //! @param theMin bottom left corner of inspection area.
78 //! @param theMax top right corner of inspection area.
79 inline void SetMinMaxSize(const gp_XY& theMin,
86 //! Binds the circle to the tool.
87 //! @param theIndex index a circle should be bound with.
88 //! @param theCircle circle to be bound.
89 Standard_EXPORT void Bind(const Standard_Integer theIndex,
90 const gp_Circ2d& theCircle);
92 //! Computes circle on three points.
93 //! @param thePoint1 first point.
94 //! @param thePoint2 second point.
95 //! @param thePoint3 third point.
96 //! @param[out] theLocation center of computed circle.
97 //! @param[out] theRadius radius of computed circle.
98 //! @return FALSE in case of impossibility to build a circle
99 //! on the given points, TRUE elsewhere.
100 Standard_EXPORT static Standard_Boolean MakeCircle(const gp_XY& thePoint1,
101 const gp_XY& thePoint2,
102 const gp_XY& thePoint3,
104 Standard_Real& theRadius);
106 //! Computes circle on three points and bind it to the tool.
107 //! @param theIndex index a circle should be bound with.
108 //! @param thePoint1 first point.
109 //! @param thePoint2 second point.
110 //! @param thePoint3 third point.
111 //! @return FALSE in case of impossibility to build a circle
112 //! on the given points, TRUE elsewhere.
113 Standard_EXPORT Standard_Boolean Bind(const Standard_Integer theIndex,
114 const gp_XY& thePoint1,
115 const gp_XY& thePoint2,
116 const gp_XY& thePoint3);
118 //! Binds implicit zero circle.
119 //! @param theIndex index a zero circle should be bound with.
120 Standard_EXPORT void MocBind(const Standard_Integer theIndex);
122 //! Deletes a circle from the tool.
123 //! @param theIndex index of a circle to be removed.
124 Standard_EXPORT void Delete(const Standard_Integer theIndex);
126 //! Select the circles shot by the given point.
127 //! @param thePoint bullet point.
128 Standard_EXPORT BRepMesh::ListOfInteger& Select(const gp_XY& thePoint);
132 //! Creates circle with the given parameters and binds it to the tool.
133 //! @param theIndex index a circle should be bound with.
134 //! @param theLocation location of a circle.
135 //! @param theRadius radius of a circle.
136 void bind(const Standard_Integer theIndex,
137 const gp_XY& theLocation,
138 const Standard_Real theRadius);
142 Standard_Real myTolerance;
143 Handle(NCollection_IncAllocator) myAllocator;
144 BRepMesh::CircleCellFilter myCellFilter;
145 BRepMesh_CircleInspector mySelector;