G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsFace.h
Go to the documentation of this file.
1
14#pragma once
15
18
19
20namespace gismo
21{
22
23template <class T>
24class gsFace : public gsMeshElement<T>
25{
26public:
28 typedef memory::shared_ptr< gsFace > Ptr;
29
31 typedef memory::unique_ptr< gsFace > uPtr;
32
33 typedef gsMeshElement<T> MeshElement;
34 typedef typename MeshElement::scalar_t scalar_t;
35 typedef typename MeshElement::gsVertexHandle gsVertexHandle;
36 typedef typename MeshElement::gsEdgeHandle gsEdgeHandle;
37 typedef typename MeshElement::gsFaceHandle gsFaceHandle;
38
39public:
40 gsFace() : MeshElement() { }
41
42 virtual ~gsFace() { }
43
44 gsFace(std::vector<gsVertexHandle> const & vert ) : MeshElement()
45 {
46 vertices = vert;
47 for ( typename std::vector<gsVertexHandle>::iterator
48 it = vertices.begin(); it!= vertices.end(); ++it)
49 (*it)->addFace(this);
50 }
51
52 gsFaceHandle handle() { return static_cast<gsFaceHandle>(this); }
53
54 gsFace(gsVertexHandle const & v0, gsVertexHandle const & v1, gsVertexHandle const & v2) : MeshElement()
55 {
56 vertices.push_back(v0);
57 vertices.push_back(v1);
58 vertices.push_back(v2);
59 v0->addFace(this);
60 v1->addFace(this);
61 v2->addFace(this);
62 }
63
64 gsFace(gsVertexHandle const & v0, gsVertexHandle const & v1, gsVertexHandle const & v2, gsVertexHandle const & v3) : MeshElement()
65 {
66 vertices.push_back(v0);
67 vertices.push_back(v1);
68 vertices.push_back(v2);
69 vertices.push_back(v3);
70 v0->addFace( handle() );
71 v1->addFace(this);
72 v2->addFace(this);
73 v3->addFace(this);
74 }
75
76 // clone function
77 //GISMO_CLONE_FUNCTION(gsFace)
78 uPtr clone() const { return uPtr(new gsFace(*this)); }
79
80 bool operator< (gsFace const & rhs) const
81 {
82 return ( Xless<T>(this->vertices[0],rhs.vertices[0])||
83 ( (this->vertices[0]->x() == rhs.vertices[0]->x() &&
84 this->vertices[0]->y() == rhs.vertices[0]->y() &&
85 this->vertices[0]->z() == rhs.vertices[0]->z() ) &&
86 Xless<T>(this->vertices[1],rhs.vertices[1]) )||
87 ( (this->vertices[0]->x() == rhs.vertices[0]->x() &&
88 this->vertices[0]->y() == rhs.vertices[0]->y() &&
89 this->vertices[0]->z() == rhs.vertices[0]->z() &&
90 this->vertices[1]->x() == rhs.vertices[1]->x() &&
91 this->vertices[1]->y() == rhs.vertices[1]->y() &&
92 this->vertices[1]->z() == rhs.vertices[1]->z() ) &&
93 Xless<T>(this->vertices[2],rhs.vertices[2]) ) );
94 }
95 bool operator == (gsFace const & rhs) const
96 {
97 return(
98 this->vertices[0]->x() == rhs.vertices[0]->x() &&
99 this->vertices[0]->y() == rhs.vertices[0]->y() &&
100 this->vertices[0]->z() == rhs.vertices[0]->z() &&
101 this->vertices[1]->x() == rhs.vertices[1]->x() &&
102 this->vertices[1]->y() == rhs.vertices[1]->y() &&
103 this->vertices[1]->z() == rhs.vertices[1]->z() &&
104 this->vertices[2]->x() == rhs.vertices[2]->x() &&
105 this->vertices[2]->y() == rhs.vertices[2]->y() &&
106 this->vertices[2]->z() == rhs.vertices[2]->z() );
107 }
108 bool operator != (gsFace const & rhs)const
109 {
110 return !(*this==rhs);
111 }
112 inline void addVertex(gsVertexHandle const & v)
113 {
114 vertices.push_back( v );
115 v->addFace(this);
116 return v;
117 }
118
119 void move(scalar_t const& dx, scalar_t const& dy, scalar_t const& dz)
120 {
121 //for ( typename
122 //it->move(dx,dy,dz)
123 }
124
125 std::ostream &print(std::ostream &os) const
126 {
127 os<<"gsFace: ";
128 for ( typename std::vector<gsVertexHandle>::const_iterator
129 it = vertices.begin(); it!= vertices.end(); ++it)
130 os<< (*it)->getId()<<" ";
131 os<<"\n";
132 return os;
133 }
134
135
136 gsVector3d<T> orthogonalVector()
137 {
138 gsVector3d<T> result;
139 gsVector3d<T> lhs(((*vertices[1]).x()-(*vertices[0]).x()),
140 ((*vertices[1]).y()-(*vertices[0]).y()),
141 ((*vertices[1]).z()-(*vertices[0]).z()));
142 gsVector3d<T> rhs(((*vertices[2]).x()-(*vertices[0]).x()),
143 ((*vertices[2]).y()-(*vertices[0]).y()),
144 ((*vertices[2]).z()-(*vertices[0]).z()));
145 result = rhs.cross(lhs);
146 return result;
147 }
148
149public:
150
151 //List of vetrices on this face
152 std::vector<gsVertexHandle> vertices;
153 std::vector<gsFaceHandle> nFaces;
154 std::vector<gsEdgeHandle> nEdges;
155 int faceIdentity;
156};
157
158} // namespace gismo
159
160
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides gsMeshElement class - a vertex, edge, face or cell of a gsMesh.
The G+Smo namespace, containing all definitions for the library.