openmbvcppinterface  3.1.0
OpenMBV C++ Interface
body.h
1 /*
2  OpenMBV - Open Multi Body Viewer.
3  Copyright (C) 2009 Markus Friedrich
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program 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
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef _OPENMBV_BODY_H_
21 #define _OPENMBV_BODY_H_
22 
23 #include <string>
24 #include <sstream>
25 #include <vector>
26 #include <openmbvcppinterface/object.h>
27 
28 namespace OpenMBV {
29 
31  class Body : public Object {
32  public:
33  enum DrawStyle { filled, lines, points };
34  private:
35  std::string getRelPathTo(const std::shared_ptr<Body> &destBody);
36  protected:
37  std::string outLineStr, shilouetteEdgeStr;
38  DrawStyle drawMethod{filled};
39  double pointSize{0};
40  double lineWidth{0};
41  std::shared_ptr<Body> hdf5LinkBody;
42  std::string hdf5LinkStr;
43  void createHDF5File() override;
44  void openHDF5File() override;
45  void terminate() override;
46  Body();
47  ~Body() override = default;
48  public:
50  void setHDF5LinkTarget(const std::shared_ptr<Body> &dest) { hdf5LinkBody=dest; }
51 
52  std::shared_ptr<Body>& getHDF5LinkTarget() { return hdf5LinkBody; }
53 
55  bool isHDF5Link() { return (hdf5LinkBody || !hdf5LinkStr.empty()); }
56 
58  void setOutLine(bool ol) { outLineStr=(ol)?"true":"false"; }
59 
60  bool getOutLine() { return outLineStr=="true"?true:false; }
61 
63  void setShilouetteEdge(bool ol) { shilouetteEdgeStr=(ol)?"true":"false"; }
64 
65  bool getShilouetteEdge() { return shilouetteEdgeStr=="true"?true:false; }
66 
68  void setDrawMethod(DrawStyle ds) { drawMethod=ds; }
69 
70  DrawStyle getDrawMethod() { return drawMethod; }
71 
73  void setPointSize(double ps) { pointSize=ps; }
74 
75  double getPointSize() { return pointSize; }
76 
78  void setLineWidth(double lw) { lineWidth=lw; }
79 
80  double getLineWidth() { return lineWidth; }
81 
83  void initializeUsingXML(xercesc::DOMElement *element) override;
84 
85  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
86 
91  virtual int getRows()=0;
92 
96  virtual std::vector<double> getRow(int i)=0;
97  };
98 
99 }
100 
101 #endif /* _OPENMBV_BODY_H_ */
102 
virtual std::vector< double > getRow(int i)=0
void setHDF5LinkTarget(const std::shared_ptr< Body > &dest)
Definition: body.h:50
void setLineWidth(double lw)
Definition: body.h:78
void setShilouetteEdge(bool ol)
Definition: body.h:63
void setPointSize(double ps)
Definition: body.h:73
Definition: object.h:43
bool isHDF5Link()
Definition: body.h:55
virtual int getRows()=0
void setDrawMethod(DrawStyle ds)
Definition: body.h:68
void setOutLine(bool ol)
Definition: body.h:58
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: body.cc:103
Definition: body.h:31