Skip to content

Commit 006e09e

Browse files
Fix MSVC compile issue (#19)
1 parent e00da37 commit 006e09e

11 files changed

+32
-46
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_definitions( -DIFCQUERY_STATIC_LIB )
77

88
add_definitions( -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS )
99
add_definitions( -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS )
10+
add_definitions( -D_USE_MATH_DEFINES )
1011

1112
file( GLOB_RECURSE IFC_HEADERS include/ifcpp/Ifc *.h )
1213

@@ -64,6 +65,7 @@ endif()
6465

6566
add_library( ${PROJECT_NAME} INTERFACE )
6667
target_link_libraries( ${PROJECT_NAME} INTERFACE ifcpp_lib )
68+
target_compile_definitions( ${PROJECT_NAME} INTERFACE -D_USE_MATH_DEFINES )
6769

6870
find_package( OpenMP )
6971
if( OpenMP_CXX_FOUND )

include/ifcpp/Geometry/CurveConverter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <map>
4+
#include <cmath>
45

56
#include "ifcpp/Model/OpenMPIncludes.h"
67

include/ifcpp/Geometry/GeomUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#define _USE_MATH_DEFINES
43
#include <cmath>
54

65
#include <limits>

include/ifcpp/Geometry/ProfileConverter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <map>
44
#include <vector>
5+
#include <cmath>
56

67
#include "ifcpp/Model/OpenMPIncludes.h"
78

include/ifcpp/Model/StatusCallback.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ class BuildingEntity;
3131
class IFCQUERY_EXPORT StatusCallback {
3232
public:
3333
enum MessageType {
34-
PROGRESS_CHANGED,
35-
INFO,
36-
WARNING,
37-
ERROR,
38-
UNKNOWN,
34+
ProgressChanged,
35+
Info,
36+
Warning,
37+
Error,
38+
Unknown,
3939
};
4040

4141
class Message {
4242
public:
43-
MessageType m_type = UNKNOWN;
43+
MessageType m_type = Unknown;
4444
std::string m_text;
4545
const char* m_function = "";
4646
std::weak_ptr<BuildingEntity> m_entity;
@@ -66,9 +66,9 @@ class IFCQUERY_EXPORT StatusCallback {
6666
}
6767

6868
//\brief trigger the callback to pass a message, warning, or error, for example to store in a logfile
69-
void SendMessage( const shared_ptr<Message>& m ) {
69+
void SendLogMessage( const shared_ptr<Message>& m ) {
7070
if( this->m_redirectTarget ) {
71-
this->m_redirectTarget->SendMessage( m );
71+
this->m_redirectTarget->SendLogMessage( m );
7272
return;
7373
}
7474

@@ -89,21 +89,21 @@ class IFCQUERY_EXPORT StatusCallback {
8989
return false;
9090
}
9191

92-
void SendMessage( const std::string& text, MessageType type, const char* function, const std::weak_ptr<BuildingEntity>& entity = {} ) {
92+
void SendLogMessage( const std::string& text, MessageType type, const char* function, const std::weak_ptr<BuildingEntity>& entity = {} ) {
9393
auto message = std::make_shared<Message>();
9494
message->m_text = text;
9595
message->m_type = type;
9696
message->m_function = function;
9797
message->m_entity = entity;
98-
this->SendMessage( message );
98+
this->SendLogMessage( message );
9999
}
100100

101101
void SendProgressChanged( double progress, const std::string& progressType ) {
102102
auto message = std::make_shared<Message>();
103-
message->m_type = MessageType::PROGRESS_CHANGED;
103+
message->m_type = MessageType::ProgressChanged;
104104
message->m_progress = progress;
105105
message->m_progressType = progressType;
106-
SendMessage( message );
106+
SendLogMessage( message );
107107
}
108108

109109
protected:

include/ifcpp/Model/UnitConverter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IFCQUERY_EXPORT UnitConverter : public StatusCallback
4242
{
4343
if( !m_length_unit_found )
4444
{
45-
SendMessage( "No length unit definition found in model", StatusCallback::WARNING, __FUNC__ );
45+
SendLogMessage( "No length unit definition found in model", StatusCallback::Warning, __FUNC__ );
4646
}
4747

4848
return m_length_unit_factor * m_custom_length_factor;
@@ -62,7 +62,7 @@ class IFCQUERY_EXPORT UnitConverter : public StatusCallback
6262
{
6363
if( m_angular_unit == UNDEFINED )
6464
{
65-
SendMessage( "No plane angle unit definition found in model", StatusCallback::WARNING, __FUNC__ );
65+
SendLogMessage( "No plane angle unit definition found in model", StatusCallback::Warning, __FUNC__ );
6666
}
6767
return m_plane_angle_factor;
6868
}

include/ifcpp/ModelLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ std::vector<typename TAdapter::TEntity> LoadModel( const std::string& filePath,
1515
const std::function<void( double )>& onProgressChanged, const std::atomic<bool>& isCancellationRequest = false ) {
1616

1717
auto readerMessageCallback = [ onProgressChanged ]( const std::shared_ptr<StatusCallback::Message>& message ) {
18-
if( message->m_type == StatusCallback::PROGRESS_CHANGED ) {
18+
if( message->m_type == StatusCallback::ProgressChanged ) {
1919
onProgressChanged( message->m_progress * 0.5 );
2020
}
2121
};

src/Model/BuildingModel.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void BuildingModel::insertEntity( shared_ptr<BuildingEntity> e, bool overwrite_e
322322
{
323323
if( warn_on_existing_entities )
324324
{
325-
this->SendMessage( "Entity already in model", StatusCallback::WARNING, __FUNC__, e );
325+
this->SendLogMessage( "Entity already in model", StatusCallback::Warning, __FUNC__, e );
326326
}
327327
}
328328
}
@@ -331,21 +331,6 @@ void BuildingModel::insertEntity( shared_ptr<BuildingEntity> e, bool overwrite_e
331331
// the key does not exist in the map
332332
m_map_entities.insert( it_find, std::map<int, shared_ptr<BuildingEntity> >::value_type( tag, e ) );
333333
}
334-
#ifdef _DEBUG
335-
shared_ptr<IfcProduct> product = dynamic_pointer_cast<IfcProduct>( e );
336-
if( product )
337-
{
338-
if( !product->m_GlobalId )
339-
{
340-
this->SendMessage( "IfcProduct->m_GlobalId not set", StatusCallback::MESSAGE_TYPE_WARNING, __FUNC__, product.get() );
341-
return;
342-
}
343-
if( product->m_GlobalId->m_value.length() < 22 )
344-
{
345-
this->SendMessage( "IfcProduct->m_GlobalId.length() < 22", StatusCallback::MESSAGE_TYPE_WARNING, __FUNC__, product.get() );
346-
}
347-
}
348-
#endif
349334

350335
// TODO: if type is IfcRoot (or subtype), and GlobalID not set, create one
351336
}
@@ -354,14 +339,14 @@ void BuildingModel::removeEntity( shared_ptr<BuildingEntity> e )
354339
{
355340
if( !e )
356341
{
357-
this->SendMessage( "Entity not valid", StatusCallback::WARNING, __FUNC__, e );
342+
this->SendLogMessage( "Entity not valid", StatusCallback::Warning, __FUNC__, e );
358343
return;
359344
}
360345
int remove_id = e->m_tag;
361346
auto it_find = m_map_entities.find(remove_id);
362347
if( it_find == m_map_entities.end() )
363348
{
364-
this->SendMessage( "Entity not found in model", StatusCallback::WARNING, __FUNC__, e );
349+
this->SendLogMessage( "Entity not found in model", StatusCallback::Warning, __FUNC__, e );
365350
return;
366351
}
367352
shared_ptr<BuildingEntity> entity_found = it_find->second;
@@ -585,7 +570,7 @@ void BuildingModel::updateCache()
585570
{
586571
if( m_ifc_project )
587572
{
588-
this->SendMessage("More than one IfcProject in model", StatusCallback::ERROR, __FUNC__, m_ifc_project);
573+
this->SendLogMessage("More than one IfcProject in model", StatusCallback::Error, __FUNC__, m_ifc_project);
589574
}
590575
m_ifc_project = dynamic_pointer_cast<IfcProject>(obj);
591576

src/Model/UnitConverter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTH
1515
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717

18-
#define _USE_MATH_DEFINES
1918
#include <cmath>
2019
#include <cstring>
2120
#include <ifcpp/Ifc/IfcConversionBasedUnit.h>
@@ -102,7 +101,7 @@ void UnitConverter::setAngleUnit(AngularUnit unit)
102101
}
103102
else
104103
{
105-
SendMessage( "Could not set angular unit", StatusCallback::WARNING, __FUNC__ );
104+
SendLogMessage( "Could not set angular unit", StatusCallback::Warning, __FUNC__ );
106105
}
107106
}
108107

@@ -112,7 +111,7 @@ void UnitConverter::setIfcProject( shared_ptr<IfcProject> project )
112111

113112
if( !project->m_UnitsInContext )
114113
{
115-
SendMessage( "IfcProject.UnitsInContext not defined", StatusCallback::WARNING, "" );
114+
SendLogMessage( "IfcProject.UnitsInContext not defined", StatusCallback::Warning, "" );
116115
return;
117116
}
118117

src/Reader/ReaderSTEP.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void ReaderSTEP::loadModelFromFile( const std::string& filePath, shared_ptr<Buil
127127
else if( std_iequal( ext, ".ifcXML" ) )
128128
{
129129
// TODO: implement xml reader
130-
this->SendMessage( "ifcXML not yet implemented", StatusCallback::ERROR, __FUNC__ );
130+
this->SendLogMessage( "ifcXML not yet implemented", StatusCallback::Error, __FUNC__ );
131131
return;
132132
}
133133
else if( std_iequal( ext, ".ifcZIP" ) || std_iequal(ext, ".zip") )
@@ -148,7 +148,7 @@ void ReaderSTEP::loadModelFromFile( const std::string& filePath, shared_ptr<Buil
148148
{
149149
std::stringstream strs;
150150
strs << "Unsupported file type: " << ext;
151-
this->SendMessage( strs.str(), StatusCallback::ERROR, __FUNC__ );
151+
this->SendLogMessage( strs.str(), StatusCallback::Error, __FUNC__ );
152152
return;
153153
}
154154

@@ -161,7 +161,7 @@ void ReaderSTEP::loadModelFromFile( const std::string& filePath, shared_ptr<Buil
161161
{
162162
std::stringstream strs;
163163
strs << "Could not open file: " << filePath.c_str();
164-
this->SendMessage( strs.str().c_str(), StatusCallback::ERROR, __FUNC__ );
164+
this->SendLogMessage( strs.str().c_str(), StatusCallback::Error, __FUNC__ );
165165
return;
166166
}
167167

@@ -487,7 +487,7 @@ void ReaderSTEP::readSingleStepLine( const std::string& line, std::pair<std::str
487487
{
488488
std::stringstream strs;
489489
strs << "Could not read STEP line: " << line.c_str();
490-
this->SendMessage( strs.str(), StatusCallback::ERROR, __FUNC__ );
490+
this->SendLogMessage( strs.str(), StatusCallback::Error, __FUNC__ );
491491
return;
492492
}
493493

@@ -760,7 +760,7 @@ void ReaderSTEP::readEntityArguments( std::vector<std::pair<std::string, shared_
760760

761761
if( err.tellp() > 0 )
762762
{
763-
this->SendMessage( err.str(), StatusCallback::ERROR, __FUNC__ );
763+
this->SendLogMessage( err.str(), StatusCallback::Error, __FUNC__ );
764764
}
765765
}
766766

@@ -774,7 +774,7 @@ void ReaderSTEP::readData( std::istream& read_in, std::streampos file_size, shar
774774
return;
775775
}
776776
std::string file_schema_version = model->getIfcSchemaVersionOfLoadedFile();
777-
this->SendMessage( std::string( "Detected IFC version: ") + file_schema_version, StatusCallback::INFO, "" );
777+
this->SendLogMessage( std::string( "Detected IFC version: ") + file_schema_version, StatusCallback::Info, "" );
778778

779779
size_t read_size = model->getFileHeader().size();
780780
std::stringstream err;
@@ -924,6 +924,6 @@ void ReaderSTEP::readData( std::istream& read_in, std::streampos file_size, shar
924924
setlocale(LC_NUMERIC,current_numeric_locale.c_str());
925925
if( err.tellp() > 0 )
926926
{
927-
this->SendMessage( err.str(), StatusCallback::ERROR, __FUNC__ );
927+
this->SendLogMessage( err.str(), StatusCallback::Error, __FUNC__ );
928928
}
929929
}

src/Reader/ReaderUtil.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Copyright (c) 2017 Fabian Gerold
1515
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616
*/
1717

18-
#define _USE_MATH_DEFINES
1918
#include <cmath>
2019
#include <iostream>
2120
#include <limits>

0 commit comments

Comments
 (0)