Skip to content

Commit d4b51a8

Browse files
committed
Fix/suppress plethora of integer conversion warnings on x64 Visual Studio build.
1 parent a749775 commit d4b51a8

11 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/ifcconvert/ColladaSerializer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::addFloatSource(const
3939
COLLADASW::FloatSource source(mSW);
4040
source.setId(mesh_id + suffix);
4141
source.setArrayId(mesh_id + suffix + COLLADASW::LibraryGeometries::ARRAY_ID_SUFFIX);
42-
source.setAccessorStride(strlen(coords));
43-
source.setAccessorCount(floats.size() / 3);
42+
source.setAccessorStride((unsigned long)strlen(coords));
43+
source.setAccessorCount((unsigned long)floats.size() / 3);
4444
for (unsigned int i = 0; i < source.getAccessorStride(); ++i) {
4545
source.getParameterNameList().push_back(std::string(1, coords[i]));
4646
}
@@ -73,7 +73,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::write(const std::str
7373
int previous_material_id = -1;
7474
for (std::vector<int>::const_iterator it = faces.begin(); !faces.empty(); it += 3) {
7575
const int current_material_id = *(material_it++);
76-
const int num_triangles = std::distance(index_range_start, it) / 3;
76+
const unsigned long num_triangles = (unsigned long)std::distance(index_range_start, it) / 3;
7777
if ((previous_material_id != current_material_id && num_triangles > 0) || (it == faces.end())) {
7878
COLLADASW::Triangles triangles(mSW);
7979
triangles.setMaterial(materials[previous_material_id].name());
@@ -126,7 +126,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::write(const std::str
126126
for (linelist_t::const_iterator it = linelist.begin(); it != linelist.end(); ++it) {
127127
COLLADASW::Lines lines(mSW);
128128
lines.setMaterial(materials[it->first].name());
129-
lines.setCount(it->second.size());
129+
lines.setCount((unsigned long)it->second.size());
130130
int offset = 0;
131131
lines.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::VERTEX, "#" + mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX, 0));
132132
lines.prepareToAppendValues();

src/ifcconvert/WavefrontObjSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement<double>*
7272

7373
const IfcGeom::Representation::Triangulation<double>& mesh = o->geometry();
7474

75-
const int vcount = mesh.verts().size() / 3;
75+
const int vcount = (int)mesh.verts().size() / 3;
7676
for ( std::vector<double>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end(); ) {
7777
const double x = *(it++);
7878
const double y = *(it++);

src/ifcgeom/IfcGeomRepresentation.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,21 @@ namespace IfcGeom {
123123
Material adapter(&it->Style());
124124
std::vector<Material>::const_iterator jt = std::find(_materials.begin(), _materials.end(), adapter);
125125
if (jt == _materials.end()) {
126-
surface_style_id = _materials.size();
126+
surface_style_id = (int)_materials.size();
127127
_materials.push_back(adapter);
128128
} else {
129-
surface_style_id = jt - _materials.begin();
129+
surface_style_id = (int)(jt - _materials.begin());
130130
}
131131
}
132132

133133
if (settings().apply_default_materials() && surface_style_id == -1) {
134134
Material material(IfcGeom::get_default_style(settings().element_type()));
135135
std::vector<Material>::const_iterator it = std::find(_materials.begin(), _materials.end(), material);
136136
if (it == _materials.end()) {
137-
surface_style_id = _materials.size();
137+
surface_style_id = (int)_materials.size();
138138
_materials.push_back(material);
139139
} else {
140-
surface_style_id = it - _materials.begin();
140+
surface_style_id = (int)(it - _materials.begin());
141141
}
142142
}
143143

@@ -251,7 +251,7 @@ namespace IfcGeom {
251251
BRepAdaptor_Curve crv(TopoDS::Edge(exp.Current()));
252252
GCPnts_QuasiUniformDeflection tessellater(crv, settings().deflection_tolerance());
253253
int n = tessellater.NbPoints();
254-
int start = _verts.size() / 3;
254+
int start = (int)_verts.size() / 3;
255255
for (int i = 1; i <= n; ++i) {
256256
gp_XYZ p = tessellater.Value(i).XYZ();
257257
trsf.Transforms(p);

src/ifcgeomserver/IfcGeomServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void swrite(std::ostream& s, T t) {
6969

7070
template <>
7171
void swrite(std::ostream& s, std::string t) {
72-
int32_t len = t.size();
72+
int32_t len = (int32_t)t.size();
7373
swrite(s, len);
7474
s.write(t.c_str(), len);
7575
while (len++ % 4) s.put(0);
@@ -323,7 +323,7 @@ int main (int argc, char** argv) {
323323
settings.convert_back_units() = true;
324324
settings.include_curves() = true;
325325

326-
iterator = new IfcGeom::Iterator<float>(settings, data, len);
326+
iterator = new IfcGeom::Iterator<float>(settings, data, (int)len);
327327
has_more = iterator->initialize();
328328

329329
More(has_more).write(std::cout);

src/ifcparse/IfcCharacterDecoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ IfcCharacterDecoder::operator std::string() {
135135
#ifdef HAVE_ICU
136136
if ( previous_codepage != codepage ) {
137137
if ( converter ) ucnv_close(converter);
138-
char encoder[11] = {'i','s','o','-','8','8','5','9','-',codepage + 0x30};
138+
char encoder[11] = {'i','s','o','-','8','8','5','9','-', (char)codepage + 0x30};
139139
converter = ucnv_open(encoder, &status);
140140
}
141141
const char characters[2] = { current_char + 0x80 };
@@ -188,7 +188,7 @@ IfcCharacterDecoder::operator std::string() {
188188
if (old_hex == 0) {
189189
old_hex = hex;
190190
} else {
191-
char characters[3] = { old_hex, hex };
191+
char characters[3] = { (char)old_hex, (char)hex };
192192
const char* char_array = &characters[0];
193193
UChar32 ch = ucnv_getNextUChar(compatibility_converter,&char_array,char_array+2,&status);
194194
addChar(s,ch);

src/ifcparse/IfcEntityDescriptor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace IfcUtil {
4848
std::pair<const char*, int> getIndex(const std::string& value) const {
4949
std::vector<std::string>::const_iterator it = std::find(values.begin(), values.end(), value);
5050
if (it != values.end()) {
51-
return std::make_pair(it->c_str(), std::distance(it, values.begin()));
51+
return std::make_pair(it->c_str(), (int)std::distance(it, values.begin()));
5252
} else {
5353
throw IfcParse::IfcException("Invalid enumeration value");
5454
}
@@ -91,7 +91,7 @@ namespace IfcUtil {
9191
arguments.push_back(IfcArgumentDescriptor(name, optional, argument_type, data_type));
9292
}
9393
unsigned getArgumentCount() const {
94-
return (parent ? parent->getArgumentCount() : 0) + arguments.size();
94+
return (parent ? parent->getArgumentCount() : 0) + (unsigned)arguments.size();
9595
}
9696
const std::string& getArgumentName(unsigned i) const {
9797
const unsigned a = argument_start();

src/ifcparse/IfcGlobalId.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ unsigned from_base64(const std::string& s) {
5252
r *= 64;
5353
const char* c = strchr(chars,*i);
5454
if ( !c ) throw IfcParse::IfcException("Failed to decode GlobalId");
55-
r += (c-chars);
55+
r += (unsigned)(c-chars);
5656
}
5757
return r;
5858
}

src/ifcparse/IfcParse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) {
467467
}
468468

469469
++it;
470-
unsigned i = (str.size()-1) * 4 - n;
470+
unsigned i = ((unsigned)str.size()-1) * 4 - n;
471471
boost::dynamic_bitset<> bitset(i);
472472

473473
for(; it != str.end(); ++it) {

src/ifcparse/IfcUtil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ class IfcEntityListList {
187187
}
188188
outer_it begin() const { return ls.begin(); }
189189
outer_it end() const { return ls.end(); }
190-
int size() const { return ls.size(); }
190+
int size() const { return (int)ls.size(); }
191191
int totalSize() const {
192192
int accum = 0;
193193
for (outer_it it = begin(); it != end(); ++it) {
194-
accum += it->size();
194+
accum += (int)it->size();
195195
}
196196
return accum;
197197
}

src/ifcparse/IfcWrite.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Argument* IfcWritableEntity::getArgument (unsigned int i) {
8484
}
8585
return args[i];
8686
}
87-
unsigned int IfcWritableEntity::getArgumentCount() const {return args.size(); }
87+
unsigned int IfcWritableEntity::getArgumentCount() const { return (unsigned)args.size(); }
8888
IfcSchema::Type::Enum IfcWritableEntity::type() const { return _type; }
8989
bool IfcWritableEntity::is(IfcSchema::Type::Enum v) const { return _type == v; }
9090
std::string IfcWritableEntity::toString(bool upper) const {
@@ -298,12 +298,12 @@ class SizeVisitor : public boost::static_visitor<int> {
298298
int operator()(const double& i) const { return -1; }
299299
int operator()(const std::string& i) const { return -1; }
300300
int operator()(const boost::dynamic_bitset<>& i) const { return -1; }
301-
int operator()(const std::vector<int>& i) const { return i.size(); }
302-
int operator()(const std::vector<double>& i) const { return i.size(); }
303-
int operator()(const std::vector< std::vector<int> >& i) const { return i.size(); }
304-
int operator()(const std::vector< std::vector<double> >& i) const { return i.size(); }
305-
int operator()(const std::vector<std::string>& i) const { return i.size(); }
306-
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return i.size(); }
301+
int operator()(const std::vector<int>& i) const { return (int)i.size(); }
302+
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
303+
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
304+
int operator()(const std::vector< std::vector<double> >& i) const { return (int)i.size(); }
305+
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
306+
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
307307
int operator()(const IfcWriteArgument::EnumerationReference& i) const { return -1; }
308308
int operator()(const IfcUtil::IfcBaseClass* const& i) const { return -1; }
309309
int operator()(const IfcEntityList::ptr& i) const { return i->size(); }
@@ -351,7 +351,7 @@ class StringBuilderVisitor : public boost::static_visitor<void> {
351351
oss.imbue(std::locale::classic());
352352
oss.put('"');
353353
oss << std::hex << std::setw(1);
354-
unsigned c = b.size();
354+
unsigned c = (unsigned)b.size();
355355
unsigned n = (4 - (c % 4)) & 3;
356356
oss << n;
357357
for (unsigned i = 0; i < c + n;) {

0 commit comments

Comments
 (0)