Geophysical Inversion and Modelling Library v1.5.4
Loading...
Searching...
No Matches
node.h
1/******************************************************************************
2 * Copyright (C) 2006-2024 by the GIMLi development team *
3 * Carsten Rücker carsten@resistivity.net *
4 * *
5 * Licensed under the Apache License, Version 2.0 (the "License"); *
6 * you may not use this file except in compliance with the License. *
7 * You may obtain a copy of the License at *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 * See the License for the specific language governing permissions and *
15 * limitations under the License. *
16 * *
17 ******************************************************************************/
18
19#ifndef _GIMLI_NODE__H
20#define _GIMLI_NODE__H
21
22#include "gimli.h"
23
24#include "baseentity.h"
25#include "pos.h"
26
27#include <set>
28
29namespace GIMLI{
30
31enum NodeState{No, Original, Secondary, Connected};
32
34
39class DLLEXPORT Node : public BaseEntity {
40
41public:
43 Node();
44
46 Node(double x, double y, double z=0.0);
47
49 Node(const RVector3 & pos);
50
52 Node(const RVector3 & pos, int marker, int id=-1);
53
55 Node(const Node & node);
56
58 Node & operator = (const Node & node);
59
61 ~Node();
62
64 inline double & operator [] (const Index i) { return this->at(i); }
65
67 inline const double & operator [] (const Index i) const { return this->at(i); }
68
69 inline uint rtti() const { return MESH_NODE_RTTI; }
70
71 inline void setPos(const RVector3 & pos) { changed_(); pos_ = pos; }
72
73 inline const RVector3 & pos() const { return pos_; }
74
76 inline RVector3 & pos() { return pos_; }
77
78 inline void insertBoundary(Boundary * bound){ boundSet_.insert(bound); }
79
80 inline void eraseBoundary(Boundary * bound){ boundSet_.erase(bound); }
81
82 inline void insertCell(Cell * cell){ cellSet_.insert(cell); }
83
84 inline void eraseCell(Cell * cell){ cellSet_.erase(cell); }
85
86 inline const std::set < Boundary * > & boundSet() const { return boundSet_; }
87
88 inline std::set < Boundary * > & boundSet() { return boundSet_; }
89
90 inline const std::set < Cell * > & cellSet() const { return cellSet_; }
91
92 inline std::set < Cell * > & cellSet() { return cellSet_; }
93
94 void transform(const RMatrix & mat);
95
96 inline void scale(const RVector3 & s) { changed_(); pos_.scale(s); }
97
98 inline void translate(const RVector3 & t) { changed_(); pos_.translate(t); }
99
100 inline void translate(double x, double y=0.0, double z=0.0) {
101 changed_(); pos_.translate(x, y, z); }
102
103 inline void rotate(const RVector3 & r) { changed_(); pos_.rotate(r); }
104
105 inline void swap(Index i, Index j) { changed_(); pos_.swap(i, j); }
106
107 inline const double & x() const { return pos_[0]; }
108
109 inline const double & y() const { return pos_[1]; }
110
111 inline const double & z() const { return pos_[2]; }
112
113 inline double & at(Index i) { return pos_[i]; }
114
115 inline const double & at(Index i) const { return pos_[i]; }
116
117 inline double dist(const Node & n) const { return pos_.dist(n.pos()); }
118
119
120 void smooth(uint function);
121
123 void setState(NodeState s) { this->_state = s; }
124
126 const NodeState state() const { return this->_state; }
127
128 void setSecondaryParent(MeshEntity * e) { this->_secondaryParent = e; }
130 MeshEntity * secondaryParent() { return this->_secondaryParent; }
131
132protected:
133
134 void copy_(const Node & node);
135
136 void changed_();
137
138 void init_();
139
140 RVector3 pos_;
141
142 std::set < Boundary * > boundSet_;
143 std::set < Cell * > cellSet_;
144
145 NodeState _state;
146 MeshEntity *_secondaryParent;
147}; // class Node
148
149DLLEXPORT std::ostream & operator << (std::ostream & str, const GIMLI::Node & node);
150
151DLLEXPORT std::ostream & operator << (std::ostream & str, const std::vector < GIMLI::Node * > & nodes);
152
153inline bool operator == (const Node & n1, const Node & n2) { return n1.pos() == n2.pos(); }
154
155} // namespace GIMLI
156
157#endif // _GIMLI_NODE__H
Definition meshentities.h:350
Definition meshentities.h:103
3D Node
Definition node.h:39
const NodeState state() const
Definition node.h:126
RVector3 & pos()
Definition node.h:76
Node()
Definition node.cpp:42
void setState(NodeState s)
Definition node.h:123
uint rtti() const
Definition node.h:69
MeshEntity * secondaryParent()
Definition node.h:130
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24
RVector y(const R3Vector &rv)
Definition pos.cpp:114
RVector x(const R3Vector &rv)
Definition pos.cpp:107
RVector z(const R3Vector &rv)
Definition pos.cpp:120