<commit_before>/**
  \file   main.cc
  \brief  Main file fir the finite element example.
  **/
// disable warnings about problems in dune headers
#include <dune/fem-tools/header/disablewarnings.hh>

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <iostream>
#include <vector>

// dune-common includes
#include <dune/common/exceptions.hh>
#include <dune/common/fmatrix.hh>

// dune-grid includes
#include <dune/grid/utility/gridtype.hh>

// dune-istl includes
#include <dune/istl/solvers.hh>

// dune-fem includes
#include <dune/fem/misc/mpimanager.hh>
//#include <dune/fem/gridpart/gridpart.hh>
//#include <dune/fem/storage/vector.hh>
//#include <dune/fem/function/adaptivefunction/adaptivefunction.hh>
#include <dune/fem/gridpart/adaptiveleafgridpart.hh>

// reenable warnings
#include <dune/fem-tools/header/enablewarnings.hh>

// dune-functionals includes
#include <dune/functionals/discretefunctionspace/finiteelement.hh>
#include <dune/functionals/discretefunctionspace/subspace/linear.hh>
#include <dune/functionals/discretefunctionspace/subspace/affine.hh>
#include <dune/functionals/discreteoperator/local/integration.hh>
#include <dune/functionals/container/factory.hh>
#include <dune/functionals/assembler/local/finiteelement.hh>
#include <dune/functionals/assembler/generic.hh>

// dune-fem-tools includes
#include <dune/fem-tools/common/string.hh>
#include <dune/fem-tools/function/runtimefunction.hh>
#include <dune/fem-tools/function/functiontools.hh>
//#include <dune/fem-tools/space/projection.hh>

using namespace Dune::Functionals;

#ifndef POLORDER
const int polOrder = 1;
#else
const int polOrder = POLORDER;
#endif

///**
//  \brief  This represents the operation \f$fv\f$.

//          \f$f\f$ is a given right hand side (in this case 1) and \f$v\f$ may be a local function, i.e. a
//          testfunction.
//  \tparam FunctionSpaceImp
//          Type of the function space, where \f$f\f$ and \f$v\f$ live in.
//  **/
// template< class FunctionSpaceImp >
// class ProductOperation
//  : public Dune::Functionals::LocalOperation::Interface< FunctionSpaceImp >
//{
// public:

//  typedef FunctionSpaceImp
//    FunctionSpaceType;

//  typedef typename FunctionSpaceType::RangeFieldType
//    RangeFieldType;

//  typedef typename FunctionSpaceType::RangeType
//    RangeType;

//  /**
//    \brief      Evaluates \f$f(x)v(x)\f$ for a given local point \f$x\f$.

//    \tparam     LocalTestFunctionType
//                Type of the local function \f$v\f$, i.e. Dune::LocalFunction.
//    \tparam     LocalPointType
//                Type of the local point \f$x\f$, i.e. Dune::FieldVector.
//    \param[in]  localTestFunction
//                The local function \f$v\f$.
//    \param[in]  localPoint
//                The local point \f$x\f$. This point is local in the sense, that this is a point on a reference
//                element.
//    \return     \f$f(x)v(x)\f$
//    **/
//  template< class LocalTestFunctionType, class LocalPointType >
//  RangeFieldType evaluate(  const LocalTestFunctionType& localTestFunction,
//                            const LocalPointType& localPoint ) const
//  {
//    // init return value
//    RangeFieldType ret = 0.0;

//    // evaluate local function
//    RangeType localTestFunctionValue( 0.0 );
//    localTestFunction.evaluate( localPoint, localTestFunctionValue );

//    // 1.0 * v(x)
//    ret = 1.0 * localTestFunctionValue;

//    // return
//    return ret;
//  }

//}; // end class ProductOperation

/**
  \brief  This represents the operation \f$a\nabla u \nabla v\f$.

          \f$a\f$ is a given scalar function (in this case 1) and \f$u\f$ and \f$u\f$ may be local functions, i.e.
          ansatz- and testfunctions.
  \tparam FunctionSpaceImp
          Type of the function space, where \f$f\f$, \f$u\f$ and \f$v\f$ live in.
  **/
template <class FunctionSpaceImp>
class EllipticEvaluation
{
public:
  typedef FunctionSpaceImp FunctionSpaceType;

  typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;

  typedef typename FunctionSpaceType::RangeType RangeType;

  typedef typename FunctionSpaceType::DomainType DomainType;

  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;

  typedef Dune::FemTools::Function::Runtime<FunctionSpaceType> InducingFunctionType;

  //! constructor, takes the inducing function as a runtime parameter
  EllipticEvaluation(const std::string expression = "[1.0;1.0;1.0]")
    : inducingFunction_(expression)
  {
  }

  //! copy constructor
  EllipticEvaluation(const EllipticEvaluation& other)
    : inducingFunction_(other.inducingFunction())
  {
  }

  //! returns the inducing function
  const InducingFunctionType& inducingFunction() const
  {
    return inducingFunction_;
  }

  /**
    * \brief      Evaluates \f$a(x)\nabla u(x) \nabla v(x)\f$ for a given local point \f$x\f$.
    *
    * \tparam     LocalAnsatzFunctionType
    *             Type of the local ansatz function \f$u\f$, i.e. Dune::LocalFunction.
    * \tparam     LocalTestFunctionType
    *             Type of the local test function \f$v\f$, i.e. Dune::LocalFunction.
    * \tparam     LocalPointType
    *             Type of the local point \f$x\f$, i.e. Dune::FieldVector.
    * \param[in]  localAnsatzFunction
    *             The local function \f$u\f$.
    * \param[in]  localTestFunction
    *             The local function \f$v\f$.
    * \param[in]  localPoint
    *             The local point \f$x\f$. This point is local in the sense, that this is a point on a reference
    *             element.
    * \return     \f$a(x)\nabla u(x) \nabla v(x)\f$
    **/
  template <class LocalAnsatzFunctionType, class LocalTestFunctionType, class LocalPointType>
  RangeFieldType evaluate(const LocalAnsatzFunctionType& localAnsatzFunction,
                          const LocalTestFunctionType& localTestFunction, const LocalPointType& localPoint) const
  {
    // get global point
    const DomainType globalPoint = localAnsatzFunction.entity().geometry().global(localPoint);

    // evaluate first gradient
    JacobianRangeType gradientLocalAnsatzFunction(0.0);
    localAnsatzFunction.jacobian(localPoint, gradientLocalAnsatzFunction);

    // evaluate second gradient
    JacobianRangeType gradientLocalTestFunction(0.0);
    localTestFunction.jacobian(localPoint, gradientLocalTestFunction);

    const RangeType gradientProduct = gradientLocalAnsatzFunction[0] * gradientLocalTestFunction[0];

    // evaluate inducing function
    RangeType functionValue(0.0);
    inducingFunction_.evaluate(globalPoint, functionValue);

    // a(x) * \gradient u(x) * \gradient v(x)
    const RangeFieldType ret = functionValue * gradientProduct;

    return ret;
  }

private:
  const InducingFunctionType inducingFunction_;
}; // end class EllipticEvalaution

int main(int argc, char** argv)
{
  try {

    // MPI manager
    Dune::MPIManager::initialize(argc, argv);

    // grid
    static const unsigned int dimRange = 1;

    typedef Dune::GridSelector::GridType GridType;

    typedef Dune::AdaptiveLeafGridPart<GridType> GridPartType;

    const std::string dgfFilename = "../macrogrids/unitcube" + Dune::FemTools::String::toString(GRIDDIM) + ".dgf";

    Dune::GridPtr<GridType> gridPtr(dgfFilename);

    GridPartType gridPart(*gridPtr);

    // function spaces and functions
    typedef Dune::FunctionSpace<double, double, GridType::dimension, dimRange> FunctionSpaceType;

    typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;

    // discrete function space
    typedef DiscreteFunctionSpace::ContinuousFiniteElement<FunctionSpaceType, GridPartType, polOrder> DiscreteH1Type;

    const DiscreteH1Type discreteH1(gridPart);

    typedef DiscreteFunctionSpace::Subspace::Linear::DirichletZero<DiscreteH1Type> DiscreteH10Type;

    const DiscreteH10Type discreteH10(discreteH1);

    typedef DiscreteFunctionSpace::Subspace::Affine::Dirichlet<DiscreteH10Type> DiscreteH1GType;

    const DiscreteH1GType discreteH1G(discreteH10, "[x+y;y;z]");

    // local evaluations
    //    typedef ProductOperation< FunctionSpaceType >
    //      ProductOperationType;

    //    ProductOperationType productOperation;

    typedef EllipticEvaluation<FunctionSpaceType> EllipticEvaluationType;

    EllipticEvaluationType ellipticEvaluation("[1.0;1.0;1.0]");

    // operator and functional
    typedef Dune::Functionals::DiscreteOperator::Local::Codim0Integration<EllipticEvaluationType,
                                                                          DiscreteH1Type,
                                                                          DiscreteH1Type> LocalEllipticOperatorType;

    const LocalEllipticOperatorType localEllipticOperator(ellipticEvaluation, discreteH1, discreteH1);

    //    FEMellipticOperatorType femEllipticOperator( ellipticIntegrator, discreteH1 );

    //    typedef Functional::FiniteElementLOP< DiscreteH1Type, ProductIntegratorType >
    //      FEMrhsFunctionalType;

    //    FEMrhsFunctionalType femRhsFunctional( discreteH1, productIntegrator );

    // matrix, rhs and solution storage
    typedef Dune::Functionals::Container::Matrix::Defaults<RangeFieldType, dimRange, dimRange>::BCRSMatrix
        MatrixFactory;

    typedef typename MatrixFactory::AutoPtrType MatrixPtrType;

    MatrixPtrType A = MatrixFactory::create(discreteH10);

    //    typedef Dune::FieldMatrix< double, dimRange, dimRange >
    //      FieldMatrixType;

    //    typedef Container::MatrixFactory< Dune::BCRSMatrix< FieldMatrixType > >
    //      MatrixFactoryType;

    //    typedef MatrixFactoryType::ContainerType
    //      MatrixContainer;

    //    typedef MatrixFactoryType::AutoPtrType
    //      MatrixContainerPtr;

    //    typedef Container::VectorFactory< Dune::BlockVector< Dune::FieldVector< double, 1 > > >
    //      VectorFactoryType;

    //    typedef VectorFactoryType::ContainerType
    //      VectorContainer;

    //    typedef VectorFactoryType::AutoPtrType
    //      VectorContainerPtr;

    //    MatrixContainerPtr A  = MatrixFactoryType::create( discreteH10 );
    //    VectorContainerPtr F  = VectorFactoryType::create( discreteH10 );
    //    VectorContainerPtr u0 = VectorFactoryType::create( discreteH10 );

    // assembler
    typedef Dune::Functionals::Assembler::Local::ContinuousFiniteElement<LocalEllipticOperatorType>
        LocalMatrixAssemblerType;

    const LocalMatrixAssemblerType localMatrixAssembler(localEllipticOperator);

    typedef Dune::Functionals::Assembler::System<DiscreteH1GType, DiscreteH10Type> AssemblerType;

    AssemblerType assembler(discreteH10, discreteH10);

    assembler.assemble(localMatrixAssembler, A);

    //    typedef Assembler::FiniteElement< MatrixContainer, VectorContainer >
    //      Assembler;

    //    Assembler::assembleMatrix( femEllipticOperator, *A );
    //    Assembler::applyMatrixConstraints( discreteH10, *A );

    //    Assembler::assembleVector( femRhsFunctional, *F );
    //    Assembler::applyVectorConstraints( discreteH10, *F );

    //    // preconditioner and solver
    //    typedef Dune::MatrixAdapter< MatrixContainer, VectorContainer, VectorContainer >
    //      MatrixAdapterType;

    //    MatrixAdapterType op( *A );

    //    typedef Dune::SeqILU0< MatrixContainer, VectorContainer, VectorContainer, 1 >
    //      SeqILU0Type;

    //    SeqILU0Type prec( *A, 1.0 );

    //    typedef Dune::CGSolver< VectorContainer >
    //      CG;

    //    CG cg( op, prec, 1e-4, 100, 2 );

    //    Dune::InverseOperatorResult res;

    //    // u_0 = A^(-1) ( F - G )
    //    cg.apply( *u0, *F, res );

    //    // postprocessing
    //    DiscreteFunctionType solution = Dune::FemTools::discreteFunctionFactory< DiscreteFunctionType >( discreteH1,
    //    *u0 );
    Dune::FemTools::Function::writeToVTK(discreteH1G.affineShift(), "boundaryData");

    return 0;
  } catch (Dune::Exception& e) {
    std::cerr << "Dune reported error: " << e << std::endl;
  } catch (...) {
    std::cerr << "Unknown exception thrown!" << std::endl;
  }
}
<commit_msg>use of assembler<commit_after>/**
  \file   main.cc
  \brief  Main file fir the finite element example.
  **/
// disable warnings about problems in dune headers
#include <dune/fem-tools/header/disablewarnings.hh>

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <iostream>
#include <vector>

// dune-common includes
#include <dune/common/exceptions.hh>
#include <dune/common/fmatrix.hh>

// dune-grid includes
#include <dune/grid/utility/gridtype.hh>

// dune-istl includes
#include <dune/istl/solvers.hh>

// dune-fem includes
#include <dune/fem/misc/mpimanager.hh>
//#include <dune/fem/gridpart/gridpart.hh>
//#include <dune/fem/storage/vector.hh>
//#include <dune/fem/function/adaptivefunction/adaptivefunction.hh>
#include <dune/fem/gridpart/adaptiveleafgridpart.hh>

// reenable warnings
#include <dune/fem-tools/header/enablewarnings.hh>

// dune-functionals includes
#include <dune/functionals/discretefunctionspace/finiteelement.hh>
#include <dune/functionals/discretefunctionspace/subspace/linear.hh>
#include <dune/functionals/discretefunctionspace/subspace/affine.hh>
#include <dune/functionals/discreteoperator/local/integration.hh>
#include <dune/functionals/container/factory.hh>
#include <dune/functionals/assembler/local/finiteelement.hh>
#include <dune/functionals/assembler/generic.hh>

// dune-fem-tools includes
#include <dune/fem-tools/common/string.hh>
#include <dune/fem-tools/function/runtimefunction.hh>
#include <dune/fem-tools/function/functiontools.hh>
//#include <dune/fem-tools/space/projection.hh>

using namespace Dune::Functionals;

#ifndef POLORDER
const int polOrder = 1;
#else
const int polOrder = POLORDER;
#endif

///**
//  \brief  This represents the operation \f$fv\f$.

//          \f$f\f$ is a given right hand side (in this case 1) and \f$v\f$ may be a local function, i.e. a
//          testfunction.
//  \tparam FunctionSpaceImp
//          Type of the function space, where \f$f\f$ and \f$v\f$ live in.
//  **/
// template< class FunctionSpaceImp >
// class ProductOperation
//  : public Dune::Functionals::LocalOperation::Interface< FunctionSpaceImp >
//{
// public:

//  typedef FunctionSpaceImp
//    FunctionSpaceType;

//  typedef typename FunctionSpaceType::RangeFieldType
//    RangeFieldType;

//  typedef typename FunctionSpaceType::RangeType
//    RangeType;

//  /**
//    \brief      Evaluates \f$f(x)v(x)\f$ for a given local point \f$x\f$.

//    \tparam     LocalTestFunctionType
//                Type of the local function \f$v\f$, i.e. Dune::LocalFunction.
//    \tparam     LocalPointType
//                Type of the local point \f$x\f$, i.e. Dune::FieldVector.
//    \param[in]  localTestFunction
//                The local function \f$v\f$.
//    \param[in]  localPoint
//                The local point \f$x\f$. This point is local in the sense, that this is a point on a reference
//                element.
//    \return     \f$f(x)v(x)\f$
//    **/
//  template< class LocalTestFunctionType, class LocalPointType >
//  RangeFieldType evaluate(  const LocalTestFunctionType& localTestFunction,
//                            const LocalPointType& localPoint ) const
//  {
//    // init return value
//    RangeFieldType ret = 0.0;

//    // evaluate local function
//    RangeType localTestFunctionValue( 0.0 );
//    localTestFunction.evaluate( localPoint, localTestFunctionValue );

//    // 1.0 * v(x)
//    ret = 1.0 * localTestFunctionValue;

//    // return
//    return ret;
//  }

//}; // end class ProductOperation

/**
  \brief  This represents the operation \f$a\nabla u \nabla v\f$.

          \f$a\f$ is a given scalar function (in this case 1) and \f$u\f$ and \f$u\f$ may be local functions, i.e.
          ansatz- and testfunctions.
  \tparam FunctionSpaceImp
          Type of the function space, where \f$f\f$, \f$u\f$ and \f$v\f$ live in.
  **/
template <class FunctionSpaceImp>
class EllipticEvaluation
{
public:
  typedef FunctionSpaceImp FunctionSpaceType;

  typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;

  typedef typename FunctionSpaceType::RangeType RangeType;

  typedef typename FunctionSpaceType::DomainType DomainType;

  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;

  typedef Dune::FemTools::Function::Runtime<FunctionSpaceType> InducingFunctionType;

  //! constructor, takes the inducing function as a runtime parameter
  EllipticEvaluation(const std::string expression = "[1.0;1.0;1.0]")
    : inducingFunction_(expression)
  {
  }

  //! copy constructor
  EllipticEvaluation(const EllipticEvaluation& other)
    : inducingFunction_(other.inducingFunction())
  {
  }

  //! returns the inducing function
  const InducingFunctionType& inducingFunction() const
  {
    return inducingFunction_;
  }

  /**
    * \brief      Evaluates \f$a(x)\nabla u(x) \nabla v(x)\f$ for a given local point \f$x\f$.
    *
    * \tparam     LocalAnsatzFunctionType
    *             Type of the local ansatz function \f$u\f$, i.e. Dune::LocalFunction.
    * \tparam     LocalTestFunctionType
    *             Type of the local test function \f$v\f$, i.e. Dune::LocalFunction.
    * \tparam     LocalPointType
    *             Type of the local point \f$x\f$, i.e. Dune::FieldVector.
    * \param[in]  localAnsatzFunction
    *             The local function \f$u\f$.
    * \param[in]  localTestFunction
    *             The local function \f$v\f$.
    * \param[in]  localPoint
    *             The local point \f$x\f$. This point is local in the sense, that this is a point on a reference
    *             element.
    * \return     \f$a(x)\nabla u(x) \nabla v(x)\f$
    **/
  template <class LocalAnsatzFunctionType, class LocalTestFunctionType, class LocalPointType>
  RangeFieldType evaluate(const LocalAnsatzFunctionType& localAnsatzFunction,
                          const LocalTestFunctionType& localTestFunction, const LocalPointType& localPoint) const
  {
    // get global point
    const DomainType globalPoint = localAnsatzFunction.entity().geometry().global(localPoint);

    // evaluate first gradient
    JacobianRangeType gradientLocalAnsatzFunction(0.0);
    localAnsatzFunction.jacobian(localPoint, gradientLocalAnsatzFunction);

    // evaluate second gradient
    JacobianRangeType gradientLocalTestFunction(0.0);
    localTestFunction.jacobian(localPoint, gradientLocalTestFunction);

    const RangeType gradientProduct = gradientLocalAnsatzFunction[0] * gradientLocalTestFunction[0];

    // evaluate inducing function
    RangeType functionValue(0.0);
    inducingFunction_.evaluate(globalPoint, functionValue);

    // a(x) * \gradient u(x) * \gradient v(x)
    const RangeFieldType ret = functionValue * gradientProduct;

    return ret;
  }

private:
  const InducingFunctionType inducingFunction_;
}; // end class EllipticEvalaution

int main(int argc, char** argv)
{
  try {

    // MPI manager
    Dune::MPIManager::initialize(argc, argv);

    // grid
    static const unsigned int dimRange = 1;

    typedef Dune::GridSelector::GridType GridType;

    typedef Dune::AdaptiveLeafGridPart<GridType> GridPartType;

    const std::string dgfFilename = "../macrogrids/unitcube" + Dune::FemTools::String::toString(GRIDDIM) + ".dgf";

    Dune::GridPtr<GridType> gridPtr(dgfFilename);

    GridPartType gridPart(*gridPtr);

    // function spaces and functions
    typedef Dune::FunctionSpace<double, double, GridType::dimension, dimRange> FunctionSpaceType;

    typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;

    // discrete function space
    typedef DiscreteFunctionSpace::ContinuousFiniteElement<FunctionSpaceType, GridPartType, polOrder> DiscreteH1Type;

    const DiscreteH1Type discreteH1(gridPart);

    typedef DiscreteFunctionSpace::Subspace::Linear::DirichletZero<DiscreteH1Type> DiscreteH10Type;

    const DiscreteH10Type discreteH10(discreteH1);

    typedef DiscreteFunctionSpace::Subspace::Affine::Dirichlet<DiscreteH10Type> DiscreteH1GType;

    const DiscreteH1GType discreteH1G(discreteH10, "[x+y;y;z]");

    // local evaluations
    //    typedef ProductOperation< FunctionSpaceType >
    //      ProductOperationType;

    //    ProductOperationType productOperation;

    typedef EllipticEvaluation<FunctionSpaceType> EllipticEvaluationType;

    EllipticEvaluationType ellipticEvaluation("[1.0;1.0;1.0]");

    // operator and functional
    typedef Dune::Functionals::DiscreteOperator::Local::Codim0Integration<EllipticEvaluationType,
                                                                          DiscreteH1Type,
                                                                          DiscreteH1Type> LocalEllipticOperatorType;

    const LocalEllipticOperatorType localEllipticOperator(ellipticEvaluation, discreteH1, discreteH1);

    //    FEMellipticOperatorType femEllipticOperator( ellipticIntegrator, discreteH1 );

    //    typedef Functional::FiniteElementLOP< DiscreteH1Type, ProductIntegratorType >
    //      FEMrhsFunctionalType;

    //    FEMrhsFunctionalType femRhsFunctional( discreteH1, productIntegrator );

    // matrix, rhs and solution storage
    typedef Dune::Functionals::Container::Matrix::Defaults<RangeFieldType, dimRange, dimRange>::BCRSMatrix
        MatrixFactory;

    typedef typename MatrixFactory::AutoPtrType MatrixPtrType;

    MatrixPtrType A = MatrixFactory::create(discreteH10);

    //    typedef Dune::FieldMatrix< double, dimRange, dimRange >
    //      FieldMatrixType;

    //    typedef Container::MatrixFactory< Dune::BCRSMatrix< FieldMatrixType > >
    //      MatrixFactoryType;

    //    typedef MatrixFactoryType::ContainerType
    //      MatrixContainer;

    //    typedef MatrixFactoryType::AutoPtrType
    //      MatrixContainerPtr;

    //    typedef Container::VectorFactory< Dune::BlockVector< Dune::FieldVector< double, 1 > > >
    //      VectorFactoryType;

    //    typedef VectorFactoryType::ContainerType
    //      VectorContainer;

    //    typedef VectorFactoryType::AutoPtrType
    //      VectorContainerPtr;

    //    MatrixContainerPtr A  = MatrixFactoryType::create( discreteH10 );
    //    VectorContainerPtr F  = VectorFactoryType::create( discreteH10 );
    //    VectorContainerPtr u0 = VectorFactoryType::create( discreteH10 );

    // assembler
    typedef Dune::Functionals::Assembler::Local::ContinuousFiniteElement<LocalEllipticOperatorType>
        LocalMatrixAssemblerType;

    const LocalMatrixAssemblerType localMatrixAssembler(localEllipticOperator);

    typedef Dune::Functionals::Assembler::System<DiscreteH1GType, DiscreteH10Type> SystemAssemblerType;

    SystemAssemblerType systemAssembler(discreteH1G, discreteH10);

    systemAssembler.assemble(localMatrixAssembler, A);

    //    Assembler::assembleVector( femRhsFunctional, *F );
    //    Assembler::applyVectorConstraints( discreteH10, *F );

    //    // preconditioner and solver
    //    typedef Dune::MatrixAdapter< MatrixContainer, VectorContainer, VectorContainer >
    //      MatrixAdapterType;

    //    MatrixAdapterType op( *A );

    //    typedef Dune::SeqILU0< MatrixContainer, VectorContainer, VectorContainer, 1 >
    //      SeqILU0Type;

    //    SeqILU0Type prec( *A, 1.0 );

    //    typedef Dune::CGSolver< VectorContainer >
    //      CG;

    //    CG cg( op, prec, 1e-4, 100, 2 );

    //    Dune::InverseOperatorResult res;

    //    // u_0 = A^(-1) ( F - G )
    //    cg.apply( *u0, *F, res );

    //    // postprocessing
    //    DiscreteFunctionType solution = Dune::FemTools::discreteFunctionFactory< DiscreteFunctionType >( discreteH1,
    //    *u0 );
    Dune::FemTools::Function::writeToVTK(discreteH1G.affineShift(), "boundaryData");

    return 0;
  } catch (Dune::Exception& e) {
    std::cerr << "Dune reported error: " << e << std::endl;
  } catch (...) {
    std::cerr << "Unknown exception thrown!" << std::endl;
  }
}
<|endoftext|>


<commit_before>/***************************************************************************
 *   Copyright (C) 2004 by                                                 *
 *   Jason Kivlighn (mizunoami44@users.sourceforge.net)                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "unit.h"

Unit::Unit() :
  id(-1)
{
}

Unit::Unit( const QString &_name, const QString &_plural, int _id ) :
  id(_id),
  name(_name),
  plural(_plural)
{
}

Unit::Unit( const QString &_name, double amount )
{
	if ( amount > 1 )
		plural = _name;
	else
		name = _name;
}

bool Unit::operator==( const Unit &u ) const
{
	//treat QString::null and "" as the same
	QString plural_test1 = u.plural.lower();
	if ( plural_test1.isNull() )
		plural_test1 = "";

	QString plural_test2 = name.lower();
	if ( plural_test2.isNull() )
		plural_test2 = "";

	QString single_test1 = u.name.lower();
	if ( single_test1.isNull() )
		single_test1 = "";

	QString single_test2 = name.lower();
	if ( single_test2.isNull() )
		single_test2 = "";

	return plural_test1 == plural_test2 || single_test1 == single_test2;
}
<commit_msg>An important bug fix when importing recipes in any format, which in certain instances causes loss of unit info<commit_after>/***************************************************************************
 *   Copyright (C) 2004 by                                                 *
 *   Jason Kivlighn (mizunoami44@users.sourceforge.net)                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "unit.h"

Unit::Unit() :
  id(-1)
{
}

Unit::Unit( const QString &_name, const QString &_plural, int _id ) :
  id(_id),
  name(_name),
  plural(_plural)
{
}

Unit::Unit( const QString &_name, double amount )
{
	if ( amount > 1 )
		plural = _name;
	else
		name = _name;
}

bool Unit::operator==( const Unit &u ) const
{
	//treat QString::null and "" as the same
	QString plural_test1 = u.plural.lower();
	if ( plural_test1.isNull() )
		plural_test1 = "";

	QString plural_test2 = plural.lower();
	if ( plural_test2.isNull() )
		plural_test2 = "";

	QString single_test1 = u.name.lower();
	if ( single_test1.isNull() )
		single_test1 = "";

	QString single_test2 = name.lower();
	if ( single_test2.isNull() )
		single_test2 = "";

	if ( plural_test1.isEmpty() && plural_test2.isEmpty() && single_test1.isEmpty() && single_test2.isEmpty() )
		return true;
	else if ( plural_test1.isEmpty() && plural_test2.isEmpty() )
		return single_test1 == single_test2;
	else if ( single_test1.isEmpty() && single_test2.isEmpty() )
		return plural_test1 == plural_test2;
	else
		return (plural_test1 == plural_test2 || single_test1 == single_test2);
}
<|endoftext|>


<commit_before>#ifndef ENTT_CORE_ITERATOR_HPP
#define ENTT_CORE_ITERATOR_HPP

#include <iterator>
#include <memory>
#include <utility>

namespace entt {

/**
 * @brief Helper type to use as pointer with input iterators.
 * @tparam Type of wrapped value.
 */
template<typename Type>
struct input_iterator_pointer final {
    /*! @brief Pointer type. */
    using pointer = Type *;

    /*! @brief Default copy constructor, deleted on purpose. */
    input_iterator_pointer(const input_iterator_pointer &) = delete;

    /*! @brief Default move constructor. */
    constexpr input_iterator_pointer(input_iterator_pointer &&) = default;

    /**
     * @brief Constructs a proxy object by move.
     * @param val Value to use to initialize the proxy object.
     */
    constexpr input_iterator_pointer(Type &&val)
        : value{std::move(val)} {}

    /**
     * @brief Default copy assignment operator, deleted on purpose.
     * @return This proxy object.
     */
    input_iterator_pointer &operator=(const input_iterator_pointer &) = delete;

    /**
     * @brief Default move assignment operator.
     * @return This proxy object.
     */
    constexpr input_iterator_pointer &operator=(input_iterator_pointer &&) = default;

    /**
     * @brief Access operator for accessing wrapped values.
     * @return A pointer to the wrapped value.
     */
    [[nodiscard]] constexpr pointer operator->() noexcept {
        return std::addressof(value);
    }

private:
    Type value;
};

/**
 * @brief Utility class to create an iterable object from a pair of iterators.
 * @tparam It Type of iterator.
 * @tparam Sentinel Type of sentinel.
 */
template<typename It, typename Sentinel = It>
struct iterable_adaptor final {
    /*! @brief Value type. */
    using value_type = typename std::iterator_traits<It>::value_type;
    /*! @brief Iterator type. */
    using iterator = It;
    /*! @brief Sentinel type. */
    using sentinel = Sentinel;

    /*! @brief Default constructor. */
    constexpr iterable_adaptor() noexcept(std::is_nothrow_default_constructible_v<It> &&std::is_nothrow_default_constructible_v<Sentinel>)
        : first{},
          last{} {}

    /**
     * @brief Creates an iterable object from a pair of iterators.
     * @param from Begin iterator.
     * @param to End iterator.
     */
    constexpr iterable_adaptor(iterator from, sentinel to) noexcept(std::is_nothrow_move_constructible_v<It> &&std::is_nothrow_move_constructible_v<Sentinel>)
        : first{std::move(from)},
          last{std::move(to)} {}

    /**
     * @brief Returns an iterator to the beginning.
     * @return An iterator to the first element of the range.
     */
    [[nodiscard]] constexpr iterator begin() const noexcept {
        return first;
    }

    /**
     * @brief Returns an iterator to the end.
     * @return An iterator to the element following the last element of the
     * range.
     */
    [[nodiscard]] constexpr sentinel end() const noexcept {
        return last;
    }

    /*! @copydoc begin */
    [[nodiscard]] constexpr iterator cbegin() const noexcept {
        return begin();
    }

    /*! @copydoc end */
    [[nodiscard]] constexpr sentinel cend() const noexcept {
        return end();
    }

private:
    It first;
    Sentinel last;
};

} // namespace entt

#endif
<commit_msg>input_iterator_pointer: conditionally noexcept<commit_after>#ifndef ENTT_CORE_ITERATOR_HPP
#define ENTT_CORE_ITERATOR_HPP

#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>

namespace entt {

/**
 * @brief Helper type to use as pointer with input iterators.
 * @tparam Type of wrapped value.
 */
template<typename Type>
struct input_iterator_pointer final {
    /*! @brief Value type. */
    using value_type = Type;
    /*! @brief Pointer type. */
    using pointer = Type *;

    /*! @brief Default copy constructor, deleted on purpose. */
    input_iterator_pointer(const input_iterator_pointer &) noexcept(std::is_nothrow_copy_constructible_v<value_type>) = delete;

    /*! @brief Default move constructor. */
    constexpr input_iterator_pointer(input_iterator_pointer &&) noexcept(std::is_nothrow_move_constructible_v<value_type>) = default;

    /**
     * @brief Constructs a proxy object by move.
     * @param val Value to use to initialize the proxy object.
     */
    constexpr input_iterator_pointer(value_type &&val) noexcept(std::is_nothrow_move_constructible_v<value_type>)
        : value{std::move(val)} {}

    /**
     * @brief Default copy assignment operator, deleted on purpose.
     * @return This proxy object.
     */
    input_iterator_pointer &operator=(const input_iterator_pointer &) noexcept(std::is_nothrow_copy_assignable_v<value_type>) = delete;

    /**
     * @brief Default move assignment operator.
     * @return This proxy object.
     */
    constexpr input_iterator_pointer &operator=(input_iterator_pointer &&) noexcept(std::is_nothrow_move_assignable_v<value_type>) = default;

    /**
     * @brief Access operator for accessing wrapped values.
     * @return A pointer to the wrapped value.
     */
    [[nodiscard]] constexpr pointer operator->() noexcept {
        return std::addressof(value);
    }

private:
    Type value;
};

/**
 * @brief Utility class to create an iterable object from a pair of iterators.
 * @tparam It Type of iterator.
 * @tparam Sentinel Type of sentinel.
 */
template<typename It, typename Sentinel = It>
struct iterable_adaptor final {
    /*! @brief Value type. */
    using value_type = typename std::iterator_traits<It>::value_type;
    /*! @brief Iterator type. */
    using iterator = It;
    /*! @brief Sentinel type. */
    using sentinel = Sentinel;

    /*! @brief Default constructor. */
    constexpr iterable_adaptor() noexcept(std::is_nothrow_default_constructible_v<iterator> &&std::is_nothrow_default_constructible_v<sentinel>)
        : first{},
          last{} {}

    /**
     * @brief Creates an iterable object from a pair of iterators.
     * @param from Begin iterator.
     * @param to End iterator.
     */
    constexpr iterable_adaptor(iterator from, sentinel to) noexcept(std::is_nothrow_move_constructible_v<iterator> &&std::is_nothrow_move_constructible_v<sentinel>)
        : first{std::move(from)},
          last{std::move(to)} {}

    /**
     * @brief Returns an iterator to the beginning.
     * @return An iterator to the first element of the range.
     */
    [[nodiscard]] constexpr iterator begin() const noexcept {
        return first;
    }

    /**
     * @brief Returns an iterator to the end.
     * @return An iterator to the element following the last element of the
     * range.
     */
    [[nodiscard]] constexpr sentinel end() const noexcept {
        return last;
    }

    /*! @copydoc begin */
    [[nodiscard]] constexpr iterator cbegin() const noexcept {
        return begin();
    }

    /*! @copydoc end */
    [[nodiscard]] constexpr sentinel cend() const noexcept {
        return end();
    }

private:
    It first;
    Sentinel last;
};

} // namespace entt

#endif
<|endoftext|>


<commit_before>#include "depthviewwindow.h"
#include "ui_depthviewwindow.h"
#include "exportdialog.h"
#include "settingswindow.h"
#include "version.h"
#include <QKeyEvent>
#include <QFileDialog>
#include <QDebug>
#include <QMessageBox>
#include <QTime>
#include <QMimeData>

DepthViewWindow::DepthViewWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::DepthViewWindow){
    ui->setupUi(this);
    fileFilters << "*.jps" << "*.pns";
    ui->imageWidget->addActions(ui->menubar->actions());
    ui->imageWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->imageWidget, SIGNAL(doubleClicked()), ui->actionFullscreen, SLOT(toggle()));

    connect(ui->actionZoomIn,  SIGNAL(triggered()), ui->imageWidget, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), ui->imageWidget, SLOT(zoomOut()));

    this->loadSettings();
}

DepthViewWindow::~DepthViewWindow(){
    settings.setValue("lastrun", QDate::currentDate().toString());
    delete ui;
}

bool DepthViewWindow::loadImage(QString filename){
    QFileInfo info(filename);
    if(info.exists() && (info.suffix().toLower() == "jps" || info.suffix().toLower() == "pns")){
        QDir::setCurrent(info.path());
        currentFile = info.fileName();
        ui->imageWidget->loadStereoImage(currentFile);
        this->setWindowTitle(currentFile);
        ui->imageWidget->repaint();
        return true;
    }
    else{
        return false;
    }
}
bool DepthViewWindow::showLoadImageDialog(){
    QString filename = QFileDialog::getOpenFileName(this, tr("Open Image"), "", tr("Stereo Image Files (*.jps *.pns)"));
    if(!filename.isEmpty()){
        return loadImage(filename);
    }
    return false;
}

void DepthViewWindow::on_actionExit_triggered(){
    this->close();
}

void DepthViewWindow::on_actionOpen_triggered(){
    this->showLoadImageDialog();
}

void DepthViewWindow::on_actionAnglaphFullColor_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphFull;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAnglaphHalfColor_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphHalf;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAnglaphGreyscale_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphGreyscale;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideNoMirror_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySide;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorLeft_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMLeft;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorRight_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMRight;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorBoth_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMBoth;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomNoMirror_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottom;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorTop_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMTop;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorBottom_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMBottom;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorBoth_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMBoth;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionInterlacedHorizontal_triggered(){
    ui->imageWidget->mode = ImageWidget::InterlacedHorizontal;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionInterlacedVertical_triggered(){
    ui->imageWidget->mode = ImageWidget::InterlacedVertical;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionCheckerboard_triggered(){
    ui->imageWidget->mode = ImageWidget::Checkerboard;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSingleLeft_triggered(){
    ui->imageWidget->mode = ImageWidget::MonoLeft;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSingleRight_triggered(){
    ui->imageWidget->mode = ImageWidget::MonoRight;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionShowMenuBar_toggled(bool val){
    ui->menubar->setVisible(val);
}

void DepthViewWindow::on_actionFullscreen_toggled(bool val){
    if(val){
        setWindowState(windowState() | Qt::WindowFullScreen);
        ui->actionShowMenuBar->setChecked(false);
    }else{
        setWindowState(windowState() & ~Qt::WindowFullScreen);
        ui->actionShowMenuBar->setChecked(true);
    }
}

void DepthViewWindow::on_actionNext_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.empty()){
        int index = entryList.indexOf(currentFile) + 1;
        if(index < 0){
            index = entryList.count() - 1;
        }else if(index >= entryList.count()){
            index = 0;
        }
        loadImage(entryList[index]);
    }
}

void DepthViewWindow::on_actionPrevious_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.empty()){
        int index = entryList.indexOf(currentFile) - 1;
        if(index < 0){
            index = entryList.count() - 1;
        }else if(index >= entryList.count()){
            index = 0;
        }
        loadImage(entryList[index]);
    }
}

void DepthViewWindow::on_actionFirst_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.isEmpty()){
        loadImage(entryList[0]);
    }
}

void DepthViewWindow::on_actionLast_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.isEmpty()){
        loadImage(entryList[entryList.count() - 1]);
    }
}

void DepthViewWindow::mousePressEvent(QMouseEvent *e){
    if(e->buttons() == Qt::XButton2){
        this->on_actionNext_triggered();
    }
    if(e->buttons() == Qt::XButton1){
        this->on_actionPrevious_triggered();
    }
}

void DepthViewWindow::mouseDoubleClickEvent(QMouseEvent *e){
    if(e->button() == Qt::LeftButton){
        ui->actionFullscreen->toggle();
    }
}

void DepthViewWindow::on_actionSaveAs_triggered(){
    QString filename = QFileDialog::getSaveFileName(this, tr("Save Image"), "", tr("Stereo Image Files (*.jps *.pns);;Image Files (*.bmp *.jpg *.jpeg *.png *.ppm *.tiff *.xbm *.xpm)"));

    if(filename.contains(".jps", Qt::CaseInsensitive) || filename.contains(".pns", Qt::CaseInsensitive)){
        QImage out = drawSideBySide(ui->imageWidget->imgL,ui->imageWidget->imgR, 0, 0);

        if(!out.isNull()){
            if(filename.contains(".jps", Qt::CaseInsensitive)){
                out.save(filename, "JPG");
            }
            if(filename.contains(".pns", Qt::CaseInsensitive)){
                out.save(filename, "PNG");
            }
        }
    }
    else if(!filename.isNull()){
        ExportDialog dialog(this);

        if(dialog.exec() == QDialog::Accepted){
            if(dialog.anglaph){
                QImage out = drawAnglaph(ui->imageWidget->imgL, ui->imageWidget->imgR, 0, 0, 0, 0, 1.0f, dialog.colormult);

                if(!out.isNull()){
                    out.save(filename, NULL, dialog.quality);
                }
            }else if(dialog.sidebyside){
                QImage out = drawSideBySide(ui->imageWidget->imgL, ui->imageWidget->imgR, 0, 0, 0, 0, 1.0f, dialog.mirrorL, dialog.mirrorR);

                if(!out.isNull()){
                    out.save(filename, NULL, dialog.quality);
                }
            }else{
                if(dialog.saveL && dialog.saveR){
                    if(!ui->imageWidget->imgL.isNull()){
                        QString filenameL = filename;
                        ui->imageWidget->imgL.save(filenameL.insert(filenameL.lastIndexOf('.'), 'L'), NULL, dialog.quality);
                    }
                    if(!ui->imageWidget->imgR.isNull()){
                        QString filenameR = filename;
                        ui->imageWidget->imgR.save(filenameR.insert(filenameR.lastIndexOf('.'), 'R'), NULL, dialog.quality);
                    }
                }else if(dialog.saveL){
                    if(!ui->imageWidget->imgL.isNull()){
                        ui->imageWidget->imgL.save(filename, NULL, dialog.quality);
                    }
                }else if(dialog.saveR){
                    if(!ui->imageWidget->imgR.isNull()){
                        ui->imageWidget->imgR.save(filename, NULL, dialog.quality);
                    }
                }
            }
        }
    }
}

void DepthViewWindow::on_actionFit_triggered(){
    ui->imageWidget->setZoom(0.0f);
}

void DepthViewWindow::on_actionzoom100_triggered(){
    ui->imageWidget->setZoom(1.0f);
}

void DepthViewWindow::on_actionzoom50_triggered(){
    ui->imageWidget->setZoom(0.5f);
}

void DepthViewWindow::on_actionzoom200_triggered(){
    ui->imageWidget->setZoom(2.0f);
}

void DepthViewWindow::on_actionOptions_triggered(){
    SettingsWindow settingsdialog(&settings, this);
    if(settingsdialog.exec() == QDialog::Accepted){
        this->loadSettings();
    }
}

void DepthViewWindow::on_actionSwap_Left_Right_toggled(bool val){
    ui->imageWidget->swapLR = val;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAbout_triggered(){
    QMessageBox::about(this, tr("About DepthView"),
                       tr(""
                          "
DepthView %1 (%2)
"
                          "
DepthView is a basic application for viewing stereo 3D image files.
"
                          "
DepthView website: github.com/chipgw/depthview
"
                          "
Please report any bugs at: github.com/chipgw/depthview/issues
"
                          "").arg(version::getVersionString()).arg(version::git_revision.left(7)));
}

void DepthViewWindow::on_actionAboutQt_triggered(){
    QMessageBox::aboutQt(this);
}

bool DepthViewWindow::setRendererFromString(const QString &renderer){
    if(renderer == "Anglaph, Full Color"){
        this->on_actionAnglaphFullColor_triggered();
    }else if(renderer == "Anglaph, Half Color"){
        this->on_actionAnglaphHalfColor_triggered();
    }else if(renderer == "Anglaph, Greyscale"){
        this->on_actionAnglaphGreyscale_triggered();
    }else if(renderer == "Side by Side, No Mirror"){
        this->on_actionSideBySideNoMirror_triggered();
    }else if(renderer == "Side by Side, Mirror Left"){
        this->on_actionSideBySideMirrorLeft_triggered();
    }else if(renderer == "Side by Side, Mirror Right"){
        this->on_actionSideBySideMirrorRight_triggered();
    }else if(renderer == "Side by Side, Mirror Both"){
        this->on_actionSideBySideMirrorBoth_triggered();
    }else if(renderer == "Top/Bottom, No Mirror"){
        this->on_actionTopBottomNoMirror_triggered();
    }else if(renderer == "Top/Bottom, Mirror Top"){
        this->on_actionTopBottomMirrorTop_triggered();
    }else if(renderer == "Top/Bottom, Mirror Bottom"){
        this->on_actionTopBottomMirrorBottom_triggered();
    }else if(renderer == "Top/Bottom, Mirror Both"){
        this->on_actionTopBottomMirrorBoth_triggered();
    }else if(renderer == "Interlaced, Horizontal"){
        this->on_actionInterlacedHorizontal_triggered();
    }else if(renderer == "Interlaced, Vertical"){
        this->on_actionInterlacedVertical_triggered();
    }else if(renderer == "Checkerboard"){
        this->on_actionCheckerboard_triggered();
    }else if(renderer == "Mono, Left"){
        this->on_actionSingleLeft_triggered();
    }else if(renderer == "Mono, Right"){
        this->on_actionSingleRight_triggered();
    }else{
        return false;
    }
    return true;
}

void DepthViewWindow::loadSettings(){
    if(settings.contains("defaultrender")){
        setRendererFromString(settings.value("defaultrender").toString());
    }
    if(settings.contains("startfullscreen")){
        ui->actionFullscreen->setChecked(settings.value("startfullscreen").toBool());
    }else{
        ui->actionFullscreen->setChecked(false);
    }
    if(settings.contains("swapLR")){
        ui->actionSwap_Left_Right->setChecked(settings.value("swapLR").toBool());
    }else{
        ui->actionSwap_Left_Right->setChecked(false);
    }
    if(settings.contains("showmenubar")){
        ui->actionShowMenuBar->setChecked(settings.value("showmenubar").toBool());
    }else{
        ui->actionShowMenuBar->setChecked(true);
    }
    if(settings.contains("disabledragdrop")){
        setAcceptDrops(!settings.value("disabledragdrop").toBool());
    }else{
        setAcceptDrops(true);
    }
    if(settings.contains("startupdirectory") && currentFile.isEmpty() && !settings.value("startupdirectory").toString().isEmpty()){
        QDir::setCurrent(settings.value("startupdirectory").toString());
    }
}

void DepthViewWindow::parseCommandLine(const QStringList &args){
    bool loaded = !this->currentFile.isEmpty();

    for(QStringListIterator i(args); i.hasNext();){
        const QString &arg = i.next();
        if(arg == "--fullscreen"){
            ui->actionFullscreen->setChecked(true);
        }else if(arg == "--startdir"){
            if(i.hasNext()){
                QDir::setCurrent(i.next());
            }else{
                QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("Argument \"--startdir\" passed with no argument after it!"));
            }
        }else if(arg == "--renderer"){
            if(i.hasNext()){
                const QString &renderer = i.next();
                if(!setRendererFromString(renderer)){
                    QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("Invalid renderer \"%1\" passed to \"--renderer\" argument!").arg(renderer));
                }
            }else{
                QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("argument \"--renderer\" passed with no argument after it!"));
            }
        }else if(!loaded){
            loaded = loadImage(arg);
        }
    }
    if(!loaded && (!settings.contains("filedialogstartup") || settings.value("filedialogstartup").toBool())){
        showLoadImageDialog();
    }
}

void DepthViewWindow::dragEnterEvent(QDragEnterEvent *event){
    if(event->mimeData()->hasUrls()){
        foreach(QUrl url, event->mimeData()->urls()){
            QFileInfo info(url.toLocalFile());
            if(info.exists() && (info.suffix().toLower() == "jps" || info.suffix().toLower() == "pns")){
                return event->acceptProposedAction();
            }
        }
    }
}

void DepthViewWindow::dropEvent(QDropEvent *event){
    if (event->mimeData()->hasUrls()){
        foreach(QUrl url, event->mimeData()->urls()){
            if(loadImage(url.toLocalFile())) break;
        }
        event->acceptProposedAction();
    }
}
<commit_msg>show warning on --startdir argument failure.<commit_after>#include "depthviewwindow.h"
#include "ui_depthviewwindow.h"
#include "exportdialog.h"
#include "settingswindow.h"
#include "version.h"
#include <QKeyEvent>
#include <QFileDialog>
#include <QDebug>
#include <QMessageBox>
#include <QTime>
#include <QMimeData>

DepthViewWindow::DepthViewWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::DepthViewWindow){
    ui->setupUi(this);
    fileFilters << "*.jps" << "*.pns";
    ui->imageWidget->addActions(ui->menubar->actions());
    ui->imageWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->imageWidget, SIGNAL(doubleClicked()), ui->actionFullscreen, SLOT(toggle()));

    connect(ui->actionZoomIn,  SIGNAL(triggered()), ui->imageWidget, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), ui->imageWidget, SLOT(zoomOut()));

    this->loadSettings();
}

DepthViewWindow::~DepthViewWindow(){
    settings.setValue("lastrun", QDate::currentDate().toString());
    delete ui;
}

bool DepthViewWindow::loadImage(QString filename){
    QFileInfo info(filename);
    if(info.exists() && (info.suffix().toLower() == "jps" || info.suffix().toLower() == "pns")){
        QDir::setCurrent(info.path());
        currentFile = info.fileName();
        ui->imageWidget->loadStereoImage(currentFile);
        this->setWindowTitle(currentFile);
        ui->imageWidget->repaint();
        return true;
    }
    else{
        return false;
    }
}
bool DepthViewWindow::showLoadImageDialog(){
    QString filename = QFileDialog::getOpenFileName(this, tr("Open Image"), "", tr("Stereo Image Files (*.jps *.pns)"));
    if(!filename.isEmpty()){
        return loadImage(filename);
    }
    return false;
}

void DepthViewWindow::on_actionExit_triggered(){
    this->close();
}

void DepthViewWindow::on_actionOpen_triggered(){
    this->showLoadImageDialog();
}

void DepthViewWindow::on_actionAnglaphFullColor_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphFull;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAnglaphHalfColor_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphHalf;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAnglaphGreyscale_triggered(){
    ui->imageWidget->mode = ImageWidget::AnglaphGreyscale;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideNoMirror_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySide;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorLeft_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMLeft;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorRight_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMRight;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSideBySideMirrorBoth_triggered(){
    ui->imageWidget->mode = ImageWidget::SidebySideMBoth;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomNoMirror_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottom;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorTop_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMTop;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorBottom_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMBottom;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionTopBottomMirrorBoth_triggered(){
    ui->imageWidget->mode = ImageWidget::TopBottomMBoth;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionInterlacedHorizontal_triggered(){
    ui->imageWidget->mode = ImageWidget::InterlacedHorizontal;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionInterlacedVertical_triggered(){
    ui->imageWidget->mode = ImageWidget::InterlacedVertical;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionCheckerboard_triggered(){
    ui->imageWidget->mode = ImageWidget::Checkerboard;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSingleLeft_triggered(){
    ui->imageWidget->mode = ImageWidget::MonoLeft;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionSingleRight_triggered(){
    ui->imageWidget->mode = ImageWidget::MonoRight;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionShowMenuBar_toggled(bool val){
    ui->menubar->setVisible(val);
}

void DepthViewWindow::on_actionFullscreen_toggled(bool val){
    if(val){
        setWindowState(windowState() | Qt::WindowFullScreen);
        ui->actionShowMenuBar->setChecked(false);
    }else{
        setWindowState(windowState() & ~Qt::WindowFullScreen);
        ui->actionShowMenuBar->setChecked(true);
    }
}

void DepthViewWindow::on_actionNext_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.empty()){
        int index = entryList.indexOf(currentFile) + 1;
        if(index < 0){
            index = entryList.count() - 1;
        }else if(index >= entryList.count()){
            index = 0;
        }
        loadImage(entryList[index]);
    }
}

void DepthViewWindow::on_actionPrevious_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.empty()){
        int index = entryList.indexOf(currentFile) - 1;
        if(index < 0){
            index = entryList.count() - 1;
        }else if(index >= entryList.count()){
            index = 0;
        }
        loadImage(entryList[index]);
    }
}

void DepthViewWindow::on_actionFirst_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.isEmpty()){
        loadImage(entryList[0]);
    }
}

void DepthViewWindow::on_actionLast_triggered(){
    QStringList entryList = QDir::current().entryList(fileFilters);
    if(!entryList.isEmpty()){
        loadImage(entryList[entryList.count() - 1]);
    }
}

void DepthViewWindow::mousePressEvent(QMouseEvent *e){
    if(e->buttons() == Qt::XButton2){
        this->on_actionNext_triggered();
    }
    if(e->buttons() == Qt::XButton1){
        this->on_actionPrevious_triggered();
    }
}

void DepthViewWindow::mouseDoubleClickEvent(QMouseEvent *e){
    if(e->button() == Qt::LeftButton){
        ui->actionFullscreen->toggle();
    }
}

void DepthViewWindow::on_actionSaveAs_triggered(){
    QString filename = QFileDialog::getSaveFileName(this, tr("Save Image"), "", tr("Stereo Image Files (*.jps *.pns);;Image Files (*.bmp *.jpg *.jpeg *.png *.ppm *.tiff *.xbm *.xpm)"));

    if(filename.contains(".jps", Qt::CaseInsensitive) || filename.contains(".pns", Qt::CaseInsensitive)){
        QImage out = drawSideBySide(ui->imageWidget->imgL,ui->imageWidget->imgR, 0, 0);

        if(!out.isNull()){
            if(filename.contains(".jps", Qt::CaseInsensitive)){
                out.save(filename, "JPG");
            }
            if(filename.contains(".pns", Qt::CaseInsensitive)){
                out.save(filename, "PNG");
            }
        }
    }
    else if(!filename.isNull()){
        ExportDialog dialog(this);

        if(dialog.exec() == QDialog::Accepted){
            if(dialog.anglaph){
                QImage out = drawAnglaph(ui->imageWidget->imgL, ui->imageWidget->imgR, 0, 0, 0, 0, 1.0f, dialog.colormult);

                if(!out.isNull()){
                    out.save(filename, NULL, dialog.quality);
                }
            }else if(dialog.sidebyside){
                QImage out = drawSideBySide(ui->imageWidget->imgL, ui->imageWidget->imgR, 0, 0, 0, 0, 1.0f, dialog.mirrorL, dialog.mirrorR);

                if(!out.isNull()){
                    out.save(filename, NULL, dialog.quality);
                }
            }else{
                if(dialog.saveL && dialog.saveR){
                    if(!ui->imageWidget->imgL.isNull()){
                        QString filenameL = filename;
                        ui->imageWidget->imgL.save(filenameL.insert(filenameL.lastIndexOf('.'), 'L'), NULL, dialog.quality);
                    }
                    if(!ui->imageWidget->imgR.isNull()){
                        QString filenameR = filename;
                        ui->imageWidget->imgR.save(filenameR.insert(filenameR.lastIndexOf('.'), 'R'), NULL, dialog.quality);
                    }
                }else if(dialog.saveL){
                    if(!ui->imageWidget->imgL.isNull()){
                        ui->imageWidget->imgL.save(filename, NULL, dialog.quality);
                    }
                }else if(dialog.saveR){
                    if(!ui->imageWidget->imgR.isNull()){
                        ui->imageWidget->imgR.save(filename, NULL, dialog.quality);
                    }
                }
            }
        }
    }
}

void DepthViewWindow::on_actionFit_triggered(){
    ui->imageWidget->setZoom(0.0f);
}

void DepthViewWindow::on_actionzoom100_triggered(){
    ui->imageWidget->setZoom(1.0f);
}

void DepthViewWindow::on_actionzoom50_triggered(){
    ui->imageWidget->setZoom(0.5f);
}

void DepthViewWindow::on_actionzoom200_triggered(){
    ui->imageWidget->setZoom(2.0f);
}

void DepthViewWindow::on_actionOptions_triggered(){
    SettingsWindow settingsdialog(&settings, this);
    if(settingsdialog.exec() == QDialog::Accepted){
        this->loadSettings();
    }
}

void DepthViewWindow::on_actionSwap_Left_Right_toggled(bool val){
    ui->imageWidget->swapLR = val;
    ui->imageWidget->repaint();
}

void DepthViewWindow::on_actionAbout_triggered(){
    QMessageBox::about(this, tr("About DepthView"),
                       tr(""
                          "
DepthView %1 (%2)
"
                          "
DepthView is a basic application for viewing stereo 3D image files.
"
                          "
DepthView website: github.com/chipgw/depthview
"
                          "
Please report any bugs at: github.com/chipgw/depthview/issues
"
                          "").arg(version::getVersionString()).arg(version::git_revision.left(7)));
}

void DepthViewWindow::on_actionAboutQt_triggered(){
    QMessageBox::aboutQt(this);
}

bool DepthViewWindow::setRendererFromString(const QString &renderer){
    if(renderer == "Anglaph, Full Color"){
        this->on_actionAnglaphFullColor_triggered();
    }else if(renderer == "Anglaph, Half Color"){
        this->on_actionAnglaphHalfColor_triggered();
    }else if(renderer == "Anglaph, Greyscale"){
        this->on_actionAnglaphGreyscale_triggered();
    }else if(renderer == "Side by Side, No Mirror"){
        this->on_actionSideBySideNoMirror_triggered();
    }else if(renderer == "Side by Side, Mirror Left"){
        this->on_actionSideBySideMirrorLeft_triggered();
    }else if(renderer == "Side by Side, Mirror Right"){
        this->on_actionSideBySideMirrorRight_triggered();
    }else if(renderer == "Side by Side, Mirror Both"){
        this->on_actionSideBySideMirrorBoth_triggered();
    }else if(renderer == "Top/Bottom, No Mirror"){
        this->on_actionTopBottomNoMirror_triggered();
    }else if(renderer == "Top/Bottom, Mirror Top"){
        this->on_actionTopBottomMirrorTop_triggered();
    }else if(renderer == "Top/Bottom, Mirror Bottom"){
        this->on_actionTopBottomMirrorBottom_triggered();
    }else if(renderer == "Top/Bottom, Mirror Both"){
        this->on_actionTopBottomMirrorBoth_triggered();
    }else if(renderer == "Interlaced, Horizontal"){
        this->on_actionInterlacedHorizontal_triggered();
    }else if(renderer == "Interlaced, Vertical"){
        this->on_actionInterlacedVertical_triggered();
    }else if(renderer == "Checkerboard"){
        this->on_actionCheckerboard_triggered();
    }else if(renderer == "Mono, Left"){
        this->on_actionSingleLeft_triggered();
    }else if(renderer == "Mono, Right"){
        this->on_actionSingleRight_triggered();
    }else{
        return false;
    }
    return true;
}

void DepthViewWindow::loadSettings(){
    if(settings.contains("defaultrender")){
        setRendererFromString(settings.value("defaultrender").toString());
    }
    if(settings.contains("startfullscreen")){
        ui->actionFullscreen->setChecked(settings.value("startfullscreen").toBool());
    }else{
        ui->actionFullscreen->setChecked(false);
    }
    if(settings.contains("swapLR")){
        ui->actionSwap_Left_Right->setChecked(settings.value("swapLR").toBool());
    }else{
        ui->actionSwap_Left_Right->setChecked(false);
    }
    if(settings.contains("showmenubar")){
        ui->actionShowMenuBar->setChecked(settings.value("showmenubar").toBool());
    }else{
        ui->actionShowMenuBar->setChecked(true);
    }
    if(settings.contains("disabledragdrop")){
        setAcceptDrops(!settings.value("disabledragdrop").toBool());
    }else{
        setAcceptDrops(true);
    }
    if(settings.contains("startupdirectory") && currentFile.isEmpty() && !settings.value("startupdirectory").toString().isEmpty()){
        QDir::setCurrent(settings.value("startupdirectory").toString());
    }
}

void DepthViewWindow::parseCommandLine(const QStringList &args){
    bool loaded = !this->currentFile.isEmpty();

    for(QStringListIterator i(args); i.hasNext();){
        const QString &arg = i.next();
        if(arg == "--fullscreen"){
            ui->actionFullscreen->setChecked(true);
        }else if(arg == "--startdir"){
            if(i.hasNext()){
                const QString &dir = i.next();
                if(!QDir::setCurrent(dir)){
                    QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("Invalid directory \"\%1\" passed to \"--startdir\" argument!").arg(dir));
                }
            }else{
                QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("Argument \"--startdir\" passed with no argument after it!"));
            }
        }else if(arg == "--renderer"){
            if(i.hasNext()){
                const QString &renderer = i.next();
                if(!setRendererFromString(renderer)){
                    QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("Invalid renderer \"%1\" passed to \"--renderer\" argument!").arg(renderer));
                }
            }else{
                QMessageBox::warning(this, tr("Warning: Invalid Command Line!"), tr("argument \"--renderer\" passed with no argument after it!"));
            }
        }else if(!loaded){
            loaded = loadImage(arg);
        }
    }
    if(!loaded && (!settings.contains("filedialogstartup") || settings.value("filedialogstartup").toBool())){
        showLoadImageDialog();
    }
}

void DepthViewWindow::dragEnterEvent(QDragEnterEvent *event){
    if(event->mimeData()->hasUrls()){
        foreach(QUrl url, event->mimeData()->urls()){
            QFileInfo info(url.toLocalFile());
            if(info.exists() && (info.suffix().toLower() == "jps" || info.suffix().toLower() == "pns")){
                return event->acceptProposedAction();
            }
        }
    }
}

void DepthViewWindow::dropEvent(QDropEvent *event){
    if (event->mimeData()->hasUrls()){
        foreach(QUrl url, event->mimeData()->urls()){
            if(loadImage(url.toLocalFile())) break;
        }
        event->acceptProposedAction();
    }
}
<|endoftext|>


<commit_before>#include "fileseq.h"
#include "private/frameset_p.h"

#include <algorithm>
#include <iterator>
#include <string>
#include <sstream>

namespace fileseq {

std::string framesToFrameRange(const Frames &frames,
                               bool sorted, int zfill) {

    size_t count = frames.size();
    if (count == 0) {
        return "";
    }

    if (count == 1) {
        return internal::zfill(frames[0], zfill);
    }

    const Frames* framesPtr = &frames;

    if (sorted) {
        Frames sortedFrames = frames;
        std::sort(sortedFrames.begin(), sortedFrames.end());
        framesPtr = &sortedFrames;
    }

    size_t i = 0;
    long step = 0;
    bool hasWritten = false;
    std::string start, end;
    std::stringstream buf;

    Frames::const_iterator framesIt = framesPtr->begin();
    Frames::const_iterator framesEnd = framesPtr->end();

    while (framesIt < framesEnd) {

        // Items left
        count = std::distance(framesIt, framesEnd);

        // If we get to the last element, just write it and end
        if (count <= 2) {
            for (i = 0; i < count; ++i) {
                if (hasWritten) {
                    buf << ",";
                }
                buf << internal::zfill(framesIt[i], zfill);
            }
            hasWritten = true;
            break;
        }
        // At this point, we have 3 or more frames to check.
        // Scan the current window of the slice to see how
        // many frames we can consume into a group
        step = framesIt[1] - framesIt[0];
        for (i = 0; i < (count-1); ++i) {
            // We have scanned as many frames as we can
            // for this group. Now write them and stop
            // looping on this window
            if ((framesIt[i+1] - framesIt[i]) != step) {
                break;
            }
        }

        // Subsequent groups are comma-separated
        if (hasWritten) {
            buf << ",";
            hasWritten = true;
        }

        // We only have a single frame to write for this group
        if (i == 0) {
            buf << internal::zfill(framesIt[0], zfill);
            framesIt++;
            hasWritten = true;
            continue;
        }

        // First do a check to see if we could have gotten a larger range
        // out of subsequent values with a different step size
        if (i == 1 && count > 3) {
            // Check if the next two pairwise frames have the same step.
            // If so, then it is better than our current grouping.
            if ((framesIt[2] - framesIt[1]) == (framesIt[3] - framesIt[2])) {
                // Just consume the first frame, and allow the next
                // loop to scan the new stepping
                buf << internal::zfill(framesIt[0], zfill);
                framesIt++;
                hasWritten = true;
                continue;
            }
        }

        // Otherwise write out this step range
        start = internal::zfill(framesIt[0], zfill);
        end = internal::zfill(framesIt[i], zfill);
        buf << start << "-" << end;
        if (step > 1) {
            buf << "x" << step;
        }
        framesIt++;
        hasWritten = true;
    }

    return buf.str();
}

bool isFrameRange(const std::string &frange) {
    internal::RangeMatches matches;
    return frameRangeMatches(matches, frange);
}

FileSequence findSequenceOnDisk(const std::string &pattern, Status* ok) {
    return findSequenceOnDisk(pattern, PadStyleDefault, ok);
}

FileSequence findSequenceOnDisk(const std::string &pattern, PadStyle style, Status* ok) {
    return FileSequence("");
}

Status findSequencesOnDisk(FileSequences &seqs,
                           const std::string &path,
                           bool hiddenFiles,
                           bool singleFiles,
                           PadStyle style) {

    Status stat;
    stat.setError("Not implemented");
    return stat;
}

} // fileseq
<commit_msg>Fix bug in framesToFrameRange() iteration<commit_after>#include "fileseq.h"
#include "private/frameset_p.h"

#include <algorithm>
#include <iterator>
#include <string>
#include <sstream>

namespace fileseq {

std::string framesToFrameRange(const Frames &frames,
                               bool sorted, int zfill) {

    Frames::size_type count = frames.size();
    if (count == 0) {
        return "";
    }

    if (count == 1) {
        return internal::zfill(frames[0], zfill);
    }

    Frames::const_iterator framesIt = frames.begin();
    Frames::const_iterator framesEnd = frames.end();

    Frames sortedFrames;

    if (sorted) {
        // Copy
        sortedFrames = frames;

        // Sort
        std::sort(sortedFrames.begin(), sortedFrames.end());

        framesIt = sortedFrames.begin();
        framesEnd = sortedFrames.end();
    }

    long step = 0;
    bool hasWritten = false;
    Frames::size_type i = 0;

    std::string start, end;
    std::stringstream buf;

    while (framesIt != framesEnd) {

        // Items left
        count = std::distance(framesIt, framesEnd);

        // If we get to the last element, just write it and end
        if (count <= 2) {
            for (i = 0; i < count; ++i) {
                if (hasWritten) {
                    buf << ",";
                }
                buf << internal::zfill(framesIt[i], zfill);
            }
            hasWritten = true;
            break;
        }

        // At this point, we have 3 or more frames to check.
        // Scan the current window of the slice to see how
        // many frames we can consume into a group
        step = framesIt[1] - framesIt[0];

        // Scan and update the pointer index until we get
        // to a point where the step changes
        for (i = 0; i < (count-1); ++i) {

            if ((framesIt[i+1] - framesIt[i]) != step) {
                // We have scanned as many frames as we can
                // for this group. Now write them and stop
                // looping on this window, because the step
                // has changed.
                break;
            }
        }

        // Subsequent groups are comma-separated
        if (hasWritten) {
            buf << ",";
            hasWritten = true;
        }

        // We only have a single frame to write for this group
        if (i == 0) {
            buf << internal::zfill(framesIt[0], zfill);
            framesIt++;
            hasWritten = true;
            continue;
        }

        // First do a check to see if we could have gotten a larger range
        // out of subsequent values with a different step size
        if (i == 1 && count > 3) {
            // Check if the next two pairwise frames have the same step.
            // If so, then it is better than our current grouping.
            if ((framesIt[2] - framesIt[1]) == (framesIt[3] - framesIt[2])) {
                // Just consume the first frame, and allow the next
                // loop to scan the new stepping
                buf << internal::zfill(framesIt[0], zfill);
                framesIt++;
                hasWritten = true;
                continue;
            }
        }

        // Otherwise write out this step range
        start = internal::zfill(framesIt[0], zfill);
        end = internal::zfill(framesIt[i], zfill);
        buf << start << "-" << end;

        if (step > 1) {
            buf << "x" << step;
        }

        hasWritten = true;

        // Advance our iterator to the end of the current window
        // so that we can test the next available number
        framesIt += (i+1);
    }

    return buf.str();
}

bool isFrameRange(const std::string &frange) {
    internal::RangeMatches matches;
    return frameRangeMatches(matches, frange);
}

FileSequence findSequenceOnDisk(const std::string &pattern, Status* ok) {
    return findSequenceOnDisk(pattern, PadStyleDefault, ok);
}

FileSequence findSequenceOnDisk(const std::string &pattern, PadStyle style, Status* ok) {
    return FileSequence("");
}

Status findSequencesOnDisk(FileSequences &seqs,
                           const std::string &path,
                           bool hiddenFiles,
                           bool singleFiles,
                           PadStyle style) {

    Status stat;
    stat.setError("Not implemented");
    return stat;
}

} // fileseq
<|endoftext|>