hrplib/hrpUtil/VrmlWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  */
9 
14 #ifndef OPENHRP_UTIL_VRML_WRITER_INCLUDED
15 #define OPENHRP_UTIL_VRML_WRITER_INCLUDED
16 
17 #include "config.h"
18 #include "VrmlNodes.h"
19 
20 #include <map>
21 #include <string>
22 #include <ostream>
23 
24 
25 namespace hrp {
26 
27  class VrmlWriter;
28 
30 
31 
33  {
34  public:
35  VrmlWriter(std::ostream& out);
36 
37  void writeHeader();
38  bool writeNode(VrmlNodePtr node);
39 
40  struct TIndent {
41  void clear() { n = 0; spaces.resize(n); }
42  TIndent& operator++() { n += 2; spaces.resize(n, ' '); return *this; }
44  n -= 2;
45  if(n < 0) { n = 0; }
46  spaces.resize(n, ' '); return *this;
47  }
48  std::string spaces;
49  int n;
50  };
51 
52  private:
53  std::ostream& out;
54 
56 
57  typedef std::map<std::string, VrmlWriterNodeMethod> TNodeMethodMap;
58  typedef std::pair<std::string, VrmlWriterNodeMethod> TNodeMethodPair;
59 
60  static TNodeMethodMap nodeMethodMap;
61 
62  static void registNodeMethod(const std::type_info& t, VrmlWriterNodeMethod method) {
63  nodeMethodMap.insert(TNodeMethodPair(t.name(), method));
64  }
65  static VrmlWriterNodeMethod getNodeMethod(VrmlNodePtr node);
66 
67  static void registerNodeMethodMap();
68 
69  template <class MFValues> void writeMFValues(MFValues values, int numColumn);
70  void writeMFInt32SeparatedByMinusValue(MFInt32& values);
71 
72  void writeNodeIter(VrmlNodePtr node);
73  void beginNode(const char* nodename, VrmlNodePtr node);
74  void endNode();
75  void writeGroupNode(VrmlNodePtr node);
76  void writeGroupFields(VrmlGroupPtr group);
77  void writeTransformNode(VrmlNodePtr node);
78  void writeShapeNode(VrmlNodePtr node);
79  void writeAppearanceNode(VrmlAppearancePtr appearance);
80  void writeMaterialNode(VrmlMaterialPtr material);
81  void writeIndexedFaceSetNode(VrmlNodePtr node);
82  void writeCoordinateNode(VrmlCoordinatePtr coord);
83 
84  };
85 
86 };
87 
88 
89 #endif
std::map< std::string, VrmlWriterNodeMethod > TNodeMethodMap
std::pair< std::string, VrmlWriterNodeMethod > TNodeMethodPair
boost::intrusive_ptr< VrmlGroup > VrmlGroupPtr
Definition: VrmlNodes.h:250
static TNodeMethodMap nodeMethodMap
void(VrmlWriter::* VrmlWriterNodeMethod)(VrmlNodePtr node)
int method
Definition: png.h:1847
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
#define HRP_UTIL_EXPORT
boost::intrusive_ptr< VrmlAppearance > VrmlAppearancePtr
Definition: VrmlNodes.h:277
boost::intrusive_ptr< VrmlNode > VrmlNodePtr
Definition: VrmlNodes.h:155
static void registNodeMethod(const std::type_info &t, VrmlWriterNodeMethod method)
boost::intrusive_ptr< VrmlCoordinate > VrmlCoordinatePtr
Definition: VrmlNodes.h:457
std::vector< SFInt32 > MFInt32
Definition: VrmlNodes.h:69
boost::intrusive_ptr< VrmlMaterial > VrmlMaterialPtr
Definition: VrmlNodes.h:295


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:06