Salome HOME
afb11447bd8ea70d8eaa703e6104eab67a8e58ca
[modules/geom.git] / src / GEOMUtils / GEOMUtils_Hatcher.hxx
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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 namespace GEOMUtils
38 {
39   class Hatcher
40   {
41   public:
42     
43     /**
44      * Constructor. Initializes the object with the face.
45      */
46     Standard_EXPORT Hatcher(const TopoDS_Face &theFace);
47     
48     /**
49      * This method initializes the hatcher with hatchings.
50      *
51      * \param theNbIsos the number of U- and V-isolines.
52      */
53     Standard_EXPORT void Init(const Standard_Integer theNbIsos);
54     
55     /**
56      * This method initializes the hatcher with hatchings.
57      *
58      * \param theNbIsoU the number of U-isolines.
59      * \param theNbIsoV the number of V-isolines.
60      */
61     Standard_EXPORT void Init(const Standard_Integer theNbIsoU,
62                               const Standard_Integer theNbIsoV);
63     
64     /**
65      * This method initializes the hatcher with a hatching.
66      *
67      * \param theIsoType the isoline type.
68      * \param theParameter the isoline parameter.
69      */
70     Standard_EXPORT void Init(const GeomAbs_IsoType theIsoType,
71                               const Standard_Real   theParameter);
72
73     /**
74      * Compute hatching domatins.
75      */
76     Standard_EXPORT void Perform();
77
78     /**
79      * This method returns true if at least one hatching's domains
80      * are computed successfully.
81      *
82      * \return Standard_True is case of success.
83      */
84     Standard_Boolean IsDone() const
85     { return myIsDone; }
86
87     /**
88      * This method returns the initial face.
89      *
90      * \return the initial face.
91      */
92     const TopoDS_Face &GetFace() const
93     { return myFace; }
94
95     /**
96      * This method returns the number of domains for a particular hatching.
97      * If the operation is not done or there is no real hatching for
98      * a particular index a negative value is returned.
99      *
100      * \param theHatchingIndex the hatching index.
101      * \return the number of domains computed for the hatching.
102      */
103     Standard_EXPORT Standard_Integer GetNbDomains
104     (const Standard_Integer theHatchingIndex) const;
105
106     /**
107      * This method returns the domputed domain range computed for a particular
108      * hatching. theDomainIndex should be in the range [1..GetNbDomains].
109      *
110      * \param theHatchingIndex the hatching index.
111      * \param theDomainIndex the domain index for the particular hatching.
112      * \param theParam1 (output) the first parameter of the domain.
113      * \param theParam2 (output) the last parameter of the domain.
114      * \return Standard_True in case of success; Standard_False otherwise.
115      */
116     Standard_EXPORT Standard_Boolean GetDomain
117     (const Standard_Integer  theHatchingIndex,
118      const Standard_Integer  theDomainIndex,
119      Standard_Real    &theParam1,
120      Standard_Real    &theParam2) const;
121
122     /**
123      * This method returns Standard_True if a domain has infinite first
124      * or last parameter.
125      *
126      * \param theHatchingIndex the hatching index.
127      * \param theDomainIndex the domain index for the particular hatching.
128      * \return Standard_True if a domain is infinite; Standard_False otherwise.
129      */
130     Standard_EXPORT Standard_Boolean IsDomainInfinite
131     (const Standard_Integer  theHatchingIndex,
132      const Standard_Integer  theDomainIndex) const;
133
134     /**
135      * This method returns the reference to OCCT hatcher.
136      *
137      * \return the reference to OCCT hatcher.
138      */
139     Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const
140     { return myHatcher; }
141
142     /**
143      * This method returns the array of indices of U-isoline hatchings.
144      * Can be null if the object is initialized by 0 U-isolines.
145      *
146      * \return the array of U-isoline hatching indices.
147      */
148     Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetUIndices() const
149     { return myUInd; }
150
151     /**
152      * This method returns the array of indices of V-isoline hatchings.
153      * Can be null if the object is initialized by 0 V-isolines.
154      *
155      * \return the array of V-isoline hatching indices.
156      */
157     Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetVIndices() const
158     { return myVInd; }
159
160     /**
161      * This method returns the array of parameters of U-isoline hatchings.
162      * Can be null if the object is initialized by 0 U-isolines.
163      *
164      * \return the array of U-isoline hatching parameters.
165      */
166     Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetUParams() const
167     { return myUPrm; }
168
169     /**
170      * This method returns the array of parameters of V-isoline hatchings.
171      * Can be null if the object is initialized by 0 V-isolines.
172      *
173      * \return the array of V-isoline hatching parameters.
174      */
175     Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetVParams() const
176     { return myVPrm; }
177
178     /**
179      * This method returns a hatching curve by its index.
180      * If the curve is not found null handle is returned.
181      *
182      * \param theHatchingIndex the hatching curve index.
183      */
184     Standard_EXPORT const Handle(Geom2d_Curve) &GetHatching
185       (const Standard_Integer theHatchingIndex) const;
186
187   protected:
188
189     /**
190      * This method clears all hatchings data.
191      */
192     void Clear();
193
194   private:
195
196     Geom2dHatch_Hatcher              myHatcher;
197     TopoDS_Face                      myFace;
198     Standard_Boolean                 myIsDone;
199     Standard_Real                    myUMin;
200     Standard_Real                    myUMax;
201     Standard_Real                    myVMin;
202     Standard_Real                    myVMax;
203     Handle(TColStd_HArray1OfReal)    myUPrm;
204     Handle(TColStd_HArray1OfReal)    myVPrm;
205     Handle(TColStd_HArray1OfInteger) myUInd;
206     Handle(TColStd_HArray1OfInteger) myVInd;
207
208   };
209 }
210
211 #endif