32 const std::vector<double>& timeSpan,
33 const std::vector<double>& alphaSpan,
38 myLastUpdateTime(creationTime),
39 animated(!timeSpan.empty()),
41 tracking(trackedObject != nullptr),
43 myTrackedObject(trackedObject),
44 myTrackedObjectID(
""),
45 myTrackedObjectsInitialPositon(nullptr),
46 myTrackedObjectsInitialAngle(-1),
47 myOriginalShape(nullptr),
53 myTimeSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(timeSpan));
57 #ifdef DEBUG_DYNAMIC_SHAPES 59 for (
unsigned int i = 1; i <
myTimeSpan->size(); ++i) {
67 #ifdef DEBUG_DYNAMIC_SHAPES 81 if (!alphaSpan.empty()) {
82 myAlphaSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(alphaSpan));
96 #ifdef DEBUG_DYNAMIC_SHAPES 97 std::cout << t <<
" PolygonDynamics::update() for polygon '" <<
myPolygon->
getID() <<
"'" << std::endl;
101 myLastUpdateTime = simtime;
116 #ifdef DEBUG_DYNAMIC_SHAPES 117 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' is on the road. Tracked position=" << objPos << std::endl;
124 #ifdef DEBUG_DYNAMIC_SHAPES 125 std::cout <<
" Relative rotation wrt original rotation: " << relRotation << std::endl;
128 newShape.
add(objPos);
131 #ifdef DEBUG_DYNAMIC_SHAPES 138 #ifdef DEBUG_DYNAMIC_SHAPES 141 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' hasn't entered the network since tracking was started." << std::endl;
169 #ifdef DEBUG_DYNAMIC_SHAPES 170 std::cout <<
" animation: dt=" << dt
177 #ifdef DEBUG_DYNAMIC_SHAPES 178 if (resetAnimation) {
179 std::cout <<
" (resetting animation!)";
182 if (resetAnimation) {
201 #ifdef DEBUG_DYNAMIC_SHAPES 202 std::cout <<
" (animation elapsed!)";
213 #ifdef DEBUG_DYNAMIC_SHAPES 214 std::cout <<
", previous anchor alpha: " << *
myPrevAlpha 218 #ifdef DEBUG_DYNAMIC_SHAPES 219 std::cout <<
", theta=" << theta << std::endl;
234 #ifdef DEBUG_DYNAMIC_SHAPES 244 #ifdef DEBUG_DYNAMIC_SHAPES 245 std::cout <<
"\n DynamicPolygon::setAlpha() Converted alpha=" << alpha <<
" into myAlpha=" << a << std::endl;
std::unique_ptr< Position > myTrackedObjectsInitialPositon
Initial position of the tracked object.
virtual const std::string & getID() const =0
Get the vehicle's ID.
virtual ~PolygonDynamics()
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.
std::vector< double >::const_iterator myPrevTime
Pointer to the next time points in timeSpan.
bool rotate
Whether this polygon should be rotated with the tracked object.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
void initTrackedPosition()
Initialize the object's position.
const std::string & getID() const
Returns the id.
double myCurrentTime
Current time.
bool tracking
Whether this polygon tracks an object.
bool looped
Whether animation should be looped.
virtual double getAngle() const =0
Returns the objects angle in degrees.
std::unique_ptr< std::vector< double > > myTimeSpan
Time points corresponding to the anchor values of the dynamic properties.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
std::vector< double >::const_iterator myNextTime
A point in 2D or 3D with translation and scaling methods.
bool animated
Whether this polygon is animated, i.e., whether timelines should be used to control properties...
std::vector< double >::const_iterator myNextAlpha
double myLastUpdateTime
The last time the animation has been updated.
SUMOTime update(SUMOTime t)
Updates the polygon according to its timeSpan and follows the tracked object.
void rotate2D(double angle)
double myTrackedObjectsInitialAngle
Initial angle of the tracked object.
Representation of a vehicle or person.
SUMOTrafficObject * myTrackedObject
An object tracked by the shape, deletion by caller.
std::string myTrackedObjectID
void setAlpha(double alpha)
Sets the alpha value for the shape's color.
std::unique_ptr< PositionVector > myOriginalShape
the original shape of the polygon (in case of tracking another object, this is converted to relative ...
std::vector< double >::const_iterator myPrevAlpha
Pointer to the next alpha points in alphaSpan.
void add(double xoff, double yoff, double zoff)
SUMOPolygon * myPolygon
The polygon this dynamics acts upon.
std::unique_ptr< std::vector< double > > myAlphaSpan
Alpha values corresponding to.
static const Position INVALID
used to indicate that a position is valid
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
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...