2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
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
|
|
|
|
|
|
|
|
2013-10-02 20:38:45 +02:00
|
|
|
Area::Area(const Building *const _building, const string &_name,
|
2010-03-05 17:24:18 +01:00
|
|
|
const Point3D &p1, const Point3D &p2):
|
2013-10-02 20:38:45 +02:00
|
|
|
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
|
|
|
/**
|
2013-05-30 21:23:05 +02:00
|
|
|
* @returns `true` if `p` is into the Area.
|
|
|
|
* @returns `false` if `p` is not into the Area.
|
2010-01-16 12:23:07 +01:00
|
|
|
*/
|
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 ;
|
|
|
|
}
|