const SoundShape *SoundBoxShapeWidget::createSoundShape() const
	{
		Point3<float> position(positionX->value(), positionY->value(), positionZ->value());

		Vector3<float> halfSizes(halfSizeX->value(), halfSizeY->value(), halfSizeZ->value());

		double orientationAngleDegree = orientationAngle->value();
		double orientationAngleRadian = AngleConverter<double>::toRadian(orientationAngleDegree);
		Vector3<float> orientationAxis(orientationAxisX->value(), orientationAxisY->value(), orientationAxisZ->value());
		Quaternion<float> orientation(orientationAxis, orientationAngleRadian);

		return new SoundBox(halfSizes, position, orientation, margin->value());
	}
bool ImageLogPolProjection::_initLogPolarCortexSampling(const double reductionFactor, const double)
{
    _initOK=false;

    if (_selectedProjection!=CORTEXLOGPOLARPROJECTION)
    {
        std::cerr<<"ImageLogPolProjection::could not initialize log projection for a logPolar projection system\n -> you probably chose the wrong init function, use initLogRetinaSampling() instead"<<std::endl;
        return false;
    }

    if (reductionFactor<1.0)
    {
        std::cerr<<"ImageLogPolProjection::reduction factor must be superior to 0, skeeping initialisation..."<<std::endl;
        return false;
    }

    // compute the smallest image size
    unsigned int minDimension=(_filterOutput.getNBrows() < _filterOutput.getNBcolumns() ? _filterOutput.getNBrows() : _filterOutput.getNBcolumns());
    // specifiying new reduction factor after preliminar checks
    _reductionFactor=reductionFactor;
    // compute image output size
    _outputNBrows=(unsigned int)((double)minDimension/reductionFactor);
    _outputNBcolumns=(unsigned int)((double)minDimension/reductionFactor);
    _outputNBpixels=_outputNBrows*_outputNBcolumns;
    _outputDoubleNBpixels=_outputNBrows*_outputNBcolumns*2;

    // get half frame size
    //unsigned int halfOutputRows = _outputNBrows/2-1;
    //unsigned int halfOutputColumns = _outputNBcolumns/2-1;
    unsigned int halfInputRows = _filterOutput.getNBrows()/2-1;
    unsigned int halfInputColumns = _filterOutput.getNBcolumns()/2-1;


#ifdef IMAGELOGPOLPROJECTION_DEBUG
    std::cout<<"ImageLogPolProjection::Log resampled image size: "<<_outputNBrows<<"*"<<_outputNBcolumns<<std::endl;
#endif

    // setup progressive prefilter that will be applied BEFORE log sampling
    setProgressiveFilterConstants_CentredAccuracy(0.f, 0.f, 0.99f);

    // (re)create the image output buffer and transform table if the reduction factor changed
    _sampledFrame.resize(_outputNBpixels*(1+(unsigned int)_colorModeCapable*2));

    // create the radius and orientation axis and fill them, radius E [0;1], orientation E[-pi, pi]
    std::valarray<double> radiusAxis(_outputNBcolumns);
    double radiusStep=2.30/(double)_outputNBcolumns;
    for (unsigned int i=0;i<_outputNBcolumns;++i)
    {
        radiusAxis[i]=i*radiusStep;
    }
    std::valarray<double> orientationAxis(_outputNBrows);
    double orientationStep=-2.0*CV_PI/(double)_outputNBrows;
    for (unsigned int io=0;io<_outputNBrows;++io)
    {
        orientationAxis[io]=io*orientationStep;
    }
    // -> use a temporay transform table which is bigger than the final one, we only report pixels coordinates that are included in the sampled picture
    std::valarray<unsigned int> tempTransformTable(2*_outputNBpixels); // the structure would be: (pixelInputCoordinate n)(pixelOutputCoordinate n)(pixelInputCoordinate n+1)(pixelOutputCoordinate n+1)
    _usefullpixelIndex=0;

    //std::cout<<"ImageLogPolProjection::Starting cortex projection"<<std::endl;
    // compute transformation, get theta and Radius in reagrd of the output sampled pixel
    double diagonalLenght=std::sqrt((double)(_outputNBcolumns*_outputNBcolumns+_outputNBrows*_outputNBrows));
    for (unsigned int radiusIndex=0;radiusIndex<_outputNBcolumns;++radiusIndex)
        for(unsigned int orientationIndex=0;orientationIndex<_outputNBrows;++orientationIndex)
        {
            double x=1.0+sinh(radiusAxis[radiusIndex])*cos(orientationAxis[orientationIndex]);
            double y=sinh(radiusAxis[radiusIndex])*sin(orientationAxis[orientationIndex]);
            // get the input picture coordinate
            double R=diagonalLenght*std::sqrt(x*x+y*y)/(5.0+std::sqrt(x*x+y*y));
            double theta=atan2(y,x);
            // convert input polar coord into cartesian/C compatble coordinate
            unsigned int columnIndex=(unsigned int)(cos(theta)*R)+halfInputColumns;
            unsigned int rowIndex=(unsigned int)(sin(theta)*R)+halfInputRows;
            //std::cout<<"ImageLogPolProjection::R="<<R<<" / Theta="<<theta<<" / (x, y)="<<columnIndex<<", "<<rowIndex<<std::endl;
            if ((columnIndex<_filterOutput.getNBcolumns())&&(columnIndex>0)&&(rowIndex<_filterOutput.getNBrows())&&(rowIndex>0))
            {
                // set coordinate
                tempTransformTable[_usefullpixelIndex++]=radiusIndex+orientationIndex*_outputNBcolumns;
                tempTransformTable[_usefullpixelIndex++]= columnIndex+rowIndex*_filterOutput.getNBcolumns();
            }
        }

    // (re)creating and filling the transform table
    _transformTable.resize(_usefullpixelIndex);
    memcpy(&_transformTable[0], &tempTransformTable[0], sizeof(unsigned int)*_usefullpixelIndex);

    // reset all buffers
    clearAllBuffers();
    _initOK=true;
    return true;
}