OpenCMISS-Zinc C++ API Documentation
field.hpp
Go to the documentation of this file.
1 
5 /* OpenCMISS-Zinc Library
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #ifndef CMZN_FIELD_HPP__
11 #define CMZN_FIELD_HPP__
12 
13 #include "opencmiss/zinc/field.h"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
20 class Differentialoperator;
21 class Element;
22 class Fieldassignment;
23 class Fieldcache;
24 class FieldComponent;
25 class FieldEdgeDiscontinuity;
26 class FieldEigenvalues;
27 class FieldElementGroup;
28 class FieldFindMeshLocation;
29 class FieldFiniteElement;
30 class FieldGroup;
31 class FieldImage;
32 class FieldImagefilterBinaryThreshold;
33 class FieldImagefilterDiscreteGaussian;
34 class FieldImagefilterHistogram;
35 class FieldImagefilterThreshold;
36 class FieldMeshIntegral;
37 class FieldNodeGroup;
38 class FieldStoredMeshLocation;
39 class FieldStoredString;
40 class Fieldmodule;
41 class Fieldsmoothing;
42 
51 class Field
52 {
53 protected:
54 
55  cmzn_field_id id;
56 
57 public:
58 
59  Field() : id(0)
60  { }
61 
62  // takes ownership of C handle, responsibility for destroying it
63  explicit Field(cmzn_field_id field_id) : id(field_id)
64  { }
65 
66  Field(const Field& field) : id(cmzn_field_access(field.id))
67  { }
68 
69  Field& operator=(const Field& field)
70  {
71  cmzn_field_id temp_id = cmzn_field_access(field.id);
72  if (0 != id)
73  {
74  cmzn_field_destroy(&id);
75  }
76  id = temp_id;
77  return *this;
78  }
79 
80  ~Field()
81  {
82  if (0 != id)
83  {
84  cmzn_field_destroy(&id);
85  }
86  }
87 
93  bool isValid() const
94  {
95  return (0 != id);
96  }
97 
103  cmzn_field_id getId() const
104  {
105  return id;
106  }
107 
112  {
113  CHANGE_FLAG_NONE = CMZN_FIELD_CHANGE_FLAG_NONE,
115  CHANGE_FLAG_ADD = CMZN_FIELD_CHANGE_FLAG_ADD,
117  CHANGE_FLAG_REMOVE = CMZN_FIELD_CHANGE_FLAG_REMOVE,
119  CHANGE_FLAG_IDENTIFIER = CMZN_FIELD_CHANGE_FLAG_IDENTIFIER,
121  CHANGE_FLAG_DEFINITION = CMZN_FIELD_CHANGE_FLAG_DEFINITION,
125  CHANGE_FLAG_FULL_RESULT = CMZN_FIELD_CHANGE_FLAG_FULL_RESULT,
128  CHANGE_FLAG_PARTIAL_RESULT = CMZN_FIELD_CHANGE_FLAG_PARTIAL_RESULT,
132  CHANGE_FLAG_RESULT = CMZN_FIELD_CHANGE_FLAG_RESULT,
134  CHANGE_FLAG_FINAL = CMZN_FIELD_CHANGE_FLAG_FINAL
136  };
137 
142  typedef int ChangeFlags;
143 
152  {
153  COORDINATE_SYSTEM_TYPE_INVALID = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_INVALID,
155  COORDINATE_SYSTEM_TYPE_RECTANGULAR_CARTESIAN = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_RECTANGULAR_CARTESIAN ,
157  COORDINATE_SYSTEM_TYPE_CYLINDRICAL_POLAR = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_CYLINDRICAL_POLAR,
163  COORDINATE_SYSTEM_TYPE_SPHERICAL_POLAR = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_SPHERICAL_POLAR,
169  COORDINATE_SYSTEM_TYPE_PROLATE_SPHEROIDAL = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_PROLATE_SPHEROIDAL,
177  COORDINATE_SYSTEM_TYPE_OBLATE_SPHEROIDAL = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_OBLATE_SPHEROIDAL,
185  COORDINATE_SYSTEM_TYPE_FIBRE = CMZN_FIELD_COORDINATE_SYSTEM_TYPE_FIBRE
204  };
205 
211  {
212  DOMAIN_TYPE_INVALID = CMZN_FIELD_DOMAIN_TYPE_INVALID,
214  DOMAIN_TYPE_POINT = CMZN_FIELD_DOMAIN_TYPE_POINT,
216  DOMAIN_TYPE_NODES = CMZN_FIELD_DOMAIN_TYPE_NODES,
218  DOMAIN_TYPE_DATAPOINTS = CMZN_FIELD_DOMAIN_TYPE_DATAPOINTS,
220  DOMAIN_TYPE_MESH1D = CMZN_FIELD_DOMAIN_TYPE_MESH1D,
222  DOMAIN_TYPE_MESH2D = CMZN_FIELD_DOMAIN_TYPE_MESH2D,
224  DOMAIN_TYPE_MESH3D = CMZN_FIELD_DOMAIN_TYPE_MESH3D,
226  DOMAIN_TYPE_MESH_HIGHEST_DIMENSION = CMZN_FIELD_DOMAIN_TYPE_MESH_HIGHEST_DIMENSION
228  };
229 
233  typedef int DomainTypes;
234 
240  {
241  VALUE_TYPE_INVALID = CMZN_FIELD_VALUE_TYPE_INVALID,
243  VALUE_TYPE_REAL = CMZN_FIELD_VALUE_TYPE_REAL,
245  VALUE_TYPE_STRING = CMZN_FIELD_VALUE_TYPE_STRING,
247  VALUE_TYPE_MESH_LOCATION = CMZN_FIELD_VALUE_TYPE_MESH_LOCATION
249  };
250 
251 
260  inline Fieldassignment createFieldassignment(const Field& sourceField);
261 
268  bool isManaged()
269  {
270  return cmzn_field_is_managed(id);
271  }
272 
285  int setManaged(bool value)
286  {
287  return cmzn_field_set_managed(id, value);
288  }
289 
301  char *getComponentName(int componentNumber)
302  {
303  return cmzn_field_get_component_name(id, componentNumber);
304  }
305 
314  int setComponentName(int componentNumber, const char *name)
315  {
316  return cmzn_field_set_component_name(id, componentNumber, name);
317  }
318 
326  {
327  return cmzn_field_get_coordinate_system_focus(id);
328  }
329 
338  int setCoordinateSystemFocus(double focus)
339  {
340  return cmzn_field_set_coordinate_system_focus(id, focus);
341  }
342 
349  {
350  return static_cast<CoordinateSystemType>(
351  cmzn_field_get_coordinate_system_type(id));
352  }
353 
364  {
365  return cmzn_field_set_coordinate_system_type(id,
366  static_cast<cmzn_field_coordinate_system_type>(coordinateSystemType));
367  }
368 
375  {
376  return cmzn_field_get_number_of_components(id);
377  }
378 
385  char *getName()
386  {
387  return cmzn_field_get_name(id);
388  }
389 
397  int setName(const char *name)
398  {
399  return cmzn_field_set_name(id, name);
400  }
401 
408  {
409  return cmzn_field_get_number_of_source_fields(id);
410  }
411 
421  {
422  return Field(cmzn_field_get_source_field(id, index));
423  }
424 
432  {
433  return cmzn_field_is_type_coordinate(id);
434  }
435 
445  int setTypeCoordinate(bool value)
446  {
447  return cmzn_field_set_type_coordinate(id, value);
448  }
449 
456  {
457  return static_cast<ValueType>(cmzn_field_get_value_type(id));
458  }
459 
465  inline Fieldmodule getFieldmodule() const;
466 
479  inline int assignMeshLocation(const Fieldcache& cache, const Element& element,
480  int coordinatesCount, const double *coordinatesIn);
481 
497  inline int assignReal(const Fieldcache& cache, int valuesCount, const double *valuesIn);
498 
508  inline int assignString(const Fieldcache& cache, const char *stringValue);
509 
521  inline Element evaluateMeshLocation(const Fieldcache& cache, int coordinatesCount,
522  double *coordinatesOut);
523 
534  inline int evaluateReal(const Fieldcache& cache, int valuesCount, double *valuesOut);
535 
545  inline char *evaluateString(const Fieldcache& cache);
546 
568  inline int evaluateDerivative(const Differentialoperator& differentialOperator,
569  const Fieldcache& cache, int valuesCount, double *valuesOut);
570 
584  inline bool isDefinedAtLocation(const Fieldcache& cache);
585 
592  inline int smooth(const Fieldsmoothing& fieldsmoothing);
593 
594  // casting functions: must check isValid()
601  inline FieldComponent castComponent();
645  inline FieldGroup castGroup();
652  inline FieldImage castImage();
699  inline FieldNodeGroup castNodeGroup();
712 };
713 
714 inline bool operator==(const Field& a, const Field& b)
715 {
716  return a.getId() == b.getId();
717 }
718 
725 {
726 private:
727 
728  cmzn_fielditerator_id id;
729 
730 public:
731 
732  Fielditerator() : id(0)
733  { }
734 
735  // takes ownership of C handle, responsibility for destroying it
736  explicit Fielditerator(cmzn_fielditerator_id iterator_id) :
737  id(iterator_id)
738  { }
739 
740  Fielditerator(const Fielditerator& fielditerator) :
741  id(cmzn_fielditerator_access(fielditerator.id))
742  { }
743 
744  Fielditerator& operator=(const Fielditerator& fielditerator)
745  {
746  cmzn_fielditerator_id temp_id = cmzn_fielditerator_access(fielditerator.id);
747  if (0 != id)
748  {
749  cmzn_fielditerator_destroy(&id);
750  }
751  id = temp_id;
752  return *this;
753  }
754 
755  ~Fielditerator()
756  {
757  if (0 != id)
758  {
759  cmzn_fielditerator_destroy(&id);
760  }
761  }
762 
768  bool isValid() const
769  {
770  return (0 != id);
771  }
772 
781  {
782  return Field(cmzn_fielditerator_next(id));
783  }
784 };
785 
786 } // namespace Zinc
787 }
788 #endif /* CMZN_FIELD_HPP__ */
int evaluateDerivative(const Differentialoperator&differentialOperator, const Fieldcache &cache, int valuesCount, double *valuesOut)
Definition: fieldcache.hpp:226
A single finite element from a mesh.
Definition: element.hpp:34
FieldNodeGroup castNodeGroup()
Definition: fieldsubobjectgroup.hpp:106
bool isValid() const
Definition: field.hpp:93
A real-valued interpolated field.
Definition: fieldfiniteelement.hpp:31
FieldImagefilterDiscreteGaussian castImagefilterDiscreteGaussian()
Definition: fieldimageprocessing.hpp:765
ChangeFlag
Definition: field.hpp:111
Element evaluateMeshLocation(const Fieldcache &cache, int coordinatesCount, double *coordinatesOut)
Definition: fieldcache.hpp:209
A field which defines a subset of elements from a master mesh.
Definition: fieldsubobjectgroup.hpp:31
char * getName()
Definition: field.hpp:385
FieldElementGroup castElementGroup()
Definition: fieldsubobjectgroup.hpp:95
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
int assignReal(const Fieldcache &cache, int valuesCount, const double *valuesIn)
Definition: fieldcache.hpp:199
FieldStoredString castStoredString()
Definition: fieldfiniteelement.hpp:549
FieldFindMeshLocation castFindMeshLocation()
Definition: fieldfiniteelement.hpp:519
CoordinateSystemType getCoordinateSystemType()
Definition: field.hpp:348
FieldComponent castComponent()
Definition: fieldcomposite.hpp:167
bool isTypeCoordinate()
Definition: field.hpp:431
int setCoordinateSystemFocus(double focus)
Definition: field.hpp:338
int setName(const char *name)
Definition: field.hpp:397
Fieldassignment createFieldassignment(const Field &sourceField)
Definition: fieldassignment.hpp:192
Field getSourceField(int index)
Definition: field.hpp:420
FieldImage castImage()
Definition: fieldimage.hpp:580
int getNumberOfComponents()
Definition: field.hpp:374
Describes the derivative of a field to evaluate.
Definition: differentialoperator.hpp:26
FieldFiniteElement castFiniteElement()
Definition: fieldfiniteelement.hpp:489
int assignString(const Fieldcache &cache, const char *stringValue)
Definition: fieldcache.hpp:204
Object for assigning values of a field from a source field.
Definition: fieldassignment.hpp:44
A field which defines a subset of nodes from a master nodeset.
Definition: fieldsubobjectgroup.hpp:64
A field which stores and returns string values at nodes.
Definition: fieldfiniteelement.hpp:401
char * getComponentName(int componentNumber)
Definition: field.hpp:301
A field returning one or more components of a source field in a specified order.
Definition: fieldcomposite.hpp:54
Image processing derived field type performing the ITK discrete gaussian filter.
Definition: fieldimageprocessing.hpp:226
FieldEdgeDiscontinuity castEdgeDiscontinuity()
Definition: fieldfiniteelement.hpp:501
A field calculating the integral over a mesh.
Definition: fieldmeshoperators.hpp:33
Parameters for smoothing a field.
Definition: fieldsmoothing.hpp:28
char * evaluateString(const Fieldcache &cache)
Definition: fieldcache.hpp:221
cmzn_field_id getId() const
Definition: field.hpp:103
A field measuring discontinuity between surface elements.
Definition: fieldfiniteelement.hpp:144
An image-based field giving the pixel colour/intensity values.
Definition: fieldimage.hpp:31
bool isDefinedAtLocation(const Fieldcache &cache)
Definition: fieldcache.hpp:233
A field storing locations within a mesh.
Definition: fieldfiniteelement.hpp:383
int setManaged(bool value)
Definition: field.hpp:285
int DomainTypes
Definition: field.hpp:233
DomainType
Definition: field.hpp:210
int ChangeFlags
Definition: field.hpp:142
CoordinateSystemType
Definition: field.hpp:151
Field next()
Definition: field.hpp:780
FieldGroup castGroup()
Definition: fieldgroup.hpp:365
bool isValid() const
Definition: field.hpp:768
FieldImagefilterHistogram castImagefilterHistogram()
Definition: fieldimageprocessing.hpp:786
int assignMeshLocation(const Fieldcache &cache, const Element &element, int coordinatesCount, const double *coordinatesIn)
Definition: fieldcache.hpp:192
Image processing derived field type performing the ITK threshold filter.
Definition: fieldimageprocessing.hpp:569
int smooth(const Fieldsmoothing &fieldsmoothing)
Definition: fieldsmoothing.hpp:124
FieldMeshIntegral castMeshIntegral()
Definition: fieldmeshoperators.hpp:182
FieldStoredMeshLocation castStoredMeshLocation()
Definition: fieldfiniteelement.hpp:538
Container/manager of fields and domains within a region.
Definition: fieldmodule.hpp:135
Cache for setting domain locations at which fields are evaluated or assigned.
Definition: fieldcache.hpp:33
int setTypeCoordinate(bool value)
Definition: field.hpp:445
int setComponentName(int componentNumber, const char *name)
Definition: field.hpp:314
ValueType
Definition: field.hpp:239
bool isManaged()
Definition: field.hpp:268
Image processing derived field type performing the ITK histogram field.
Definition: fieldimageprocessing.hpp:302
ValueType getValueType()
Definition: field.hpp:455
A generic group field used for grouping local subobjects.
Definition: fieldgroup.hpp:35
Image processing derived field type performing the ITK binary threshold filter.
Definition: fieldimageprocessing.hpp:80
double getCoordinateSystemFocus()
Definition: field.hpp:325
The OpenCMISS namespace.
Definition: context.hpp:20
FieldEigenvalues castEigenvalues()
Definition: fieldmatrixoperators.hpp:213
int getNumberOfSourceFields()
Definition: field.hpp:407
FieldImagefilterBinaryThreshold castImagefilterBinaryThreshold()
Definition: fieldimageprocessing.hpp:724
int evaluateReal(const Fieldcache &cache, int valuesCount, double *valuesOut)
Definition: fieldcache.hpp:216
int setCoordinateSystemType(CoordinateSystemType coordinateSystemType)
Definition: field.hpp:363
An iterator for looping through all the fields in a fieldmodule.
Definition: field.hpp:724
FieldImagefilterThreshold castImagefilterThreshold()
Definition: fieldimageprocessing.hpp:824
A field calculating the eigenvalues.
Definition: fieldmatrixoperators.hpp:50
A field that computes the location in a mesh.
Definition: fieldfiniteelement.hpp:282
Fieldmodule getFieldmodule() const
Definition: fieldmodule.hpp:1786