forked from pazdera/libcity
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored Zone and Block. Created base class for areas in libcity "A…
…rea". New class -- Lot. Fixed unit tests, everything up and running.
- Loading branch information
Showing
16 changed files
with
287 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* This code is part of libcity library. | ||
* | ||
* @file area/area.cpp | ||
* @date 26.04.2011 | ||
* @author Radek Pazdera ([email protected]) | ||
* | ||
* @see lot.h | ||
* | ||
*/ | ||
|
||
#include "area.h" | ||
|
||
#include "../debug.h" | ||
#include "../geometry/units.h" | ||
#include "../geometry/point.h" | ||
#include "../geometry/polygon.h" | ||
#include "../geometry/vector.h" | ||
|
||
Area::Area() | ||
{ | ||
initialize(); | ||
} | ||
|
||
Area::Area(Area const& source) | ||
{ | ||
initialize(); | ||
|
||
*constraints = *(source.constraints); | ||
parentArea = source.parentArea; | ||
} | ||
|
||
void Area::initialize() | ||
{ | ||
parentArea = 0; | ||
constraints = new Polygon(); | ||
} | ||
|
||
Area& Area::operator=(Area const& source) | ||
{ | ||
*constraints = *(source.constraints); | ||
parentArea = source.parentArea; | ||
|
||
return *this; | ||
} | ||
|
||
Area::~Area() | ||
{ | ||
freeMemory(); | ||
} | ||
|
||
void Area::freeMemory() | ||
{ | ||
delete constraints; | ||
} | ||
|
||
Polygon Area::areaConstraints() | ||
{ | ||
return *constraints; | ||
} | ||
|
||
void Area::setAreaConstraints(Polygon const& area) | ||
{ | ||
*constraints = area; | ||
} | ||
|
||
void Area::setParent(Area* area) | ||
{ | ||
parentArea = area; | ||
} | ||
|
||
Area* Area::parent() | ||
{ | ||
return parentArea; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* This code is part of libcity library. | ||
* | ||
* @file area/area.h | ||
* @date 26.04.2011 | ||
* @author Radek Pazdera ([email protected]) | ||
* | ||
* @brief Base class for city areas (zones, districts, blocks, alottments). | ||
* | ||
*/ | ||
|
||
#ifndef _AREA_H_ | ||
#define _AREA_H_ | ||
|
||
/* STL */ | ||
#include <vector> | ||
#include <list> | ||
#include <map> | ||
|
||
class Polygon; | ||
class StreetGraph; | ||
class RoadLSystem; | ||
class Intersection; | ||
class Block; | ||
|
||
class Area; | ||
class Area | ||
{ | ||
public: | ||
Area(); | ||
virtual ~Area(); | ||
|
||
Area(Area const& source); | ||
Area& operator=(Area const& source); | ||
|
||
virtual void setAreaConstraints(Polygon const& area); | ||
virtual Polygon areaConstraints(); | ||
|
||
virtual void setParent(Area* area); | ||
virtual Area* parent(); | ||
|
||
protected: | ||
Polygon* constraints; | ||
Area* parentArea; | ||
|
||
private: | ||
void initialize(); | ||
void freeMemory(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* This code is part of libcity library. | ||
* | ||
* @file buildings/block.cpp | ||
* @file area/block.cpp | ||
* @date 25.04.2011 | ||
* @author Radek Pazdera ([email protected]) | ||
* | ||
|
@@ -16,7 +16,8 @@ | |
#include "../geometry/point.h" | ||
#include "../geometry/polygon.h" | ||
#include "../geometry/vector.h" | ||
#include "../streetgraph/zone.h" | ||
#include "zone.h" | ||
#include "lot.h" | ||
|
||
Block::Block() | ||
{ | ||
|
@@ -26,65 +27,40 @@ Block::Block() | |
Block::Block(Zone* parentZone) | ||
{ | ||
initialize(); | ||
associatedZone = parentZone; | ||
setParent(parentZone); | ||
} | ||
|
||
Block::Block(Zone* parentZone, Polygon const& border) | ||
{ | ||
initialize(); | ||
associatedZone = parentZone; | ||
*constraints = border; | ||
setParent(parentZone); | ||
setAreaConstraints(border); | ||
} | ||
|
||
Block::Block(Block const& source) | ||
: Area(source) | ||
{ | ||
initialize(); | ||
|
||
associatedZone = source.associatedZone; | ||
*constraints = *(source.constraints); | ||
} | ||
|
||
void Block::initialize() | ||
{ | ||
constraints = new Polygon(); | ||
lots.clear(); | ||
} | ||
|
||
Block& Block::operator=(Block const& source) | ||
{ | ||
reset(); | ||
|
||
associatedZone = source.associatedZone; | ||
*constraints = *(source.constraints); | ||
Area::operator=(source); | ||
|
||
return *this; | ||
} | ||
|
||
void Block::reset() | ||
{ | ||
constraints->clear(); | ||
} | ||
|
||
Block::~Block() | ||
{ | ||
freeMemory(); | ||
} | ||
|
||
void Block::freeMemory() | ||
{ | ||
delete constraints; | ||
lots.clear(); | ||
} | ||
|
||
Polygon Block::areaConstraints() | ||
{ | ||
return *constraints; | ||
} | ||
|
||
void Block::setAreaConstraints(Polygon const& area) | ||
{ | ||
*constraints = area; | ||
} | ||
|
||
void Block::setZone(Zone* zone) | ||
{ | ||
associatedZone = zone; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* This code is part of libcity library. | ||
* | ||
* @file buildings/block.h | ||
* @file area/block.h | ||
* @date 25.04.2011 | ||
* @author Radek Pazdera ([email protected]) | ||
* | ||
|
@@ -12,15 +12,20 @@ | |
#ifndef _BLOCK_H_ | ||
#define _BLOCK_H_ | ||
|
||
/* STL */ | ||
#include <string> | ||
|
||
/* libcity */ | ||
#include "area.h" | ||
|
||
class LineSegment; | ||
class Point; | ||
class Vector; | ||
class Polygon; | ||
class Zone; | ||
class Lot; | ||
|
||
class Block | ||
class Block : public Area | ||
{ | ||
public: | ||
Block(); | ||
|
@@ -32,17 +37,11 @@ class Block | |
|
||
~Block(); | ||
|
||
Polygon areaConstraints(); | ||
void setAreaConstraints(Polygon const& area); | ||
|
||
void setZone(Zone* zone); | ||
private: | ||
std::list<Lot*> lots; | ||
|
||
void initialize(); | ||
void reset(); | ||
void freeMemory(); | ||
|
||
Polygon* constraints; | ||
Zone* associatedZone; | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* This code is part of libcity library. | ||
* | ||
* @file area/lot.cpp | ||
* @date 26.04.2011 | ||
* @author Radek Pazdera ([email protected]) | ||
* | ||
* @see lot.h | ||
* | ||
*/ | ||
|
||
#include "lot.h" | ||
|
||
#include "../debug.h" | ||
#include "../geometry/units.h" | ||
#include "../geometry/point.h" | ||
#include "../geometry/polygon.h" | ||
#include "../geometry/vector.h" | ||
#include "block.h" | ||
|
||
Lot::Lot() | ||
{ | ||
initialize(); | ||
} | ||
|
||
Lot::Lot(Block* parentBlock) | ||
{ | ||
initialize(); | ||
setParent(parentBlock); | ||
} | ||
|
||
Lot::Lot(Lot const& source) | ||
: Area(source) | ||
{ | ||
initialize(); | ||
} | ||
|
||
void Lot::initialize() | ||
{ | ||
} | ||
|
||
Lot& Lot::operator=(Lot const& source) | ||
{ | ||
Area::operator=(source); | ||
|
||
return *this; | ||
} | ||
|
||
Lot::~Lot() | ||
{ | ||
freeMemory(); | ||
} | ||
|
||
void Lot::freeMemory() | ||
{ | ||
} |
Oops, something went wrong.