openmbvcppinterface  3.1.0
OpenMBV C++ Interface
polygonpoint.h
1 /*
2  OpenMBV - Open Multi Body Viewer.
3  Copyright (C) 2009 Markus Friedrich
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef _OPENMBV_POLYGONPOINT_H_
21 #define _OPENMBV_POLYGONPOINT_H_
22 
23 #include <vector>
24 #include <fstream>
25 #include <iostream>
26 #include "openmbvcppinterface/body.h"
27 #include <stdexcept>
28 
29 namespace OpenMBV {
30 
37  class PolygonPoint {
38  protected:
39  PolygonPoint(double x_, double y_, int b_) : x(x_), y(y_), b(b_) {}
40  ~PolygonPoint() = default;
41  static void deleter(PolygonPoint *pp) { delete pp; }
42  public:
43  static std::shared_ptr<PolygonPoint> create(double x_, double y_, int b_) {
44  return {new PolygonPoint(x_, y_, b_), &deleter};
45  };
46 
47  /* GETTER / SETTER */
48  double getXComponent() { return x; }
49  double getYComponent() { return y; }
50  int getBorderValue() { return b; }
51  /***************************************************/
52 
53  /* CONVENIENCE */
55  static void serializePolygonPointContour(xercesc::DOMElement *parent,
56  const std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > &cont);
57 
58  static std::shared_ptr<std::vector<std::shared_ptr<PolygonPoint> > > initializeUsingXML(xercesc::DOMElement *element);
59 
60  private:
61  double x, y;
62  int b;
63  };
64 
65 }
66 
67 #endif /* POLYGONPOINT_H */
68 
static void serializePolygonPointContour(xercesc::DOMElement *parent, const std::shared_ptr< std::vector< std::shared_ptr< PolygonPoint > > > &cont)
Definition: polygonpoint.cc:30
Definition: polygonpoint.h:37