2020#include < map>
2121#include < set>
2222
23- #include < Max.h>
2423#include < stdmat.h>
2524#include < istdplug.h>
2625
27- #include " ../ifcmax/ IfcMax.h"
26+ #include " IfcMax.h"
2827#include " ../ifcgeom/IfcGeomIterator.h"
2928
3029static const int NUM_MATERIAL_SLOTS = 24 ;
3130
32- int controlsInit = false ;
33-
34- BOOL WINAPI DllMain (HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
31+ BOOL WINAPI DllMain (HINSTANCE /* hinstDLL*/ , ULONG /* fdwReason*/ , LPVOID /* lpvReserved*/ ) {
32+ static int controlsInit = false ;
3533 if (!controlsInit) {
3634 controlsInit = true ;
3735 InitCommonControls ();
38- }
39- return true ;
40- }
41-
42- __declspec ( dllexport ) const TCHAR* LibDescription() {
43- return _T (" IfcOpenShell IFC Importer" );
36+ }
37+ return TRUE ;
4438}
4539
46- __declspec ( dllexport ) int LibNumberClasses() { return 1 ; }
47-
48- static class IFCImpClassDesc :public ClassDesc {
40+ static class IFCImpClassDesc :public ClassDesc {
4941public:
50- int IsPublic () {return 1 ;}
51- void * Create (BOOL loading = FALSE ) {return new IFCImp;}
52- const TCHAR * ClassName () {return _T (" IFCImp" );}
53- SClass_ID SuperClassID () {return SCENE_IMPORT_CLASS_ID;}
54- Class_ID ClassID () {return Class_ID (0x3f230dbf , 0x5b3015c2 );}
55- const TCHAR* Category () {return _T (" Chrutilities" );}
42+ int IsPublic () { return 1 ; }
43+ void * Create (BOOL /* loading = FALSE*/ ) { return new IFCImp; }
44+ // TODO Delete() function?
45+ const TCHAR * ClassName () { return _T (" IFCImp" ); }
46+ SClass_ID SuperClassID () { return SCENE_IMPORT_CLASS_ID; }
47+ Class_ID ClassID () { return Class_ID (0x3f230dbf , 0x5b3015c2 ); }
48+ const TCHAR* Category () { return _T (" Chrutilities" ); }
5649} IFCImpDesc;
5750
58- __declspec ( dllexport ) ClassDesc* LibClassDesc(int i) {
59- return i == 0 ? &IFCImpDesc : 0 ;
51+ #define DLLEXPORT __declspec (dllexport)
52+
53+ extern "C" {
54+
55+ DLLEXPORT const TCHAR* LibDescription () {
56+ return _T (" IfcOpenShell IFC Importer" );
57+ }
58+
59+ DLLEXPORT int LibNumberClasses () { return 1 ; }
60+
61+ DLLEXPORT ClassDesc* LibClassDesc (int i) {
62+ return i == 0 ? &IFCImpDesc : 0 ;
6063}
6164
62- __declspec ( dllexport ) ULONG LibVersion() {
63- return VERSION_3DSMAX;
65+ DLLEXPORT ULONG LibVersion () {
66+ return VERSION_3DSMAX;
6467}
6568
69+ } // extern "C"
70+
6671int IFCImp::ExtCount () { return 1 ; }
6772
6873const TCHAR * IFCImp::Ext (int n) {
@@ -82,7 +87,7 @@ const TCHAR * IFCImp::AuthorName() {
8287}
8388
8489const TCHAR * IFCImp::CopyrightMessage () {
85- return _T (" Copyight (c) 2011 IfcOpenShell" );
90+ return _T (" Copyright (c) 2011-2016 IfcOpenShell" );
8691}
8792
8893const TCHAR * IFCImp::OtherMessage1 () {
@@ -97,13 +102,14 @@ unsigned int IFCImp::Version() {
97102 return 12 ;
98103}
99104
100- static BOOL CALLBACK AboutBoxDlgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
101- return TRUE ;
102- }
105+ // TODO Use this in IFCImp::ShowAbout() if/when wanted
106+ // static BOOL CALLBACK AboutBoxDlgProc(HWND /*hWnd*/, UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) {
107+ // return TRUE;
108+ // }
103109
104- void IFCImp::ShowAbout (HWND hWnd) {}
110+ void IFCImp::ShowAbout (HWND /* hWnd*/ ) {}
105111
106- DWORD WINAPI fn (LPVOID arg) { return 0 ; }
112+ DWORD WINAPI fn (LPVOID /* arg*/ ) { return 0 ; }
107113
108114#if MAX_RELEASE > 14000
109115# define S (x ) (TSTR::FromCStr(x.c_str()))
@@ -113,16 +119,17 @@ DWORD WINAPI fn(LPVOID arg) { return 0; }
113119# define S (x ) (CStr(x.c_str()))
114120#endif
115121
116- Mtl* FindMaterialByName (MtlBaseLib* library, const std::string& material_name) {
117- const int mat_index = library->FindMtlByName (S (material_name));
122+ static Mtl* FindMaterialByName (MtlBaseLib* library, const std::string& material_name) {
123+ TSTR mat_name = S (material_name);
124+ const int mat_index = library->FindMtlByName (mat_name);
118125 Mtl* m = 0 ;
119126 if (mat_index != -1 ) {
120127 m = static_cast <Mtl*>((*library)[mat_index]);
121128 }
122129 return m;
123130}
124131
125- Mtl* FindOrCreateMaterial (MtlBaseLib* library, Interface* max_interface, int & slot, const IfcGeom::Material& material) {
132+ static Mtl* FindOrCreateMaterial (MtlBaseLib* library, Interface* max_interface, int & slot, const IfcGeom::Material& material) {
126133 Mtl* m = FindMaterialByName (library, material.name ());
127134 if (m == 0 ) {
128135 StdMat2* stdm = NewDefaultStdMat ();
@@ -136,10 +143,10 @@ Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& sl
136143 stdm->SetSpecular (Color (specular[0 ], specular[1 ], specular[2 ]),t);
137144 }
138145 if (material.hasSpecularity ()) {
139- stdm->SetShininess (material.specularity (), t);
146+ stdm->SetShininess (( float ) material.specularity (), t);
140147 }
141148 if (material.hasTransparency ()) {
142- stdm->SetOpacity (1.0 - material.transparency (), t);
149+ stdm->SetOpacity (1 .0f - ( float ) material.transparency (), t);
143150 }
144151 m = stdm;
145152 m->SetName (S (material.name ()));
@@ -151,7 +158,10 @@ Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& sl
151158 return m;
152159}
153160
154- Mtl* ComposeMultiMaterial (std::map<std::vector<std::string>, Mtl*>& multi_mats, MtlBaseLib* library, Interface* max_interface, int & slot, const std::vector<IfcGeom::Material>& materials, const std::string& object_type, const std::vector<int >& material_ids) {
161+ static Mtl* ComposeMultiMaterial (std::map<std::vector<std::string>, Mtl*>& multi_mats, MtlBaseLib* library,
162+ Interface* max_interface, int & slot, const std::vector<IfcGeom::Material>& materials,
163+ const std::string& object_type, const std::vector<int >& material_ids)
164+ {
155165 std::vector<std::string> material_names;
156166 bool needs_default = std::find (material_ids.begin (), material_ids.end (), -1 ) != material_ids.end ();
157167 if (needs_default) {
@@ -184,7 +194,7 @@ Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats,
184194 return i->second ;
185195 }
186196 MultiMtl* multi_mat = NewDefaultMultiMtl ();
187- multi_mat->SetNumSubMtls (material_names.size ());
197+ multi_mat->SetNumSubMtls (( int ) material_names.size ());
188198 int mtl_id = 0 ;
189199 if (needs_default) {
190200 multi_mat->SetSubMtlAndName (mtl_id ++, default_material, default_material->GetName ());
@@ -201,7 +211,7 @@ Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats,
201211 return multi_mat;
202212}
203213
204- int IFCImp::DoImport (const TCHAR *name, ImpInterface *impitfc, Interface *itfc, BOOL suppressPrompts) {
214+ int IFCImp::DoImport (const TCHAR *name, ImpInterface *impitfc, Interface *itfc, BOOL /* suppressPrompts*/ ) {
205215
206216 IfcGeom::IteratorSettings settings;
207217 settings.use_world_coords () = false ;
@@ -217,7 +227,7 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
217227#endif
218228
219229 IfcGeom::Iterator<float > iterator (settings, fn_mb);
220-
230+ delete fn_mb;
221231 if (!iterator.initialize ()) return false ;
222232
223233 itfc->ProgressStart (_T (" Importing file..." ), TRUE , fn, NULL );
@@ -237,12 +247,12 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
237247
238248 TriObject* tri = CreateNewTriObject ();
239249
240- const int numVerts = o->geometry ().verts ().size ()/3 ;
250+ const int numVerts = ( int ) o->geometry ().verts ().size ()/3 ;
241251 tri->mesh .setNumVerts (numVerts);
242252 for ( int i = 0 ; i < numVerts; i ++ ) {
243253 tri->mesh .setVert (i,o->geometry ().verts ()[3 *i+0 ],o->geometry ().verts ()[3 *i+1 ],o->geometry ().verts ()[3 *i+2 ]);
244254 }
245- const int numFaces = o->geometry ().faces ().size ()/3 ;
255+ const int numFaces = ( int ) o->geometry ().faces ().size ()/3 ;
246256 tri->mesh .setNumFaces (numFaces);
247257
248258 bool needs_default = std::find (o->geometry ().material_ids ().begin (), o->geometry ().material_ids ().end (), -1 ) != o->geometry ().material_ids ().end ();
@@ -274,7 +284,7 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
274284 tri->mesh .faces [i].setVerts (v1, v2, v3);
275285 tri->mesh .faces [i].setEdgeVisFlags (b1, b2, b3);
276286
277- MtlID mtlid = o->geometry ().material_ids ()[i];
287+ MtlID mtlid = (MtlID) o->geometry ().material_ids ()[i];
278288 if (needs_default) {
279289 mtlid ++;
280290 }
@@ -310,4 +320,4 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
310320 itfc->ProgressEnd ();
311321
312322 return true ;
313- }
323+ }
0 commit comments