+template<typename Functor>
+class Dereference
+{
+const Functor& functor;
+public:
+Dereference( const Functor& functor ) : functor( functor ){
+}
+get_result_type<Functor> operator()( typename RemoveReference<get_argument<Functor, 0>>::type *firstArgument ) const {
+ return functor( *firstArgument );
+}
+};
+
+template<typename Functor>
+inline Dereference<Functor> makeDereference( const Functor& functor ){
+ return Dereference<Functor>( functor );
+}
+
+typedef Face* FacePointer;
+const FacePointer c_nullFacePointer = 0;
+
+template<typename Predicate>
+Face* Brush_findIf( const Brush& brush, const Predicate& predicate ){
+ Brush::const_iterator i = std::find_if( brush.begin(), brush.end(), makeDereference( predicate ) );
+ return i == brush.end() ? c_nullFacePointer : *i; // uses c_nullFacePointer instead of 0 because otherwise gcc 4.1 attempts conversion to int
+}
+
+template<typename Caller>
+class BindArguments1
+{
+typedef get_argument<Caller, 1> FirstBound;
+FirstBound firstBound;
+public:
+BindArguments1( FirstBound firstBound )
+ : firstBound( firstBound ){
+}
+
+get_result_type<Caller> operator()( get_argument<Caller, 0> firstArgument ) const {
+ return Caller::call( firstArgument, firstBound );
+}
+};
+
+template<typename Caller>
+class BindArguments2
+{
+typedef get_argument<Caller, 1> FirstBound;
+typedef get_argument<Caller, 2> SecondBound;
+FirstBound firstBound;
+SecondBound secondBound;
+public:
+BindArguments2( FirstBound firstBound, SecondBound secondBound )
+ : firstBound( firstBound ), secondBound( secondBound ){
+}
+
+get_result_type<Caller> operator()( get_argument<Caller, 0> firstArgument ) const {
+ return Caller::call( firstArgument, firstBound, secondBound );
+}
+};
+
+template<typename Caller, typename FirstBound, typename SecondBound>
+BindArguments2<Caller> bindArguments( const Caller& caller, FirstBound firstBound, SecondBound secondBound ){
+ return BindArguments2<Caller>( firstBound, secondBound );
+}
+
+inline bool Face_testPlane( const Face& face, const Plane3& plane, bool flipped ){
+ return face.contributes() && !Winding_TestPlane( face.getWinding(), plane, flipped );
+}
+
+typedef Function<bool ( const Face &, const Plane3 &, bool ), Face_testPlane> FaceTestPlane;
+
+
+/// \brief Returns true if
+/// \li !flipped && brush is BACK or ON
+/// \li flipped && brush is FRONT or ON
+bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){
+ brush.evaluateBRep();
+#if 1
+ for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i )