fc9b36d6 |
1 | // Copyright (c) 2013 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _BRepMesh_CircleTool_HeaderFile |
15 | #define _BRepMesh_CircleTool_HeaderFile |
16 | |
17 | #include <Standard.hxx> |
18 | #include <Standard_DefineAlloc.hxx> |
19 | #include <Standard_Macro.hxx> |
20 | |
21 | #include <Standard_Real.hxx> |
22 | #include <BRepMesh_CircleInspector.hxx> |
23 | #include <gp_XY.hxx> |
24 | #include <gp_XYZ.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_Boolean.hxx> |
848fa7e3 |
27 | #include <BRepMesh.hxx> |
50bc8f96 |
28 | #include <NCollection_Array1.hxx> |
fc9b36d6 |
29 | |
30 | class gp_Circ2d; |
31 | |
32 | //! Create sort and destroy the circles used in triangulation. <br> |
33 | class BRepMesh_CircleTool |
34 | { |
35 | public: |
36 | |
37 | DEFINE_STANDARD_ALLOC |
38 | |
39 | //! Constructor. |
848fa7e3 |
40 | //! @param theAllocator memory allocator to be used by internal structures. |
41 | Standard_EXPORT BRepMesh_CircleTool( |
42 | const Handle(NCollection_IncAllocator)& theAllocator); |
fc9b36d6 |
43 | |
44 | //! Constructor. |
848fa7e3 |
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); |
fc9b36d6 |
50 | |
51 | //! Initializes the tool. |
848fa7e3 |
52 | //! @param theReservedSize size to be reserved for vector of circles. |
fc9b36d6 |
53 | inline void Init(const Standard_Integer /*theReservedSize*/) |
54 | { |
55 | myTolerance = Precision::PConfusion() * Precision::PConfusion(); |
56 | } |
57 | |
58 | //! Sets new size for cell filter. |
848fa7e3 |
59 | //! @param theSize cell size to be set for X and Y dimensions. |
fc9b36d6 |
60 | inline void SetCellSize(const Standard_Real theSize) |
61 | { |
62 | myCellFilter.Reset(theSize, myAllocator); |
63 | } |
64 | |
65 | //! Sets new size for cell filter. |
848fa7e3 |
66 | //! @param theSizeX cell size to be set for X dimension. |
67 | //! @param theSizeY cell size to be set for Y dimension. |
fc9b36d6 |
68 | inline void SetCellSize(const Standard_Real theSizeX, |
69 | const Standard_Real theSizeY) |
70 | { |
50bc8f96 |
71 | Standard_Real aCellSizeC[2] = { theSizeX, theSizeY }; |
72 | NCollection_Array1<Standard_Real> aCellSize(aCellSizeC[0], 1, 2); |
fc9b36d6 |
73 | myCellFilter.Reset(aCellSize, myAllocator); |
74 | } |
75 | |
76 | //! Sets limits of inspection area. |
848fa7e3 |
77 | //! @param theMin bottom left corner of inspection area. |
78 | //! @param theMax top right corner of inspection area. |
fc9b36d6 |
79 | inline void SetMinMaxSize(const gp_XY& theMin, |
80 | const gp_XY& theMax) |
81 | { |
82 | myFaceMin = theMin; |
83 | myFaceMax = theMax; |
84 | } |
85 | |
86 | //! Binds the circle to the tool. |
848fa7e3 |
87 | //! @param theIndex index a circle should be bound with. |
88 | //! @param theCircle circle to be bound. |
fc9b36d6 |
89 | Standard_EXPORT void Bind(const Standard_Integer theIndex, |
90 | const gp_Circ2d& theCircle); |
91 | |
ec26bf88 |
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, |
103 | gp_XY& theLocation, |
104 | Standard_Real& theRadius); |
105 | |
fc9b36d6 |
106 | //! Computes circle on three points and bind it to the tool. |
848fa7e3 |
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 |
fc9b36d6 |
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); |
117 | |
118 | //! Binds implicit zero circle. |
848fa7e3 |
119 | //! @param theIndex index a zero circle should be bound with. |
fc9b36d6 |
120 | Standard_EXPORT void MocBind(const Standard_Integer theIndex); |
121 | |
122 | //! Deletes a circle from the tool. |
848fa7e3 |
123 | //! @param theIndex index of a circle to be removed. |
fc9b36d6 |
124 | Standard_EXPORT void Delete(const Standard_Integer theIndex); |
125 | |
126 | //! Select the circles shot by the given point. |
848fa7e3 |
127 | //! @param thePoint bullet point. |
128 | Standard_EXPORT BRepMesh::ListOfInteger& Select(const gp_XY& thePoint); |
fc9b36d6 |
129 | |
130 | private: |
131 | |
132 | //! Creates circle with the given parameters and binds it to the tool. |
848fa7e3 |
133 | //! @param theIndex index a circle should be bound with. |
134 | //! @param theLocation location of a circle. |
135 | //! @param theRadius radius of a circle. |
fc9b36d6 |
136 | void bind(const Standard_Integer theIndex, |
137 | const gp_XY& theLocation, |
138 | const Standard_Real theRadius); |
139 | |
140 | private: |
141 | |
848fa7e3 |
142 | Standard_Real myTolerance; |
143 | Handle(NCollection_IncAllocator) myAllocator; |
144 | BRepMesh::CircleCellFilter myCellFilter; |
145 | BRepMesh_CircleInspector mySelector; |
146 | gp_XY myFaceMax; |
147 | gp_XY myFaceMin; |
fc9b36d6 |
148 | }; |
149 | |
150 | #endif |