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>2009-03-21 01:55:07 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-03-21 01:55:07 +0300
commita0682124459d870e53f1bc5d9b1d2930e5a907f3 (patch)
treea8bd700614557ceeea6a57d6a58306948292a5f9 /source/blender/freestyle/intern/view_map
parentac0918a1beb4c40dab17a914ca58042642a266d0 (diff)
Made changes to the C++ API in order to allow for proper error
propagation up to the toplevel error handler in BPY_txt_do_python_Text(). Before these changes were made, the operator() methods of predicates and functions, for example, returned a value of various types such as bool, double and Vec2f. These returned values were not capable to represent an error state in many cases. Now the operator() methods always return 0 on normal exit and -1 on error. The original returned values are stored in the "result" member variables of the predicate/function classes. This means that if we have a code fragment like below: UnaryPredicate1D& pred; Interface1D& inter; if (pred(inter)) { /* do something */ } then we have to rewrite it as follows: UnaryPredicate1D& pred; Interface1D& inter; if (pred(inter) < 0) return -1; /* an error in pred() is propagated */ if (pred.result) { /* do something */ } Suppose that pred is a user-defined predicate in Python, i.e. the predicate is likely error-prone (especially when debugging the predicate). The first code fragment shown above prevents the proper error propagation because the boolean return value of UnaryPredicate1D::operator() cannot inform the occurrence of an error to the caller; the second code fragment can. In addition to the operator() methods of predicates and functions, similar improvements have been made to all other C++ API functions and methods that are involved in the execution of user-defined Python code snippets. Changes in the signatures of functions and methods are summarized as follows (note that all subclasses of listed classes are also subject to the changes). Old signatures: virtual void Iterator::increment(); virtual void Iterator::decrement(); virtual void ChainingIterator::init(); virtual ViewEdge * ChainingIterator::traverse(const AdjacencyIterator &it); static void Operators::select(UnaryPredicate1D& pred); static void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, UnaryPredicate1D& pred, UnaryFunction1D_void& modifier); static void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, UnaryPredicate1D& pred); static void Operators::bidirectionalChain(ChainingIterator& it, UnaryPredicate1D& pred); static void Operators::bidirectionalChain(ChainingIterator& it); static void Operators::sequentialSplit(UnaryPredicate0D& startingPred, UnaryPredicate0D& stoppingPred, float sampling = 0); static void Operators::sequentialSplit(UnaryPredicate0D& pred, float sampling = 0); static void Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate1D& pred, float sampling = 0); static void Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate0D& pred0d, UnaryPredicate1D& pred, float sampling = 0); static void Operators::sort(BinaryPredicate1D& pred); static void Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders); virtual bool UnaryPredicate0D::operator()(Interface0DIterator& it); virtual bool BinaryPredicate0D::operator()(Interface0D& inter1, Interface0D& inter2); virtual bool UnaryPredicate1D::operator()(Interface1D& inter); virtual bool BinaryPredicate1D::operator()(Interface1D& inter1, Interface1D& inter2); virtual void StrokeShader::shade(Stroke& ioStroke) const; virtual T UnaryFunction0D::operator()(Interface0DIterator& iter); virtual T UnaryFunction1D::operator()(Interface1D& inter); New signatures: virtual int Iterator::increment(); virtual int Iterator::decrement(); virtual int ChainingIterator::init(); virtual int ChainingIterator::traverse(const AdjacencyIterator &it); static int Operators::select(UnaryPredicate1D& pred); static int Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, UnaryPredicate1D& pred, UnaryFunction1D_void& modifier); static int Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it, UnaryPredicate1D& pred); static int Operators::bidirectionalChain(ChainingIterator& it, UnaryPredicate1D& pred); static int Operators::bidirectionalChain(ChainingIterator& it); static int Operators::sequentialSplit(UnaryPredicate0D& startingPred, UnaryPredicate0D& stoppingPred, float sampling = 0); static int Operators::sequentialSplit(UnaryPredicate0D& pred, float sampling = 0); static int Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate1D& pred, float sampling = 0); static int Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate0D& pred0d, UnaryPredicate1D& pred, float sampling = 0); static int Operators::sort(BinaryPredicate1D& pred); static int Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders); virtual int UnaryPredicate0D::operator()(Interface0DIterator& it); virtual int BinaryPredicate0D::operator()(Interface0D& inter1, Interface0D& inter2); virtual int UnaryPredicate1D::operator()(Interface1D& inter); virtual int BinaryPredicate1D::operator()(Interface1D& inter1, Interface1D& inter2); virtual int StrokeShader::shade(Stroke& ioStroke) const; virtual int UnaryFunction0D::operator()(Interface0DIterator& iter); virtual int UnaryFunction1D::operator()(Interface1D& inter);
Diffstat (limited to 'source/blender/freestyle/intern/view_map')
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions0D.cpp87
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions0D.h73
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions1D.cpp100
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions1D.h60
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Interface0D.h12
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Interface1D.h34
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Silhouette.h10
-rwxr-xr-xsource/blender/freestyle/intern/view_map/ViewMapIterators.h21
8 files changed, 228 insertions, 169 deletions
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index 1bd6d6f46f1..d6b820e3b18 100755
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -146,7 +146,7 @@ namespace Functions0D {
}
//
- Vec2f VertexOrientation2DF0D::operator()(Interface0DIterator& iter) {
+ int VertexOrientation2DF0D::operator()(Interface0DIterator& iter) {
Vec2f A,C;
Vec2f B(iter->getProjectedX(), iter->getProjectedY());
if(iter.isBegin())
@@ -170,13 +170,13 @@ namespace Functions0D {
Vec2f BC(C-B);
if(BC.norm() != 0)
BC.normalize();
- Vec2f res (AB + BC);
- if(res.norm() != 0)
- res.normalize();
- return res;
+ result = AB + BC;
+ if(result.norm() != 0)
+ result.normalize();
+ return 0;
}
- Vec3f VertexOrientation3DF0D::operator()(Interface0DIterator& iter) {
+ int VertexOrientation3DF0D::operator()(Interface0DIterator& iter) {
Vec3r A,C;
Vec3r B(iter->getX(), iter->getY(), iter->getZ());
if(iter.isBegin())
@@ -200,13 +200,13 @@ namespace Functions0D {
Vec3r BC(C-B);
if(BC.norm() != 0)
BC.normalize();
- Vec3f res (AB + BC);
- if(res.norm() != 0)
- res.normalize();
- return res;
+ result = AB + BC;
+ if(result.norm() != 0)
+ result.normalize();
+ return 0;
}
- real Curvature2DAngleF0D::operator()(Interface0DIterator& iter) {
+ int Curvature2DAngleF0D::operator()(Interface0DIterator& iter) {
Interface0DIterator tmp1 = iter, tmp2 = iter;
++tmp2;
unsigned count = 1;
@@ -220,8 +220,11 @@ namespace Functions0D {
++tmp2;
++count;
}
- if(count < 3)
- return 0; // if we only have 2 vertices
+ if(count < 3) {
+ // if we only have 2 vertices
+ result = 0;
+ return -1;
+ }
Interface0DIterator v = iter;
if(iter.isBegin())
@@ -250,29 +253,30 @@ namespace Functions0D {
if((N1.norm() == 0) && (N2.norm() == 0))
{
Exception::raiseException();
- return 0;
+ result = 0;
+ return -1;
}
double cosin = N1*N2;
if(cosin > 1)
cosin = 1;
if(cosin < -1)
cosin = -1;
- return acos(cosin);
+ result = acos(cosin);
+ return 0;
}
- real ZDiscontinuityF0D::operator()(Interface0DIterator& iter) {
+ int ZDiscontinuityF0D::operator()(Interface0DIterator& iter) {
FEdge *fe1, *fe2;
getFEdges(iter, fe1, fe2);
- real result ;
result = fe1->z_discontinuity();
if(fe2!=0){
result += fe2->z_discontinuity();
result /= 2.f;
}
- return result;
+ return 0;
}
- Vec2f Normal2DF0D::operator()(Interface0DIterator& iter) {
+ int Normal2DF0D::operator()(Interface0DIterator& iter) {
FEdge *fe1, *fe2;
getFEdges(iter,fe1,fe2);
Vec3f e1(fe1->orientation2d());
@@ -285,31 +289,32 @@ namespace Functions0D {
n += n2;
}
n.normalize();
- return n;
+ result = n;
+ return 0;
}
- FrsMaterial MaterialF0D::operator()(Interface0DIterator& iter) {
+ int MaterialF0D::operator()(Interface0DIterator& iter) {
FEdge *fe1, *fe2;
getFEdges(iter,fe1,fe2);
if(fe1 == 0)
getFEdges(iter, fe1, fe2);
- FrsMaterial mat;
if(fe1->isSmooth())
- mat = ((FEdgeSmooth*)fe1)->frs_material();
+ result = ((FEdgeSmooth*)fe1)->frs_material();
else
- mat = ((FEdgeSharp*)fe1)->bFrsMaterial();
+ result = ((FEdgeSharp*)fe1)->bFrsMaterial();
// const SShape * sshape = getShapeF0D(iter);
// return sshape->material();
- return mat;
+ return 0;
}
- Id ShapeIdF0D::operator()(Interface0DIterator& iter) {
+ int ShapeIdF0D::operator()(Interface0DIterator& iter) {
ViewShape * vshape = getShapeF0D(iter);
- return vshape->getId();
+ result = vshape->getId();
+ return 0;
}
- unsigned int QuantitativeInvisibilityF0D::operator()(Interface0DIterator& iter) {
+ int QuantitativeInvisibilityF0D::operator()(Interface0DIterator& iter) {
ViewEdge * ve1, *ve2;
getViewEdges(iter,ve1,ve2);
unsigned int qi1, qi2;
@@ -319,38 +324,42 @@ namespace Functions0D {
if(qi2!=qi1)
cout << "QuantitativeInvisibilityF0D: ambiguous evaluation for point " << iter->getId() << endl;
}
- return qi1;
+ result = qi1;
+ return 0;
}
- Nature::EdgeNature CurveNatureF0D::operator()(Interface0DIterator& iter) {
+ int CurveNatureF0D::operator()(Interface0DIterator& iter) {
Nature::EdgeNature nat = 0;
ViewEdge * ve1, *ve2;
getViewEdges(iter, ve1, ve2);
nat |= ve1->getNature();
if(ve2!=0)
nat |= ve2->getNature();
- return nat;
+ result = nat;
+ return 0;
}
- vector<ViewShape*> GetOccludersF0D::operator()(Interface0DIterator& iter) {
+ int GetOccludersF0D::operator()(Interface0DIterator& iter) {
set<ViewShape*> occluders;
getOccludersF0D(iter,occluders);
- vector<ViewShape*> vsOccluders;
+ result.clear();
// vsOccluders.insert(vsOccluders.begin(), occluders.begin(), occluders.end());
for(set<ViewShape*>::iterator it=occluders.begin(), itend=occluders.end();
it!=itend;
++it){
- vsOccluders.push_back((*it));
+ result.push_back((*it));
}
- return vsOccluders;
+ return 0;
}
- ViewShape* GetShapeF0D::operator()(Interface0DIterator& iter) {
- return getShapeF0D(iter);
+ int GetShapeF0D::operator()(Interface0DIterator& iter) {
+ result = getShapeF0D(iter);
+ return 0;
}
- ViewShape* GetOccludeeF0D::operator()(Interface0DIterator& iter) {
- return getOccludeeF0D(iter);
+ int GetOccludeeF0D::operator()(Interface0DIterator& iter) {
+ result = getOccludeeF0D(iter);
+ return 0;
}
} // end of namespace Functions0D
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 24d2edac094..dbd7d558a47 100755
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -94,16 +94,17 @@ UnaryFunction0D() { py_uf0D = 0;}
* the function.
* \return the result of the function of type T.
*/
- virtual T operator()(Interface0DIterator& iter) {
+ virtual int operator()(Interface0DIterator& iter) {
string name( py_uf0D ? PyString_AsString(PyObject_CallMethod(py_uf0D, "getName", "")) : getName() );
if( py_uf0D && PyObject_HasAttrString(py_uf0D, "__call__") ) {
- Director_BPy_UnaryFunction0D___call__( this, py_uf0D, iter);
- return result;
+ if (Director_BPy_UnaryFunction0D___call__( this, py_uf0D, iter) < 0) {
+ return -1;
+ }
} else {
cerr << "Warning: " << name << " operator() not implemented" << endl;
- return T();
}
+ return 0;
}
};
@@ -146,8 +147,9 @@ namespace Functions0D {
return "GetXF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getX();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getX();
+ return 0;
}
};
@@ -161,8 +163,9 @@ namespace Functions0D {
return "GetYF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getY();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getY();
+ return 0;
}
};
@@ -176,8 +179,9 @@ namespace Functions0D {
return "GetZF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getZ();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getZ();
+ return 0;
}
};
@@ -191,8 +195,9 @@ namespace Functions0D {
return "GetProjectedXF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getProjectedX();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getProjectedX();
+ return 0;
}
};
@@ -206,8 +211,9 @@ namespace Functions0D {
return "GetProjectedYF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getProjectedY();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getProjectedY();
+ return 0;
}
};
@@ -221,8 +227,9 @@ namespace Functions0D {
return "GetProjectedZF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter) {
- return iter->getProjectedZ();
+ int operator()(Interface0DIterator& iter) {
+ result = iter->getProjectedZ();
+ return 0;
}
};
@@ -236,8 +243,9 @@ namespace Functions0D {
return "GetCurvilinearAbscissaF0D";
}
/*! the () operator.*/
- float operator()(Interface0DIterator& iter) {
- return iter.t();
+ int operator()(Interface0DIterator& iter) {
+ result = iter.t();
+ return 0;
}
};
@@ -251,8 +259,9 @@ namespace Functions0D {
return "GetParameterF0D";
}
/*! the () operator.*/
- float operator()(Interface0DIterator& iter) {
- return iter.u();
+ int operator()(Interface0DIterator& iter) {
+ result = iter.u();
+ return 0;
}
};
@@ -269,7 +278,7 @@ namespace Functions0D {
return "VertexOrientation2DF0D";
}
/*! the () operator.*/
- Vec2f operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// VertexOrientation3DF0D
@@ -285,7 +294,7 @@ namespace Functions0D {
return "VertexOrientation3DF0D";
}
/*! the () operator.*/
- Vec3f operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// Curvature2DAngleF0D
@@ -301,7 +310,7 @@ namespace Functions0D {
return "Curvature2DAngleF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// ZDiscontinuity
@@ -319,7 +328,7 @@ namespace Functions0D {
return "ZDiscontinuityF0D";
}
/*! the () operator.*/
- real operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// Normal2DF0D
@@ -335,7 +344,7 @@ namespace Functions0D {
return "Normal2DF0D";
}
/*! the () operator.*/
- Vec2f operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// MaterialF0D
@@ -358,7 +367,7 @@ namespace Functions0D {
return "MaterialF0D";
}
/*! the () operator.*/
- FrsMaterial operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// ShapeIdF0D
@@ -379,7 +388,7 @@ namespace Functions0D {
return "ShapeIdF0D";
}
/*! the () operator.*/
- Id operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// QiF0D
@@ -400,7 +409,7 @@ namespace Functions0D {
return "QuantitativeInvisibilityF0D";
}
/*! the () operator.*/
- unsigned int operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// CurveNatureF0D
@@ -415,7 +424,7 @@ namespace Functions0D {
return "CurveNatureF0D";
}
/*! the () operator.*/
- Nature::EdgeNature operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// GetShapeF0D
@@ -430,7 +439,7 @@ namespace Functions0D {
return "GetShapeF0D";
}
/*! the () operator.*/
- ViewShape* operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// GetOccludersF0D
@@ -445,7 +454,7 @@ namespace Functions0D {
return "GetOccludersF0D";
}
/*! the () operator.*/
- std::vector<ViewShape*> operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
// GetOccludeeF0D
@@ -460,7 +469,7 @@ namespace Functions0D {
return "GetOccludeeF0D";
}
/*! the () operator.*/
- ViewShape* operator()(Interface0DIterator& iter);
+ int operator()(Interface0DIterator& iter);
};
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.cpp b/source/blender/freestyle/intern/view_map/Functions1D.cpp
index a34124ded31..8545c660084 100755
--- a/source/blender/freestyle/intern/view_map/Functions1D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions1D.cpp
@@ -24,61 +24,76 @@ using namespace std;
namespace Functions1D {
- real GetXF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetXF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real GetYF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetYF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real GetZF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetZF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real GetProjectedXF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetProjectedXF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real GetProjectedYF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetProjectedYF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real GetProjectedZF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int GetProjectedZF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- Vec2f Orientation2DF1D::operator()(Interface1D& inter) {
+ int Orientation2DF1D::operator()(Interface1D& inter) {
FEdge * fe = dynamic_cast<FEdge*>(&inter);
if(fe){
Vec3r res = fe->orientation2d();
- return Vec2f(res[0], res[1]);
- }
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ result = Vec2f(res[0], res[1]);
+ } else {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ }
+ return 0;
}
- Vec3f Orientation3DF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int Orientation3DF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- real ZDiscontinuityF1D::operator()(Interface1D& inter) {
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int ZDiscontinuityF1D::operator()(Interface1D& inter) {
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- unsigned QuantitativeInvisibilityF1D::operator()(Interface1D& inter) {
+ int QuantitativeInvisibilityF1D::operator()(Interface1D& inter) {
ViewEdge* ve = dynamic_cast<ViewEdge*>(&inter);
- if (ve)
- return ve->qi();
+ if (ve) {
+ result = ve->qi();
+ return 0;
+ }
FEdge *fe = dynamic_cast<FEdge*>(&inter);
- if(fe)
- return ve->qi();
- return integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ if (fe) {
+ result = ve->qi();
+ return 0;
+ }
+ result = integrate(_func, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
- Nature::EdgeNature CurveNatureF1D::operator()(Interface1D& inter) {
+ int CurveNatureF1D::operator()(Interface1D& inter) {
ViewEdge* ve = dynamic_cast<ViewEdge*>(&inter);
if (ve)
- return ve->getNature();
+ result = ve->getNature();
else{
// we return a nature that contains every
// natures of the viewedges spanned by the chain.
@@ -88,29 +103,33 @@ namespace Functions1D {
nat |= _func(it);
++it;
}
- return nat;
+ result = nat;
}
+ return 0;
}
- void TimeStampF1D::operator()(Interface1D& inter) {
+ int TimeStampF1D::operator()(Interface1D& inter) {
TimeStamp *timestamp = TimeStamp::instance();
inter.setTimeStamp(timestamp->getTimeStamp());
+ return 0;
}
- void ChainingTimeStampF1D::operator()(Interface1D& inter) {
+ int ChainingTimeStampF1D::operator()(Interface1D& inter) {
TimeStamp *timestamp = TimeStamp::instance();
ViewEdge *ve = dynamic_cast<ViewEdge*>(&inter);
if(ve)
ve->setChainingTimeStamp(timestamp->getTimeStamp());
+ return 0;
}
- void IncrementChainingTimeStampF1D::operator()(Interface1D& inter) {
+ int IncrementChainingTimeStampF1D::operator()(Interface1D& inter) {
ViewEdge *ve = dynamic_cast<ViewEdge*>(&inter);
if(ve)
ve->setChainingTimeStamp(ve->getChainingTimeStamp()+1);
+ return 0;
}
- vector<ViewShape*> GetShapeF1D::operator()(Interface1D& inter) {
+ int GetShapeF1D::operator()(Interface1D& inter) {
vector<ViewShape*> shapesVector;
set<ViewShape*> shapesSet;
ViewEdge* ve = dynamic_cast<ViewEdge*>(&inter);
@@ -122,26 +141,28 @@ namespace Functions1D {
shapesSet.insert(Functions0D::getShapeF0D(it));
shapesVector.insert<set<ViewShape*>::iterator>(shapesVector.begin(), shapesSet.begin(), shapesSet.end());
}
- return shapesVector;
+ result = shapesVector;
+ return 0;
}
- vector<ViewShape*> GetOccludersF1D::operator()(Interface1D& inter) {
+ int GetOccludersF1D::operator()(Interface1D& inter) {
vector<ViewShape*> shapesVector;
set<ViewShape*> shapesSet;
ViewEdge* ve = dynamic_cast<ViewEdge*>(&inter);
if (ve){
- return ve->occluders();
+ result = ve->occluders();
}else{
Interface0DIterator it=inter.verticesBegin(), itend=inter.verticesEnd();
for(;it!=itend;++it){
Functions0D::getOccludersF0D(it, shapesSet);
}
shapesVector.insert(shapesVector.begin(), shapesSet.begin(), shapesSet.end());
+ result = shapesVector;
}
- return shapesVector;
+ return 0;
}
- vector<ViewShape*> GetOccludeeF1D::operator()(Interface1D& inter) {
+ int GetOccludeeF1D::operator()(Interface1D& inter) {
vector<ViewShape*> shapesVector;
set<ViewShape*> shapesSet;
ViewEdge* ve = dynamic_cast<ViewEdge*>(&inter);
@@ -155,7 +176,8 @@ namespace Functions1D {
}
shapesVector.insert<set<ViewShape*>::iterator>(shapesVector.begin(), shapesSet.begin(), shapesSet.end());
}
- return shapesVector;
+ result = shapesVector;
+ return 0;
}
// Internal
////////////
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index c4f8b9f7607..8dbea93dfb0 100755
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -98,16 +98,17 @@ public:
* the function.
* \return the result of the function of type T.
*/
- virtual T operator()(Interface1D& inter) {
+ virtual int operator()(Interface1D& inter) {
string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() );
if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) {
- Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter);
- return result;
+ if (Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter) < 0) {
+ return -1;
+ }
} else {
cerr << "Warning: " << name << " operator() not implemented" << endl;
- return T(0);
}
+ return 0;
}
/*! Sets the integration method */
@@ -139,14 +140,17 @@ public:
return "UnaryFunction1D_void";
}
- void operator()(Interface1D& inter) {
+ int operator()(Interface1D& inter) {
string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() );
if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) {
- Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter);
+ if (Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter) < 0) {
+ return -1;
+ }
} else {
cerr << "Warning: " << name << " operator() not implemented" << endl;
}
+ return 0;
}
void setIntegrationType(IntegrationType integration) { _integration = integration; }
@@ -182,7 +186,7 @@ namespace Functions1D {
return "GetXF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter) ;
+ int operator()(Interface1D& inter) ;
};
// GetYF1D
@@ -203,7 +207,7 @@ namespace Functions1D {
return "GetYF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter) ;
+ int operator()(Interface1D& inter) ;
};
// GetZF1D
@@ -224,7 +228,7 @@ namespace Functions1D {
return "GetZF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter) ;
+ int operator()(Interface1D& inter) ;
};
// GetProjectedXF1D
@@ -246,7 +250,7 @@ namespace Functions1D {
return "GetProjectedXF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// GetProjectedYF1D
@@ -268,7 +272,7 @@ namespace Functions1D {
return "GetProjectedYF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// GetProjectedZF1D
@@ -290,7 +294,7 @@ namespace Functions1D {
return "GetProjectedZF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// Orientation2DF1D
@@ -311,7 +315,7 @@ namespace Functions1D {
return "Orientation2DF1D";
}
/*! the () operator.*/
- Vec2f operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// Orientation3DF1D
@@ -332,7 +336,7 @@ namespace Functions1D {
return "Orientation3DF1D";
}
/*! the () operator.*/
- Vec3f operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// ZDiscontinuityF1D
@@ -358,7 +362,7 @@ namespace Functions1D {
return "ZDiscontinuityF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// QuantitativeInvisibilityF1D
@@ -384,7 +388,7 @@ namespace Functions1D {
return "QuantitativeInvisibilityF1D";
}
/*! the () operator.*/
- unsigned operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// CurveNatureF1D
@@ -410,7 +414,7 @@ namespace Functions1D {
return "CurveNatureF1D";
}
/*! the () operator.*/
- Nature::EdgeNature operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// TimeStampF1D
@@ -423,7 +427,7 @@ namespace Functions1D {
return "TimeStampF1D";
}
/*! the () operator.*/
- void operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// IncrementChainingTimeStampF1D
@@ -436,7 +440,7 @@ namespace Functions1D {
return "IncrementChainingTimeStampF1D";
}
/*! the () operator.*/
- void operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// ChainingTimeStampF1D
@@ -449,7 +453,7 @@ namespace Functions1D {
return "ChainingTimeStampF1D";
}
/*! the () operator.*/
- void operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
@@ -469,8 +473,9 @@ namespace Functions1D {
return "Curvature2DAngleF1D";
}
/*! the () operator.*/
- real operator()(Interface1D& inter) {
- return integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int operator()(Interface1D& inter) {
+ result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
private:
Functions0D::Curvature2DAngleF0D _fun;
@@ -492,8 +497,9 @@ namespace Functions1D {
return "Normal2DF1D";
}
/*! the () operator.*/
- Vec2f operator()(Interface1D& inter) {
- return integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ int operator()(Interface1D& inter) {
+ result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
+ return 0;
}
private:
Functions0D::Normal2DF0D _fun;
@@ -512,7 +518,7 @@ namespace Functions1D {
return "GetShapeF1D";
}
/*! the () operator.*/
- std::vector<ViewShape*> operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// GetOccludersF1D
@@ -528,7 +534,7 @@ namespace Functions1D {
return "GetOccludersF1D";
}
/*! the () operator.*/
- std::vector<ViewShape*> operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// GetOccludeeF1D
@@ -544,7 +550,7 @@ namespace Functions1D {
return "GetOccludeeF1D";
}
/*! the () operator.*/
- std::vector<ViewShape*> operator()(Interface1D& inter);
+ int operator()(Interface1D& inter);
};
// internal
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index 89d8f606264..c24fbaf9063 100755
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -277,9 +277,9 @@ public:
return &(operator*());
}
- virtual void increment() = 0;
+ virtual int increment() = 0;
- virtual void decrement() = 0;
+ virtual int decrement() = 0;
virtual bool isBegin() const = 0;
@@ -404,13 +404,13 @@ public:
}
/*! Increments. */
- virtual void increment() {
- _iterator->increment();
+ virtual int increment() {
+ return _iterator->increment();
}
/*! Decrements. */
- virtual void decrement() {
- _iterator->decrement();
+ virtual int decrement() {
+ return _iterator->decrement();
}
/*! Returns true if the pointed Interface0D is the
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index 44822005705..c626bcbef80 100755
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -81,36 +81,42 @@ T integrate(UnaryFunction0D<T>& fun,
Interface0DIterator it_end,
IntegrationType integration_type = MEAN) {
T res;
- T res_tmp;
unsigned size;
switch (integration_type) {
case MIN:
- res = fun(it);++it;
+ fun(it);
+ res = fun.result;++it;
for (; !it.isEnd(); ++it) {
- res_tmp = fun(it);
- if (res_tmp < res)
- res = res_tmp;
+ fun(it);
+ if (fun.result < res)
+ res = fun.result;
}
break;
case MAX:
- res = fun(it);++it;
+ fun(it);
+ res = fun.result;++it;
for (; !it.isEnd(); ++it) {
- res_tmp = fun(it);
- if (res_tmp > res)
- res = res_tmp;
+ fun(it);
+ if (fun.result > res)
+ res = fun.result;
}
break;
case FIRST:
- res = fun(it);
+ fun(it);
+ res = fun.result;
break;
case LAST:
- res = fun(--it_end);
+ fun(--it_end);
+ res = fun.result;
break;
case MEAN:
default:
- res = fun(it);++it;
- for (size = 1; !it.isEnd(); ++it, ++size)
- res += fun(it);
+ fun(it);
+ res = fun.result;++it;
+ for (size = 1; !it.isEnd(); ++it, ++size) {
+ fun(it);
+ res += fun.result;
+ }
res /= (size ? size : 1);
break;
}
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index 6b9ebde5707..b8e7d66efcc 100755
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -694,21 +694,23 @@ namespace FEdgeInternal {
return ret;
}
- virtual void increment() {
+ virtual int increment() {
if (_vertex == _edge->vertexB()) {
_vertex = 0;
- return;
+ return 0;
}
_vertex = _edge->vertexB();
+ return 0;
}
- virtual void decrement() {
+ virtual int decrement() {
if (_vertex == _edge->vertexA()) {
_vertex = 0;
- return;
+ return 0;
}
_vertex = _edge->vertexA();
+ return 0;
}
virtual bool isBegin() const {
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index fa6fb8e1641..789aec0d5c3 100755
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -206,7 +206,7 @@ namespace ViewVertexInternal{
public:
/*! increments.*/
- virtual inline void increment()
+ virtual inline int increment()
{
if(_Nature & Nature::T_VERTEX)
{
@@ -221,6 +221,7 @@ namespace ViewVertexInternal{
}
else
++_nontvertex_iter;
+ return 0;
}
};
@@ -312,30 +313,32 @@ namespace ViewEdgeInternal {
return ret;
}
- virtual void increment(){
+ virtual int increment(){
if (!_next_edge) {
_vertex = 0;
- return;
+ return 0;
}
_t += (float)_next_edge->getLength2D();
_vertex = _next_edge->vertexB();
_previous_edge = _next_edge;
_next_edge = _next_edge->nextEdge();
+ return 0;
}
- virtual void decrement(){
+ virtual int decrement(){
if (!_previous_edge) {
_vertex = 0;
- return;
+ return 0;
}
if((!_next_edge) && (!_vertex)){
_vertex = _previous_edge->vertexB();
- return;
+ return 0;
}
_t -= (float)_previous_edge->getLength2D();
_vertex = _previous_edge->vertexA();
_next_edge = _previous_edge;
_previous_edge = _previous_edge->previousEdge();
+ return 0;
}
virtual bool isBegin() const {
@@ -482,8 +485,9 @@ public:
}
/*! increments. */
- virtual void increment() {
+ virtual int increment() {
cerr << "Warning: method increment() not implemented" << endl;
+ return 0;
}
/*! Decrements. In the scripting language, call
@@ -504,8 +508,9 @@ public:
}
/*! decrements. */
- virtual void decrement(){
+ virtual int decrement(){
cerr << "Warning: method decrement() not implemented" << endl;
+ return 0;
}
/*! Returns true if the pointed ViewEdge is the