Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Perception/EdgesPercept.h

Go to the documentation of this file.

    00001 /**
    00002  * @file EdgesPercept.h
    00003  *
    00004  * Declaration of class EdgesPercept
    00005  * @author Dirk Thomas
    00006  */
    00007
    00008 #ifndef __EdgesPercept_h_
    00009 #define __EdgesPercept_h_
    00010
    00011
    00012 #include "Tools/Streams/InOut.h"
    00013 #include "Tools/Math/Vector2.h"
    00014
    00015 /**
    00016 * The class represents a percepted edge on the field.
    00017 */
    00018 class EdgesPercept : public Streamable
    00019 {
    00020   public:
    00021     enum {maxNumberOfEdges = 50}; /**< Specifies the maximum number of edges. */
    00022
    00023     class Edge : public Streamable
    00024     {
    00025     public:
    00026       void serialize(In* in, Out* out)
    00027       {
    00028         STREAM_REGISTER_BEGIN();
    00029         STREAM( point1OnField);
    00030         STREAM( point2OnField);
    00031         STREAM( point1InImage);
    00032         STREAM( point2InImage);
    00033         STREAM( lengthOnField);
    00034         STREAM( lengthInImage);
    00035         STREAM( angleOnField);
    00036         STREAM( angleInImage);
    00037         STREAM_REGISTER_FINISH();
    00038       }
    00039
    00040       Vector2<double> point1OnField;
    00041       Vector2<double> point2OnField;
    00042       Vector2<int> point1InImage;
    00043       Vector2<int> point2InImage;
    00044       double lengthOnField;
    00045       double lengthInImage;
    00046       double angleOnField;
    00047       double angleInImage;
    00048     };
    00049
    00050     Edge edges[maxNumberOfEdges]; /**< The edges. */
    00051     int numberOfEdges; /**< The number of edges. */
    00052     unsigned long frameNumber; /**< The frame number when perceived. */
    00053
    00054     /**
    00055      * Constructor.
    00056      */
    00057     EdgesPercept() :
    00058       frameNumber(0),
    00059       numberOfEdges(0)
    00060     {
    00061     }
    00062
    00063     /**
    00064      * The function empties the edge percept.
    00065      */
    00066     void reset(unsigned long frameNumber);
    00067
    00068     /**
    00069      * The function adds a new edge to the edge percept.
    00070      * @param point1OnField The point of one end of the edge on the field.
    00071      * @param point2OnField The point of the other end of the edge on the field.
    00072      * @param point1InImage The point of one end of the edge in the image.
    00073      * @param point2InImage The point of the other end of the edge in the image.
    00074      */
    00075     void add(const Vector2<double>& point1OnField, const Vector2<double>& point2OnField,
    00076              const Vector2<int>& point1InImage, const Vector2<int>& point2InImage);
    00077
    00078     void serialize(In* in, Out* out)
    00079     {
    00080       STREAM_REGISTER_BEGIN();
    00081       STREAM(frameNumber);
    00082       STREAM_DYN_ARRAY( edges, numberOfEdges);
    00083       STREAM_REGISTER_FINISH();
    00084     }
    00085 };
    00086
    00087 #endif //__EdgesPercept_h_