2012-02-06 16:44:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
2012-11-03 14:52:33 +01:00
|
|
|
* OwlPS is a project of the University of Franche-Comte
|
2012-02-06 16:44:09 +01:00
|
|
|
* (Université de Franche-Comté), France.
|
2012-11-03 14:52:33 +01:00
|
|
|
*
|
|
|
|
* Copyright © Université de Franche-Comté 2007-2012.
|
|
|
|
*
|
|
|
|
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*
|
|
|
|
* This software is governed by the CeCILL license under French law and
|
|
|
|
* abiding by the rules of distribution of free software. You can use,
|
|
|
|
* modify and/or redistribute the software under the terms of the CeCILL
|
|
|
|
* license as circulated by CEA, CNRS and INRIA at the following URL:
|
|
|
|
* http://www.cecill.info
|
|
|
|
*
|
|
|
|
* As a counterpart to the access to the source code and rights to copy,
|
|
|
|
* modify and redistribute granted by the license, users are provided
|
|
|
|
* only with a limited warranty and the software's authors, the holder
|
|
|
|
* of the economic rights, and the successive licensors have only
|
|
|
|
* limited liability.
|
|
|
|
*
|
|
|
|
* In this respect, the user's attention is drawn to the risks
|
|
|
|
* associated with loading, using, modifying and/or developing or
|
|
|
|
* reproducing the software by the user in light of its specific status
|
|
|
|
* of free software, that may mean that it is complicated to manipulate,
|
|
|
|
* and that also therefore means that it is reserved for developers and
|
|
|
|
* experienced professionals having in-depth computer knowledge. Users
|
|
|
|
* are therefore encouraged to load and test the software's suitability
|
|
|
|
* as regards their requirements in conditions enabling the security of
|
|
|
|
* their systems and/or data to be ensured and, more generally, to use
|
|
|
|
* and operate it in the same conditions as regards security.
|
|
|
|
*
|
|
|
|
* The fact that you are presently reading this means that you have had
|
|
|
|
* knowledge of the CeCILL license and that you accept its terms.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-04-11 10:11:29 +02:00
|
|
|
#include "area.hh"
|
2010-04-02 10:56:52 +02:00
|
|
|
#include "building.hh"
|
2008-04-11 10:11:29 +02:00
|
|
|
|
|
|
|
|
2010-01-04 17:10:42 +01:00
|
|
|
using namespace std ;
|
|
|
|
|
2008-05-29 10:48:05 +02:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
|
|
|
|
/* *** Constructors *** */
|
2009-12-07 16:03:53 +01:00
|
|
|
|
|
|
|
|
2009-12-11 17:56:31 +01:00
|
|
|
Area::Area(const Building *_building, const string &_name,
|
2010-03-05 17:24:18 +01:00
|
|
|
const Point3D &p1, const Point3D &p2):
|
|
|
|
building(const_cast<Building*>(_building)), name(_name)
|
2008-04-11 10:11:29 +02:00
|
|
|
{
|
2010-02-04 18:46:23 +01:00
|
|
|
set_coordinates(p1, p2) ;
|
2008-04-11 10:11:29 +02:00
|
|
|
}
|
|
|
|
|
2008-05-29 10:48:05 +02:00
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operations *** */
|
2009-12-07 16:03:53 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* @return \em true if \em p is into the Area.
|
|
|
|
* @return \em false if \em p is not into the Area.
|
|
|
|
*/
|
2009-12-07 16:03:53 +01:00
|
|
|
bool Area::contains_point(const Point3D &p) const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
p.get_x() >= p_min.get_x() &&
|
|
|
|
p.get_x() <= p_max.get_x() &&
|
|
|
|
p.get_y() >= p_min.get_y() &&
|
|
|
|
p.get_y() <= p_max.get_y() &&
|
|
|
|
p.get_z() >= p_min.get_z() &&
|
|
|
|
p.get_z() <= p_max.get_z() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-04 18:46:23 +01:00
|
|
|
/**
|
|
|
|
* Changes the Area coordinates so that #p_min is the South-West-lower
|
|
|
|
* point and #p_max the North-East-higher point.
|
|
|
|
*/
|
|
|
|
void Area::reorder_coordinates()
|
|
|
|
{
|
|
|
|
float
|
|
|
|
x1 = p_min.get_x(),
|
|
|
|
y1 = p_min.get_y(),
|
|
|
|
z1 = p_min.get_z(),
|
|
|
|
x2 = p_max.get_x(),
|
|
|
|
y2 = p_max.get_y(),
|
|
|
|
z2 = p_max.get_z(),
|
|
|
|
x_min, x_max, y_min,
|
|
|
|
y_max, z_min, z_max ;
|
|
|
|
|
|
|
|
// 2-D coordinates (X and Y) //
|
|
|
|
|
|
|
|
// First point is North-West
|
|
|
|
if (x1 < x2 && y1 > y2)
|
|
|
|
{
|
|
|
|
x_min = x1 ;
|
|
|
|
x_max = x2 ;
|
|
|
|
y_min = y2 ; // We swap the two Y
|
|
|
|
y_max = y1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First point is South-East
|
|
|
|
else if (x1 > x2 && y1 < y2)
|
|
|
|
{
|
|
|
|
x_min = x2 ; // We swap the two X
|
|
|
|
x_max = x1 ;
|
|
|
|
y_min = y1 ;
|
|
|
|
y_max = y2 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First point is North-East
|
|
|
|
else if (x1 > x2 && y1 > y2)
|
|
|
|
{
|
|
|
|
x_min = x2 ; // We swap the two X
|
|
|
|
x_max = x1 ;
|
|
|
|
y_min = y2 ; // and we swap the two Y
|
|
|
|
y_max = y1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First point is South-West
|
2011-05-04 19:20:46 +02:00
|
|
|
// (or other cases such as coordinates equal to zero)
|
2010-02-04 18:46:23 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// We swap nothing
|
|
|
|
x_min = x1 ;
|
|
|
|
x_max = x2 ;
|
|
|
|
y_min = y1 ;
|
|
|
|
y_max = y2 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Vertical coordinate (Z) //
|
|
|
|
|
|
|
|
// First point is lower
|
|
|
|
if (z1 < z2)
|
|
|
|
{
|
|
|
|
z_min = z1 ;
|
|
|
|
z_max = z2 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First point is higher
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We swap the two Z
|
|
|
|
z_min = z2 ;
|
|
|
|
z_max = z1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_min = Point3D(x_min, y_min, z_min) ;
|
|
|
|
p_max = Point3D(x_max, y_max, z_max) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operators *** */
|
2010-01-05 11:50:24 +01:00
|
|
|
|
|
|
|
|
2011-07-30 20:38:42 +02:00
|
|
|
Area& Area::operator=(const Area &source)
|
2010-01-18 14:19:57 +01:00
|
|
|
{
|
2010-03-05 17:24:18 +01:00
|
|
|
if (this == &source)
|
2010-01-18 14:19:57 +01:00
|
|
|
return *this ;
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
building = source.building ;
|
|
|
|
name = source.name ;
|
|
|
|
p_min = source.p_min ;
|
|
|
|
p_max = source.p_max ;
|
2010-01-18 14:19:57 +01:00
|
|
|
|
|
|
|
return *this ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
bool Area::operator==(const Area &source) const
|
2009-12-07 16:03:53 +01:00
|
|
|
{
|
2010-03-05 17:24:18 +01:00
|
|
|
if (this == &source)
|
2010-05-21 10:35:15 +02:00
|
|
|
return true ;
|
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
return
|
2010-03-05 17:24:18 +01:00
|
|
|
building == source.building &&
|
|
|
|
name == source.name &&
|
|
|
|
p_min == source.p_min &&
|
|
|
|
p_max == source.p_max ;
|
2009-12-07 16:03:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
GuiNuMo : gestion topologie
server.{hh,cc} :
* Utilisation d'une map plutôt que d'une multimap pour stocker la liste
des pièces. Conséquence : les noms des zones doivent être uniques, il
faut donc numéroter les zones des pièces composites (par exemple
« Couloir N1 A » et « Couloir N1 B »).
* Ajout de la fonction inWhichAreas() qui permet d'obtenir la liste des
zones auxquelles appartient un point.
* Modification de la fonction makeWaypointDistancesFromFile() (renommée
makeWaypointListFromFile()) de manière à ce qu'elle calcule la matrice
des distances entre points de passage (lecture d'une liste de points).
Abandon du format décrivant les points en visibilité (voir le fichier
cfg/distances.csv, supprimé à cette révision), puisque nous nous
servons des points de passage et de la description des zones pour
calculer les liens entre points. RESTE À FAIRE : prise en comppte de
la topologie dans le calcul de distance.
* Ajout de deux fonctions areaConnection() qui permettent de récupérer
la liste des points de passage d'une zone, ou faisant l'intersection
entre deux zones.
* Ajout de la fonction distanceTopology, qui calcule la distance entre
deux points en tenant compte de la topologie (zones et points de
passage entre elles).
* Ajout de la fonction makeReferencePointDistances(), qui calcule les
distances entre points de référence, en tenant compte de la
topologie.
* Ajout de la fonction point_vector_idx(), semblable à point_tab_idx()
mais pour un vector<Point>.
referencepoint.{hh,cc} :
* Ajout de l'operator de cast en Point (operator Point()).
area.{hh,cc} :
* Ajout de l'operator==(Area).
cfg/distances.csv
* Suppression de ce fichier obsolète.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@47 785a6c6c-259e-4ff1-8b91-dc31627914f0
2008-06-25 16:19:07 +02:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* Note: to avoid looping, the Building associated with the Area is
|
|
|
|
* not displayed.
|
|
|
|
*/
|
2008-05-29 10:48:05 +02:00
|
|
|
ostream &operator<<(ostream &os, const Area &a)
|
|
|
|
{
|
2010-04-02 10:56:52 +02:00
|
|
|
os
|
|
|
|
<< (a.building ? a.building->get_name() : "No building") << ';'
|
|
|
|
<< a.name << ';'
|
|
|
|
<< a.p_min.get_x() << ';'
|
|
|
|
<< a.p_max.get_x() << ';'
|
|
|
|
<< a.p_min.get_y() << ';'
|
|
|
|
<< a.p_max.get_y() << ';'
|
|
|
|
<< a.p_min.get_z() << ';'
|
|
|
|
<< a.p_max.get_z() ;
|
2008-05-29 10:48:05 +02:00
|
|
|
return os ;
|
|
|
|
}
|