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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-04 03:27:20 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-04 03:27:20 +0400
commitec78eb353f71341f84999f47a7222becaadb8598 (patch)
tree0ae6937bcd59f93e0cec512f7b902686cf210e22 /source/blender/freestyle/intern/stroke
parent699da2fb0d9012cef5e45cc1b547a01fd92dbc1c (diff)
New command-line option --debug-freestyle to enable verbose debug messages
on the console during Freestyle rendering. The debug prints are turned off by default now. Errors are still printed on the console. A patch set implementing this functionality was provided by Bastien Montagne. Many thanks! :)
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp57
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.cpp14
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp36
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp19
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp26
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.cpp2
7 files changed, 108 insertions, 48 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index 852a36571d4..245f4cfb3de 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -48,6 +48,8 @@
#include "../view_map/Functions0D.h"
#include "../view_map/Functions1D.h"
+#include "BKE_global.h"
+
//soc #include <qimage.h>
//soc #include <QString>
@@ -764,14 +766,16 @@ int BezierCurveShader::shade(Stroke& stroke) const
if (equal) {
if (data.back() == data.front()) {
vector<Vec2d>::iterator d = data.begin(), dend;
- 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;
+ 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;
+ }
}
}
}
@@ -790,10 +794,17 @@ int BezierCurveShader::shade(Stroke& stroke) const
cerr << "Warning: unsufficient resampling" << endl;
}
else {
- //cout << "Oversampling" << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Oversampling" << endl;
+ }
+#endif
nExtraVertex = newsize - originalSize;
- if (nExtraVertex != 0)
- cout << "Bezier Shader : Stroke " << stroke.getId() << " have not been resampled" << endl;
+ if (nExtraVertex != 0) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Bezier Shader : Stroke " << stroke.getId() << " have not been resampled" << endl;
+ }
+ }
}
// assigns the new coordinates:
@@ -813,7 +824,9 @@ int BezierCurveShader::shade(Stroke& stroke) const
#if 0
double x = p->x();
double y = p->y();
- cout << "x = " << x << "-" << "y = " << y << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "x = " << x << "-" << "y = " << y << endl;
+ }
#endif
last = p;
}
@@ -830,7 +843,9 @@ int BezierCurveShader::shade(Stroke& stroke) const
verticesToRemove.push_back(&(*it));
if (it.isEnd()) {
// XXX Shocking! :P Shouldn't we break in this case???
- cout << "fucked up" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "fucked up" << endl;
+ }
}
}
for (it = stroke.strokeVerticesBegin(); it != itend; ++it) {
@@ -1081,13 +1096,21 @@ int TipRemoverShader::shade(Stroke& stroke) const
// assign old attributes to new stroke vertices:
vector<StrokeAttribute>::iterator a = oldAttributes.begin(), aend = oldAttributes.end();
- //cout << "-----------------------------------------------" << endl;
+#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);
- //cout << "thickness = " << (*a).getThickness()[0] << "-" << (*a).getThickness()[1] << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "thickness = " << (*a).getThickness()[0] << "-" << (*a).getThickness()[1] << endl;
+ }
+#endif
}
// we're done!
return 0;
@@ -1095,7 +1118,9 @@ int TipRemoverShader::shade(Stroke& stroke) const
int streamShader::shade(Stroke& stroke) const
{
- cout << stroke << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << stroke << endl;
+ }
return 0;
}
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 33919b65f21..58647861390 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -877,7 +877,7 @@ public:
{
_stream .open(iFileName);
if (!_stream.is_open()) {
- cout << "couldn't open file " << iFileName << endl;
+ cerr << "couldn't open file " << iFileName << endl;
}
}
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index a51c138f64e..4427192a7b0 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -49,6 +49,8 @@
#include "../view_map/SteerableViewMap.h"
+#include "BKE_global.h"
+
//soc #include <qimage.h>
//soc #include <QString>
@@ -334,7 +336,7 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i
QImage *qimg;
QImage newMap(filePath.c_str());
if (newMap.isNull()) {
- cout << "Could not load image file " << filePath << endl;
+ cerr << "Could not load image file " << filePath << endl;
return;
}
qimg = &newMap;
@@ -342,7 +344,7 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i
/* OCIO_TODO: support different input color space */
ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0, NULL);
if (qimg == 0) {
- cout << "Could not load image file " << filePath << endl;
+ cerr << "Could not load image file " << filePath << endl;
return;
}
@@ -455,12 +457,16 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i
float Canvas::readMapPixel(const char *iMapName, int level, int x, int y)
{
if (_maps.empty()) {
- cout << "readMapPixel warning: no map was loaded "<< endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "readMapPixel warning: no map was loaded "<< endl;
+ }
return -1;
}
mapsMap::iterator m = _maps.find(iMapName);
if (m == _maps.end()) {
- cout << "readMapPixel warning: no map was loaded with the name " << iMapName << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "readMapPixel warning: no map was loaded with the name " << iMapName << endl;
+ }
return -1;
}
ImagePyramid *pyramid = (*m).second;
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index 54b8eeaef36..30d651421a4 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -36,6 +36,8 @@
#include "CurveAdvancedIterators.h"
#include "CurveIterators.h"
+#include "BKE_global.h"
+
/**********************************/
/* */
/* */
@@ -151,12 +153,14 @@ iA_B_eq_iB_A:
}
if (!__A || !__B) {
- printf("iA A 0x%p p (%f, %f)\n", iA->A(), iA->A()->getPoint2D().x(), iA->A()->getPoint2D().y());
- printf("iA B 0x%p p (%f, %f)\n", iA->B(), iA->B()->getPoint2D().x(), iA->B()->getPoint2D().y());
- printf("iB A 0x%p p (%f, %f)\n", iB->A(), iB->A()->getPoint2D().x(), iB->A()->getPoint2D().y());
- printf("iB B 0x%p p (%f, %f)\n", iB->B(), iB->B()->getPoint2D().x(), iB->B()->getPoint2D().y());
- printf("iA t2d %f p (%f, %f)\n", iA->t2d(), iA->getPoint2D().x(), iA->getPoint2D().y());
- printf("iB t2d %f p (%f, %f)\n", iB->t2d(), iB->getPoint2D().x(), iB->getPoint2D().y());
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("iA A 0x%p p (%f, %f)\n", iA->A(), iA->A()->getPoint2D().x(), iA->A()->getPoint2D().y());
+ printf("iA B 0x%p p (%f, %f)\n", iA->B(), iA->B()->getPoint2D().x(), iA->B()->getPoint2D().y());
+ printf("iB A 0x%p p (%f, %f)\n", iB->A(), iB->A()->getPoint2D().x(), iB->A()->getPoint2D().y());
+ printf("iB B 0x%p p (%f, %f)\n", iB->B(), iB->B()->getPoint2D().x(), iB->B()->getPoint2D().y());
+ printf("iA t2d %f p (%f, %f)\n", iA->t2d(), iA->getPoint2D().x(), iA->getPoint2D().y());
+ printf("iB t2d %f p (%f, %f)\n", iB->t2d(), iB->getPoint2D().x(), iB->getPoint2D().y());
+ }
cerr << "Fatal error in CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)" << endl;
}
assert(__A != 0 && __B != 0);
@@ -249,18 +253,20 @@ FEdge *CurvePoint::getFEdge(Interface0D& inter)
return __A->getFEdge(*__B);
}
#if 0
- printf("__A 0x%p p (%f, %f)\n", __A, __A->getPoint2D().x(), __A->getPoint2D().y());
- printf("__B 0x%p p (%f, %f)\n", __B, __B->getPoint2D().x(), __B->getPoint2D().y());
- printf("iVertexB->A() 0x%p p (%f, %f)\n", iVertexB->A(), iVertexB->A()->getPoint2D().x(),
- iVertexB->A()->getPoint2D().y());
- printf("iVertexB->B() 0x%p p (%f, %f)\n", iVertexB->B(), iVertexB->B()->getPoint2D().x(),
- iVertexB->B()->getPoint2D().y());
- printf("_t2d %f p (%f, %f)\n", _t2d, getPoint2D().x(), getPoint2D().y());
- printf("iVertexB->t2d() %f p (%f, %f)\n", iVertexB->t2d(), iVertexB->getPoint2D().x(), iVertexB->getPoint2D().y());
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("__A 0x%p p (%f, %f)\n", __A, __A->getPoint2D().x(), __A->getPoint2D().y());
+ printf("__B 0x%p p (%f, %f)\n", __B, __B->getPoint2D().x(), __B->getPoint2D().y());
+ printf("iVertexB->A() 0x%p p (%f, %f)\n", iVertexB->A(), iVertexB->A()->getPoint2D().x(),
+ iVertexB->A()->getPoint2D().y());
+ printf("iVertexB->B() 0x%p p (%f, %f)\n", iVertexB->B(), iVertexB->B()->getPoint2D().x(),
+ iVertexB->B()->getPoint2D().y());
+ printf("_t2d %f p (%f, %f)\n", _t2d, getPoint2D().x(), getPoint2D().y());
+ printf("iVertexB->t2d() %f p (%f, %f)\n", iVertexB->t2d(), iVertexB->getPoint2D().x(), iVertexB->getPoint2D().y());
+ }
#endif
cerr << "Warning: CurvePoint::getFEdge() failed." << endl;
- return 0;
+ return NULL;
}
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 15aff89db45..e35a811fcab 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -40,6 +40,8 @@
#include "Canvas.h"
#include "Stroke.h"
+#include "BKE_global.h"
+
LIB_STROKE_EXPORT Operators::I1DContainer Operators::_current_view_edges_set;
LIB_STROKE_EXPORT Operators::I1DContainer Operators::_current_chains_set;
LIB_STROKE_EXPORT Operators::I1DContainer *Operators::_current_set = NULL;
@@ -728,7 +730,9 @@ static int __recursiveSplit(Chain *_curve, UnaryFunction0D<double>& func, UnaryP
new_curve_a->push_vertex_back(&(*vit));
}
if ((vit == vitend) || (vnext == vitend)) {
- cout << "The split takes place in bad location" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "The split takes place in bad location" << endl;
+ }
newChains.push_back(_curve);
delete new_curve_a;
delete new_curve_b;
@@ -897,7 +901,9 @@ static int __recursiveSplit(Chain *_curve, UnaryFunction0D<double>& func, UnaryP
new_curve_a->push_vertex_back(&(*vit));
}
if ((vit == vitend) || (vnext == vitend)) {
- cout << "The split takes place in bad location" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "The split takes place in bad location" << endl;
+ }
newChains.push_back(_curve);
delete new_curve_a;
delete new_curve_b;
@@ -1143,8 +1149,11 @@ static Stroke *createStroke(Interface1D& inter)
}
dir.normalize();
Vec2r offset(dir * len);
- //cout << "#vert " << nvert << " len " << len << " reverse? " << reverse << endl;
-
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "#vert " << nvert << " len " << len << " reverse? " << reverse << endl;
+ }
+#endif
// add the offset to the overlapping vertices
StrokeVertex *sv;
std::vector<Interface0D *>::iterator it = overlapping_vertices.begin(),
@@ -1190,7 +1199,7 @@ static Stroke *createStroke(Interface1D& inter)
++v;
++vnext;
}
- if (warning) {
+ if (warning && G.debug & G_DEBUG_FREESTYLE) {
printf("Warning: stroke contains singular points.\n");
}
}
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 477092f2e7a..96e3b7aac48 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -37,6 +37,8 @@
#include "StrokeIterators.h"
#include "StrokeRenderer.h"
+#include "BKE_global.h"
+
/**********************************/
/* */
/* */
@@ -208,12 +210,16 @@ StrokeAttribute& StrokeAttribute::operator=(const StrokeAttribute& iBrother)
float StrokeAttribute::getAttributeReal(const char *iName) const
{
if (!_userAttributesReal) {
- cout << "StrokeAttribute warning: no real attribute was defined" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no real attribute was defined" << endl;
+ }
return 0.0f;
}
realMap::iterator a = _userAttributesReal->find(iName);
if (a == _userAttributesReal->end()) {
- cout << "StrokeAttribute warning: no real attribute was added with the name " << iName << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no real attribute was added with the name " << iName << endl;
+ }
return 0.0f;
}
return (*a).second;
@@ -222,12 +228,16 @@ float StrokeAttribute::getAttributeReal(const char *iName) const
Vec2f StrokeAttribute::getAttributeVec2f(const char *iName) const
{
if (!_userAttributesVec2f) {
- cout << "StrokeAttribute warning: no Vec2f attribute was defined" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no Vec2f attribute was defined" << endl;
+ }
return 0;
}
Vec2fMap::iterator a = _userAttributesVec2f->find(iName);
if (a == _userAttributesVec2f->end()) {
- cout << "StrokeAttribute warning: no Vec2f attribute was added with the name " << iName << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no Vec2f attribute was added with the name " << iName << endl;
+ }
return 0;
}
return (*a).second;
@@ -236,12 +246,16 @@ Vec2f StrokeAttribute::getAttributeVec2f(const char *iName) const
Vec3f StrokeAttribute::getAttributeVec3f(const char *iName) const
{
if (!_userAttributesVec3f) {
- cout << "StrokeAttribute warning: no Vec3f attribute was defined" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no Vec3f attribute was defined" << endl;
+ }
return 0;
}
Vec3fMap::iterator a = _userAttributesVec3f->find(iName);
if (a == _userAttributesVec3f->end()) {
- cout << "StrokeAttribute warning: no Vec3f attribute was added with the name " << iName << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "StrokeAttribute warning: no Vec3f attribute was added with the name " << iName << endl;
+ }
return 0;
}
return (*a).second;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
index 6f12dbf2083..56c5f2b5001 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
@@ -109,7 +109,7 @@ unsigned TextureManager::getBrushTextureIndex(string name, Stroke::MediumType lo
_brushesMap[bt] = texId;
return texId;
// XXX!
- cout << "brush file " << name << " not found" << endl;
+ cerr << "brush file " << name << " not found" << endl;
return 0;
}
else {