OpenCMISS-Zinc C++ API Documentation
fieldassignment.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 
10 #ifndef CMZN_FIELDASSIGNMENT_HPP__
11 #define CMZN_FIELDASSIGNMENT_HPP__
12 
13 #include "opencmiss/zinc/fieldassignment.h"
14 #include "opencmiss/zinc/field.hpp"
15 #include "opencmiss/zinc/nodeset.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 
45 {
46 protected:
47  cmzn_fieldassignment_id id;
48 
49 public:
50 
51  Fieldassignment() :
52  id(0)
53  {
54  }
55 
56  // takes ownership of C handle, responsibility for destroying it
57  explicit Fieldassignment(cmzn_fieldassignment_id fieldassignment_id) :
58  id(fieldassignment_id)
59  {
60  }
61 
62  Fieldassignment(const Fieldassignment& fieldassignment) :
63  id(cmzn_fieldassignment_access(fieldassignment.id))
64  {
65  }
66 
67  Fieldassignment& operator=(const Fieldassignment& fieldassignment)
68  {
69  cmzn_fieldassignment_id temp_id = cmzn_fieldassignment_access(fieldassignment.id);
70  if (0 != this->id)
71  {
72  cmzn_fieldassignment_destroy(&this->id);
73  }
74  this->id = temp_id;
75  return *this;
76  }
77 
79  {
80  if (0 != this->id)
81  {
82  cmzn_fieldassignment_destroy(&this->id);
83  }
84  }
85 
91  bool isValid() const
92  {
93  return (0 != this->id);
94  }
95 
101  cmzn_fieldassignment_id getId() const
102  {
103  return id;
104  }
105 
112  int assign()
113  {
114  return cmzn_fieldassignment_assign(this->id);
115  }
116 
125  {
126  return Field(cmzn_fieldassignment_get_conditional_field(this->id));
127  }
128 
139  int setConditionalField(const Field& conditionalField)
140  {
141  return cmzn_fieldassignment_set_conditional_field(this->id, conditionalField.getId());
142  }
143 
152  {
153  return Nodeset(cmzn_fieldassignment_get_nodeset(this->id));
154  }
155 
164  int setNodeset(const Nodeset& nodeset)
165  {
166  return cmzn_fieldassignment_set_nodeset(this->id, nodeset.getId());
167  }
168 
176  {
177  return Field(cmzn_fieldassignment_get_source_field(this->id));
178  }
179 
187  {
188  return Field(cmzn_fieldassignment_get_target_field(this->id));
189  }
190 };
191 
193 {
194  return Fieldassignment(cmzn_field_create_fieldassignment(this->getId(), sourceField.getId()));
195 }
196 
197 } // namespace Zinc
198 }
199 
200 #endif /* CMZN_FIELDASSIGNMENT_HPP__ */
int assign()
Definition: fieldassignment.hpp:112
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
Nodeset getNodeset() const
Definition: fieldassignment.hpp:151
cmzn_nodeset_id getId() const
Definition: nodeset.hpp:82
Fieldassignment createFieldassignment(const Field &sourceField)
Definition: fieldassignment.hpp:192
cmzn_fieldassignment_id getId() const
Definition: fieldassignment.hpp:101
int setNodeset(const Nodeset &nodeset)
Definition: fieldassignment.hpp:164
Object for assigning values of a field from a source field.
Definition: fieldassignment.hpp:44
Field getTargetField() const
Definition: fieldassignment.hpp:186
Field getConditionalField() const
Definition: fieldassignment.hpp:124
cmzn_field_id getId() const
Definition: field.hpp:103
Field getSourceField() const
Definition: fieldassignment.hpp:175
int setConditionalField(const Field &conditionalField)
Definition: fieldassignment.hpp:139
bool isValid() const
Definition: fieldassignment.hpp:91
The OpenCMISS namespace.
Definition: context.hpp:20
A set of nodes or points.
Definition: nodeset.hpp:29