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
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')
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp16
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp116
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp66
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp14
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp10
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp123
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.cpp8
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.cpp11
-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
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h18
-rw-r--r--source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp14
-rw-r--r--source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp18
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.cpp30
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.h53
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp18
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.cpp9
-rw-r--r--source/blender/freestyle/intern/view_map/GridDensityProvider.h16
-rw-r--r--source/blender/freestyle/intern/view_map/OccluderSource.cpp8
-rw-r--r--source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp14
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp17
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.cpp30
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.h53
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.cpp10
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp331
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp5
31 files changed, 830 insertions, 334 deletions
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 6e47a52b76f..06391717bb9 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -145,8 +145,12 @@ void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) cons
int recty = _pass_z.height;
float xfac = ((float)rectx) / ((float)(xmax - xmin));
float yfac = ((float)recty) / ((float)(ymax - ymin));
- //printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
- // xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
+ xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ }
+#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = (int)((y - ymin + j) * yfac);
@@ -178,8 +182,12 @@ void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) con
int recty = _pass_z.height;
float xfac = ((float)rectx) / ((float)(xmax - xmin));
float yfac = ((float)recty) / ((float)(ymax - ymin));
- //printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
- // xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
+ xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ }
+#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = (int)((y - ymin + j) * yfac);
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index a8bc4cf2987..662686c2524 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -68,6 +68,8 @@
#include "../blender_interface/BlenderStrokeRenderer.h"
#include "../blender_interface/BlenderStyleModule.h"
+#include "BKE_global.h"
+
// XXX Not inside an "extern C" block???
#include "DNA_freestyle_types.h"
@@ -227,19 +229,26 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
NodeGroup *blenderScene = loader.Load();
if (blenderScene == NULL) {
- cout << "Cannot load scene" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Cannot load scene" << endl;
+ }
return 1;
}
if (blenderScene->numberOfChildren() < 1) {
- cout << "Empty scene" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Empty scene" << endl;
+ }
blenderScene->destroy();
delete blenderScene;
return 1;
}
- cout << "Scene loaded" << endl;
- printf("Mesh cleaning : %lf\n", _Chrono.stop());
+ real duration = _Chrono.stop();
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Scene loaded" << endl;
+ printf("Mesh cleaning : %lf\n", duration);
+ }
_SceneNumFaces += loader.numFacesRead();
if (loader.minEdgeSize() < _minEdgeSize) {
@@ -267,7 +276,10 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
blenderScene->accept(wx_builder);
_winged_edge = wx_builder.getWingedEdge();
- printf("WEdge building : %lf\n", _Chrono.stop());
+ duration = _Chrono.stop();
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("WEdge building : %lf\n", duration);
+ }
#if 0
_pView->setDebug(_DebugNode);
@@ -288,9 +300,11 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
_ListOfModels.push_back("Blender_models");
- cout << "Triangles nb : " << _SceneNumFaces << endl;
_bboxDiag = (_RootNode->bbox().getMax()-_RootNode->bbox().getMin()).norm();
- cout << "Bounding Box : " << _bboxDiag << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Triangles nb : " << _SceneNumFaces << endl;
+ cout << "Bounding Box : " << _bboxDiag << endl;
+ }
ClearRootNode();
@@ -430,37 +444,66 @@ void Controller::ComputeViewMap()
// 3D context is on.
Vec3r vp(freestyle_viewpoint[0], freestyle_viewpoint[1], freestyle_viewpoint[2]);
- //cout << "mv" << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "mv" << endl;
+ }
+#endif
real mv[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mv[i][j] = freestyle_mv[i][j];
- //cout << mv[i][j] << " ";
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << mv[i][j] << " ";
+ }
+#endif
+ }
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
}
- //cout << endl;
+#endif
}
- //cout << "\nproj" << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\nproj" << endl;
+ }
+#endif
real proj[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
proj[i][j] = freestyle_proj[i][j];
- //cout << proj[i][j] << " ";
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << proj[i][j] << " ";
+ }
+#endif
}
- //cout << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
+ }
+#endif
}
int viewport[4];
for (int i = 0; i < 4; i++)
viewport[i] = freestyle_viewport[i];
- //cout << "\nfocal:" << _pView->GetFocalLength() << endl << endl;
-
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\nfocal:" << _pView->GetFocalLength() << endl << endl;
+ }
+#endif
// Flag the WXEdge structure for silhouette edge detection:
//----------------------------------------------------------
- cout << "\n=== Detecting silhouette edges ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Detecting silhouette edges ===" << endl;
+ }
_Chrono.start();
edgeDetector.setViewpoint(Vec3r(vp));
@@ -476,7 +519,9 @@ void Controller::ComputeViewMap()
edgeDetector.processShapes(*_winged_edge);
real duration = _Chrono.stop();
- printf("Feature lines : %lf\n", duration);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("Feature lines : %lf\n", duration);
+ }
if (_pRenderMonitor->testBreak())
return;
@@ -500,13 +545,17 @@ void Controller::ComputeViewMap()
#endif
sTesselator3d.setNature(_edgeTesselationNature);
- cout << "\n=== Building the view map ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Building the view map ===" << endl;
+ }
_Chrono.start();
// Build View Map
_ViewMap = vmBuilder.BuildViewMap(*_winged_edge, _VisibilityAlgo, _EPSILON, _RootNode->bbox(), _SceneNumFaces);
_ViewMap->setScene3dBBox(_RootNode->bbox());
- printf("ViewMap edge count : %i\n", _ViewMap->viewedges_size());
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("ViewMap edge count : %i\n", _ViewMap->viewedges_size());
+ }
// Tesselate the 3D edges:
_SilhouetteNode = sTesselator3d.Tesselate(_ViewMap);
@@ -519,7 +568,9 @@ void Controller::ComputeViewMap()
#endif
duration = _Chrono.stop();
- printf("ViewMap building : %lf\n", duration);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("ViewMap building : %lf\n", duration);
+ }
_pView->AddSilhouette(_SilhouetteNode);
#if 0
@@ -595,8 +646,11 @@ void Controller::ComputeSteerableViewMap()
#endif
pm = offscreenBuffer.renderPixmap(_pView->width(), _pView->height());
- if (pm.isNull())
- cout << "BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
+ if (pm.isNull()) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
+ }
+ }
//pm.save(QString("steerable") + QString::number(i) + QString(".bmp"), "BMP");
// FIXME!! Lost of time !
qimg = pm.toImage();
@@ -770,12 +824,16 @@ void Controller::DrawStrokes()
if (_ViewMap == 0)
return;
- cout << "\n=== Stroke drawing ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Stroke drawing ===" << endl;
+ }
_Chrono.start();
_Canvas->Draw();
real d = _Chrono.stop();
- cout << "Strokes generation : " << d << endl;
- cout << "Stroke count : " << _Canvas->stroke_count << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Strokes generation : " << d << endl;
+ cout << "Stroke count : " << _Canvas->stroke_count << endl;
+ }
resetModified();
DeleteViewMap();
}
@@ -791,11 +849,15 @@ Render* Controller::RenderStrokes(Render *re)
BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re, ++_render_count);
_Canvas->Render(blenderRenderer);
real d = _Chrono.stop();
- cout << "Temporary scene generation: " << d << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Temporary scene generation: " << d << endl;
+ }
_Chrono.start();
Render* freestyle_render = blenderRenderer->RenderScene(re);
d = _Chrono.stop();
- cout << "Stroke rendering : " << d << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Stroke rendering : " << d << endl;
+ }
delete blenderRenderer;
return freestyle_render;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index ea20f8255b1..11124b60b06 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -33,6 +33,8 @@
#include "BlenderFileLoader.h"
+#include "BKE_global.h"
+
BlenderFileLoader::BlenderFileLoader(Render *re, SceneRenderLayer* srl)
{
_re = re;
@@ -52,7 +54,9 @@ NodeGroup* BlenderFileLoader::Load()
{
ObjectInstanceRen *obi;
- cout << "\n=== Importing triangular meshes into Blender ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Importing triangular meshes into Blender ===" << endl;
+ }
// creation of the scene root node
_Scene = new NodeGroup;
@@ -64,9 +68,11 @@ NodeGroup* BlenderFileLoader::Load()
_z_near = -_re->clipsta;
_z_far = -_re->clipend;
#if 0
- cout << "Frustum: l " << _viewplane_left << " r " << _viewplane_right
- << " b " << _viewplane_bottom << " t " << _viewplane_top
- << " n " << _z_near << " f " << _z_far << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Frustum: l " << _viewplane_left << " r " << _viewplane_right
+ << " b " << _viewplane_bottom << " t " << _viewplane_top
+ << " n " << _z_near << " f " << _z_far << endl;
+ }
#endif
int id = 0;
@@ -79,10 +85,12 @@ NodeGroup* BlenderFileLoader::Load()
//cout << name[0] << name[1] << ":" << (name+2) <<;
//print_m4("obi->mat", obi->mat);
- if (obi->obr->totvlak > 0)
+ if (obi->obr->totvlak > 0) {
insertShapeNode(obi, ++id);
- else
- cout << "Warning: " << (name+2) << " is not a vlak-based object (ignored)" << endl;
+ }
+ else if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Warning: " << (name + 2) << " is not a vlak-based object (ignored)" << endl;
+ }
}
// Return the built scene.
@@ -116,7 +124,11 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3],
else {
clip[i] = NOT_CLIPPED;
}
- //printf("%d %s\n", i, (clip[i] == NOT_CLIPPED) ? "not" : (clip[i] == CLIPPED_BY_NEAR) ? "near" : "far");
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("%d %s\n", i, (clip[i] == NOT_CLIPPED) ? "not" : (clip[i] == CLIPPED_BY_NEAR) ? "near" : "far");
+ }
+#endif
sum += clip[i];
}
switch (numClipped) {
@@ -293,8 +305,9 @@ int BlenderFileLoader::testDegenerateTriangle(float v1[3], float v2[3], float v3
if (equals_v3v3(v1, v2) || equals_v3v3(v2, v3) || equals_v3v3(v1, v3)) {
#if 0
- if (verbose)
+ if (verbose && G.debug & G_DEBUG_FREESTYLE) {
printf("BlenderFileLoader::testDegenerateTriangle = 1\n");
+ }
#endif
return 1;
}
@@ -303,14 +316,16 @@ int BlenderFileLoader::testDegenerateTriangle(float v1[3], float v2[3], float v3
dist_to_line_segment_v3(v3, v1, v2) < 1.0e-6)
{
#if 0
- if (verbose)
+ if (verbose && G.debug & G_DEBUG_FREESTYLE) {
printf("BlenderFileLoader::testDegenerateTriangle = 2\n");
+ }
#endif
return 2;
}
#if 0
- if (verbose)
+ if (verbose && G.debug & G_DEBUG_FREESTYLE) {
printf("BlenderFileLoader::testDegenerateTriangle = 0\n");
+ }
#endif
return 0;
}
@@ -321,7 +336,11 @@ bool BlenderFileLoader::testEdgeRotation(float v1[3], float v2[3], float v3[3],
{
if (testDegenerateTriangle(v1, v2, v3) == 2 || testDegenerateTriangle(v1, v3, v4) == 2) {
if (testDegenerateTriangle(v1, v2, v4) == 2 || testDegenerateTriangle(v2, v3, v4) == 2) {
- //printf("BlenderFileLoader::testEdgeRotation: edge rotation is unsuccessful.\n");
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("BlenderFileLoader::testEdgeRotation: edge rotation is unsuccessful.\n");
+ }
+#endif
return false;
}
return true;
@@ -381,9 +400,16 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
numFaces += countClippedFaces(v2, v3, v4, clip_2);
}
}
- if (wire_material)
- printf("Warning: Object %s has wire materials (ignored)\n", name);
-// cout << "numFaces " << numFaces << endl;
+ if (wire_material) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Warning: Object " << name << " has wire materials (ignored)" << endl;
+ }
+ }
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "numFaces " << numFaces << endl;
+ }
+#endif
if (numFaces == 0)
return;
@@ -488,7 +514,9 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
numTris_1 = countClippedFaces(v1, v2, v4, clip_1);
numTris_2 = countClippedFaces(v2, v3, v4, clip_2);
edge_rotation = true;
- printf("BlenderFileLoader::insertShapeNode: edge rotation is performed.\n");
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("BlenderFileLoader::insertShapeNode: edge rotation is performed.\n");
+ }
}
if (numTris_1 == 0 && numTris_2 == 0)
continue;
@@ -709,8 +737,10 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
cleanVertices[detri.viP+2] += 1.0e-5 * detri.v.z();
}
}
- printf("Warning: Object %s contains %lu degenerated triangle%s (strokes may be incorrect)\n",
- name, detriList.size(), (detriList.size() > 1) ? "s" : "");
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("Warning: Object %s contains %lu degenerated triangle%s (strokes may be incorrect)\n",
+ name, detriList.size(), (detriList.size() > 1) ? "s" : "");
+ }
}
// Create the IndexedFaceSet with the retrieved attributes
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index f2ce7df0f6c..356b752466e 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -35,6 +35,8 @@
#include "../application/AppConfig.h"
#include "../stroke/Canvas.h"
+#include "BKE_global.h"
+
// XXX Are those "ifdef __cplusplus" useful here?
#ifdef __cplusplus
extern "C" {
@@ -164,7 +166,11 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
void *data = ob->data;
char name[24];
strcpy(name, ob->id.name);
- //cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
+ }
+#endif
switch (ob->type) {
case OB_MESH:
BKE_libblock_free(&G.main->object, ob);
@@ -484,7 +490,11 @@ Render* BlenderStrokeRenderer::RenderScene(Render *re)
Camera *camera = (Camera*)freestyle_scene->camera->data;
if (camera->clipend < _z)
camera->clipend = _z + _z_delta * 100.0f;
- //cout << "clipsta " << camera->clipsta << ", clipend " << camera->clipend << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "clipsta " << camera->clipsta << ", clipend " << camera->clipend << endl;
+ }
+#endif
Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp b/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
index 053ad636837..aa8f8809cea 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderTextureManager.cpp
@@ -31,6 +31,8 @@
#include "BlenderTextureManager.h"
+#include "BKE_global.h"
+
BlenderTextureManager::BlenderTextureManager()
: TextureManager()
{
@@ -76,7 +78,9 @@ unsigned int BlenderTextureManager::loadBrush(string sname, Stroke::MediumType m
if (!found)
return 0;
// Brush texture
- cout << "Loading brush texture..." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Loading brush texture..." << endl;
+ }
switch (mediumType) {
case Stroke::DRY_MEDIUM:
//soc prepareTextureLuminance((const char*)path.toAscii(), texId);
@@ -89,7 +93,9 @@ unsigned int BlenderTextureManager::loadBrush(string sname, Stroke::MediumType m
prepareTextureAlpha(StringUtils::toAscii(path), texId);
break;
}
- cout << "Done." << endl << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Done." << endl << endl;
+ }
return texId;
#else
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 759bf09380f..97a84a284e0 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -38,6 +38,8 @@
#include "../application/AppView.h"
#include "../application/Controller.h"
+#include "BKE_global.h"
+
using namespace std;
// XXX Are those "ifdef __cplusplus" useful here?
@@ -118,7 +120,9 @@ void FRS_initialize()
void FRS_set_context(bContext *C)
{
- cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
+ }
controller->setContext(C);
}
@@ -166,12 +170,14 @@ static void init_view(Render *re)
view->setBorder(xmin, ymin, xmax, ymax);
view->setThickness(thickness);
- cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
- cout << "Width : " << width << endl;
- cout << "Height : " << height << endl;
- if (re->r.mode & R_BORDER)
- cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
- cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
+ cout << "Width : " << width << endl;
+ cout << "Height : " << height << endl;
+ if (re->r.mode & R_BORDER)
+ cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
+ cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
+ }
}
static void init_camera(Render *re)
@@ -309,24 +315,32 @@ static void prepare(Render *re, SceneRenderLayer *srl)
// add style modules
FreestyleConfig *config = &srl->freestyleConfig;
- cout << "\n=== Rendering options ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Rendering options ===" << endl;
+ }
int layer_count = 0;
switch (config->mode) {
case FREESTYLE_CONTROL_SCRIPT_MODE:
- cout << "Modules :" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Modules :" << endl;
+ }
for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig*)config->modules.first;
module_conf;
module_conf = module_conf->next)
{
if(module_conf->is_displayed) {
- cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
+ }
controller->InsertStyleModule(layer_count, module_conf->module_path);
controller->toggleLayer(layer_count, true);
layer_count++;
}
}
- cout << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
+ }
controller->setComputeRidgesAndValleysFlag((config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
controller->setComputeSuggestiveContoursFlag((config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
controller->setComputeMaterialBoundariesFlag((config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false);
@@ -347,14 +361,18 @@ static void prepare(Render *re, SceneRenderLayer *srl)
{FREESTYLE_FE_EDGE_MARK, 0}
};
int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition);
- cout << "Linesets:" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Linesets:" << endl;
+ }
for (FreestyleLineSet *lineset = (FreestyleLineSet*)config->linesets.first;
lineset;
lineset = lineset->next)
{
if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
- cout << " " << layer_count+1 << ": " << lineset->name << " - "
- << lineset->linestyle->id.name+2 << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << " " << layer_count+1 << ": " << lineset->name << " - "
+ << lineset->linestyle->id.name+2 << endl;
+ }
Text *text = create_lineset_handler(srl->name, lineset->name);
controller->InsertStyleModule(layer_count, lineset->name, text);
controller->toggleLayer(layer_count, true);
@@ -424,17 +442,20 @@ static void prepare(Render *re, SceneRenderLayer *srl)
FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE :
FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE);
- cout << "Crease angle : " << controller->getCreaseAngle() << endl;
- cout << "Sphere radius : " << controller->getSphereRadius() << endl;
- cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled") << endl;
- cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
- cout << "Suggestive contours : " << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled")
- << endl;
- cout << "Suggestive contour Kr derivative epsilon : " << controller->getSuggestiveContourKrDerivativeEpsilon()
- << endl;
- cout << "Material boundaries : " << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled")
- << endl;
- cout << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Crease angle : " << controller->getCreaseAngle() << endl;
+ cout << "Sphere radius : " << controller->getSphereRadius() << endl;
+ cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled") << endl;
+ cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled")
+ << endl;
+ cout << "Suggestive contours : " << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled")
+ << endl;
+ cout << "Suggestive contour Kr derivative epsilon : " << controller->getSuggestiveContourKrDerivativeEpsilon()
+ << endl;
+ cout << "Material boundaries : " << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled")
+ << endl;
+ cout << endl;
+ }
// set diffuse and z depth passes
RenderLayer *rl = RE_GetRenderLayer(re->result, srl->name);
@@ -451,9 +472,11 @@ static void prepare(Render *re, SceneRenderLayer *srl)
break;
}
}
- cout << "Passes :" << endl;
- cout << " Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
- cout << " Z = " << (z ? "enabled" : "disabled") << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Passes :" << endl;
+ cout << " Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
+ cout << " Z = " << (z ? "enabled" : "disabled") << endl;
+ }
// compute view map
re->i.infostr = "Freestyle: View map creation";
@@ -473,19 +496,31 @@ void FRS_composite_result(Render* re, SceneRenderLayer* srl, Render* freestyle_r
rl = render_get_active_layer( freestyle_render, freestyle_render->result );
if (!rl || rl->rectf == NULL) {
- cout << "Cannot find Freestyle result image" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Cannot find Freestyle result image" << endl;
+ }
return;
}
src = rl->rectf;
- //cout << "src: " << rl->rectx << " x " << rl->recty << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "src: " << rl->rectx << " x " << rl->recty << endl;
+ }
+#endif
rl = RE_GetRenderLayer(re->result, srl->name);
if (!rl || rl->rectf == NULL) {
- cout << "No layer to composite to" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "No layer to composite to" << endl;
+ }
return;
}
dest = rl->rectf;
- //cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
+ }
+#endif
rectx = re->rectx;
recty = re->recty;
@@ -534,10 +569,12 @@ int FRS_is_freestyle_enabled(SceneRenderLayer *srl)
void FRS_init_stroke_rendering(Render *re)
{
- cout << endl;
- cout << "#===============================================================" << endl;
- cout << "# Freestyle" << endl;
- cout << "#===============================================================" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
+ cout << "#===============================================================" << endl;
+ cout << "# Freestyle" << endl;
+ cout << "#===============================================================" << endl;
+ }
init_view(re);
init_camera(re);
@@ -552,10 +589,12 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
RenderMonitor monitor(re);
controller->setRenderMonitor(&monitor);
- cout << endl;
- cout << "----------------------------------------------------------" << endl;
- cout << "| " << (re->scene->id.name + 2) << "|" << srl->name << endl;
- cout << "----------------------------------------------------------" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
+ cout << "----------------------------------------------------------" << endl;
+ cout << "| " << (re->scene->id.name + 2) << "|" << srl->name << endl;
+ cout << "----------------------------------------------------------" << endl;
+ }
// prepare Freestyle:
// - load mesh
@@ -566,7 +605,9 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
if (re->test_break(re->tbh)) {
controller->CloseFile();
- cout << "Break" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Break" << endl;
+ }
return NULL;
}
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.cpp b/source/blender/freestyle/intern/geometry/FastGrid.cpp
index f5f9bc1079e..7051d960346 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.cpp
+++ b/source/blender/freestyle/intern/geometry/FastGrid.cpp
@@ -34,6 +34,8 @@
#include "FastGrid.h"
+#include "BKE_global.h"
+
void FastGrid::clear()
{
if (!_cells)
@@ -61,8 +63,10 @@ void FastGrid::configure(const Vec3r& orig, const Vec3r& size, unsigned nb)
Cell *FastGrid::getCell(const Vec3u& p)
{
#if 0
- cout << _cells << " " << p << " " << _cells_nb[0] << "-" << _cells_nb[1] << "-" << _cells_nb[2]
- << " " << _cells_size << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cells << " " << p << " " << _cells_nb[0] << "-" << _cells_nb[1] << "-" << _cells_nb[2]
+ << " " << _cells_size << endl;
+ }
#endif
assert(_cells || ("_cells is a null pointer"));
assert((_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]) < _cells_size);
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
index aba845a2faf..c90513c6294 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
@@ -50,6 +50,8 @@
#include "../system/TimeUtils.h"
+#include "BKE_global.h"
+
using namespace std;
@@ -157,12 +159,17 @@ void GeomCleaner::SortAndCompressIndexedVertexArray(const float *iVertices, unsi
// Sort data
chrono.start();
GeomCleaner::SortIndexedVertexArray(iVertices, iVSize, iIndices, iISize, &tmpVertices, &tmpIndices);
- printf("Sorting: %lf\n", chrono.stop());
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("Sorting: %lf\n", chrono.stop());
+ }
// compress data
chrono.start();
GeomCleaner::CompressIndexedVertexArray(tmpVertices, iVSize, tmpIndices, iISize, oVertices, oVSize, oIndices);
- printf("Merging: %lf\n", chrono.stop());
+ real duration = chrono.stop();
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("Merging: %lf\n", duration);
+ }
// deallocates memory:
delete [] tmpVertices;
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 {
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index c6acf502e5e..6093b6e4dcd 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -103,9 +103,9 @@ public:
#endif
if (status != 1) {
- cout << "\nError executing Python script from PythonInterpreter::interpretFile" << endl;
- cout << "File: " << fn << endl;
- cout << "Errors: " << endl;
+ cerr << "\nError executing Python script from PythonInterpreter::interpretFile" << endl;
+ cerr << "File: " << fn << endl;
+ cerr << "Errors: " << endl;
BKE_reports_print(reports, RPT_ERROR);
return 1;
}
@@ -124,9 +124,9 @@ public:
BKE_reports_clear(reports);
if (!BPY_text_exec(_context, text, reports, false)) {
- cout << "\nError executing Python script from PythonInterpreter::interpretText" << endl;
- cout << "Name: " << name << endl;
- cout << "Errors: " << endl;
+ cerr << "\nError executing Python script from PythonInterpreter::interpretText" << endl;
+ cerr << "Name: " << name << endl;
+ cerr << "Errors: " << endl;
BKE_reports_print(reports, RPT_ERROR);
return 1;
}
@@ -173,9 +173,11 @@ private:
for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) {
if (!it->empty()) {
- cout << "Adding Python path: " << *it << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Adding Python path: " << *it << endl;
+ }
cmd = "sys.path.append(r\"" + *it + "\")\n";
- txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
+ txt_insert_buf(text, const_cast<char *>(cmd.c_str()));
}
}
diff --git a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
index c7925026cd5..24cef37f381 100644
--- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
+++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
@@ -34,6 +34,8 @@
#include "ArbitraryGridDensityProvider.h"
+#include "BKE_global.h"
+
ArbitraryGridDensityProvider::ArbitraryGridDensityProvider(OccluderSource& source, const real proscenium[4],
unsigned numCells)
: GridDensityProvider(source), numCells(numCells)
@@ -67,13 +69,17 @@ void ArbitraryGridDensityProvider::initialize(const real proscenium[4])
float prosceniumWidth = (proscenium[1] - proscenium[0]);
float prosceniumHeight = (proscenium[3] - proscenium[2]);
real cellArea = prosceniumWidth * prosceniumHeight / numCells;
- cout << prosceniumWidth << " x " << prosceniumHeight << " grid with cells of area " << cellArea << "." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << prosceniumWidth << " x " << prosceniumHeight << " grid with cells of area " << cellArea << "." << endl;
+ }
_cellSize = sqrt(cellArea);
// Now we know how many cells make each side of our grid
_cellsX = ceil(prosceniumWidth / _cellSize);
_cellsY = ceil(prosceniumHeight / _cellSize);
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Make sure the grid exceeds the proscenium by a small amount
float safetyZone = 0.1f;
@@ -83,7 +89,9 @@ void ArbitraryGridDensityProvider::initialize(const real proscenium[4])
if (_cellsY * _cellSize < prosceniumHeight * (1.0 + safetyZone)) {
_cellsY = prosceniumHeight * (1.0 + safetyZone) / _cellSize;
}
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Find grid origin
_cellOrigin[0] = ((proscenium[0] + proscenium[1]) / 2.0) - (_cellsX / 2.0) * _cellSize;
diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
index 4832d08f2bc..d293ed8189f 100644
--- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
+++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
@@ -34,6 +34,8 @@
#include "AverageAreaGridDensityProvider.h"
+#include "BKE_global.h"
+
AverageAreaGridDensityProvider::AverageAreaGridDensityProvider(OccluderSource& source, const real proscenium[4],
real sizeFactor)
: GridDensityProvider(source)
@@ -76,16 +78,22 @@ void AverageAreaGridDensityProvider::initialize(const real proscenium[4], real s
cellArea += (max[0] - min[0]) * (max[1] - min[1]);
++numFaces;
}
- cout << "Total area: " << cellArea << ". Number of faces: " << numFaces << "." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Total area: " << cellArea << ". Number of faces: " << numFaces << "." << endl;
+ }
cellArea /= numFaces;
cellArea *= sizeFactor;
- cout << "Building grid with average area " << cellArea << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Building grid with average area " << cellArea << endl;
+ }
_cellSize = sqrt(cellArea);
// Now we know how many cells make each side of our grid
_cellsX = ceil(prosceniumWidth / _cellSize);
_cellsY = ceil(prosceniumHeight / _cellSize);
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Make sure the grid exceeds the proscenium by a small amount
float safetyZone = 0.1f;
@@ -95,7 +103,9 @@ void AverageAreaGridDensityProvider::initialize(const real proscenium[4], real s
if (_cellsY * _cellSize < prosceniumHeight * (1.0 + safetyZone)) {
_cellsY = prosceniumHeight * (1.0 + safetyZone) / _cellSize;
}
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Find grid origin
_cellOrigin[0] = ((proscenium[0] + proscenium[1]) / 2.0) - (_cellsX / 2.0) * _cellSize;
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
index 6b2804b17ce..c83ab44a259 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
@@ -37,6 +37,8 @@
#include "BoxGrid.h"
+#include "BKE_global.h"
+
using namespace std;
// Helper Classes
@@ -80,9 +82,11 @@ BoxGrid::Iterator::Iterator (BoxGrid& grid, Vec3r& center, real epsilon)
// Find target cell
_cell = grid.findCell(_target);
#if BOX_GRID_LOGGING
- cout << "Searching for occluders of edge centered at " << _target << " in cell ["
- << _cell->boundary[0] << ", " << _cell->boundary[1] << ", " << _cell->boundary[2]
- << ", " << _cell->boundary[3] << "] (" << _cell->faces.size() << " occluders)" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Searching for occluders of edge centered at " << _target << " in cell ["
+ << _cell->boundary[0] << ", " << _cell->boundary[1] << ", " << _cell->boundary[2]
+ << ", " << _cell->boundary[3] << "] (" << _cell->faces.size() << " occluders)" << endl;
+ }
#endif
// Set iterator
@@ -99,18 +103,26 @@ BoxGrid::BoxGrid(OccluderSource& source, GridDensityProvider& density, ViewMap *
: _viewpoint(viewpoint), _enableQI(enableQI)
{
// Generate Cell structure
- cout << "Generate Cell structure" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Generate Cell structure" << endl;
+ }
assignCells(source, density, viewMap);
// Fill Cells
- cout << "Distribute occluders" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Distribute occluders" << endl;
+ }
distributePolygons(source);
// Reorganize Cells
- cout << "Reorganize cells" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Reorganize cells" << endl;
+ }
reorganizeCells();
- cout << "Ready to use BoxGrid" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Ready to use BoxGrid" << endl;
+ }
}
BoxGrid::~BoxGrid() {}
@@ -178,7 +190,9 @@ void BoxGrid::distributePolygons(OccluderSource& source)
}
++nFaces;
}
- cout << "Distributed " << nFaces << " occluders. Retained " << nKeptFaces << "." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Distributed " << nFaces << " occluders. Retained " << nKeptFaces << "." << endl;
+ }
}
void BoxGrid::reorganizeCells()
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h
index 9c8875865ef..50ca1622e99 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.h
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.h
@@ -55,6 +55,8 @@
#include "../winged_edge/WEdge.h"
+#include "BKE_global.h"
+
class BoxGrid
{
public:
@@ -193,14 +195,19 @@ inline void BoxGrid::Iterator::initAfterTarget()
{
if (_foundOccludee) {
#if BOX_GRID_LOGGING
- std::cout << "\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tStarting occludee search from occludeeCandidate at depth "
+ << _occludeeDepth << std::endl;
+ }
#endif
_current = _occludeeCandidate;
return;
}
#if BOX_GRID_LOGGING
- std::cout << "\tStarting occludee search from current position" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tStarting occludee search from current position" << std::endl;
+ }
#endif
while (_current != _cell->faces.end() && !testOccluder(true)) {
@@ -217,17 +224,21 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
return true;
}
#if BOX_GRID_LOGGING
- std::cout << "\tTesting occluder " << (*_current)->poly.getVertices()[0];
- for (unsigned int i = 1; i < (*_current)->poly.getVertices().size(); ++i) {
- std::cout << ", " << (*_current)->poly.getVertices()[i];
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tTesting occluder " << (*_current)->poly.getVertices()[0];
+ for (unsigned int i = 1; i < (*_current)->poly.getVertices().size(); ++i) {
+ std::cout << ", " << (*_current)->poly.getVertices()[i];
+ }
+ std::cout << " from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
}
- std::cout << " from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
#endif
// If we have an occluder candidate and we are unambiguously after it, abort
if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
#if BOX_GRID_LOGGING
- std::cout << "\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
+ }
#endif
_current = _cell->faces.end();
@@ -239,7 +250,9 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
if (wantOccludee) {
if ((*_current)->deepest < _target[2]) {
#if BOX_GRID_LOGGING
- std::cout << "\t\tSkipping: shallower than target while looking for occludee" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tSkipping: shallower than target while looking for occludee" << std::endl;
+ }
#endif
return false;
}
@@ -247,7 +260,9 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
else {
if ((*_current)->shallowest > _target[2]) {
#if BOX_GRID_LOGGING
- std::cout << "\t\tStopping: deeper than target while looking for occluder" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tStopping: deeper than target while looking for occluder" << std::endl;
+ }
#endif
return true;
}
@@ -260,7 +275,9 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
(*_current)->poly.getBBox(bbMin, bbMax);
if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] || _target[1] > bbMax[1]) {
#if BOX_GRID_LOGGING
- std::cout << "\t\tSkipping: bounding box violation" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tSkipping: bounding box violation" << std::endl;
+ }
#endif
return false;
}
@@ -276,11 +293,15 @@ inline void BoxGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
// We need to convert it into a Z-value in grid space
real depth = -(origin + (u * t))[2];
#if BOX_GRID_LOGGING
- std::cout << "\t\tReporting depth of occluder/ee: " << depth;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tReporting depth of occluder/ee: " << depth;
+ }
#endif
if (depth > _target[2]) {
#if BOX_GRID_LOGGING
- std::cout << " is deeper than target" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << " is deeper than target" << std::endl;
+ }
#endif
// If the current occluder is the best occludee so far, save it.
if (! _foundOccludee || _occludeeDepth > depth) {
@@ -289,7 +310,9 @@ inline void BoxGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
}
else {
#if BOX_GRID_LOGGING
- std::cout << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << std::endl;
+ }
#endif
}
}
@@ -325,7 +348,9 @@ inline bool BoxGrid::Iterator::validAfterTarget()
inline void BoxGrid::Iterator::markCurrentOccludeeCandidate(real depth)
{
#if BOX_GRID_LOGGING
- std::cout << "\t\tFound occludeeCandidate at depth " << depth << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tFound occludeeCandidate at depth " << depth << std::endl;
+ }
#endif
_occludeeCandidate = _current;
_occludeeDepth = depth;
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
index 0e01a70181a..2c9a9def4fc 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -38,6 +38,8 @@
#include "../geometry/GridHelpers.h"
+#include "BKE_global.h"
+
CulledOccluderSource::CulledOccluderSource(const GridHelpers::Transform& t, WingedEdge& we, ViewMap& viewMap,
bool extensiveFEdgeSearch)
: OccluderSource(t, we), rejected(0), gridSpaceOccluderProsceniumInitialized(false)
@@ -73,7 +75,9 @@ bool CulledOccluderSource::next()
return true;
}
}
- std::cout << "Finished generating occluders. Rejected " << rejected << " faces." << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "Finished generating occluders. Rejected " << rejected << " faces." << std::endl;
+ }
return false;
}
@@ -121,11 +125,13 @@ void CulledOccluderSource::cullViewEdges(ViewMap& viewMap, bool extensiveFEdgeSe
real prosceniumOrigin[2];
prosceniumOrigin[0] = (viewProscenium[1] - viewProscenium[0]) / 2.0;
prosceniumOrigin[1] = (viewProscenium[3] - viewProscenium[2]) / 2.0;
- cout << "Proscenium culling:" << endl;
- cout << "Proscenium: [" << viewProscenium[0] << ", " << viewProscenium[1] << ", " << viewProscenium[2]
- << ", " << viewProscenium[3] << "]"<< endl;
- cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]"<< endl;
-
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Proscenium culling:" << endl;
+ cout << "Proscenium: [" << viewProscenium[0] << ", " << viewProscenium[1] << ", " << viewProscenium[2]
+ << ", " << viewProscenium[3] << "]"<< endl;
+ cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]"<< endl;
+ }
+
// A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
// expanding as necessary so that it encompasses the center point of at least one feature edge in each
// retained view edge.
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index b6821afcb93..9e8557b0fd3 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -36,6 +36,8 @@
#include "Functions0D.h"
#include "ViewMap.h"
+#include "BKE_global.h"
+
using namespace std;
namespace Functions0D {
@@ -325,8 +327,11 @@ int QuantitativeInvisibilityF0D::operator()(Interface0DIterator& iter)
qi1 = ve1->qi();
if (ve2 != NULL) {
qi2 = ve2->qi();
- if (qi2 != qi1)
- cout << "QuantitativeInvisibilityF0D: ambiguous evaluation for point " << iter->getId() << endl;
+ if (qi2 != qi1) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "QuantitativeInvisibilityF0D: ambiguous evaluation for point " << iter->getId() << endl;
+ }
+ }
}
result = qi1;
return 0;
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
index cc711fedece..5fe7d095358 100644
--- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
@@ -42,6 +42,8 @@
#include "../geometry/BBox.h"
+#include "BKE_global.h"
+
class GridDensityProvider
{
// Disallow copying and assignment
@@ -90,8 +92,10 @@ public:
source.next();
}
}
- cout << "Proscenium: (" << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2]
- << ", " << proscenium[3] << ")" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Proscenium: (" << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2]
+ << ", " << proscenium[3] << ")" << endl;
+ }
}
static void calculateQuickProscenium(const GridHelpers::Transform& transform, const BBox<Vec3r>& bbox,
@@ -108,13 +112,15 @@ public:
// Now calculate the proscenium according to the min and max values of the x and y coordinates
Vec3r minPoint = transform(Vec3r(bbox.getMin()[0], bbox.getMin()[1], z));
Vec3r maxPoint = transform(Vec3r(bbox.getMax()[0], bbox.getMax()[1], z));
- cout << "Bounding box: " << minPoint << " to " << maxPoint << endl;
proscenium[0] = std::min(minPoint[0], maxPoint[0]);
proscenium[1] = std::max(minPoint[0], maxPoint[0]);
proscenium[2] = std::min(minPoint[1], maxPoint[1]);
proscenium[3] = std::max(minPoint[1], maxPoint[1]);
- cout << "Proscenium : " << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", "
- << proscenium[3] << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Bounding box: " << minPoint << " to " << maxPoint << endl;
+ cout << "Proscenium : " << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", "
+ << proscenium[3] << endl;
+ }
}
protected:
diff --git a/source/blender/freestyle/intern/view_map/OccluderSource.cpp b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
index 5af618dd6f6..0cbad57b44a 100644
--- a/source/blender/freestyle/intern/view_map/OccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
@@ -36,6 +36,8 @@
#include "OccluderSource.h"
+#include "BKE_global.h"
+
OccluderSource::OccluderSource(const GridHelpers::Transform& t, WingedEdge& we)
: wingedEdge(we), valid(false), transform(t)
{
@@ -127,8 +129,10 @@ void OccluderSource::getOccluderProscenium(real proscenium[4])
GridHelpers::expandProscenium (proscenium, cachedPolygon);
next();
}
- cout << "Proscenium: (" << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", "
- << proscenium[3] << ")" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Proscenium: (" << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", "
+ << proscenium[3] << ")" << endl;
+ }
}
real OccluderSource::averageOccluderArea()
diff --git a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp
index 1a15fc849a6..10c6265ebb4 100644
--- a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp
+++ b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp
@@ -34,6 +34,8 @@
#include "Pow23GridDensityProvider.h"
+#include "BKE_global.h"
+
Pow23GridDensityProvider::Pow23GridDensityProvider(OccluderSource& source, const real proscenium[4], unsigned numFaces)
: GridDensityProvider(source), numFaces(numFaces)
{
@@ -66,13 +68,17 @@ void Pow23GridDensityProvider::initialize(const real proscenium[4])
float prosceniumWidth = (proscenium[1] - proscenium[0]);
float prosceniumHeight = (proscenium[3] - proscenium[2]);
real cellArea = prosceniumWidth * prosceniumHeight / pow(numFaces, 2.0f / 3.0f);
- cout << prosceniumWidth << " x " << prosceniumHeight << " grid with cells of area " << cellArea << "." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << prosceniumWidth << " x " << prosceniumHeight << " grid with cells of area " << cellArea << "." << endl;
+ }
_cellSize = sqrt(cellArea);
// Now we know how many cells make each side of our grid
_cellsX = ceil(prosceniumWidth / _cellSize);
_cellsY = ceil(prosceniumHeight / _cellSize);
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Make sure the grid exceeds the proscenium by a small amount
float safetyZone = 0.1;
@@ -82,7 +88,9 @@ void Pow23GridDensityProvider::initialize(const real proscenium[4])
if (_cellsY * _cellSize < prosceniumHeight * (1.0 + safetyZone)) {
_cellsY = prosceniumHeight * (1.0 + safetyZone) / _cellSize;
}
- cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << _cellsX << "x" << _cellsY << " cells of size " << _cellSize << " square." << endl;
+ }
// Find grid origin
_cellOrigin[0] = ((proscenium[0] + proscenium[1]) / 2.0) - (_cellsX / 2.0) * _cellSize;
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 06cbd85d863..2de6be4c68a 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -38,6 +38,8 @@
#include "../geometry/GeomUtils.h"
+#include "BKE_global.h"
+
using namespace std;
Vec3r SilhouetteGeomEngine::_Viewpoint = Vec3r(0, 0, 0);
@@ -196,9 +198,11 @@ real SilhouetteGeomEngine::ImageToWorldParameter(FEdge *fe, real t)
GeomUtils::fromWorldToCamera(Bw, Bc, _modelViewMatrix);
Vec3r ABc = Bc - Ac;
#if 0
- cout << "Ac " << Ac << endl;
- cout << "Bc " << Bc << endl;
- cout << "ABc " << ABc << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Ac " << Ac << endl;
+ cout << "Bc " << Bc << endl;
+ cout << "ABc " << ABc << endl;
+ }
#endif
Vec3r Ai = (fe)->vertexA()->point2D();
Vec3r Bi = (fe)->vertexB()->point2D();
@@ -295,10 +299,13 @@ iter:
}
}
#if 0
- printf("SilhouetteGeomEngine::ImageToWorldParameter(): #iters = %d, dist = %e\n", i, dist);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("SilhouetteGeomEngine::ImageToWorldParameter(): #iters = %d, dist = %e\n", i, dist);
+ }
#endif
- if (i == max_iters)
+ if (i == max_iters && G.debug & G_DEBUG_FREESTYLE) {
printf("SilhouetteGeomEngine::ImageToWorldParameter(): reached to max_iters (dist = %e)\n", dist);
+ }
}
return T;
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
index 1052965d472..4582fb40b61 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
@@ -37,6 +37,8 @@
#include "SphericalGrid.h"
+#include "BKE_global.h"
+
using namespace std;
// Helper Classes
@@ -81,9 +83,11 @@ SphericalGrid::Iterator::Iterator(SphericalGrid& grid, Vec3r& center, real epsil
// Find target cell
_cell = grid.findCell(_target);
#if SPHERICAL_GRID_LOGGING
- cout << "Searching for occluders of edge centered at " << _target << " in cell ["
- << _cell->boundary[0] << ", " << _cell->boundary[1] << ", " << _cell->boundary[2]
- << ", " << _cell->boundary[3] << "] (" << _cell->faces.size() << " occluders)" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Searching for occluders of edge centered at " << _target << " in cell ["
+ << _cell->boundary[0] << ", " << _cell->boundary[1] << ", " << _cell->boundary[2]
+ << ", " << _cell->boundary[3] << "] (" << _cell->faces.size() << " occluders)" << endl;
+ }
#endif
// Set iterator
@@ -99,16 +103,24 @@ SphericalGrid::SphericalGrid(OccluderSource& source, GridDensityProvider& densit
Vec3r& viewpoint, bool enableQI)
: _viewpoint(viewpoint), _enableQI(enableQI)
{
- cout << "Generate Cell structure" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Generate Cell structure" << endl;
+ }
// Generate Cell structure
assignCells(source, density, viewMap);
- cout << "Distribute occluders" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Distribute occluders" << endl;
+ }
// Fill Cells
distributePolygons(source);
- cout << "Reorganize cells" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Reorganize cells" << endl;
+ }
// Reorganize Cells
reorganizeCells();
- cout << "Ready to use SphericalGrid" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Ready to use SphericalGrid" << endl;
+ }
}
SphericalGrid::~SphericalGrid() {}
@@ -175,7 +187,9 @@ void SphericalGrid::distributePolygons(OccluderSource& source)
}
++nFaces;
}
- cout << "Distributed " << nFaces << " occluders. Retained " << nKeptFaces << "." << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Distributed " << nFaces << " occluders. Retained " << nKeptFaces << "." << endl;
+ }
}
void SphericalGrid::reorganizeCells()
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h
index 0f369b4b686..57ed117a935 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.h
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h
@@ -54,6 +54,8 @@
#include "../winged_edge/WEdge.h"
+#include "BKE_global.h"
+
class SphericalGrid
{
public:
@@ -192,14 +194,19 @@ inline void SphericalGrid::Iterator::initAfterTarget()
{
if (_foundOccludee) {
#if SPHERICAL_GRID_LOGGING
- std::cout << "\tStarting occludee search from occludeeCandidate at depth " << _occludeeDepth << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tStarting occludee search from occludeeCandidate at depth "
+ << _occludeeDepth << std::endl;
+ }
#endif
_current = _occludeeCandidate;
return;
}
#if SPHERICAL_GRID_LOGGING
- std::cout << "\tStarting occludee search from current position" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tStarting occludee search from current position" << std::endl;
+ }
#endif
while (_current != _cell->faces.end() && !testOccluder(true)) {
@@ -216,17 +223,21 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
return true;
}
#if SPHERICAL_GRID_LOGGING
- std::cout << "\tTesting occluder " << (*_current)->poly.getVertices()[0];
- for (unsigned int i = 1; i < (*_current)->poly.getVertices().size(); ++i) {
- std::cout << ", " << (*_current)->poly.getVertices()[i];
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\tTesting occluder " << (*_current)->poly.getVertices()[0];
+ for (unsigned int i = 1; i < (*_current)->poly.getVertices().size(); ++i) {
+ std::cout << ", " << (*_current)->poly.getVertices()[i];
+ }
+ std::cout << " from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
}
- std::cout << " from shape " << (*_current)->face->GetVertex(0)->shape()->GetId() << std::endl;
#endif
// If we have an occluder candidate and we are unambiguously after it, abort
if (_foundOccludee && (*_current)->shallowest > _occludeeDepth) {
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tAborting: shallowest > occludeeCandidate->deepest" << std::endl;
+ }
#endif
_current = _cell->faces.end();
@@ -238,7 +249,9 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
if (wantOccludee) {
if ((*_current)->deepest < _target[2]) {
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tSkipping: shallower than target while looking for occludee" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tSkipping: shallower than target while looking for occludee" << std::endl;
+ }
#endif
return false;
}
@@ -246,7 +259,9 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
else {
if ((*_current)->shallowest > _target[2]) {
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tStopping: deeper than target while looking for occluder" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tStopping: deeper than target while looking for occluder" << std::endl;
+ }
#endif
return true;
}
@@ -259,7 +274,9 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
(*_current)->poly.getBBox(bbMin, bbMax);
if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] || _target[1] > bbMax[1]) {
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tSkipping: bounding box violation" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tSkipping: bounding box violation" << std::endl;
+ }
#endif
return false;
}
@@ -275,11 +292,15 @@ inline void SphericalGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
// viewponit or target, at the cost of changing the OptimizedGrid API.
real depth = (origin + u * t).norm();
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tReporting depth of occluder/ee: " << depth;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tReporting depth of occluder/ee: " << depth;
+ }
#endif
if (depth > _target[2]) {
#if SPHERICAL_GRID_LOGGING
- std::cout << " is deeper than target" << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << " is deeper than target" << std::endl;
+ }
#endif
// If the current occluder is the best occludee so far, save it.
if (! _foundOccludee || _occludeeDepth > depth) {
@@ -288,7 +309,9 @@ inline void SphericalGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
}
else {
#if SPHERICAL_GRID_LOGGING
- std::cout << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << std::endl;
+ }
#endif
}
}
@@ -324,7 +347,9 @@ inline bool SphericalGrid::Iterator::validAfterTarget()
inline void SphericalGrid::Iterator::markCurrentOccludeeCandidate(real depth)
{
#if SPHERICAL_GRID_LOGGING
- std::cout << "\t\tFound occludeeCandidate at depth " << depth << std::endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ std::cout << "\t\tFound occludeeCandidate at depth " << depth << std::endl;
+ }
#endif
_occludeeCandidate = _current;
_occludeeDepth = depth;
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
index e39181e335d..120ef46667b 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
@@ -45,6 +45,8 @@
#include "../image/ImagePyramid.h"
#include "../image/Image.h"
+#include "BKE_global.h"
+
extern "C" {
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -206,9 +208,11 @@ void SteerableViewMap::buildImagesPyramids(GrayImage **steerableBases, bool copy
float SteerableViewMap::readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y)
{
ImagePyramid *pyramid = _imagesPyramids[iOrientation];
- if (pyramid == 0) {
- cout << "Warning: this steerable ViewMap level doesn't exist" << endl;
- return 0;
+ if (!pyramid) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Warning: this steerable ViewMap level doesn't exist" << endl;
+ }
+ return 0.0f;
}
if ((x < 0) || (x >= pyramid->width()) || (y < 0) || (y >= pyramid->height()))
return 0;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 84cd166dca0..fc7da724e8f 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -50,6 +50,11 @@
#include "../winged_edge/WFillGrid.h"
+#include "BKE_global.h"
+
+// XXX Grmll... G is used as template's typename parameter :/
+const Global &_global = G;
+
#define LOGGING FALSE
using namespace std;
@@ -77,8 +82,10 @@ static void findOccludee(FEdge *fe, G& grid, I& occluders, real epsilon, WFace *
for (occluders.initAfterTarget(); occluders.validAfterTarget(); occluders.nextOccludee()) {
#if LOGGING
- cout << "\t\tEvaluating intersection for occludee " << occluders.getWFace() << " and ray " << A
- << " * " << u << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tEvaluating intersection for occludee " << occluders.getWFace() << " and ray " << A
+ << " * " << u << endl;
+ }
#endif
oface = occluders.getWFace();
Polygon3r *p = occluders.getCameraSpacePolygon();
@@ -125,7 +132,9 @@ static void findOccludee(FEdge *fe, G& grid, I& occluders, real epsilon, WFace *
if (GeomUtils::COINCIDENT == GeomUtils::intersectRayPlane(origin, edge, p->getNormal(), d, t, epsilon))
{
#if LOGGING
- cout << "\t\tRejecting occluder for target coincidence." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRejecting occluder for target coincidence." << endl;
+ }
#endif
continue;
}
@@ -133,8 +142,10 @@ static void findOccludee(FEdge *fe, G& grid, I& occluders, real epsilon, WFace *
if (p->rayIntersect(A, v, t, t_u, t_v)) {
#if LOGGING
- cout << "\t\tRay " << A << " * " << v << " intersects at time " << t << endl;
- cout << "\t\t(v * normal) == " << (v * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRay " << A << " * " << v << " intersects at time " << t << endl;
+ cout << "\t\t(v * normal) == " << (v * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ }
#endif
if (fabs(v * p->getNormal()) > 0.0001) {
if ((t > 0.0)) { // && (t<1.0))
@@ -144,7 +155,9 @@ static void findOccludee(FEdge *fe, G& grid, I& occluders, real epsilon, WFace *
noIntersection = false;
fe->setOccludeeIntersection(Vec3r(A + t * v));
#if LOGGING
- cout << "\t\tIs occludee" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tIs occludee" << endl;
+ }
#endif
}
}
@@ -244,9 +257,11 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
Polygon3r *p = occluders.getCameraSpacePolygon();
real t, t_u, t_v;
#if LOGGING
- cout << "\t\tEvaluating intersection for occluder " << (p->getVertices())[0] << (p->getVertices())[1]
- << (p->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center << ")"
- << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tEvaluating intersection for occluder " << (p->getVertices())[0] << (p->getVertices())[1]
+ << (p->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center << ")"
+ << endl;
+ }
#endif
#if LOGGING
@@ -264,10 +279,12 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
Polygon3r p1(points, oface->GetNormal());
Vec3r v1((p1.getVertices())[0]);
real d = -(v1 * p->getNormal());
- cout << "\t\tp: " << (p->getVertices())[0] << (p->getVertices())[1] << (p->getVertices())[2] << ", norm: "
- << p->getNormal() << endl;
- cout << "\t\tp1: " << (p1.getVertices())[0] << (p1.getVertices())[1] << (p1.getVertices())[2] << ", norm: "
- << p1.getNormal() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tp: " << (p->getVertices())[0] << (p->getVertices())[1] << (p->getVertices())[2] << ", norm: "
+ << p->getNormal() << endl;
+ cout << "\t\tp1: " << (p1.getVertices())[0] << (p1.getVertices())[1] << (p1.getVertices())[2] << ", norm: "
+ << p1.getNormal() << endl;
+ }
#else
real d = -((p->getVertices())[0] * p->getNormal());
#endif
@@ -275,13 +292,17 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
if (face)
{
#if LOGGING
- cout << "\t\tDetermining face adjacency...";
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tDetermining face adjacency...";
+ }
#endif
skipFace = false;
if (face == oface) {
#if LOGGING
- cout << " Rejecting occluder for face concurrency." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face concurrency." << endl;
+ }
#endif
continue;
}
@@ -310,7 +331,9 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
}
if (skipFace) {
#if LOGGING
- cout << " Rejecting occluder for face adjacency." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face adjacency." << endl;
+ }
#endif
continue;
}
@@ -321,33 +344,41 @@ static int computeVisibility(ViewMap *viewMap, FEdge *fe, G& grid, real epsilon,
//first let us compute the plane equation.
if (GeomUtils::COINCIDENT == GeomUtils::intersectRayPlane(origin, edge, p->getNormal(), d, t, epsilon)) {
#if LOGGING
- cout << "\t\tRejecting occluder for target coincidence." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRejecting occluder for target coincidence." << endl;
+ }
#endif
continue;
}
}
#if LOGGING
- real x;
- if (p1.rayIntersect(center, v, x, t_u, t_v)) {
- cout << "\t\tRay should intersect at time " << (rl - x) << ". Center: " << center << ", V: " << v
- << ", RL: " << rl << ", T:" << x << endl;
- }
- else {
- cout << "\t\tRay should not intersect. Center: " << center << ", V: " << v << ", RL: " << rl << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ real x;
+ if (p1.rayIntersect(center, v, x, t_u, t_v)) {
+ cout << "\t\tRay should intersect at time " << (rl - x) << ". Center: " << center << ", V: " << v
+ << ", RL: " << rl << ", T:" << x << endl;
+ }
+ else {
+ cout << "\t\tRay should not intersect. Center: " << center << ", V: " << v << ", RL: " << rl << endl;
+ }
}
#endif
if (p->rayIntersect(center, u, t, t_u, t_v)) {
#if LOGGING
- cout << "\t\tRay " << center << " * " << u << " intersects at time " << t << " (raylength is "
- << raylength << ")" << endl;
- cout << "\t\t(u * normal) == " << (u * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRay " << center << " * " << u << " intersects at time " << t << " (raylength is "
+ << raylength << ")" << endl;
+ cout << "\t\t(u * normal) == " << (u * p->getNormal()) << " for normal " << p->getNormal() << endl;
+ }
#endif
if (fabs(u * p->getNormal()) > 0.0001) {
if ((t > 0.0) && (t < raylength)) {
#if LOGGING
- cout << "\t\tIs occluder" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tIs occluder" << endl;
+ }
#endif
if ( foundOccluders != NULL ) {
ViewShape *vshape = viewMap->viewShape(oface->GetVertex(0)->shape()->GetId());
@@ -395,7 +426,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
if (iRenderMonitor && iRenderMonitor->testBreak())
break;
#if LOGGING
- cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ }
#endif
// Find an edge to test
if (!(*ve)->isInImage()) {
@@ -403,7 +436,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
(*ve)->setQI(255);
(*ve)->setaShape(0);
#if LOGGING
- cout << "\tCulled." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tCulled." << endl;
+ }
#endif
continue;
}
@@ -422,7 +457,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
if (qiMajority == 0) {
// There are no occludable FEdges on this ViewEdge
// This should be impossible.
- cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ }
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
@@ -434,7 +471,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
qiMajority >>= 1;
}
#if LOGGING
- cout << "\tqiMajority: " << qiMajority << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tqiMajority: " << qiMajority << endl;
+ }
#endif
tmpQI = 0;
@@ -454,7 +493,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
//ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
- cout << "\tFEdge: visibility " << tmpQI << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: visibility " << tmpQI << endl;
+ }
#endif
//ARB: This is an error condition, not an alert condition.
@@ -475,7 +516,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
//ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
- cout << "\tFEdge: occludee only (" << (wFace != NULL ? "found" : "not found") << ")" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: occludee only (" << (wFace != NULL ? "found" : "not found") << ")" << endl;
+ }
#endif
}
@@ -491,7 +534,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
wFaces.push_back(wFace);
fe->setOccludeeEmpty(false);
#if LOGGING
- cout << "\tFound occludee" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFound occludee" << endl;
+ }
#endif
}
else {
@@ -503,7 +548,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
} while ((maxCard < qiMajority) && (fe) && (fe != festart));
#if LOGGING
- cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ }
#endif
// ViewEdge
@@ -523,7 +570,9 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
(*ve)->AddOccluder((*o));
}
#if LOGGING
- cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ }
#endif
// occludee --
if (!wFaces.empty()) {
@@ -557,7 +606,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
if (iRenderMonitor && iRenderMonitor->testBreak())
break;
#if LOGGING
- cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ }
#endif
// Find an edge to test
if (!(*ve)->isInImage()) {
@@ -565,7 +616,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
(*ve)->setQI(255);
(*ve)->setaShape(0);
#if LOGGING
- cout << "\tCulled." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tCulled." << endl;
+ }
#endif
continue;
}
@@ -584,7 +637,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
if (qiMajority == 0) {
// There are no occludable FEdges on this ViewEdge
// This should be impossible.
- cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ }
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
@@ -596,7 +651,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
qiMajority >>= 1;
}
#if LOGGING
- cout << "\tqiMajority: " << qiMajority << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tqiMajority: " << qiMajority << endl;
+ }
#endif
tmpQI = 0;
@@ -616,7 +673,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
//ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
- cout << "\tFEdge: visibility " << tmpQI << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: visibility " << tmpQI << endl;
+ }
#endif
//ARB: This is an error condition, not an alert condition.
@@ -637,7 +696,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
//ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
- cout << "\tFEdge: occludee only (" << (wFace != NULL ? "found" : "not found") << ")" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: occludee only (" << (wFace != NULL ? "found" : "not found") << ")" << endl;
+ }
#endif
}
@@ -653,7 +714,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
wFaces.push_back(wFace);
fe->setOccludeeEmpty(false);
#if LOGGING
- cout << "\tFound occludee" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFound occludee" << endl;
+ }
#endif
}
else {
@@ -665,7 +728,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
} while ((maxCard < qiMajority) && (fe) && (fe != festart));
#if LOGGING
- cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ }
#endif
// ViewEdge
@@ -678,7 +743,9 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon,
(*ve)->AddOccluder((*o));
}
#if LOGGING
- cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ }
#endif
// occludee --
if (!wFaces.empty()) {
@@ -735,7 +802,9 @@ static void computeFastVisibility(ViewMap *ioViewMap, G& grid, real epsilon)
if (qiMajority == 0 ) {
// There are no occludable FEdges on this ViewEdge
// This should be impossible.
- cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ }
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
@@ -852,7 +921,9 @@ static void computeVeryFastVisibility(ViewMap *ioViewMap, G& grid, real epsilon)
if (!fe || !fe->isInImage()) {
// There are no occludable FEdges on this ViewEdge
// This should be impossible.
- cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "View Edge in viewport without occludable FEdges: " << (*ve)->getId() << endl;
+ }
// We can recover from this error:
// Treat this edge as fully visible with no occludee
qi = 0;
@@ -889,7 +960,9 @@ void ViewMapBuilder::BuildGrid(WingedEdge& we, const BBox<Vec3r>& bbox, unsigned
size[i] = fabs(bbox.getMax()[i] - bbox.getMin()[i]);
size[i] += size[i]/10.0; // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells intersections
if (size[i] == 0) {
- cout << "Warning: the bbox size is 0 in dimension " << i << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Warning: the bbox size is 0 in dimension " << i << endl;
+ }
}
}
_Grid->configure(Vec3r(bbox.getMin() - size / 20.0), size, sceneNumFaces);
@@ -962,10 +1035,12 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap, real viewProscenium[4], r
real prosceniumOrigin[2];
prosceniumOrigin[0] = (viewProscenium[1] - viewProscenium[0]) / 2.0;
prosceniumOrigin[1] = (viewProscenium[3] - viewProscenium[2]) / 2.0;
- cout << "Proscenium culling:" << endl;
- cout << "Proscenium: [" << viewProscenium[0] << ", " << viewProscenium[1] << ", " << viewProscenium[2]
- << ", " << viewProscenium[3] << "]"<< endl;
- cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]"<< endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Proscenium culling:" << endl;
+ cout << "Proscenium: [" << viewProscenium[0] << ", " << viewProscenium[1] << ", " << viewProscenium[2]
+ << ", " << viewProscenium[3] << "]"<< endl;
+ cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]"<< endl;
+ }
// A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
// expanding as necessary so that it encompasses the center point of at least one feature edge in each retained view
@@ -1276,22 +1351,30 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap, WingedEdge& we,
{
switch(iAlgo) {
case ray_casting:
- cout << "Using ordinary ray casting" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using ordinary ray casting" << endl;
+ }
BuildGrid(we, bbox, sceneNumFaces);
ComputeRayCastingVisibility(ioViewMap, epsilon);
break;
case ray_casting_fast:
- cout << "Using fast ray casting" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using fast ray casting" << endl;
+ }
BuildGrid(we, bbox, sceneNumFaces);
ComputeFastRayCastingVisibility(ioViewMap, epsilon);
break;
case ray_casting_very_fast:
- cout << "Using very fast ray casting" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using very fast ray casting" << endl;
+ }
BuildGrid(we, bbox, sceneNumFaces);
ComputeVeryFastRayCastingVisibility(ioViewMap, epsilon);
break;
case ray_casting_culled_adaptive_traditional:
- cout << "Using culled adaptive grid with heuristic density and traditional QI calculation" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using culled adaptive grid with heuristic density and traditional QI calculation" << endl;
+ }
try {
HeuristicGridDensityProviderFactory factory(0.5f, sceneNumFaces);
ComputeDetailedVisibility(ioViewMap, we, bbox, epsilon, true, factory);
@@ -1310,7 +1393,9 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap, WingedEdge& we,
}
break;
case ray_casting_adaptive_traditional:
- cout << "Using unculled adaptive grid with heuristic density and traditional QI calculation" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using unculled adaptive grid with heuristic density and traditional QI calculation" << endl;
+ }
try {
HeuristicGridDensityProviderFactory factory(0.5f, sceneNumFaces);
ComputeDetailedVisibility(ioViewMap, we, bbox, epsilon, false, factory);
@@ -1320,7 +1405,9 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap, WingedEdge& we,
}
break;
case ray_casting_culled_adaptive_cumulative:
- cout << "Using culled adaptive grid with heuristic density and cumulative QI calculation" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using culled adaptive grid with heuristic density and cumulative QI calculation" << endl;
+ }
try {
HeuristicGridDensityProviderFactory factory(0.5f, sceneNumFaces);
ComputeCumulativeVisibility(ioViewMap, we, bbox, epsilon, true, factory);
@@ -1330,7 +1417,9 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap, WingedEdge& we,
}
break;
case ray_casting_adaptive_cumulative:
- cout << "Using unculled adaptive grid with heuristic density and cumulative QI calculation" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Using unculled adaptive grid with heuristic density and cumulative QI calculation" << endl;
+ }
try {
HeuristicGridDensityProviderFactory factory(0.5f, sceneNumFaces);
ComputeCumulativeVisibility(ioViewMap, we, bbox, epsilon, false, factory);
@@ -1379,7 +1468,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
if (_pRenderMonitor && _pRenderMonitor->testBreak())
break;
#if LOGGING
- cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "Processing ViewEdge " << (*ve)->getId() << endl;
+ }
#endif
festart = (*ve)->fedgeA();
fe = (*ve)->fedgeA();
@@ -1390,7 +1481,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
} while (fe && fe != festart);
qiMajority >>= 1;
#if LOGGING
- cout << "\tqiMajority: " << qiMajority << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tqiMajority: " << qiMajority << endl;
+ }
#endif
tmpQI = 0;
@@ -1405,7 +1498,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
tmpQI = ComputeRayCastingVisibility(fe, _Grid, epsilon, occluders, &aFace, timestamp++);
#if LOGGING
- cout << "\tFEdge: visibility " << tmpQI << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: visibility " << tmpQI << endl;
+ }
#endif
//ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
@@ -1424,7 +1519,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
//ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
FindOccludee(fe, _Grid, epsilon, &aFace, timestamp++);
#if LOGGING
- cout << "\tFEdge: occludee only (" << (aFace != NULL ? "found" : "not found") << ")" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFEdge: occludee only (" << (aFace != NULL ? "found" : "not found") << ")" << endl;
+ }
#endif
}
@@ -1433,7 +1530,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
aFaces.push_back(aFace);
fe->setOccludeeEmpty(false);
#if LOGGING
- cout << "\tFound occludee" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFound occludee" << endl;
+ }
#endif
}
else {
@@ -1447,7 +1546,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
fe = fe->nextEdge();
} while ((maxCard < qiMajority) && (fe) && (fe != festart));
#if LOGGING
- cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl;
+ }
#endif
// ViewEdge
@@ -1457,7 +1558,9 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
for (set<ViewShape*>::iterator o = occluders.begin(), oend = occluders.end(); o != oend; ++o)
(*ve)->AddOccluder((*o));
#if LOGGING
- cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() << " occluders." << endl;
+ }
#endif
// occludee --
if (!aFaces.empty()) {
@@ -1837,9 +1940,11 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
real raylength = u.norm();
u.normalize();
#if 0
- cout << "grid origin " << iGrid->getOrigin().x() << "," << iGrid->getOrigin().y() << ","
- << iGrid->getOrigin().z() << endl;
- cout << "center " << center.x() << "," << center.y() << "," << center.z() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "grid origin " << iGrid->getOrigin().x() << "," << iGrid->getOrigin().y() << ","
+ << iGrid->getOrigin().z() << endl;
+ cout << "center " << center.x() << "," << center.y() << "," << center.z() << endl;
+ }
#endif
iGrid->castRay(center, vp, occluders, timestamp);
@@ -1864,9 +1969,11 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
//-----------
oface = (WFace*)(*p)->userdata;
#if LOGGING
- cout << "\t\tEvaluating intersection for occluder " << ((*p)->getVertices())[0] << ((*p)->getVertices())[1]
- << ((*p)->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center
- << ")" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tEvaluating intersection for occluder " << ((*p)->getVertices())[0] << ((*p)->getVertices())[1]
+ << ((*p)->getVertices())[2] << endl << "\t\t\tand ray " << vp << " * " << u << " (center " << center
+ << ")" << endl;
+ }
#endif
Vec3r v1(((*p)->getVertices())[0]);
Vec3r normal((*p)->getNormal());
@@ -1874,19 +1981,25 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
real t, t_u, t_v;
#if LOGGING
- cout << "\t\tp: " << ((*p)->getVertices())[0] << ((*p)->getVertices())[1] << ((*p)->getVertices())[2]
- << ", norm: " << (*p)->getNormal() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tp: " << ((*p)->getVertices())[0] << ((*p)->getVertices())[1] << ((*p)->getVertices())[2]
+ << ", norm: " << (*p)->getNormal() << endl;
+ }
#endif
if (face) {
#if LOGGING
- cout << "\t\tDetermining face adjacency...";
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tDetermining face adjacency...";
+ }
#endif
skipFace = false;
if (face == oface) {
#if LOGGING
- cout << " Rejecting occluder for face concurrency." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face concurrency." << endl;
+ }
#endif
continue;
}
@@ -1917,7 +2030,9 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
}
if (skipFace) {
#if LOGGING
- cout << " Rejecting occluder for face adjacency." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << " Rejecting occluder for face adjacency." << endl;
+ }
#endif
continue;
}
@@ -1929,7 +2044,9 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
if (GeomUtils::COINCIDENT == GeomUtils::intersectRayPlane(origin, edge, normal, d, t, epsilon)) {
#if LOGGING
- cout << "\t\tRejecting occluder for target coincidence." << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRejecting occluder for target coincidence." << endl;
+ }
#endif
continue;
}
@@ -1937,14 +2054,18 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps
if ((*p)->rayIntersect(center, u, t, t_u, t_v)) {
#if LOGGING
- cout << "\t\tRay " << vp << " * " << u << " intersects at time " << t << " (raylength is "
- << raylength << ")" << endl;
- cout << "\t\t(u * normal) == " << (u * normal) << " for normal " << normal << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tRay " << vp << " * " << u << " intersects at time " << t << " (raylength is "
+ << raylength << ")" << endl;
+ cout << "\t\t(u * normal) == " << (u * normal) << " for normal " << normal << endl;
+ }
#endif
if (fabs(u * normal) > 0.0001) {
if ((t>0.0) && (t<raylength)) {
#if LOGGING
- cout << "\t\tIs occluder" << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "\t\tIs occluder" << endl;
+ }
#endif
WFace *f = (WFace*)((*p)->userdata);
ViewShape *vshape = _ViewMap->viewShape(f->GetVertex(0)->shape()->GetId());
@@ -1979,11 +2100,13 @@ void ViewMapBuilder::ComputeIntersections(ViewMap *ioViewMap, intersection_algo
{
if ((*vv)->getNature() == Nature::T_VERTEX) {
TVertex *tvertex = (TVertex*)(*vv);
- cout << "TVertex " << tvertex->getId() << " has :" << endl;
- cout << "FrontEdgeA: " << tvertex->frontEdgeA().first << endl;
- cout << "FrontEdgeB: " << tvertex->frontEdgeB().first << endl;
- cout << "BackEdgeA: " << tvertex->backEdgeA().first << endl;
- cout << "BackEdgeB: " << tvertex->backEdgeB().first << endl << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ cout << "TVertex " << tvertex->getId() << " has :" << endl;
+ cout << "FrontEdgeA: " << tvertex->frontEdgeA().first << endl;
+ cout << "FrontEdgeB: " << tvertex->frontEdgeB().first << endl;
+ cout << "BackEdgeA: " << tvertex->backEdgeA().first << endl;
+ cout << "BackEdgeB: " << tvertex->backEdgeB().first << endl << endl;
+ }
}
}
}
@@ -2061,9 +2184,11 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
unsigned sVerticesSize = svertices.size();
unsigned fEdgesSize = ioViewMap->FEdges().size();
#if 0
- ViewMap::fedges_container& fedges = ioViewMap->FEdges();
- for (ViewMap::fedges_container::const_iterator f = fedges.begin(), end = fedges.end(); f != end; ++f) {
- cout << (*f)->aMaterialIndex() << "-" << (*f)->bMaterialIndex() << endl;
+ if (_global.debug & G_DEBUG_FREESTYLE) {
+ ViewMap::fedges_container& fedges = ioViewMap->FEdges();
+ for (ViewMap::fedges_container::const_iterator f = fedges.begin(), end = fedges.end(); f != end; ++f) {
+ cout << (*f)->aMaterialIndex() << "-" << (*f)->bMaterialIndex() << endl;
+ }
}
#endif
unsigned progressBarStep = 0;
@@ -2184,17 +2309,19 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
<< fB->vertexB()->getId() << endl;
#if 0
- if ((Ta < -epsilon) || (Ta > 1 + epsilon) || (Tb < -epsilon) || (Tb > 1 + epsilon)) {
- printf("ta %.12e\n", ta);
- printf("tb %.12e\n", tb);
- printf("a1 %e, %e -- b1 %e, %e\n", a1[0], a1[1], b1[0], b1[1]);
- printf("a2 %e, %e -- b2 %e, %e\n", a2[0], a2[1], b2[0], b2[1]);
- if ((Ta < -epsilon) || (Ta > 1 + epsilon))
- printf("Ta %.12e\n", Ta);
- if ((Tb < -epsilon) || (Tb > 1 + epsilon))
- printf("Tb %.12e\n", Tb);
- printf("A1 %e, %e, %e -- B1 %e, %e, %e\n", A1[0], A1[1], A1[2], B1[0], B1[1], B1[2]);
- printf("A2 %e, %e, %e -- B2 %e, %e, %e\n", A2[0], A2[1], A2[2], B2[0], B2[1], B2[2]);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ if ((Ta < -epsilon) || (Ta > 1 + epsilon) || (Tb < -epsilon) || (Tb > 1 + epsilon)) {
+ printf("ta %.12e\n", ta);
+ printf("tb %.12e\n", tb);
+ printf("a1 %e, %e -- b1 %e, %e\n", a1[0], a1[1], b1[0], b1[1]);
+ printf("a2 %e, %e -- b2 %e, %e\n", a2[0], a2[1], b2[0], b2[1]);
+ if ((Ta < -epsilon) || (Ta > 1 + epsilon))
+ printf("Ta %.12e\n", Ta);
+ if ((Tb < -epsilon) || (Tb > 1 + epsilon))
+ printf("Tb %.12e\n", Tb);
+ printf("A1 %e, %e, %e -- B1 %e, %e, %e\n", A1[0], A1[1], A1[2], B1[0], B1[1], B1[2]);
+ printf("A2 %e, %e, %e -- B2 %e, %e, %e\n", A2[0], A2[1], A2[2], B2[0], B2[1], B2[2]);
+ }
}
#endif
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index fed9a1588bb..719ed10925d 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -33,6 +33,7 @@
*/
#include "WXEdge.h"
+#include "BKE_global.h"
/**********************************
* *
@@ -132,7 +133,9 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
RetrieveCuspEdgesIndices(cuspEdgesIndices);
// We should have only one EdgeCusp:
if (cuspEdgesIndices.size() != 1) {
- cout << "Warning in BuildSmoothEdge: weird WXFace configuration" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Warning in BuildSmoothEdge: weird WXFace configuration" << endl;
+ }
_pSmoothEdge = NULL;
return NULL;
}