OpenCMISS-Zinc C++ API Documentation
fieldvectoroperators.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_FIELDVECTOROPERATORS_HPP__
10 #define CMZN_FIELDVECTOROPERATORS_HPP__
11 
12 #include "opencmiss/zinc/fieldvectoroperators.h"
13 #include "opencmiss/zinc/field.hpp"
14 #include "opencmiss/zinc/fieldmodule.hpp"
15 
16 namespace OpenCMISS
17 {
18 namespace Zinc
19 {
20 class FieldCrossProduct : public Field
35 {
36 private:
37  // takes ownership of C handle, responsibility for destroying it
38  explicit FieldCrossProduct(cmzn_field_id field_id) : Field(field_id)
39  { }
40 
41  friend FieldCrossProduct Fieldmodule::createFieldCrossProduct(int fieldsCount,
42  const Field *sourceFields);
43 
44  friend FieldCrossProduct Fieldmodule::createFieldCrossProduct(
45  const Field& sourceField1, const Field& sourceField2);
46 
47 public:
48 
49  FieldCrossProduct() : Field(0)
50  { }
51 
52 };
53 class FieldDotProduct : public Field
62 {
63 private:
64  // takes ownership of C handle, responsibility for destroying it
65  explicit FieldDotProduct(cmzn_field_id field_id) : Field(field_id)
66  { }
67 
68  friend FieldDotProduct Fieldmodule::createFieldDotProduct(const Field& sourceField1,
69  const Field& sourceField2);
70 
71 public:
72 
73  FieldDotProduct() : Field(0)
74  { }
75 
76 };
77 class FieldMagnitude : public Field
84 {
85 private:
86  // takes ownership of C handle, responsibility for destroying it
87  explicit FieldMagnitude(cmzn_field_id field_id) : Field(field_id)
88  { }
89 
90  friend FieldMagnitude Fieldmodule::createFieldMagnitude(const Field& sourceField);
91 
92 public:
93 
94  FieldMagnitude() : Field(0)
95  { }
96 
97 };
98 class FieldNormalise : public Field
107 {
108 private:
109  // takes ownership of C handle, responsibility for destroying it
110  explicit FieldNormalise(cmzn_field_id field_id) : Field(field_id)
111  { }
112 
113  friend FieldNormalise Fieldmodule::createFieldNormalise(const Field& sourceField);
114 
115 public:
116 
117  FieldNormalise() : Field(0)
118  { }
119 
120 };
121 class FieldSumComponents : public Field
131 {
132 private:
133  // takes ownership of C handle, responsibility for destroying it
134  explicit FieldSumComponents(cmzn_field_id field_id) : Field(field_id)
135  { }
136 
137  friend FieldSumComponents Fieldmodule::createFieldSumComponents(const Field& sourceField);
138 
139 public:
140 
141  FieldSumComponents() : Field(0)
142  { }
143 
144 };
145 
146 inline FieldCrossProduct Fieldmodule::createFieldCrossProduct(int fieldsCount, const Field *sourceFields)
147 {
148  cmzn_field_id field = 0;
149  if (fieldsCount > 0)
150  {
151  cmzn_field_id *source_fields = new cmzn_field_id[fieldsCount];
152  for (int i = 0; i < fieldsCount; i++)
153  {
154  source_fields[i] = sourceFields[i].getId();
155  }
156  field = cmzn_fieldmodule_create_field_cross_product(id, fieldsCount, source_fields);
157  delete[] source_fields;
158  }
159  return FieldCrossProduct(field);
160 }
161 
162 inline FieldCrossProduct Fieldmodule::createFieldCrossProduct(const Field& sourceField1, const Field& sourceField2)
163 {
164  return FieldCrossProduct(cmzn_fieldmodule_create_field_cross_product_3d(id, sourceField1.getId(),
165  sourceField2.getId()));
166 }
167 
168 inline FieldDotProduct Fieldmodule::createFieldDotProduct(const Field& sourceField1, const Field& sourceField2)
169 {
170  return FieldDotProduct(cmzn_fieldmodule_create_field_dot_product(id, sourceField1.getId(),
171  sourceField2.getId()));
172 }
173 
175 {
176  return FieldMagnitude(cmzn_fieldmodule_create_field_magnitude(id, sourceField.getId()));
177 }
178 
180 {
181  return FieldNormalise(cmzn_fieldmodule_create_field_normalise(id, sourceField.getId()));
182 }
183 
185 {
186  return FieldSumComponents(cmzn_fieldmodule_create_field_sum_components(id,
187  sourceField.getId()));
188 }
189 
190 } // namespace Zinc
191 }
192 
193 #endif
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
A field which has one component equal to the sum of all components of the source field.
Definition: fieldvectoroperators.hpp:130
FieldDotProduct createFieldDotProduct(const Field &sourceField1, const Field &sourceField2)
Definition: fieldvectoroperators.hpp:168
FieldNormalise createFieldNormalise(const Field &sourceField)
Definition: fieldvectoroperators.hpp:179
A scalar field whose value is the dot product of the two supplied source fields, which must have equa...
Definition: fieldvectoroperators.hpp:61
A scalar field returning the magnitude of the vector source field.
Definition: fieldvectoroperators.hpp:83
cmzn_field_id getId() const
Definition: field.hpp:103
A field returning the values of source vector field normalised to unit length.
Definition: fieldvectoroperators.hpp:106
FieldMagnitude createFieldMagnitude(const Field &sourceField)
Definition: fieldvectoroperators.hpp:174
FieldSumComponents createFieldSumComponents(const Field &sourceField)
Definition: fieldvectoroperators.hpp:184
The OpenCMISS namespace.
Definition: context.hpp:20
FieldCrossProduct createFieldCrossProduct(int fieldsCount, const Field *sourceFields)
Definition: fieldvectoroperators.hpp:146
A vector field which is the cross product of the source_fields.
Definition: fieldvectoroperators.hpp:34