~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/winged_edge/WXEdge.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software Foundation,
 
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 *
 
18
 * ***** END GPL LICENSE BLOCK *****
 
19
 */
 
20
 
 
21
#ifndef __FREESTYLE_WX_EDGE_H__
 
22
#define __FREESTYLE_WX_EDGE_H__
 
23
 
 
24
/** \file blender/freestyle/intern/winged_edge/WXEdge.h
 
25
 *  \ingroup freestyle
 
26
 *  \brief Classes to define an Extended Winged Edge data structure.
 
27
 *  \author Stephane Grabli
 
28
 *  \date 26/10/2003
 
29
 */
 
30
 
 
31
#include "Curvature.h"
 
32
#include "Nature.h"
 
33
#include "WEdge.h"
 
34
 
 
35
#ifdef WITH_CXX_GUARDEDALLOC
 
36
#include "MEM_guardedalloc.h"
 
37
#endif
 
38
 
 
39
namespace Freestyle {
 
40
 
 
41
typedef Nature::EdgeNature WXNature;
 
42
 
 
43
/**********************************
 
44
 *                                *
 
45
 *                                *
 
46
 *             WXVertex           *
 
47
 *                                *
 
48
 *                                *
 
49
 **********************************/
 
50
 
 
51
class WXVertex : public WVertex
 
52
{
 
53
private:
 
54
        // Curvature info
 
55
        CurvatureInfo *_curvatures;
 
56
 
 
57
public:
 
58
        inline WXVertex(const Vec3r &v) : WVertex(v)
 
59
        {
 
60
                _curvatures = NULL;
 
61
        }
 
62
 
 
63
        /*! Copy constructor */
 
64
        WXVertex(WXVertex& iBrother) : WVertex(iBrother)
 
65
        {
 
66
                _curvatures = new CurvatureInfo(*iBrother._curvatures);
 
67
        }
 
68
 
 
69
        virtual WVertex *duplicate()
 
70
        {
 
71
                WXVertex *clone = new WXVertex(*this);
 
72
                return clone;
 
73
        }
 
74
 
 
75
        virtual ~WXVertex()
 
76
        {
 
77
                if (_curvatures)
 
78
                        delete _curvatures;
 
79
        }
 
80
 
 
81
        virtual void Reset()
 
82
        {
 
83
                if (_curvatures)
 
84
                        _curvatures->Kr = 0.0;
 
85
        }
 
86
 
 
87
        inline void setCurvatures(CurvatureInfo *ci)
 
88
        {
 
89
                _curvatures = ci;
 
90
        }
 
91
 
 
92
        inline bool isFeature();
 
93
 
 
94
        inline CurvatureInfo *curvatures()
 
95
        {
 
96
                return _curvatures;
 
97
        }
 
98
};
 
99
 
 
100
 
 
101
/**********************************
 
102
 *                                *
 
103
 *                                *
 
104
 *             WXEdge             *
 
105
 *                                *
 
106
 *                                *
 
107
 **********************************/
 
108
 
 
109
class WXEdge : public WEdge
 
110
{
 
111
private:
 
112
        // flag to indicate whether the edge is a silhouette edge or not
 
113
        WXNature _nature;
 
114
        // 0: the order doesn't matter. 1: the order is the orginal one. -1: the order is not good
 
115
        int _order;
 
116
        // A front facing edge is an edge for which the bording face which is the nearest from the viewpoint is front.
 
117
        // A back facing edge is the opposite.
 
118
        bool _front;
 
119
 
 
120
public:
 
121
        inline WXEdge() : WEdge()
 
122
        {
 
123
                _nature = Nature::NO_FEATURE;
 
124
                _front = false;
 
125
                _order = 0;
 
126
        }
 
127
 
 
128
        inline WXEdge(WOEdge *iOEdge) : WEdge(iOEdge)
 
129
        {
 
130
                _nature = Nature::NO_FEATURE;
 
131
                _front = false;
 
132
                _order = 0;
 
133
        }
 
134
 
 
135
        inline WXEdge(WOEdge *iaOEdge, WOEdge *ibOEdge) : WEdge(iaOEdge, ibOEdge)
 
136
        {
 
137
                _nature = Nature::NO_FEATURE;
 
138
                _front = false;
 
139
                _order = 0;
 
140
        }
 
141
 
 
142
        /*! Copy constructor */
 
143
        inline WXEdge(WXEdge& iBrother) : WEdge(iBrother)
 
144
        {
 
145
                _nature = iBrother.nature();
 
146
                _front = iBrother._front;
 
147
                _order = iBrother._order;
 
148
        }
 
149
 
 
150
        virtual WEdge *duplicate()
 
151
        {
 
152
                WXEdge *clone = new WXEdge(*this);
 
153
                return clone;
 
154
        }
 
155
 
 
156
        virtual ~WXEdge() {}
 
157
 
 
158
        virtual void Reset()
 
159
        {
 
160
                _nature  = _nature & ~Nature::SILHOUETTE;
 
161
                _nature  = _nature & ~Nature::SUGGESTIVE_CONTOUR;
 
162
        }
 
163
 
 
164
        /*! accessors */
 
165
        inline WXNature nature()
 
166
        {
 
167
                return _nature;
 
168
        }
 
169
 
 
170
        inline bool front()
 
171
        {
 
172
                return _front;
 
173
        }
 
174
 
 
175
        inline int order() const
 
176
        {
 
177
                return _order;
 
178
        }
 
179
 
 
180
        /*! modifiers */
 
181
        inline void setFront(bool iFront)
 
182
        {
 
183
                _front = iFront;
 
184
        }
 
185
 
 
186
        inline void setNature(WXNature iNature)
 
187
        {
 
188
                _nature = iNature;
 
189
        }
 
190
 
 
191
        inline void AddNature(WXNature iNature)
 
192
        {
 
193
                _nature = _nature | iNature;
 
194
        }
 
195
 
 
196
        inline void setOrder(int i)
 
197
        {
 
198
                _order = i;
 
199
        }
 
200
};
 
201
 
 
202
/**********************************
 
203
 *                                *
 
204
 *                                *
 
205
 *             WXFace             *
 
206
 *                                *
 
207
 *                                *
 
208
 **********************************/
 
209
 
 
210
/*! Class to store a smooth edge (i.e Hertzman & Zorin smooth silhouette edges) */
 
211
class WXSmoothEdge
 
212
{
 
213
public:
 
214
        typedef enum {
 
215
                EDGE_EDGE,
 
216
                VERTEX_EDGE,
 
217
                EDGE_VERTEX,
 
218
        } Configuration;
 
219
 
 
220
        WOEdge *_woea; // Oriented edge from which the silhouette edge starts
 
221
        WOEdge *_woeb; // Oriented edge where the silhouette edge ends
 
222
        real _ta;      // The silhouette starting point's coordinates are : _woea[0]+ta*(_woea[1]-_woea[0])
 
223
        real _tb;      // The silhouette ending point's coordinates are : _woeb[0]+ta*(_woeb[1]-_woeb[0])
 
224
        bool _front;
 
225
        Configuration _config;
 
226
 
 
227
        WXSmoothEdge()
 
228
        {
 
229
                _woea = NULL;
 
230
                _woeb = NULL;
 
231
                _ta = 0;
 
232
                _tb = 0;
 
233
                _front = false;
 
234
                _config = EDGE_EDGE;
 
235
        }
 
236
 
 
237
        WXSmoothEdge(const WXSmoothEdge& iBrother)
 
238
        {
 
239
                _woea = iBrother._woea;
 
240
                _woeb = iBrother._woeb;
 
241
                _ta = iBrother._ta;
 
242
                _tb = iBrother._tb;
 
243
                _config = iBrother._config;
 
244
                _front = iBrother._front;
 
245
        }
 
246
 
 
247
        ~WXSmoothEdge() {}
 
248
 
 
249
        inline WOEdge *woea()
 
250
        {
 
251
                return _woea;
 
252
        }
 
253
 
 
254
        inline WOEdge *woeb()
 
255
        {
 
256
                return _woeb;
 
257
        }
 
258
 
 
259
        inline real ta() const
 
260
        {
 
261
                return _ta;
 
262
        }
 
263
 
 
264
        inline real tb() const
 
265
        {
 
266
                return _tb;
 
267
        }
 
268
 
 
269
        inline bool front() const
 
270
        {
 
271
                return _front;
 
272
        }
 
273
 
 
274
        inline Configuration configuration() const
 
275
        {
 
276
                return _config;
 
277
        }
 
278
 
 
279
        /*! modifiers */
 
280
        inline void setWOeA(WOEdge *iwoea)
 
281
        {
 
282
                _woea = iwoea;
 
283
        }
 
284
 
 
285
        inline void setWOeB(WOEdge *iwoeb)
 
286
        {
 
287
                _woeb = iwoeb;
 
288
        }
 
289
 
 
290
        inline void setTa(real ta)
 
291
        {
 
292
                _ta = ta;
 
293
        }
 
294
 
 
295
        inline void setTb(real tb)
 
296
        {
 
297
                _tb = tb;
 
298
        }
 
299
 
 
300
        inline void setFront(bool iFront)
 
301
        {
 
302
                _front = iFront;
 
303
        }
 
304
 
 
305
        inline void setConfiguration(Configuration iConf)
 
306
        {
 
307
                _config = iConf;
 
308
        }
 
309
 
 
310
#ifdef WITH_CXX_GUARDEDALLOC
 
311
        MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXSmoothEdge")
 
312
#endif
 
313
};
 
314
 
 
315
/* Class to store a value per vertex and a smooth edge.
 
316
 * The WXFace stores a list of these
 
317
 */
 
318
class WXFace;
 
319
 
 
320
class LIB_WINGED_EDGE_EXPORT WXFaceLayer
 
321
{
 
322
public:
 
323
        void *userdata;
 
324
        WXFace *_pWXFace;
 
325
        // in case of silhouette: the values obtained when computing the normal-view direction dot product. _DotP[i] is
 
326
        // this value for the vertex i for that face.
 
327
        vector<real> _DotP;
 
328
        WXSmoothEdge *_pSmoothEdge;
 
329
        WXNature _Nature;
 
330
 
 
331
        //oldtmp values
 
332
        // count the number of positive dot products for vertices.
 
333
        // if this number is != 0 and !=_DotP.size() -> it is a silhouette fac
 
334
        unsigned _nPosDotP;
 
335
 
 
336
        unsigned _nNullDotP; // count the number of null dot products for vertices.
 
337
        unsigned _ClosestPointIndex;
 
338
        bool _viewDependant;
 
339
 
 
340
        WXFaceLayer(WXFace *iFace, WXNature iNature, bool viewDependant)
 
341
        {
 
342
                _pWXFace = iFace;
 
343
                _pSmoothEdge = NULL;
 
344
                _nPosDotP = 0;
 
345
                _nNullDotP = 0;
 
346
                _Nature = iNature;
 
347
                _viewDependant = viewDependant;
 
348
                userdata = NULL;
 
349
        }
 
350
 
 
351
        WXFaceLayer(const WXFaceLayer& iBrother)
 
352
        {
 
353
                _pWXFace = iBrother._pWXFace;
 
354
                _pSmoothEdge = NULL;
 
355
                _DotP = iBrother._DotP;
 
356
                _nPosDotP = iBrother._nPosDotP;
 
357
                _nNullDotP = iBrother._nNullDotP;
 
358
                _Nature = iBrother._Nature;
 
359
                if (iBrother._pSmoothEdge) {  // XXX ? It's set to null a few lines above!
 
360
                        _pSmoothEdge = new WXSmoothEdge(*(iBrother._pSmoothEdge));
 
361
                }
 
362
                _viewDependant = iBrother._viewDependant;
 
363
                userdata = NULL;
 
364
        }
 
365
 
 
366
        virtual ~WXFaceLayer()
 
367
        {
 
368
                if (!_DotP.empty())
 
369
                        _DotP.clear();
 
370
                if (_pSmoothEdge) {
 
371
                        delete _pSmoothEdge;
 
372
                        _pSmoothEdge = NULL;
 
373
                }
 
374
        }
 
375
 
 
376
        inline const real dotP(int i) const
 
377
        {
 
378
                return _DotP[i];
 
379
        }
 
380
 
 
381
        inline unsigned nPosDotP() const
 
382
        {
 
383
                return _nPosDotP;
 
384
        }
 
385
 
 
386
        inline unsigned nNullDotP() const
 
387
        {
 
388
                return _nNullDotP;
 
389
        }
 
390
 
 
391
        inline int closestPointIndex() const
 
392
        {
 
393
                return _ClosestPointIndex;
 
394
        }
 
395
 
 
396
        inline Nature::EdgeNature nature() const
 
397
        {
 
398
                return _Nature;
 
399
        }
 
400
 
 
401
        inline bool hasSmoothEdge() const
 
402
        {
 
403
                if (_pSmoothEdge)
 
404
                        return true;
 
405
                return false;
 
406
        }
 
407
 
 
408
        inline WXFace *getFace()
 
409
        {
 
410
                return _pWXFace;
 
411
        }
 
412
 
 
413
        inline WXSmoothEdge *getSmoothEdge()
 
414
        {
 
415
                return _pSmoothEdge;
 
416
        }
 
417
 
 
418
        inline bool isViewDependant() const
 
419
        {
 
420
                return _viewDependant;
 
421
        }
 
422
 
 
423
        inline void setClosestPointIndex(int iIndex)
 
424
        {
 
425
                _ClosestPointIndex = iIndex;
 
426
        }
 
427
 
 
428
        inline void removeSmoothEdge()
 
429
        {
 
430
                if (!_DotP.empty())
 
431
                        _DotP.clear();
 
432
                if (_pSmoothEdge) {
 
433
                        delete _pSmoothEdge;
 
434
                        _pSmoothEdge = NULL;
 
435
                }
 
436
        }
 
437
 
 
438
        /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where it happens */
 
439
        unsigned int Get0VertexIndex() const;
 
440
 
 
441
        /*! In case one of the edge of the triangle is a smooth edge, this method allows to retrieve the concerned edge */
 
442
        unsigned int GetSmoothEdgeIndex() const;
 
443
 
 
444
        /*! retrieves the edges of the triangle for which the signs are different (a null value is not considered) for
 
445
         *  the dotp values at each edge extrimity
 
446
         */
 
447
        void RetrieveCuspEdgesIndices(vector<int>& oCuspEdges);
 
448
 
 
449
        WXSmoothEdge *BuildSmoothEdge();
 
450
 
 
451
        inline void setDotP(const vector<real>& iDotP)
 
452
        {
 
453
                _DotP = iDotP;
 
454
        }
 
455
 
 
456
        inline void PushDotP(real iDotP)
 
457
        {
 
458
                _DotP.push_back(iDotP);
 
459
                if (iDotP > 0)
 
460
                        ++_nPosDotP;
 
461
                if (iDotP == 0)
 
462
                        ++_nNullDotP;
 
463
        }
 
464
 
 
465
        inline void ReplaceDotP(unsigned int index, real newDotP)
 
466
        {
 
467
                _DotP[index] = newDotP;
 
468
                updateDotPInfos();
 
469
        }
 
470
 
 
471
        inline void updateDotPInfos()
 
472
        {
 
473
                _nPosDotP = 0;
 
474
                _nNullDotP = 0;
 
475
                for (vector<real>::iterator d = _DotP.begin(), dend = _DotP.end(); d != dend; ++d) {
 
476
                        if ((*d) > 0)
 
477
                                ++_nPosDotP;
 
478
                        if ((*d) == 0)
 
479
                                ++_nNullDotP;
 
480
                }
 
481
        }
 
482
 
 
483
#ifdef WITH_CXX_GUARDEDALLOC
 
484
        MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXFaceLayer")
 
485
#endif
 
486
};
 
487
 
 
488
class WXFace : public WFace
 
489
{
 
490
protected:
 
491
        Vec3r _center; // center of the face
 
492
        real _Z; // distance from viewpoint to the center of the face
 
493
        bool _front; // flag to tell whether the face is front facing or back facing
 
494
        real _dotp;  // value obtained when computing the normal-viewpoint dot product
 
495
 
 
496
        vector<WXFaceLayer *> _SmoothLayers; // The data needed to store one or several smooth edges that traverse the face
 
497
 
 
498
public:
 
499
        inline WXFace() : WFace()
 
500
        {
 
501
                _Z = 0.0;
 
502
                _front = false;
 
503
        }
 
504
 
 
505
        /*! Copy constructor */
 
506
        WXFace(WXFace& iBrother) : WFace(iBrother)
 
507
        {
 
508
                _center = iBrother.center();
 
509
                _Z = iBrother.Z();
 
510
                _front = iBrother.front();
 
511
                for (vector<WXFaceLayer*>::iterator wxf = iBrother._SmoothLayers.begin(), wxfend = iBrother._SmoothLayers.end();
 
512
                     wxf != wxfend;
 
513
                     ++wxf)
 
514
                {
 
515
                        _SmoothLayers.push_back(new WXFaceLayer(**wxf));
 
516
                }
 
517
        }
 
518
 
 
519
        virtual WFace *duplicate()
 
520
        {
 
521
                WXFace *clone = new WXFace(*this);
 
522
                return clone;
 
523
        }
 
524
 
 
525
        virtual ~WXFace()
 
526
        {
 
527
                if (!_SmoothLayers.empty()) {
 
528
                        for (vector<WXFaceLayer*>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
529
                             wxf != wxfend;
 
530
                             ++wxf)
 
531
                        {
 
532
                                delete (*wxf);
 
533
                        }
 
534
                        _SmoothLayers.clear();
 
535
                }
 
536
        }
 
537
 
 
538
        /*! designed to build a specialized WEdge for use in MakeEdge */
 
539
        virtual WEdge *instanciateEdge() const
 
540
        {
 
541
                return new WXEdge;
 
542
        }
 
543
 
 
544
        /*! accessors */
 
545
        inline Vec3r& center()
 
546
        {
 
547
                return _center;
 
548
        }
 
549
 
 
550
        inline real Z()
 
551
        {
 
552
                return _Z;
 
553
        }
 
554
 
 
555
        inline bool front()
 
556
        {
 
557
                return _front;
 
558
        }
 
559
 
 
560
        inline real dotp()
 
561
        {
 
562
                return _dotp;
 
563
        }
 
564
 
 
565
        inline bool hasSmoothEdges() const
 
566
        {
 
567
                for (vector<WXFaceLayer*>::const_iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
568
                     wxf != wxfend;
 
569
                     ++wxf)
 
570
                {
 
571
                        if ((*wxf)->hasSmoothEdge()) {
 
572
                                return true;
 
573
                        }
 
574
                }
 
575
                return false;
 
576
        }
 
577
 
 
578
        vector<WXFaceLayer*>& getSmoothLayers()
 
579
        {
 
580
                return _SmoothLayers;
 
581
        }
 
582
 
 
583
        /*! retrieve the smooth edges that match the Nature given as argument */
 
584
        void retrieveSmoothEdges(WXNature iNature, vector<WXSmoothEdge *>& oSmoothEdges)
 
585
        {
 
586
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
587
                     wxf != wxfend;
 
588
                     ++wxf)
 
589
                {
 
590
                        if ((*wxf)->hasSmoothEdge() && ((*wxf)->_Nature & iNature)) {
 
591
                                oSmoothEdges.push_back((*wxf)->_pSmoothEdge);
 
592
                        }
 
593
                }
 
594
        }
 
595
 
 
596
        void retrieveSmoothEdgesLayers(WXNature iNature, vector<WXFaceLayer *>& oSmoothEdgesLayers)
 
597
        {
 
598
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
599
                     wxf != wxfend;
 
600
                     ++wxf)
 
601
                {
 
602
                        if ((*wxf)->hasSmoothEdge() && ((*wxf)->_Nature & iNature)) {
 
603
                                oSmoothEdgesLayers.push_back((*wxf));
 
604
                        }
 
605
                }
 
606
        }
 
607
 
 
608
        void retrieveSmoothLayers(WXNature iNature, vector<WXFaceLayer *>& oSmoothLayers)
 
609
        {
 
610
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
611
                     wxf != wxfend;
 
612
                     ++wxf)
 
613
                {
 
614
                        if ((*wxf)->_Nature & iNature) {
 
615
                                oSmoothLayers.push_back(*wxf);
 
616
                        }
 
617
                }
 
618
        }
 
619
 
 
620
        /*! modifiers */
 
621
        inline void setCenter(const Vec3r& iCenter)
 
622
        {
 
623
                _center = iCenter;
 
624
        }
 
625
 
 
626
        void ComputeCenter();
 
627
 
 
628
        inline void setZ(real z)
 
629
        {
 
630
                _Z = z;
 
631
        }
 
632
 
 
633
        inline void setFront(bool iFront)
 
634
        {
 
635
                _front = iFront;
 
636
        }
 
637
 
 
638
        inline void setDotP(real iDotP)
 
639
        {
 
640
                _dotp = iDotP;
 
641
                if (_dotp > 0)
 
642
                        _front = true;
 
643
                else
 
644
                        _front = false;
 
645
        }
 
646
 
 
647
        inline void AddSmoothLayer(WXFaceLayer *iLayer)
 
648
        {
 
649
                _SmoothLayers.push_back(iLayer);
 
650
        }
 
651
 
 
652
        inline void Reset()
 
653
        {
 
654
                vector<WXFaceLayer *> layersToKeep;
 
655
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
656
                     wxf != wxfend;
 
657
                     ++wxf)
 
658
                {
 
659
                        if ((*wxf)->isViewDependant())
 
660
                                delete (*wxf);
 
661
                        else
 
662
                                layersToKeep.push_back(*wxf);
 
663
                }
 
664
                _SmoothLayers = layersToKeep;
 
665
        }
 
666
 
 
667
        /*! Clears everything */
 
668
        inline void Clear()
 
669
        {
 
670
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
671
                     wxf != wxfend;
 
672
                     ++wxf)
 
673
                {
 
674
                        delete (*wxf);
 
675
                }
 
676
                _SmoothLayers.clear();
 
677
        }
 
678
 
 
679
        virtual void ResetUserData()
 
680
        {
 
681
                WFace::ResetUserData();
 
682
                for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
 
683
                     wxf != wxfend;
 
684
                     ++wxf)
 
685
                {
 
686
                        (*wxf)->userdata = NULL;
 
687
                }
 
688
        }
 
689
};
 
690
 
 
691
 
 
692
/**********************************
 
693
 *                                *
 
694
 *                                *
 
695
 *             WXShape            *
 
696
 *                                *
 
697
 *                                *
 
698
 **********************************/
 
699
 
 
700
class WXShape : public WShape
 
701
{
 
702
public:
 
703
        typedef WXShape type_name;
 
704
 
 
705
protected:
 
706
        bool _computeViewIndependant; // flag to indicate whether the view independant stuff must be computed or not
 
707
 
 
708
public:
 
709
        inline WXShape() : WShape()
 
710
        {
 
711
                _computeViewIndependant = true;
 
712
        }
 
713
 
 
714
        /*! copy constructor */
 
715
        inline WXShape(WXShape& iBrother) : WShape(iBrother)
 
716
        {
 
717
                _computeViewIndependant = iBrother._computeViewIndependant;
 
718
        }
 
719
 
 
720
        virtual WShape *duplicate()
 
721
        {
 
722
                WXShape *clone = new WXShape(*this);
 
723
                return clone;
 
724
        }
 
725
 
 
726
        virtual ~WXShape() {}
 
727
 
 
728
        inline bool getComputeViewIndependantFlag() const
 
729
        {
 
730
                return _computeViewIndependant;
 
731
        }
 
732
 
 
733
        inline void setComputeViewIndependantFlag(bool iFlag)
 
734
        {
 
735
                _computeViewIndependant = iFlag;
 
736
        }
 
737
 
 
738
        /*! designed to build a specialized WFace for use in MakeFace */
 
739
        virtual WFace *instanciateFace() const
 
740
        {
 
741
                return new WXFace;
 
742
        }
 
743
 
 
744
        /*! adds a new face to the shape returns the built face.
 
745
         *   iVertexList
 
746
         *      List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed
 
747
         *      to be already stored when calling MakeFace. The order in which the vertices are stored in the list
 
748
         *      determines the face's edges orientation and (so) the face orientation.
 
749
         */
 
750
        virtual WFace *MakeFace(vector<WVertex *>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex);
 
751
 
 
752
        /*! adds a new face to the shape. The difference with the previous method is that this one is designed to build
 
753
         *  a WingedEdge structure for which there are per vertex normals, opposed to per face normals.
 
754
         *  returns the built face.
 
755
         *   iVertexList
 
756
         *      List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
 
757
         *      already stored when calling MakeFace.
 
758
         *      The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
 
759
         *      face orientation.
 
760
         *   iNormalsList
 
761
         *     The list of normals, iNormalsList[i] corresponding to the normal of the vertex iVertexList[i] for that face.
 
762
         *   iTexCoordsList
 
763
         *     The list of tex coords, iTexCoordsList[i] corresponding to the normal of the vertex iVertexList[i] for
 
764
         *     that face.
 
765
         */
 
766
        virtual WFace *MakeFace(vector<WVertex *>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList,
 
767
                                vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex);
 
768
 
 
769
        /*! Reset all edges and vertices flags (which might have been set up on a previous pass) */
 
770
        virtual void Reset()
 
771
        {
 
772
                // Reset Edges
 
773
                vector<WEdge *>& wedges = getEdgeList();
 
774
                for (vector<WEdge *>::iterator we = wedges.begin(), weend = wedges.end(); we != weend; ++we) {
 
775
                        ((WXEdge *)(*we))->Reset();
 
776
                }
 
777
 
 
778
                //Reset faces:
 
779
                vector<WFace *>& wfaces = GetFaceList();
 
780
                for (vector<WFace *>::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; ++wf) {
 
781
                        ((WXFace *)(*wf))->Reset();
 
782
                }
 
783
        }
 
784
        /*! accessors */
 
785
};
 
786
 
 
787
/*
 
788
 
 
789
#############################################
 
790
#############################################
 
791
#############################################
 
792
######                                 ######
 
793
######   I M P L E M E N T A T I O N   ######
 
794
######                                 ######
 
795
#############################################
 
796
#############################################
 
797
#############################################
 
798
 
 
799
*/
 
800
/* for inline functions */
 
801
 
 
802
bool WXVertex::isFeature()
 
803
{
 
804
        int counter = 0;
 
805
        vector<WEdge *>& vedges = GetEdges();
 
806
        for (vector<WEdge *>::iterator ve = vedges.begin(), vend = vedges.end(); ve != vend; ++ve) {
 
807
                if (((WXEdge *)(*ve))->nature() != Nature::NO_FEATURE)
 
808
                        counter++;
 
809
        }
 
810
 
 
811
        if ((counter == 1) || (counter > 2))
 
812
                return true;
 
813
        return false;
 
814
}
 
815
 
 
816
} /* namespace Freestyle */
 
817
 
 
818
#endif  // __FREESTYLE_WX_EDGE_H__