| 74 | } |
| 75 | |
| 76 | Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) { |
| 77 | // flags == 0 basis |
| 78 | // flags == 1 Powell-Sabin refinend |
| 79 | |
| 80 | assert(pTh); |
| 81 | bool PowellSabin = flags ==1; |
| 82 | if(verbosity>1) |
| 83 | cout << "SplitMesh6New "<<flags <<endl; |
| 84 | const Mesh &Th(*pTh); // le maillage d'origne a decoupe |
| 85 | using Fem2D::BoundaryEdge; |
| 86 | using Fem2D::Mesh; |
| 87 | using Fem2D::R2; |
| 88 | using Fem2D::Triangle; |
| 89 | using Fem2D::Vertex; |
| 90 | int nbv = Th.nv; // nombre de sommet |
| 91 | int nbt = Th.nt; // nombre de triangles |
| 92 | int neb = Th.neb; // nombre d'aretes fontiere |
| 93 | // allocation des nouveaux items du maillage |
| 94 | int nbe = 0; |
| 95 | |
| 96 | for (int k = 0; k < nbt; ++k) { |
| 97 | for (int e = 0; e < 3; ++e) { |
| 98 | int ee = e; |
| 99 | int kk = Th.ElementAdj(k, ee); |
| 100 | if (kk <= k) { |
| 101 | nbe++; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | Vertex *v = new Vertex[nbv + nbt + nbe]; |
| 107 | Triangle *t = new Triangle[nbt * 6]; |
| 108 | BoundaryEdge *b = new BoundaryEdge[neb * 2]; |
| 109 | // generation des nouveaus sommets |
| 110 | Vertex *vv = v; |
| 111 | KN< int > mm(3 * nbt); |
| 112 | |
| 113 | // copie des anciens sommets (remarque il n'y a pas operateur de copy des sommets) |
| 114 | for (int i = 0; i < nbv; i++) { |
| 115 | Vertex &V = Th(i); |
| 116 | vv->x = V.x; |
| 117 | vv->y = V.y; |
| 118 | vv->lab = V.lab; |
| 119 | vv++; |
| 120 | } |
| 121 | |
| 122 | // generation des points barycentre de trianngles o c |
| 123 | for (int k = 0; k < nbt; k++) { |
| 124 | Triangle &K = Th[k]; |
| 125 | R2 G; |
| 126 | if(PowellSabin) |
| 127 | G = incircleCenter(K[0] ,K[1] ,K[2] ); |
| 128 | else |
| 129 | G = ((R2)K[0] + K[1] + K[2]) / 3.; |
| 130 | vv->x = G.x; |
| 131 | vv->y = G.y; |
| 132 | vv->lab = 0; |
| 133 | vv++; |
no test coverage detected