Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operations-mesh.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 #ifdef MODULE_MESH
26 //******************************************************************************
27 #include "g-map-vertex.hh"
28 #include "controler-gmap.hh"
29 #include <cassert>
30 #include <sstream>
31 
32 #include "mesh-interface.hh"
33 
34 using namespace GMap3d;
35 //******************************************************************************
37 {
38  bool res = false;
40  {
42 
44 
45  int nb =
46  CMesh(FMap).meshMarkedEdges(getSelectionMark(), sx, NULL,
48  ->getInterpolationMerges(),
50  ->getInterpolationSews());
51 
52  if (nb==0)
53  {
54  setMessage("No edge meshed");
56  }
57  else
58  {
60  setModelChanged();
61  setMessage(nb, nb==1 ? " edge meshed" : " edges meshed");
62  res = true;
63  }
64  }
65 
66  return res;
67 }
68 //******************************************************************************
69 bool CControlerGMap::meshSquares(int ADimFrom, int ADimTo)
70 {
71  if (! (0 <= ADimFrom && ADimFrom < ADimTo && ADimTo <= 2))
72  return false;
73 
74  bool res = false;
76  {
78 
81 
82  int nb =
83  CMesh(FMap).meshMarkedSquares(getSelectionMark(), sx, sy, NULL,
85  ->getInterpolationMerges(),
87  ->getInterpolationSews(),
88  false, ADimFrom, ADimTo);
89 
90  std::stringstream s;
91  if (nb==0) s<<"Aucun";
92  else s<<nb;
93 
94  s<<(nb<2 ? "square meshed" : "squared meshed");
95  s<<" ["<<ADimFrom<<" -> "<<ADimTo<<"]";
96 
97  if (nb==0)
99  else
100  {
102  setModelChanged();
103  res = true;
104  }
105 
106  setMessage(s.str());
107  }
108 
109  return res;
110 }
111 //******************************************************************************
112 bool CControlerGMap::meshCubes(int ADimFrom, int ADimTo)
113 {
114  if (! (0 <= ADimFrom && ADimFrom < ADimTo && ADimTo <= 3))
115  return false;
116 
117  bool res = false;
119  {
120  undoRedoPreSave();
121 
122  if (! getParameterOperations()->getInterpolationMerges())
123  {
124  setMessage("Not yet developed!!! (the created mesh must "
125  "be merged with the original object)");
126  return false;
127  }
128 
132 
135 
136  int nb =
137  CMesh(FMap).meshMarkedCubes(getSelectionMark(), sx,sy,sz, NULL,
138  merges, sews, false, ADimFrom, ADimTo);
139 
140  std::stringstream s;
141 
142  if (nb==0) s<<"No";
143  else s<<nb;
144 
145  s<<(nb<2 ? "cube meshed" : "cubes meshed");
146  s<<" ["<<ADimFrom<<" -> "<<ADimTo<<"]";
147 
148  if (nb==0)
150  else
151  {
153  setModelChanged();
154  res = true;
155  }
156 
157  setMessage(s.str());
158  }
159  return res;
160 }
161 //******************************************************************************
163 {
164  bool res = false;
166  {
167  undoRedoPreSave();
168 
170 
171  int nb =
172  CMesh(FMap).meshMarkedEdges(getSelectionMark(), sx,
173  &getParameterOperations()->getMeshMatrix(),
174  getParameterOperations()->getSmoothMerges(),
175  getParameterOperations()->getSmoothSews());
176 
177  if (nb==0)
178  {
179  setMessage("No edge smoothed");
181  }
182  else
183  {
185  setModelChanged();
186  setMessage(nb, nb==1 ? " edge smoothed" : " edges smoothed");
187  res = true;
188  }
189  }
190 
191  return res;
192 }
193 //******************************************************************************
195 {
196  bool res = false;
198  {
199  undoRedoPreSave();
200 
203 
204  int nb =
205  CMesh(FMap).meshMarkedSquares(getSelectionMark(), sx,sy,
207  ->getMeshMatrix(),
209  ->getSmoothMerges(),
211  ->getSmoothSews());
212 
213  if (nb==0)
214  {
215  setMessage("No square smoothed");
217  }
218  else
219  {
221  setModelChanged();
222  setMessage(nb, nb==1 ? " square smoothed" : " squares smoothed");
223  res = true;
224  }
225  }
226 
227  return res;
228 }
229 //******************************************************************************
231 {
232  bool res = false;
234  {
235  if (!getParameterOperations()->getSmoothMerges())
236  {
237  setMessage("Not yet developed!!! (the created mesh must "
238  "be merged with the original object)");
239  return false;
240  }
241 
242  undoRedoPreSave();
243 
247 
248  int nb =
249  CMesh(FMap).meshMarkedCubes(getSelectionMark(), sx,sy,sz,
250  &getParameterOperations()->getMeshMatrix(),
251  getParameterOperations()->getSmoothMerges(),
252  getParameterOperations()->getSmoothSews());
253 
254  if (nb==0)
255  {
256  setMessage("No cube smoothed");
258  }
259  else
260  {
262  setModelChanged();
263  setMessage(nb, nb==1 ? " cube smoothed" : " cubes smoothed");
264  res = true;
265  }
266  }
267 
268  return res;
269 }
270 //******************************************************************************
271 #endif // MODULE_MESH
272 //******************************************************************************