Debian Codegraph @

vcg/wrap/gui/trackmode.cpp

raw symbols SCIP
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2004 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24 History
25
26 $Log: trackmode.cpp,v $
27 Revision 1.29 2008/02/26 18:00:41 benedetti
28 corrected CylinderMode::Apply
29
30 Revision 1.28 2008/02/24 18:05:08 ponchio
31 Should work as before. I didn't test cylinder and other exotic modes.
32
33 Revision 1.27 2008/02/24 14:37:00 ponchio
34 Restored trackball functionality. Not very much tested, and code will need some
35 cleanup.
36
37 Revision 1.26 2008/02/15 20:56:41 benedetti
38 removed some variable initialization related warning, added snap to CylinderMode
39
40 Revision 1.25 2007/10/24 10:39:07 ponchio
41 #include <gl/glew.h> -> #include <GL/glew.h>
42
43 (it is case sensitive under linux...)
44
45 Revision 1.24 2007/07/09 22:47:18 benedetti
46 Removed using namespace std and modified accordingly.
47
48 Revision 1.23 2007/06/13 17:15:09 benedetti
49 Added one-level undo system and sticky trackmodes.
50
51 Revision 1.22 2007/05/28 08:10:47 fiorin
52 Removed type cast warnings
53
54 Revision 1.21 2007/05/16 08:44:05 ganovelli
55 added inclusion of glew.h
56
57 Revision 1.20 2007/05/15 14:58:57 benedetti
58 Main restructuring. added many new modes
59
60 Revision 1.19 2006/08/30 07:01:54 cignoni
61 Reverted to version 1.17. Version 1.18 was wrongly done starting from a outdated version.
62
63 Revision 1.17 2006/07/26 13:54:45 cignoni
64 Reversed the direction of wheel scaling and added middle mouse panning
65
66 Revision 1.16 2006/02/13 13:10:27 cignoni
67 Added Zmode for moving objects along the perpendicular to the viewplane
68
69 Revision 1.15 2006/01/12 15:40:05 cignoni
70 Corrected small bugs on rotating after scaling+translating
71 changed void PlaneMode::Apply and void SphereMode::Apply
72
73 Revision 1.14 2005/07/15 16:39:30 callieri
74 in SphereMode::Hit added a check on the sphere intersection, if no intersection, calculating distance could generate a NAN exception
75
76 Revision 1.13 2005/06/29 15:22:26 callieri
77 changed the name of some intersection functions to avoid ambiguity
78
79 Revision 1.12 2005/02/11 11:44:07 tommyfranken
80 Trackball translation corrected
81
82 Revision 1.11 2005/02/02 16:46:41 pietroni
83 some warning corrected
84
85 Revision 1.10 2005/01/14 15:44:03 ganovelli
86 PlaneMode completed
87
88 Revision 1.9 2004/09/09 22:59:21 cignoni
89 Removed many small warnings
90
91 Revision 1.8 2004/07/18 06:54:08 cignoni
92 Added Scaling
93
94 Revision 1.7 2004/07/11 22:06:56 cignoni
95 Added scaling by wheel
96
97 Revision 1.6 2004/06/09 14:01:13 cignoni
98 Heavily restructured. To be completed only rotation works...
99
100 Revision 1.5 2004/05/14 03:15:09 ponchio
101 Redesigned partial version.
102
103 Revision 1.4 2004/05/07 12:46:08 cignoni
104 Restructured and adapted in a better way to opengl
105
106 Revision 1.3 2004/04/07 10:54:11 cignoni
107 Commented out unused parameter names and other minor warning related issues
108
109 Revision 1.2 2004/03/25 14:55:25 ponchio
110 Adding copyright.
111
112
113 ****************************************************************************/
114
115 #include <GL/glew.h>
116
117 #include <wrap/gui/trackmode.h>cxx . . $ `<file>/vcg/wrap/gui/trackmode.h`/
118 #include <wrap/gui/trackball.h>cxx . . $ `<file>/vcg/wrap/gui/trackball.h`/
119 #include <wrap/gui/trackutils.h>cxx . . $ `<file>/vcg/wrap/gui/trackutils.h`/
120
121 using namespace vcg;
122 using namespace vcgcxx . . $ vcg/::trackutils;
123
124 // the old implementation is not used anymore, some of the old support functions,
125 // like HitViewPlane, GetViewPlane, HitHyper and SphereMode::Hit were made
126 // class-independent and moved to trackutils.h
127 /*
128 void TrackMode::Apply(Trackball *trackball, float WheelNotch) {
129 }
130 void ScaleMode::Apply(Trackball *tb, Point3f new_point) {
131 }
132 Plane3f TrackMode::GetViewPlane(const View<float> &camera, const Point3f &center) {
133 }
134 Point3f TrackMode::HitViewPlane(Trackball *tb, const Point3f &p) {
135 }
136 void SphereMode::Apply(Trackball *tb, Point3f new_point) {
137 }
138 bool SphereMode::HitHyper(Point3f center, float radius, Point3f viewpoint, Plane3f vp, Point3f hitplane, Point3f &hit)
139 {
140 }
141 Point3f SphereMode::Hit(Trackball *tb, const Point3f &p) {
142 }
143 void PlaneMode::Apply(Trackball *tb, Point3f new_point) {
144
145 }
146 void ZMode::Apply(Trackball *tb, Point3f new_point) {
147 }
148 */
149
150 // Track mode implementation, dummy.
151 void TrackModecxx . . $ vcg/TrackMode#::Applycxx . . $ vcg/TrackMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * , float ){}
152
153 void TrackModecxx . . $ vcg/TrackMode#::Applycxx . . $ vcg/TrackMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * , Point3fcxx . . $ vcg/Point3f# ){}
154
155 void TrackModecxx . . $ vcg/TrackMode#::Drawcxx . . $ vcg/TrackMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * ){}
156
157 void TrackModecxx . . $ vcg/TrackMode#::SetActioncxx . . $ vcg/TrackMode#SetAction(49f6e7a06ebc5aa8). (){}
158
159 void TrackModecxx . . $ vcg/TrackMode#::Resetcxx . . $ vcg/TrackMode#Reset(49f6e7a06ebc5aa8). (){}
160
161 bool TrackModecxx . . $ vcg/TrackMode#::isStickycxx . . $ vcg/TrackMode#isSticky(c9857a73d68e59ba).() {
162 return false;
163 }
164
165 void TrackModecxx . . $ vcg/TrackMode#::Undocxx . . $ vcg/TrackMode#Undo(49f6e7a06ebc5aa8).(){}
166
167 // draw an inactive trackball
168 void InactiveModecxx . . $ vcg/InactiveMode#::Drawcxx . . $ vcg/InactiveMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
169 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,false);
170 }
171
172 // Sphere mode implementation.
173 // the most important function; given a new point in window coord,
174 // it update the transformation computed by the trackball.
175 // General scheme : the transformation is a function of just
176 // the begin and current mouse positions, with greater precision
177 // is function of just two 3d points over the manipulator.
178 void SphereModecxx . . $ vcg/SphereMode#::Applycxx . . $ vcg/SphereMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
179 {
180 Point3fcxx . . $ vcg/Point3f# hitOld = HitSpherecxx . . $ vcg/trackutils/HitSphere(973390b3fc0c6841). (tb, tb->last_pointcxx . . $ vcg/Trackball#last_point.);
181 Point3fcxx . . $ vcg/Point3f# hitNew = HitSpherecxx . . $ vcg/trackutils/HitSphere(973390b3fc0c6841). (tb, new_point);
182 tb->Hitscxx . . $ vcg/Trackball#Hits..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb). (hitNew);
183 Point3fcxx . . $ vcg/Point3f# center = tbcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).->centercxx . . $ vcg/Transform#center.;
184 Point3fcxx . . $ vcg/Point3f# axis = (hitNew -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center) ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). (hitOld -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center);
185 // Figure out how much to rotate around that axis.
186 float phi = Distancecxx . . $ vcg/Distance(1e0ebe277e908d16). (hitNew, hitOld) / tb->radiuscxx . . $ vcg/Transform#radius.;
187 // tb->track.rot = tb->last_track.rot * Quaternionf (-phi, axis);
188 tb->trackcxx . . $ vcg/Transform#track..rotcxx . . $ vcg/Similarity#rot. =cxx . . $ vcg/Quaternion#`operator=`(16b791caee783959). Quaternionfcxx . . $ vcg/Quaternion#Quaternion(4e5e266e2bc2b269). (-phi, axis) *cxx . . $ vcg/Quaternion#`operator*`(2c10525a21bddf4d). tb->last_trackcxx . . $ vcg/Trackball#last_track..rotcxx . . $ vcg/Similarity#rot.;
189 }
190
191 void SphereModecxx . . $ vcg/SphereMode#::Drawcxx . . $ vcg/SphereMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
192 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
193 }
194
195 // Pan mode implementation.
196 void PanModecxx . . $ vcg/PanMode#::Applycxx . . $ vcg/PanMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
197 {
198 Point3fcxx . . $ vcg/Point3f# hitOld = HitViewPlanecxx . . $ vcg/trackutils/HitViewPlane(973390b3fc0c6841). (tb, tb->last_pointcxx . . $ vcg/Trackball#last_point.);
199 Point3fcxx . . $ vcg/Point3f# hitNew = HitViewPlanecxx . . $ vcg/trackutils/HitViewPlane(973390b3fc0c6841). (tb, new_point);
200 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (hitNew -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). hitOld);
201 }
202
203 void PanModecxx . . $ vcg/PanMode#::Drawcxx . . $ vcg/PanMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
204 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
205 DrawUglyPanModecxx . . $ vcg/trackutils/DrawUglyPanMode(3c6e6be657895f3d).(tb);
206 }
207
208 // Z mode implementation.
209 void ZModecxx . . $ vcg/ZMode#::Applycxx . . $ vcg/ZMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * tb, float WheelNotch)
210 {
211 Point3fcxx . . $ vcg/Point3f# dir= (cxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (tb->cameracxx . . $ vcg/Trackball#camera., tb->centercxx . . $ vcg/Transform#center.)).Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).();
212 dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
213 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (dir *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). (-WheelNotch));
214 }
215
216 void ZModecxx . . $ vcg/ZMode#::Applycxx . . $ vcg/ZMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
217 {
218 Point3fcxx . . $ vcg/Point3f# dir= (cxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (tb->cameracxx . . $ vcg/Trackball#camera., tb->centercxx . . $ vcg/Transform#center.)).Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).();
219 dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
220 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (dir *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). ( -2.0f * getDeltaYcxx . . $ vcg/trackutils/getDeltaY(cd77a98eeff4ce03).(tb,new_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).)));
221 }
222
223 void ZModecxx . . $ vcg/ZMode#::Drawcxx . . $ vcg/ZMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
224 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
225 DrawUglyZModecxx . . $ vcg/trackutils/DrawUglyZMode(3c6e6be657895f3d).(tb);
226 }
227
228 // Scale mode implementation.
229 void ScaleModecxx . . $ vcg/ScaleMode#::Applycxx . . $ vcg/ScaleMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * tb, float WheelNotch)
230 {
231 tb->trackcxx . . $ vcg/Transform#track..scacxx . . $ vcg/Similarity#sca. *= powcxx . . $ pow(d59a45cd3bfd2eda). (1.2f, -WheelNotch);
232 }
233
234 void ScaleModecxx . . $ vcg/ScaleMode#::Applycxx . . $ vcg/ScaleMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
235 {
236 tb->trackcxx . . $ vcg/Transform#track..scacxx . . $ vcg/Similarity#sca. = tb->last_trackcxx . . $ vcg/Trackball#last_track..scacxx . . $ vcg/Similarity#sca. * powcxx . . $ pow(d59a45cd3bfd2eda). (3.0f, -(getDeltaYcxx . . $ vcg/trackutils/getDeltaY(cd77a98eeff4ce03).(tb,new_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).)));
237 }
238
239 void ScaleModecxx . . $ vcg/ScaleMode#::Drawcxx . . $ vcg/ScaleMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
240 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
241 DrawUglyScaleModecxx . . $ vcg/trackutils/DrawUglyScaleMode(3c6e6be657895f3d).(tb);
242 }
243
244 // Axis mode implementation.
245 void AxisModecxx . . $ vcg/AxisMode#::Applycxx . . $ vcg/AxisMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * tb, float WheelNotch)
246 {
247 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (axiscxx . . $ vcg/AxisMode#axis..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357). () *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). (WheelNotch / 10.0f));
248 }
249
250 void AxisModecxx . . $ vcg/AxisMode#::Applycxx . . $ vcg/AxisMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
251 {
252 stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#,bool > hitOld = HitNearestPointOnAxiscxx . . $ vcg/trackutils/HitNearestPointOnAxis(3c3311225a63c6d9). (tb, axiscxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f)., tbcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).->last_pointcxx . . $ vcg/Trackball#last_point.);
253 stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#,bool > hitNew = HitNearestPointOnAxiscxx . . $ vcg/trackutils/HitNearestPointOnAxis(3c3311225a63c6d9). (tb, axiscxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f)., new_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
254 if (hitOld.second && hitNew.second){
255 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (hitNew.first -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). hitOld.first);
256 }
257 }
258
259 void AxisModecxx . . $ vcg/AxisMode#::Drawcxx . . $ vcg/AxisMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
260 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
261 DrawUglyAxisModecxx . . $ vcg/trackutils/DrawUglyAxisMode(2723725398461483).(tb,axiscxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f).);
262 }
263
264 // Plane mode implementation.
265 void PlaneModecxx . . $ vcg/PlaneMode#::Applycxx . . $ vcg/PlaneMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
266 {
267 stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#, bool > hitOld = HitPlanecxx . . $ vcg/trackutils/HitPlane(588e4de9d9172459).(tb,tbcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).->last_pointcxx . . $ vcg/Trackball#last_point.,planecxx . . $ vcg/PlaneMode#plane.);
268 stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#, bool > hitNew = HitPlanecxx . . $ vcg/trackutils/HitPlane(588e4de9d9172459).(tb,new_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,planecxx . . $ vcg/PlaneMode#plane.);
269 if(hitOld.second && hitNew.second){
270 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (hitNew.first -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). hitOld.first);
271 }
272 }
273
274 void PlaneModecxx . . $ vcg/PlaneMode#::Drawcxx . . $ vcg/PlaneMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
275 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
276 DrawUglyPlaneModecxx . . $ vcg/trackutils/DrawUglyPlaneMode(ea6189cad2d31736).(tb, planecxx . . $ vcg/PlaneMode#plane.);
277 }
278
279 // Cylinder mode implementation.
280 void CylinderModecxx . . $ vcg/CylinderMode#::Applycxx . . $ vcg/CylinderMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * tb, float WheelNotch)
281 {
282 const float PI2=6.283185307179586232f;
283 float angle= (snapcxx . . $ vcg/CylinderMode#snap.==0.0) ? WheelNotch/(tb->radiuscxx . . $ vcg/Transform#radius. * PI2) : WheelNotch * snapcxx . . $ vcg/CylinderMode#snap.;
284 tb->trackcxx . . $ vcg/Transform#track..rotcxx . . $ vcg/Similarity#rot. =cxx . . $ vcg/Quaternion#`operator=`(16b791caee783959). tb->last_trackcxx . . $ vcg/Trackball#last_track..rotcxx . . $ vcg/Similarity#rot. *cxx . . $ vcg/Quaternion#`operator*`(2c10525a21bddf4d). Quaternionfcxx . . $ vcg/Quaternion#Quaternion(4e5e266e2bc2b269). (angle,axiscxx . . $ vcg/CylinderMode#axis..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).());
285 }
286
287 void CylinderModecxx . . $ vcg/CylinderMode#::Applycxx . . $ vcg/CylinderMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
288 {
289 Plane3fcxx . . $ vcg/Plane3f# viewplane=GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (tb->cameracxx . . $ vcg/Trackball#camera., tb->centercxx . . $ vcg/Transform#center.);
290 Line3fcxx . . $ vcg/Line3f# axisprojcxx . . $ vcg/Line3#Line3(49f6e7a06ebc5aa8).;
291 axisproj=cxx . . $ vcg/Line3#`operator=`(19e99af4a44c886a).ProjectLineOnPlanecxx . . $ vcg/trackutils/ProjectLineOnPlane(49131df0238fb562).(axiscxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f).,viewplane);
292 float angle;
293 const float EPSILON=0.005f; // this IS scale independent
294 if(axisproj.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).().Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() < EPSILON){
295 angle=(10.0f * getDeltaYcxx . . $ vcg/trackutils/getDeltaY(cd77a98eeff4ce03).(tb,new_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).)) / tb->radiuscxx . . $ vcg/Transform#radius.;
296 } else {
297 Point3fcxx . . $ vcg/Point3f# hitOld = HitViewPlanecxx . . $ vcg/trackutils/HitViewPlane(973390b3fc0c6841). (tb, tb->last_pointcxx . . $ vcg/Trackball#last_point.);
298 Point3fcxx . . $ vcg/Point3f# hitNew = HitViewPlanecxx . . $ vcg/trackutils/HitViewPlane(973390b3fc0c6841). (tb, new_point);
299 axisproj.Normalizecxx . . $ vcg/Line3#Normalize(4abc844e2faf5adc).();
300 Point3fcxx . . $ vcg/Point3f# plusdir= viewplane.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).() ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). axisproj.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).();
301 float distOld = signedDistancecxx . . $ vcg/trackutils/signedDistance(910fb716c289e83a).(axisproj,hitOldcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,plusdircxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
302 float distNew = signedDistancecxx . . $ vcg/trackutils/signedDistance(910fb716c289e83a).(axisproj,hitNewcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,plusdircxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
303 angle= (distNew-distOld) / tb->radiuscxx . . $ vcg/Transform#radius.;
304 }
305 if(snapcxx . . $ vcg/CylinderMode#snap.>0.0){
306 angle = ((angle<0)?-1:1)* floorcxx . . $ floor(fee4f1d22bc8e617).((((angle<0)?-angle:angle)/snapcxx . . $ vcg/CylinderMode#snap.)+0.5)*snapcxx . . $ vcg/CylinderMode#snap.;
307 }
308 // tb->track.rot = tb->last_track.rot * Quaternionf (angle,axis.Direction());
309 tb->trackcxx . . $ vcg/Transform#track..rotcxx . . $ vcg/Similarity#rot. =cxx . . $ vcg/Quaternion#`operator=`(16b791caee783959). Quaternionfcxx . . $ vcg/Quaternion#Quaternion(4e5e266e2bc2b269). (-angle,axiscxx . . $ vcg/CylinderMode#axis..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()) *cxx . . $ vcg/Quaternion#`operator*`(2c10525a21bddf4d). tb->last_trackcxx . . $ vcg/Trackball#last_track..rotcxx . . $ vcg/Similarity#rot.;
310 }
311
312 void CylinderModecxx . . $ vcg/CylinderMode#::Drawcxx . . $ vcg/CylinderMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
313 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
314 DrawUglyCylinderModecxx . . $ vcg/trackutils/DrawUglyCylinderMode(2723725398461483).(tb,axiscxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f).);
315 }
316
317 // Path mode implementation.
318 void PathModecxx . . $ vcg/PathMode#::Initcxx . . $ vcg/PathMode#Init(5d43ab4385af61b5).(const stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3fcxx . . $ vcg/Point3f# > &pts)
319 {
320 unsigned int npts = int(pts.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
321 assertcxx . . $ `/usr/include/assert.h:50:10`!(npts >= 2);
322 pointscxx . . $ vcg/PathMode#points..reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(npts);
323 for(unsigned int i=0;i<npts;i++){
324 pointscxx . . $ vcg/PathMode#points..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i]);
325 }
326 path_lengthcxx . . $ vcg/PathMode#path_length.=0.0f;
327 min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length.=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0],pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1]);
328 float seg_length;
329 for(unsigned int i=1;i<npts;i++){
330 seg_length=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-1],pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]);
331 path_lengthcxx . . $ vcg/PathMode#path_length. += seg_length;
332 min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(seg_length,min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length.);
333 }
334 if(wrapcxx . . $ vcg/PathMode#wrap.){
335 seg_length=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1],pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0]);
336 path_lengthcxx . . $ vcg/PathMode#path_length. += seg_length;
337 min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(seg_length,min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length.);
338 }
339 }
340
341 void PathModecxx . . $ vcg/PathMode#::Resetcxx . . $ vcg/PathMode#Reset(49f6e7a06ebc5aa8).()
342 {
343 current_statecxx . . $ vcg/PathMode#current_state.=initial_statecxx . . $ vcg/PathMode#initial_state.;
344 }
345
346 Point3fcxx . . $ vcg/Point3f# PathModecxx . . $ vcg/PathMode#::SetStartNearcxx . . $ vcg/PathMode#SetStartNear(6b4611f5b3558e88).(Point3fcxx . . $ vcg/Point3f# point)
347 {
348 float p0_state=0;
349 Point3fcxx . . $ vcg/Point3f# p0cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,p1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
350 float nearest_state=0;
351 Point3fcxx . . $ vcg/Point3f# nearest_point=pointscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
352 float nearest_distance=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(nearest_point,point);
353 unsigned int npts = int(pointscxx . . $ vcg/PathMode#points..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
354 for(unsigned int i = 1;i <= npts;i++){
355 if( i == npts){
356 if (wrapcxx . . $ vcg/PathMode#wrap.){
357 p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1];
358 p1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
359 } else {
360 break;
361 }
362 } else {
363 p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-1];
364 p1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i];
365 }
366 Point3fcxx . . $ vcg/Point3f# segment_point=ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(Segment3fcxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(p0,p1),point);
367 float distance=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(segment_point,point);
368 if(distance<nearest_distance){
369 nearest_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).segment_point;
370 nearest_distance=distance;
371 nearest_state=p0_state+(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(p0,nearest_point)/path_lengthcxx . . $ vcg/PathMode#path_length.);
372 }
373 float segment_norm= Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(p0,p1) / path_lengthcxx . . $ vcg/PathMode#path_length.;
374 p0_state+=segment_norm;
375 }
376 assertcxx . . $ `/usr/include/assert.h:50:10`!( nearest_state >= 0.0 );
377 if(nearest_state > 1.0){
378 nearest_state=1.0;
379 nearest_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).( wrapcxx . . $ vcg/PathMode#wrap. ? pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0] : pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1] );
380 }
381 initial_statecxx . . $ vcg/PathMode#initial_state.=nearest_state;
382 return nearest_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).;
383 }
384
385 void PathModecxx . . $ vcg/PathMode#::GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(float state, Point3fcxx . . $ vcg/Point3f# & point, Point3fcxx . . $ vcg/Point3f# & prev_point, Point3fcxx . . $ vcg/Point3f# & next_point)
386 {
387 assertcxx . . $ `/usr/include/assert.h:50:10`!(state >= 0.0f);
388 assertcxx . . $ `/usr/include/assert.h:50:10`!(state <= 1.0f);
389 float remaining_norm=state;
390 Point3fcxx . . $ vcg/Point3f# p0cxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0),p1cxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0);
391 unsigned int npts = int(pointscxx . . $ vcg/PathMode#points..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
392 for(unsigned int i = 1;i <= npts;i++){
393 if( i == npts){
394 if (wrapcxx . . $ vcg/PathMode#wrap.){
395 p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1];
396 p1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0];
397 } else {
398 break;
399 }
400 } else {
401 p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-1];
402 p1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i];
403 }
404 float segment_norm= Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(p0,p1) / path_lengthcxx . . $ vcg/PathMode#path_length.;
405 if (segment_norm < remaining_norm){
406 remaining_norm -= segment_norm;
407 continue;
408 }
409 prev_point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). p0;
410 next_point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). p1;
411 float ratio= remaining_norm / segment_norm;
412 point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). prev_point +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (( next_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). prev_point ) *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). ratio);
413 const float EPSILON=min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length. * 0.01f;
414 if(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(point,prev_point) < EPSILON){
415 point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).prev_point;
416 if (i > 1){
417 prev_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-2];
418 } else if (wrapcxx . . $ vcg/PathMode#wrap.){
419 prev_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1];
420 }
421 } else if (Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(point,next_point) < EPSILON){
422 point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).next_point;
423 if( i < (npts-1)){
424 next_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i+1];
425 } else {
426 if (wrapcxx . . $ vcg/PathMode#wrap.){
427 next_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
428 } else {
429 next_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1];
430 }
431 }
432 }
433 return;
434 }
435 // rounding errors can lead out of the for..
436 prev_point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). p0;
437 point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). p1;
438 if (wrapcxx . . $ vcg/PathMode#wrap.){
439 next_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1];
440 }else{
441 next_point =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). pointscxx . . $ vcg/PathMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).npts-1];
442 }
443 }
444
445 void PathModecxx . . $ vcg/PathMode#::Applycxx . . $ vcg/PathMode#Apply(727d76963269bc9a). (Trackballcxx . . $ vcg/Trackball# * tb, float WheelNotch)
446 {
447 undo_current_statecxx . . $ vcg/PathMode#undo_current_state.=current_statecxx . . $ vcg/PathMode#current_state.;
448 undo_old_hitpointcxx . . $ vcg/PathMode#undo_old_hitpoint.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).old_hitpointcxx . . $ vcg/PathMode#old_hitpoint.;
449
450 const float STEP_COEFF = min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length. * 0.5f;
451 float delta=(WheelNotch*STEP_COEFF)/path_lengthcxx . . $ vcg/PathMode#path_length.;
452 Point3fcxx . . $ vcg/Point3f# old_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,new_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,prev_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,next_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
453 GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(current_statecxx . . $ vcg/PathMode#current_state.,old_point,prev_point,next_point);
454 current_statecxx . . $ vcg/PathMode#current_state.=Normalizecxx . . $ vcg/PathMode#Normalize(fbcf3211dfe1bfd1).(current_statecxx . . $ vcg/PathMode#current_state.+delta);
455 GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(current_statecxx . . $ vcg/PathMode#current_state.,new_point,prev_point,next_point);
456 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (new_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). old_point);
457 }
458
459 float PathModecxx . . $ vcg/PathMode#::Normalizecxx . . $ vcg/PathMode#Normalize(fbcf3211dfe1bfd1).(float state)
460 {
461 if ( wrapcxx . . $ vcg/PathMode#wrap. ) {
462 double intpart;
463 float fractpart;
464 fractpart =(float) modfcxx . . $ modf(1bb7ebbf7cb219ee).(state,&intpart);
465 if( fractpart < 0.0f )
466 fractpart += 1.0f;
467 return fractpart;
468 }
469 if ( state < 0.0f )
470 return 0.0f;
471 if ( state > 1.0f )
472 return 1.0f;
473 return state;
474 }
475
476 int PathModecxx . . $ vcg/PathMode#::Versecxx . . $ vcg/PathMode#Verse(b8fe0f9470e92c42).(Point3fcxx . . $ vcg/Point3f# reference_point,Point3fcxx . . $ vcg/Point3f# current_point,Point3fcxx . . $ vcg/Point3f# prev_point,Point3fcxx . . $ vcg/Point3f# next_point)
477 {
478 Point3fcxx . . $ vcg/Point3f# reference_dir = reference_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). current_point ;
479 Point3fcxx . . $ vcg/Point3f# prev_dir = prev_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). current_point ;
480 Point3fcxx . . $ vcg/Point3f# next_dir = next_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). current_point ;
481 const float EPSILON=min_seg_lengthcxx . . $ vcg/PathMode#min_seg_length. * 0.005f;
482 if (reference_dir.Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() < EPSILON)
483 reference_dir =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0);
484 if (prev_dir.Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() < EPSILON)
485 prev_dir =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0);
486 if (next_dir.Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() < EPSILON)
487 next_dir =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0);
488 reference_dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
489 prev_dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
490 next_dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
491 float prev_coeff,next_coeff;
492 prev_coeff = prev_dir *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). reference_dir;
493 next_coeff = next_dir *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). reference_dir;
494 if (prev_coeff < 0.0f)
495 prev_coeff = 0.0f;
496 if (next_coeff < 0.0f)
497 next_coeff = 0.0f;
498 if( (prev_coeff == 0.0f) && (next_coeff == 0.0f)){
499 return 0;
500 }
501 if ( prev_coeff <= next_coeff ){
502 return 1;
503 }
504 return -1;
505 }
506
507 float PathModecxx . . $ vcg/PathMode#::HitPointcxx . . $ vcg/PathMode#HitPoint(c03d724e4f969feb).(float state, Ray3fNcxx . . $ vcg/Ray3fN# ray, Point3fcxx . . $ vcg/Point3f# &hit_point)
508 {
509 Point3fcxx . . $ vcg/Point3f# current_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8)., next_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8)., prev_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
510 GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(state,current_point,prev_point,next_point);
511
512 Point3fcxx . . $ vcg/Point3f# closest_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
513 closest_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ray.ClosestPointcxx . . $ vcg/Ray3#ClosestPoint(7198c4a0a81b097f).(current_point);
514 int verse=Versecxx . . $ vcg/PathMode#Verse(b8fe0f9470e92c42).(closest_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,current_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,prev_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,next_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
515 if (verse == 0){
516 hit_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).current_point;
517 return 0.0f;
518 }
519
520 Segment3fcxx . . $ vcg/Segment3f# active_segmentcxx . . $ vcg/Segment3#Segment3(49f6e7a06ebc5aa8).;
521 if (verse > 0){
522 active_segment=cxx . . $ vcg/Segment3#`operator=`(9351e96f1bd64a90).Segment3fcxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(current_point,next_point);
523 } else {
524 active_segment=cxx . . $ vcg/Segment3#`operator=`(9351e96f1bd64a90). Segment3fcxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(current_point,prev_point);
525 }
526
527 hit_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(active_segment,closest_point);
528
529 return verse * ((hit_point-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).current_point).Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() / path_lengthcxx . . $ vcg/PathMode#path_length.);
530 }
531
532 void PathModecxx . . $ vcg/PathMode#::SetActioncxx . . $ vcg/PathMode#SetAction(49f6e7a06ebc5aa8). (){
533 Point3fcxx . . $ vcg/Point3f# temp1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,temp2cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
534 GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(current_statecxx . . $ vcg/PathMode#current_state.,old_hitpointcxx . . $ vcg/PathMode#old_hitpoint.,temp1,temp2);
535 }
536
537 void PathModecxx . . $ vcg/PathMode#::Applycxx . . $ vcg/PathMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
538 {
539 undo_current_statecxx . . $ vcg/PathMode#undo_current_state.=current_statecxx . . $ vcg/PathMode#current_state.;
540 undo_old_hitpointcxx . . $ vcg/PathMode#undo_old_hitpoint.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).old_hitpointcxx . . $ vcg/PathMode#old_hitpoint.;
541
542 Ray3fNcxx . . $ vcg/Ray3fN# ray = line2raycxx . . $ vcg/Ray3#Ray3(df917d9193d4eced).(tb->cameracxx . . $ vcg/Trackball#camera..ViewLineFromWindowcxx . . $ vcg/View#ViewLineFromWindow(49e77427d541d16d). (new_point));
543 Point3fcxx . . $ vcg/Point3f# hit_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
544 float delta_state=HitPointcxx . . $ vcg/PathMode#HitPoint(c03d724e4f969feb).(current_statecxx . . $ vcg/PathMode#current_state.,ray,hit_point);
545 current_statecxx . . $ vcg/PathMode#current_state.=Normalizecxx . . $ vcg/PathMode#Normalize(fbcf3211dfe1bfd1).(current_statecxx . . $ vcg/PathMode#current_state.+delta_state);
546 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (hit_point -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). old_hitpointcxx . . $ vcg/PathMode#old_hitpoint.);
547 }
548
549 bool PathModecxx . . $ vcg/PathMode#::isStickycxx . . $ vcg/PathMode#isSticky(c9857a73d68e59ba).() {
550 return true;
551 }
552
553 void PathModecxx . . $ vcg/PathMode#::Undocxx . . $ vcg/PathMode#Undo(49f6e7a06ebc5aa8).(){
554 current_statecxx . . $ vcg/PathMode#current_state.=undo_current_statecxx . . $ vcg/PathMode#undo_current_state.;
555 old_hitpointcxx . . $ vcg/PathMode#old_hitpoint.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).undo_old_hitpointcxx . . $ vcg/PathMode#undo_old_hitpoint.;
556 }
557
558 void PathModecxx . . $ vcg/PathMode#::Drawcxx . . $ vcg/PathMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb){
559 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
560 Point3fcxx . . $ vcg/Point3f# current_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,prev_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,next_pointcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
561 GetPointscxx . . $ vcg/PathMode#GetPoints(5377b56630b10e34).(current_statecxx . . $ vcg/PathMode#current_state.,current_point,prev_point,next_point);
562 DrawUglyPathModecxx . . $ vcg/trackutils/DrawUglyPathMode(eea556f2aa4961e5).(tb,pointscxx . . $ vcg/PathMode#points.,current_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,prev_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,
563 next_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,old_hitpointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,wrapcxx . . $ vcg/PathMode#wrap.);
564 }
565
566 // Area mode implementation.
567 void AreaModecxx . . $ vcg/AreaMode#::Initcxx . . $ vcg/AreaMode#Init(5d43ab4385af61b5).(const stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3fcxx . . $ vcg/Point3f# > &pts)
568 {
569 unsigned int npts = int(pts.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
570
571 assertcxx . . $ `/usr/include/assert.h:50:10`!(npts >= 3);
572 //get the plane
573 Point3fcxx . . $ vcg/Point3f# p0=ptscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).0];
574 unsigned int onethird=(unsigned int)floorcxx . . $ floor(fee4f1d22bc8e617).(npts/3.0);
575 const float EPSILON = 0.005f;
576 bool pts_not_in_line=false;
577 Point3fcxx . . $ vcg/Point3f# acxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,bcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
578 for(unsigned int i=0;i<onethird;i++){
579 a=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(i+ onethird )%npts] -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i%npts]).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
580 b=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(i+(2*onethird))%npts] -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i%npts]).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
581 pts_not_in_line = (a ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). b).Normcxx . . $ vcg/Point3#Norm(8f5363d873dd4781).() > EPSILON;
582 if(pts_not_in_line){
583 planecxx . . $ vcg/AreaMode#plane..Initcxx . . $ vcg/Plane3#Init(318edd9dff3a835c).( pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i%npts],
584 pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(i+(onethird))%npts],
585 pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(i+(2*onethird))%npts]);
586 break;
587 }
588 }
589 assertcxx . . $ `/usr/include/assert.h:50:10`!(pts_not_in_line);
590 float ncx,ncy,ncz;
591 ncx=fabscxx . . $ fabs(fbcf3211dfe1bfd1).(planecxx . . $ vcg/AreaMode#plane..Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).()[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).0]);
592 ncy=fabscxx . . $ fabs(fbcf3211dfe1bfd1).(planecxx . . $ vcg/AreaMode#plane..Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).()[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).1]);
593 ncz=fabscxx . . $ fabs(fbcf3211dfe1bfd1).(planecxx . . $ vcg/AreaMode#plane..Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).()[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).2]);
594 if(( ncx > ncy ) && ( ncx > ncz )){
595 first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.=1;
596 second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.=2;
597 } else if(( ncy > ncx ) && ( ncy > ncz)){
598 first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.=0;
599 second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.=2;
600 } else {
601 first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.=0;
602 second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.=1;
603 }
604 pointscxx . . $ vcg/AreaMode#points..reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(npts);
605 for(unsigned int i=0;i<npts;i++){
606 pointscxx . . $ vcg/AreaMode#points..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(planecxx . . $ vcg/AreaMode#plane..Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(pts[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i]));
607 }
608 min_side_lengthcxx . . $ vcg/AreaMode#min_side_length.=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0],pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1]);
609 for(unsigned int i=1;i<npts;i++){
610 min_side_lengthcxx . . $ vcg/AreaMode#min_side_length.=stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-1],pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]),min_side_lengthcxx . . $ vcg/AreaMode#min_side_length.);
611 }
612 rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).old_statuscxx . . $ vcg/AreaMode#old_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).statuscxx . . $ vcg/AreaMode#status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).initial_statuscxx . . $ vcg/AreaMode#initial_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).p0;
613 }
614
615 void AreaModecxx . . $ vcg/AreaMode#::Resetcxx . . $ vcg/AreaMode#Reset(49f6e7a06ebc5aa8).()
616 {
617 rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).old_statuscxx . . $ vcg/AreaMode#old_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).statuscxx . . $ vcg/AreaMode#status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).initial_statuscxx . . $ vcg/AreaMode#initial_status.;
618 pathcxx . . $ vcg/AreaMode#path..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
619 }
620
621 void AreaModecxx . . $ vcg/AreaMode#::Applycxx . . $ vcg/AreaMode#Apply(dd961599e018a09). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point)
622 {
623 undo_begin_actioncxx . . $ vcg/AreaMode#undo_begin_action.=begin_actioncxx . . $ vcg/AreaMode#begin_action.;
624 undo_statuscxx . . $ vcg/AreaMode#undo_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).statuscxx . . $ vcg/AreaMode#status.;
625 undo_delta_mousecxx . . $ vcg/AreaMode#undo_delta_mouse.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).delta_mousecxx . . $ vcg/AreaMode#delta_mouse.;
626 undo_old_statuscxx . . $ vcg/AreaMode#undo_old_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).old_statuscxx . . $ vcg/AreaMode#old_status.;
627 undo_rubberband_handlecxx . . $ vcg/AreaMode#undo_rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.;
628 undo_path_indexcxx . . $ vcg/AreaMode#undo_path_index.=pathcxx . . $ vcg/AreaMode#path..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
629
630 if(begin_actioncxx . . $ vcg/AreaMode#begin_action.){
631 delta_mousecxx . . $ vcg/AreaMode#delta_mouse.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).tb->cameracxx . . $ vcg/Trackball#camera..Projectcxx . . $ vcg/View#Project(7198c4a0a81b097f).(statuscxx . . $ vcg/AreaMode#status.)-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).new_point;
632 begin_actioncxx . . $ vcg/AreaMode#begin_action.=false;
633 }
634 stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#, bool > hitNew = HitPlanecxx . . $ vcg/trackutils/HitPlane(588e4de9d9172459).(tb,new_point+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).delta_mousecxx . . $ vcg/AreaMode#delta_mouse.,planecxx . . $ vcg/AreaMode#plane.);
635 if(! hitNew.second){
636 return;
637 }
638 Point3fcxx . . $ vcg/Point3f# hit_point=hitNewcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..first;
639 Point3fcxx . . $ vcg/Point3f# delta_status=Movecxx . . $ vcg/AreaMode#Move(ebba7da48304bf4a).(statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,hit_pointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
640 statuscxx . . $ vcg/AreaMode#status. +=cxx . . $ vcg/Point3#`operator+=`(4233705dd3c5533e). delta_status;
641 tb->Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d). (statuscxx . . $ vcg/AreaMode#status. -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). old_statuscxx . . $ vcg/AreaMode#old_status.);
642 rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).hit_point;
643 }
644
645
646 void AreaModecxx . . $ vcg/AreaMode#::SetActioncxx . . $ vcg/AreaMode#SetAction(49f6e7a06ebc5aa8). ()
647 {
648 begin_actioncxx . . $ vcg/AreaMode#begin_action.=true;
649 old_statuscxx . . $ vcg/AreaMode#old_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).statuscxx . . $ vcg/AreaMode#status.;
650
651 pathcxx . . $ vcg/AreaMode#path..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
652 pathcxx . . $ vcg/AreaMode#path..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(statuscxx . . $ vcg/AreaMode#status.);
653 rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).statuscxx . . $ vcg/AreaMode#status.;
654 }
655
656 Point3fcxx . . $ vcg/Point3f# AreaModecxx . . $ vcg/AreaMode#::Movecxx . . $ vcg/AreaMode#Move(ebba7da48304bf4a).(Point3fcxx . . $ vcg/Point3f# start,Point3fcxx . . $ vcg/Point3f# end)
657 {
658 const float EPSILON=min_side_lengthcxx . . $ vcg/AreaMode#min_side_length.*0.001f;
659 Point3fcxx . . $ vcg/Point3f# pt=startcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).;
660 bool done=false;
661 bool end_inside=Insidecxx . . $ vcg/AreaMode#Inside(fb818b536fe750bb).(endcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
662 while(!done){
663 pathcxx . . $ vcg/AreaMode#path..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pt);
664 Segment3fcxx . . $ vcg/Segment3f# segmentcxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(pt,end);
665 bool p_on_side = false;
666 bool hit=false;
667
668 Point3fcxx . . $ vcg/Point3f# psidecxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0),phitcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0);
669 bool slide=false,mid_inside;
670
671 int np = int(pointscxx . . $ vcg/AreaMode#points..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()), i, j;
672 for (i = 0, j = np-1; i < np; j = i++) {
673 Segment3fcxx . . $ vcg/Segment3f# sidecxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i],pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j]);
674 Point3fcxx . . $ vcg/Point3f# psegcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,psidcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).;
675 stdcxx . . $ std/::pair<float,bool> res=SegmentSegmentDistancecxx . . $ vcg/trackutils/SegmentSegmentDistance(da606baca246057e).(segment,side,pseg,psid);
676 if(res.first < EPSILON && ! res.second){
677 float dist= Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pt,pseg);
678 if(dist < EPSILON){
679 Point3fcxx . . $ vcg/Point3f# pn=ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(side,end);
680 if(!p_on_side || (Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pn,end)<Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(end,pside))){
681 pside=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pn;
682 p_on_side=true;
683 }
684 } else {
685 if (!hit || Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pt,pseg) < Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pt,phit)){
686 phit=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pseg;
687 hit=true;
688 }
689 }
690 }
691 }
692 if (p_on_side)
693 slide = Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(pside,pt) > EPSILON;
694
695 if (hit)
696 mid_inside = Insidecxx . . $ vcg/AreaMode#Inside(fb818b536fe750bb).( pt +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). ( ( phit -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). pt ) /cxx . . $ vcg/Point3#`operator/`(19a42edf8b0c4f9d). 2) );
697
698 if ( !hit && end_inside ){
699 pt =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). end;
700 done = true;
701 } else if ( hit && (!p_on_side || (p_on_side && mid_inside))) {
702 pt =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). phit;
703 } else if ( p_on_side && slide) {
704 pt =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). pside;
705 } else {
706 done = true;
707 }
708 }
709 pathcxx . . $ vcg/AreaMode#path..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(pt);
710 return pt -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). start;
711 }
712
713 // adapted from the original C code by W. Randolph Franklin
714 // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
715 bool AreaModecxx . . $ vcg/AreaMode#::Insidecxx . . $ vcg/AreaMode#Inside(fb818b536fe750bb).(Point3fcxx . . $ vcg/Point3f# point)
716 {
717 bool inside=false;
718 float x=point[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.];
719 float y=point[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.];
720 float yi, yj, xi, xj;
721 int i, j, np=int(pointscxx . . $ vcg/AreaMode#points..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
722 for (i = 0, j = np-1; i < np; j = i++) {
723 xi=pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.];
724 yi=pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.];
725 xj=pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).first_coord_keptcxx . . $ vcg/AreaMode#first_coord_kept.];
726 yj=pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).second_coord_keptcxx . . $ vcg/AreaMode#second_coord_kept.];
727 if ( ( ( (yi<=y) && (y<yj) ) || ( (yj<=y) && (y<yi) ) ) &&
728 ( x < ( xj - xi ) * ( y - yi ) / ( yj - yi ) + xi ) )
729 {
730 inside=!inside;
731 }
732 }
733 return inside;
734 }
735
736 Point3fcxx . . $ vcg/Point3f# AreaModecxx . . $ vcg/AreaMode#::SetStartNearcxx . . $ vcg/AreaMode#SetStartNear(6b4611f5b3558e88).(Point3fcxx . . $ vcg/Point3f# point)
737 {
738 Point3fcxx . . $ vcg/Point3f# candidate=planecxx . . $ vcg/AreaMode#plane..Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(point);
739 if (Insidecxx . . $ vcg/AreaMode#Inside(fb818b536fe750bb).(candidatecxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).)){
740 initial_statuscxx . . $ vcg/AreaMode#initial_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).candidate;
741 return initial_statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).;
742 }
743 Point3fcxx . . $ vcg/Point3f# nearest_point=initial_statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).;
744 float nearest_distance=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(nearest_point,candidate);
745 int i, j, np=int(pointscxx . . $ vcg/AreaMode#points..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
746 for (i = 0, j = np-1; i < np; j = i++) {
747 Segment3fcxx . . $ vcg/Segment3f# sidecxx . . $ vcg/Segment3#Segment3(d881d180352d7f4a).(pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i],pointscxx . . $ vcg/AreaMode#points.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j]);
748 Point3fcxx . . $ vcg/Point3f# side_point=ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(side,candidate);
749 float distance=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(side_point,candidate);
750 if( distance < nearest_distance ){
751 nearest_point=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).side_point;
752 nearest_distance=distance;
753 }
754 }
755 initial_statuscxx . . $ vcg/AreaMode#initial_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).nearest_point;
756 return initial_statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).;
757 }
758
759 bool AreaModecxx . . $ vcg/AreaMode#::isStickycxx . . $ vcg/AreaMode#isSticky(c9857a73d68e59ba).() {
760 return true;
761 }
762
763 void AreaModecxx . . $ vcg/AreaMode#::Undocxx . . $ vcg/AreaMode#Undo(49f6e7a06ebc5aa8).(){
764 begin_actioncxx . . $ vcg/AreaMode#begin_action.=undo_begin_actioncxx . . $ vcg/AreaMode#undo_begin_action.;
765 statuscxx . . $ vcg/AreaMode#status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).undo_statuscxx . . $ vcg/AreaMode#undo_status.;
766 delta_mousecxx . . $ vcg/AreaMode#delta_mouse.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).undo_delta_mousecxx . . $ vcg/AreaMode#undo_delta_mouse.;
767 old_statuscxx . . $ vcg/AreaMode#old_status.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).undo_old_statuscxx . . $ vcg/AreaMode#undo_old_status.;
768 rubberband_handlecxx . . $ vcg/AreaMode#rubberband_handle.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).undo_rubberband_handlecxx . . $ vcg/AreaMode#undo_rubberband_handle.;
769 for(unsigned int i=pathcxx . . $ vcg/AreaMode#path..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() - 1; i > undo_path_indexcxx . . $ vcg/AreaMode#undo_path_index.; --i)
770 pathcxx . . $ vcg/AreaMode#path..pop_backcxx . . $ std/vector#pop_back(ced63f7c635d850d).();
771 }
772
773 void AreaModecxx . . $ vcg/AreaMode#::Drawcxx . . $ vcg/AreaMode#Draw(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb)
774 {
775 DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a).(tb,true );
776 DrawUglyAreaModecxx . . $ vcg/trackutils/DrawUglyAreaMode(da0f49b836d7f101).(tb,pointscxx . . $ vcg/AreaMode#points.,statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,old_statuscxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,planecxx . . $ vcg/AreaMode#plane.,pathcxx . . $ vcg/AreaMode#path.,rubberband_handlecxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).);
777 }