h o m e d o c u m e n t a t i o n c l a s s h i e r a r c h y

AdvancedStrokeShaders.h

00001 //
00002 //  Filename         : AdvancedStrokeShaders.h
00003 //  Author           : Fredo Durand
00004 //  Purpose          : Fredo's stroke shaders
00005 //  Date of creation : 17/12/2002
00006 //
00008 
00009 
00010 //
00011 //  Copyright (C) : Please refer to the COPYRIGHT file distributed 
00012 //   with this source distribution. 
00013 //
00014 //  This program is free software; you can redistribute it and/or
00015 //  modify it under the terms of the GNU General Public License
00016 //  as published by the Free Software Foundation; either version 2
00017 //  of the License, or (at your option) any later version.
00018 //
00019 //  This program is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with this program; if not, write to the Free Software
00026 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 //
00029 
00030 #ifndef  ADVANCEDSTROKESHADERS_H
00031 # define ADVANCEDSTROKESHADERS_H
00032 
00033 # include "BasicStrokeShaders.h"
00034 
00042 class LIB_STROKE_EXPORT CalligraphicShader : public StrokeShader 
00043 {
00044         
00045 public:
00057   CalligraphicShader (real iMinThickness, real iMaxThickness,
00058                       const Vec2f &iOrientation, bool clamp);
00060   virtual ~CalligraphicShader () {}
00062   virtual void shade(Stroke &ioStroke) const;
00063 protected:
00064   real _maxThickness;
00065   real _minThickness;
00066   Vec2f _orientation; 
00067   bool _clamp;
00068 };
00069 
00075 class LIB_STROKE_EXPORT SpatialNoiseShader : public StrokeShader 
00076 {
00077 public:
00090   SpatialNoiseShader (float iAmount, float ixScale, int nbOctave, bool smooth, bool pureRandom);
00092   virtual ~SpatialNoiseShader () {}
00094   virtual void shade(Stroke &ioStroke) const;
00095 
00096 protected:
00097 
00098   float _amount;
00099   float _xScale;
00100   int _nbOctave;
00101   bool _smooth;
00102   bool _pureRandom;
00103 };
00104 
00113 class LIB_STROKE_EXPORT SmoothingShader : public StrokeShader 
00114 {
00115 public:
00134   SmoothingShader (int iNbIteration, real iFactorPoint, real ifactorCurvature, real iFactorCurvatureDifference,
00135                    real iAnisoPoint, real iAnisoNormal, real iAnisoCurvature, real icarricatureFactor);
00137   virtual ~SmoothingShader () {}
00138 
00140   virtual void shade(Stroke &ioStroke) const;
00141 
00142 protected:
00143 
00144   int _nbIterations;
00145   real _factorPoint;
00146   real _factorCurvature;
00147   real _factorCurvatureDifference;
00148   real _anisoPoint;
00149   real _anisoNormal;
00150   real _anisoCurvature;
00151   real _carricatureFactor;
00152 };
00153 
00154 class LIB_STROKE_EXPORT Smoother
00155 {
00156 public:
00157   Smoother (Stroke &ioStroke);
00158         
00159   virtual ~Smoother () {}
00160 
00161   void smooth (int nbIterations, real iFactorPoint, real ifactorCurvature, real iFactorCurvatureDifference,
00162                real iAnisoPoint, real iAnisoNormal, real iAnisoCurvature, real icarricatureFactor);
00163   void computeCurvature ();
00164 
00165 protected:
00166   real _factorPoint;
00167   real _factorCurvature;
00168   real _factorCurvatureDifference;
00169   real _anisoPoint;
00170   real _anisoNormal;
00171   real _anisoCurvature;
00172   real _carricatureFactor;
00173 
00174   void iteration();
00175   void copyVertices ();
00176 
00177   Stroke *_stroke;
00178   int _nbVertices;
00179   Vec2r *_vertex;
00180   Vec2r *_normal;
00181   real *_curvature;
00182   bool *_isFixedVertex;
00183 
00184   bool _isClosedCurve;
00185   bool _safeTest;
00186 };
00187 
00188 class LIB_STROKE_EXPORT Omitter : public Smoother 
00189 {
00190 public:
00191   Omitter (Stroke &ioStroke);
00192   virtual ~Omitter () {}
00193 
00194   void omit (real sizeWindow, real thrVari, real thrFlat, real lFlat);
00195 protected:
00196   real *_u;
00197 
00198   real _sizeWindow;
00199   real _thresholdVariation;
00200   real _thresholdFlat;
00201   real _lengthFlat;
00202 };
00203 
00206 class LIB_STROKE_EXPORT OmissionShader : public StrokeShader 
00207 {
00208 public:
00209   OmissionShader (real sizeWindow, real thrVari, real thrFlat, real lFlat);
00210   virtual ~OmissionShader () {}
00211 
00212   virtual void shade(Stroke &ioStroke) const;
00213 
00214 protected:
00215 
00216   real _sizeWindow;
00217   real _thresholdVariation;
00218   real _thresholdFlat;
00219   real _lengthFlat;
00220 };
00221 
00222 #endif // ADVANCEDSTROKESHADERS_H