Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ShapeSpace.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _SHAPESPACE_H_
00003 #define _SHAPESPACE_H_
00004 
00005 #include <vector>
00006 #include <iostream>
00007 
00008 #include "Vision/colors.h"
00009 #include "Shared/fmatSpatial.h"
00010 
00011 #include "Shared/Measures.h"
00012 #include "ShapeTypes.h"
00013 
00014 namespace DualCoding {
00015 
00016 //****************
00017 //
00018 // ShapeSpace holds a collection of data objects, e.g., AgentData,
00019 // LineData, EllipseData
00020 
00021 class BaseData;
00022 class ShapeRoot;
00023 class Point;
00024 class SketchSpace;
00025 class LineData;
00026 template<typename T> class Shape;
00027 
00028 //! Holds a collection of diverse shapes such as LineData or EllipseData
00029 
00030 class ShapeSpace {
00031 private:
00032   friend class SketchSpace;
00033   friend class ShapeRoot;
00034   friend class VisualRoutinesBehavior;
00035   //  friend class WorldMapBuilder;
00036   
00037 public:
00038   std::string name;  //!< Name of the ShapeSpace
00039 
00040 private:
00041   SketchSpace* dualSpace;
00042   int id_counter;
00043   std::vector<ShapeRoot> shapeCache;
00044   ShapeRoot& addShape(BaseData* p);
00045   ReferenceFrameType_t refFrameType;
00046   
00047 public:
00048 
00049   //! Constructor for ShapeSpace; requires dual SketchSpace. 
00050   ShapeSpace(SketchSpace* dualSkS, int init_id=70000, std::string const _name="", 
00051        ReferenceFrameType_t _refFrameType=camcentric);
00052   
00053   ~ShapeSpace(void);
00054   
00055   SketchSpace& getDualSpace(void) const { return *dualSpace; }
00056   ReferenceFrameType_t getRefFrameType() const { return refFrameType; }
00057   
00058   void importShapes(std::vector<ShapeRoot>& foreign_shapes);
00059   BaseData* importShape(const ShapeRoot& foreign_shape);
00060   
00061   void deleteShape(ShapeRoot &b);
00062   void deleteShapes(std::vector<ShapeRoot>& shapes_vec); 
00063   template<typename T> void deleteShapes(std::vector<Shape<T> >& shapes_vec) {
00064     deleteShapes(*(std::vector<ShapeRoot>*)&shapes_vec); }
00065 
00066   template<typename T> void deleteShapes() { deleteShapeType(T::getStaticType()); }
00067   
00068   void clear();
00069   
00070   std::vector<ShapeRoot>& allShapes(void) { return shapeCache; }
00071   const std::vector<ShapeRoot>& allShapes(void) const { return shapeCache; }
00072   std::vector<ShapeRoot> allShapes(ShapeType_t type);
00073   std::vector<ShapeRoot> allShapes(rgb color);
00074 
00075   ShapeRoot getShapeFromId(int id);
00076 
00077   // Coerce a ShapeSpace into a vector of ShapeRoots it contains
00078   operator std::vector<ShapeRoot>&() { return shapeCache; }
00079   std::vector<ShapeRoot>::iterator begin() { return shapeCache.begin(); }
00080   std::vector<ShapeRoot>::iterator end() { return shapeCache.end(); }
00081 
00082   std::string getShapeListForGUI(void);  
00083   
00084   void printParams(void);
00085   void printSummary(void);
00086   
00087   //! Transformation and Location Utilities
00088   //@{
00089   void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00090   
00091   Point getCentroid(void);
00092   
00093   Point getCentroidOfSubset(const std::vector<ShapeRoot>& subset);
00094   //@}
00095 
00096 private:
00097   ShapeSpace(const ShapeSpace&);  //!< never call this
00098   ShapeSpace& operator=(const ShapeSpace&); //!< never call this
00099   void deleteShapeType(ShapeType_t type);
00100 };
00101 
00102 } // namespace
00103 
00104 #endif

DualCoding 5.1CVS
Generated Mon May 9 04:56:27 2016 by Doxygen 1.6.3