Hline.cpp 3.05 KB
Newer Older
1
/**
Weichen's avatar
Weichen committed
2 3
 * \file        Hline.cpp
 * \date        Aug 1, 2012
4 5
 * \version     v0.7
 * \copyright   <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
6
 *
Weichen's avatar
Weichen committed
7
 * \section License
8 9 10
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
Weichen's avatar
Weichen committed
11
 * it under the terms of the GNU Lesser General Public License as published by
12 13 14 15 16 17 18 19
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * JuPedSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
Weichen's avatar
Weichen committed
20
 * You should have received a copy of the GNU Lesser General Public License
21 22
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
 *
Weichen's avatar
Weichen committed
23
 * \section Description
24 25
 *
 *
Weichen's avatar
Weichen committed
26
 **/
27

28

29
#include "Hline.h"
Ulrich Kemloh's avatar
Ulrich Kemloh committed
30
#include "SubRoom.h"
31

32 33
using namespace std;

34 35 36
Hline::Hline()
{
     _id=-1;
37 38
}

39 40
Hline::~Hline()
{
41 42
}

43 44 45
void Hline::SetID(int ID)
{
     _id=ID;
46 47
}

48
void Hline::SetRoom1(Room* r)
49
{
50
     _room1=r;
51 52
}

53 54 55
void Hline::SetCaption(string s)
{
     _caption=s;
56 57
}

58
void Hline::SetSubRoom1(SubRoom* s)
59
{
60
     _subRoom1=s;
61 62
}

63 64 65
int Hline::GetID() const
{
     return _id;
66 67
}

68 69 70
string Hline::GetCaption() const
{
     return _caption;
71 72
}

73
Room* Hline::GetRoom1() const
74
{
75
     return _room1;
76 77
}

78
SubRoom* Hline::GetSubRoom1() const
79
{
80
     return _subRoom1;
81 82
}

83 84 85 86 87 88 89 90 91 92 93
void Hline::SetSubRoom2(SubRoom* r2)
{
     _subRoom2 = r2;
}


SubRoom* Hline::GetSubRoom2() const
{
     return _subRoom2;
}

94 95
bool Hline::IsInSubRoom(int subroomID) const
{
96
     return _subRoom1->GetSubRoomID() == subroomID;
97 98
}

99 100
bool Hline::IsInRoom(int roomID) const
{
101
     return _room1->GetID() == roomID;
102 103
}

104 105 106 107 108 109 110
void Hline::WriteToErrorLog() const
{
     string s;
     char tmp[CLENGTH];
     sprintf(tmp, "\t\tHline: %d (%f, %f) -- (%f, %f)\n", GetID(), GetPoint1().GetX(),
             GetPoint1().GetY(), GetPoint2().GetX(), GetPoint2().GetY());
     s.append(tmp);
111 112
     sprintf(tmp, "\t\t\t\tRoom: %d <-> SubRoom: %d\n", _room1->GetID(),
             _subRoom1->GetSubRoomID());
113 114
     s.append(tmp);
     Log->Write(s);
115 116 117
}

// TraVisTo Ausgabe
118
string Hline::GetDescription() const
119 120 121
{
     string geometry;
     char tmp[CLENGTH] = "";
122
     sprintf(tmp,"\t\t<hline ID=\"%d\" room_id=\"%d\" subroom_id=\"%d\" color = \"250\" caption=\"h_%d_%d\">\n",GetUniqueID(),_room1->GetID(),_subRoom1->GetSubRoomID(),GetID(),GetUniqueID());
123 124 125 126 127
     geometry.append(tmp);
     //geometry.append("\t\t<door color=\"250\">\n");
     sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
             (GetPoint1().GetX()) * FAKTOR,
             (GetPoint1().GetY()) * FAKTOR,
128
             _subRoom1->GetElevation(GetPoint1())*FAKTOR);
129 130 131 132
     geometry.append(tmp);
     sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
             (GetPoint2().GetX()) * FAKTOR,
             (GetPoint2().GetY()) * FAKTOR,
133
             _subRoom1->GetElevation(GetPoint2())*FAKTOR);
134
     geometry.append(tmp);
Ulrich Kemloh's avatar
Ulrich Kemloh committed
135
     geometry.append("\t\t</hline>\n");
136
     return geometry;
137
}