class MeshLoader
!!!260016.cpp!!!	MeshLoader()
    addAlias(&tetrahedra,"tetras");
    addAlias(&hexahedra,"hexas");
    //TODO: check if necessary!
    positions.setPersistent(false);
    edges.setPersistent(false);
    triangles.setPersistent(false);
    quads.setPersistent(false);
    polygons.setPersistent(false);
    tetrahedra.setPersistent(false);
    hexahedra.setPersistent(false);
    normals.setPersistent(false);
!!!260144.cpp!!!	canLoad() : bool
    std::string cmd;

    // -- Check filename field:
    if(m_filename.getValue() == "")
    {
      serr << "Error: MeshLoader: No file name given." << sendl;
      return false;
    }

	  
    // -- Check if file exist:
    const char* filename = m_filename.getFullPath().c_str();
    std::string sfilename (filename);

    if (!sofa::helper::system::DataRepository.findFile(sfilename))
    {
      serr << "Error: MeshLoader: File '" << m_filename << "' not found. " << sendl;
      return false;
    }

    std::ifstream file(filename);
    
    // -- Check if file is readable:
    if (!file.good())
    {
      serr << "Error: MeshLoader: Cannot read file '" << m_filename << "'." << sendl;
      return false;
    }
    
    // -- Step 2.2: Check first line.
    file >> cmd;
    if (cmd.empty())
    {
      serr << "Error: MeshLoader: Cannot read first line in file '" << m_filename << "'." << sendl;
      file.close();
      return false;
    }

    file.close();
    return true;
!!!260272.cpp!!!	parse(inout arg : BaseObjectDescription) : void
    BaseLoader::parse(arg);

    if (canLoad())
      load(/*m_filename.getFullPath().c_str()*/);
    else
      sout << "Doing nothing" << sendl;

    updateMesh();

    if (translation.getValue() != Vector3(0.0,0.0,0.0))
        this->applyTranslation(translation.getValue()[0], translation.getValue()[1], translation.getValue()[2]);
    if (rotation.getValue() != Vector3(0.0,0.0,0.0))
        this->applyRotation(rotation.getValue()[0], rotation.getValue()[1], rotation.getValue()[2]);
    if (scale.getValue() != Vector3(1.0,1.0,1.0))
        this->applyScale(scale.getValue()[0],scale.getValue()[1],scale.getValue()[2]);
!!!260400.cpp!!!	reinit() : void
    if (translation.getValue() != Vector3(0.0,0.0,0.0))
        this->applyTranslation(translation.getValue()[0], translation.getValue()[1], translation.getValue()[2]);
    if (rotation.getValue() != Vector3(0.0,0.0,0.0))
        this->applyRotation(rotation.getValue()[0], rotation.getValue()[1], rotation.getValue()[2]);
    if (scale.getValue() != Vector3(1.0,1.0,1.0))
        this->applyScale(scale.getValue()[0],scale.getValue()[1],scale.getValue()[2]);
!!!260528.cpp!!!	applyTranslation(in dx : SReal, in dy : SReal, in dz : SReal) : void
      sofa::helper::WriteAccessor <Data< helper::vector<sofa::defaulttype::Vec<3,SReal> > > > my_positions = positions;
      for (unsigned int i = 0; i < my_positions.size(); i++)
          my_positions[i] += Vector3(dx,dy,dz);
!!!260656.cpp!!!	applyRotation(in rx : SReal, in ry : SReal, in rz : SReal) : void
      Quaternion q = helper::Quater< SReal >::createQuaterFromEuler(Vec< 3, SReal >(rx, ry, rz) * M_PI / 180.0);
      applyRotation(q);
!!!260784.cpp!!!	applyRotation(in q : defaulttype::Quat) : void
      sofa::helper::WriteAccessor <Data< helper::vector<sofa::defaulttype::Vec<3,SReal> > > > my_positions = positions;
      for (unsigned int i = 0; i < my_positions.size(); i++)
      {
          Vec<3,SReal> newposition = q.rotate(my_positions[i]);
          my_positions[i] = newposition;
      }
!!!260912.cpp!!!	applyScale(in sx : SReal, in sy : SReal, in sz : SReal) : void
      sofa::helper::WriteAccessor <Data< helper::vector<sofa::defaulttype::Vec<3,SReal> > > > my_positions = positions;
      for (unsigned int i = 0; i < my_positions.size(); i++)
      {
          my_positions[i][0] *= sx;
          my_positions[i][1] *= sy;
          my_positions[i][2] *= sz;
      }
!!!261808.cpp!!!	updateMesh() : void
    updateElements();
    updatePoints();
    updateNormals();
!!!261936.cpp!!!	updateElements() : void
    if (triangulate.getValue())
    {
        helper::WriteAccessor<Data<helper::vector< helper::fixed_array <unsigned int,4> > > > waQuads = quads;
        helper::WriteAccessor<Data<helper::vector< helper::fixed_array <unsigned int,3> > > > waTriangles = triangles;

        for (unsigned int i = 0; i < waQuads.size() ; i++)
        {
            const helper::fixed_array <unsigned int,4>& q = waQuads[i];
            addTriangle(&waTriangles.wref(), q[0], q[1], q[2]);
            addTriangle(&waTriangles.wref(), q[0], q[2], q[3]);
        }
        waQuads.clear();
    }
!!!262064.cpp!!!	updatePoints() : void
    if (onlyAttachedPoints.getValue())
    {
        std::set<unsigned int> attachedPoints;
        {
            helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,2> > > > elems = edges;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                attachedPoints.insert(elems[i][j]);
        }
        {
            helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,3> > > > elems = triangles;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                attachedPoints.insert(elems[i][j]);
        }
        {
            helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,4> > > > elems = quads;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                attachedPoints.insert(elems[i][j]);
        }
        {
            helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,4> > > > elems = tetrahedra;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                attachedPoints.insert(elems[i][j]);
        }
        {
            helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,8> > > > elems = hexahedra;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                attachedPoints.insert(elems[i][j]);
        }
        const unsigned int newsize = attachedPoints.size();
        if (newsize == positions.getValue().size()) return; // all points are attached
        helper::WriteAccessor<Data<helper::vector<sofa::defaulttype::Vec<3,SReal> > > > waPositions = positions;
        helper::vector<unsigned int> old2new;
        old2new.resize(waPositions.size());
        unsigned int p = 0;
        for (std::set<unsigned int>::const_iterator it = attachedPoints.begin(), itend = attachedPoints.end(); it != itend; ++it)
        {
            unsigned int newp = *it;
            old2new[newp] = p;
            if (p != newp) waPositions[p] = waPositions[newp];
            ++p;
        }
        waPositions.resize(newsize);
        {
            helper::WriteAccessor<Data< helper::vector< helper::fixed_array <unsigned int,2> > > > elems = edges;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                elems[i][j] = old2new[elems[i][j]];
        }
        {
            helper::WriteAccessor<Data< helper::vector< helper::fixed_array <unsigned int,3> > > > elems = triangles;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                elems[i][j] = old2new[elems[i][j]];
        }
        {
            helper::WriteAccessor<Data< helper::vector< helper::fixed_array <unsigned int,4> > > > elems = quads;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                elems[i][j] = old2new[elems[i][j]];
        }
        {
            helper::WriteAccessor<Data< helper::vector< helper::fixed_array <unsigned int,4> > > > elems = tetrahedra;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                elems[i][j] = old2new[elems[i][j]];
        }
        {
            helper::WriteAccessor<Data< helper::vector< helper::fixed_array <unsigned int,8> > > > elems = hexahedra;
        for (unsigned int i=0;i<elems.size();++i)
            for (unsigned int j=0;j<elems[i].size();++j)
                elems[i][j] = old2new[elems[i][j]];
        }
    }
!!!262192.cpp!!!	updateNormals() : void
    helper::ReadAccessor<Data<helper::vector<sofa::defaulttype::Vec<3,SReal> > > > raPositions = positions;
    helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,3> > > > raTriangles = triangles;
    helper::ReadAccessor<Data< helper::vector< helper::fixed_array <unsigned int,4> > > > raQuads = quads;

    //look if we already have loaded normals
    if (normals.getValue().size() == raPositions.size())
        return;

    helper::WriteAccessor<Data<helper::vector<sofa::defaulttype::Vec<3,SReal> > > > waNormals = normals;

	  waNormals.resize(raPositions.size());

      for (unsigned int i = 0; i < raTriangles.size() ; i++)
      {
    	  const sofa::defaulttype::Vec<3,SReal>  v1 = raPositions[raTriangles[i][0]];
    	  const sofa::defaulttype::Vec<3,SReal>  v2 = raPositions[raTriangles[i][1]];
    	  const sofa::defaulttype::Vec<3,SReal>  v3 = raPositions[raTriangles[i][2]];
    	  sofa::defaulttype::Vec<3,SReal> n = cross(v2-v1, v3-v1);

          n.normalize();
          waNormals[raTriangles[i][0]] += n;
          waNormals[raTriangles[i][1]] += n;
          waNormals[raTriangles[i][2]] += n;

      }
      for (unsigned int i = 0; i < raQuads.size() ; i++)
      {
          const sofa::defaulttype::Vec<3,SReal> & v1 = raPositions[raQuads[i][0]];
          const sofa::defaulttype::Vec<3,SReal> & v2 = raPositions[raQuads[i][1]];
          const sofa::defaulttype::Vec<3,SReal> & v3 = raPositions[raQuads[i][2]];
          const sofa::defaulttype::Vec<3,SReal> & v4 = raPositions[raQuads[i][3]];
          sofa::defaulttype::Vec<3,SReal> n1 = cross(v2-v1, v4-v1);
		  sofa::defaulttype::Vec<3,SReal> n2 = cross(v3-v2, v1-v2);
		  sofa::defaulttype::Vec<3,SReal> n3 = cross(v4-v3, v2-v3);
		  sofa::defaulttype::Vec<3,SReal> n4 = cross(v1-v4, v3-v4);
          n1.normalize(); n2.normalize(); n3.normalize(); n4.normalize();
          waNormals[raQuads[i][0]] += n1;
          waNormals[raQuads[i][1]] += n2;
          waNormals[raQuads[i][2]] += n3;
          waNormals[raQuads[i][3]] += n4;
      }

	  for (unsigned int i = 0; i < waNormals.size(); i++)
	  {
		  waNormals[i].normalize();
	  }
!!!262320.cpp!!!	addPosition(inout pPositions : helper::vector<sofa::defaulttype::Vec<3,SReal> >, in p : sofa::defaulttype::Vec<3,SReal>) : void
	  pPositions->push_back(p);
!!!262448.cpp!!!	addPosition(inout pPositions : helper::vector<sofa::defaulttype::Vec<3,SReal> >, in x : SReal, in y : SReal, in z : SReal) : void
	  addPosition(pPositions, sofa::defaulttype::Vec<3,SReal>(x, y, z));
!!!262576.cpp!!!	addEdge(inout pEdges : helper::vector<helper::fixed_array <unsigned int,2> >, in p : helper::fixed_array<unsigned int,2>) : void
	  pEdges->push_back(p);
!!!262704.cpp!!!	addEdge(inout pEdges : helper::vector<helper::fixed_array <unsigned int,2> >, in p0 : uint, in p1 : uint) : void
	  addEdge(pEdges, helper::fixed_array <unsigned int,2>(p0, p1));
!!!262832.cpp!!!	addTriangle(inout pTriangles : helper::vector<helper::fixed_array <unsigned int,3> >, in p : helper::fixed_array<unsigned int,3>) : void
	  if (flipNormals.getValue())
	  {
		  helper::fixed_array <unsigned int,3> revertP;
		  std::reverse_copy(p.begin(), p.end(), revertP.begin());

		  pTriangles->push_back(revertP);
	  }
	  else
		  pTriangles->push_back(p);
!!!262960.cpp!!!	addTriangle(inout pTriangles : helper::vector<helper::fixed_array <unsigned int,3> >, in p0 : uint, in p1 : uint, in p2 : uint) : void
	  addTriangle(pTriangles, helper::fixed_array <unsigned int,3>(p0, p1, p2));
!!!263088.cpp!!!	addQuad(inout pQuads : helper::vector<helper::fixed_array <unsigned int,4> >, in p : helper::fixed_array<unsigned int,4>) : void
	  if (flipNormals.getValue())
	  {
		  helper::fixed_array <unsigned int,4> revertP;
		  std::reverse_copy(p.begin(), p.end(), revertP.begin());

		  pQuads->push_back(revertP);
	  }
	  else
		  pQuads->push_back(p);
!!!263216.cpp!!!	addQuad(inout pQuads : helper::vector<helper::fixed_array <unsigned int,4> >, in p0 : uint, in p1 : uint, in p2 : uint, in p3 : uint) : void
	  addQuad(pQuads, helper::fixed_array <unsigned int,4>(p0, p1, p2, p3));
!!!263344.cpp!!!	addPolygon(inout pPolygons : helper::vector< helper::vector <unsigned int> >, in p : helper::vector<unsigned int>) : void
	  if (flipNormals.getValue())
	  {
		  helper::vector<unsigned int> revertP(p.size());
		  std::reverse_copy(p.begin(), p.end(), revertP.begin());

		  pPolygons->push_back(revertP);
	  }
	  else
		  pPolygons->push_back(p);
!!!263472.cpp!!!	addTetrahedron(inout pTetrahedra : helper::vector< helper::fixed_array<unsigned int,4> >, in p : helper::fixed_array<unsigned int,4>) : void
	  pTetrahedra->push_back(p);
!!!263600.cpp!!!	addTetrahedron(inout pTetrahedra : helper::vector< helper::fixed_array<unsigned int,4> >, in p0 : uint, in p1 : uint, in p2 : uint, in p3 : uint) : void
	  addTetrahedron(pTetrahedra, helper::fixed_array <unsigned int,4>(p0, p1, p2, p3));
!!!263728.cpp!!!	addHexahedron(inout pHexahedra : helper::vector< helper::fixed_array<unsigned int,8> >, in p : helper::fixed_array<unsigned int,8>) : void
	  pHexahedra->push_back(p);
!!!263856.cpp!!!	addHexahedron(inout pHexahedra : helper::vector< helper::fixed_array<unsigned int,8> >, in p0 : uint, in p1 : uint, in p2 : uint, in p3 : uint, in p4 : uint, in p5 : uint, in p6 : uint, in p7 : uint) : void
	  addHexahedron(pHexahedra, helper::fixed_array <unsigned int,8>(p0, p1, p2, p3, p4, p5, p6, p7));
