Salome HOME
a95bc77ae730a1044708e794192ada9e28d2312d
[modules/geom.git] / src / GEOM / GEOM_IField.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 //NOTE: This is an interface to a function for the Field creation.
24 //
25 #include "GEOM_Function.hxx"
26
27 #include <TColStd_HArray1OfExtendedString.hxx>
28 #include <TColStd_HArray1OfInteger.hxx>
29 #include <TColStd_HArray1OfReal.hxx>
30
31 class GEOM_Field;
32
33 class GEOM_IField
34 {
35   enum {
36     // field
37     FIELD_SHAPE      = 1, // ref
38     FIELD_DATATYPE   = 1, // int
39     FIELD_DIMENSION  = 2, // int
40     FIELD_COMPONENTS = 1, // string array
41     // field step
42     STEP_FIELD       = 1, // ref
43     STEP_ID          = 1, // int
44     STEP_STAMP       = 2, // int
45     STEP_VALUES      = 2  // an array of any type
46   };
47
48 public:
49
50   GEOM_IField(Handle(GEOM_Function) theFunction): _func(theFunction) {}
51
52   Standard_EXPORT Handle(GEOM_Function) GetShape()
53   { return _func->GetReference( FIELD_SHAPE ); }
54   Standard_EXPORT int GetDataType()  { return _func->GetInteger( FIELD_DATATYPE ); }
55   Standard_EXPORT int GetDimension() { return _func->GetInteger( FIELD_DIMENSION ); }
56   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetComponents()
57   { return _func->GetStringArray( FIELD_COMPONENTS ); }
58
59   Standard_EXPORT Handle(GEOM_Function) GetField()
60   { return _func->GetReference( STEP_FIELD ); }
61   Standard_EXPORT int GetStepID() { return _func->GetInteger( STEP_ID ); }
62   Standard_EXPORT int GetStepStamp() { return _func->GetInteger( STEP_STAMP ); }
63   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntValues()
64   { return _func->GetIntegerArray( STEP_VALUES ); }
65   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetDoubleValues()
66   { return _func->GetRealArray( STEP_VALUES ); }
67   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringValues()
68   { return _func->GetStringArray( STEP_VALUES ); }
69
70  private:
71
72   void SetShape(Handle(GEOM_Function) theS) { _func->SetReference( FIELD_SHAPE, theS ); }
73   void SetDataType( int type ) { _func->SetInteger( FIELD_DATATYPE, type ); }
74   void SetDimension( int dim ) { _func->SetInteger( FIELD_DIMENSION, dim ); }
75   void SetComponents( const Handle(TColStd_HArray1OfExtendedString)& compNames )
76   { _func->SetStringArray( FIELD_COMPONENTS, compNames ); }
77
78   friend class GEOM_Field;
79
80   void SetField(Handle(GEOM_Function) theF) { _func->SetReference( STEP_FIELD, theF ); }
81   void SetStepStamp( int stamp ) { _func->SetInteger( STEP_STAMP, stamp ); }
82   void SetStepID( int step ) { _func->SetInteger( STEP_ID, step ); }
83   // void SetStepIDs( Handle(TColStd_HArray1OfInteger) steps )
84   // { _func->SetRealArray( FIELD_STEP_IDS, steps ); }
85   void SetValues( const Handle(TColStd_HArray1OfInteger)& values )
86   { _func->SetIntegerArray( STEP_VALUES, values ); }
87   void SetValues( const Handle(TColStd_HArray1OfReal)& values )
88   { _func->SetRealArray( STEP_VALUES, values ); }
89   void SetValues( const Handle(TColStd_HArray1OfExtendedString)& values )
90   { _func->SetStringArray( STEP_VALUES, values ); }
91
92   friend class GEOM_FieldStep;
93
94   Handle(GEOM_Function) _func;
95 };