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 #ifdef MODULE_GEOLOGY
00026
00027 #include "g-map-vertex.hh"
00028 #include "controler-gmap.hh"
00029 #include "operations.hh"
00030 #include "parameter-selection.hh"
00031 #include "view-precompile.hh"
00032
00033 #include "geology-api.hh"
00034 #include "geo-tools.hh"
00035 #include "corefinement-api.hh"
00036 #include "corefine-3d.hh"
00037
00038 using namespace GMap3d;
00039
00040
00041
00042 bool CControlerGMap::createUncertainZone()
00043 {
00044 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00045 SUB_OPERATION_GEOLOGY_UNCERTAIN_ZONE, -1))) {
00046 CGeologyAPI geo(FMap);
00047 CDart *d1, *d2;
00048
00049 if (FMap->getMarkedCells(ORBIT_CC, getSelectionMark(), NULL, &d1) != 1) {
00050 setMessage("Sélection maillage 1 incohérente");
00051 return false;
00052 }
00053
00054 if (FMap->getMarkedCells(ORBIT_EDGE, getNextSelectionMark(1),
00055 NULL, &d2) != 1) {
00056 setMessage("Sélection de distance incohérente");
00057 return false;
00058 }
00059
00060 CVertex v = *FMap->findVertex(FMap->alpha0(d2)) - *FMap->findVertex(d2);
00061
00062 undoRedoPreSave();
00063 geo.createUncertainZone(d1, v.norm(), 5);
00064 undoRedoPostSaveOk();
00065
00066 setModelChanged();
00067 setMessage("Création d'une zone d'incertitude effectuée");
00068 return true;
00069 }
00070
00071 return false;
00072 }
00073
00074
00075
00076 bool CControlerGMap::createNearestIntersections()
00077 {
00078 if (canApplyOperation(COperation(OPERATION_COREFINE,
00079 SUB_OPERATION_COREFINE3D, -1)))
00080 {
00081 CDart *d1, *d2;
00082
00083 if (FMap->getMarkedCells(ORBIT_CC, getSelectionMark(), NULL, &d1) != 1)
00084 {
00085 setMessage("Sélection maillage 1 incohérente");
00086 return false;
00087 }
00088
00089 if (FMap->getMarkedCells(ORBIT_CC, getNextSelectionMark(1),
00090 NULL, &d2) != 1)
00091 {
00092 setMessage("Sélection maillage 2 incohérente");
00093 return false;
00094 }
00095
00096 undoRedoPreSave();
00097
00098 CCorefine3d *coref = new CCorefine3d(FMap);
00099
00100 coref->computeOnlyFirstIntersection(true);
00101 coref->splitAndMergeMeshes(d1, d2);
00102
00103 delete coref;
00104
00105 undoRedoPostSaveOk();
00106
00107 setModelChanged();
00108 setMessage("Co-raffinement 3D effectué");
00109 return true;
00110 }
00111
00112 return false;
00113 }
00114
00115
00116
00117 bool CControlerGMap::extendSelectedBorders()
00118 {
00119 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00120 SUB_OPERATION_GEOLOGY_EXTEND, -1))) {
00121 CGeologyAPI geo(FMap);
00122 CDart *d;
00123
00124 if (FMap->getMarkedCells(ORBIT_EDGE, getNextSelectionMark(1),
00125 NULL, &d) != 1) {
00126 setMessage("Sélection de distance incohérente");
00127 return false;
00128 }
00129
00130 CVertex v = *FMap->findVertex(FMap->alpha0(d)) - *FMap->findVertex(d);
00131
00132 undoRedoPreSave();
00133 geo.extendSelectedBorders(getSelectionMark(), v.norm());
00134 undoRedoPostSaveOk();
00135
00136 setModelChanged();
00137 setMessage("Extensions des bords effectuées");
00138 return true;
00139 }
00140
00141 return false;
00142 }
00143
00144
00145
00146 bool CControlerGMap::extendSelectedBordersToSurface()
00147 {
00148 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00149 SUB_OPERATION_GEOLOGY_EXTEND_TO, -1))) {
00150 CGeologyAPI geo(FMap);
00151 CDart *d;
00152
00153 if (FMap->getMarkedCells(ORBIT_CC, getNextSelectionMark(1),
00154 NULL, &d) != 1) {
00155 setMessage("Sélection de la surface incohérente");
00156 return false;
00157 }
00158
00159 undoRedoPreSave();
00160 geo.extendSelectedBordersToSurface(getSelectionMark(), d);
00161 undoRedoPostSaveOk();
00162
00163 setModelChanged();
00164 setMessage("Extension des bords effectué");
00165 return true;
00166 }
00167
00168 return false;
00169 }
00170
00171
00172
00173 bool CControlerGMap::smoothSelection()
00174 {
00175 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00176 SUB_OPERATION_GEOLOGY_SMOOTH, -1))) {
00177 CGeologyAPI geo(FMap);
00178
00179 undoRedoPreSave();
00180 geo.smoothSelection(getSelectionMark());
00181 undoRedoPostSaveOk();
00182
00183 setModelChanged();
00184 setMessage("Lissage effectué");
00185 return true;
00186 }
00187
00188 return false;
00189 }
00190
00191
00192
00193 bool CControlerGMap::relaxSelection()
00194 {
00195 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00196 SUB_OPERATION_GEOLOGY_RELAX, -1))) {
00197 CGeologyAPI geo(FMap, 1E-2);
00198
00199 undoRedoPreSave();
00200 geo.relaxSelection(getSelectionMark());
00201 undoRedoPostSaveOk();
00202
00203 setModelChanged();
00204 setMessage("Relachement effectué");
00205 return true;
00206 }
00207
00208 return false;
00209 }
00210
00211
00212
00213 bool CControlerGMap::simplifyMesh()
00214 {
00215 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00216 SUB_OPERATION_GEOLOGY_SIMPLIFY, -1))) {
00217 CGeologyAPI geo(FMap);
00218
00219
00220
00221
00222
00223
00224
00225 undoRedoPreSave();
00226 geo.optimizeSelection(getSelectionMark(), 5);
00227 undoRedoPostSaveOk();
00228
00229 setModelChanged();
00230 setMessage("Maillage simplifié");
00231 return true;
00232 }
00233
00234 return false;
00235 }
00236
00237
00238
00239 bool CControlerGMap::centerSelection()
00240 {
00241 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00242 SUB_OPERATION_GEOLOGY_CENTER, -1))) {
00243 CGeoTools tools(FMap);
00244
00245 undoRedoPreSave();
00246 tools.centerSelectedDarts(getSelectionMark());
00247 undoRedoPostSaveOk();
00248
00249 setModelChanged();
00250 setMessage("Centrage effectué");
00251 return true;
00252 }
00253
00254 return false;
00255 }
00256
00257
00258
00259 bool CControlerGMap::plateVerticesOnFaces()
00260 {
00261 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00262 SUB_OPERATION_GEOLOGY_PLATE_ON_FACES, -1))) {
00263 CGeologyAPI geo(FMap);
00264 CDart *d;
00265 CVertex v;
00266
00267 int nb = FMap->getMarkedCells(ORBIT_EDGE, getNextSelectionMark(2),
00268 NULL, &d);
00269
00270 if (nb > 1) {
00271 setMessage("Sélection de direction incohérente");
00272 return false;
00273 }
00274
00275 if (nb == 0) v = OZ;
00276 else v = *FMap->findVertex(FMap->alpha0(d)) - *FMap->findVertex(d);
00277
00278 undoRedoPreSave();
00279 geo.plateVerticesOnFaces(getSelectionMark(), getNextSelectionMark(1), v);
00280 undoRedoPostSaveOk();
00281
00282 setModelChanged();
00283 setMessage("Plaquage effectué");
00284 return true;
00285 }
00286
00287 return false;
00288 }
00289
00290
00291
00292 bool CControlerGMap::plateVerticesOnEdges()
00293 {
00294 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00295 SUB_OPERATION_GEOLOGY_PLATE_ON_EDGES, -1))) {
00296 CGeologyAPI geo(FMap);
00297 CDart *d;
00298 CVertex v;
00299
00300 int nb = FMap->getMarkedCells(ORBIT_EDGE, getNextSelectionMark(2),
00301 NULL, &d);
00302
00303 if (nb != 1) {
00304 setMessage("Sélection de direction incohérente");
00305 return false;
00306 }
00307
00308 v = *FMap->findVertex(FMap->alpha0(d)) - *FMap->findVertex(d);
00309
00310 undoRedoPreSave();
00311 geo.plateVerticesOnEdges(getSelectionMark(), getNextSelectionMark(1), v);
00312 undoRedoPostSaveOk();
00313
00314 setModelChanged();
00315 setMessage("Plaquage effectué");
00316 return true;
00317 }
00318
00319 return false;
00320 }
00321
00322
00323
00324 bool CControlerGMap::plateVerticesOnVertices()
00325 {
00326 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00327 SUB_OPERATION_GEOLOGY_PLATE_ON_VERTICES, -1))) {
00328 CGeologyAPI geo(FMap);
00329
00330 undoRedoPreSave();
00331 geo.plateVerticesOnVertices(getSelectionMark(), getNextSelectionMark(1));
00332 undoRedoPostSaveOk();
00333
00334 setModelChanged();
00335 setMessage("Plaquage effectué");
00336 return true;
00337 }
00338
00339 return false;
00340 }
00341
00342
00343
00344 bool CControlerGMap::selectMacroVertices()
00345 {
00346 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00347 SUB_OPERATION_GEOLOGY_SELECT_VERTICES, -1))) {
00348 CGeologyAPI geo(FMap);
00349
00350 geo.selectMacroVertices(getSelectionMark());
00351
00352 setMessage("Selection effectuée");
00353 setSelectionChanged();
00354 return true;
00355 }
00356
00357 return false;
00358 }
00359
00360
00361
00362 bool CControlerGMap::selectAllMacroEdges()
00363 {
00364 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00365 SUB_OPERATION_GEOLOGY_SELECT_ALL_EDGES, -1))) {
00366 CGeologyAPI geo(FMap);
00367
00368 geo.selectAllMacroEdges(getSelectionMark());
00369
00370 setMessage("Selection effectuée");
00371 setSelectionChanged();
00372 return true;
00373 }
00374
00375 return false;
00376 }
00377
00378
00379
00380 bool CControlerGMap::selectMacroEdges()
00381 {
00382 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00383 SUB_OPERATION_GEOLOGY_SELECT_EDGES, -1))) {
00384 CGeologyAPI geo(FMap);
00385
00386 geo.selectMacroEdges(getSelectionMark(), getNextSelectionMark(1));
00387
00388 setMessage("Selection effectuée");
00389 setSelectionChanged();
00390 return true;
00391 }
00392
00393 return false;
00394 }
00395
00396
00397
00398 bool CControlerGMap::selectMacroFaces()
00399 {
00400 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00401 SUB_OPERATION_GEOLOGY_SELECT_FACES, -1))) {
00402 CGeologyAPI geo(FMap);
00403
00404 geo.selectMacroFaces(getSelectionMark(), getNextSelectionMark(1));
00405
00406 setMessage("Selection effectuée");
00407 setSelectionChanged();
00408 return true;
00409 }
00410
00411 return false;
00412 }
00413
00414
00415
00416 bool CControlerGMap::selectBordersBetweenSelectedDarts()
00417 {
00418 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00419 SUB_OPERATION_GEOLOGY_SELECT_BORDERS, -1))) {
00420 CGeoTools tools(FMap);
00421
00422 tools.selectBordersBetweenSelectedDarts(getSelectionMark());
00423
00424 setMessage("Selection des bords effectuée");
00425 setSelectionChanged();
00426 return true;
00427 }
00428
00429 return false;
00430 }
00431
00432
00433 bool CControlerGMap::importGr2d(const char * AFileName)
00434 {
00435 bool res = false;
00436
00437 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00438 SUB_OPERATION_GEOLOGY_IMPORT_GR2D, -1))) {
00439 CGeologyAPI geo(FMap);
00440
00441 undoRedoPreSave();
00442
00443 if (geo.importFile(AFileName, GR2D_Format)) {
00444 undoRedoPostSaveOk();
00445 setModelChanged();
00446 setMessage("Chargement effectué");
00447 res = true;
00448 }
00449 else {
00450 undoRedoPostSaveFailed();
00451 setMessage("Chargement impossible");
00452 }
00453
00454 assert(isMapOk());
00455 }
00456
00457 return res;
00458 }
00459
00460
00461
00462 bool CControlerGMap::importXyz(const char * AFileName)
00463 {
00464 bool res = false;
00465
00466 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00467 SUB_OPERATION_GEOLOGY_IMPORT_XYZ, -1))) {
00468 CGeologyAPI geo(FMap);
00469
00470 undoRedoPreSave();
00471
00472 if (geo.importFile(AFileName, XYZ_Format)) {
00473 undoRedoPostSaveOk();
00474 setModelChanged();
00475 setMessage("Chargement effectué");
00476 res = true;
00477 }
00478 else {
00479 undoRedoPostSaveFailed();
00480 setMessage("Chargement impossible");
00481 }
00482
00483 assert(isMapOk());
00484 }
00485
00486 return res;
00487 }
00488
00489
00490
00491 bool CControlerGMap::importTs(const char * AFileName)
00492 {
00493 bool res = false;
00494
00495 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00496 SUB_OPERATION_GEOLOGY_IMPORT_TS, -1))) {
00497 CGeologyAPI geo(FMap);
00498
00499 undoRedoPreSave();
00500
00501 if (geo.importFile(AFileName, TS_Format)) {
00502 undoRedoPostSaveOk();
00503 setModelChanged();
00504 setMessage("Chargement effectué");
00505 res = true;
00506 }
00507 else {
00508 undoRedoPostSaveFailed();
00509 setMessage("Chargement impossible");
00510 }
00511
00512 assert(isMapOk());
00513 }
00514
00515 return res;
00516 }
00517
00518
00519
00520 bool CControlerGMap::importCloud(const char * AFileName)
00521 {
00522 bool res = false;
00523
00524 if (canApplyOperation(COperation(OPERATION_GEOLOGY,
00525 SUB_OPERATION_GEOLOGY_IMPORT_CLOUD, -1))) {
00526 CGeologyAPI geo(FMap);
00527
00528 undoRedoPreSave();
00529
00530 if (geo.importFile(AFileName, CLOUD_Format)) {
00531 undoRedoPostSaveOk();
00532 setModelChanged();
00533 setMessage("Chargement effectué");
00534 res = true;
00535 }
00536 else {
00537 undoRedoPostSaveFailed();
00538 setMessage("Chargement impossible");
00539 }
00540
00541 assert(isMapOk());
00542 }
00543
00544 return res;
00545 }
00546
00547 #endif // MODULE_GEOLOGY
00548