4646#include " ../ifcgeom/IfcGeom.h"
4747
4848// Welds vertices that belong to different faces
49- bool weld_vertices = false ;
49+ bool weld_vertices = true ;
5050
5151int IfcGeomObjects::IfcMesh::addvert (const gp_XYZ& p) {
5252 const float X = (float )p.X ();const float Y = (float )p.Y ();const float Z = (float )p.Z ();
@@ -93,9 +93,7 @@ IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) {
9393 if ( ! tri.IsNull () ) {
9494
9595 // A 3x3 matrix to rotate the vertex normals
96- const gp_Mat rotation_matrix = use_world_coords
97- ? trsf.VectorialPart () * loc.Transformation ().VectorialPart ()
98- : loc.Transformation ().VectorialPart ();
96+ const gp_Mat rotation_matrix = trsf.VectorialPart ();
9997
10098 // Keep track of the number of times an edge is used
10199 // Manifold edges (i.e. edges used twice) are deemed invisible
@@ -431,14 +429,10 @@ const IfcGeomObjects::IfcObject* IfcGeomObjects::GetObject(int id) {
431429const IfcGeomObjects::IfcGeomObject* IfcGeomObjects::Get () {
432430 return current_geom_obj;
433431}
434- bool IfcGeomObjects::Init (const char * fn, bool world_coords ) {
435- return IfcGeomObjects::Init (fn, world_coords, 0 , 0 );
432+ bool IfcGeomObjects::Init (const char * fn) {
433+ return IfcGeomObjects::Init (fn, 0 , 0 );
436434}
437- bool IfcGeomObjects::Init (const char * fn, bool world_coords, std::ostream* log1, std::ostream* log2) {
438- Ifc::SetOutput (log1,log2);
439- use_world_coords = world_coords;
440- if ( !Ifc::Init (fn) ) return false ;
441-
435+ bool _Init () {
442436 shapereps = Ifc::EntitiesByType<Ifc2x3::IfcShapeRepresentation>();
443437 if ( ! shapereps ) return false ;
444438
@@ -452,42 +446,30 @@ bool IfcGeomObjects::Init(const char* fn, bool world_coords, std::ostream* log1,
452446 total = shapereps->Size ();
453447 return true ;
454448}
455- bool IfcGeomObjects::Init (std::istream& f, int len, bool world_coords, std::ostream* log1, std::ostream* log2) {
449+ bool IfcGeomObjects::Init (const char * fn, std::ostream* log1, std::ostream* log2) {
450+ Ifc::SetOutput (log1,log2);
451+ if ( !Ifc::Init (fn) ) return false ;
452+ return _Init ();
453+ }
454+ bool IfcGeomObjects::Init (std::istream& f, int len, std::ostream* log1, std::ostream* log2) {
456455 Ifc::SetOutput (log1,log2);
457- use_world_coords = world_coords;
458456 if ( !Ifc::Init (f, len) ) return false ;
459-
460- shapereps = Ifc::EntitiesByType<Ifc2x3::IfcShapeRepresentation>();
461- if ( ! shapereps ) return false ;
462-
463- outer = shapereps->begin ();
464- entities.reset ();
465- current_geom_obj = _get ();
466-
467- if ( ! current_geom_obj ) return false ;
468-
469- done = 0 ;
470- total = shapereps->Size ();
471- return true ;
457+ return _Init ();
472458}
473459bool IfcGeomObjects::Init (void * data, int len) {
474460 Ifc::SetOutput (0 ,0 );
475- use_world_coords = true ;
476- weld_vertices = false ;
477461 if ( !Ifc::Init (data, len) ) return false ;
478-
479- shapereps = Ifc::EntitiesByType<Ifc2x3::IfcShapeRepresentation>();
480- if ( ! shapereps ) return false ;
481-
482- outer = shapereps->begin ();
483- entities.reset ();
484- current_geom_obj = _get ();
485-
486- if ( ! current_geom_obj ) return false ;
487-
488- done = 0 ;
489- total = shapereps->Size ();
490- return true ;
462+ return _Init ();
463+ }
464+ void IfcGeomObjects::Settings (int setting, bool value) {
465+ switch ( setting ) {
466+ case USE_WORLD_COORDS:
467+ use_world_coords = value;
468+ break ;
469+ case WELD_VERTICES:
470+ weld_vertices = value;
471+ break ;
472+ }
491473}
492474int IfcGeomObjects::Progress () {
493475 return 100 * done / total;
0 commit comments