00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "MeshCut_Utils.hxx"
00023 #include "MeshCut_Maillage.hxx"
00024
00025 #include "MeshCut_Carre.hxx"
00026 #include "MeshCut_Cube.hxx"
00027
00028 #include "MeshCut_Fonctions.hxx"
00029 #include "MeshCut_Cas.hxx"
00030
00031 #include "MeshCut_Globals.hxx"
00032
00033 #include <iostream>
00034 #include <cmath>
00035 #include <cstdlib>
00036 #include <cstring>
00037
00038 using namespace MESHCUT;
00039 using namespace std;
00040
00041
00042
00043 std::map<std::string, int> MESHCUT::intersections;
00044
00045 int MESHCUT::indexNouvellesMailles, MESHCUT::indexNouveauxNoeuds, MESHCUT::offsetMailles;
00046 std::string MESHCUT::str_id_GMplus, MESHCUT::str_id_GMmoins;
00047 Maillage *MESHCUT::MAILLAGE1, *MESHCUT::MAILLAGE2;
00048
00049 std::vector<float> MESHCUT::newXX, MESHCUT::newYY, MESHCUT::newZZ;
00050 std::map<TYPE_MAILLE, std::vector<int> > MESHCUT::newCNX;
00051 std::map<TYPE_MAILLE, int> MESHCUT::cptNouvellesMailles;
00052 std::map<TYPE_MAILLE, std::vector<int> > MESHCUT::GMplus, MESHCUT::GMmoins;
00053 std::vector<int> MESHCUT::cutTetras;
00054
00055 float *MESHCUT::DNP;
00056 int *MESHCUT::POSN;
00057
00058 std::string MESHCUT::str_id_maillagenew;
00059
00060 float MESHCUT::normale[3], MESHCUT::pointPlan[3];
00061 float MESHCUT::d;
00062 float MESHCUT::epsilon;
00063
00064 bool MESHCUT::debug;
00065 int MESHCUT::Naretes;
00066
00067
00068
00069 int main(int argc, char *argv[])
00070 {
00071
00072 debug = false;
00073 string ficMEDin;
00074 string ficMEDout;
00075 float xNormal;
00076 float yNormal;
00077 float zNormal;
00078 float xm;
00079 float ym;
00080 float zm;
00081 float tolerance;
00082 try
00083 {
00084 if (argc != 13)
00085 throw std::exception();
00086 char *ficMEDin0 = argv[1];
00087 ficMEDin = (string) ficMEDin0;
00088 char *ficMEDout0 = argv[2];
00089 ficMEDout = (string) ficMEDout0;
00090 char *id_maillagenew = argv[3];
00091 str_id_maillagenew = (string) id_maillagenew;
00092
00093
00094 char *id_GMplus = argv[4];
00095 str_id_GMplus = (string) id_GMplus;
00096 char *id_GMmoins = argv[5];
00097 str_id_GMmoins = (string) id_GMmoins;
00098
00099
00100 char *charxn = argv[6];
00101 xNormal = char2float(charxn);
00102 char *charyn = argv[7];
00103 yNormal = char2float(charyn);
00104 char *charzn = argv[8];
00105 zNormal = char2float(charzn);
00106
00107
00108 char *charxm = argv[9];
00109 xm = char2float(charxm);
00110 char *charym = argv[10];
00111 ym = char2float(charym);
00112 char *charzm = argv[11];
00113 zm = char2float(charzm);
00114
00115
00116 char *chtolerance = argv[12];
00117 tolerance = char2float(chtolerance);
00118 }
00119 catch (...)
00120 {
00121 cout << endl;
00122 cout << " Cut a tetrahedron mesh by a plane" << endl;
00123 cout << " ---------------------------------" << endl;
00124 cout << "Syntax:" << endl << endl;
00125 cout << argv[0] << " input.med output.med resuMeshName aboveGroup belowGroup nx ny nz px py pz T " << endl;
00126 cout << endl << "where:" << endl;
00127 cout << " input.med = name of the original mesh file in med format" << endl;
00128 cout << " output.med = name of the result mesh file in med format" << endl;
00129 cout << " resuMeshName = name of the result mesh" << endl;
00130 cout << " aboveGroup = name of the group of volumes above the cut plane" << endl;
00131 cout << " belowGroups = name of the group of volumes below the cut plane" << endl;
00132 cout << " nx ny nz = vector normal to the cut plane" << endl;
00133 cout << " px py pz = a point of the cut plane" << endl;
00134 cout << " T = 0 < T < 1 : vertices of a tetrahedron are considered as belonging" << endl;
00135 cout << " the cut plane if their distance to the plane is inferior to L*T" << endl;
00136 cout << " where L is the mean edge size of the tetrahedron" << endl;
00137 ERREUR("--> check arguments!");
00138 }
00139
00140 cout << "Cut by a plane :" << endl;
00141 cout << " source mesh: " << ficMEDin << endl;
00142 cout << " result mesh: " << ficMEDout << endl;
00143 cout << " mesh name: " << str_id_maillagenew << endl;
00144 cout << " group above plane: " << str_id_GMplus << endl;
00145 cout << " group below plane: " << str_id_GMmoins << endl;
00146 cout << " vector normal to the cut plane: xn=" << xNormal << " yn=" << yNormal << " zn=" << zNormal << endl;
00147 cout << " point in the cut plane: xm=" << xm << " ym=" << ym << " zm=" << zm << endl;
00148 cout << " tolerance: " << tolerance << endl;
00149 cout << endl;
00150
00151 if (tolerance <= 0.0)
00152 ERREUR("Tolerance must not be negative or null");
00153
00154
00155 float normeNormal = sqrt(xNormal * xNormal + yNormal * yNormal + zNormal * zNormal);
00156 if (normeNormal == 0.0)
00157 ERREUR("null normal vector");
00158 normale[0] = xNormal / normeNormal;
00159 normale[1] = yNormal / normeNormal;
00160 normale[2] = zNormal / normeNormal;
00161
00162 pointPlan[0] = xm;
00163 pointPlan[1] = ym;
00164 pointPlan[2] = zm;
00165
00166
00167 d = -normale[0] * xm - normale[1] * ym - normale[2] * zm;
00168
00169 intersections.clear();
00170
00171
00172 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00173 {
00174 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
00175 cptNouvellesMailles[tm] = 0;
00176 }
00177
00178 int V[6];
00179 int S[4];
00180
00181
00182
00183
00184 MAILLAGE1 = new Maillage((string) "TEMP");
00185 MAILLAGE1->inputMED(ficMEDin);
00186 cout << chrono() << " - End of mesh read" << endl;
00187 indexNouveauxNoeuds = MAILLAGE1->nombreNoeudsMaillage;
00188
00189
00190 if (!MAILLAGE1->EFFECTIFS_TYPES[TETRA4])
00191 {
00192 cout << "WARNING: mesh does not contain tetra4 elements, it will not be modified" << endl;
00193 MAILLAGE1->ID = str_id_maillagenew;
00194 MAILLAGE1->outputMED(ficMEDout);
00195 cout << chrono() << " - Finished!" << endl << endl;
00196 exit(0);
00197 }
00198
00199
00200
00201
00202 DNP = (float*) malloc(sizeof(float) * MAILLAGE1->nombreNoeudsMaillage);
00203 for (int k = 0; k < MAILLAGE1->nombreNoeudsMaillage; k++)
00204 DNP[k] = distanceNoeudPlan(k + 1);
00205 cout << chrono() << " - End of computation of distances between nodes and plane" << endl;
00206
00207
00208 float LONGUEURS = 0.0;
00209 int cptLONGUEURS = 0;
00210 for (int it4 = 0; it4 < MAILLAGE1->EFFECTIFS_TYPES[TETRA4]; it4++)
00211 {
00212 bool plus = false;
00213 bool moins = false;
00214 int *offset = MAILLAGE1->CNX[TETRA4] + 4 * it4;
00215 for (int is = 0; is < 4; is++)
00216 {
00217 int ng = *(offset + is);
00218 if (DNP[ng - 1] > 0.0)
00219 plus = true;
00220 else if (DNP[ng - 1] < 0.0)
00221 moins = true;
00222 }
00223 if (plus && moins)
00224 {
00225
00226 LONGUEURS += longueurSegment(*(offset + 0), *(offset + 1));
00227 cptLONGUEURS++;
00228 LONGUEURS += longueurSegment(*(offset + 0), *(offset + 2));
00229 cptLONGUEURS++;
00230 LONGUEURS += longueurSegment(*(offset + 0), *(offset + 3));
00231 cptLONGUEURS++;
00232 LONGUEURS += longueurSegment(*(offset + 1), *(offset + 2));
00233 cptLONGUEURS++;
00234 LONGUEURS += longueurSegment(*(offset + 1), *(offset + 3));
00235 cptLONGUEURS++;
00236 LONGUEURS += longueurSegment(*(offset + 2), *(offset + 3));
00237 cptLONGUEURS++;
00238 }
00239 }
00240
00241
00242 if (cptLONGUEURS == 0)
00243 {
00244 cout
00245 << "WARNING: the cut plane does not cut any tetra4 element, initial mesh will not be modified"
00246 << endl;
00247 MAILLAGE1->ID = str_id_maillagenew;
00248 MAILLAGE1->outputMED(ficMEDout);
00249 cout << chrono() << " - Finished!" << endl << endl;
00250 exit(0);
00251 }
00252
00253
00254
00255 float longueurMoyenne = LONGUEURS / cptLONGUEURS;
00256 epsilon = tolerance * longueurMoyenne;
00257
00258 int nT4coupe = cptLONGUEURS / 6;
00259 cout << chrono() << " - End of computation of mean length of tetra4 edges near the cut plane" << endl;
00260
00261 cout << "Number of tetra4 to be cut = " << nT4coupe << endl;
00262 cout << "Mean length = " << longueurMoyenne << endl;
00263 cout << "Tolerance = " << tolerance << endl;
00264 cout << "Epsilon = " << epsilon << endl;
00265
00266
00267 POSN = (int*) malloc(sizeof(int) * MAILLAGE1->nombreNoeudsMaillage);
00268 for (int k = 0; k < MAILLAGE1->nombreNoeudsMaillage; k++)
00269 {
00270 if (DNP[k] > epsilon)
00271 POSN[k] = 1;
00272 else if (DNP[k] < -epsilon)
00273 POSN[k] = -1;
00274 else
00275 POSN[k] = 0;
00276 }
00277 cout << chrono() << " - End of nodes qualification above or below the cut plane" << endl;
00278 cout << "Start of iteration on tetra4" << endl;
00279
00280 for (int it4 = 0; it4 < MAILLAGE1->EFFECTIFS_TYPES[TETRA4]; it4++)
00281 {
00282
00283 for (int is = 0; is < 4; is++)
00284 {
00285 int ng = *(MAILLAGE1->CNX[TETRA4] + 4 * it4 + is);
00286
00287 S[is] = *(POSN + ng - 1);
00288 }
00289
00290
00291
00292 if (S[0] == -1 && S[1] == -1 && S[2] == -1 && S[3] == -1)
00293 GMmoins[TETRA4].push_back(it4);
00294
00295 else if (S[0] == -1 && S[1] == -1 && S[2] == -1 && S[3] == 0)
00296 GMmoins[TETRA4].push_back(it4);
00297
00298 else if (S[0] == -1 && S[1] == -1 && S[2] == -1 && S[3] == 1)
00299 {
00300 V[0] = -1;
00301 V[1] = -1;
00302 V[2] = intersectionSegmentPlan(it4, 2);
00303 V[3] = -1;
00304 V[4] = intersectionSegmentPlan(it4, 4);
00305 V[5] = intersectionSegmentPlan(it4, 5);
00306 cas3(V, it4);
00307 }
00308
00309
00310
00311 else if (S[0] == -1 && S[1] == -1 && S[2] == 0 && S[3] == -1)
00312 GMmoins[TETRA4].push_back(it4);
00313
00314 else if (S[0] == -1 && S[1] == -1 && S[2] == 0 && S[3] == 0)
00315 GMmoins[TETRA4].push_back(it4);
00316
00317 else if (S[0] == -1 && S[1] == -1 && S[2] == 0 && S[3] == 1)
00318 {
00319 V[0] = -1;
00320 V[1] = -1;
00321 V[2] = intersectionSegmentPlan(it4, 2);
00322 V[3] = -1;
00323 V[4] = intersectionSegmentPlan(it4, 4);
00324 V[5] = -1;
00325 cas2(V, it4);
00326 }
00327
00328
00329
00330 else if (S[0] == -1 && S[1] == -1 && S[2] == 1 && S[3] == -1)
00331 {
00332 V[0] = -1;
00333 V[1] = intersectionSegmentPlan(it4, 1);
00334 V[2] = -1;
00335 V[3] = intersectionSegmentPlan(it4, 3);
00336 V[4] = -1;
00337 V[5] = intersectionSegmentPlan(it4, 5);
00338 cas3(V, it4);
00339 }
00340
00341 else if (S[0] == -1 && S[1] == -1 && S[2] == 1 && S[3] == 0)
00342 {
00343 V[0] = -1;
00344 V[1] = intersectionSegmentPlan(it4, 1);
00345 V[2] = -1;
00346 V[3] = intersectionSegmentPlan(it4, 3);
00347 V[4] = -1;
00348 V[5] = -1;
00349 cas2(V, it4);
00350 }
00351
00352 else if (S[0] == -1 && S[1] == -1 && S[2] == 1 && S[3] == 1)
00353 {
00354 V[0] = -1;
00355 V[1] = intersectionSegmentPlan(it4, 1);
00356 V[2] = intersectionSegmentPlan(it4, 2);
00357 V[3] = intersectionSegmentPlan(it4, 3);
00358 V[4] = intersectionSegmentPlan(it4, 4);
00359 V[5] = -1;
00360 cas4(V, it4);
00361 }
00362
00363
00364
00365 else if (S[0] == -1 && S[1] == 0 && S[2] == -1 && S[3] == -1)
00366 GMmoins[TETRA4].push_back(it4);
00367
00368 else if (S[0] == -1 && S[1] == 0 && S[2] == -1 && S[3] == 0)
00369 GMmoins[TETRA4].push_back(it4);
00370
00371 else if (S[0] == -1 && S[1] == 0 && S[2] == -1 && S[3] == 1)
00372 {
00373 V[0] = -1;
00374 V[1] = -1;
00375 V[2] = intersectionSegmentPlan(it4, 2);
00376 V[3] = -1;
00377 V[4] = -1;
00378 V[5] = intersectionSegmentPlan(it4, 5);
00379 cas2(V, it4);
00380 }
00381
00382
00383
00384 else if (S[0] == -1 && S[1] == 0 && S[2] == 0 && S[3] == -1)
00385 GMmoins[TETRA4].push_back(it4);
00386
00387 else if (S[0] == -1 && S[1] == 0 && S[2] == 0 && S[3] == 0)
00388 GMmoins[TETRA4].push_back(it4);
00389
00390 else if (S[0] == -1 && S[1] == 0 && S[2] == 0 && S[3] == 1)
00391 {
00392 V[0] = -1;
00393 V[1] = -1;
00394 V[2] = intersectionSegmentPlan(it4, 2);
00395 V[3] = -1;
00396 V[4] = -1;
00397 V[5] = -1;
00398 cas1(V, it4);
00399 }
00400
00401
00402
00403 else if (S[0] == -1 && S[1] == 0 && S[2] == 1 && S[3] == -1)
00404 {
00405 V[0] = -1;
00406 V[1] = intersectionSegmentPlan(it4, 1);
00407 V[2] = -1;
00408 V[3] = -1;
00409 V[4] = -1;
00410 V[5] = intersectionSegmentPlan(it4, 5);
00411 cas2(V, it4);
00412 }
00413
00414 else if (S[0] == -1 && S[1] == 0 && S[2] == 1 && S[3] == 0)
00415 {
00416 V[0] = -1;
00417 V[1] = intersectionSegmentPlan(it4, 1);
00418 V[2] = -1;
00419 V[3] = -1;
00420 V[4] = -1;
00421 V[5] = -1;
00422 cas1(V, it4);
00423 }
00424
00425 else if (S[0] == -1 && S[1] == 0 && S[2] == 1 && S[3] == 1)
00426 {
00427 V[0] = -1;
00428 V[1] = intersectionSegmentPlan(it4, 1);
00429 V[2] = intersectionSegmentPlan(it4, 2);
00430 V[3] = -1;
00431 V[4] = -1;
00432 V[5] = -1;
00433 cas2(V, it4);
00434 }
00435
00436
00437
00438 else if (S[0] == -1 && S[1] == 1 && S[2] == -1 && S[3] == -1)
00439 {
00440 V[0] = intersectionSegmentPlan(it4, 0);
00441 V[1] = -1;
00442 V[2] = -1;
00443 V[3] = intersectionSegmentPlan(it4, 3);
00444 V[4] = intersectionSegmentPlan(it4, 4);
00445 V[5] = -1;
00446 cas3(V, it4);
00447 }
00448
00449 else if (S[0] == -1 && S[1] == 1 && S[2] == -1 && S[3] == 0)
00450 {
00451 V[0] = intersectionSegmentPlan(it4, 0);
00452 V[1] = -1;
00453 V[2] = -1;
00454 V[3] = intersectionSegmentPlan(it4, 3);
00455 V[4] = -1;
00456 V[5] = -1;
00457 cas2(V, it4);
00458 }
00459
00460 else if (S[0] == -1 && S[1] == 1 && S[2] == -1 && S[3] == 1)
00461 {
00462 V[0] = intersectionSegmentPlan(it4, 0);
00463 V[1] = -1;
00464 V[2] = intersectionSegmentPlan(it4, 2);
00465 V[3] = intersectionSegmentPlan(it4, 3);
00466 V[4] = -1;
00467 V[5] = intersectionSegmentPlan(it4, 5);
00468 cas4(V, it4);
00469 }
00470
00471
00472
00473 else if (S[0] == -1 && S[1] == 1 && S[2] == 0 && S[3] == -1)
00474 {
00475 V[0] = intersectionSegmentPlan(it4, 0);
00476 V[1] = -1;
00477 V[2] = -1;
00478 V[3] = -1;
00479 V[4] = intersectionSegmentPlan(it4, 4);
00480 V[5] = -1;
00481 cas2(V, it4);
00482 }
00483
00484 else if (S[0] == -1 && S[1] == 1 && S[2] == 0 && S[3] == 0)
00485 {
00486 V[0] = intersectionSegmentPlan(it4, 0);
00487 V[1] = -1;
00488 V[2] = -1;
00489 V[3] = -1;
00490 V[4] = -1;
00491 V[5] = -1;
00492 cas1(V, it4);
00493 }
00494
00495 else if (S[0] == -1 && S[1] == 1 && S[2] == 0 && S[3] == 1)
00496 {
00497 V[0] = intersectionSegmentPlan(it4, 0);
00498 V[1] = -1;
00499 V[2] = intersectionSegmentPlan(it4, 2);
00500 V[3] = -1;
00501 V[4] = -1;
00502 V[5] = -1;
00503 cas2(V, it4);
00504 }
00505
00506
00507
00508 else if (S[0] == -1 && S[1] == 1 && S[2] == 1 && S[3] == -1)
00509 {
00510 V[0] = intersectionSegmentPlan(it4, 0);
00511 V[1] = intersectionSegmentPlan(it4, 1);
00512 V[2] = -1;
00513 V[3] = -1;
00514 V[4] = intersectionSegmentPlan(it4, 4);
00515 V[5] = intersectionSegmentPlan(it4, 5);
00516 cas4(V, it4);
00517 }
00518
00519 else if (S[0] == -1 && S[1] == 1 && S[2] == 1 && S[3] == 0)
00520 {
00521 V[0] = intersectionSegmentPlan(it4, 0);
00522 V[1] = intersectionSegmentPlan(it4, 1);
00523 V[2] = -1;
00524 V[3] = -1;
00525 V[4] = -1;
00526 V[5] = -1;
00527 cas2(V, it4);
00528 }
00529
00530 else if (S[0] == -1 && S[1] == 1 && S[2] == 1 && S[3] == 1)
00531 {
00532 V[0] = intersectionSegmentPlan(it4, 0);
00533 V[1] = intersectionSegmentPlan(it4, 1);
00534 V[2] = intersectionSegmentPlan(it4, 2);
00535 V[3] = -1;
00536 V[4] = -1;
00537 V[5] = -1;
00538 cas3(V, it4);
00539 }
00540
00541
00542
00543 else if (S[0] == 0 && S[1] == -1 && S[2] == -1 && S[3] == -1)
00544 GMmoins[TETRA4].push_back(it4);
00545
00546 else if (S[0] == 0 && S[1] == -1 && S[2] == -1 && S[3] == 0)
00547 GMmoins[TETRA4].push_back(it4);
00548
00549 else if (S[0] == 0 && S[1] == -1 && S[2] == -1 && S[3] == 1)
00550 {
00551 V[0] = -1;
00552 V[1] = -1;
00553 V[2] = -1;
00554 V[3] = -1;
00555 V[4] = intersectionSegmentPlan(it4, 4);
00556 V[5] = intersectionSegmentPlan(it4, 5);
00557 cas2(V, it4);
00558 }
00559
00560
00561
00562 else if (S[0] == 0 && S[1] == -1 && S[2] == 0 && S[3] == -1)
00563 GMmoins[TETRA4].push_back(it4);
00564
00565 else if (S[0] == 0 && S[1] == -1 && S[2] == 0 && S[3] == 0)
00566 GMmoins[TETRA4].push_back(it4);
00567
00568 else if (S[0] == 0 && S[1] == -1 && S[2] == 0 && S[3] == 1)
00569 {
00570 V[0] = -1;
00571 V[1] = -1;
00572 V[2] = -1;
00573 V[3] = -1;
00574 V[4] = intersectionSegmentPlan(it4, 4);
00575 V[5] = -1;
00576 cas1(V, it4);
00577 }
00578
00579
00580
00581 else if (S[0] == 0 && S[1] == -1 && S[2] == 1 && S[3] == -1)
00582 {
00583 V[0] = -1;
00584 V[1] = -1;
00585 V[2] = -1;
00586 V[3] = intersectionSegmentPlan(it4, 3);
00587 V[4] = -1;
00588 V[5] = intersectionSegmentPlan(it4, 5);
00589 cas2(V, it4);
00590 }
00591
00592 else if (S[0] == 0 && S[1] == -1 && S[2] == 1 && S[3] == 0)
00593 {
00594 V[0] = -1;
00595 V[1] = -1;
00596 V[2] = -1;
00597 V[3] = intersectionSegmentPlan(it4, 3);
00598 V[4] = -1;
00599 V[5] = -1;
00600 cas1(V, it4);
00601 }
00602
00603 else if (S[0] == 0 && S[1] == -1 && S[2] == 1 && S[3] == 1)
00604 {
00605 V[0] = -1;
00606 V[1] = -1;
00607 V[2] = -1;
00608 V[3] = intersectionSegmentPlan(it4, 3);
00609 V[4] = intersectionSegmentPlan(it4, 4);
00610 V[5] = -1;
00611 cas2(V, it4);
00612 }
00613
00614
00615
00616 else if (S[0] == 0 && S[1] == 0 && S[2] == -1 && S[3] == -1)
00617 GMmoins[TETRA4].push_back(it4);
00618
00619 else if (S[0] == 0 && S[1] == 0 && S[2] == -1 && S[3] == 0)
00620 GMmoins[TETRA4].push_back(it4);
00621
00622 else if (S[0] == 0 && S[1] == 0 && S[2] == -1 && S[3] == 1)
00623 {
00624 V[0] = -1;
00625 V[1] = -1;
00626 V[2] = -1;
00627 V[3] = -1;
00628 V[4] = -1;
00629 V[5] = intersectionSegmentPlan(it4, 5);
00630 cas1(V, it4);
00631 }
00632
00633
00634
00635 else if (S[0] == 0 && S[1] == 0 && S[2] == 0 && S[3] == -1)
00636 GMmoins[TETRA4].push_back(it4);
00637
00638 else if (S[0] == 0 && S[1] == 0 && S[2] == 0 && S[3] == 0)
00639 {
00640 cout << "WARNING: TETRA4 number " << it4
00641 << " entirely in the tolerance zone near the cut plane" << endl;
00642 cout << " --> affected to group " << str_id_GMmoins << endl;
00643 GMmoins[TETRA4].push_back(it4);
00644 }
00645
00646 else if (S[0] == 0 && S[1] == 0 && S[2] == 0 && S[3] == 1)
00647 GMplus[TETRA4].push_back(it4);
00648
00649
00650
00651 else if (S[0] == 0 && S[1] == 0 && S[2] == 1 && S[3] == -1)
00652 {
00653 V[0] = -1;
00654 V[1] = -1;
00655 V[2] = -1;
00656 V[3] = -1;
00657 V[4] = -1;
00658 V[5] = intersectionSegmentPlan(it4, 5);
00659 cas1(V, it4);
00660 }
00661
00662 else if (S[0] == 0 && S[1] == 0 && S[2] == 1 && S[3] == 0)
00663 GMplus[TETRA4].push_back(it4);
00664
00665 else if (S[0] == 0 && S[1] == 0 && S[2] == 1 && S[3] == 1)
00666 GMplus[TETRA4].push_back(it4);
00667
00668
00669
00670 else if (S[0] == 0 && S[1] == 1 && S[2] == -1 && S[3] == -1)
00671 {
00672 V[0] = -1;
00673 V[1] = -1;
00674 V[2] = -1;
00675 V[3] = intersectionSegmentPlan(it4, 3);
00676 V[4] = intersectionSegmentPlan(it4, 4);
00677 V[5] = -1;
00678 cas2(V, it4);
00679 }
00680
00681 else if (S[0] == 0 && S[1] == 1 && S[2] == -1 && S[3] == 0)
00682 {
00683 V[0] = -1;
00684 V[1] = -1;
00685 V[2] = -1;
00686 V[3] = intersectionSegmentPlan(it4, 3);
00687 V[4] = -1;
00688 V[5] = -1;
00689 cas1(V, it4);
00690 }
00691
00692 else if (S[0] == 0 && S[1] == 1 && S[2] == -1 && S[3] == 1)
00693 {
00694 V[0] = -1;
00695 V[1] = -1;
00696 V[2] = -1;
00697 V[3] = intersectionSegmentPlan(it4, 3);
00698 V[4] = -1;
00699 V[5] = intersectionSegmentPlan(it4, 5);
00700 cas2(V, it4);
00701 }
00702
00703
00704
00705 else if (S[0] == 0 && S[1] == 1 && S[2] == 0 && S[3] == -1)
00706 {
00707 V[0] = -1;
00708 V[1] = -1;
00709 V[2] = -1;
00710 V[3] = -1;
00711 V[4] = intersectionSegmentPlan(it4, 4);
00712 V[5] = -1;
00713 cas1(V, it4);
00714 }
00715
00716 else if (S[0] == 0 && S[1] == 1 && S[2] == 0 && S[3] == 0)
00717 GMplus[TETRA4].push_back(it4);
00718
00719 else if (S[0] == 0 && S[1] == 1 && S[2] == 0 && S[3] == 1)
00720 GMplus[TETRA4].push_back(it4);
00721
00722
00723
00724 else if (S[0] == 0 && S[1] == 1 && S[2] == 1 && S[3] == -1)
00725 {
00726 V[0] = -1;
00727 V[1] = -1;
00728 V[2] = -1;
00729 V[3] = -1;
00730 V[4] = intersectionSegmentPlan(it4, 4);
00731 V[5] = intersectionSegmentPlan(it4, 5);
00732 cas2(V, it4);
00733 }
00734
00735 else if (S[0] == 0 && S[1] == 1 && S[2] == 1 && S[3] == 0)
00736 GMplus[TETRA4].push_back(it4);
00737
00738 else if (S[0] == 0 && S[1] == 1 && S[2] == 1 && S[3] == 1)
00739 GMplus[TETRA4].push_back(it4);
00740
00741
00742
00743 else if (S[0] == 1 && S[1] == -1 && S[2] == -1 && S[3] == -1)
00744 {
00745 V[0] = intersectionSegmentPlan(it4, 0);
00746 V[1] = intersectionSegmentPlan(it4, 1);
00747 V[2] = intersectionSegmentPlan(it4, 2);
00748 V[3] = -1;
00749 V[4] = -1;
00750 V[5] = -1;
00751 cas3(V, it4);
00752 }
00753
00754 else if (S[0] == 1 && S[1] == -1 && S[2] == -1 && S[3] == 0)
00755 {
00756 V[0] = intersectionSegmentPlan(it4, 0);
00757 V[1] = intersectionSegmentPlan(it4, 1);
00758 V[2] = -1;
00759 V[3] = -1;
00760 V[4] = -1;
00761 V[5] = -1;
00762 cas2(V, it4);
00763 }
00764
00765 else if (S[0] == 1 && S[1] == -1 && S[2] == -1 && S[3] == 1)
00766 {
00767 V[0] = intersectionSegmentPlan(it4, 0);
00768 V[1] = intersectionSegmentPlan(it4, 1);
00769 V[2] = -1;
00770 V[3] = -1;
00771 V[4] = intersectionSegmentPlan(it4, 4);
00772 V[5] = intersectionSegmentPlan(it4, 5);
00773 cas4(V, it4);
00774 }
00775
00776
00777
00778 else if (S[0] == 1 && S[1] == -1 && S[2] == 0 && S[3] == -1)
00779 {
00780 V[0] = intersectionSegmentPlan(it4, 0);
00781 V[1] = -1;
00782 V[2] = intersectionSegmentPlan(it4, 2);
00783 V[3] = -1;
00784 V[4] = -1;
00785 V[5] = -1;
00786 cas2(V, it4);
00787 }
00788
00789 else if (S[0] == 1 && S[1] == -1 && S[2] == 0 && S[3] == 0)
00790 {
00791 V[0] = intersectionSegmentPlan(it4, 0);
00792 V[1] = -1;
00793 V[2] = -1;
00794 V[3] = -1;
00795 V[4] = -1;
00796 V[5] = -1;
00797 cas1(V, it4);
00798 }
00799
00800 else if (S[0] == 1 && S[1] == -1 && S[2] == 0 && S[3] == 1)
00801 {
00802 V[0] = intersectionSegmentPlan(it4, 0);
00803 V[1] = -1;
00804 V[2] = -1;
00805 V[3] = -1;
00806 V[4] = intersectionSegmentPlan(it4, 4);
00807 V[5] = -1;
00808 cas2(V, it4);
00809 }
00810
00811
00812
00813 else if (S[0] == 1 && S[1] == -1 && S[2] == 1 && S[3] == -1)
00814 {
00815 V[0] = intersectionSegmentPlan(it4, 0);
00816 V[1] = -1;
00817 V[2] = intersectionSegmentPlan(it4, 2);
00818 V[3] = intersectionSegmentPlan(it4, 3);
00819 V[4] = -1;
00820 V[5] = intersectionSegmentPlan(it4, 5);
00821 cas4(V, it4);
00822 }
00823
00824 else if (S[0] == 1 && S[1] == -1 && S[2] == 1 && S[3] == 0)
00825 {
00826 V[0] = intersectionSegmentPlan(it4, 0);
00827 V[1] = -1;
00828 V[2] = -1;
00829 V[3] = intersectionSegmentPlan(it4, 3);
00830 V[4] = -1;
00831 V[5] = -1;
00832 cas2(V, it4);
00833 }
00834
00835 else if (S[0] == 1 && S[1] == -1 && S[2] == 1 && S[3] == 1)
00836 {
00837 V[0] = intersectionSegmentPlan(it4, 0);
00838 V[1] = -1;
00839 V[2] = -1;
00840 V[3] = intersectionSegmentPlan(it4, 3);
00841 V[4] = intersectionSegmentPlan(it4, 4);
00842 V[5] = -1;
00843 cas3(V, it4);
00844 }
00845
00846
00847
00848 else if (S[0] == 1 && S[1] == 0 && S[2] == -1 && S[3] == -1)
00849 {
00850 V[0] = -1;
00851 V[1] = intersectionSegmentPlan(it4, 1);
00852 V[2] = intersectionSegmentPlan(it4, 2);
00853 V[3] = -1;
00854 V[4] = -1;
00855 V[5] = -1;
00856 cas2(V, it4);
00857 }
00858
00859 else if (S[0] == 1 && S[1] == 0 && S[2] == -1 && S[3] == 0)
00860 {
00861 V[0] = -1;
00862 V[1] = intersectionSegmentPlan(it4, 1);
00863 V[2] = -1;
00864 V[3] = -1;
00865 V[4] = -1;
00866 V[5] = -1;
00867 cas1(V, it4);
00868 }
00869
00870 else if (S[0] == 1 && S[1] == 0 && S[2] == -1 && S[3] == 1)
00871 {
00872 V[0] = -1;
00873 V[1] = intersectionSegmentPlan(it4, 1);
00874 V[2] = -1;
00875 V[3] = -1;
00876 V[4] = -1;
00877 V[5] = intersectionSegmentPlan(it4, 5);
00878 cas2(V, it4);
00879 }
00880
00881
00882
00883 else if (S[0] == 1 && S[1] == 0 && S[2] == 0 && S[3] == -1)
00884 {
00885 V[0] = -1;
00886 V[1] = -1;
00887 V[2] = intersectionSegmentPlan(it4, 2);
00888 V[3] = -1;
00889 V[4] = -1;
00890 V[5] = -1;
00891 cas1(V, it4);
00892 }
00893
00894 else if (S[0] == 1 && S[1] == 0 && S[2] == 0 && S[3] == 0)
00895 GMplus[TETRA4].push_back(it4);
00896
00897 else if (S[0] == 1 && S[1] == 0 && S[2] == 0 && S[3] == 1)
00898 GMplus[TETRA4].push_back(it4);
00899
00900
00901
00902 else if (S[0] == 1 && S[1] == 0 && S[2] == 1 && S[3] == -1)
00903 {
00904 V[0] = -1;
00905 V[1] = -1;
00906 V[2] = intersectionSegmentPlan(it4, 2);
00907 V[3] = -1;
00908 V[4] = -1;
00909 V[5] = intersectionSegmentPlan(it4, 5);
00910 cas2(V, it4);
00911 }
00912
00913 else if (S[0] == 1 && S[1] == 0 && S[2] == 1 && S[3] == 0)
00914 GMplus[TETRA4].push_back(it4);
00915
00916 else if (S[0] == 1 && S[1] == 0 && S[2] == 1 && S[3] == 1)
00917 GMplus[TETRA4].push_back(it4);
00918
00919
00920
00921 else if (S[0] == 1 && S[1] == 1 && S[2] == -1 && S[3] == -1)
00922 {
00923 V[0] = -1;
00924 V[1] = intersectionSegmentPlan(it4, 1);
00925 V[2] = intersectionSegmentPlan(it4, 2);
00926 V[3] = intersectionSegmentPlan(it4, 3);
00927 V[4] = intersectionSegmentPlan(it4, 4);
00928 V[5] = -1;
00929 cas4(V, it4);
00930 }
00931
00932 else if (S[0] == 1 && S[1] == 1 && S[2] == -1 && S[3] == 0)
00933 {
00934 V[0] = -1;
00935 V[1] = intersectionSegmentPlan(it4, 1);
00936 V[2] = -1;
00937 V[3] = intersectionSegmentPlan(it4, 3);
00938 V[4] = -1;
00939 V[5] = -1;
00940 cas2(V, it4);
00941 }
00942
00943 else if (S[0] == 1 && S[1] == 1 && S[2] == -1 && S[3] == 1)
00944 {
00945 V[0] = -1;
00946 V[1] = intersectionSegmentPlan(it4, 1);
00947 V[2] = -1;
00948 V[3] = intersectionSegmentPlan(it4, 3);
00949 V[4] = -1;
00950 V[5] = intersectionSegmentPlan(it4, 5);
00951 cas3(V, it4);
00952 }
00953
00954
00955
00956 else if (S[0] == 1 && S[1] == 1 && S[2] == 0 && S[3] == -1)
00957 {
00958 V[0] = -1;
00959 V[1] = -1;
00960 V[2] = intersectionSegmentPlan(it4, 2);
00961 V[3] = -1;
00962 V[4] = intersectionSegmentPlan(it4, 4);
00963 V[5] = -1;
00964 cas2(V, it4);
00965 }
00966
00967 else if (S[0] == 1 && S[1] == 1 && S[2] == 0 && S[3] == 0)
00968 GMplus[TETRA4].push_back(it4);
00969
00970 else if (S[0] == 1 && S[1] == 1 && S[2] == 0 && S[3] == 1)
00971 GMplus[TETRA4].push_back(it4);
00972
00973
00974
00975 else if (S[0] == 1 && S[1] == 1 && S[2] == 1 && S[3] == -1)
00976 {
00977 V[0] = -1;
00978 V[1] = -1;
00979 V[2] = intersectionSegmentPlan(it4, 2);
00980 V[3] = -1;
00981 V[4] = intersectionSegmentPlan(it4, 4);
00982 V[5] = intersectionSegmentPlan(it4, 5);
00983 cas3(V, it4);
00984 }
00985
00986 else if (S[0] == 1 && S[1] == 1 && S[2] == 1 && S[3] == 0)
00987 GMplus[TETRA4].push_back(it4);
00988
00989 else if (S[0] == 1 && S[1] == 1 && S[2] == 1 && S[3] == 1)
00990 GMplus[TETRA4].push_back(it4);
00991
00992 else
00993 ERREUR("Case not taken into account");
00994
00995 }
00996 cout << chrono() << " - End of iteration on tetra4" << endl;
00997
00998
00999 newXX.resize(indexNouveauxNoeuds - MAILLAGE1->nombreNoeudsMaillage);
01000 newYY.resize(indexNouveauxNoeuds - MAILLAGE1->nombreNoeudsMaillage);
01001 newZZ.resize(indexNouveauxNoeuds - MAILLAGE1->nombreNoeudsMaillage);
01002
01003 if (cptNouvellesMailles[TETRA4])
01004 newCNX[TETRA4].resize(4 * cptNouvellesMailles[TETRA4]);
01005 if (cptNouvellesMailles[PYRAM5])
01006 newCNX[PYRAM5].resize(5 * cptNouvellesMailles[PYRAM5]);
01007 if (cptNouvellesMailles[PENTA6])
01008 newCNX[PENTA6].resize(6 * cptNouvellesMailles[PENTA6]);
01009
01010
01011
01012
01013
01014 cout << chrono() << " - Constitution of final mesh" << endl;
01015
01016 MAILLAGE2 = new Maillage(str_id_maillagenew);
01017 MAILLAGE2->dimensionMaillage = MAILLAGE1->dimensionMaillage;
01018 MAILLAGE2->dimensionEspace = MAILLAGE1->dimensionEspace;
01019 strcpy(MAILLAGE2->axisname, MAILLAGE1->axisname);
01020 strcpy(MAILLAGE2->unitname, MAILLAGE1->unitname);
01021 MAILLAGE2->nombreNoeudsMaillage = indexNouveauxNoeuds;
01022 MAILLAGE2->nombreMaillesMaillage = MAILLAGE1->nombreMaillesMaillage + cptNouvellesMailles[TETRA4]
01023 + cptNouvellesMailles[PYRAM5] + cptNouvellesMailles[PENTA6];
01024
01025
01026
01027
01028
01029 MAILLAGE2->XX = (float*) malloc(sizeof(float) * MAILLAGE2->nombreNoeudsMaillage);
01030 for (int i = 0; i < MAILLAGE1->nombreNoeudsMaillage; i++)
01031 *(MAILLAGE2->XX + i) = *(MAILLAGE1->XX + i);
01032 free(MAILLAGE1->XX);
01033 MAILLAGE2->YY = (float*) malloc(sizeof(float) * MAILLAGE2->nombreNoeudsMaillage);
01034 for (int i = 0; i < MAILLAGE1->nombreNoeudsMaillage; i++)
01035 *(MAILLAGE2->YY + i) = *(MAILLAGE1->YY + i);
01036 free(MAILLAGE1->YY);
01037 MAILLAGE2->ZZ = (float*) malloc(sizeof(float) * MAILLAGE2->nombreNoeudsMaillage);
01038 for (int i = 0; i < MAILLAGE1->nombreNoeudsMaillage; i++)
01039 *(MAILLAGE2->ZZ + i) = *(MAILLAGE1->ZZ + i);
01040 free(MAILLAGE1->ZZ);
01041
01042
01043 for (int i = 0; i < MAILLAGE2->nombreNoeudsMaillage - MAILLAGE1->nombreNoeudsMaillage; i++)
01044 {
01045 *(MAILLAGE2->XX + MAILLAGE1->nombreNoeudsMaillage + i) = newXX[i];
01046 *(MAILLAGE2->YY + MAILLAGE1->nombreNoeudsMaillage + i) = newYY[i];
01047 *(MAILLAGE2->ZZ + MAILLAGE1->nombreNoeudsMaillage + i) = newZZ[i];
01048
01049 }
01050
01051
01052 for (int itm = (int) TETRA4; itm <= (int) HEXA20; itm++)
01053 {
01054 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01055 if (tm != TETRA4 && tm != PYRAM5 && tm != PENTA6)
01056 {
01057
01058 if (MAILLAGE1->EFFECTIFS_TYPES[tm])
01059 MAILLAGE2->CNX[tm] = MAILLAGE1->CNX[tm];
01060 MAILLAGE2->EFFECTIFS_TYPES[tm] = MAILLAGE1->EFFECTIFS_TYPES[tm];
01061 }
01062 else
01063 {
01064
01065
01066 int tailleType = Nnoeuds(tm);
01067
01068 MAILLAGE2->CNX[tm] = (int*) malloc(sizeof(int) * tailleType * (MAILLAGE1->EFFECTIFS_TYPES[tm]
01069 + cptNouvellesMailles[tm]));
01070 for (int i = 0; i < MAILLAGE1->EFFECTIFS_TYPES[tm]; i++)
01071 for (int j = 0; j < tailleType; j++)
01072 *(MAILLAGE2->CNX[tm] + tailleType * i + j) = *(MAILLAGE1->CNX[tm] + tailleType * i + j);
01073
01074 for (int i = 0; i < cptNouvellesMailles[tm]; i++)
01075 for (int j = 0; j < tailleType; j++)
01076 *(MAILLAGE2->CNX[tm] + tailleType * (MAILLAGE1->EFFECTIFS_TYPES[tm] + i) + j) = newCNX[tm][i * tailleType
01077 + j];
01078
01079 MAILLAGE2->EFFECTIFS_TYPES[tm] = MAILLAGE1->EFFECTIFS_TYPES[tm] + cptNouvellesMailles[tm];
01080 }
01081 }
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107 MAILLAGE2->GM = MAILLAGE1->GM;
01108 MAILLAGE2->GM[str_id_GMplus] = GMplus;
01109 MAILLAGE2->GM[str_id_GMmoins] = GMmoins;
01110
01111 MAILLAGE2->GN = MAILLAGE1->GN;
01112
01113 MAILLAGE2->eliminationMailles(TETRA4, cutTetras);
01114
01115 cout << chrono() << " - MED file writing" << endl;
01116
01117 MAILLAGE2->outputMED(ficMEDout);
01118 cout << chrono() << " - Finished!" << endl << endl;
01119
01120 return 0;
01121
01122 }