diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-10 03:06:28 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-10 03:06:28 +0400 |
commit | fd9ad582983939741a4c4fa5f2707f29365d6c09 (patch) | |
tree | d8817227d5b5687af533316e18b4db40512884e6 /source/blender/freestyle/intern/stroke | |
parent | 64e4a3ec9aed6c8abe095e2cd1fe1552f7cde51c (diff) |
soc-2008-mxcurioni: towards Freestyle compilation, removing Qt's QString and QImage dependencies. Up to this commit, the following directories compile well (and without any warning): system, image, geometry, graph, winged_edge, view_map, stroke.
Modified code is commented by //soc and unused variables by //soc unused
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
7 files changed, 113 insertions, 64 deletions
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp index cf2982606e0..ca0e97e68c1 100755 --- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp +++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp @@ -89,13 +89,13 @@ namespace Functions1D { } double GetDirectionalViewMapDensityF1D::operator()(Interface1D& inter) { - unsigned size; + //soc unsigned size; double res = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration); return res; } double GetCompleteViewMapDensityF1D::operator()(Interface1D& inter) { - unsigned size; + //soc unsigned size; Id id = inter.getId(); double res = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration); return res; diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index c3827ae3e36..40a0bbbc738 100755 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -20,7 +20,6 @@ /////////////////////////////////////////////////////////////////////////////// #include <fstream> -#include <qimage.h> #include "BasicStrokeShaders.h" #include "../system/PseudoNoise.h" #include "../system/RandGen.h" @@ -32,16 +31,32 @@ #include "../system/StringUtils.h" #include "StrokeRenderer.h" #include "StrokeIO.h" -#include <QString> + +//soc #include <qimage.h> +//soc #include <QString> +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" // Internal function -void convert(const QImage& iImage, float **oArray, unsigned &oSize) { - oSize = iImage.width(); - *oArray = new float[oSize]; - for(unsigned i=0; i<oSize; ++i) { - QRgb rgb = iImage.pixel(i,0); - (*oArray)[i] = ((float)qBlue(rgb))/255.f; - } + +// soc +// void convert(const QImage& iImage, float **oArray, unsigned &oSize) { +// oSize = iImage.width(); +// *oArray = new float[oSize]; +// for(unsigned i=0; i<oSize; ++i) { +// QRgb rgb = iImage.pixel(i,0); +// (*oArray)[i] = ((float)qBlue(rgb))/255.f; +// } +// } +void convert(ImBuf *imBuf, float **oArray, unsigned &oSize) { + oSize = imBuf->x; + *oArray = new float[oSize]; + + char *pix; + for(unsigned i=0; i < oSize; ++i) { + pix = (char*) imBuf->rect + i*4; + (*oArray)[i] = ((float) pix[2] )/255.f; + } } namespace StrokeShaders { @@ -137,7 +152,7 @@ namespace StrokeShaders { { float step = (_maxThickness-_minThickness)/3.f; float l = stroke.getLength2D(); - float thickness; + float thickness = 0.0; if(l>300.f) thickness = _minThickness+3.f*step; else if((l< 300.f) && (l>100.f)) @@ -172,7 +187,7 @@ namespace StrokeShaders { _stretch = stretch; _minThickness = iMinThickness; _maxThickness = iMaxThickness; - QImage image; + ImBuf *image = 0; //soc vector<string> pathnames; StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, @@ -180,11 +195,12 @@ namespace StrokeShaders { for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) { ifstream ifs(j->c_str()); if (ifs.is_open()) { - image.load(j->c_str()); - break; + //soc image.load(j->c_str()); + image = IMB_loadiffname(j->c_str(), 0); + break; } } - if (image.isNull()) + if (image == 0) //soc cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl; else @@ -315,7 +331,7 @@ namespace StrokeShaders { bool stretch) : StrokeShader() { _stretch = stretch; - QImage image; + ImBuf *image = 0; //soc vector<string> pathnames; StringUtils::getPathName(TextureManager::Options::getPatternsPath(), pattern_name, @@ -323,11 +339,11 @@ namespace StrokeShaders { for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) { ifstream ifs(j->c_str()); if (ifs.is_open()) { - image.load(j->c_str()); - break; + image = IMB_loadiffname(j->c_str(), 0); //soc + break; } } - if (image.isNull()) + if (image == 0) //soc cerr << "Error: cannot find pattern \"" << pattern_name << "\" - check the path in the Options" << endl; else @@ -558,7 +574,7 @@ namespace StrokeShaders { void ExternalContourStretcherShader::shade(Stroke& stroke) const { - float l=stroke.getLength2D(); + //float l=stroke.getLength2D(); Interface0DIterator it=stroke.verticesBegin(); Functions0D::Normal2DF0D fun; StrokeVertex* sv; @@ -1074,7 +1090,7 @@ namespace StrokeShaders { // number of vertices than before stroke.Resample(originalSize); - if(stroke.strokeVerticesSize() != originalSize) + if((int)stroke.strokeVerticesSize() != originalSize) //soc cerr << "Warning: resampling problem" << endl; // assign old attributes to new stroke vertices: diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index ecb76c4a015..7e63d964cb5 100755 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -25,14 +25,19 @@ #include "../system/TimeStamp.h" #include "../system/PseudoNoise.h" #include "Canvas.h" -#include <qimage.h> -#include <QString> #include "../image/Image.h" #include "../image/GaussianFilter.h" #include "../image/ImagePyramid.h" #include "../view_map/SteerableViewMap.h" #include "StyleModule.h" +//soc #include <qimage.h> +//soc #include <QString> +#include <sstream> +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "intern/IMB_bmp.h" + using namespace std; LIB_STROKE_EXPORT @@ -326,21 +331,35 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i }else{ filePath = iFileName; } - QImage * qimg; - QImage newMap(filePath.c_str()); - if(newMap.isNull()){ - cout << "Could not load image file " << filePath << endl; - return; - } - qimg = &newMap; - + + //soc + // QImage *qimg; + // QImage newMap(filePath.c_str()); + // if(newMap.isNull()){ + // cout << "Could not load image file " << filePath << endl; + // return; + // } + // qimg = &newMap; + ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0);; + if( qimg == 0 ){ + cout << "Could not load image file " << filePath << endl; + return; + } + + // soc //resize - QImage scaledImg; - if((newMap.width()!=width()) || (newMap.height()!=height())){ - scaledImg = newMap.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - qimg = &scaledImg; + // QImage scaledImg; + // if((newMap.width()!=width()) || (newMap.height()!=height())){ + // scaledImg = newMap.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + // qimg = &scaledImg; + // } + ImBuf *scaledImg; + if( ( qimg->x != width() ) || ( qimg->y != height() ) ){ + scaledImg = IMB_dupImBuf(qimg); + IMB_scaleImBuf(scaledImg, width(), height()); } + // deal with color image // if(newMap->depth() != 8){ // int w = newMap->width(); @@ -356,13 +375,17 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i // newMap = tmp; // } - unsigned x,y; - int w = qimg->width(); - int h = qimg->height(); + int x,y; + int w = qimg->x; + int h = qimg->y; +int rowbytes = w*4; GrayImage tmp(w,h); + char *pix; + for(y=0; y<h;++y){ for(x=0;x<w;++x){ - float c = qGray(qimg->pixel(x,y));// /255.f; + pix = (char*)qimg->rect + y*rowbytes + x*4; + float c = (pix[0]*11 + pix[1]*16 + pix[2]*5)/32; tmp.setPixel(x,y,c); } } @@ -380,20 +403,30 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i GaussianPyramid *pyramid = new GaussianPyramid(tmp, iNbLevels, iSigma); int ow = pyramid->width(0); int oh = pyramid->height(0); - QString base(iMapName); - for(unsigned i=0; i<pyramid->getNumberOfLevels(); ++i){ + string base(iMapName); //soc + for(int i=0; i<pyramid->getNumberOfLevels(); ++i){ // save each image: // w = pyramid.width(i); // h = pyramid.height(i); - QImage qtmp(ow, oh, QImage::Format_RGB32); - //int k = (1<<i); + + //soc QImage qtmp(ow, oh, QImage::Format_RGB32); + ImBuf *qtmp = IMB_allocImBuf(ow, oh, 32, IB_rect, 0); + +//int k = (1<<i); for(y=0;y<oh;++y){ for(x=0;x<ow;++x){ int c = pyramid->pixel(x,y,i);//255*pyramid->pixel(x,y,i); - qtmp.setPixel(x,y,qRgb(c,c,c)); + //soc qtmp.setPixel(x,y,qRgb(c,c,c)); + pix = (char*)qtmp->rect + y*rowbytes + x*4; + pix[0] = pix [1] = pix[2] = c; } } - qtmp.save(base+QString::number(i)+".bmp", "BMP"); + //soc qtmp.save(base+QString::number(i)+".bmp", "BMP"); + stringstream filename; + filename << base; + filename << i << ".bmp"; + imb_savebmp(qtmp, const_cast<char *>(filename.str().c_str()), 0); + } // QImage *qtmp = new QImage(w, h, 32); // for(y=0;y<h;++y){ diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp index 206b6eb7364..ede3488c546 100755 --- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp +++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp @@ -106,7 +106,7 @@ ViewEdge * ChainSilhouetteIterator::traverse(const AdjacencyIterator& ait){ return 0; } if(nextVertex->getNature() & Nature::NON_T_VERTEX){ - NonTVertex * nontvertex = (NonTVertex*)nextVertex; + //soc NonTVertex * nontvertex = (NonTVertex*)nextVertex; ViewEdge * newEdge(0); // we'll try to chain the edges by keeping the same nature... // the preseance order is : SILHOUETTE, BORDER, CREASE, SUGGESTIVE, VALLEY, RIDGE diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp index 121dee3ba26..8e34d9c5197 100755 --- a/source/blender/freestyle/intern/stroke/Operators.cpp +++ b/source/blender/freestyle/intern/stroke/Operators.cpp @@ -71,7 +71,7 @@ void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, unsigned id = 0; ViewEdge* edge; - Chain* new_chain; + //soc unused - Chain* new_chain; for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); @@ -108,7 +108,7 @@ void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, Predicates1D::EqualToChainingTimeStampUP1D pred_ts(TimeStamp::instance()->getTimeStamp()+1); ViewEdge* edge; - Chain* new_chain; + //soc Chain* new_chain; for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); @@ -232,7 +232,7 @@ void Operators::bidirectionalChain(ChainingIterator& it, UnaryPredicate1D& pred) Predicates1D::EqualToChainingTimeStampUP1D pred_ts(TimeStamp::instance()->getTimeStamp()+1); ViewEdge* edge; - Chain* new_chain; + //soc unused - Chain* new_chain; for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); @@ -279,7 +279,7 @@ void Operators::bidirectionalChain(ChainingIterator& it) { Predicates1D::EqualToChainingTimeStampUP1D pred_ts(TimeStamp::instance()->getTimeStamp()+1); ViewEdge* edge; - Chain* new_chain; + //soc unused - Chain* new_chain; for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); @@ -604,7 +604,7 @@ void __recursiveSplit(Chain *_curve, UnaryFunction0D<double>& func, UnaryPredica //real _min = func(it0d);++it; real _min = FLT_MAX;++it; real mean = 0.f; - real variance = 0.f; + //soc unused - real variance = 0.f; unsigned count = 0; CurveInternal::CurvePointIterator next = it;++next; real tmp; @@ -767,7 +767,7 @@ Stroke* createStroke(Interface1D& inter) { Vec3r previous = current; SVertex* sv; CurvePoint* cp; - StrokeVertex* stroke_vertex; + StrokeVertex* stroke_vertex = NULL; do { cp = dynamic_cast<CurvePoint*>(&(*it)); diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index d6ff4d255c4..7e7eb5ff3f0 100755 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -463,7 +463,7 @@ void Stroke::SetLength(float iLength) float Stroke::ComputeSampling(int iNVertices) { - if(iNVertices <= _Vertices.size()) + if(iNVertices <= (int)_Vertices.size()) //soc return _sampling; float sampling = _Length/(float)(iNVertices-_Vertices.size()+1); diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index 055e1fb1be4..51a1c8cfd4d 100755 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -303,7 +303,7 @@ Strip::createStrip (const vector<StrokeVertex*>& iStrokeVertices) real dp1 = userDir*orthDir; real dp2 = userDir*t; real h = (thicknessLast[1]+thicknessLast[0])/dp1; - real x = fabs(h*dp2/2.0); + //soc unused - real x = fabs(h*dp2/2.0); if(dp1>0){ //i'm in the upper part of the unit circle if(dp2>0){ @@ -367,7 +367,7 @@ Strip::createStrip (const vector<StrokeVertex*>& iStrokeVertices) if (iStrokeVertices.size()<3) _averageThickness=0.5*(thicknessLast[1]+thicknessLast[0]+thickness[0]+thickness[1]); - if (i!=2*iStrokeVertices.size()) + if (i != 2*(int)iStrokeVertices.size()) cerr << "Warning: problem with stripe size\n"; cleanUpSingularities (iStrokeVertices); @@ -380,7 +380,7 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices) { int k; - unsigned sizeStrip = _vertices.size(); + int sizeStrip = _vertices.size(); for (k=0; k<sizeStrip; k++) if (notValid(_vertices[k]->point2d())) @@ -393,7 +393,7 @@ Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices) if (iStrokeVertices.size()<2) return; int i=0, j; vector<StrokeVertex*>::const_iterator v ,vend, v2, vPrev; - StrokeVertex *sv, *sv2, *svPrev; +StrokeVertex *sv, *sv2; //soc unused - *svPrev; bool singu1=false, singu2=false; int timeSinceSingu1=0, timeSinceSingu2=0; @@ -469,7 +469,7 @@ Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices) { //traverse all the vertices of the singularity and average them Vec2r avP(0.0,0.0); - for (int j=i-timeSinceSingu1; j<i; j++) + for (j=i-timeSinceSingu1; j<i; j++) avP=Vec2r(avP+_vertices[2*j]->point2d()); avP=Vec2r(1.0/float(timeSinceSingu1)*avP); for (j=i-timeSinceSingu1; j<i; j++) @@ -525,18 +525,18 @@ Strip::computeTexCoord (const vector<StrokeVertex*>& iStrokeVertices) void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd) { - unsigned int sizeStrip = _vertices.size()+8; //for the transition between the tip and the body + //soc unused - unsigned int sizeStrip = _vertices.size()+8; //for the transition between the tip and the body vector<StrokeVertex*>::const_iterator v ,vend; - StrokeVertex *sv; + StrokeVertex *sv = 0; v=iStrokeVertices.begin(); vend=iStrokeVertices.end(); float l=(*v)->strokeLength()/_averageThickness; int tiles=int(l); float fact=(float(tiles)+0.5)/l; - float uTip2=float(tiles)+0.25; + //soc unused - float uTip2=float(tiles)+0.25; float u=0; - float uPrev; + float uPrev=0; int i=0; float t; StrokeVertexRep *tvRep1, *tvRep2; @@ -757,7 +757,7 @@ StrokeRep::StrokeRep(Stroke *iStroke) StrokeRep::StrokeRep(const StrokeRep& iBrother) { - int i=0; + //soc unused - int i=0; _stroke = iBrother._stroke; _strokeType=iBrother._strokeType; _textureId = iBrother._textureId; |