Skip to content

Commit 036786f

Browse files
committed
fix bug in unicode decoding. fix bug in SimpleViewerExample
1 parent 4e8f2fd commit 036786f

File tree

6 files changed

+185
-147
lines changed

6 files changed

+185
-147
lines changed

IfcPlusPlus/src/ifcpp/geometry/GeometryConverter.h

+81-85
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GeometryConverter : public StatusCallback
5858

5959
std::map<std::string, shared_ptr<ProductShapeData> > m_product_shape_data;
6060
std::map<std::string, shared_ptr<BuildingObject> > m_map_outside_spatial_structure;
61-
std::set<std::string> m_setResolvedProjectStructure;
61+
std::set<int> m_setResolvedProjectStructure;
6262
vec3 m_siteOffset;
6363
double m_recent_progress = 0;
6464
std::map<int, std::vector<shared_ptr<StatusCallback::Message> > > m_messages;
@@ -225,7 +225,7 @@ class GeometryConverter : public StatusCallback
225225
}
226226

227227
#ifdef _DEBUG
228-
std::string className = IFC4X3::EntityFactory::getStringForClassID(ifc_object_def->classID());
228+
std::string className = IFC4X3::EntityFactory::getStringForClassID(ifc_object_def->classID());
229229
#endif
230230

231231
for( const weak_ptr<IfcRelAggregates>& relAggregates_weak_ptr : ifc_object_def->m_IsDecomposedBy_inverse )
@@ -243,33 +243,31 @@ class GeometryConverter : public StatusCallback
243243
const shared_ptr<IfcObjectDefinition>& related_obj_def = vec_related_objects[jj];
244244
if( related_obj_def )
245245
{
246-
std::string related_guid;
247-
if( related_obj_def->m_GlobalId )
246+
int tag = related_obj_def->m_tag;
247+
if( tag < 0 )
248248
{
249-
related_guid = related_obj_def->m_GlobalId->m_value;
250-
}
251-
252-
if( related_guid.size() < 20 )
253-
{
254-
std::cout << "guid invalid: " << related_guid << std::endl;
249+
std::cout << "invalid tag: " << tag << std::endl;
255250
continue;
256251
}
257252

258-
if( m_setResolvedProjectStructure.find(related_guid) != m_setResolvedProjectStructure.end() )
253+
if( m_setResolvedProjectStructure.find(tag) != m_setResolvedProjectStructure.end() )
259254
{
260255
continue;
261256
}
262-
m_setResolvedProjectStructure.insert(related_guid);
263-
257+
m_setResolvedProjectStructure.insert(tag);
264258

265-
auto it_product_map = m_product_shape_data.find(related_guid);
266-
if( it_product_map != m_product_shape_data.end() )
259+
if( related_obj_def->m_GlobalId )
267260
{
268-
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
269-
if( related_product_shape )
261+
std::string guid = related_obj_def->m_GlobalId->m_value;
262+
auto it_product_map = m_product_shape_data.find(guid);
263+
if( it_product_map != m_product_shape_data.end() )
270264
{
271-
product_data->addChildProduct(related_product_shape, product_data);
272-
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
265+
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
266+
if( related_product_shape )
267+
{
268+
product_data->addChildProduct(related_product_shape, product_data);
269+
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
270+
}
273271
}
274272
}
275273
}
@@ -298,41 +296,40 @@ class GeometryConverter : public StatusCallback
298296
const shared_ptr<IfcProduct>& related_product = vec_related_elements[jj];
299297
if( related_product )
300298
{
301-
std::string related_guid;
302-
if( related_product->m_GlobalId )
299+
int tag = related_product->m_tag;
300+
if( tag < 0 )
303301
{
304-
related_guid = related_product->m_GlobalId->m_value;
305-
}
306-
307-
if( related_guid.size() < 20 )
308-
{
309-
std::cout << "guid invalid: " << related_guid << std::endl;
302+
std::cout << "tag invalid: " << tag << std::endl;
310303
continue;
311304
}
312305

313-
if( m_setResolvedProjectStructure.find(related_guid) != m_setResolvedProjectStructure.end() )
306+
if( m_setResolvedProjectStructure.find(tag) != m_setResolvedProjectStructure.end() )
314307
{
315-
//std::cout << "duplicate guid in model tree: " << related_guid << std::endl;
316308
continue;
317309
}
318-
m_setResolvedProjectStructure.insert(related_guid);
310+
m_setResolvedProjectStructure.insert(tag);
319311

320-
auto it_product_map = m_product_shape_data.find(related_guid);
321-
if( it_product_map != m_product_shape_data.end() )
312+
if( related_product->m_GlobalId )
322313
{
323-
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
324-
if( related_product_shape )
314+
std::string related_guid = related_product->m_GlobalId->m_value;
315+
316+
auto it_product_map = m_product_shape_data.find(related_guid);
317+
if( it_product_map != m_product_shape_data.end() )
325318
{
326-
product_data->addChildProduct(related_product_shape, product_data);
327-
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
319+
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
320+
if( related_product_shape )
321+
{
322+
product_data->addChildProduct(related_product_shape, product_data);
323+
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
324+
}
328325
}
329326
}
330327
}
331328
}
332329
}
333330
}
334331
}
335-
332+
336333
if( resolveSecondaryStructure )
337334
{
338335
// handle IfcRelAssigns
@@ -373,33 +370,33 @@ class GeometryConverter : public StatusCallback
373370

374371
for( auto related_object : groupedBy->m_RelatedObjects )
375372
{
376-
std::string related_guid;
377-
if( related_object->m_GlobalId )
373+
int tag = related_object->m_tag;
374+
if( tag < 0 )
378375
{
379-
related_guid = related_object->m_GlobalId->m_value;
380-
}
381-
382-
if( related_guid.size() < 20 )
383-
{
384-
std::cout << "guid invalid: " << related_guid << std::endl;
376+
std::cout << "tag invalid: " << tag << std::endl;
385377
continue;
386378
}
387379

388-
if( m_setResolvedProjectStructure.find(related_guid) != m_setResolvedProjectStructure.end() )
380+
if( m_setResolvedProjectStructure.find(tag) != m_setResolvedProjectStructure.end() )
389381
{
390382
// std::cout << "duplicate guid in model tree: " << related_guid << std::endl;
391383
continue;
392384
}
393-
m_setResolvedProjectStructure.insert(related_guid);
385+
m_setResolvedProjectStructure.insert(tag);
394386

395-
auto it_product_map = m_product_shape_data.find(related_guid);
396-
if( it_product_map != m_product_shape_data.end() )
387+
if( related_object->m_GlobalId )
397388
{
398-
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
399-
if( related_product_shape )
389+
std::string related_guid = related_object->m_GlobalId->m_value;
390+
391+
auto it_product_map = m_product_shape_data.find(related_guid);
392+
if( it_product_map != m_product_shape_data.end() )
400393
{
401-
product_data->addChildProduct(related_product_shape, product_data);
402-
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
394+
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
395+
if( related_product_shape )
396+
{
397+
product_data->addChildProduct(related_product_shape, product_data);
398+
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
399+
}
403400
}
404401
}
405402
}
@@ -434,33 +431,33 @@ class GeometryConverter : public StatusCallback
434431
//shared_ptr<IfcPort> m_RelatingPort;
435432
//shared_ptr<IfcDistributionElement> m_RelatedElement;
436433

437-
std::string related_guid;
438-
if( related_object->m_GlobalId )
439-
{
440-
related_guid = related_object->m_GlobalId->m_value;
441-
}
434+
int tag = related_object->m_tag;
442435

443-
if( related_guid.size() < 20 )
436+
if( tag < 0 )
444437
{
445-
std::cout << "guid invalid: " << related_guid << std::endl;
438+
std::cout << "tag invalid: " << tag << std::endl;
446439
continue;
447440
}
448441

449-
if( m_setResolvedProjectStructure.find(related_guid) != m_setResolvedProjectStructure.end() )
442+
if( m_setResolvedProjectStructure.find(tag) != m_setResolvedProjectStructure.end() )
450443
{
451444
// std::cout << "duplicate guid in model tree: " << related_guid << std::endl;
452445
continue;
453446
}
454-
m_setResolvedProjectStructure.insert(related_guid);
447+
m_setResolvedProjectStructure.insert(tag);
455448

456-
auto it_product_map = m_product_shape_data.find(related_guid);
457-
if( it_product_map != m_product_shape_data.end() )
449+
if( related_object->m_GlobalId )
458450
{
459-
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
460-
if( related_product_shape )
451+
std::string related_guid = related_object->m_GlobalId->m_value;
452+
auto it_product_map = m_product_shape_data.find(related_guid);
453+
if( it_product_map != m_product_shape_data.end() )
461454
{
462-
product_data->addChildProduct(related_product_shape, product_data);
463-
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
455+
shared_ptr<ProductShapeData>& related_product_shape = it_product_map->second;
456+
if( related_product_shape )
457+
{
458+
product_data->addChildProduct(related_product_shape, product_data);
459+
resolveProjectStructure(related_product_shape, resolveSecondaryStructure);
460+
}
464461
}
465462
}
466463
}
@@ -476,10 +473,9 @@ class GeometryConverter : public StatusCallback
476473
std::map<std::string, shared_ptr<ProductShapeData> >& map_shapeInputData = getShapeInputData();
477474
shared_ptr<BuildingModel> ifc_model = getBuildingModel();
478475
shared_ptr<IfcProject> ifc_project = ifc_model->getIfcProject();
479-
shared_ptr<IfcSite> ifc_site;
480-
476+
std::vector<shared_ptr<IfcSite> > vec_ifc_sites;
481477
std::vector<shared_ptr<ProductShapeData> > vec_ifc_buildings;
482-
478+
483479
for( auto it : map_shapeInputData )
484480
{
485481
std::string guid = it.first;
@@ -511,7 +507,7 @@ class GeometryConverter : public StatusCallback
511507
shared_ptr<IfcSite> site = dynamic_pointer_cast<IfcSite>(ifc_object_definition);
512508
if( site )
513509
{
514-
ifc_site = site;
510+
vec_ifc_sites.push_back( site );
515511
continue;
516512
}
517513
}
@@ -528,7 +524,7 @@ class GeometryConverter : public StatusCallback
528524
}
529525

530526
// if IfcBuilding is not connected to IfcSite and IfcProject, find IfcSite, and connect it
531-
if( ifc_site )
527+
for( auto ifc_site : vec_ifc_sites )
532528
{
533529
for( auto product_shape_building : vec_ifc_buildings )
534530
{
@@ -830,7 +826,7 @@ class GeometryConverter : public StatusCallback
830826
} // implicit barrier
831827
#endif
832828

833-
// subtract openings in related objects, such as IFCBUILDINGELEMENTPART connected to a window through IFCRELAGGREGATES
829+
// subtract openings in related objects, such as IFCBUILDINGELEMENTPART connected to a window through IFCRELAGGREGATES
834830
for( auto it = map_products_ptr->begin(); it != map_products_ptr->end(); ++it )
835831
{
836832
shared_ptr<ProductShapeData> product_geom_input_data = it->second;
@@ -883,13 +879,13 @@ class GeometryConverter : public StatusCallback
883879
if( !product_shape->m_ifc_object_definition.expired() )
884880
{
885881
shared_ptr<IfcObjectDefinition> ifc_object_def( product_shape->m_ifc_object_definition );
886-
887-
if( !m_geom_settings->skipRenderObject(ifc_object_def->classID()) )
882+
883+
if( m_geom_settings->skipRenderObject(ifc_object_def->classID()) )
888884
{
889885
continue;
890886
}
891887
std::string guid;
892-
888+
893889
if (ifc_object_def->m_GlobalId)
894890
{
895891
guid = ifc_object_def->m_GlobalId->m_value;
@@ -1068,7 +1064,7 @@ class GeometryConverter : public StatusCallback
10681064
if( enableCaching )
10691065
{
10701066
bool equalItemFound = false;
1071-
1067+
10721068
for( auto it : m_product_shape_data )
10731069
{
10741070
const shared_ptr<ProductShapeData>& existingProductShape = it.second;
@@ -1091,14 +1087,14 @@ class GeometryConverter : public StatusCallback
10911087
}
10921088
if( !equalItemFound )
10931089
{
1094-
// representation_data->m_vec_item_data.push_back(geom_item_data);
1095-
//#ifdef _OPENMP
1096-
// ScopedLock lock( m_writelock_item_cache );
1097-
//#endif
1098-
// m_map_item_data_cache.push_back(geom_item_data);
1090+
// representation_data->m_vec_item_data.push_back(geom_item_data);
1091+
//#ifdef _OPENMP
1092+
// ScopedLock lock( m_writelock_item_cache );
1093+
//#endif
1094+
// m_map_item_data_cache.push_back(geom_item_data);
10991095
}
11001096
}
1101-
1097+
11021098
if( m_clear_memory_immedeately )
11031099
{
11041100
ifc_product->m_Representation.reset();
@@ -1186,7 +1182,7 @@ class GeometryConverter : public StatusCallback
11861182
if (related_object->m_GlobalId)
11871183
{
11881184
guid = related_object->m_GlobalId->m_value;
1189-
1185+
11901186
auto it_find_related_shape = m_product_shape_data.find(guid);
11911187
if( it_find_related_shape != m_product_shape_data.end() )
11921188
{

0 commit comments

Comments
 (0)