2424#include " ../ifcmax/IfcMax.h"
2525#include " ../ifcmax/MaxMaterials.h"
2626#include " ../ifcgeom/IfcGeomObjects.h"
27+
2728int controlsInit = false ;
2829
2930BOOL WINAPI DllMain (HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
@@ -106,10 +107,11 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
106107
107108 IfcGeomObjects::Settings (IfcGeomObjects::USE_WORLD_COORDS,false );
108109 IfcGeomObjects::Settings (IfcGeomObjects::WELD_VERTICES,true );
110+ IfcGeomObjects::Settings (IfcGeomObjects::SEW_SHELLS,true );
109111
110112 if ( ! IfcGeomObjects::Init ((char *)name,0 ,0 ) ) return false ;
111113
112- std::map<int , TriObject*> dict;
114+ // std::map<int, TriObject*> dict;
113115 MtlBaseLib* mats = itfc->GetSceneMtls ();
114116 int slot = mats->Count ();
115117
@@ -129,10 +131,14 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
129131 m = static_cast <Mtl*>((*mats)[matIndex]);
130132 }
131133
132- std::map<int , TriObject*>::const_iterator it = dict.find (o->mesh ->id );
134+ // This mapping is useless for now, because this even in case
135+ // meshes entities in IFC share the same representation elements
136+ // they will never be given the same id.
137+ // TODO: Fix this!
138+ // std::map<int, TriObject*>::const_iterator it = dict.find(o->mesh->id);
133139
134140 TriObject* tri;
135- if ( it == dict.end () ) {
141+ // if ( it == dict.end() ) {
136142 tri = CreateNewTriObject ();
137143 const int numVerts = o->mesh ->verts .size ()/3 ;
138144 tri->mesh .setNumVerts (numVerts);
@@ -145,14 +151,21 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
145151 tri->mesh .faces [i].setVerts (o->mesh ->faces [3 *i+0 ],o->mesh ->faces [3 *i+1 ],o->mesh ->faces [3 *i+2 ]);
146152 tri->mesh .faces [i].setEdgeVisFlags (o->mesh ->edges [3 *i+0 ],o->mesh ->edges [3 *i+1 ],o->mesh ->edges [3 *i+2 ]);
147153 }
148- tri->mesh .InvalidateTopologyCache ();
149- tri->mesh .InvalidateGeomCache ();
154+
150155 tri->mesh .buildNormals ();
156+ // Either use this or undefine the FACESETS_AS_COMPOUND option in IfcGeom.h to have
157+ // properly oriented normals. Using only the line below will result in a consistent
158+ // orientation of normals accross shells, but not always oriented towards the
159+ // outside.
160+ // tri->mesh.UnifyNormals(false);
151161 tri->mesh .BuildStripsAndEdges ();
152- dict[o->mesh ->id ] = tri;
153- } else {
154- tri = (*it).second ;
155- }
162+ tri->mesh .InvalidateTopologyCache ();
163+ tri->mesh .InvalidateGeomCache ();
164+
165+ // dict[o->mesh->id] = tri;
166+ // } else {
167+ // tri = (*it).second;
168+ // }
156169
157170 ImpNode* node = impitfc->CreateNode ();
158171 node->Reference (tri);
0 commit comments