int HighOrderMeshGenerator::meshDimension(int dim, int order){
  element_set& elements = mesh.getElementsOfDim(dim);
  for(auto it = elements.begin(); it != elements.end(); ++it){
    const unique_element_ptr& el = *it;

    MEl_to_ActiveEl m2a(mesh.getNodes(),index_factory);
    const arma::mat& elnodes = m2a.get(el).getNodesMatrix();
    const arma::mat& interpolation_matrix = 
      node_interpolator->getNodeInterpolationMatrix(el->getElementType(),
						    el->getOrder(),order);

    arma::mat newelnodes = elnodes*interpolation_matrix;
    arma::mat new_parametric_coords;


    if(el->hasGeoEntity()){
      ParametricCoordinateEvaluator 
	parametric_evaluator(geometry,mesh.getNodes());

      const arma::mat& parametric_coords = 
	parametric_evaluator.getParametricCoordinates(el);


      const arma::mat& newparametric = 
	parametric_coords*interpolation_matrix;
      

      newelnodes = 
	parametric_evaluator.projectPointsOnGeometry(el,
						     newelnodes,
						     newparametric,
						     new_parametric_coords);
  
    }

    //std::cout << "After has geo entity" << std::endl;
    
    std::vector<int> nodeindices = 
      insertNewNodes(el,newelnodes,new_parametric_coords,order);


    /*
    for(int i = 0; i < nodeindices.size(); i++){
      std::cout << nodeindices[i] << " ";
    }
    std::cout << std::endl;
    */

    insertNewElement(el,nodeindices,order);

  }

};
void THtmlParser::prepend(int parent, const THtmlParser &parser)
{
    if (parser.elementCount() <= 1)
        return;

    THtmlElement &e = insertNewElement(parent, 0);
    e.tag = parser.at(1).tag;
    e.attributes = parser.at(1).attributes;
    e.text = parser.at(1).text;
    e.selfCloseMark = parser.at(1).selfCloseMark;
    e.tagClosed = parser.at(1).tagClosed;
    int idx = lastIndex();
    for (int i = 0; i < parser.at(1).children.count(); ++i) {
        prepend(idx, parser.mid(parser.at(1).children[i]));
    }
}
THtmlElement &THtmlParser::appendNewElement(int parent)
{
    return insertNewElement(parent, -1);
}