Skip to content

Commit

Permalink
replaced some boost snippets, to improve compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
ifcquery committed Dec 2, 2019
1 parent 9bf80de commit b856027
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 100 deletions.
2 changes: 2 additions & 0 deletions IfcPlusPlus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(UNIX)
set(IFCPP_SOURCE_FILES
src/ifcpp/IFC4/EntityFactory.cpp
src/ifcpp/IFC4/TypeFactory.cpp
src/ifcpp/model/BuildingGuid.cpp
src/ifcpp/model/BuildingModel.cpp
src/ifcpp/model/UnitConverter.cpp
src/ifcpp/reader/AbstractReader.cpp
Expand All @@ -44,6 +45,7 @@ else(UNIX)
set(IFCPP_SOURCE_FILES
src/ifcpp/IFC4/EntityFactory.cpp
src/ifcpp/IFC4/TypeFactory.cpp
src/ifcpp/model/BuildingGuid.cpp
src/ifcpp/model/BuildingModel.cpp
src/ifcpp/model/UnitConverter.cpp
src/ifcpp/reader/AbstractReader.cpp
Expand Down
1 change: 1 addition & 0 deletions IfcPlusPlus/src/ifcpp/geometry/Carve/ConverterOSG.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#include <ifcpp/model/StatusCallback.h>
#include <ifcpp/IFC4/include/IfcCurtainWall.h>
#include <ifcpp/IFC4/include/IfcFeatureElementSubtraction.h>
#include <ifcpp/IFC4/include/IfcGloballyUniqueId.h>
#include <ifcpp/IFC4/include/IfcProject.h>
#include <ifcpp/IFC4/include/IfcPropertySetDefinitionSet.h>
#include <ifcpp/IFC4/include/IfcRelAggregates.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU

#pragma once

#include <boost/unordered/unordered_set.hpp>
#include <unordered_set>
#include <BRepBuilderAPI_MakeFace.hxx>

#include <ifcpp/geometry/GeometrySettings.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU

#pragma once

#include <boost/unordered/unordered_set.hpp>
#include <unordered_set>
#include <osg/Material>
#include <osg/Geode>
#include <osg/CullFace>
Expand Down
20 changes: 10 additions & 10 deletions IfcPlusPlus/src/ifcpp/geometry/StylesConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#pragma once

#include <map>
#include <boost/algorithm/string.hpp>

#include <ifcpp/geometry/AppearanceData.h>
#include <ifcpp/model/BasicTypes.h>
#include <ifcpp/model/StatusCallback.h>
#include <ifcpp/reader/ReaderUtil.h>
#include <ifcpp/IFC4/include/IfcSpecularHighlightSelect.h>
#include <ifcpp/IFC4/include/IfcSpecularExponent.h>
#include <ifcpp/IFC4/include/IfcSpecularRoughness.h>
Expand Down Expand Up @@ -153,14 +153,14 @@ class StylesConverter : public StatusCallback
if( draughting_predefined_color->m_Name )
{
std::wstring predefined_name = draughting_predefined_color->m_Name->m_value;
if( boost::iequals( predefined_name, L"black" ) ) color.setColor( 0.0, 0.0, 0.0, 1.0 );
else if( boost::iequals( predefined_name, L"red" ) ) color.setColor( 1.0, 0.0, 0.0, 1.0 );
else if( boost::iequals( predefined_name, L"green" ) ) color.setColor( 0.0, 1.0, 0.0, 1.0 );
else if( boost::iequals( predefined_name, L"blue" ) ) color.setColor( 0.0, 0.0, 1.0, 1.0 );
else if( boost::iequals( predefined_name, L"yellow" ) ) color.setColor( 1.0, 1.0, 0.0, 1.0 );
else if( boost::iequals( predefined_name, L"magenta" ) ) color.setColor( 1.0, 0.0, 1.0, 1.0 );
else if( boost::iequals( predefined_name, L"cyan" ) ) color.setColor( 0.0, 1.0, 1.0, 1.0 );
else if( boost::iequals( predefined_name, L"white" ) ) color.setColor( 1.0, 1.0, 1.0, 1.0 );
if( std_iequal( predefined_name, L"black" ) ) color.setColor( 0.0, 0.0, 0.0, 1.0 );
else if( std_iequal( predefined_name, L"red" ) ) color.setColor( 1.0, 0.0, 0.0, 1.0 );
else if( std_iequal( predefined_name, L"green" ) ) color.setColor( 0.0, 1.0, 0.0, 1.0 );
else if( std_iequal( predefined_name, L"blue" ) ) color.setColor( 0.0, 0.0, 1.0, 1.0 );
else if( std_iequal( predefined_name, L"yellow" ) ) color.setColor( 1.0, 1.0, 0.0, 1.0 );
else if( std_iequal( predefined_name, L"magenta" ) ) color.setColor( 1.0, 0.0, 1.0, 1.0 );
else if( std_iequal( predefined_name, L"cyan" ) ) color.setColor( 0.0, 1.0, 1.0, 1.0 );
else if( std_iequal( predefined_name, L"white" ) ) color.setColor( 1.0, 1.0, 1.0, 1.0 );
}
}
return;
Expand Down Expand Up @@ -463,7 +463,7 @@ class StylesConverter : public StatusCallback
if( !complex_property->m_UsageName ) return;
if( vec_HasProperties.size() < 3 ) return;
std::wstring usage_name = complex_property->m_UsageName->m_value;
if( !boost::iequals( usage_name.c_str(), L"Color" ) ) return;
if( !std_iequal( usage_name.c_str(), L"Color" ) ) return;

if( complex_property->m_HasProperties.size() > 2 )
{
Expand Down
36 changes: 18 additions & 18 deletions IfcPlusPlus/src/ifcpp/model/BuildingGuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#include "BuildingGuid.h"

///@brief Creates a GUID string with 36 characters including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
std::basic_string<wchar_t> createGUID32_wstr()
std::wstring createGUID32_wstr()
{
std::basic_stringstream<wchar_t> uuid_strs;
uuid_strs << std::uppercase;
Expand All @@ -33,7 +33,7 @@ std::basic_string<wchar_t> createGUID32_wstr()
return uuid_strs.str();
}

std::basic_string<char> createGUID32()
std::string createGUID32()
{
std::basic_stringstream<char> uuid_strs;
uuid_strs << std::uppercase;
Expand Down Expand Up @@ -63,7 +63,7 @@ static const char base64mask[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -
///@brief Compresses a GUID string
///@details Expects a string with exactly 36 characters including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
///@returns an IFC GUID string with 22 characters, for example: "3n0m0Cc6L4xhvkpCU0k1GZ"
std::basic_string<wchar_t> compressGUID_wstr(const std::basic_string<wchar_t>& in)
std::wstring compressGUID_wstr(const std::wstring& in)
{
static constexpr std::array<wchar_t, 64> base64Chars = {
'0','1','2','3','4','5','6','7','8','9',
Expand All @@ -72,8 +72,8 @@ std::basic_string<wchar_t> compressGUID_wstr(const std::basic_string<wchar_t>& i
'_','$'
};

std::basic_string<wchar_t> temp;
std::basic_string<wchar_t> result;
std::wstring temp;
std::wstring result;
result.resize(23);
result[0] = '0';

Expand Down Expand Up @@ -102,7 +102,7 @@ std::basic_string<wchar_t> compressGUID_wstr(const std::basic_string<wchar_t>& i
result.resize(22);
return result;
}
std::basic_string<char> compressGUID(const std::basic_string<char>& in)
std::string compressGUID(const std::string& in)
{
static constexpr std::array<char, 64> base64Chars = {
'0','1','2','3','4','5','6','7','8','9',
Expand All @@ -111,8 +111,8 @@ std::basic_string<char> compressGUID(const std::basic_string<char>& in)
'_','$'
};

std::basic_string<char> temp;
std::basic_string<char> result;
std::string temp;
std::string result;
result.resize(23);
result[0] = '0';

Expand Down Expand Up @@ -145,7 +145,7 @@ std::basic_string<char> compressGUID(const std::basic_string<char>& in)
///@brief Decompresses an IFC GUID string
///@details Expects a string with exactly 22 characters, for example "3n0m0Cc6L4xhvkpCU0k1GZ"
///@returns GUID string with 36 characters, including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
std::basic_string<wchar_t> decompressGUID_wstr(const std::basic_string<wchar_t>& in )
std::wstring decompressGUID_wstr(const std::wstring& in )
{
static constexpr std::array<wchar_t, 16> base16Chars = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };

Expand All @@ -167,7 +167,7 @@ std::basic_string<wchar_t> decompressGUID_wstr(const std::basic_string<wchar_t>&
temp[ii_out] = '\0';

// add dashes: F103000C-9865-44EE-BE6E-CCC780B81423
std::basic_string<wchar_t> result;
std::wstring result;
for (size_t ii = 1; ii < 36; ++ii)
{
if (ii == 9 || ii == 13 || ii == 17 || ii == 21)
Expand All @@ -181,7 +181,7 @@ std::basic_string<wchar_t> decompressGUID_wstr(const std::basic_string<wchar_t>&
result.resize(36);
return result;
}
std::basic_string<char> decompressGUID(const std::basic_string<char>& in)
std::string decompressGUID(const std::string& in)
{
static constexpr std::array<char, 16> base16Chars = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };

Expand All @@ -203,7 +203,7 @@ std::basic_string<char> decompressGUID(const std::basic_string<char>& in)
temp[ii_out] = '\0';

// add dashes: F103000C-9865-44EE-BE6E-CCC780B81423
std::basic_string<char> result;
std::string result;
for (size_t ii = 1; ii < 36; ++ii)
{
if (ii == 9 || ii == 13 || ii == 17 || ii == 21)
Expand All @@ -222,15 +222,15 @@ std::basic_string<char> decompressGUID(const std::basic_string<char>& in)
///@details Use desired character type as template parameter - char or wchar_t.
///IFC uses a different base64 character set than RFC4648 - it starts with digits
///instead of uppercase letters and uses '_' and '$' as last two characters.
std::basic_string<wchar_t> createBase64Uuid_wstr()
std::wstring createBase64Uuid_wstr()
{
std::basic_string<wchar_t> guid_uncompressed = createGUID32_wstr();
std::basic_string<wchar_t> guid_compressed = compressGUID_wstr(guid_uncompressed);
std::wstring guid_uncompressed = createGUID32_wstr();
std::wstring guid_compressed = compressGUID_wstr(guid_uncompressed);
return guid_compressed;
}
std::basic_string<char> createBase64Uuid()
std::string createBase64Uuid()
{
std::basic_string<char> guid_uncompressed = createGUID32();
std::basic_string<char> guid_compressed = compressGUID(guid_uncompressed);
std::string guid_uncompressed = createGUID32();
std::string guid_compressed = compressGUID(guid_uncompressed);
return guid_compressed;
}
17 changes: 9 additions & 8 deletions IfcPlusPlus/src/ifcpp/model/BuildingGuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#include "GlobalDefines.h"

///@brief Creates a GUID string with 36 characters including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
IFCQUERY_EXPORT std::basic_string<wchar_t> createGUID32_wstr();
IFCQUERY_EXPORT std::basic_string<char> createGUID32();
///@details These functions are non-template on purpose, to keep it simple and stupid, and to reduce compile time
IFCQUERY_EXPORT std::wstring createGUID32_wstr();
IFCQUERY_EXPORT std::string createGUID32();

///@brief Compresses a GUID string
///@details Expects a string with exactly 36 characters including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
///@returns an IFC GUID string with 22 characters, for example: "3n0m0Cc6L4xhvkpCU0k1GZ"
IFCQUERY_EXPORT std::basic_string<wchar_t> compressGUID_wstr(const std::basic_string<wchar_t>& in);
IFCQUERY_EXPORT std::basic_string<char> compressGUID(const std::basic_string<char>& in);
IFCQUERY_EXPORT std::wstring compressGUID_wstr(const std::wstring& in);
IFCQUERY_EXPORT std::string compressGUID(const std::string& in);

///@brief Decompresses an IFC GUID string
///@details Expects a string with exactly 22 characters, for example "3n0m0Cc6L4xhvkpCU0k1GZ"
///@returns GUID string with 36 characters, including dashes, for example: "F103000C-9865-44EE-BE6E-CCC780B81423"
IFCQUERY_EXPORT std::basic_string<wchar_t> decompressGUID_wstr(const std::basic_string<wchar_t>& in);
IFCQUERY_EXPORT std::basic_string<char> decompressGUID(const std::basic_string<char>& in);
IFCQUERY_EXPORT std::wstring decompressGUID_wstr(const std::wstring& in);
IFCQUERY_EXPORT std::string decompressGUID(const std::string& in);


///@brief Create IFC GUID string with 22 characters, for example "3n0m0Cc6L4xhvkpCU0k1GZ"
///@details Use desired character type as template parameter - char or wchar_t.
///IFC uses a different base64 character set than RFC4648 - it starts with digits
///instead of uppercase letters and uses '_' and '$' as last two characters.
IFCQUERY_EXPORT std::basic_string<wchar_t> createBase64Uuid_wstr();
IFCQUERY_EXPORT std::basic_string<char> createBase64Uuid();
IFCQUERY_EXPORT std::wstring createBase64Uuid_wstr();
IFCQUERY_EXPORT std::string createBase64Uuid();
1 change: 0 additions & 1 deletion IfcPlusPlus/src/ifcpp/model/BuildingModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#include <vector>
#include <map>
#include <string>
#include <boost/unordered_map.hpp>
#include "BasicTypes.h"
#include "StatusCallback.h"

Expand Down
12 changes: 6 additions & 6 deletions IfcPlusPlus/src/ifcpp/model/UnitConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <boost/algorithm/string.hpp>
#include "ifcpp/IFC4/include/IfcConversionBasedUnit.h"
#include "ifcpp/IFC4/include/IfcLabel.h"
#include "ifcpp/IFC4/include/IfcLengthMeasure.h"
Expand All @@ -34,6 +33,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
#include "ifcpp/IFC4/include/IfcUnitEnum.h"
#include "ifcpp/IFC4/include/IfcValue.h"

#include "ifcpp/reader/ReaderUtil.h"
#include "UnitConverter.h"

UnitConverter::UnitConverter()
Expand Down Expand Up @@ -215,22 +215,22 @@ void UnitConverter::setIfcProject( shared_ptr<IfcProject> project )
}
}

if( boost::iequals( conversion_based_unit->m_Name->m_value.c_str(), L"INCH" ) )
if( std_iequal( conversion_based_unit->m_Name->m_value.c_str(), L"INCH" ) )
{
m_length_unit_factor = 25.4*0.001; // 1 unit is 25.4 mm
m_length_unit_found = true;
}
else if( boost::iequals( conversion_based_unit->m_Name->m_value.c_str(), L"FOOT" ) )
else if( std_iequal( conversion_based_unit->m_Name->m_value.c_str(), L"FOOT" ) )
{
m_length_unit_factor = 304.8*0.001; // 1 unit is 304.8 mm
m_length_unit_found = true;
}
else if( boost::iequals( conversion_based_unit->m_Name->m_value.c_str(), L"YARD" ) )
else if( std_iequal( conversion_based_unit->m_Name->m_value.c_str(), L"YARD" ) )
{
m_length_unit_factor = 914*0.001; // 1 unit is 914 mm
m_length_unit_found = true;
}
else if( boost::iequals( conversion_based_unit->m_Name->m_value.c_str(), L"MILE" ) )
else if( std_iequal( conversion_based_unit->m_Name->m_value.c_str(), L"MILE" ) )
{
m_length_unit_factor = 1609*0.001; // 1 unit is 1609 mm
m_length_unit_found = true;
Expand All @@ -256,7 +256,7 @@ void UnitConverter::setIfcProject( shared_ptr<IfcProject> project )
}
else if( conversion_based_unit->m_Name )
{
if( boost::iequals( conversion_based_unit->m_Name->m_value.c_str(), L"DEGREE" ) )
if( std_iequal( conversion_based_unit->m_Name->m_value.c_str(), L"DEGREE" ) )
{
m_angular_unit = DEGREE;
m_plane_angle_factor = M_PI / 180.0;
Expand Down
6 changes: 3 additions & 3 deletions IfcPlusPlus/src/ifcpp/reader/ReaderSTEP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ void ReaderSTEP::loadModelFromFile( const std::wstring& filePath, shared_ptr<Bui
}
std::wstring ext = filePath.substr(posDot + 1);

if( boost::iequals( ext, "ifc" ) )
if( std_iequal( ext, L"ifc" ) )
{
// ok, nothing to do here
}
else if( boost::iequals( ext, "ifcXML" ) )
else if( std_iequal( ext, L"ifcXML" ) )
{
// TODO: implement xml reader
messageCallback( "ifcXML not yet implemented", StatusCallback::MESSAGE_TYPE_ERROR, __FUNC__ );
return;
}
else if( boost::iequals( ext, "ifcZIP" ) || boost::iequals(ext, "zip") )
else if( std_iequal( ext, L"ifcZIP" ) || std_iequal(ext, L"zip") )
{
std::string buffer;
unzipFile(filePath, buffer);
Expand Down
Loading

0 comments on commit b856027

Please sign in to comment.