OpenCMISS-Zinc C++ API Documentation
elementtemplate.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_ELEMENTTEMPLATE_HPP__
11 #define CMZN_ELEMENTTEMPLATE_HPP__
12 
13 #include "opencmiss/zinc/elementtemplate.h"
14 #include "opencmiss/zinc/element.hpp"
15 #include "opencmiss/zinc/elementfieldtemplate.hpp"
16 #include "opencmiss/zinc/field.hpp"
17 #include "opencmiss/zinc/node.hpp"
18 
19 namespace OpenCMISS
20 {
21 namespace Zinc
22 {
23 
32 {
33 private:
34 
35  cmzn_elementtemplate_id id;
36 
37 public:
38 
39  Elementtemplate() : id(0)
40  { }
41 
42  // takes ownership of C handle, responsibility for destroying it
43  explicit Elementtemplate(cmzn_elementtemplate_id element_template_id) :
44  id(element_template_id)
45  { }
46 
47  Elementtemplate(const Elementtemplate& elementTemplate) :
48  id(cmzn_elementtemplate_access(elementTemplate.id))
49  { }
50 
51  Elementtemplate& operator=(const Elementtemplate& elementTemplate)
52  {
53  cmzn_elementtemplate_id temp_id = cmzn_elementtemplate_access(elementTemplate.id);
54  if (0 != id)
55  {
56  cmzn_elementtemplate_destroy(&id);
57  }
58  id = temp_id;
59  return *this;
60  }
61 
63  {
64  if (0 != id)
65  {
66  cmzn_elementtemplate_destroy(&id);
67  }
68  }
69 
75  bool isValid() const
76  {
77  return (0 != id);
78  }
79 
85  cmzn_elementtemplate_id getId() const
86  {
87  return id;
88  }
89 
96  {
97  return static_cast<Element::ShapeType>(cmzn_elementtemplate_get_element_shape_type(id));
98  }
99 
111  {
112  return cmzn_elementtemplate_set_element_shape_type(id,
113  static_cast<cmzn_element_shape_type>(shapeType));
114  }
115 
122  {
123  return cmzn_elementtemplate_get_number_of_nodes(id);
124  }
125 
135  int setNumberOfNodes(int numberOfNodes)
136  {
137  return cmzn_elementtemplate_set_number_of_nodes(id, numberOfNodes);
138  }
139 
152  int defineField(const Field& field, int componentNumber, const Elementfieldtemplate& eft)
153  {
154  return cmzn_elementtemplate_define_field(this->id, field.getId(),
155  componentNumber, eft.getId());
156  }
157 
170  int defineFieldElementConstant(const Field& field, int componentNumber)
171  {
172  return cmzn_elementtemplate_define_field_element_constant(
173  id, field.getId(), componentNumber);
174  }
175 
204  int defineFieldSimpleNodal(const Field& field, int componentNumber,
205  const Elementbasis& basis, int nodeIndexesCount, const int *nodeIndexesIn)
206  {
207  return cmzn_elementtemplate_define_field_simple_nodal(
208  id, field.getId(), componentNumber, basis.getId(),
209  nodeIndexesCount, nodeIndexesIn);
210  }
211 
232  int setMapNodeValueLabel(const Field& field, int componentNumber,
233  int basisNodeIndex, int nodeFunctionIndex, Node::ValueLabel nodeValueLabel)
234  {
235  return cmzn_elementtemplate_set_map_node_value_label(id, field.getId(),
236  componentNumber, basisNodeIndex, nodeFunctionIndex,
237  static_cast<cmzn_node_value_label>(nodeValueLabel));
238  }
239 
260  int setMapNodeVersion(const Field& field, int componentNumber,
261  int basisNodeIndex, int nodeFunctionIndex, int versionNumber)
262  {
263  return cmzn_elementtemplate_set_map_node_version(id, field.getId(),
264  componentNumber, basisNodeIndex, nodeFunctionIndex, versionNumber);
265  }
266 
274  Node getNode(int localNodeIndex)
275  {
276  return Node(cmzn_elementtemplate_get_node(id, localNodeIndex));
277  }
278 
288  int setNode(int localNodeIndex, const Node& node)
289  {
290  return cmzn_elementtemplate_set_node(id, localNodeIndex, node.getId());
291  }
292 
299  int removeField(const Field& field)
300  {
301  return cmzn_elementtemplate_remove_field(this->id, field.getId());
302  }
303 
312  int undefineField(const Field& field)
313  {
314  return cmzn_elementtemplate_undefine_field(this->id, field.getId());
315  }
316 };
317 
318 inline int Element::merge(const Elementtemplate& elementTemplate)
319 {
320  return cmzn_element_merge(id, elementTemplate.getId());
321 }
322 
323 } // namespace Zinc
324 }
325 
326 #endif /* CMZN_ELEMENTTEMPLATE_HPP__ */
int removeField(const Field &field)
Definition: elementtemplate.hpp:299
int setElementShapeType(enum Element::ShapeType shapeType)
Definition: elementtemplate.hpp:110
ValueLabel
Definition: node.hpp:80
A set of basis functions that can apply over an element of a given dimension.
Definition: elementbasis.hpp:28
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:51
ShapeType
Definition: element.hpp:137
int setNumberOfNodes(int numberOfNodes)
Definition: elementtemplate.hpp:135
Node getNode(int localNodeIndex)
Definition: elementtemplate.hpp:274
int undefineField(const Field &field)
Definition: elementtemplate.hpp:312
int setMapNodeVersion(const Field &field, int componentNumber, int basisNodeIndex, int nodeFunctionIndex, int versionNumber)
Definition: elementtemplate.hpp:260
int defineField(const Field &field, int componentNumber, const Elementfieldtemplate &eft)
Definition: elementtemplate.hpp:152
bool isValid() const
Definition: elementtemplate.hpp:75
int defineFieldSimpleNodal(const Field &field, int componentNumber, const Elementbasis &basis, int nodeIndexesCount, const int *nodeIndexesIn)
Definition: elementtemplate.hpp:204
cmzn_field_id getId() const
Definition: field.hpp:103
A description of element shape and field definitions.
Definition: elementtemplate.hpp:31
int defineFieldElementConstant(const Field &field, int componentNumber)
Definition: elementtemplate.hpp:170
cmzn_node_id getId() const
Definition: node.hpp:136
int getNumberOfNodes()
Definition: elementtemplate.hpp:121
cmzn_elementbasis_id getId() const
Definition: elementbasis.hpp:122
cmzn_elementtemplate_id getId() const
Definition: elementtemplate.hpp:85
int setNode(int localNodeIndex, const Node &node)
Definition: elementtemplate.hpp:288
enum Element::ShapeType getElementShapeType()
Definition: elementtemplate.hpp:95
int setMapNodeValueLabel(const Field &field, int componentNumber, int basisNodeIndex, int nodeFunctionIndex, Node::ValueLabel nodeValueLabel)
Definition: elementtemplate.hpp:232
The OpenCMISS namespace.
Definition: context.hpp:20
Point object used to represent finite element nodes.
Definition: node.hpp:34
int merge(const Elementtemplate &elementTemplate)
Definition: elementtemplate.hpp:318
cmzn_elementfieldtemplate_id getId() const
Definition: elementfieldtemplate.hpp:132
A template defining field parameter mapping and interpolation over an element chart.
Definition: elementfieldtemplate.hpp:39