Skip to content

Commit 7fcdc7f

Browse files
authored
Remove library uses of std::endl on std::cerr (#542)
* Remove library uses of std::endl on std::cerr There is no need to flush cerr. https://en.cppreference.com/w/cpp/io/cerr https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rio-endl
1 parent 50fb18d commit 7fcdc7f

File tree

9 files changed

+54
-55
lines changed

9 files changed

+54
-55
lines changed

include/fcl/geometry/bvh/BVH_model-inl.h

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@ int BVHModel<BV>::beginModel(int num_tris_, int num_vertices_)
228228
tri_indices = new(std::nothrow) Triangle[num_tris_allocated];
229229
if(!tri_indices)
230230
{
231-
std::cerr << "BVH Error! Out of memory for tri_indices array on BeginModel() call!" << std::endl;
231+
std::cerr << "BVH Error! Out of memory for tri_indices array on BeginModel() call!\n";
232232
return BVH_ERR_MODEL_OUT_OF_MEMORY;
233233
}
234234
}
235235

236236
vertices = new Vector3<S>[num_vertices_allocated];
237237
if(!vertices)
238238
{
239-
std::cerr << "BVH Error! Out of memory for vertices array on BeginModel() call!" << std::endl;
239+
std::cerr << "BVH Error! Out of memory for vertices array on BeginModel() call!\n";
240240
return BVH_ERR_MODEL_OUT_OF_MEMORY;
241241
}
242242

243243
if(build_state != BVH_BUILD_STATE_EMPTY)
244244
{
245-
std::cerr << "BVH Warning! Call beginModel() on a BVHModel that is not empty. This model was cleared and previous triangles/vertices were lost." << std::endl;
245+
std::cerr << "BVH Warning! Call beginModel() on a BVHModel that is not empty. This model was cleared and previous triangles/vertices were lost.\n";
246246
build_state = BVH_BUILD_STATE_EMPTY;
247247
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
248248
}
@@ -258,7 +258,7 @@ int BVHModel<BV>::addVertex(const Vector3<S>& p)
258258
{
259259
if(build_state != BVH_BUILD_STATE_BEGUN)
260260
{
261-
std::cerr << "BVH Warning! Call addVertex() in a wrong order. addVertex() was ignored. Must do a beginModel() to clear the model for addition of new vertices." << std::endl;
261+
std::cerr << "BVH Warning! Call addVertex() in a wrong order. addVertex() was ignored. Must do a beginModel() to clear the model for addition of new vertices.\n";
262262
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
263263
}
264264

@@ -267,7 +267,7 @@ int BVHModel<BV>::addVertex(const Vector3<S>& p)
267267
Vector3<S>* temp = new Vector3<S>[num_vertices_allocated * 2];
268268
if(!temp)
269269
{
270-
std::cerr << "BVH Error! Out of memory for vertices array on addVertex() call!" << std::endl;
270+
std::cerr << "BVH Error! Out of memory for vertices array on addVertex() call!\n";
271271
return BVH_ERR_MODEL_OUT_OF_MEMORY;
272272
}
273273

@@ -289,7 +289,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
289289
{
290290
if(build_state == BVH_BUILD_STATE_PROCESSED)
291291
{
292-
std::cerr << "BVH Warning! Call addTriangle() in a wrong order. addTriangle() was ignored. Must do a beginModel() to clear the model for addition of new triangles." << std::endl;
292+
std::cerr << "BVH Warning! Call addTriangle() in a wrong order. addTriangle() was ignored. Must do a beginModel() to clear the model for addition of new triangles.\n";
293293
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
294294
}
295295

@@ -298,7 +298,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
298298
Vector3<S>* temp = new Vector3<S>[num_vertices_allocated * 2 + 2];
299299
if(!temp)
300300
{
301-
std::cerr << "BVH Error! Out of memory for vertices array on addTriangle() call!" << std::endl;
301+
std::cerr << "BVH Error! Out of memory for vertices array on addTriangle() call!\n";
302302
return BVH_ERR_MODEL_OUT_OF_MEMORY;
303303
}
304304

@@ -326,7 +326,7 @@ int BVHModel<BV>::addTriangle(const Vector3<S>& p1, const Vector3<S>& p2, const
326326
Triangle* temp = new Triangle[num_tris_allocated * 2];
327327
if(!temp)
328328
{
329-
std::cerr << "BVH Error! Out of memory for tri_indices array on addTriangle() call!" << std::endl;
329+
std::cerr << "BVH Error! Out of memory for tri_indices array on addTriangle() call!\n";
330330
return BVH_ERR_MODEL_OUT_OF_MEMORY;
331331
}
332332

@@ -348,7 +348,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps)
348348
{
349349
if(build_state == BVH_BUILD_STATE_PROCESSED)
350350
{
351-
std::cerr << "BVH Warning! Call addSubModel() in a wrong order. addSubModel() was ignored. Must do a beginModel() to clear the model for addition of new vertices." << std::endl;
351+
std::cerr << "BVH Warning! Call addSubModel() in a wrong order. addSubModel() was ignored. Must do a beginModel() to clear the model for addition of new vertices.\n";
352352
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
353353
}
354354

@@ -359,7 +359,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps)
359359
Vector3<S>* temp = new Vector3<S>[num_vertices_allocated * 2 + num_vertices_to_add - 1];
360360
if(!temp)
361361
{
362-
std::cerr << "BVH Error! Out of memory for vertices array on addSubModel() call!" << std::endl;
362+
std::cerr << "BVH Error! Out of memory for vertices array on addSubModel() call!\n";
363363
return BVH_ERR_MODEL_OUT_OF_MEMORY;
364364
}
365365

@@ -384,7 +384,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
384384
{
385385
if(build_state == BVH_BUILD_STATE_PROCESSED)
386386
{
387-
std::cerr << "BVH Warning! Call addSubModel() in a wrong order. addSubModel() was ignored. Must do a beginModel() to clear the model for addition of new vertices." << std::endl;
387+
std::cerr << "BVH Warning! Call addSubModel() in a wrong order. addSubModel() was ignored. Must do a beginModel() to clear the model for addition of new vertices.\n";
388388
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
389389
}
390390

@@ -395,7 +395,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
395395
Vector3<S>* temp = new Vector3<S>[num_vertices_allocated * 2 + num_vertices_to_add - 1];
396396
if(!temp)
397397
{
398-
std::cerr << "BVH Error! Out of memory for vertices array on addSubModel() call!" << std::endl;
398+
std::cerr << "BVH Error! Out of memory for vertices array on addSubModel() call!\n";
399399
return BVH_ERR_MODEL_OUT_OF_MEMORY;
400400
}
401401

@@ -425,7 +425,7 @@ int BVHModel<BV>::addSubModel(const std::vector<Vector3<S>>& ps, const std::vect
425425
Triangle* temp = new(std::nothrow) Triangle[num_tris_allocated * 2 + num_tris_to_add - 1];
426426
if(!temp)
427427
{
428-
std::cerr << "BVH Error! Out of memory for tri_indices array on addSubModel() call!" << std::endl;
428+
std::cerr << "BVH Error! Out of memory for tri_indices array on addSubModel() call!\n";
429429
return BVH_ERR_MODEL_OUT_OF_MEMORY;
430430
}
431431

@@ -451,13 +451,13 @@ int BVHModel<BV>::endModel()
451451
{
452452
if(build_state != BVH_BUILD_STATE_BEGUN)
453453
{
454-
std::cerr << "BVH Warning! Call endModel() in wrong order. endModel() was ignored." << std::endl;
454+
std::cerr << "BVH Warning! Call endModel() in wrong order. endModel() was ignored.\n";
455455
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
456456
}
457457

458458
if(num_tris == 0 && num_vertices == 0)
459459
{
460-
std::cerr << "BVH Error! endModel() called on model with no triangles and vertices." << std::endl;
460+
std::cerr << "BVH Error! endModel() called on model with no triangles and vertices.\n";
461461
return BVH_ERR_BUILD_EMPTY_MODEL;
462462
}
463463

@@ -466,7 +466,7 @@ int BVHModel<BV>::endModel()
466466
Triangle* new_tris = new(std::nothrow) Triangle[num_tris];
467467
if(!new_tris)
468468
{
469-
std::cerr << "BVH Error! Out of memory for tri_indices array in endModel() call!" << std::endl;
469+
std::cerr << "BVH Error! Out of memory for tri_indices array in endModel() call!\n";
470470
return BVH_ERR_MODEL_OUT_OF_MEMORY;
471471
}
472472
std::copy(tri_indices, tri_indices + num_tris, new_tris);
@@ -480,7 +480,7 @@ int BVHModel<BV>::endModel()
480480
Vector3<S>* new_vertices = new Vector3<S>[num_vertices];
481481
if(!new_vertices)
482482
{
483-
std::cerr << "BVH Error! Out of memory for vertices array in endModel() call!" << std::endl;
483+
std::cerr << "BVH Error! Out of memory for vertices array in endModel() call!\n";
484484
return BVH_ERR_MODEL_OUT_OF_MEMORY;
485485
}
486486
std::copy(vertices, vertices + num_vertices, new_vertices);
@@ -502,7 +502,7 @@ int BVHModel<BV>::endModel()
502502
primitive_indices = new(std::nothrow) unsigned int [num_bvs_to_be_allocated];
503503
if(!bvs || !primitive_indices)
504504
{
505-
std::cerr << "BVH Error! Out of memory for BV array in endModel()!" << std::endl;
505+
std::cerr << "BVH Error! Out of memory for BV array in endModel()!\n";
506506
return BVH_ERR_MODEL_OUT_OF_MEMORY;
507507
}
508508
num_bvs_allocated = num_bvs_to_be_allocated;
@@ -522,7 +522,7 @@ int BVHModel<BV>::beginReplaceModel()
522522
{
523523
if(build_state != BVH_BUILD_STATE_PROCESSED)
524524
{
525-
std::cerr << "BVH Error! Call beginReplaceModel() on a BVHModel that has no previous frame." << std::endl;
525+
std::cerr << "BVH Error! Call beginReplaceModel() on a BVHModel that has no previous frame.\n";
526526
return BVH_ERR_BUILD_EMPTY_PREVIOUS_FRAME;
527527
}
528528

@@ -545,7 +545,7 @@ int BVHModel<BV>::replaceVertex(const Vector3<S>& p)
545545
{
546546
if(build_state != BVH_BUILD_STATE_REPLACE_BEGUN)
547547
{
548-
std::cerr << "BVH Warning! Call replaceVertex() in a wrong order. replaceVertex() was ignored. Must do a beginReplaceModel() for initialization." << std::endl;
548+
std::cerr << "BVH Warning! Call replaceVertex() in a wrong order. replaceVertex() was ignored. Must do a beginReplaceModel() for initialization.\n";
549549
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
550550
}
551551

@@ -561,7 +561,7 @@ int BVHModel<BV>::replaceTriangle(const Vector3<S>& p1, const Vector3<S>& p2, co
561561
{
562562
if(build_state != BVH_BUILD_STATE_REPLACE_BEGUN)
563563
{
564-
std::cerr << "BVH Warning! Call replaceTriangle() in a wrong order. replaceTriangle() was ignored. Must do a beginReplaceModel() for initialization." << std::endl;
564+
std::cerr << "BVH Warning! Call replaceTriangle() in a wrong order. replaceTriangle() was ignored. Must do a beginReplaceModel() for initialization.\n";
565565
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
566566
}
567567

@@ -577,7 +577,7 @@ int BVHModel<BV>::replaceSubModel(const std::vector<Vector3<S>>& ps)
577577
{
578578
if(build_state != BVH_BUILD_STATE_REPLACE_BEGUN)
579579
{
580-
std::cerr << "BVH Warning! Call replaceSubModel() in a wrong order. replaceSubModel() was ignored. Must do a beginReplaceModel() for initialization." << std::endl;
580+
std::cerr << "BVH Warning! Call replaceSubModel() in a wrong order. replaceSubModel() was ignored. Must do a beginReplaceModel() for initialization.\n";
581581
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
582582
}
583583

@@ -595,13 +595,13 @@ int BVHModel<BV>::endReplaceModel(bool refit, bool bottomup)
595595
{
596596
if(build_state != BVH_BUILD_STATE_REPLACE_BEGUN)
597597
{
598-
std::cerr << "BVH Warning! Call endReplaceModel() in a wrong order. endReplaceModel() was ignored. " << std::endl;
598+
std::cerr << "BVH Warning! Call endReplaceModel() in a wrong order. endReplaceModel() was ignored. \n";
599599
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
600600
}
601601

602602
if(num_vertex_updated != num_vertices)
603603
{
604-
std::cerr << "BVH Error! The replaced model should have the same number of vertices as the old model." << std::endl;
604+
std::cerr << "BVH Error! The replaced model should have the same number of vertices as the old model.\n";
605605
return BVH_ERR_INCORRECT_DATA;
606606
}
607607

@@ -625,7 +625,7 @@ int BVHModel<BV>::beginUpdateModel()
625625
{
626626
if(build_state != BVH_BUILD_STATE_PROCESSED && build_state != BVH_BUILD_STATE_UPDATED)
627627
{
628-
std::cerr << "BVH Error! Call beginUpdatemodel() on a BVHModel that has no previous frame." << std::endl;
628+
std::cerr << "BVH Error! Call beginUpdatemodel() on a BVHModel that has no previous frame.\n";
629629
return BVH_ERR_BUILD_EMPTY_PREVIOUS_FRAME;
630630
}
631631

@@ -654,7 +654,7 @@ int BVHModel<BV>::updateVertex(const Vector3<S>& p)
654654
{
655655
if(build_state != BVH_BUILD_STATE_UPDATE_BEGUN)
656656
{
657-
std::cerr << "BVH Warning! Call updateVertex() in a wrong order. updateVertex() was ignored. Must do a beginUpdateModel() for initialization." << std::endl;
657+
std::cerr << "BVH Warning! Call updateVertex() in a wrong order. updateVertex() was ignored. Must do a beginUpdateModel() for initialization.\n";
658658
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
659659
}
660660

@@ -670,7 +670,7 @@ int BVHModel<BV>::updateTriangle(const Vector3<S>& p1, const Vector3<S>& p2, con
670670
{
671671
if(build_state != BVH_BUILD_STATE_UPDATE_BEGUN)
672672
{
673-
std::cerr << "BVH Warning! Call updateTriangle() in a wrong order. updateTriangle() was ignored. Must do a beginUpdateModel() for initialization." << std::endl;
673+
std::cerr << "BVH Warning! Call updateTriangle() in a wrong order. updateTriangle() was ignored. Must do a beginUpdateModel() for initialization.\n";
674674
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
675675
}
676676

@@ -686,7 +686,7 @@ int BVHModel<BV>::updateSubModel(const std::vector<Vector3<S>>& ps)
686686
{
687687
if(build_state != BVH_BUILD_STATE_UPDATE_BEGUN)
688688
{
689-
std::cerr << "BVH Warning! Call updateSubModel() in a wrong order. updateSubModel() was ignored. Must do a beginUpdateModel() for initialization." << std::endl;
689+
std::cerr << "BVH Warning! Call updateSubModel() in a wrong order. updateSubModel() was ignored. Must do a beginUpdateModel() for initialization.\n";
690690
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
691691
}
692692

@@ -704,13 +704,13 @@ int BVHModel<BV>::endUpdateModel(bool refit, bool bottomup)
704704
{
705705
if(build_state != BVH_BUILD_STATE_UPDATE_BEGUN)
706706
{
707-
std::cerr << "BVH Warning! Call endUpdateModel() in a wrong order. endUpdateModel() was ignored. " << std::endl;
707+
std::cerr << "BVH Warning! Call endUpdateModel() in a wrong order. endUpdateModel() was ignored. \n";
708708
return BVH_ERR_BUILD_OUT_OF_SEQUENCE;
709709
}
710710

711711
if(num_vertex_updated != num_vertices)
712712
{
713-
std::cerr << "BVH Error! The updated model should have the same number of vertices as the old model." << std::endl;
713+
std::cerr << "BVH Error! The updated model should have the same number of vertices as the old model.\n";
714714
return BVH_ERR_INCORRECT_DATA;
715715
}
716716

@@ -744,10 +744,10 @@ int BVHModel<BV>::memUsage(int msg) const
744744
int total_mem = mem_bv_list + mem_tri_list + mem_vertex_list + sizeof(BVHModel<BV>);
745745
if(msg)
746746
{
747-
std::cerr << "Total for model " << total_mem << " bytes." << std::endl;
748-
std::cerr << "BVs: " << num_bvs << " allocated." << std::endl;
749-
std::cerr << "Tris: " << num_tris << " allocated." << std::endl;
750-
std::cerr << "Vertices: " << num_vertices << " allocated." << std::endl;
747+
std::cerr << "Total for model " << total_mem << " bytes.\n";
748+
std::cerr << "BVs: " << num_bvs << " allocated.\n";
749+
std::cerr << "Tris: " << num_tris << " allocated.\n";
750+
std::cerr << "Vertices: " << num_vertices << " allocated.\n";
751751
}
752752

753753
return BVH_OK;
@@ -849,7 +849,7 @@ int BVHModel<BV>::buildTree()
849849
num_primitives = num_vertices;
850850
break;
851851
default:
852-
std::cerr << "BVH Error: Model type not supported!" << std::endl;
852+
std::cerr << "BVH Error: Model type not supported!\n";
853853
return BVH_ERR_UNSUPPORTED_FUNCTION;
854854
}
855855

@@ -903,7 +903,7 @@ int BVHModel<BV>::recursiveBuildTree(int bv_id, int first_primitive, int num_pri
903903
}
904904
else
905905
{
906-
std::cerr << "BVH Error: Model type not supported!" << std::endl;
906+
std::cerr << "BVH Error: Model type not supported!\n";
907907
return BVH_ERR_UNSUPPORTED_FUNCTION;
908908
}
909909

@@ -1012,7 +1012,7 @@ int BVHModel<BV>::recursiveRefitTree_bottomup(int bv_id)
10121012
}
10131013
else
10141014
{
1015-
std::cerr << "BVH Error: Model type not supported!" << std::endl;
1015+
std::cerr << "BVH Error: Model type not supported!\n";
10161016
return BVH_ERR_UNSUPPORTED_FUNCTION;
10171017
}
10181018
}

include/fcl/geometry/bvh/detail/BV_splitter-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void BVSplitter<BV>::computeRule(
9090
computeRule_bvcenter(bv, primitive_indices, num_primitives);
9191
break;
9292
default:
93-
std::cerr << "Split method not supported" << std::endl;
93+
std::cerr << "Split method not supported\n";
9494
}
9595
}
9696

include/fcl/math/bv/OBB-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ S OBB<S>::distance(const OBB& other, Vector3<S>* P,
224224
FCL_UNUSED(P);
225225
FCL_UNUSED(Q);
226226

227-
std::cerr << "OBB distance not implemented!" << std::endl;
227+
std::cerr << "OBB distance not implemented!\n";
228228
return 0.0;
229229
}
230230

include/fcl/math/bv/kDOP-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ S KDOP<S, N>::distance(const KDOP<S, N>& other, Vector3<S>* P, Vector3<S>* Q) co
264264
FCL_UNUSED(P);
265265
FCL_UNUSED(Q);
266266

267-
std::cerr << "KDOP distance not implemented!" << std::endl;
267+
std::cerr << "KDOP distance not implemented!\n";
268268
return 0.0;
269269
}
270270

include/fcl/math/geometry-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void eigen_old(const Matrix3<S>& m, Vector3<S>& dout, Matrix3<S>& vout)
556556
}
557557
}
558558

559-
std::cerr << "eigen: too many iterations in Jacobi transform." << std::endl;
559+
std::cerr << "eigen: too many iterations in Jacobi transform.\n";
560560

561561
return;
562562
}

include/fcl/math/rng-inl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,12 @@ void RNG<S>::setSeed(uint_fast32_t seed)
194194
if (detail::Seed::isFirstSeedGenerated())
195195
{
196196
std::cerr << "Random number generation already started. Changing seed now "
197-
<< "will not lead to deterministic sampling." << std::endl;
197+
<< "will not lead to deterministic sampling.\n";
198198
}
199199

200200
if (seed == 0)
201201
{
202-
std::cerr << "Random generator seed cannot be 0. Using 1 instead."
203-
<< std::endl;
202+
std::cerr << "Random generator seed cannot be 0. Using 1 instead.\n";
204203
detail::Seed::setUserSetSeed(1);
205204
}
206205
else

include/fcl/narrowphase/collision-inl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ std::size_t collide(
110110
std::size_t res;
111111
if(request.num_max_contacts == 0)
112112
{
113-
std::cerr << "Warning: should stop early as num_max_contact is " << request.num_max_contacts << " !" << std::endl;
113+
std::cerr << "Warning: should stop early as num_max_contact is " << request.num_max_contacts << " !\n";
114114
res = 0;
115115
}
116116
else
@@ -124,7 +124,7 @@ std::size_t collide(
124124
{
125125
if(!looktable.collision_matrix[node_type2][node_type1])
126126
{
127-
std::cerr << "Warning: collision function between node type " << node_type1 << " and node type " << node_type2 << " is not supported"<< std::endl;
127+
std::cerr << "Warning: collision function between node type " << node_type1 << " and node type " << node_type2 << " is not supported\n";
128128
res = 0;
129129
}
130130
else
@@ -134,7 +134,7 @@ std::size_t collide(
134134
{
135135
if(!looktable.collision_matrix[node_type1][node_type2])
136136
{
137-
std::cerr << "Warning: collision function between node type " << node_type1 << " and node type " << node_type2 << " is not supported"<< std::endl;
137+
std::cerr << "Warning: collision function between node type " << node_type1 << " and node type " << node_type2 << " is not supported\n";
138138
res = 0;
139139
}
140140
else
@@ -201,7 +201,7 @@ std::size_t collide(
201201
return collide(o1, tf1, o2, tf2, &solver, request, result);
202202
}
203203
default:
204-
std::cerr << "Warning! Invalid GJK solver" << std::endl;
204+
std::cerr << "Warning! Invalid GJK solver\n";
205205
return -1; // error
206206
}
207207
}

0 commit comments

Comments
 (0)