mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Merge pull request #25 from aothms/master
Refactoring shared_ptr and array usage
This commit is contained in:
@@ -294,7 +294,7 @@ void SvgSerializer::finalize() {
|
||||
const double cx = xmin * sc;
|
||||
const double cy = ymin * sc;
|
||||
|
||||
{std::vector< SHARED_PTR<util::string_buffer::float_item> >::const_iterator it;
|
||||
{std::vector< boost::shared_ptr<util::string_buffer::float_item> >::const_iterator it;
|
||||
for (it = xcoords.begin(); it != xcoords.end(); ++it) {
|
||||
double& v = (*it)->value();
|
||||
v = v * sc - cx;
|
||||
|
||||
@@ -40,9 +40,9 @@ protected:
|
||||
boost::optional<double> section_height;
|
||||
bool rescale;
|
||||
std::multimap<IfcSchema::IfcBuildingStorey*, path_object> paths;
|
||||
std::vector< SHARED_PTR<util::string_buffer::float_item> > xcoords;
|
||||
std::vector< SHARED_PTR<util::string_buffer::float_item> > ycoords;
|
||||
std::vector< SHARED_PTR<util::string_buffer::float_item> > radii;
|
||||
std::vector< boost::shared_ptr<util::string_buffer::float_item> > xcoords;
|
||||
std::vector< boost::shared_ptr<util::string_buffer::float_item> > ycoords;
|
||||
std::vector< boost::shared_ptr<util::string_buffer::float_item> > radii;
|
||||
IfcParse::IfcFile* file;
|
||||
public:
|
||||
explicit SvgSerializer(const std::string& out_filename)
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
, rescale(false)
|
||||
, file(0)
|
||||
{}
|
||||
virtual void addXCoordinate(const SHARED_PTR<util::string_buffer::float_item>& fi) { xcoords.push_back(fi); }
|
||||
virtual void addYCoordinate(const SHARED_PTR<util::string_buffer::float_item>& fi) { ycoords.push_back(fi); }
|
||||
virtual void addSizeComponent(const SHARED_PTR<util::string_buffer::float_item>& fi) { radii.push_back(fi); }
|
||||
virtual void addXCoordinate(const boost::shared_ptr<util::string_buffer::float_item>& fi) { xcoords.push_back(fi); }
|
||||
virtual void addYCoordinate(const boost::shared_ptr<util::string_buffer::float_item>& fi) { ycoords.push_back(fi); }
|
||||
virtual void addSizeComponent(const boost::shared_ptr<util::string_buffer::float_item>& fi) { radii.push_back(fi); }
|
||||
virtual void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; }
|
||||
virtual ~SvgSerializer() {}
|
||||
virtual void writeHeader();
|
||||
|
||||
@@ -24,19 +24,19 @@
|
||||
|
||||
using namespace util;
|
||||
|
||||
SHARED_PTR<string_buffer::string_item> string_buffer::add(const std::string& s) {
|
||||
SHARED_PTR<string_item> i = SHARED_PTR<string_item>(new string_item(s));
|
||||
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;
|
||||
}
|
||||
SHARED_PTR<string_buffer::float_item> string_buffer::add(const double& d) {
|
||||
SHARED_PTR<float_item> i = SHARED_PTR<float_item>(new float_item(d));
|
||||
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< SHARED_PTR<item> >::const_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
for (std::vector< boost::shared_ptr<item> >::const_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
ss << (**it).str();
|
||||
}
|
||||
return ss.str();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "../ifcparse/SharedPointer.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace util {
|
||||
class string_buffer {
|
||||
@@ -51,12 +51,12 @@ namespace util {
|
||||
std::string str() const { std::stringstream ss; ss << d; return ss.str(); }
|
||||
};
|
||||
private:
|
||||
std::vector< SHARED_PTR<item> > items;
|
||||
std::vector< boost::shared_ptr<item> > items;
|
||||
void clear();
|
||||
void assign(const std::vector< SHARED_PTR<item> >& other);
|
||||
void assign(const std::vector< boost::shared_ptr<item> >& other);
|
||||
public:
|
||||
SHARED_PTR<string_item> add(const std::string& s);
|
||||
SHARED_PTR<float_item> add(const double& d);
|
||||
boost::shared_ptr<string_item> add(const std::string& s);
|
||||
boost::shared_ptr<float_item> add(const double& d);
|
||||
std::string str() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_S
|
||||
#ifdef USE_IFC4
|
||||
|
||||
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) {
|
||||
SHARED_PTR< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
|
||||
boost::shared_ptr< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
|
||||
std::vector<double> uknots = l->UKnots();
|
||||
std::vector<double> vknots = l->VKnots();
|
||||
std::vector<int> umults = l->UMultiplicities();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "IfcGeom.h"
|
||||
|
||||
bool process_colour(IfcSchema::IfcColourRgb* colour, std::tr1::array<double, 3>& rgb) {
|
||||
bool process_colour(IfcSchema::IfcColourRgb* colour, double* rgb) {
|
||||
if (colour != 0) {
|
||||
rgb[0] = colour->Red();
|
||||
rgb[1] = colour->Green();
|
||||
@@ -30,7 +30,7 @@ bool process_colour(IfcSchema::IfcColourRgb* colour, std::tr1::array<double, 3>&
|
||||
return colour != 0;
|
||||
}
|
||||
|
||||
bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, std::tr1::array<double, 3>& rgb) {
|
||||
bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, double* rgb) {
|
||||
if (factor != 0) {
|
||||
const double f = *factor;
|
||||
rgb[0] = rgb[1] = rgb[2] = f;
|
||||
@@ -38,7 +38,7 @@ bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, std::tr1::arra
|
||||
return factor != 0;
|
||||
}
|
||||
|
||||
bool process_colour(IfcSchema::IfcColourOrFactor* colour_or_factor, std::tr1::array<double, 3>& rgb) {
|
||||
bool process_colour(IfcSchema::IfcColourOrFactor* colour_or_factor, double* rgb) {
|
||||
if (colour_or_factor == 0) {
|
||||
return false;
|
||||
} else if (colour_or_factor->is(IfcSchema::Type::IfcColourRgb)) {
|
||||
@@ -66,7 +66,7 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::get_style(const IfcSchema::IfcRepr
|
||||
} else {
|
||||
surface_style = SurfaceStyle(surface_style_id);
|
||||
}
|
||||
std::tr1::array<double, 3> rgb;
|
||||
double rgb[3];
|
||||
if (process_colour(shading_styles.second->SurfaceColour(), rgb)) {
|
||||
surface_style.Diffuse().reset(SurfaceStyle::ColorComponent(rgb[0], rgb[1], rgb[2]));
|
||||
}
|
||||
|
||||
@@ -20,16 +20,6 @@
|
||||
#ifndef IFCGEOMRENDERSTYLES_H
|
||||
#define IFCGEOMRENDERSTYLES_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <tr1/array>
|
||||
#else
|
||||
#if _MSC_VER < 1600
|
||||
#include <boost/tr1/array.hpp>
|
||||
#else
|
||||
#include <array>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_IFC4
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
#else
|
||||
@@ -41,7 +31,7 @@ namespace IfcGeom {
|
||||
public:
|
||||
class ColorComponent {
|
||||
private:
|
||||
std::tr1::array<double, 3> data;
|
||||
double data[3];
|
||||
public:
|
||||
ColorComponent(double r, double g, double b) {
|
||||
data[0] = r; data[1] = g; data[2] = b;
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../ifcparse/SharedPointer.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "../ifcparse/IfcUtil.h"
|
||||
#include "../ifcparse/IfcException.h"
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
#include "../ifcparse/SharedPointer.h"
|
||||
#include "../ifcparse/IfcCharacterDecoder.h"
|
||||
#include "../ifcparse/IfcUtil.h"
|
||||
|
||||
|
||||
@@ -26,10 +26,9 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
#include "../ifcparse/SharedPointer.h"
|
||||
|
||||
#ifdef USE_IFC4
|
||||
#include "../ifcparse/Ifc4enum.h"
|
||||
#else
|
||||
@@ -119,7 +118,7 @@ class IfcTemplatedEntityList;
|
||||
class IfcEntityList {
|
||||
std::vector<IfcUtil::IfcBaseClass*> ls;
|
||||
public:
|
||||
typedef SHARED_PTR<IfcEntityList> ptr;
|
||||
typedef boost::shared_ptr<IfcEntityList> ptr;
|
||||
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
|
||||
void push(IfcUtil::IfcBaseClass* l);
|
||||
void push(const ptr& l);
|
||||
@@ -143,7 +142,7 @@ template <class T>
|
||||
class IfcTemplatedEntityList {
|
||||
std::vector<T*> ls;
|
||||
public:
|
||||
typedef SHARED_PTR< IfcTemplatedEntityList<T> > ptr;
|
||||
typedef boost::shared_ptr< IfcTemplatedEntityList<T> > ptr;
|
||||
typedef typename std::vector<T*>::const_iterator it;
|
||||
void push(T* t) { if (t) { ls.push_back(t); } }
|
||||
void push(ptr t) { if (t) { for ( typename T::list::it it = t->begin(); it != t->end(); ++it ) push(*it); } }
|
||||
@@ -177,7 +176,7 @@ class IfcTemplatedEntityListList;
|
||||
class IfcEntityListList {
|
||||
std::vector< std::vector<IfcUtil::IfcBaseClass*> > ls;
|
||||
public:
|
||||
typedef SHARED_PTR< IfcEntityListList > ptr;
|
||||
typedef boost::shared_ptr< IfcEntityListList > ptr;
|
||||
typedef std::vector< std::vector<IfcUtil::IfcBaseClass*> >::const_iterator outer_it;
|
||||
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
|
||||
void push(const std::vector<IfcUtil::IfcBaseClass*>& l) {
|
||||
@@ -231,7 +230,7 @@ template <class T>
|
||||
class IfcTemplatedEntityListList {
|
||||
std::vector< std::vector<T*> > ls;
|
||||
public:
|
||||
typedef typename SHARED_PTR< IfcTemplatedEntityListList<T> > ptr;
|
||||
typedef typename boost::shared_ptr< IfcTemplatedEntityListList<T> > ptr;
|
||||
typedef typename std::vector< std::vector<T*> >::const_iterator outer_it;
|
||||
typedef typename std::vector<T*>::const_iterator inner_it;
|
||||
void push(const std::vector<T*>& t) {ls.push_back(t);}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* 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/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file defines the shared pointer implementation to use, shared pointers *
|
||||
* are used extensively in IfcOpenShell *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <tr1/memory>
|
||||
#define SHARED_PTR std::tr1::shared_ptr
|
||||
#else
|
||||
#if _MSC_VER >= 1600
|
||||
// MSVC 2008 does not have shared_ptr by default, but it comes
|
||||
// in a feature pack. Therefore for IDEs prior to MSVC 2010 the
|
||||
// shared_ptr that ships with boost is used.
|
||||
#include <memory>
|
||||
#define SHARED_PTR std::tr1::shared_ptr
|
||||
#else
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#define SHARED_PTR boost::shared_ptr
|
||||
#endif
|
||||
#endif
|
||||
@@ -319,10 +319,6 @@
|
||||
RelativePath="..\..\src\ifcparse\IfcWrite.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ifcparse\SharedPointer.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
||||
Reference in New Issue
Block a user