Schema dependent serializers

This commit is contained in:
Thomas Krijnen
2018-03-16 13:49:11 +01:00
parent d374fd3778
commit 834780b726
11 changed files with 34 additions and 32 deletions
+2 -2
View File
@@ -43,7 +43,7 @@
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcconvert/GeometrySerializer.h"
#include "../serializers/GeometrySerializer.h"
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
@@ -86,7 +86,7 @@ private:
const std::string scene_id;
bool scene_opened;
std::stack<COLLADASW::Node*> parentNodes;
std::stack<IfcGeom::Transformation<double> > matrixStack;
std::stack<IfcGeom::Transformation<real_t> > matrixStack;
public:
ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer)
: COLLADASW::LibraryVisualScenes(&stream)
+1 -1
View File
@@ -26,7 +26,7 @@ typedef double real_t;
typedef float real_t;
#endif
#include "../ifcconvert/Serializer.h"
#include "../serializers/Serializer.h"
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcgeom/IfcGeomElement.h"
+1 -1
View File
@@ -22,7 +22,7 @@
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcconvert/GeometrySerializer.h"
#include "../serializers/GeometrySerializer.h"
class OpenCascadeBasedSerializer : public GeometrySerializer {
OpenCascadeBasedSerializer(const OpenCascadeBasedSerializer&); //N/A
+1 -1
View File
@@ -25,7 +25,7 @@
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
#include "../ifcconvert/OpenCascadeBasedSerializer.h"
#include "../serializers/OpenCascadeBasedSerializer.h"
class StepSerializer : public OpenCascadeBasedSerializer
{
+2 -2
View File
@@ -22,8 +22,8 @@
#ifndef SVGSERIALIZER_H
#define SVGSERIALIZER_H
#include "../ifcconvert/GeometrySerializer.h"
#include "../ifcconvert/util.h"
#include "../serializers/GeometrySerializer.h"
#include "../serializers/util.h"
#include <sstream>
#include <string>
+1 -1
View File
@@ -24,7 +24,7 @@
#include <string>
#include <fstream>
#include "../ifcconvert/GeometrySerializer.h"
#include "../serializers/GeometrySerializer.h"
// http://people.sc.fsu.edu/~jburkardt/txt/obj_format.txt
class WaveFrontOBJSerializer : public GeometrySerializer {
+43
View File
@@ -0,0 +1,43 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include <set>
#include <iostream>
#include "../serializers/util.h"
using namespace util;
boost::shared_ptr<string_buffer::string_item> string_buffer::add(const std::string& s) {
boost::shared_ptr<string_item> i = boost::shared_ptr<string_item>(new string_item(s));
items.push_back(i);
return i;
}
boost::shared_ptr<string_buffer::float_item> string_buffer::add(const double& d) {
boost::shared_ptr<float_item> i = boost::shared_ptr<float_item>(new float_item(d));
items.push_back(i);
return i;
}
std::string string_buffer::str() const {
std::stringstream ss;
for (std::vector< boost::shared_ptr<item> >::const_iterator it = items.begin(); it != items.end(); ++it) {
ss << (**it).str();
}
return ss.str();
}
+67
View File
@@ -0,0 +1,67 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef IFCCONVERT_UTIL_H
#define IFCCONVERT_UTIL_H
#include <sstream>
#include <vector>
#include <boost/shared_ptr.hpp>
namespace util {
class string_buffer {
public:
class item {
public:
virtual std::string str() const = 0;
virtual ~item() {};
};
class string_item : public item {
std::string s;
public:
string_item(const std::string& s) : s(s) {}
void assign(const std::string& s) { this->s = s; }
const std::string& value() const { return s; }
std::string& value() { return s; }
std::string str() const { return s; }
virtual ~string_item() {};
};
class float_item : public item {
double d;
public:
float_item(const double& d) : d(d) {}
void assign(const double& d) { this->d = d; }
const double& value() const { return d; }
double& value() { return d; }
std::string str() const { std::stringstream ss; ss << d; return ss.str(); }
virtual ~float_item() {};
};
private:
std::vector< boost::shared_ptr<item> > items;
void clear();
void assign(const std::vector< boost::shared_ptr<item> >& other);
public:
boost::shared_ptr<string_item> add(const std::string& s);
boost::shared_ptr<float_item> add(const double& d);
std::string str() const;
};
}
#endif