Salome HOME
Updated copyright comment
[modules/shaper.git] / src / XAO / XAO_Field.hxx
1 // Copyright (C) 2013-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Frederic Pons (OpenCascade)
20
21 #ifndef __XAO_FIELD_HXX__
22 #define __XAO_FIELD_HXX__
23
24 #include <string>
25 #include <vector>
26
27 #include "XAO.hxx"
28 #include "XAO_XaoUtils.hxx"
29 #include "XAO_Step.hxx"
30
31 #ifdef WIN32
32 #pragma warning(disable:4290) // Warning Exception ...
33 #pragma warning(disable:4251) // Warning dll-interface ...
34 #endif
35
36
37 namespace XAO
38 {
39     typedef std::vector<Step*>::iterator stepIterator;
40
41     /**
42      * @class Field
43      * A geometrical Field.
44      */
45     class XAO_EXPORT Field
46     {
47     protected:
48         /**
49          * Constructor.
50          * @param dimension the dimension of the field.
51          * @param nbElements the number of elements.
52          * @param nbComponents the number of components.
53          * @param name the name of the field.
54          */
55         Field(XAO::Dimension dimension,
56               int nbElements, int nbComponents, const std::string& name);
57
58     public:
59         /**
60          * Creates a Field of the given type.
61          * @param type the type of the field to create.
62          * @param dimension the dimension.
63          * @param nbElements the number of geometrical elements.
64          * @param nbComponents the number of components.
65          * @name the name of the field.
66          * @return the created field.
67          */
68         static Field* createField(XAO::Type type, XAO::Dimension dimension,
69                                   int nbElements, int nbComponents,
70                                   const std::string& name = std::string(""));
71
72         /**
73          * Destructor.
74          */
75         virtual ~Field();
76
77         /**
78          * Gets the Type of the field.
79          * @return the Type of the field.
80          */
81         virtual XAO::Type getType() = 0;
82
83         /**
84          * Gets the name of the Field.
85          * @return the name of the Field.
86          */
87         const std::string getName() const
88         {
89             return m_name;
90         }
91
92         /**
93          * Sets the name of the Field.
94          * @param name the name to set.
95          */
96         void setName(const std::string& name)
97         {
98             m_name = name;
99         }
100
101         /**
102          * Gets the Dimension of the Field.
103          * @return the Dimension of the Field.
104          */
105         XAO::Dimension getDimension() const
106         {
107             return m_dimension;
108         }
109
110         /**
111          * Gets the number of elements of each step.
112          * @return the number of elements of each step.
113          */
114         int countElements() const
115         {
116             return m_nbElements;
117         }
118
119         /**
120          * Gets the number of components.
121          * @return the number of components.
122          */
123         int countComponents() const
124         {
125             return m_nbComponents;
126         }
127
128         /**
129          * Gets the number of values for each step.
130          * @return the number of values for each step.
131          */
132         int countValues() const
133         {
134             return m_nbElements * m_nbComponents;
135         }
136
137         /**
138          * Gets the number of the steps.
139          * @return the number of steps.
140          */
141         int countSteps() const { return m_steps.size(); }
142
143         /**
144          * Gets the name of a component.
145          * @param index the index of the component to get.
146          * @return the name of the component for the given index.
147          */
148         const std::string getComponentName(int index);
149
150         /**
151          * Sets the name of a component.
152          * @param componentIndex the index of the component to set.
153          * @param name the name to set.
154          */
155         void setComponentName(int componentIndex, const std::string& name);
156
157         /**
158          * Sets the name of the components.
159          * @param names the names to set.
160          */
161         void setComponentsNames(const std::vector<std::string>& names);
162
163         /**
164          * Adds a new step of the same type than the field.
165          * @param number the numer of the step.
166          * @return the new create step.
167          */
168         virtual Step* addNewStep(int number) = 0;
169
170         /**
171          * Remove a step.
172          * @param step the step to remove.
173          * @return true if the step has been removed, false otherwise.
174          */
175         bool removeStep(Step* step);
176
177         /**
178          * Verifies if the field has a step with the given step number.
179          * @param step the step number.
180          * @return true if the field has a step for the given number.
181          */
182         bool hasStep(int step);
183
184         /**
185          * Returns the first step.
186          * @return an iterator on the first step.
187          */
188         stepIterator begin() { return m_steps.begin(); }
189
190         /**
191          * Returns the last step.
192          * @return an iterator on the last step.
193          */
194         stepIterator end() { return m_steps.end(); }
195
196     protected:
197         void checkComponent(int component) ;
198         void checkStepIndex(int step) ;
199
200     protected:
201         /** The name of the Field. */
202         std::string m_name;
203         /** The dimension of the Field. */
204         XAO::Dimension m_dimension;
205
206         /** The number of components. */
207         int m_nbComponents;
208         /** The components of the field. */
209         std::vector<std::string> m_components;
210         /** The number of elements. */
211         int m_nbElements;
212
213         /** The list of steps. */
214         std::vector<Step*> m_steps;
215     };
216 }
217
218 #endif