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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp')
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp388
1 files changed, 0 insertions, 388 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index 69ca45d3ec7..8d0720d83d9 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -43,9 +43,6 @@
#include "BKE_global.h"
-//soc #include <qimage.h>
-//soc #include <QString>
-
extern "C" {
# include "IMB_imbuf.h"
# include "IMB_imbuf_types.h"
@@ -55,18 +52,6 @@ namespace Freestyle {
// Internal function
-#if 0 // soc
-void convert(const QImage& iImage, float **oArray, unsigned &oSize)
-{
- oSize = iImage.width();
- *oArray = new float[oSize];
- for (unsigned int i = 0; i < oSize; ++i) {
- QRgb rgb = iImage.pixel(i,0);
- (*oArray)[i] = ((float)qBlue(rgb)) / 255.0f;
- }
-}
-#endif
-
static void convert(ImBuf *imBuf, float **oArray, unsigned &oSize)
{
oSize = imBuf->x;
@@ -191,76 +176,6 @@ int LengthDependingThicknessShader::shade(Stroke& stroke) const
return 0;
}
-
-ThicknessVariationPatternShader::ThicknessVariationPatternShader(const string pattern_name, float iMinThickness,
- float iMaxThickness, bool stretch)
-: StrokeShader()
-{
- _stretch = stretch;
- _minThickness = iMinThickness;
- _maxThickness = iMaxThickness;
- ImBuf *image = NULL;
- vector<string> pathnames;
- StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, pathnames);
- for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); ++j) {
- ifstream ifs(j->c_str());
- if (ifs.is_open()) {
- /* OCIO_TODO: support different input color space */
- image = IMB_loadiffname(j->c_str(), 0, NULL);
- break;
- }
- }
- if (image == NULL)
- cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl;
- else
- convert(image, &_aThickness, _size);
- IMB_freeImBuf(image);
-}
-
-
-int ThicknessVariationPatternShader::shade(Stroke& stroke) const
-{
- StrokeInternal::StrokeVertexIterator v, vend;
- float *array = NULL;
- /* int size; */ /* UNUSED */
- array = _aThickness;
- /* size = _size; */ /* UNUSED */
- int vert_size = stroke.strokeVerticesSize();
- int sig = 0;
- unsigned index;
- const float *originalThickness;
- for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- originalThickness = v->attribute().getThickness();
- if (_stretch) {
- float tmp = v->u() * (_size - 1);
- index = (unsigned)floor(tmp);
- if ((tmp - index) > (index + 1 - tmp))
- ++index;
- }
- else {
- index = (unsigned)floor(v->curvilinearAbscissa());
- }
- index %= _size;
- float thicknessR = array[index] * originalThickness[0];
- float thicknessL = array[index] * originalThickness[1];
- if (thicknessR + thicknessL < _minThickness) {
- thicknessL = _minThickness / 2.0f;
- thicknessR = _minThickness / 2.0f;
- }
- if (thicknessR + thicknessL > _maxThickness) {
- thicknessL = _maxThickness / 2.0f;
- thicknessR = _maxThickness / 2.0f;
- }
- if ((sig == 0) || (sig == vert_size - 1))
- v->attribute().setThickness(1, 1);
- else
- v->attribute().setThickness(thicknessR, thicknessL);
- ++sig;
- }
- return 0;
-}
-
-
static const unsigned NB_VALUE_NOISE = 512;
ThicknessNoiseShader::ThicknessNoiseShader() : StrokeShader()
@@ -328,51 +243,6 @@ int IncreasingColorShader::shade(Stroke& stroke) const
return 0;
}
-ColorVariationPatternShader::ColorVariationPatternShader(const string pattern_name, bool stretch) : StrokeShader()
-{
- _stretch = stretch;
- ImBuf *image = NULL;
- vector<string> pathnames;
- StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, pathnames);
- for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); ++j) {
- ifstream ifs(j->c_str());
- if (ifs.is_open()) {
- /* OCIO_TODO: support different input color space */
- image = IMB_loadiffname(j->c_str(), 0, NULL); //soc
- break;
- }
- }
- if (image == NULL)
- cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl;
- else
- convert(image, &_aVariation, _size);
- IMB_freeImBuf(image);
-}
-
-int ColorVariationPatternShader::shade(Stroke& stroke) const
-{
- StrokeInternal::StrokeVertexIterator v, vend;
- unsigned index;
- for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- const float *originalColor = v->attribute().getColor();
- if (_stretch) {
- float tmp = v->u() * (_size - 1);
- index = (unsigned)floor(tmp);
- if ((tmp - index) > (index + 1 - tmp))
- ++index;
- }
- else {
- index = (unsigned)floor(v->curvilinearAbscissa());
- }
- index %= _size;
- float r = _aVariation[index] * originalColor[0];
- float g = _aVariation[index] * originalColor[1];
- float b = _aVariation[index] * originalColor[2];
- v->attribute().setColor(r, g, b);
- }
- return 0;
-}
-
int MaterialColorShader::shade(Stroke& stroke) const
{
Interface0DIterator v, vend;
@@ -389,29 +259,6 @@ int MaterialColorShader::shade(Stroke& stroke) const
return 0;
}
-
-int CalligraphicColorShader::shade(Stroke& stroke) const
-{
- Interface0DIterator v;
- Functions0D::VertexOrientation2DF0D fun;
- StrokeVertex *sv;
- for (v = stroke.verticesBegin(); !v.isEnd(); ++v) {
- if (fun(v) < 0)
- return -1;
- Vec2f vertexOri(fun.result);
- Vec2d ori2d(-vertexOri[1], vertexOri[0]);
- ori2d.normalizeSafe();
- real scal = ori2d * _orientation;
- sv = dynamic_cast<StrokeVertex*>(&(*v));
- if ((scal < 0))
- sv->attribute().setColor(0, 0, 0);
- else
- sv->attribute().setColor(1, 1, 1);
- }
- return 0;
-}
-
-
ColorNoiseShader::ColorNoiseShader() : StrokeShader()
{
_amplitude = 1.0f;
@@ -439,11 +286,9 @@ int ColorNoiseShader::shade(Stroke& stroke) const
float b = bruit * _amplitude + originalColor[2];
v->attribute().setColor(r, g, b);
}
-
return 0;
}
-
//
// Texture Shaders
//
@@ -466,19 +311,6 @@ int StrokeTextureStepShader::shade(Stroke& stroke) const
return 0;
}
-// Legacy shaders from freestyle standalone texture system
-int TextureAssignerShader::shade(Stroke& stroke) const
-{
- cout << "TextureAssignerShader is not supported in blender, please use the BlenderTextureShader" << endl;
- return 0;
-}
-
-int StrokeTextureShader::shade(Stroke& stroke) const
-{
- cout << "StrokeTextureShader is not supported in blender, please use the BlenderTextureShader" << endl;
- return 0;
-}
-
//
// Geometry Shaders
//
@@ -541,119 +373,6 @@ int ExternalContourStretcherShader::shade(Stroke& stroke) const
return 0;
}
-int BSplineShader::shade(Stroke& stroke) const
-{
- if (stroke.strokeVerticesSize() < 4)
- return 0;
-
- // Find the new vertices
- vector<Vec2d> newVertices;
- double t = 0.0;
- float _sampling = 5.0f;
-
- StrokeInternal::StrokeVertexIterator p0, p1, p2, p3, end;
- p0 = stroke.strokeVerticesBegin();
- p1 = p0;
- p2 = p1;
- p3 = p2;
- end = stroke.strokeVerticesEnd();
- double a[4], b[4];
- int n = 0;
- while (p1 != end) {
-#if 0
- if (p1 == end)
- p1 = p0;
-#endif
- if (p2 == end)
- p2 = p1;
- if (p3 == end)
- p3 = p2;
- // compute new matrix
- a[0] = (-(p0)->x() + 3 * (p1)->x() - 3 * (p2)->x() + (p3)->x()) / 6.0;
- a[1] = (3 * (p0)->x() - 6 * (p1)->x() + 3 * (p2)->x()) / 6.0;
- a[2] = (-3 * (p0)->x() + 3 * (p2)->x()) / 6.0;
- a[3] = ((p0)->x() + 4 * (p1)->x() + (p2)->x()) / 6.0;
-
- b[0] = (-(p0)->y() + 3 * (p1)->y() - 3 * (p2)->y() + (p3)->y()) / 6.0;
- b[1] = (3 * (p0)->y() - 6 * (p1)->y() + 3 * (p2)->y()) / 6.0;
- b[2] = (-3 * (p0)->y() + 3 * (p2)->y()) / 6.0;
- b[3] = ((p0)->y() + 4 * (p1)->y() + (p2)->y()) / 6.0;
-
- // draw the spline depending on resolution:
- Vec2d p1p2((p2)->x() - (p1)->x(), (p2)->y() - (p1)->y());
- double norm = p1p2.norm();
- //t = _sampling / norm;
- t = 0;
- while (t < 1) {
- newVertices.push_back(Vec2d((a[3] + t * (a[2] + t * (a[1] + t * a[0]))),
- (b[3] + t * (b[2] + t * (b[1] + t * b[0])))));
- t = t + _sampling / norm;
- }
- if (n > 2) {
- ++p0;
- ++p1;
- ++p2;
- ++p3;
- }
- else {
- if (n == 0)
- ++p3;
- if (n == 1) {
- ++p2;
- ++p3;
- }
- if (n == 2) {
- ++p1;
- ++p2;
- ++p3;
- }
- ++n;
- }
- }
- //last point:
- newVertices.push_back(Vec2d((p0)->x(), (p0)->y()));
-
- int originalSize = newVertices.size();
- _sampling = stroke.ComputeSampling(originalSize);
-
- // Resample and set x,y coordinates
- stroke.Resample(_sampling);
- int newsize = stroke.strokeVerticesSize();
-
- int nExtraVertex = 0;
- if (newsize < originalSize) {
- cerr << "Warning: unsufficient resampling" << endl;
- }
- else {
- nExtraVertex = newsize - originalSize;
- }
-
- // assigns the new coordinates:
- vector<Vec2d>::iterator p = newVertices.begin(), pend = newVertices.end();
- vector<Vec2d>::iterator last = p;
- n = 0;
- StrokeInternal::StrokeVertexIterator it, itend;
- for (it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd();
- (it != itend) && (p != pend);
- ++it, ++p, ++n)
- {
- it->setX(p->x());
- it->setY(p->y());
- last = p;
- }
-
- // nExtraVertex should stay unassigned
- for (int i = 0; i < nExtraVertex; ++i, ++it, ++n) {
- it->setX(last->x());
- it->setY(last->y());
- if (it.isEnd()) {
- // XXX Shouldn't we break in this case???
- cerr << "Warning: Problem encountered while creating B-spline" << endl;
- }
- }
- stroke.UpdateLength();
- return 0;
-}
//!! Bezier curve stroke shader
int BezierCurveShader::shade(Stroke& stroke) const
@@ -673,15 +392,6 @@ int BezierCurveShader::shade(Stroke& stroke) const
previous = v;
}
-#if 0
- Vec2d tmp;
- bool equal = false;
- if (data.front() == data.back()) {
- tmp = data.back();
- data.pop_back();
- equal = true;
- }
-#endif
// here we build the bezier curve
BezierCurve bcurve(data, _error);
@@ -702,25 +412,6 @@ int BezierCurveShader::shade(Stroke& stroke) const
}
}
-#if 0
- if (equal) {
- if (data.back() == data.front()) {
- vector<Vec2d>::iterator d = data.begin(), dend;
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "ending point = starting point" << endl;
- cout << "---------------DATA----------" << endl;
- for (dend = data.end(); d != dend; ++d) {
- cout << d->x() << "-" << d->y() << endl;
- }
- cout << "--------------BEZIER RESULT----------" << endl;
- for (d = CurveVertices.begin(), dend = CurveVertices.end(); d != dend; ++d) {
- cout << d->x() << "-" << d->y() << endl;
- }
- }
- }
- }
-#endif
-
// Resample the Stroke depending on the number of vertices of the bezier curve:
int originalSize = CurveVertices.size();
#if 0
@@ -734,11 +425,6 @@ int BezierCurveShader::shade(Stroke& stroke) const
cerr << "Warning: unsufficient resampling" << endl;
}
else {
-#if 0
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Oversampling" << endl;
- }
-#endif
nExtraVertex = newsize - originalSize;
if (nExtraVertex != 0) {
if (G.debug & G_DEBUG_FREESTYLE) {
@@ -752,22 +438,12 @@ int BezierCurveShader::shade(Stroke& stroke) const
vector<Vec2d>::iterator last = p;
int n;
StrokeInternal::StrokeVertexIterator it, itend;
-#if 0
- for (; p != pend; ++n, ++p);
-#endif
for (n = 0, it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd(), pend = CurveVertices.end();
(it != itend) && (p != pend);
++it, ++p, ++n)
{
it->setX(p->x());
it->setY(p->y());
-#if 0
- double x = p->x();
- double y = p->y();
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "x = " << x << "-" << "y = " << y << endl;
- }
-#endif
last = p;
}
stroke.UpdateLength();
@@ -816,46 +492,6 @@ int BezierCurveShader::shade(Stroke& stroke) const
return 0;
}
-int InflateShader::shade(Stroke& stroke) const
-{
- // we're computing the curvature variance of the stroke. (Combo 5)
- // If it's too high, forget about it
- Functions1D::Curvature2DAngleF1D fun;
- if (fun(stroke) < 0)
- return -1;
- if (fun.result > _curvatureThreshold)
- return 0;
-
- Functions0D::VertexOrientation2DF0D ori_fun;
- Functions0D::Curvature2DAngleF0D curv_fun;
- Functions1D::Normal2DF1D norm_fun;
- Interface0DIterator it;
- StrokeVertex *sv;
- for (it = stroke.verticesBegin(); !it.isEnd(); ++it) {
- if (ori_fun(it) < 0)
- return -1;
- Vec2f ntmp(ori_fun.result);
- Vec2f n(ntmp.y(), -ntmp.x());
- if (norm_fun(stroke) < 0)
- return -1;
- Vec2f strokeN(norm_fun.result);
- if (n * strokeN < 0) {
- n[0] = -n[0];
- n[1] = -n[1];
- }
- sv = dynamic_cast<StrokeVertex*>(&(*it));
- float u = sv->u();
- float t = 4.0f * (0.25f - (u - 0.5) * (u - 0.5));
- if (curv_fun(it) < 0)
- return -1;
- float curvature_coeff = (M_PI - curv_fun.result) / M_PI;
- Vec2d newPoint(sv->x() + curvature_coeff * t * _amount * n.x(),
- sv->y() + curvature_coeff * t * _amount * n.y());
- sv->setPoint(newPoint[0], newPoint[1]);
- }
- stroke.UpdateLength();
- return 0;
-}
class CurvePiece
{
@@ -1040,40 +676,16 @@ int TipRemoverShader::shade(Stroke& stroke) const
// assign old attributes to new stroke vertices:
vector<StrokeAttribute>::iterator a = oldAttributes.begin(), aend = oldAttributes.end();
-#if 0
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "-----------------------------------------------" << endl;
- }
-#endif
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd();
(v != vend) && (a != aend);
++v, ++a)
{
v->setAttribute(*a);
-#if 0
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "thickness = " << (*a).getThickness()[0] << "-" << (*a).getThickness()[1] << endl;
- }
-#endif
}
// we're done!
return 0;
}
-int streamShader::shade(Stroke& stroke) const
-{
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << stroke << endl;
- }
- return 0;
-}
-
-int fstreamShader::shade(Stroke& stroke) const
-{
- _stream << stroke << endl;
- return 0;
-}
-
} // end of namespace StrokeShaders
} /* namespace Freestyle */