9 template<
typename DataTypeContainer,
typename TriangleType >
19 typedef typename DataTypeContainer::MaskType
MaskType;
30 : _vertexIterator(), _triangIterator()
44 return ( _vertexIterator.size() );
48 return ( static_cast<int> ( _triangIterator.size() ) );
54 _vertexIterator.push_back(newVertex);
62 _triangIterator.push_back (
TriangleType( globalIdx, nodeIdx, _vertexIterator ) );
68 return _vertexIterator[num];
70 void setVertex(
const int num,
const Point3DType Arg)
72 _vertexIterator[num] = Arg;
76 int getNeighbour(
const int elementID,
const int acrossLocalEdge)
const 78 return _neighbour_[elementID][acrossLocalEdge];
82 void setNeighbour(
const int elementID,
const int acrossLocalEdge,
const int value)
const 84 _neighbour_[elementID][acrossLocalEdge] = value;
89 return _triangIterator[num];
96 return _triangIterator[num];
101 _triangIterator[num] = Arg;
106 return _triangIterator[num].getGlobalNodeIdx(localNode);
111 _triangIterator[num].setGlobalNodeIdx(localNode, newIdx );
117 for (
int elementIndex = 0; elementIndex <
getNumTriangs(); ++elementIndex ) _triangIterator[elementIndex].updateNodesAndEdges( _vertexIterator );
122 for (
int nodeIndex = 0; nodeIndex <
getNumVertices(); ++nodeIndex ) {
123 cout << endl <<
"node = " << nodeIndex << endl;
125 for (
int elementIndex = 0; elementIndex <
getNumTriangs(); ++elementIndex ) _triangIterator[elementIndex].
print();
134 std::ifstream vtkFile;
135 vtkFile.open ( filename.c_str() );
136 if ( vtkFile.fail() )
throw std::invalid_argument(
aol::strprintf (
"Cannot open file. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
137 bool readVertices =
false;
138 bool readFaces =
false;
139 while ( !vtkFile.eof() ) {
141 vtkFile.getline ( line, 256 );
143 if( !strncmp ( line,
"POINTS ", strlen (
"POINTS " ) ) ) {
148 if( !strncmp ( line,
"POLYGONS ", strlen (
"POLYGONS " ) ) ) {
149 readVertices =
false;
154 if( readFaces && strncmp ( line,
"3 ", strlen (
"3 " ) ) )
break;
158 char * substring = strtok ( line,
" " );
159 for (
int i = 0; i < 3; i++ ) {
160 vertex[i] = atof( substring );
161 substring = strtok (NULL,
" ");
167 Indices3DType triangle;
168 char * substring = strtok ( line,
" " );
169 for (
int i = 0; i < 3; i++ ) {
170 substring = strtok (NULL,
" ");
171 triangle[i] = atof( substring );
182 int *n_to_t, *num_of_n, *start_of_n;
186 if (
int(_neighbour_.size()) != numElements ) _neighbour_.resize ( numElements );
188 n_to_t =
new int[numElements*3];
189 num_of_n =
new int[numNodes];
190 start_of_n =
new int[numNodes+1];
193 for (
int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++ ) num_of_n[nodeIndex] = 0;
196 for (
int elementIndex = 0; elementIndex < numElements; elementIndex++ )
197 for (
int j = 0; j < 3; j++ ) {
204 start_of_n[nodeIdx++] = 0;
205 while ( nodeIdx < numNodes ) {
206 start_of_n[nodeIdx] = start_of_n[nodeIdx-1] + num_of_n[nodeIdx-1];
209 start_of_n[numNodes] = 3 * numElements;
212 for (
int elementIndex = 0; elementIndex < numElements*3; ++elementIndex ) n_to_t[elementIndex] = -1;
215 for (
int elementIndex = 0; elementIndex < numElements; elementIndex++ )
216 for (
int j = 0; j < 3; j++ ) {
218 while ( n_to_t[k] > -1 ) k++;
219 n_to_t[k] = elementIndex;
222 for (
int elementIndex = 0; elementIndex < numElements; elementIndex++ )
223 for (
int j = 0; j < 3; j++ ) {
228 for (
int k = start_of_n[node1]; k < start_of_n[node1+1]; k++ ) {
230 if ( elementIndex < n )
231 for (
int l = 0; l < 3; l++ ) {
234 for (
int v = 0; v < 3; v++ )
239 for (
int v = 0; v < 3; v++ )
261 std::queue<int> activeTriangles;
262 activeTriangles.push( 0 );
267 while( !activeTriangles.empty() ) {
268 currentTriangle = activeTriangles.front();
269 activeTriangles.pop();
271 for (
int i = 0; i < 3; i++ ) {
273 if ( neighbor >= 0 && neighbor < this->
getNumTriangs() && !alreadyHandled[neighbor] ) {
287 exchangeCache =
getNeighbour( neighbor, ( j + 1 ) % 3 );
291 if ( !inQueue[neighbor] ) {
292 activeTriangles.push( neighbor );
293 inQueue[neighbor] =
true;
297 alreadyHandled[currentTriangle] =
true;
void updateAllTriangles()
void makeNeighbour() const
const TriangleType & getTriang(const int num) const
const Point3DType & getVertex(const int num) const
std::vector< TriangleType > _triangIterator
DataTypeContainer::MaskType MaskType
DataTypeContainer::Indices3DType Indices3DType
int pushBackTriang(const Indices3DType nodeIdx)
Insert new triangle and return global index.
int getNumVertices() const
int getNeighbour(const int elementID, const int acrossLocalEdge) const
Get neighbor on edge.
void loadFromLegacyVTK(const string &filename)
load from file in the .vtk file format. Currently only loads geometric information.
std::vector< Point3DType > _vertexIterator
int getNumTriangs() const
void setTriangNodeIdx(const int num, const int localNode, const int newIdx)
TriangleType & getTriang(const int num)
Returns a triangle.
int pushBackVertex(const Point3DType newVertex)
Insert new vertex and return global index.
DataTypeContainer::VectorType VectorType
shellFE::ShellElementWithTangentSpaceAtVertex< DataTypeContainerShellFE > TriangleType
void setTriang(const int num, const TriangleType Arg)
int getTriangNodeIdx(const int num, const int localNode) const
TriangMesh(const string &fileName)
void setNeighbour(const int elementID, const int acrossLocalEdge, const int value) const
Set neighbor on edge.
TriangMesh()
Create empty TriangMesh.
string strprintf(const char *format,...)
Give back formatted string, analogously to sprintf, but save the long way 'round with char arrays...
DataTypeContainer::TangentVecType TangentVecType
void makeOrientationConsistent()
ConfiguratorType::VectorType VectorType
void setVertex(const int num, const Point3DType Arg)
DataTypeContainer::RealType RealType
std::vector< Indices3DType > _neighbour_
Triangle which has a tangent space at each node.
DataTypeContainer::Point3DType Point3DType