## Code Excerpt for Texture Model CellularGrid

    Scalar PointDensity; // in [1 .. 5] stepsize 0.2
    Scalar Stretch;      // in [0 .. 6] stepsize 0.6
    Scalar InnerWidth;   // in [0 .. 1] stepsize 0.05
    Scalar OuterWidth;   // in [0 .. 1] stepsize 0.05

    void TextureCellularGrid::setupParameter(const std::vector<Scalar> &parameter)
    {

      // ad-hoc perceptual scaling
      point_no_ = pow(2.0, PointDensity);
      stretch_ = pow(2.0, Stretch);

      if(OuterWidth > InnerWidth) {
        width_inner_ = InnerWidth;
        width_outer_ = OuterWidth;
      } else {
        width_inner_ = OuterWidth;
        width_outer_ = InnerWidth;
      }
    }

    Scalar TextureCellularGrid::evaluate(const Scalar &x_norm, const Scalar &y_norm)
    {
        Scalar value = 0.0;
        Scalar coord_x = fabs(x_norm+0.5);
        Scalar coord_y = fabs(y_norm+0.5);

        // scale
        coord_x *= point_no_;
        coord_y *= point_no_;

        // stretch
        coord_x *= 1.0 / stretch_;

        Scalar fract_x = coord_x - (int) coord_x;
        Scalar fract_y = coord_y - (int) coord_y;

        if (fract_x > 0.5)
        {
            fract_x = 1.0 - fract_x;
        }
        if (fract_y > 0.5)
        {
            fract_y = 1.0 - fract_y;
        }

        value = Tools::pNorm(fract_x,fract_y)/ (Scalar) Tools::pNorm(0.5,0.5);
        value = (value - width_inner_) / (std::max) ((Scalar) 10e-8, (width_outer_ - width_inner_));
        value = (std::min) ( (Scalar) 1.0, (std::max) ( (Scalar) 0.0, value));
        return value;

    }