Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operations-triangulation-quadrangulation.cc
Go to the documentation of this file.
1 /*
2  * lib-controler-gmap : Le contrôleur de 3-G-cartes, surcouche de lib-controler.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-controler-gmap
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #include "g-map-vertex.hh"
26 #include "controler-gmap.hh"
27 #include <cassert>
28 
29 using namespace GMap3d;
30 //******************************************************************************
32 {
33  switch (getSelectionOrbit())
34  {
35  case ORBIT_EDGE : return triangulate(1); break;
36  case ORBIT_FACE : return triangulate(2); break;
37  case ORBIT_VOLUME : return triangulate(3); break;
38  default: setMessage("Selected orbit not correct");
39  }
40  return false;
41 }
42 //******************************************************************************
43 bool CControlerGMap::triangulate(int ADimension)
44 {
45  bool res = false;
46 
48  {
50 
51  int nb = FMap->triangulateMarkedCells(getSelectionMark(), ADimension);
52 
53  if (nb==0)
54  {
55  setMessage("No ",ADimension,"-cell triangulated");
57  }
58  else
59  {
61 
63  setMessage(nb, ADimension, nb==1 ?
64  "-cell triangulated" :
65  "-cells triangulated");
66  res = true;
67  }
68  }
69 
70  return res;
71 }
72 //******************************************************************************
74 {
75  bool res = false;
76 
79  {
81 
82  int nb = FMap->quadrangulateMarkedFaces(getSelectionMark());
83 
84  if (nb==0)
85  {
86  setMessage("No face quadrangulated");
88  }
89  else
90  {
92 
93  setModelChanged();
94  setMessage(nb, nb==1 ? " face quadrangulated" :
95  " faces quadrangulated");
96  res = true;
97  }
98  }
99 
100  return res;
101 }
102 //******************************************************************************
104 {
105  bool res = false;
106 
109  {
110  undoRedoPreSave();
111 
112  int nb = FMap->quadrangulateMarkedFaces(getSelectionMark(), false);
113 
114  if (nb==0)
115  {
116  setMessage("No face quadrangulated");
118  }
119  else
120  {
122 
123  setModelChanged();
124  setMessage(nb, nb==1 ? " face quadrangulated" :
125  " faces quadrangulated");
126  res = true;
127  }
128  }
129 
130  return res;
131 }
132 //******************************************************************************
134 {
135  bool res = false;
136 
139  CDart *d;
140 
141  if (FMap->getMarkedCells(ORBIT_EDGE, getSelectionMark(), NULL, &d) != 1) {
142  setMessage("Selected edge not correct: you need one edge");
143  return false;
144  }
145 
146  undoRedoPreSave();
147 
148  if (FMap->swapEdge(d)) {
150  setModelChanged();
151  setMessage("No edge swapped");
152  res = true;
153  }
154  else {
156  setMessage("Not possible to swap the edge");
157  }
158 
159  assert(isMapOk());
160  }
161 
162  return res;
163 }
164 //******************************************************************************
166 {
169  {
170  /* int vertexDI = getNewDirectInfo();
171  pointDirectInfoToAttributeVertex(vertexDI); */
172 
173  undoRedoPreSave();
174  FMap->triangulateMarkedFaces(getSelectionMark());
176 
177  // freeDirectInfo(vertexDI);
178 
179  setModelChanged();
180  setMessage("Faces triangulated");
181  return true;
182  }
183 
184  return false;
185 }
186 //******************************************************************************