 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
31 const std::vector<double>& timeSpan,
32 const std::vector<double>& alphaSpan,
37 myLastUpdateTime(creationTime),
38 animated(!timeSpan.empty()),
40 tracking(trackedObject != nullptr),
42 myTrackedObject(trackedObject),
43 myTrackedObjectID(
""),
44 myTrackedObjectsInitialPositon(nullptr),
45 myTrackedObjectsInitialAngle(-1),
46 myOriginalShape(nullptr),
52 myTimeSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(timeSpan));
56 #ifdef DEBUG_DYNAMIC_SHAPES
58 for (
unsigned int i = 1; i <
myTimeSpan->size(); ++i) {
66 #ifdef DEBUG_DYNAMIC_SHAPES
80 if (!alphaSpan.empty()) {
81 myAlphaSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(alphaSpan));
95 #ifdef DEBUG_DYNAMIC_SHAPES
96 std::cout << t <<
" PolygonDynamics::update() for polygon '" <<
myPolygon->
getID() <<
"'" << std::endl;
115 #ifdef DEBUG_DYNAMIC_SHAPES
116 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' is on the road. Tracked position=" << objPos << std::endl;
123 #ifdef DEBUG_DYNAMIC_SHAPES
124 std::cout <<
" Relative rotation wrt original rotation: " << relRotation << std::endl;
127 newShape.
add(objPos);
130 #ifdef DEBUG_DYNAMIC_SHAPES
137 #ifdef DEBUG_DYNAMIC_SHAPES
140 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' hasn't entered the network since tracking was started." << std::endl;
168 #ifdef DEBUG_DYNAMIC_SHAPES
169 std::cout <<
" animation: dt=" << dt
176 #ifdef DEBUG_DYNAMIC_SHAPES
177 if (resetAnimation) {
178 std::cout <<
" (resetting animation!)";
181 if (resetAnimation) {
200 #ifdef DEBUG_DYNAMIC_SHAPES
201 std::cout <<
" (animation elapsed!)";
212 #ifdef DEBUG_DYNAMIC_SHAPES
213 std::cout <<
", previous anchor alpha: " << *
myPrevAlpha
217 #ifdef DEBUG_DYNAMIC_SHAPES
218 std::cout <<
", theta=" << theta << std::endl;
233 #ifdef DEBUG_DYNAMIC_SHAPES
243 #ifdef DEBUG_DYNAMIC_SHAPES
244 std::cout <<
"\n DynamicPolygon::setAlpha() Converted alpha=" << alpha <<
" into myAlpha=" << a << std::endl;
std::unique_ptr< std::vector< double > > myAlphaSpan
Alpha values corresponding to.
Representation of a vehicle or person.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual ~PolygonDynamics()
static const Position INVALID
used to indicate that a position is valid
void rotate2D(double angle)
virtual const std::string & getID() const =0
Get the vehicle's ID.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
void initTrackedPosition()
Initialize the object's position.
double myCurrentTime
Current time.
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
std::vector< double >::const_iterator myPrevTime
Pointer to the next time points in timeSpan.
void add(double xoff, double yoff, double zoff)
bool rotate
Whether this polygon should be rotated with the tracked object.
std::unique_ptr< std::vector< double > > myTimeSpan
Time points corresponding to the anchor values of the dynamic properties.
std::vector< double >::const_iterator myNextAlpha
virtual double getAngle() const =0
Returns the objects angle in degrees.
bool tracking
Whether this polygon tracks an object.
bool looped
Whether animation should be looped.
std::vector< double >::const_iterator myNextTime
A point in 2D or 3D with translation and scaling methods.
double myLastUpdateTime
The last time the animation has been updated.
double myTrackedObjectsInitialAngle
Initial angle of the tracked object.
bool animated
Whether this polygon is animated, i.e., whether timelines should be used to control properties.
std::string myTrackedObjectID
const PositionVector & getShape() const
Returns whether the shape of the polygon.
SUMOTrafficObject * myTrackedObject
An object tracked by the shape, deletion by caller.
SUMOPolygon * myPolygon
The polygon this dynamics acts upon.
std::unique_ptr< PositionVector > myOriginalShape
the original shape of the polygon (in case of tracking another object, this is converted to relative ...
SUMOTime update(SUMOTime t)
Updates the polygon according to its timeSpan and follows the tracked object.
std::vector< double >::const_iterator myPrevAlpha
Pointer to the next alpha points in alphaSpan.
const std::string & getID() const
Returns the id.
void setAlpha(double alpha)
Sets the alpha value for the shape's color.
PolygonDynamics(double creationTime, SUMOPolygon *p, SUMOTrafficObject *trackedObject, const std::vector< double > &timeSpan, const std::vector< double > &alphaSpan, bool looped, bool rotate)
Constructor that takes a SUMOPolygon and adds timelines for the properties to be modified dynamically...
std::unique_ptr< Position > myTrackedObjectsInitialPositon
Initial position of the tracked object.