## Code Excerpt for Texture Model Symbol

    Scalar Scale; // in [30 .. 80] stepsize 1
    Scalar Letter; // in [0 .. 29] stepsize 1
    Scalar Randomize; // in [1 .. 0] stepsize 0.1

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

        scale_ = boost::math::round(Scale);

        letter_ = Image<Scalar>(scale_,scale_, 1);
        ToolsImage::fill(letter_, Eigen::Matrix<Scalar, 3, 1>::Zero());

        QImage letter(scale_,scale_,QImage::Format_RGB32);
        QPainter painter(&letter);
        painter.fillRect(letter.rect(), Qt::white);

        QFont font("Wingdings", (scale_ - floor(scale_/10.0)));

        QString str = ToolsImage::intToWingDing(Letter);
        QRect rect = QRect(0, 0, scale_, scale_);
        painter.setFont(font);
        painter.drawText( rect, Qt::AlignCenter, str);
        painter.end();

        ToolsImage::qImgToImgData(letter, letter_, 1);

        // offset for converting coordinates to only positive numbers
        // which makes the offset easier
        Eigen::Vector2i size = getImageSizeForRotation(settings_.resolution_x, settings_.resolution_y, rotation_);
        offset_x_ = (0.5*(size.x() - settings_.resolution_x));
        offset_y_ = (0.5*(size.y() - settings_.resolution_y));

        int count = ceil((size.x() / (Scalar) scale_)) + 2;
        offset_ = Image<vector<int> >(count,count, 1);

        random_range_ = floor(Randomize * scale_);

        generator_.seed(0);
        boost::uniform_int<> range(0,random_range_);

        for(int x=0; x < count; ++x) {
          for(int y=0; y < count; ++y) {
            vector<int> tmp(2,0);
            if(random_range_ != 0) {
              boost::variate_generator<boost::mt19937&, boost::uniform_int<> > val_x(generator_, range);
              tmp[0] = val_x();
              boost::variate_generator<boost::mt19937&, boost::uniform_int<> > val_y(generator_, range);
              tmp[1] = val_y();
            }
            offset_(x,y,0) = tmp;
          }
        }
    }

    Scalar TextureSymbol::evaluate(const Scalar &x_norm, const Scalar &y_norm){
        Scalar value = 1.0;

        int x = (boost::math::iround((x_norm * settings_.resolution_x) + offset_x_));
        int y = (boost::math::iround((y_norm * settings_.resolution_y) + offset_y_));
        Scalar x_index_coordinate = x/(Scalar) scale_;
        Scalar y_index_coordinate = y/(Scalar) scale_;

        int x_cell_coordinate = floor(x_index_coordinate);
        int y_cell_coordinate  = floor(y_index_coordinate);
        int x_cell = x_cell_coordinate ;
        int y_cell = y_cell_coordinate ;
        int offset_x = 0;
        int offset_y = 0;

        x_index_coordinate -= x_cell;
        x_index_coordinate *= scale_;
        y_index_coordinate -= y_cell;
        y_index_coordinate *= scale_;

        Scalar x_index = x_index_coordinate;
        Scalar y_index = y_index_coordinate;

        int index = 0;
        if(random_range_ != 0) index = -1;

        for (int i = index; i <= 0; ++i) {
          for (int j = index; j <= 0; j++) {

            x_cell = x_cell_coordinate +1; // add one for having data also at the border cells
            y_cell = y_cell_coordinate +1;

            x_index = x_index_coordinate ;
            y_index = y_index_coordinate ;

            x_cell += i;
            y_cell += j;

            if(x_cell >= 0 && y_cell >= 0) {
              offset_x = offset_(x_cell,y_cell,0)[0];
              offset_y = offset_(x_cell,y_cell,0)[1];

              if(i == 0) {
                x_index -= offset_x;
              } else {
                x_index += (scale_ - offset_x);
              }

              if(j == 0) {
                y_index -= offset_y;
              } else {
                y_index += (scale_ - offset_y);
              }

              int x_coord = boost::math::iround(x_index);
              int y_coord = boost::math::iround(y_index);
              if(x_coord < scale_ && y_coord < scale_ && x_coord >= 0 && y_coord >= 0) {
                value = min(value, letter_(x_coord,y_coord,0));
              }
            }
          }
        }

        return value;
    }