00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "VertexElement.hpp"
00036 #include <cassert>
00037
00038
00039 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00040 VertexElement<ELEMENT_DIM, SPACE_DIM>::VertexElement(unsigned index,
00041 const std::vector<VertexElement<ELEMENT_DIM-1,SPACE_DIM>*>& rFaces,
00042 const std::vector<bool>& rOrientations,
00043 const std::vector<Node<SPACE_DIM>*>& rNodes)
00044 : MutableElement<ELEMENT_DIM, SPACE_DIM>(index, rNodes),
00045 mFaces(rFaces),
00046 mOrientations(rOrientations)
00047 {
00048
00049 assert(SPACE_DIM == 3);
00050
00051
00052 assert(mFaces.size() == mOrientations.size());
00053
00054 if (SPACE_DIM == ELEMENT_DIM)
00055 {
00056
00057 this->RegisterWithNodes();
00058 }
00059 }
00060
00061 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00062 VertexElement<ELEMENT_DIM, SPACE_DIM>::VertexElement(unsigned index,
00063 const std::vector<VertexElement<ELEMENT_DIM-1,SPACE_DIM>*>& rFaces,
00064 const std::vector<bool>& rOrientations)
00065 : MutableElement<ELEMENT_DIM, SPACE_DIM>(index),
00066 mFaces(rFaces),
00067 mOrientations(rOrientations)
00068 {
00069
00070 assert(mFaces.size() == mOrientations.size());
00071
00072
00073 std::set<Node<SPACE_DIM>* > nodes_set;
00074 for (unsigned face_index=0; face_index<mFaces.size(); face_index++)
00075 {
00076 for (unsigned node_index=0; node_index<mFaces[face_index]->GetNumNodes(); node_index++)
00077 {
00078 nodes_set.insert(mFaces[face_index]->GetNode(node_index));
00079 }
00080 }
00081
00082
00083 for (typename std::set< Node<SPACE_DIM>* >::iterator node_iter = nodes_set.begin();
00084 node_iter != nodes_set.end();
00085 ++node_iter)
00086 {
00087 this->mNodes.push_back(*node_iter);
00088 }
00089
00090
00091 this->RegisterWithNodes();
00092 }
00093
00094 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00095 VertexElement<ELEMENT_DIM, SPACE_DIM>::VertexElement(unsigned index)
00096 : MutableElement<ELEMENT_DIM, SPACE_DIM>(index)
00097 {
00098 }
00099
00100 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00101 VertexElement<ELEMENT_DIM, SPACE_DIM>::VertexElement(unsigned index,
00102 const std::vector<Node<SPACE_DIM>*>& rNodes)
00103 : MutableElement<ELEMENT_DIM, SPACE_DIM>(index, rNodes)
00104 {
00105 }
00106
00107 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00108 VertexElement<ELEMENT_DIM, SPACE_DIM>::~VertexElement()
00109 {
00110 }
00111
00112 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00113 unsigned VertexElement<ELEMENT_DIM, SPACE_DIM>::GetNumFaces() const
00114 {
00115 return mFaces.size();
00116 }
00117
00118 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00119 void VertexElement<ELEMENT_DIM, SPACE_DIM>::AddFace(VertexElement<ELEMENT_DIM-1,SPACE_DIM>* pFace)
00120 {
00121
00122 this->mFaces.push_back(pFace);
00123
00124
00125 std::set<unsigned> node_indices;
00126 for (unsigned local_index=0; local_index<this->GetNumNodes(); local_index++)
00127 {
00128 node_indices.insert(this->GetNodeGlobalIndex(local_index));
00129 }
00130
00131
00132 unsigned end_index = this->GetNumNodes()-1;
00133 for (unsigned local_index=0; local_index<pFace->GetNumNodes(); local_index++)
00134 {
00135
00136 unsigned global_index = pFace->GetNodeGlobalIndex(local_index);
00137 if (node_indices.find(global_index) == node_indices.end())
00138 {
00139
00140 this->AddNode(pFace->GetNode(local_index), end_index);
00141 end_index++;
00142 }
00143 }
00144 }
00145
00146 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00147 VertexElement<ELEMENT_DIM-1, SPACE_DIM>* VertexElement<ELEMENT_DIM, SPACE_DIM>::GetFace(unsigned index) const
00148 {
00149 assert(index < mFaces.size());
00150 return mFaces[index];
00151 }
00152
00153 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00154 bool VertexElement<ELEMENT_DIM, SPACE_DIM>::FaceIsOrientatedClockwise(unsigned index) const
00155 {
00156 assert(index < mOrientations.size());
00157 return mOrientations[index];
00158 }
00159
00161
00162
00163
00165
00170 template<unsigned SPACE_DIM>
00171 VertexElement<1, SPACE_DIM>::VertexElement(unsigned index, const std::vector<Node<SPACE_DIM>*>& rNodes)
00172 : MutableElement<1, SPACE_DIM>(index, rNodes)
00173 {
00174 }
00175
00176 template<unsigned SPACE_DIM>
00177 unsigned VertexElement<1, SPACE_DIM>::GetNumFaces() const
00178 {
00179 return 0;
00180 }
00181
00182 template<unsigned SPACE_DIM>
00183 VertexElement<0, SPACE_DIM>* VertexElement<1, SPACE_DIM>::GetFace(unsigned index) const
00184 {
00185 return NULL;
00186 }
00187
00188 template<unsigned SPACE_DIM>
00189 bool VertexElement<1, SPACE_DIM>::FaceIsOrientatedClockwise(unsigned index) const
00190 {
00191 return false;
00192 }
00193
00194
00196
00198
00199 template class VertexElement<1,1>;
00200 template class VertexElement<1,2>;
00201 template class VertexElement<1,3>;
00202 template class VertexElement<2,2>;
00203 template class VertexElement<2,3>;
00204 template class VertexElement<3,3>;