Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FEdgeXDetector.h « view_map « intern « freestyle « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e6788c6ff8832756bce469557b871893fd4f3ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//
//  Filename         : FEdgeXDetector.h
//  Author(s)        : Stephane Grabli
//  Purpose          : Detects/flags/builds extended features edges on the
//                     WXEdge structure
//  Date of creation : 26/10/2003
//
///////////////////////////////////////////////////////////////////////////////


//
//  Copyright (C) : Please refer to the COPYRIGHT file distributed 
//   with this source distribution. 
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
///////////////////////////////////////////////////////////////////////////////


#ifndef  FEDGEXDETECTOR_H
# define FEDGEXDETECTOR_H

# include <vector>
# include "../system/FreestyleConfig.h"
# include "../geometry/Geom.h"
# include "../winged_edge/WXEdge.h"
# include "../winged_edge/Curvature.h"
# include "../system/ProgressBar.h"

using namespace Geometry;

/*! This class takes as input a WXEdge structure and fills it
 */

class LIB_VIEW_MAP_EXPORT FEdgeXDetector
{
public:

  FEdgeXDetector() {
    _pProgressBar = 0;
    _computeViewIndependant = true;
    _bbox_diagonal = 1.0;
    _meanEdgeSize = 0;
    _computeRidgesAndValleys = true;
    _computeSuggestiveContours = true;
    _sphereRadius = 1.0;
    _changes = false;
    _kr_derivative_epsilon = 0.0;
  }
  virtual ~FEdgeXDetector() {}

  /*! Process shapes from a WingedEdge containing a list of WShapes */
  virtual void processShapes(WingedEdge&);

  // GENERAL STUFF
  virtual void preProcessShape(WXShape* iShape);
  virtual void preProcessFace(WXFace* iFace);
  virtual void computeCurvatures(WXVertex *iVertex);

  // SILHOUETTE
  virtual void processSilhouetteShape(WXShape* iShape);
  virtual void ProcessSilhouetteFace(WXFace *iFace);
  virtual void ProcessSilhouetteEdge(WXEdge *iEdge);

  // CREASE
  virtual void processCreaseShape(WXShape* iShape);
  virtual void ProcessCreaseEdge(WXEdge *iEdge);

  // BORDER
  virtual void processBorderShape(WXShape* iShape);
  virtual void ProcessBorderEdge(WXEdge *iEdge);

  // RIDGES AND VALLEYS
  virtual void processRidgesAndValleysShape(WXShape* iShape);
  virtual void ProcessRidgeFace(WXFace *iFace);

  // SUGGESTIVE CONTOURS
  virtual void processSuggestiveContourShape(WXShape* iShape);
  virtual void ProcessSuggestiveContourFace(WXFace *iFace);
  virtual void postProcessSuggestiveContourShape(WXShape* iShape);
  virtual void postProcessSuggestiveContourFace(WXFace *iFace);
  /*! Sets the minimal derivative of the radial curvature for suggestive contours
   *  \param dkr
   *    The minimal derivative of the radial curvature
   */
  inline void setSuggestiveContourKrDerivativeEpsilon(real dkr) {
    if (dkr != _kr_derivative_epsilon){
      _kr_derivative_epsilon = dkr;
      _changes = true;
    }
  }

  // EVERYBODY
  virtual void buildSmoothEdges(WXShape* iShape);

  /*! Sets the current viewpoint */
  inline void setViewpoint(const Vec3r& ivp) {_Viewpoint = ivp;}
  inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
  inline void enableSuggestiveContours(bool b) {_computeSuggestiveContours = b;}
  /*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
   *  \param r
   *    The radius of the sphere expressed as a ratio of the mean edge size
   */
  inline void setSphereRadius(real r) {
    if(r!=_sphereRadius){
      _sphereRadius = r;
      _changes=true;
    }
  }

  inline void setProgressBar(ProgressBar *iProgressBar) {_pProgressBar = iProgressBar;}

protected:

  Vec3r _Viewpoint;
  real _bbox_diagonal; // diagonal of the current processed shape bbox
  //oldtmp values
  bool _computeViewIndependant;
  real _meanK1;
  real _meanKr;
  real _minK1;
  real _minKr;
  real _maxK1;
  real _maxKr;
  unsigned _nPoints;
  real _meanEdgeSize;

  bool _computeRidgesAndValleys;
  bool _computeSuggestiveContours;
  real _sphereRadius; // expressed as a ratio of the mean edge size
  bool _changes;

  real _kr_derivative_epsilon;

  ProgressBar *_pProgressBar;
};

#endif // FEDGEDXETECTOR_H