OpenCMISS-Zinc C++ API Documentation
fieldcomposite.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_FIELDCOMPOSITE_HPP__
10 #define CMZN_FIELDCOMPOSITE_HPP__
11 
12 
13 #include "opencmiss/zinc/fieldcomposite.h"
14 #include "opencmiss/zinc/field.hpp"
15 #include "opencmiss/zinc/fieldmodule.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 class FieldIdentity : public Field
31 {
32 
33 private:
34  // takes ownership of C handle, responsibility for destroying it
35  explicit FieldIdentity(cmzn_field_id field_id) : Field(field_id)
36  { }
37 
38  friend FieldIdentity Fieldmodule::createFieldIdentity(const Field& sourceField);
39 
40 public:
41 
42  FieldIdentity() : Field(0)
43  { }
44 
45 };
46 
54 class FieldComponent : public Field
55 {
56 public:
57 
58  FieldComponent() : Field(0)
59  { }
60 
61  // takes ownership of C handle, responsibility for destroying it
62  explicit FieldComponent(cmzn_field_component_id field_component_id) :
63  Field(reinterpret_cast<cmzn_field_id>(field_component_id))
64  { }
65 
71  inline cmzn_field_component_id getDerivedId()
72  {
73  return reinterpret_cast<cmzn_field_component_id>(id);
74  }
75 
82  {
83  return cmzn_field_component_get_component_index(getDerivedId());
84  }
85 
93  int setComponentIndex(int componentIndex)
94  {
95  return cmzn_field_component_set_component_index(getDerivedId(), componentIndex);
96  }
97 
104  int getSourceComponentIndex(int index)
105  {
106  return cmzn_field_component_get_source_component_index(getDerivedId(), index);
107  }
108 
117  int setSourceComponentIndex(int index, int sourceComponentIndex)
118  {
119  return cmzn_field_component_set_source_component_index(getDerivedId(), index, sourceComponentIndex);
120  }
121 
122 };
123 class FieldConcatenate : public Field
132 {
133 private:
134 
135  // takes ownership of C handle, responsibility for destroying it
136  explicit FieldConcatenate(cmzn_field_id field_id) : Field(field_id)
137  { }
138 
139  friend FieldConcatenate Fieldmodule::createFieldConcatenate(int fieldsCount, const Field *sourceFields);
140 
141 public:
142 
143  FieldConcatenate() : Field(0)
144  { }
145 
146 };
147 
149 {
150  return FieldIdentity(cmzn_fieldmodule_create_field_identity(id, sourceField.getId()));
151 }
152 
153 inline FieldComponent Fieldmodule::createFieldComponent(const Field& sourceField, int sourceComponentIndex)
154 {
155  return FieldComponent(reinterpret_cast<cmzn_field_component_id>(
156  cmzn_fieldmodule_create_field_component(this->id, sourceField.getId(), sourceComponentIndex)));
157 }
158 
160  int sourceComponentIndexesCount, const int *sourceComponentIndexesIn)
161 {
162  return FieldComponent(reinterpret_cast<cmzn_field_component_id>(
163  cmzn_fieldmodule_create_field_component_multiple(this->id, sourceField.getId(),
164  sourceComponentIndexesCount, sourceComponentIndexesIn)));
165 }
166 
168 {
169  return FieldComponent(cmzn_field_cast_component(id));
170 }
171 
172 inline FieldConcatenate Fieldmodule::createFieldConcatenate(int fieldsCount, const Field *sourceFields)
173 {
174  cmzn_field_id concatenateField = 0;
175  if (fieldsCount > 0)
176  {
177  cmzn_field_id *source_fields = new cmzn_field_id[fieldsCount];
178  for (int i = 0; i < fieldsCount; i++)
179  {
180  source_fields[i] = sourceFields[i].getId();
181  }
182  concatenateField = cmzn_fieldmodule_create_field_concatenate(id, fieldsCount, source_fields);
183  delete[] source_fields;
184  }
185  return FieldConcatenate(concatenateField);
186 }
187 
188 } // namespace Zinc
189 }
190 
191 #endif
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
A field which concatenates the components of all source fields, in order, into a single vector...
Definition: fieldcomposite.hpp:131
FieldComponent castComponent()
Definition: fieldcomposite.hpp:167
int setSourceComponentIndex(int index, int sourceComponentIndex)
Definition: fieldcomposite.hpp:117
A field returning one or more components of a source field in a specified order.
Definition: fieldcomposite.hpp:54
cmzn_field_id getId() const
Definition: field.hpp:103
int getComponentIndex()
Definition: fieldcomposite.hpp:81
cmzn_field_component_id getDerivedId()
Definition: fieldcomposite.hpp:71
int getSourceComponentIndex(int index)
Definition: fieldcomposite.hpp:104
int setComponentIndex(int componentIndex)
Definition: fieldcomposite.hpp:93
FieldConcatenate createFieldConcatenate(int fieldsCount, const Field *sourceFields)
Definition: fieldcomposite.hpp:172
FieldComponent createFieldComponent(const Field &sourceField, int sourceComponentIndex)
Definition: fieldcomposite.hpp:153
FieldIdentity createFieldIdentity(const Field &sourceField)
Definition: fieldcomposite.hpp:148
The OpenCMISS namespace.
Definition: context.hpp:20
A field with the single source field.
Definition: fieldcomposite.hpp:30