Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operations-materialization.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 {
35  {
37  FMap->materializeBarycenter(getSelectionMark());
39 
41  setMessage("Barycenter materialized");
42  return true;
43  }
44 
45  return false;
46 }
47 //******************************************************************************
49 {
52  {
53  CDart *d1, *d2;
54 
55  if (FMap->getMarkedCells(ORBIT_VERTEX, getSelectionMark(),
56  getLastSelectedDart(), &d2,&d1) != 2)
57  {
58  setMessage("Selection not correct: we need two darts");
59  return false;
60  }
61 
63  CDart * d= FMap->materializeAxe(d1,d2);
66  FMap->markOrbit(d,ORBIT_EDGE, getSelectionMark());
67  selectDart(d);
68 
70  setMessage("Axis materialized");
71  return true;
72  }
73  return false;
74 }
75 //******************************************************************************
77 {
80  {
81  CDart *d1, *d2, *d3;
82 
83  if (FMap->getMarkedCells(ORBIT_VERTEX, getSelectionMark(),
84  getLastSelectedDart(), &d3,&d2,&d1) != 3)
85  {
86  setMessage("Selection not correct: we need three darts");
87  return false;
88  }
89 
91  CDart * d= FMap->materializePlane(d1,d2,d3);
94  FMap->markOrbit(d,ORBIT_FACE, getSelectionMark());
95  selectDart(d);
96 
98  setMessage("Plane materialized");
99  return true;
100  }
101  return false;
102 }
103 //******************************************************************************
105 {
108  {
109  CDart * last = getLastSelectedDart();
110 
111  if (last==NULL ||
112  FMap->getMarkedCells(ORBIT_FACE, getSelectionMark()) != 1 ||
113  FMap->getNbPolylineVertices(last) < 3)
114  {
115  setMessage("Selection not correct");
116  return false;
117  }
118 
119  undoRedoPreSave();
120  CDart * d= FMap->materializeNormalVector(last);
123  FMap->markOrbit(d,ORBIT_EDGE, getSelectionMark());
124  selectDart(d);
125 
126  setModelChanged();
127  setMessage("Normal vector materialized");
128  return true;
129  }
130  return false;
131 }
132 //******************************************************************************
134 {
137  {
138  CDart *d1, *d2;
139 
140  CDart * last = getLastSelectedDart();
141 
142  if (last==NULL ||
143  FMap->getMarkedCells(ORBIT_VERTEX, getSelectionMark(),
144  last, &d2, &d1) != 2)
145  {
146  setMessage("Selection not correct");
147  return false;
148  }
149 
150  undoRedoPreSave();
151  CDart * d= FMap->materializeNormalPlane(d1,d2);
154  FMap->markOrbit(d,ORBIT_FACE, getSelectionMark());
155  selectDart(d);
156 
157  setModelChanged();
158  setMessage("Normal plane materialized");
159  return true;
160  }
161  return false;
162 }
163 //******************************************************************************
165 {
168  {
169  undoRedoPreSave();
170  FMap->materializeReferential();
172 
173  setModelChanged();
174  setMessage("Referential materialized");
175  return false;
176  }
177  return false;
178 }
179 //******************************************************************************