Skip to content

Commit a13042f

Browse files
committed
Fix warnings: unused variables, shadowing variable names, constant conditional expressions, integer conversions, inability to generate copy-ctor and/or assignment operator, etc.
1 parent 3cbb47a commit a13042f

23 files changed

Lines changed: 169 additions & 129 deletions

src/ifcconvert/ColladaSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void ColladaSerializer::ColladaExporter::ColladaGeometries::write(const std::str
128128
lines.setMaterial(materials[it->first].name());
129129
lines.setCount((unsigned long)it->second.size());
130130
int offset = 0;
131-
lines.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::VERTEX, "#" + mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX, 0));
131+
lines.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::VERTEX, "#" + mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX, offset++));
132132
lines.prepareToAppendValues();
133133
lines.appendValues(it->second);
134134
lines.finish();

src/ifcconvert/ColladaSerializer.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#ifndef COLLADASERIALIZER_H
2323
#define COLLADASERIALIZER_H
2424

25+
#ifdef _MSC_VER
26+
#pragma warning(push)
27+
#pragma warning(disable : 4201 4512)
28+
#endif
2529
#include <COLLADASWStreamWriter.h>
2630
#include <COLLADASWPrimitves.h>
2731
#include <COLLADASWLibraryGeometries.h>
@@ -34,19 +38,25 @@
3438
#include <COLLADASWLibraryMaterials.h>
3539
#include <COLLADASWBaseInputElement.h>
3640
#include <COLLADASWAsset.h>
41+
#ifdef _MSC_VER
42+
#pragma warning(pop)
43+
#endif
3744

3845
#include "../ifcgeom/IfcGeomIterator.h"
3946

4047
#include "../ifcconvert/GeometrySerializer.h"
4148

4249
class ColladaSerializer : public GeometrySerializer
4350
{
51+
// TODO The vast amount of implement details of ColladaSerializer could be hidden to the cpp file.
4452
private:
4553
class ColladaExporter
4654
{
4755
private:
4856
class ColladaGeometries : public COLLADASW::LibraryGeometries
4957
{
58+
ColladaGeometries(const ColladaGeometries&); //N/A
59+
ColladaGeometries& operator =(const ColladaGeometries&); //N/A
5060
public:
5161
explicit ColladaGeometries(COLLADASW::StreamWriter& stream)
5262
: COLLADASW::LibraryGeometries(&stream)
@@ -58,6 +68,9 @@ class ColladaSerializer : public GeometrySerializer
5868
class ColladaScene : public COLLADASW::LibraryVisualScenes
5969
{
6070
private:
71+
ColladaScene(const ColladaScene&); //N/A
72+
ColladaScene& operator =(const ColladaScene&); //N/A
73+
6174
const std::string scene_id;
6275
bool scene_opened;
6376
public:
@@ -71,9 +84,13 @@ class ColladaSerializer : public GeometrySerializer
7184
};
7285
class ColladaMaterials : public COLLADASW::LibraryMaterials
7386
{
87+
ColladaMaterials(const ColladaMaterials&); //N/A
88+
ColladaMaterials& operator =(const ColladaMaterials&); //N/A
7489
private:
7590
class ColladaEffects : public COLLADASW::LibraryEffects
7691
{
92+
ColladaEffects(const ColladaEffects&); //N/A
93+
ColladaEffects& operator =(const ColladaEffects&); //N/A
7794
public:
7895
explicit ColladaEffects(COLLADASW::StreamWriter& stream)
7996
: COLLADASW::LibraryEffects(&stream)

src/ifcconvert/IfcConvert.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ int main(int argc, char** argv) {
198198
std::set<std::string> entities;
199199
for (std::vector<std::string>::const_iterator it = entity_vector.begin(); it != entity_vector.end(); ++it) {
200200
std::string lowercase_type = *it;
201-
for (std::string::iterator c = lowercase_type.begin(); c != lowercase_type.end(); ++c) {
202-
*c = tolower(*c);
203-
}
201+
std::transform(lowercase_type.begin(), lowercase_type.end(), lowercase_type.begin(), ::tolower);
204202
entities.insert(lowercase_type);
205203
}
206204

@@ -217,9 +215,7 @@ int main(int argc, char** argv) {
217215
}
218216

219217
std::string output_extension = output_filename.substr(output_filename.size()-4);
220-
for (std::string::iterator c = output_extension.begin(); c != output_extension.end(); ++c) {
221-
*c = tolower(*c);
222-
}
218+
std::transform(output_extension.begin(), output_extension.end(), output_extension.begin(), ::tolower);
223219

224220
// If no entities are specified these are the defaults to skip from output
225221
if (entity_vector.empty()) {

src/ifcconvert/OpenCascadeBasedSerializer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
#include "../ifcconvert/GeometrySerializer.h"
2626

2727
class OpenCascadeBasedSerializer : public GeometrySerializer {
28+
OpenCascadeBasedSerializer(const OpenCascadeBasedSerializer&); //N/A
29+
OpenCascadeBasedSerializer& operator =(const OpenCascadeBasedSerializer&); //N/A
2830
protected:
29-
const std::string& out_filename;
31+
const std::string out_filename;
3032
const char* getSymbolForUnitMagnitude(float mag);
3133
public:
3234
explicit OpenCascadeBasedSerializer(const std::string& out_filename)

src/ifcconvert/SvgSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement<double>* o) {
178178
typedef IfcSchema::IfcRelAggregates decomposition_element;
179179
#endif
180180

181-
while (true) {
181+
for (;;) {
182182
// Iterate over the decomposing element to find the parent IfcBuildingStorey
183183
decomposition_element::list::ptr decomposes = obdef->Decomposes();
184184
if (!decomposes->size()) {

src/ifcconvert/XmlSerializer.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/********************************************************************************
2+
* *
3+
* This file is part of IfcOpenShell. *
4+
* *
5+
* IfcOpenShell is free software: you can redistribute it and/or modify *
6+
* it under the terms of the Lesser GNU General Public License as published by *
7+
* the Free Software Foundation, either version 3.0 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* IfcOpenShell is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* Lesser GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the Lesser GNU General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
* *
18+
********************************************************************************/
19+
120
#include <map>
221

322
#include <boost/property_tree/ptree.hpp>
@@ -7,6 +26,8 @@
726

827
#include "XmlSerializer.h"
928

29+
#include <algorithm>
30+
1031
using boost::property_tree::ptree;
1132
using namespace IfcSchema;
1233

@@ -58,7 +79,8 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
5879
unit_name = unit->Name();
5980
}
6081

61-
for (std::string::iterator c = unit_name.begin(); c != unit_name.end(); ++c) *c = tolower(*c);
82+
// TODO add toLower() and toUpper() string helper functions for the project
83+
std::transform(unit_name.begin(), unit_name.end(), unit_name.begin(), ::tolower);
6284

6385
value = unit_name;
6486
}

src/ifcgeom/IfcGeomFaces.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
101101
IfcSchema::IfcFaceBound::list::ptr bounds = l->Bounds();
102102

103103
Handle(Geom_Surface) face_surface;
104-
bool reversed_face_surface = false;
105104
const bool is_face_surface = l->is(IfcSchema::Type::IfcFaceSurface);
106105

107106
if (is_face_surface) {
@@ -237,9 +236,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
237236
// If the wires are reversed the face needs to be reversed as well in order
238237
// to maintain the counter-clock-wise ordering of the bounding wire's vertices.
239238
bool all_reversed = true;
240-
TopoDS_Iterator it(outer_face_bound, false);
241-
for (; it.More(); it.Next()) {
242-
const TopoDS_Wire& w = TopoDS::Wire(it.Value());
239+
TopoDS_Iterator jt(outer_face_bound, false);
240+
for (; jt.More(); jt.Next()) {
241+
const TopoDS_Wire& w = TopoDS::Wire(jt.Value());
243242
if ((w.Orientation() != TopAbs_REVERSED) == same_sense) {
244243
all_reversed = false;
245244
}
@@ -856,7 +855,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeProfileDef* l, TopoDS
856855
builder.MakeCompound(compound);
857856

858857
IfcSchema::IfcProfileDef::list::ptr profiles = l->Profiles();
859-
bool first = true;
858+
//bool first = true;
860859
for (IfcSchema::IfcProfileDef::list::it it = profiles->begin(); it != profiles->end(); ++it) {
861860
TopoDS_Face f;
862861
if (convert_face(*it, f)) {

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,11 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
208208
? BRepBuilderAPI_GTransform(opening_shape_unlocated,opening_shape_gtrsf,true).Shape()
209209
: opening_shape_unlocated.Moved(opening_shape_gtrsf.Trsf());
210210

211-
double opening_volume, original_shape_volume;
211+
double opening_volume;
212212
if ( Logger::Verbosity() >= Logger::LOG_WARNING ) {
213213
opening_volume = shape_volume(opening_shape);
214214
if ( opening_volume <= ALMOST_ZERO )
215215
Logger::Message(Logger::LOG_WARNING,"Empty opening for:",entity->entity);
216-
original_shape_volume = shape_volume(entity_shape);
217216
}
218217

219218
if (entity_shape.ShapeType() == TopAbs_COMPSOLID) {
@@ -235,9 +234,9 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
235234
BRepCheck_Analyzer analyser(brep_cut_result);
236235
bool is_valid = analyser.IsValid() != 0;
237236
if (is_valid) {
238-
TopExp_Explorer exp(brep_cut_result, TopAbs_SOLID);
239-
for (; exp.More(); exp.Next()) {
240-
builder.Add(compound, exp.Current());
237+
TopExp_Explorer exp2(brep_cut_result, TopAbs_SOLID);
238+
for (; exp2.More(); exp2.Next()) {
239+
builder.Add(compound, exp2.Current());
241240
added = true;
242241
}
243242
}
@@ -272,7 +271,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
272271
entity_shape = brep_cut_result;
273272
if ( Logger::Verbosity() >= Logger::LOG_WARNING ) {
274273
const double volume_after_subtraction = shape_volume(entity_shape);
275-
274+
double original_shape_volume = shape_volume(entity_shape);
276275
if ( ALMOST_THE_SAME(original_shape_volume,volume_after_subtraction) )
277276
Logger::Message(Logger::LOG_WARNING,"Subtraction yields unchanged volume:",entity->entity);
278277
}
@@ -615,11 +614,11 @@ IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(TopoDS_Shape& shape, do
615614
IfcSchema::IfcFaceOuterBound* bound = new IfcSchema::IfcFaceOuterBound(loop, face.Orientation() != TopAbs_REVERSED);
616615
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
617616
bounds->push(bound);
618-
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
617+
IfcSchema::IfcFace* face2 = new IfcSchema::IfcFace(bounds);
619618
es->push(loop);
620619
es->push(bound);
621-
es->push(face);
622-
faces->push(face);
620+
es->push(face2);
621+
faces->push(face2);
623622
}
624623
}
625624
}
@@ -703,15 +702,14 @@ bool IfcGeom::Kernel::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& sha
703702
// Now loop over all the vertices that are part of the wire(s) to be filled
704703
for (int i = 1; i <= num_verts; ++i) {
705704
first = current = TopoDS::Vertex(vertex_to_edges.FindKey(i));
706-
const bool isSame = first.IsSame(current);
707705
// We keep track of the vertices we already used
708706
if (visited.find(vertex_to_edges.FindIndex(current)) != visited.end()) {
709707
continue;
710708
}
711709
// Given these vertices, try to find closed loops and create new
712710
// wires out of them.
713711
BRepBuilderAPI_MakeWire w;
714-
while (true) {
712+
for (;;) {
715713
visited.insert(vertex_to_edges.FindIndex(current));
716714
// Find the edge that the current vertex is part of and points
717715
// away from the previous vertex (null for the first vertex).
@@ -822,7 +820,7 @@ void IfcGeom::Kernel::remove_redundant_points_from_loop(TColgp_SequenceOfPnt& po
822820
if (tol <= 0.) tol = getValue(GV_POINT_EQUALITY_TOLERANCE);
823821
tol *= tol;
824822

825-
while (true) {
823+
for (;;) {
826824
bool removed = false;
827825
int n = polygon.Length() - (closed ? 0 : 1);
828826
for (int i = 1; i <= n; ++i) {

src/ifcgeom/IfcGeomHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
287287
return false;
288288
}
289289
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l;
290-
while (1) {
290+
for (;;) {
291291
gp_Trsf trsf2;
292292
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
293293
if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) {

src/ifcgeom/IfcGeomIterator.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ namespace IfcGeom {
182182
}
183183
if (context->hasContextType()) {
184184
std::string context_type_lc = context->ContextType();
185-
for (std::string::iterator c = context_type_lc.begin(); c != context_type_lc.end(); ++c) {
186-
*c = tolower(*c);
187-
}
185+
std::transform(context_type_lc.begin(), context_type_lc.end(), context_type_lc.begin(), ::tolower);
188186
if (context_types.find(context_type_lc) != context_types.end()) {
189187
filtered_contexts->push(context);
190188
}
@@ -287,7 +285,7 @@ namespace IfcGeom {
287285
}
288286

289287
BRepElement<P>* create_shape_model_for_next_entity() {
290-
while ( true ) {
288+
for (;;) {
291289
IfcSchema::IfcRepresentation* representation;
292290

293291
// Have we reached the end of our list of representations?
@@ -320,16 +318,16 @@ namespace IfcGeom {
320318

321319
// Filter the products based on the set of entities being included or excluded for
322320
// processing. The set is iterated over te able to filter on subtypes.
323-
for ( IfcSchema::IfcProduct::list::it it = unfiltered_products->begin(); it != unfiltered_products->end(); ++it ) {
321+
for ( IfcSchema::IfcProduct::list::it jt = unfiltered_products->begin(); jt != unfiltered_products->end(); ++jt ) {
324322
bool found = false;
325-
for (std::set<IfcSchema::Type::Enum>::const_iterator jt = entities_to_include_or_exclude.begin(); jt != entities_to_include_or_exclude.end(); ++jt) {
326-
if ((*it)->is(*jt)) {
323+
for (std::set<IfcSchema::Type::Enum>::const_iterator kt = entities_to_include_or_exclude.begin(); kt != entities_to_include_or_exclude.end(); ++kt) {
324+
if ((*jt)->is(*kt)) {
327325
found = true;
328326
break;
329327
}
330328
}
331329
if (found == include_entities_in_processing) {
332-
ifcproducts->push(*it);
330+
ifcproducts->push(*jt);
333331
}
334332
}
335333

0 commit comments

Comments
 (0)