Salome HOME
8513543aace712bf991cdab1b648d1797531b770
[modules/geom.git] / src / GEOMUtils / GEOMUtils_Hatcher.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _GEOMUtils_Hatcher_HXX_
24 #define _GEOMUtils_Hatcher_HXX_
25
26
27 #include <Geom2dHatch_Hatcher.hxx>
28 #include <GeomAbs_IsoType.hxx>
29 #include <TColStd_HArray1OfInteger.hxx>
30 #include <TColStd_HArray1OfReal.hxx>
31 #include <TopoDS_Face.hxx>
32
33
34 /*!
35  * This class represents a hatcher for topological faces.
36  */
37 class GEOMUtils_Hatcher {
38
39 public:
40
41   /**
42    * Constructor. Initializes the object with the face.
43    */
44   Standard_EXPORT GEOMUtils_Hatcher(const TopoDS_Face &theFace);
45
46   /**
47    * This method initializes the hatcher with hatchings.
48    *
49    * \param theNbIsos the number of U- and V-isolines.
50    */
51   Standard_EXPORT void Init(const Standard_Integer theNbIsos);
52
53   /**
54    * This method initializes the hatcher with hatchings.
55    *
56    * \param theNbIsoU the number of U-isolines.
57    * \param theNbIsoV the number of V-isolines.
58    */
59   Standard_EXPORT void Init(const Standard_Integer theNbIsoU,
60                             const Standard_Integer theNbIsoV);
61
62   /**
63    * This method initializes the hatcher with a hatching.
64    *
65    * \param theIsoType the isoline type.
66    * \param theParameter the isoline parameter.
67    */
68   Standard_EXPORT void Init(const GeomAbs_IsoType theIsoType,
69                             const Standard_Real   theParameter);
70
71   /**
72    * Compute hatching domatins.
73    */
74   Standard_EXPORT void Perform();
75
76   /**
77    * This method returns true if at least one hatching's domains
78    * are computed successfully.
79    *
80    * \return Standard_True is case of success.
81    */
82   Standard_Boolean IsDone() const
83   { return myIsDone; }
84
85   /**
86    * This method returns the initial face.
87    *
88    * \return the initial face.
89    */
90   const TopoDS_Face &GetFace() const
91   { return myFace; }
92
93   /**
94    * This method returns the number of domains for a particular hatching.
95    * If the operation is not done or there is no real hatching for
96    * a particular index a negative value is returned.
97    *
98    * \param theHatchingIndex the hatching index.
99    * \return the number of domains computed for the hatching.
100    */
101   Standard_EXPORT Standard_Integer GetNbDomains
102               (const Standard_Integer theHatchingIndex) const;
103
104   /**
105    * This method returns the domputed domain range computed for a particular
106    * hatching. theDomainIndex should be in the range [1..GetNbDomains].
107    *
108    * \param theHatchingIndex the hatching index.
109    * \param theDomainIndex the domain index for the particular hatching.
110    * \param theParam1 (output) the first parameter of the domain.
111    * \param theParam2 (output) the last parameter of the domain.
112    * \return Standard_True in case of success; Standard_False otherwise.
113    */
114   Standard_EXPORT Standard_Boolean GetDomain
115                            (const Standard_Integer  theHatchingIndex,
116                             const Standard_Integer  theDomainIndex,
117                                   Standard_Real    &theParam1,
118                                   Standard_Real    &theParam2) const;
119
120   /**
121    * This method returns Standard_True if a domain has infinite first
122    * or last parameter.
123    *
124    * \param theHatchingIndex the hatching index.
125    * \param theDomainIndex the domain index for the particular hatching.
126    * \return Standard_True if a domain is infinite; Standard_False otherwise.
127    */
128   Standard_EXPORT Standard_Boolean IsDomainInfinite
129                            (const Standard_Integer  theHatchingIndex,
130                             const Standard_Integer  theDomainIndex) const;
131
132   /**
133    * This method returns the reference to OCCT hatcher.
134    *
135    * \return the reference to OCCT hatcher.
136    */
137   Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const
138   { return myHatcher; }
139
140   /**
141    * This method returns the array of indices of U-isoline hatchings.
142    * Can be null if the object is initialized by 0 U-isolines.
143    *
144    * \return the array of U-isoline hatching indices.
145    */
146   Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetUIndices() const
147   { return myUInd; }
148
149   /**
150    * This method returns the array of indices of V-isoline hatchings.
151    * Can be null if the object is initialized by 0 V-isolines.
152    *
153    * \return the array of V-isoline hatching indices.
154    */
155   Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetVIndices() const
156   { return myVInd; }
157
158   /**
159    * This method returns the array of parameters of U-isoline hatchings.
160    * Can be null if the object is initialized by 0 U-isolines.
161    *
162    * \return the array of U-isoline hatching parameters.
163    */
164   Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetUParams() const
165   { return myUPrm; }
166
167   /**
168    * This method returns the array of parameters of V-isoline hatchings.
169    * Can be null if the object is initialized by 0 V-isolines.
170    *
171    * \return the array of V-isoline hatching parameters.
172    */
173   Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetVParams() const
174   { return myVPrm; }
175
176   /**
177    * This method returns a hatching curve by its index.
178    * If the curve is not found null handle is returned.
179    *
180    * \param theHatchingIndex the hatching curve index.
181    */
182   Standard_EXPORT const Handle(Geom2d_Curve) &GetHatching
183                       (const Standard_Integer theHatchingIndex) const;
184
185 protected:
186
187   /**
188    * This method clears all hatchings data.
189    */
190   void Clear();
191
192 private:
193
194   Geom2dHatch_Hatcher              myHatcher;
195   TopoDS_Face                      myFace;
196   Standard_Boolean                 myIsDone;
197   Standard_Real                    myUMin;
198   Standard_Real                    myUMax;
199   Standard_Real                    myVMin;
200   Standard_Real                    myVMax;
201   Handle(TColStd_HArray1OfReal)    myUPrm;
202   Handle(TColStd_HArray1OfReal)    myVPrm;
203   Handle(TColStd_HArray1OfInteger) myUInd;
204   Handle(TColStd_HArray1OfInteger) myVInd;
205
206 };
207
208 #endif