KASKADE 7 development version
cuboid.hh
Go to the documentation of this file.
1#include "cube.hh"
2
3class cuboid{
4
5public:
6 std::vector<Dune::FieldVector<double, 3> > vertices;
7 std::vector<std::vector< unsigned int> > tetraeder;
8
9 //creates a standart cube with weidth 1, depth 1 and heigth 1
11 cube cube1;
12 this->vertices=cube1.getVertices();
13 this->tetraeder=cube1.getTetraeder();
14 }
15
16 //creates a cuboid with weidth x , depth y and heigth 1
17 cuboid(int x, int y, int z){
18 std::vector<cube> cubes;
19 for(int i=0; i<x; i++){
20 for(int j=0; j<y; j++){
21 for(int k=0; k<z; k++){
22 cube cube1(i,j,k); cubes.push_back(cube1);
23 }
24 }
25 }
26 createCuboid(cubes);
27
28 }
29
30 //creates a cuboid with an given vector of qubes
31 //vertices that are twice or more will be deleted and the tedrader will be updated
32 void createCuboid(std::vector<cube> cubes){
33 std::vector<Dune::FieldVector<double,3> > verts;
34 std::vector<std::vector<unsigned int> > tet;
35 std::vector<unsigned int> new_ind;
38 std::vector<int> toerase;
39 std::vector<bool> erased(verts.size(),false);
40
41
42 for(int k=0;k<cubes.size();k++){
43 for(int i=0;i<9;i++){
44 verts.push_back(cubes[k].getVertices()[i]);
45 new_ind.push_back(k*9+i);
46 }
47 for(int i=0;i<12;i++){
48 for(int j=0;j<4;j++){
49 cubes[k].getTetraeder()[i][j]+=k*9;
50 }
51 tet.push_back(cubes[k].getTetraeder()[i]);
52 }
53 }
54
55 for(unsigned int i=0;i<verts.size();i++){
56 totest=verts[i];
57 for(unsigned int j=i+1;j<verts.size();j++){
58 sub=totest-verts[j];
59 if(sub.two_norm()<pow(10,-12) && !erased[j]){
60 erased[j]=true;
61 new_ind[j]=new_ind[i];
62 for(int l=j+1;l<new_ind.size();l++){
63 if(new_ind[l]>new_ind[j]) new_ind[l]-=1;
64 }
65 toerase.push_back(j);
66 }
67 }
68 }
69
70 for(int k=0;k<tet.size();k++){
71 for(int l=0;l<4;l++){
72 tet[k][l]=new_ind[tet[k][l]];
73 }
74 }
75 sort(toerase.begin(),toerase.end());
76 for(int k=toerase.size()-1;k>=0;k--){
77 verts.erase(verts.begin()+toerase[k]);
78 }
79
80 this->vertices=verts;
81 this->tetraeder=tet;
82 }
83
84
85 std::vector<Dune::FieldVector<double,3> >& getVerts(){return this->vertices;}
86 std::vector<std::vector<unsigned int> >& getTets(){return this->tetraeder;}
87
88
89 /*std::vector<Dune::FieldVector<double,3> > deldouble(std::vector<Dune::FieldVector<double,3> > tosort){
90 std::vector<int> toerase;
91 std::vector<bool> erased(tosort.size(),false);
92 for(int i=0; i<tosort.size();i++){
93 for(int j=i+1;j<tosort.size();j++){
94 if(tosort[i]==tosort[j] && !erased[j]){
95 erased[j]=true;
96 toerase.push_back(j);
97 }
98 }
99 }
100 for(int k=toerase.size()-1;k>=0;k--){
101 tosort.erase(tosort.begin()+toerase[k]);
102 }
103 return tosort;
104 }*/
105
106};
Definition: cuboid.hh:3
void createCuboid(std::vector< cube > cubes)
Definition: cuboid.hh:32
std::vector< std::vector< unsigned int > > & getTets()
Definition: cuboid.hh:86
cuboid(int x, int y, int z)
Definition: cuboid.hh:17
std::vector< Dune::FieldVector< double, 3 > > vertices
Definition: cuboid.hh:6
std::vector< std::vector< unsigned int > > tetraeder
Definition: cuboid.hh:7
std::vector< Dune::FieldVector< double, 3 > > & getVerts()
Definition: cuboid.hh:85
cuboid()
Definition: cuboid.hh:10