OpenCMISS-Zinc C++ API Documentation
nodeset.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_NODESET_HPP__
10 #define CMZN_NODESET_HPP__
11 
12 #include "opencmiss/zinc/nodeset.h"
13 #include "opencmiss/zinc/field.hpp"
14 #include "opencmiss/zinc/node.hpp"
15 #include "opencmiss/zinc/nodetemplate.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 
22 class NodesetGroup;
23 
29 class Nodeset
30 {
31 protected:
32 
33  cmzn_nodeset_id id;
34 
35 public:
36 
37  Nodeset() : id(0)
38  { }
39 
40  // takes ownership of C handle, responsibility for destroying it
41  explicit Nodeset(cmzn_nodeset_id nodeset_id) : id(nodeset_id)
42  { }
43 
44  Nodeset(const Nodeset& nodeset) :
45  id(cmzn_nodeset_access(nodeset.id))
46  { }
47 
48  Nodeset& operator=(const Nodeset& nodeset)
49  {
50  cmzn_nodeset_id temp_id = cmzn_nodeset_access(nodeset.id);
51  if (0 != id)
52  {
53  cmzn_nodeset_destroy(&id);
54  }
55  id = temp_id;
56  return *this;
57  }
58 
59  ~Nodeset()
60  {
61  if (0 != id)
62  {
63  cmzn_nodeset_destroy(&id);
64  }
65  }
66 
72  bool isValid() const
73  {
74  return (0 != id);
75  }
76 
82  cmzn_nodeset_id getId() const
83  {
84  return id;
85  }
86 
94  inline NodesetGroup castGroup();
95 
102  bool containsNode(const Node& node)
103  {
104  return cmzn_nodeset_contains_node(id, node.getId());
105  }
106 
115  {
116  return Nodetemplate(cmzn_nodeset_create_nodetemplate(id));
117  }
118 
129  Node createNode(int identifier, const Nodetemplate& nodeTemplate)
130  {
131  return Node(cmzn_nodeset_create_node(id, identifier, nodeTemplate.getId()));
132  }
133 
145  {
146  return Nodeiterator(cmzn_nodeset_create_nodeiterator(id));
147  }
148 
159  {
160  return cmzn_nodeset_destroy_all_nodes(id);
161  }
162 
173  int destroyNode(const Node& node)
174  {
175  return cmzn_nodeset_destroy_node(id, node.getId());
176  }
177 
192  int destroyNodesConditional(const Field& conditionalField)
193  {
194  return cmzn_nodeset_destroy_nodes_conditional(id, conditionalField.getId());
195  }
196 
203  Node findNodeByIdentifier(int identifier)
204  {
205  return Node(cmzn_nodeset_find_node_by_identifier(id, identifier));
206  }
207 
213  inline Fieldmodule getFieldmodule() const;
214 
222  {
223  return Nodeset(cmzn_nodeset_get_master_nodeset(id));
224  }
225 
233  char *getName()
234  {
235  return cmzn_nodeset_get_name(id);
236  }
237 
243  int getSize()
244  {
245  return cmzn_nodeset_get_size(id);
246  }
247 
248 };
249 
250 inline bool operator==(const Nodeset& a, const Nodeset& b)
251 {
252  return cmzn_nodeset_match(a.getId(), b.getId());
253 }
254 
255 inline Nodeset Node::getNodeset() const
256 {
257  return Nodeset(cmzn_node_get_nodeset(id));
258 }
259 
265 class NodesetGroup : public Nodeset
266 {
267 
268 public:
269 
270  // takes ownership of C handle, responsibility for destroying it
271  explicit NodesetGroup(cmzn_nodeset_group_id nodeset_id) : Nodeset(reinterpret_cast<cmzn_nodeset_id>(nodeset_id))
272  { }
273 
274  NodesetGroup()
275  { }
276 
282  cmzn_nodeset_group_id getId() const
283  {
284  return (cmzn_nodeset_group_id)(id);
285  }
286 
295  int addNode(const Node& node)
296  {
297  return cmzn_nodeset_group_add_node(
298  reinterpret_cast<cmzn_nodeset_group_id>(id), node.getId());
299  }
300 
309  int addNodesConditional(const Field& conditionalField)
310  {
311  return cmzn_nodeset_group_add_nodes_conditional(
312  reinterpret_cast<cmzn_nodeset_group_id>(id), conditionalField.getId());
313  }
314 
321  {
322  return cmzn_nodeset_group_remove_all_nodes(
323  reinterpret_cast<cmzn_nodeset_group_id>(id));
324  }
325 
334  int removeNode(const Node& node)
335  {
336  return cmzn_nodeset_group_remove_node(reinterpret_cast<cmzn_nodeset_group_id>(id),
337  node.getId());
338  }
339 
349  int removeNodesConditional(const Field& conditionalField)
350  {
351  return cmzn_nodeset_group_remove_nodes_conditional(
352  reinterpret_cast<cmzn_nodeset_group_id>(id), conditionalField.getId());
353  }
354 
355 };
356 
358 {
359  return NodesetGroup(cmzn_nodeset_cast_group(id));
360 }
361 
368 {
369 private:
370 
371  cmzn_nodesetchanges_id id;
372 
373 public:
374 
375  Nodesetchanges() : id(0)
376  { }
377 
378  // takes ownership of C handle, responsibility for destroying it
379  explicit Nodesetchanges(cmzn_nodesetchanges_id nodesetchanges_id) :
380  id(nodesetchanges_id)
381  { }
382 
383  Nodesetchanges(const Nodesetchanges& nodesetchanges) :
384  id(cmzn_nodesetchanges_access(nodesetchanges.id))
385  { }
386 
387  Nodesetchanges& operator=(const Nodesetchanges& nodesetchanges)
388  {
389  cmzn_nodesetchanges_id temp_id = cmzn_nodesetchanges_access(nodesetchanges.id);
390  if (0 != id)
391  cmzn_nodesetchanges_destroy(&id);
392  id = temp_id;
393  return *this;
394  }
395 
396  ~Nodesetchanges()
397  {
398  if (0 != id)
399  cmzn_nodesetchanges_destroy(&id);
400  }
401 
407  bool isValid() const
408  {
409  return (0 != id);
410  }
411 
419  {
420  return cmzn_nodesetchanges_get_node_change_flags(id, node.getId());
421  }
422 
430  {
431  return cmzn_nodesetchanges_get_number_of_changes(id);
432  }
433 
440  {
441  return cmzn_nodesetchanges_get_summary_node_change_flags(id);
442  }
443 };
444 
445 } // namespace Zinc
446 }
447 
448 #endif // CMZN_NODESET_HPP__
An iterator for looping through all the nodes in a nodeset.
Definition: node.hpp:187
bool isValid() const
Definition: nodeset.hpp:407
Object describing changes to a nodeset in a fieldmoduleevent.
Definition: nodeset.hpp:367
bool isValid() const
Definition: nodeset.hpp:72
int addNode(const Node &node)
Definition: nodeset.hpp:295
cmzn_nodetemplate_id getId() const
Definition: nodetemplate.hpp:83
A description of field parameters to define at a node.
Definition: nodetemplate.hpp:29
int removeNode(const Node &node)
Definition: nodeset.hpp:334
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
int removeNodesConditional(const Field &conditionalField)
Definition: nodeset.hpp:349
Node::ChangeFlags getNodeChangeFlags(const Node &node)
Definition: nodeset.hpp:418
A subset of a master nodeset.
Definition: nodeset.hpp:265
cmzn_nodeset_id getId() const
Definition: nodeset.hpp:82
int destroyAllNodes()
Definition: nodeset.hpp:158
cmzn_nodeset_group_id getId() const
Definition: nodeset.hpp:282
NodesetGroup castGroup()
Definition: nodeset.hpp:357
Node::ChangeFlags getSummaryNodeChangeFlags()
Definition: nodeset.hpp:439
Node findNodeByIdentifier(int identifier)
Definition: nodeset.hpp:203
Nodetemplate createNodetemplate()
Definition: nodeset.hpp:114
cmzn_field_id getId() const
Definition: field.hpp:103
Nodeiterator createNodeiterator()
Definition: nodeset.hpp:144
int destroyNode(const Node &node)
Definition: nodeset.hpp:173
Nodeset getMasterNodeset()
Definition: nodeset.hpp:221
Nodeset getNodeset() const
Definition: nodeset.hpp:255
int getSize()
Definition: nodeset.hpp:243
char * getName()
Definition: nodeset.hpp:233
cmzn_node_id getId() const
Definition: node.hpp:136
int getNumberOfChanges()
Definition: nodeset.hpp:429
Container/manager of fields and domains within a region.
Definition: fieldmodule.hpp:135
Node createNode(int identifier, const Nodetemplate &nodeTemplate)
Definition: nodeset.hpp:129
int ChangeFlags
Definition: node.hpp:75
bool containsNode(const Node &node)
Definition: nodeset.hpp:102
The OpenCMISS namespace.
Definition: context.hpp:20
Point object used to represent finite element nodes.
Definition: node.hpp:34
int removeAllNodes()
Definition: nodeset.hpp:320
int destroyNodesConditional(const Field &conditionalField)
Definition: nodeset.hpp:192
int addNodesConditional(const Field &conditionalField)
Definition: nodeset.hpp:309
A set of nodes or points.
Definition: nodeset.hpp:29
Fieldmodule getFieldmodule() const
Definition: fieldmodule.hpp:1796