OpenCMISS-Zinc C++ API Documentation
nodetemplate.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_NODETEMPLATE_HPP__
10 #define CMZN_NODETEMPLATE_HPP__
11 
12 #include "opencmiss/zinc/nodetemplate.h"
13 #include "opencmiss/zinc/field.hpp"
14 #include "opencmiss/zinc/node.hpp"
15 #include "opencmiss/zinc/timesequence.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 
30 {
31 private:
32 
33  cmzn_nodetemplate_id id;
34 
35 public:
36 
37  Nodetemplate() : id(0)
38  { }
39 
40  // takes ownership of C handle, responsibility for destroying it
41  explicit Nodetemplate(cmzn_nodetemplate_id node_template_id) :
42  id(node_template_id)
43  { }
44 
45  Nodetemplate(const Nodetemplate& nodeTemplate) :
46  id(cmzn_nodetemplate_access(nodeTemplate.id))
47  { }
48 
49  Nodetemplate& operator=(const Nodetemplate& nodeTemplate)
50  {
51  cmzn_nodetemplate_id temp_id = cmzn_nodetemplate_access(nodeTemplate.id);
52  if (0 != id)
53  {
54  cmzn_nodetemplate_destroy(&id);
55  }
56  id = temp_id;
57  return *this;
58  }
59 
60  ~Nodetemplate()
61  {
62  if (0 != id)
63  {
64  cmzn_nodetemplate_destroy(&id);
65  }
66  }
67 
73  bool isValid() const
74  {
75  return (0 != id);
76  }
77 
83  cmzn_nodetemplate_id getId() const
84  {
85  return id;
86  }
87 
98  int defineField(const Field& field)
99  {
100  return cmzn_nodetemplate_define_field(id, field.getId());
101  }
102 
115  int defineFieldFromNode(const Field& field, const Node& node)
116  {
117  return cmzn_nodetemplate_define_field_from_node(id, field.getId(), node.getId());
118  }
119 
128  {
129  return Timesequence(cmzn_nodetemplate_get_timesequence(id, field.getId()));
130  }
131 
146  int setTimesequence(const Field& field, const Timesequence& timesequence)
147  {
148  return cmzn_nodetemplate_set_timesequence(id, field.getId(), timesequence.getId());
149  }
150 
167  int getValueNumberOfVersions(const Field& field, int componentNumber,
168  Node::ValueLabel valueLabel)
169  {
170  return cmzn_nodetemplate_get_value_number_of_versions(id, field.getId(),
171  componentNumber, static_cast<cmzn_node_value_label>(valueLabel));
172  }
173 
192  int setValueNumberOfVersions(const Field& field, int componentNumber,
193  Node::ValueLabel valueLabel, int numberOfVersions)
194  {
195  return cmzn_nodetemplate_set_value_number_of_versions(id, field.getId(),
196  componentNumber, static_cast<cmzn_node_value_label>(valueLabel), numberOfVersions);
197  }
198 
205  int removeField(const Field& field)
206  {
207  return cmzn_nodetemplate_remove_field(id, field.getId());
208  }
217  int undefineField(const Field& field)
218  {
219  return cmzn_nodetemplate_undefine_field(id, field.getId());
220  }
221 };
222 
223 inline int Node::merge(const Nodetemplate& nodeTemplate)
224 {
225  return cmzn_node_merge(id, nodeTemplate.getId());
226 }
227 
228 } // namespace Zinc
229 }
230 
231 #endif // CMZN_NODETEMPLATE_HPP__
int setTimesequence(const Field &field, const Timesequence &timesequence)
Definition: nodetemplate.hpp:146
cmzn_nodetemplate_id getId() const
Definition: nodetemplate.hpp:83
int setValueNumberOfVersions(const Field &field, int componentNumber, Node::ValueLabel valueLabel, int numberOfVersions)
Definition: nodetemplate.hpp:192
A description of field parameters to define at a node.
Definition: nodetemplate.hpp:29
ValueLabel
Definition: node.hpp:80
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
int removeField(const Field &field)
Definition: nodetemplate.hpp:205
bool isValid() const
Definition: nodetemplate.hpp:73
int undefineField(const Field &field)
Definition: nodetemplate.hpp:217
int getValueNumberOfVersions(const Field &field, int componentNumber, Node::ValueLabel valueLabel)
Definition: nodetemplate.hpp:167
cmzn_field_id getId() const
Definition: field.hpp:103
Timesequence getTimesequence(const Field &field)
Definition: nodetemplate.hpp:127
cmzn_node_id getId() const
Definition: node.hpp:136
int defineField(const Field &field)
Definition: nodetemplate.hpp:98
A non-decreasing list of times at which nodal parameters can be stored.
Definition: timesequence.hpp:35
cmzn_timesequence_id getId() const
Definition: timesequence.hpp:88
The OpenCMISS namespace.
Definition: context.hpp:20
Point object used to represent finite element nodes.
Definition: node.hpp:34
int defineFieldFromNode(const Field &field, const Node &node)
Definition: nodetemplate.hpp:115