OpenCMISS-Zinc C++ API Documentation
node.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_NODE_HPP__
10 #define CMZN_NODE_HPP__
11 
12 #include "opencmiss/zinc/node.h"
13 
14 namespace OpenCMISS
15 {
16 namespace Zinc
17 {
18 
19 class Nodeset;
20 class Nodetemplate;
21 
34 class Node
35 {
36 private:
37 
38  cmzn_node_id id;
39 
40 public:
41 
42  Node() : id(0)
43  { }
44 
45  // takes ownership of C handle, responsibility for destroying it
46  explicit Node(cmzn_node_id node_id) : id(node_id)
47  { }
48 
49  Node(const Node& node) :
50  id(cmzn_node_access(node.id))
51  { }
52 
57  {
58  CHANGE_FLAG_NONE = CMZN_NODE_CHANGE_FLAG_NONE,
60  CHANGE_FLAG_ADD = CMZN_NODE_CHANGE_FLAG_ADD,
62  CHANGE_FLAG_REMOVE = CMZN_NODE_CHANGE_FLAG_REMOVE,
64  CHANGE_FLAG_IDENTIFIER = CMZN_NODE_CHANGE_FLAG_IDENTIFIER,
66  CHANGE_FLAG_DEFINITION = CMZN_NODE_CHANGE_FLAG_DEFINITION,
68  CHANGE_FLAG_FIELD = CMZN_NODE_CHANGE_FLAG_FIELD
70  };
71 
75  typedef int ChangeFlags;
76 
81  {
82  VALUE_LABEL_INVALID = CMZN_NODE_VALUE_LABEL_INVALID,
84  VALUE_LABEL_VALUE = CMZN_NODE_VALUE_LABEL_VALUE,
86  VALUE_LABEL_D_DS1 = CMZN_NODE_VALUE_LABEL_D_DS1,
88  VALUE_LABEL_D_DS2 = CMZN_NODE_VALUE_LABEL_D_DS2,
90  VALUE_LABEL_D2_DS1DS2 = CMZN_NODE_VALUE_LABEL_D2_DS1DS2,
92  VALUE_LABEL_D_DS3 = CMZN_NODE_VALUE_LABEL_D_DS3,
94  VALUE_LABEL_D2_DS1DS3 = CMZN_NODE_VALUE_LABEL_D2_DS1DS3,
96  VALUE_LABEL_D2_DS2DS3 = CMZN_NODE_VALUE_LABEL_D2_DS2DS3,
98  VALUE_LABEL_D3_DS1DS2DS3 = CMZN_NODE_VALUE_LABEL_D3_DS1DS2DS3,
100  };
101 
102  Node& operator=(const Node& node)
103  {
104  cmzn_node_id temp_id = cmzn_node_access(node.id);
105  if (0 != id)
106  {
107  cmzn_node_destroy(&id);
108  }
109  id = temp_id;
110  return *this;
111  }
112 
113  ~Node()
114  {
115  if (0 != id)
116  {
117  cmzn_node_destroy(&id);
118  }
119  }
120 
126  bool isValid() const
127  {
128  return (0 != id);
129  }
130 
136  cmzn_node_id getId() const
137  {
138  return id;
139  }
140 
149  {
150  return cmzn_node_get_identifier(id);
151  }
152 
161  int setIdentifier(int identifier)
162  {
163  return cmzn_node_set_identifier(id, identifier);
164  }
165 
171  inline Nodeset getNodeset() const;
172 
173  int merge(const Nodetemplate& nodeTemplate);
174 
175 };
176 
177 inline bool operator==(const Node& a, const Node& b)
178 {
179  return a.getId() == b.getId();
180 }
181 
188 {
189 private:
190 
191  cmzn_nodeiterator_id id;
192 
193 public:
194 
195  Nodeiterator() : id(0)
196  { }
197 
198  // takes ownership of C handle, responsibility for destroying it
199  explicit Nodeiterator(cmzn_nodeiterator_id node_iterator_id) :
200  id(node_iterator_id)
201  { }
202 
203  Nodeiterator(const Nodeiterator& nodeIterator) :
204  id(cmzn_nodeiterator_access(nodeIterator.id))
205  { }
206 
207  Nodeiterator& operator=(const Nodeiterator& nodeIterator)
208  {
209  cmzn_nodeiterator_id temp_id = cmzn_nodeiterator_access(nodeIterator.id);
210  if (0 != id)
211  {
212  cmzn_nodeiterator_destroy(&id);
213  }
214  id = temp_id;
215  return *this;
216  }
217 
218  ~Nodeiterator()
219  {
220  if (0 != id)
221  {
222  cmzn_nodeiterator_destroy(&id);
223  }
224  }
225 
231  bool isValid() const
232  {
233  return (0 != id);
234  }
235 
244  {
245  return Node(cmzn_nodeiterator_next(id));
246  }
247 };
248 
249 } // namespace Zinc
250 }
251 
252 #endif // CMZN_NODE_HPP__
An iterator for looping through all the nodes in a nodeset.
Definition: node.hpp:187
A description of field parameters to define at a node.
Definition: nodetemplate.hpp:29
ValueLabel
Definition: node.hpp:80
int getIdentifier()
Definition: node.hpp:148
Node next()
Definition: node.hpp:243
ChangeFlag
Definition: node.hpp:56
int setIdentifier(int identifier)
Definition: node.hpp:161
bool isValid() const
Definition: node.hpp:231
Nodeset getNodeset() const
Definition: nodeset.hpp:255
cmzn_node_id getId() const
Definition: node.hpp:136
bool isValid() const
Definition: node.hpp:126
int ChangeFlags
Definition: node.hpp:75
The OpenCMISS namespace.
Definition: context.hpp:20
Point object used to represent finite element nodes.
Definition: node.hpp:34
A set of nodes or points.
Definition: nodeset.hpp:29