void FloorScene::loadFloorPlan() {
    this->clear();

    FloorVertex* floorplan = mesh->getFloorPlan();
    unsigned int floorPlanSize = mesh->getFloorPlanSize();
    float x(0.0f);
    float y(0.0f);
    Vertex* currentVertex = floorplan;

    // go through the vertices of the floor plan, create and draw their ellipse
    for (unsigned int i(0); i < floorPlanSize; ++i) {
        x = currentVertex->getX();
        y = currentVertex->getY();

        QRectF thisSize = this->sceneRect();
        Utils::adjustCoordinates3DToScene(x, y, thisSize.width(), thisSize.height());
        if(currentVertex->getEllipse() == 0){
            currentVertex->setEllipse(new QGraphicsEllipseItem(x - vertexRadius, y - vertexRadius, vertexRadius * 2.0f, vertexRadius * 2.0f));
            this->addItem(currentVertex->getEllipse());
        } else {
            std::cerr << "something strange happen, try to reload an already loaded floorplan maybe is ok and i shouldn't do anything";
        }

        currentVertex = currentVertex->getNeighbor2();
    }

    // go through the vertices of the floor plan, create and draw their edges
    currentVertex = floorplan;
    for (unsigned int i(0); i < floorPlanSize; ++i) {
        if(currentVertex->addEdge1()){
            this->addItem(currentVertex->getEdge1());
        }
        if(currentVertex->addEdge2()){
           this->addItem(currentVertex->getEdge2());
        }
        currentVertex = currentVertex->getNeighbor2();
    }

    // tell the mesh to generate new point/triangle
    mesh->setUpdateOnMesh();
}
void ProfileScene::loadProfile()
{

    if (currentProfile != 0) {

        Vertex* currentVertex = currentProfile->getProfileVertex();

        while(currentVertex != 0){
            this->removeItem(currentVertex->getEllipse());
            if (currentVertex->getNeighbor2() != 0) {
                this->removeItem(currentVertex->getEdge2());
            }

            currentVertex = currentVertex->getNeighbor2();
        }
    }


    currentProfile = mesh->getCurrentProfile();

    Vertex* currentVertex = currentProfile->getProfileVertex();

    float x(0.0f);
    float y(0.0f);
    while(currentVertex != 0)
    {
        if(currentVertex->getEllipse() == 0){
            x = currentVertex->getX();
            y = currentVertex->getY();
            QRectF thisSize = this->sceneRect();
            Utils::adjustCoordinates3DToScene(x, y, thisSize.width(), thisSize.height());

            currentVertex->setEllipse(new QGraphicsEllipseItem(x - vertexRadius, y - vertexRadius, vertexRadius * 2.0f, vertexRadius * 2.0f));
            this->addItem(currentVertex->getEllipse());

        }else {
            this->addItem(currentVertex->getEllipse());
            if (currentVertex->getNeighbor2() != 0) {
                this->addItem(currentVertex->getEdge2());
            }
        }
        currentVertex = currentVertex->getNeighbor2();
    }


    currentVertex = currentProfile->getProfileVertex();

    while(currentVertex->getNeighbor2() != 0)
    {
        if(currentVertex->addEdge2()){
            currentVertex->getNeighbor2()->setEdge1(currentVertex->getEdge2());
            this->addItem(currentVertex->getEdge2());
        }
        currentVertex = currentVertex->getNeighbor2();
    }

    // now we can delete the old profiles from the previous mesh
    // take the old profiles
    ProfileDestructorManager::swap();
    // destroy them
    ProfileDestructorManager::deleteProfiles();
    // take again the current profiles
    ProfileDestructorManager::swap();
}