Skip to content

Commit eff53bd

Browse files
ReaderWriterIFC::getObjectsOutsideSpatialStructure
updated CMakeLists.txt IfcMappedItem - overwrite StyledItem
1 parent a6186b9 commit eff53bd

15 files changed

+226
-134
lines changed

Carve/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ if(Boost_FOUND)
3232
include_directories(${Boost_INCLUDE_DIRS})
3333
message(STATUS "Using Boost libraries for Carve")
3434
else(Boost_FOUND)
35-
message(STATUS "Could not find Boost libraries for Carve")
35+
message(FATAL_ERROR "Could not find Boost libraries for Carve")
3636
endif(Boost_FOUND)
37+
add_definitions(-DCARVE_SYSTEM_BOOST)
38+
3739

3840
set(CARVE_HEADER_FILES
3941
src/common/geometry.hpp

IfcPlusPlus.v11.suo

0 Bytes
Binary file not shown.

IfcPlusPlus/CMakeLists.txt

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
cmake_minimum_required (VERSION 2.8)
22

3-
43
IF(NOT CMAKE_BUILD_TYPE)
54
SET(CMAKE_BUILD_TYPE "Release")
65
ENDIF(NOT CMAKE_BUILD_TYPE)
@@ -17,8 +16,9 @@ if(Boost_FOUND)
1716
include_directories(${Boost_INCLUDE_DIRS})
1817
message(STATUS "Using Boost libraries")
1918
else(Boost_FOUND)
20-
message(STATUS "Could not find Boost libraries")
19+
message(FATAL_ERROR "Could not find Boost libraries")
2120
endif(Boost_FOUND)
21+
add_definitions(-DCARVE_SYSTEM_BOOST)
2222

2323
# Carve library
2424
message(STATUS "IfcPlusPlus: directories of Carve")
@@ -30,13 +30,11 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CARVE_SOURCE_DIR}/src)
3030
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CARVE_SOURCE_DIR}/src/common)
3131
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CARVE_SOURCE_DIR}/src/include)
3232
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CARVE_BINARY_DIR}/include) # For the generated Config file
33-
3433
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} src/)
3534

3635
LINK_DIRECTORIES (${LINK_DIRECTORIES} ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
3736

3837
file (GLOB ifc4_headers "src/ifcpp/IFC4/include/*.h")
39-
4038
file (GLOB ifc4_source "src/ifcpp/IFC4/*.cpp")
4139

4240
set(IFCPP_HEADER_FILES
@@ -68,7 +66,6 @@ set(IFCPP_HEADER_FILES
6866
src/ifcpp/xml/XmlTools.h
6967

7068
${ifc4_headers}
71-
7269
)
7370

7471
set(IFCPP_SOURCE_FILES

IfcPlusPlusGeometry/CMakeLists.txt

+12-11
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ if(Boost_FOUND)
5252
include_directories(${Boost_INCLUDE_DIRS})
5353
message(STATUS "Using Boost libraries for Carve")
5454
else(Boost_FOUND)
55-
message(STATUS "Could not find Boost libraries for Carve")
55+
message(FATAL_ERROR "Could not find Boost libraries for Carve")
5656
endif(Boost_FOUND)
57+
add_definitions(-DCARVE_SYSTEM_BOOST)
5758

5859
# Carve library
5960
message(STATUS "IfcPlusPlusGeometry: directories of Carve")
@@ -86,15 +87,15 @@ LINK_DIRECTORIES (${LINK_DIRECTORIES} ${CARVE_BINARY_DIR}/common)
8687

8788
ADD_LIBRARY(IfcPlusPlusGeometry SHARED ${IFCPPGEOMETRY_HEADER_FILES} ${IFCPPGEOMETRY_SOURCE_FILES})
8889

89-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry carve carve_misc)
90-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry IfcPlusPlus)
91-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OPENTHREADS_LIBRARY} )
92-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSG_LIBRARY} )
93-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGDB_LIBRARY} )
94-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGUTIL_LIBRARY} )
95-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGANIMATION_LIBRARY} )
96-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGFX_LIBRARY} )
97-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGTEXT_LIBRARY} )
98-
TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGVIEWER_LIBRARY} )
90+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry carve carve_misc)
91+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry IfcPlusPlus)
92+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OPENTHREADS_LIBRARY} )
93+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSG_LIBRARY} )
94+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGDB_LIBRARY} )
95+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGUTIL_LIBRARY} )
96+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGANIMATION_LIBRARY} )
97+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGFX_LIBRARY} )
98+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGTEXT_LIBRARY} )
99+
#TARGET_LINK_LIBRARIES( IfcPlusPlusGeometry ${OSGVIEWER_LIBRARY} )
99100

100101
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

IfcPlusPlusGeometry/src/ifcppgeometry/ConverterOSG.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ void AppearanceManagerOSG::clearAppearanceCache()
615615
global_vec_existing_statesets.clear();
616616
}
617617

618-
osg::StateSet* AppearanceManagerOSG::convertToStateSet( shared_ptr<AppearanceData>& appearence )
618+
osg::StateSet* AppearanceManagerOSG::convertToStateSet( const shared_ptr<AppearanceData>& appearence )
619619
{
620620
if( !appearence )
621621
{

IfcPlusPlusGeometry/src/ifcppgeometry/ConverterOSG.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class ConverterOSG
3535
class AppearanceManagerOSG
3636
{
3737
public:
38-
//AppearanceManagerOSG();
39-
//~AppearanceManagerOSG();
4038
static void clearAppearanceCache();
41-
static osg::StateSet* convertToStateSet( shared_ptr<AppearanceData>& appearence );
39+
static osg::StateSet* convertToStateSet( const shared_ptr<AppearanceData>& appearence );
4240

4341
};

IfcPlusPlusGeometry/src/ifcppgeometry/GeometryInputData.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ shared_ptr<ItemData> ItemData::getDeepCopy()
196196
void ShapeInputData::addInputData( shared_ptr<ShapeInputData>& other )
197197
{
198198
std::copy( other->vec_item_data.begin(), other->vec_item_data.end(), std::back_inserter( vec_item_data ) );
199-
std::copy( other->vec_appearances.begin(), other->vec_appearances.end(), std::back_inserter( vec_appearances ) );
199+
std::copy( other->getAppearances().begin(), other->getAppearances().end(), std::back_inserter( vec_appearances ) );
200200
}
201201

202202
void ShapeInputData::deepCopyFrom( shared_ptr<ShapeInputData>& other )
@@ -213,6 +213,28 @@ void ShapeInputData::deepCopyFrom( shared_ptr<ShapeInputData>& other )
213213
//addInputData( other );
214214
}
215215

216+
void ShapeInputData::addAppearance( shared_ptr<AppearanceData>& appearance )
217+
{
218+
if( !appearance )
219+
{
220+
return;
221+
}
222+
int append_id = appearance->m_step_stype_id;
223+
for( size_t ii = 0; ii < vec_appearances.size(); ++ii )
224+
{
225+
shared_ptr<AppearanceData>& appearance = vec_appearances[ii];
226+
if( appearance->m_step_stype_id == append_id )
227+
{
228+
return;
229+
}
230+
}
231+
vec_appearances.push_back( appearance );
232+
}
233+
void ShapeInputData::clearAppearanceData()
234+
{
235+
vec_appearances.clear();
236+
}
237+
216238
// PolyInputCache
217239
PolyInputCache3D::PolyInputCache3D()
218240
{

IfcPlusPlusGeometry/src/ifcppgeometry/GeometryInputData.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,27 @@ class TextItemData
3333
class AppearanceData
3434
{
3535
public:
36-
AppearanceData()
36+
enum GeometryTypeEnum { UNDEFINED, TEXT, CURVE, SURFACE, VOLUME };
37+
AppearanceData( int step_style_id ) : m_step_stype_id( step_style_id )
3738
{
3839
set_transparent = false;
3940
shininess = 10.f;
4041
transparency = 1.f;
4142
specular_exponent = 0.f;
4243
specular_roughness = 0.f;
44+
apply_to_geometry_type = UNDEFINED;
4345
}
4446
carve::geom::vector<4> color_ambient;
4547
carve::geom::vector<4> color_diffuse;
4648
carve::geom::vector<4> color_specular;
49+
int m_step_stype_id;
4750
float shininess;
4851
float transparency;
4952
float specular_exponent;
5053
float specular_roughness;
5154
bool set_transparent;
5255
shared_ptr<IfcTextStyle> text_style;
56+
GeometryTypeEnum apply_to_geometry_type;
5357
};
5458

5559
//\brief Class to hold input data of one IFC geometric representation item.
@@ -90,17 +94,23 @@ class ShapeInputData
9094

9195
void addInputData( shared_ptr<ShapeInputData>& other );
9296
void deepCopyFrom( shared_ptr<ShapeInputData>& other );
97+
const std::vector<shared_ptr<AppearanceData> >& getAppearances() { return vec_appearances; }
98+
void addAppearance( shared_ptr<AppearanceData>& appearance );
99+
void clearAppearanceData();
93100

94101
shared_ptr<IfcProduct> ifc_product;
95102
shared_ptr<IfcRepresentation> representation;
96103
shared_ptr<IfcObjectPlacement> object_placement;
97104
osg::ref_ptr<osg::Switch> product_switch;
105+
osg::ref_ptr<osg::Switch> product_switch_curves;
98106
osg::ref_ptr<osg::Switch> space_switch;
99107
//std::vector<shared_ptr<IfcProduct> > vec_openings;
100108

101109
std::vector<shared_ptr<ItemData> > vec_item_data;
102-
std::vector<shared_ptr<AppearanceData> > vec_appearances;
103110
bool added_to_storey;
111+
112+
protected:
113+
std::vector<shared_ptr<AppearanceData> > vec_appearances;
104114
};
105115

106116
class PolyInputCache3D

IfcPlusPlusGeometry/src/ifcppgeometry/ReaderWriterIFC.cpp

+49-16
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ void ReaderWriterIFC::resetModel()
102102
m_messages.str(std::string());
103103

104104
deleteInputCache();
105-
//m_processed_products.clear();
105+
m_map_visited.clear();
106+
m_map_outside_spatial_structure.clear();
106107
AppearanceManagerOSG::clearAppearanceCache();
107108

108109
m_group_result->removeChildren( 0, m_group_result->getNumChildren() );
@@ -275,6 +276,7 @@ void ReaderWriterIFC::createGeometry()
275276
}
276277

277278
m_shape_input_data.clear();
279+
m_map_outside_spatial_structure.clear();
278280
m_representation_converter->getProfileCache()->clearProfileCache();
279281

280282
std::vector<shared_ptr<IfcProduct> > vec_products;
@@ -419,6 +421,7 @@ void ReaderWriterIFC::createGeometry()
419421
group_outside_spatial_structure->addChild( product_switch );
420422
}
421423
product_shape->added_to_storey = true;
424+
m_map_outside_spatial_structure.insert( std::make_pair( ifc_product->getId(), ifc_product ) );
422425
}
423426
}
424427
}
@@ -579,6 +582,7 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
579582
const int product_id = product->getId();
580583
std::stringstream strs_err;
581584
osg::ref_ptr<osg::Switch> product_switch = new osg::Switch();
585+
osg::ref_ptr<osg::Switch> product_switch_curves = new osg::Switch();
582586
std::stringstream group_name;
583587
group_name << "#" << product_id << "=IfcProduct group";
584588
product_switch->setName( group_name.str().c_str() );
@@ -626,6 +630,7 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
626630
{
627631
shared_ptr<ItemData> item_data = product_items[i_item];
628632
osg::Group* item_group = new osg::Group();
633+
osg::Group* item_group_curves = new osg::Group();
629634

630635
// create shape for open shells
631636
for( int i=0; i<item_data->open_polyhedrons.size(); ++i )
@@ -679,7 +684,7 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
679684
shared_ptr<carve::input::PolylineSetData>& polyline_data = item_data->polylines[polyline_i];
680685
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
681686
ConverterOSG::drawPolyline( polyline_data.get(), geode );
682-
item_group->addChild(geode);
687+
item_group_curves->addChild(geode);
683688
}
684689

685690
if( m_geom_settings->m_show_text_literals )
@@ -717,23 +722,46 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
717722
for( int i_appearance=0; i_appearance<item_data->vec_item_appearances.size(); ++i_appearance )
718723
{
719724
shared_ptr<AppearanceData>& appearance = item_data->vec_item_appearances[i_appearance];
720-
721-
osg::StateSet* item_stateset = AppearanceManagerOSG::convertToStateSet( appearance );
722-
if( item_stateset != nullptr )
725+
if( appearance->apply_to_geometry_type == AppearanceData::SURFACE )
723726
{
724-
item_group->setStateSet( item_stateset );
727+
osg::StateSet* item_stateset = AppearanceManagerOSG::convertToStateSet( appearance );
728+
if( item_stateset != nullptr )
729+
{
730+
item_group->setStateSet( item_stateset );
725731

726-
osg::StateSet* existing_item_stateset = item_group->getStateSet();
732+
osg::StateSet* existing_item_stateset = item_group->getStateSet();
727733

728-
if( existing_item_stateset )
729-
{
730-
osg::StateSet* merged_product_stateset = new osg::StateSet( *existing_item_stateset );
731-
merged_product_stateset->merge( *item_stateset );
732-
item_group->setStateSet( merged_product_stateset );
734+
if( existing_item_stateset )
735+
{
736+
osg::StateSet* merged_product_stateset = new osg::StateSet( *existing_item_stateset );
737+
merged_product_stateset->merge( *item_stateset );
738+
item_group->setStateSet( merged_product_stateset );
739+
}
740+
else
741+
{
742+
item_group->setStateSet( item_stateset );
743+
}
733744
}
734-
else
745+
else if( appearance->apply_to_geometry_type == AppearanceData::CURVE )
735746
{
736-
item_group->setStateSet( item_stateset );
747+
osg::StateSet* item_stateset = AppearanceManagerOSG::convertToStateSet( appearance );
748+
if( item_stateset != nullptr )
749+
{
750+
item_group->setStateSet( item_stateset );
751+
752+
osg::StateSet* existing_item_stateset = item_group->getStateSet();
753+
754+
if( existing_item_stateset )
755+
{
756+
osg::StateSet* merged_product_stateset = new osg::StateSet( *existing_item_stateset );
757+
merged_product_stateset->merge( *item_stateset );
758+
item_group->setStateSet( merged_product_stateset );
759+
}
760+
else
761+
{
762+
item_group_curves->setStateSet( item_stateset );
763+
}
764+
}
737765
}
738766
}
739767
}
@@ -812,9 +840,9 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
812840
// }
813841
//}
814842

815-
for( int i=0; i<product_shape->vec_appearances.size(); ++i )
843+
for( int i=0; i<product_shape->getAppearances().size(); ++i )
816844
{
817-
shared_ptr<AppearanceData>& appearance = product_shape->vec_appearances[i];
845+
const shared_ptr<AppearanceData>& appearance = product_shape->getAppearances()[i];
818846
if( !appearance )
819847
{
820848
continue;
@@ -861,6 +889,11 @@ void ReaderWriterIFC::convertIfcProduct( const shared_ptr<IfcProduct>& product,
861889
product_shape->product_switch = product_switch;
862890
}
863891

892+
if( product_switch_curves->getNumChildren() > 0 )
893+
{
894+
product_shape->product_switch_curves = product_switch_curves;
895+
}
896+
864897
if( strs_err.tellp() > 0 )
865898
{
866899
throw IfcPPException( strs_err.str().c_str(), __func__ );

IfcPlusPlusGeometry/src/ifcppgeometry/ReaderWriterIFC.h

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ReaderWriterIFC : public osgDB::ReaderWriter, public StatusObservable
5353
shared_ptr<IfcStepWriter>& getIfcPPWriter() { return m_step_writer; }
5454
shared_ptr<RepresentationConverter>& getRepresentationConverter() { return m_representation_converter; }
5555
std::map<int,shared_ptr<ShapeInputData> >& getShapeInputData() { return m_shape_input_data; }
56+
std::map<int,shared_ptr<IfcPPObject> >& getObjectsOutsideSpatialStructure() { return m_map_outside_spatial_structure; }
5657
shared_ptr<UnitConverter>& getUnitConverter() { return m_unit_converter; }
5758

5859
std::stringstream& getErrors() { return m_err; }
@@ -82,6 +83,7 @@ class ReaderWriterIFC : public osgDB::ReaderWriter, public StatusObservable
8283

8384
std::map<int, shared_ptr<ShapeInputData> > m_shape_input_data;
8485
std::map<int, shared_ptr<IfcPPObject> > m_map_visited;
86+
std::map<int, shared_ptr<IfcPPObject> > m_map_outside_spatial_structure;
8587
osg::ref_ptr<osg::Group> m_group_result;
8688
double m_recent_progress;
8789
};

0 commit comments

Comments
 (0)