24 singlePrecision(true) {
27 union {
long l;
char c[
sizeof (long)]; } u;
33 if (
tags.size() <= 0) {
35 tags[
"heprep"] = 0x05;
36 tags[
"attdef"] = 0x06;
37 tags[
"attvalue"] = 0x07;
38 tags[
"instance"] = 0x08;
39 tags[
"treeid"] = 0x09;
40 tags[
"action"] = 0x0a;
41 tags[
"instancetree"] = 0x0b;
43 tags[
"typetree"] = 0x0d;
84 values[
"drawasoptions"] = 0x86;
85 values[
"visibility"] = 0x87;
90 values[
"fontstyle"] = 0x8a;
92 values[
"fontcolor"] = 0x8c;
93 values[
"fonthasframe"] = 0x8d;
94 values[
"fontframecolor"] = 0x8e;
95 values[
"fontframewidth"] = 0x8f;
96 values[
"fonthasbanner"] = 0x90;
97 values[
"fontbannercolor"] = 0x91;
100 values[
"framecolor"] = 0x93;
102 values[
"markname"] = 0x95;
103 values[
"marksize"] = 0x96;
104 values[
"marksizemultiplier"] = 0x97;
105 values[
"marktype"] = 0x98;
106 values[
"hasframe"] = 0x99;
107 values[
"framecolor"] = 0x9a;
108 values[
"framewidth"] = 0x9b;
110 values[
"linestyle"] = 0x9c;
111 values[
"linewidth"] = 0x9d;
112 values[
"linewidthmultiplier"] = 0x9e;
113 values[
"linehasarrow"] = 0x9f;
115 values[
"fillcolor"] = 0xa0;
116 values[
"filltype"] = 0xa1;
126 values[
"curvature"] = 0xaa;
127 values[
"flylength"] = 0xab;
136 values[
"ispickable"] = 0xb2;
137 values[
"showparentvalues"] = 0xb3;
138 values[
"pickparent"] = 0xb4;
151 values[
"ellipsoid"] = 0xd9;
153 values[
"cylinder"] = 0xdb;
154 values[
"ellipseprism"] = 0xdc;
162 values[
"uptriangle"] = 0xe2;
163 values[
"dntriangle"] = 0xe3;
182 values[
"sansserif"] = 0xf3;
183 values[
"monotype"] = 0xf4;
191 values[
"baseline"] = 0xfa;
216 version =
"BinaryHepRep/1.0";
246 std::string
s = tagName;
247 std::transform(s.begin(), s.end(), s.begin(), (
int(*)(
int)) tolower);
250 if (
tags.count(s) <= 0) {
251 std::cerr <<
"Cannot find tag '" << s <<
"' in tags table." << std::endl;
256 bool isPoint = (s ==
"point");
259 if (!hasAttributes && isPoint) {
274 std::string
name = i->first;
275 std::string
value = i->second;
279 std::string v =
value;
280 std::transform(v.begin(), v.end(), v.begin(), (
int(*)(
int)) tolower);
281 if (
values.count(v) > 0) {
301 std::string
name = i->first;
302 std::vector<double>
value = i->second;
308 writeByte((
int)(value[0] * 0xff) & 0xff);
309 writeByte((
int)(value[1] * 0xff) & 0xff);
310 writeByte((
int)(value[2] * 0xff) & 0xff);
311 if (value.size() > 3)
writeByte((
int)(value[3] * 0xff) & 0xff);
317 std::string
name = i->first;
330 std::string
name = i->first;
331 int value = i->second;
343 std::string
name = i->first;
344 bool value = i->second;
354 std::string
name = i->first;
355 double value = i->second;
356 if (!isPoint && (name !=
"x") && (name !=
"y") && (name !=
"z")) {
379 if (isPoint && !hasContent) {
386 if (
points.size() <= 0)
return;
391 for (std::vector<double>::iterator i =
points.begin(); i !=
points.end(); ) {
406 if (name ==
"value") name = name.append(
"String");
410 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
418 if (name ==
"value") name = name.append(
"Color");
422 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
430 if (name ==
"value") name = name.append(
"Long");
434 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
442 if (name ==
"value") name = name.append(
"Int");
446 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
454 if (name ==
"value") name = name.append(
"Boolean");
458 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
466 if (name ==
"value") name = name.append(
"Double");
470 std::cerr <<
"Cannot find attribute name '" << name <<
"' in attributes table, skipped." << std::endl;
483 unsigned char buf[5];
487 buf[idx++] = (
unsigned char) (ui & 0x7f);
519 os.put((i >> 56) & 0xff);
520 os.put((i >> 48) & 0xff);
521 os.put((i >> 40) & 0xff);
522 os.put((i >> 32) & 0xff);
523 os.put((i >> 24) & 0xff);
524 os.put((i >> 16) & 0xff);
525 os.put((i >> 8) & 0xff);
531 os.put((i >> 24) & 0xff);
532 os.put((i >> 16) & 0xff);
533 os.put((i >> 8) & 0xff);
void closeDoc(bool force=false)
void writeMultiByteInt(unsigned int ui)
std::map< std::string, int > intAttributes
std::map< std::string, int64 > longAttributes
std::map< std::string, double > doubleAttributes
static const unsigned char STR_D
void openDoc(std::string version="BinaryHepRep/1.0", std::string encoding="UTF-8", bool standalone=false)
static const unsigned char PI
void setAttribute(std::string name, char *value)
void writeTag(std::string name, bool content=false)
static const unsigned char CONTENT
static const unsigned char OPAQUE
const XML_Char int const XML_Char * value
void printTag(std::string name)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static const unsigned char UNKNOWN_PID
BHepRepWriter(std::ostream &os)
std::map< std::string, std::vector< double > > colorAttributes
static std::map< std::string, unsigned char > values
std::map< std::string, bool > booleanAttributes
static const unsigned char WBXML_VERSION
void writeString(std::string s)
void writeByte(unsigned char b)
static std::map< std::string, unsigned char > tags
static std::map< std::string, unsigned char > attributes
static const unsigned char UTF8
static const unsigned char END
std::vector< double > points
std::map< std::string, std::string > stringAttributes
void writeStringDefine(std::string s)
void writeReal(double ui)
std::map< std::string, unsigned int > stringValues
static const unsigned char STR_R
void openTag(std::string name)