1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007 | /*
*
*
* Copyright (C) 2004 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000
* with Sandia Corporation, the U.S. Government retains certain rights in this software.
*
* This file is part of facetbool--contact via [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
*
*/
#include <math.h>
#include <algorithm>
#include "FBRetriangulate.hpp"
#include "FBTiler.hpp"
#include "CubitMessage.hpp"
#ifdef KEEP_BOYD10_KEEP
bool edgecf_less(const FB_Edge* efirst, const FB_Edge* esecond)<--- The function 'edgecf_less' is never used.
{
if ( efirst->quadrant < esecond->quadrant ) return true;
if ( efirst->quadrant > esecond->quadrant ) return false;
if ( efirst->slope < esecond->slope ) return true;
else return false;
}
#endif
FBRetriangulate::FBRetriangulate(std::vector<FB_Coord *>& my_verts,
std::vector<FB_Triangle *>& my_tris,
std::vector<int>& my_newfacets,
std::vector<int>& my_newfacetsindex)
{
verts = my_verts;
tris = &my_tris;
newfacets = &my_newfacets;
newfacetsindex = &my_newfacetsindex;
p_dir=0;
s_dir=0;
}
FBRetriangulate::FBRetriangulate(std::vector<FB_Coord *>& my_verts,
std::vector<FB_Triangle *>& my_tris,
std::vector<int>& my_newfacets)
{
verts = my_verts;
tris = &my_tris;
newfacets = &my_newfacets;
newfacetsindex = 0;
p_dir=0;
s_dir=0;
}
FBRetriangulate::~FBRetriangulate()
{
}
CubitStatus FBRetriangulate::retriangulate_this_tri(int sequence, std::vector<FB_Edge*> &orphaned_edges)
{
CubitStatus status;
double xspan, yspan, zspan;
std::vector<FB_Triangle *>::iterator itt;
itt = tris->begin();
itt += sequence;
my_tri = *itt;
status = CUBIT_SUCCESS;<--- status is assigned
// tri = &itt;
xspan = my_tri->boundingbox.xmax - my_tri->boundingbox.xmin;
yspan = my_tri->boundingbox.ymax - my_tri->boundingbox.ymin;
zspan = my_tri->boundingbox.zmax - my_tri->boundingbox.zmin;
if ( ( fabs(my_tri->c) >= fabs(my_tri->a) ) &&
( fabs(my_tri->c) >= fabs(my_tri->b) ) ) {
p_dir = 1;
s_dir = 0;
if ( xspan > yspan ) {
p_dir = 0;
s_dir = 1;
}
}
else if ( fabs(my_tri->b) >= fabs(my_tri->a) ) {
p_dir = 2;
s_dir = 0;
if ( xspan > zspan ) {
p_dir = 0;
s_dir = 2;
}
}
else {
p_dir = 1;
s_dir = 2;
if ( zspan > yspan ) {
p_dir = 2;
s_dir = 1;
}
}
if ( p_dir == 0 ) {
if ( s_dir == 1 ) {
if ( my_tri->c > 0.0 )
winding = CCW;
else
winding = CW;
}
else if (s_dir == 2 ) {
if ( my_tri->b > 0.0 )
winding = CW;
else
winding = CCW;
}
}
else if ( p_dir == 1 ) {
if ( s_dir == 0 ) {
if ( my_tri->c > 0.0 )
winding = CW;
else
winding = CCW;
}
else if (s_dir == 2 ) {
if ( my_tri->a > 0.0 )
winding = CW;
else
winding = CCW;
}
}
else if ( p_dir == 2 ) {
if ( s_dir == 0 ) {
if ( my_tri->b > 0.0 )
winding = CCW;
else
winding = CW;
}
else if (s_dir == 1 ) {
if ( my_tri->a > 0.0 )
winding = CCW;
else
winding = CW;
}
}
else{
PRINT_ERROR("Unexpected result.\n");
return CUBIT_FAILURE;
}
//if ( winding == CCW ) winding = CW;
//else winding = CCW;
classify_edges();
// Add edges around the perimeter of the triangle to its edge list.
status = add_bdry_edges(orphaned_edges);<--- status is overwritten<--- status is assigned
make_vert_list();
// Add internal edges where there is a local min or max
status = remove_min_max();<--- status is overwritten
// Get the vertex chains that will be retriangulated.
bool chain_status = true;
sort_vertstufflist_edges();
std::vector<int> *chainlist = new std::vector<int>;
// std::vector<FB_Triangle* > new_tris;
unsigned int i, nfsize;
nfsize = newfacets->size();
while (chain_status == true ) {
chain_status = get_a_chain(chainlist);
if ( chain_status == false ) break;
FBTiler *tiler = new FBTiler(verts,p_dir,s_dir,sequence,
my_tri->a,my_tri->b,my_tri->c,newfacets);
status = tiler->Tile_Poly(chainlist);
delete tiler;
chainlist->clear();
}
delete chainlist;
unsigned int number_new;
int e0index, e1index, e2index;<--- The scope of the variable 'e0index' can be reduced. [+]The scope of the variable 'e0index' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e1index' can be reduced. [+]The scope of the variable 'e1index' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e2index' can be reduced. [+]The scope of the variable 'e2index' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
number_new = newfacets->size() - nfsize;
if ( number_new > 0 ) {
std::vector<int>::iterator itp;
itp = newfacets->begin();
itp += nfsize;
for ( i = 0; i < number_new; i += 3 ) {
FB_Triangle *new_tri;
e0index = e1index = e2index = 0;
get_edge_indices(*itp,*(itp+1),*(itp+2),sequence,
e0index, e1index, e2index);
new_tri = new FB_Triangle(*itp,*(itp+1),*(itp+2),
sequence,my_tri->cubitsurfaceindex,
e0index, e1index, e2index);
tris->push_back(new_tri);
itp += 3;
}
if ( newfacetsindex ) newfacetsindex->push_back(nfsize);
}
for ( i = 0; i < vertstufflist.size(); i++ ) {
delete vertstufflist[i];
}
vertstufflist.clear();
return status;
}
CubitStatus FBRetriangulate::remove_min_max()
{
CubitStatus status;
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe;
bool goes_down, goes_up;
VertexStuff *vstuff;
unsigned int i;
int this_vert, that_vert;
double this_vert_p_dir_coord, that_vert_p_dir_coord;
status = CUBIT_SUCCESS;
for ( i = 0; i < vertstufflist.size(); i++ ) {
vstuff = vertstufflist[i];
if ( vstuff->v0type != INTERIOR_VERT ) continue;
goes_down = goes_up = false;
this_vert = vstuff->v0;
this_vert_p_dir_coord = verts[this_vert]->coord[p_dir];
dpe = vstuff->edge_list.begin();
while ( dpe != vstuff->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( edge->v0 == this_vert ) that_vert = edge->v1;
else that_vert = edge->v0;
that_vert_p_dir_coord = verts[that_vert]->coord[p_dir];
if ( that_vert_p_dir_coord < this_vert_p_dir_coord )
goes_down = true;
else if ( that_vert_p_dir_coord > this_vert_p_dir_coord )
goes_up = true;
else {
double this_vert_s_dir_coord, that_vert_s_dir_coord;
this_vert_s_dir_coord = verts[this_vert]->coord[s_dir];
that_vert_s_dir_coord = verts[that_vert]->coord[s_dir];
if ( this_vert_s_dir_coord < that_vert_s_dir_coord )
goes_up = true;
else goes_down = true;
}
}
if ( goes_down == false ) {
add_edge_down(this_vert,i);
} else if ( goes_up == false ) {
add_edge_up(this_vert,i);
}
}
return status;
}
CubitStatus FBRetriangulate::add_bdry_edges(std::vector<FB_Edge*> &orphaned_edges)
{
// For each triangle edge, make a list of pairs of edge points and
// vertex numbers that touch the edge. Then sort the list by distance
// from the start of the edge. (This was what we really put in the
// pair, not the point itself.) Finally, go through this sorted list
// and add edges to the edge_list. If the edge_list is empty, we
// still must add in the triangle edge itself.
CubitStatus status;
FB_Edge *edge;
std::list< std::pair<double,int> > edge0_list, edge1_list, edge2_list;
std::list< std::pair<double,int> >::iterator dp;
std::vector<FB_Edge*>::iterator dpe, dpe_orig;
double vx0, vy0, vz0, vx1, vy1, vz1, vx2, vy2, vz2, dist;
std::pair<double,int> mypair;
status = CUBIT_SUCCESS;
vx0 = verts[my_tri->v0]->coord[0];
vy0 = verts[my_tri->v0]->coord[1];
vz0 = verts[my_tri->v0]->coord[2];
vx1 = verts[my_tri->v1]->coord[0];
vy1 = verts[my_tri->v1]->coord[1];
vz1 = verts[my_tri->v1]->coord[2];
vx2 = verts[my_tri->v2]->coord[0];
vy2 = verts[my_tri->v2]->coord[1];
vz2 = verts[my_tri->v2]->coord[2];
dpe = my_tri->edge_list.begin();
while ( dpe != my_tri->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( (edge->v0_type == INTERIOR_VERT) &&
(edge->v1_type == INTERIOR_VERT) )
continue;
if ( edge->v0_type == EDGE_0 ) {
dist = get_dist(vx0,vy0,vz0,verts[edge->v0]->coord[0],
verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
edge0_list.push_back(std::pair<double,int>(dist,edge->v0));
} else if ( edge->v0_type == EDGE_1 ) {
dist = get_dist(vx1,vy1,vz1,verts[edge->v0]->coord[0],
verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
edge1_list.push_back(std::pair<double,int>(dist,edge->v0));
} else if ( edge->v0_type == EDGE_2 ) {
dist = get_dist(vx2,vy2,vz2,verts[edge->v0]->coord[0],
verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
edge2_list.push_back(std::pair<double,int>(dist,edge->v0));
}
if ( edge->v1_type == EDGE_0 ) {
dist = get_dist(vx0,vy0,vz0,verts[edge->v1]->coord[0],
verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
edge0_list.push_back(std::pair<double,int>(dist,edge->v1));
} else if ( edge->v1_type == EDGE_1 ) {
dist = get_dist(vx1,vy1,vz1,verts[edge->v1]->coord[0],
verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
edge1_list.push_back(std::pair<double,int>(dist,edge->v1));
} else if ( edge->v1_type == EDGE_2 ) {
dist = get_dist(vx2,vy2,vz2,verts[edge->v1]->coord[0],
verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
edge2_list.push_back(std::pair<double,int>(dist,edge->v1));
}
}
edge0_list.sort();
edge1_list.sort();
edge2_list.sort();
// Now we have to remove all BDRY_EDGEs because they will be made anew
// in what follows. Erasing elements from a vector is inefficient, but
// this shouldn't happen often.
dpe = my_tri->edge_list.begin();
dpe_orig = my_tri->edge_list.end();
while ( dpe != dpe_orig ) {
edge = *dpe;
if ( edge->edge_type == BDRY_EDGE ) {
dpe = my_tri->edge_list.erase(dpe);
orphaned_edges.push_back(edge);
dpe_orig = my_tri->edge_list.end();
} else {
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
}
int newv0, newv1, newv0_type, newv1_type;
newv0_type = newv1_type = EDGE_0;
newv0 = my_tri->v0;
dp = edge0_list.begin();
while ( dp != edge0_list.end() ) {
mypair = *dp;
newv1 = mypair.second;
// It is possible to get the same vert more than once in the list.
// After sorting, they will be adjacent. The following if statement
// causes duplicate verts to be used only once.
if ( newv0 != newv1 ) {
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
newv0 = newv1;
}
dp++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
newv1 = my_tri->v1;
if ( newv0 != newv1 )
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
newv0_type = newv1_type = EDGE_1;
newv0 = my_tri->v1;
dp = edge1_list.begin();
while ( dp != edge1_list.end() ) {
mypair = *dp;
newv1 = mypair.second;
if ( newv0 != newv1 ) {
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
newv0 = newv1;
}
dp++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
newv1 = my_tri->v2;
if ( newv0 != newv1 )
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
newv0_type = newv1_type = EDGE_2;
newv0 = my_tri->v2;
dp = edge2_list.begin();
while ( dp != edge2_list.end() ) {
mypair = *dp;
newv1 = mypair.second;
if ( newv0 != newv1 ) {
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
newv0 = newv1;
}
dp++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
newv1 = my_tri->v0;
if ( newv0 != newv1 )
add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
return status;
}
void FBRetriangulate::add_this_bdry_edge(int v0, int v1, int v0_type,
int v1_type)
{
// Add an edge if it doesn't already exist.
std::vector<FB_Edge*>::iterator dpe;
bool ifoundit;
FB_Edge *edge, *new_edge;<--- The scope of the variable 'edge' can be reduced. [+]The scope of the variable 'edge' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'new_edge' can be reduced. [+]The scope of the variable 'new_edge' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
ifoundit = false;
dpe = my_tri->edge_list.begin();
while ( dpe != my_tri->edge_list.end() ) {
edge = *dpe;
if ( ( ((int)edge->v0 == v0) && ((int)edge->v1 == v1) ) ||
( ((int)edge->v0 == v1) && ((int)edge->v1 == v0) ) ) {
ifoundit = true;
break;
}
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
if ( ifoundit == false ) {
new_edge = new FB_Edge(v0,v1,v0_type,v1_type,true);
new_edge->edge_type = BDRY_EDGE;
my_tri->edge_list.push_back(new_edge);
}
}
void FBRetriangulate::make_vert_list()
{
unsigned int i;
int v0, v1;<--- The scope of the variable 'v0' can be reduced. [+]The scope of the variable 'v0' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'v1' can be reduced. [+]The scope of the variable 'v1' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
FB_Edge *edge;
VertexStuff *vstuff;
std::vector<FB_Edge*>::iterator dpe;
bool foundv0, foundv1; <--- The scope of the variable 'foundv0' can be reduced. [+]The scope of the variable 'foundv0' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'foundv1' can be reduced. [+]The scope of the variable 'foundv1' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
dpe = my_tri->edge_list.begin();
while ( dpe != my_tri->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
v0 = edge->v0;
v1 = edge->v1;
foundv0 = foundv1 = false;
for ( i = 0; i < vertstufflist.size(); i++ ) {
if ( vertstufflist[i]->v0 == v0 ) {
vertstufflist[i]->edge_list.push_back(edge);
foundv0 = true;
}
if ( vertstufflist[i]->v0 == v1 ) {
vertstufflist[i]->edge_list.push_back(edge);
foundv1 = true;
}
}
if ( foundv0 == false ) {
vstuff = new VertexStuff(v0, edge->v0_type,verts[v0]->coord[p_dir],
verts[v0]->coord[s_dir]);
vstuff->edge_list.push_back(edge);
vertstufflist.push_back(vstuff);
}
if ( foundv1 == false ) {
vstuff = new VertexStuff(v1, edge->v1_type,verts[v1]->coord[p_dir],
verts[v1]->coord[s_dir]);
vstuff->edge_list.push_back(edge);
vertstufflist.push_back(vstuff);
}
}
std::vector<VertexStuff* >::iterator vitbegin, vitend;
vitbegin = vertstufflist.begin();
vitend = vertstufflist.end();
std::sort(vitbegin,vitend,vertstuffcompfn_less());
}
void FBRetriangulate::add_edge_up(int v0, int seq)
{
unsigned int i, k;
int v1, v0test, v1test, v0type, v1type;
bool foundit, crossed;<--- The scope of the variable 'foundit' can be reduced. [+]The scope of the variable 'foundit' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe;
v1 = 0; //To keep compiler from warning that v1 might be used uninitialized.
v1type = 0;
v0type = vertstufflist[seq]->v0type;
for ( k = seq+1; k < vertstufflist.size(); k++ ) {
foundit = true;
v1 = vertstufflist[k]->v0;
if ( fabs(verts[v1]->coord[p_dir]-verts[v0]->coord[p_dir]) < EPSILON )
continue;
v1type = vertstufflist[k]->v0type;
// v0 to v1 is the putative new edge. Test whether it crosses any
// existing internal edge. Any such internal edge that it crosses
// has to have an endpoint higher than v1. If v1 is the next-to-top
// vertex, use it.
if ( k == vertstufflist.size() - 1 ) {
foundit = true;<--- Variable 'foundit' is assigned a value that is never used.
add_tri_edge(v0,v1,v0type,v1type);
return;
}
for ( i = k+1; i < vertstufflist.size()-1; i++ ) {
dpe = vertstufflist[i]->edge_list.begin();
while ( dpe != vertstufflist[i]->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( (edge->v0_type != INTERIOR_VERT) &&
(edge->v1_type != INTERIOR_VERT) )
continue;
v0test = edge->v0;
v1test = edge->v1;
if ( (v0test == v1) || (v1test == v1) ) continue;
crossed = test_for_crossing(v0,v1,v0test,v1test);
if ( crossed == true ) {
foundit = false;
break;
}
}
if ( foundit == false ) break;
} // end of "for (i ...."
if ( foundit == true ) break;
}
add_tri_edge(v0,v1,v0type,v1type);
}
void FBRetriangulate::add_edge_down(int v0, int seq)
{
int i, k;
int v1, v0test, v1test, v0type, v1type;
bool foundit, crossed;<--- The scope of the variable 'foundit' can be reduced. [+]The scope of the variable 'foundit' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe;
v1 = 0; //To keep compiler from warning that v1 might be used uninitialized.
v1type = 0;
v0type = vertstufflist[seq]->v0type;
for ( k = seq-1; k > -1; k-- ) {
foundit = true;
v1 = vertstufflist[k]->v0;
if ( fabs(verts[v1]->coord[p_dir]-verts[v0]->coord[p_dir]) < EPSILON ) continue;
v1type = vertstufflist[k]->v0type;
// v0 to v1 is the putative new edge. Test whether it crosses
// any existing internal edge. Any such internal edge that it
// crosses has to have an endpoint higher than v1. If v1 is the
// next-to-top vertex, use it.
if ( k == 0 ) {
foundit = true;<--- Variable 'foundit' is assigned a value that is never used.
add_tri_edge(v0,v1,v0type,v1type);
return;
}
for ( i = k-1; i > 0; i-- ) {
dpe = vertstufflist[i]->edge_list.begin();
while ( dpe != vertstufflist[i]->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( (edge->v0_type != INTERIOR_VERT) &&
(edge->v1_type != INTERIOR_VERT) )
continue;
v0test = edge->v0;
v1test = edge->v1;
if ( (v0test == v1) || (v1test == v1) ) continue;
crossed = test_for_crossing(v0,v1,v0test,v1test);
if ( crossed == true ) {
foundit = false;
break;
}
}
if ( foundit == false ) break;
} // end of "for (i ...."
if ( foundit == true ) break;
}
add_tri_edge(v0,v1,v0type,v1type);
}
bool FBRetriangulate::test_for_crossing(int v0, int v1, int v2, int v3)
{
double x0, y0, x1, y1, x2, y2, x3, y3, dxa, dya, dxb, dyb, p01x, p01y;<--- The scope of the variable 'p01x' can be reduced. [+]The scope of the variable 'p01x' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'p01y' can be reduced. [+]The scope of the variable 'p01y' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
double product, dasq, dbsq, prodsq;
double s, t;<--- The scope of the variable 's' can be reduced. [+]The scope of the variable 's' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 't' can be reduced. [+]The scope of the variable 't' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
x0 = verts[v0]->coord[p_dir]; y0 = verts[v0]->coord[s_dir];
x1 = verts[v1]->coord[p_dir]; y1 = verts[v1]->coord[s_dir];
x2 = verts[v2]->coord[p_dir]; y2 = verts[v2]->coord[s_dir];
x3 = verts[v3]->coord[p_dir]; y3 = verts[v3]->coord[s_dir];
dxa = x1 - x0; dya = y1 - y0;
dxb = x3 - x2; dyb = y3 - y2;
product = dxa*dyb - dya*dxb;
dasq = dxa*dxa + dya*dya;
dbsq = dxb*dxb + dyb*dyb;
prodsq = product*product;
if ( prodsq > EPSILON2*dasq*dbsq ) {
p01x = x2 - x0;
p01y = y2 - y0;
s = (p01x*dyb - p01y*dxb)/product;
if ( (s < 0.0) || (s > 1.0) ) return false;
t = (p01x*dya - p01y*dxa)/product;
if ( (t < 0.0) || (t > 1.0) ) return false;
}
return true;
}
void FBRetriangulate::add_tri_edge(int v0, int v1, int v0_type, int v1_type)
{
FB_Edge *edge;
unsigned int i;
edge = new FB_Edge(v0,v1,v0_type,v1_type,false);
edge->edge_type = INTERIOR_EDGE;
my_tri->edge_list.push_back(edge);
for ( i = 0; i < vertstufflist.size(); i++ ) {
if ( vertstufflist[i]->v0 == v0 ) {
vertstufflist[i]->edge_list.push_back(edge);
}
if ( vertstufflist[i]->v0 == v1 ) {
vertstufflist[i]->edge_list.push_back(edge);
v1_type = vertstufflist[i]->v0type;
}
}
}
bool FBRetriangulate::get_a_chain(std::vector<int> *chainlist)
{
bool status;
int vthis, vprev, vstart;
int direction;
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe;
status = false;
dpe = my_tri->edge_list.begin();
// to keep compiler from warning that edge might be used uninitialized
edge = 0;
while ( dpe != my_tri->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
// Skip edges that are not interior edges.
// if ( edge->v0_type == edge->v1_type ) continue;
if ( edge->edge_type == BDRY_EDGE ) continue;
if ( edge->num_times < 2 ) {
if ( (edge->edge_type == BDRY_EDGE) && (edge->num_times == 1) )
continue;
status = true;
edge->num_times++;
break;
}
}
if ( status == true ) {
if ( edge->num_times == 1 ) {
vthis = edge->v1;
vprev = edge->v0;
direction = 1;
} else {
vthis = edge->v0;
vprev = edge->v1;
direction = 1;
}
vstart = vprev;
chainlist->push_back(vthis);
while ( vthis != vstart ) {
get_next_vert_in_chain(vthis,vprev,direction);
chainlist->push_back(vthis);
}
}
if ( status == false ) { // There were no interior edges.
// So just go around the perimeter.
dpe = my_tri->edge_list.begin();
edge = *dpe;
if ( edge->num_times != 0 ) {
status = false;
return status;
}
edge->num_times = 1;
vthis = edge->v0;
vprev = edge->v1;
direction = 1;
vstart = vprev;
chainlist->push_back(vthis);
while ( vthis != vstart ) {
get_next_vert_in_chain(vthis,vprev,direction);
chainlist->push_back(vthis);
}
status = true;
}
return status;
}
void FBRetriangulate::get_next_vert_in_chain(int& vthis,
int& vprev, int direction)
// Right now, direction always equals 1.
{
unsigned int i;
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe, dpebegin, dpeend;
for ( i = 0; i < vertstufflist.size(); i++ ) {
if ( vertstufflist[i]->v0 == (int)vthis ) break;
}
dpe = dpebegin = vertstufflist[i]->edge_list.begin();
dpeend = vertstufflist[i]->edge_list.end();
while ( dpe != dpeend ) {
edge = *dpe;
if ( (edge->v0 == vprev) || (edge->v1 == vprev) ) break;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
if ( direction == 1 ) {
if ( dpe == dpebegin )
dpe = vertstufflist[i]->edge_list.end();
dpe--; <--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
} else {
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( dpe == dpeend )
dpe = dpebegin;
}
edge = *dpe;
vprev = vthis;
if ( vthis == edge->v1 ) {
// Swap the edge verts. We do this so that next time we see this
// edge we will know that it was oriented to point in the direction
// of the previous loop. Thus we will know to proceed in the
// opposite direction next time.
// (see edge->num_times test in get_a_chain().)
unsigned int vtemp;
vtemp = edge->v0;
edge->v0 = edge->v1;
edge->v1 = vtemp;
vtemp = edge->v0_type;
edge->v0_type = edge->v1_type;
edge->v1_type = vtemp;
}
vthis = edge->v1;
edge->num_times++;
}
void FBRetriangulate::sort_vertstufflist_edges()
{
// For each vertex that has more than 2 edges, sort the edges in CCW order.
unsigned int i;
FB_Edge *edge;
std::vector<FB_Edge*>::iterator dpe, dpebegin, dpeend;
double x0, y0, x1, y1, slope;
int v0;
unsigned int quadrant;
quadrant = 0; // Initialize so compiler won't warn.
for ( i = 0; i < vertstufflist.size(); i++ ) {
if ( vertstufflist[i]->edge_list.size() > 2 ) {
v0 = vertstufflist[i]->v0;
x0 = verts[v0]->coord[p_dir];
y0 = verts[v0]->coord[s_dir];
dpe = vertstufflist[i]->edge_list.begin();
while ( dpe != vertstufflist[i]->edge_list.end() ) {
edge = *dpe;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
if ( edge->v0 == v0 ) {
x1 = verts[edge->v1]->coord[p_dir];
y1 = verts[edge->v1]->coord[s_dir];
} else {
x1 = verts[edge->v0]->coord[p_dir];
y1 = verts[edge->v0]->coord[s_dir];
}
if ( fabs(x1-x0) < EPSILON ) {
if ( y1 > y0 ) {
slope = CUBIT_DBL_MAX;
quadrant = 1;
} else {
slope = -CUBIT_DBL_MAX;
quadrant = 4;
}
} else {
slope = (y1-y0)/(x1-x0);
if ( (x1 >= x0) && (y1 >= y0) ) quadrant = 1;
else if ( (x1 < x0) && (y1 > y0) ) quadrant = 2;
else if ( (x1 <= x0) && (y1 <= y0) ) quadrant = 3;
else if ( (x1 > x0) && (y1 < y0) ) quadrant = 4;
}
edge->slope = slope;
edge->quadrant = quadrant;
}
// Now sort the edge list by the value of quadrant or slope.
// vertstufflist[i]->edge_list.sort(edgecompfn_less());
// vertstufflist[i]->edge_list.sort(edgecf_less);
dpebegin = vertstufflist[i]->edge_list.begin();
dpeend = vertstufflist[i]->edge_list.end();
// if ( winding == CW )
std::sort(dpebegin,dpeend,edgecompfn_less());
// else
// std::sort(dpebegin,dpeend,edgecompfn_more());
}
dpe = vertstufflist[i]->edge_list.begin();
while ( dpe != vertstufflist[i]->edge_list.end() ) {
edge = *dpe;<--- Variable 'edge' is assigned a value that is never used.
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
}
}
void FBRetriangulate::classify_edges()
{
// Flag boundary edges as such.
FB_Edge *edge;<--- The scope of the variable 'edge' can be reduced. [+]The scope of the variable 'edge' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
std::vector<FB_Edge*>::iterator dpe;
int type;
dpe = my_tri->edge_list.begin();
while ( dpe != my_tri->edge_list.end() ) {
edge = *dpe;
if ( (edge->v0_type != INTERIOR_VERT) &&
(edge->v1_type != INTERIOR_VERT) ) {
if ( edge->v0_type == edge->v1_type )
edge->edge_type = BDRY_EDGE;
else {
type = UNKNOWN;
switch( edge->v0_type ) {
case VERTEX_0:
if ( edge->v1_type != EDGE_1 ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE) {
if ( edge->v1_type == VERTEX_1 )
my_tri->cubitedge0index = INTERSECTION_EDGE;
else if ( edge->v1_type == VERTEX_2 )
my_tri->cubitedge2index = INTERSECTION_EDGE;
}
}
break;
case VERTEX_1:
if ( edge->v1_type != EDGE_2 ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE) {
if ( edge->v1_type == VERTEX_2 )
my_tri->cubitedge1index = INTERSECTION_EDGE;
else if ( edge->v1_type == VERTEX_0 )
my_tri->cubitedge0index = INTERSECTION_EDGE;
}
}
break;
case VERTEX_2:
if ( edge->v1_type != EDGE_0 ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE) {
if ( edge->v1_type == VERTEX_1 )
my_tri->cubitedge1index = INTERSECTION_EDGE;
else if ( edge->v1_type == VERTEX_0 )
my_tri->cubitedge2index = INTERSECTION_EDGE;
}
}
break;
case EDGE_0:
if ( (edge->v1_type == VERTEX_0) ||
(edge->v1_type == VERTEX_1) ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE)
my_tri->cubitedge0index = INTERSECTION_EDGE;
}
break;
case EDGE_1:
if ( (edge->v1_type == VERTEX_1) ||
(edge->v1_type == VERTEX_2) ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE)
my_tri->cubitedge1index = INTERSECTION_EDGE;
}
break;
case EDGE_2:
if ( (edge->v1_type == VERTEX_2) ||
(edge->v1_type == VERTEX_0) ) {
type = BDRY_EDGE;
if ( edge->edge_type == INTERSECTION_EDGE)
my_tri->cubitedge2index = INTERSECTION_EDGE;
}
break;
}
if ( type == BDRY_EDGE ) edge->edge_type = BDRY_EDGE;
}
} // else edge->edge_type = INTERIOR_EDGE;
dpe++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
}
void FBRetriangulate::get_edge_indices(int v0, int v1, int v2, int parent,
int &e0index, int &e1index,
int &e2index)
{
std::vector<FB_Edge*>::iterator itt;
std::vector<FB_Triangle*>::iterator itp;
FB_Edge *edge;
int e_v0, e_v1, e_type, e_v0type, e_v1type;<--- The scope of the variable 'e_v0' can be reduced. [+]The scope of the variable 'e_v0' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e_v1' can be reduced. [+]The scope of the variable 'e_v1' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e_type' can be reduced. [+]The scope of the variable 'e_type' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e_v0type' can be reduced. [+]The scope of the variable 'e_v0type' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'e_v1type' can be reduced. [+]The scope of the variable 'e_v1type' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
itp = tris->begin();
itp += parent;
itt = (*itp)->edge_list.begin();
while ( itt != (*itp)->edge_list.end() ) {
edge = *itt;
e_v0 = edge->v0;
e_v1 = edge->v1;
e_v0type = edge->v0_type;
e_v1type = edge->v1_type;
e_type = edge->edge_type;
if ( ( (e_v0 == v0) && (e_v1 == v1) ) ||
( (e_v0 == v1) && (e_v1 == v0) ) ) {
if ( e_type == INTERSECTION_EDGE )
e0index = INTERSECTION_EDGE;
else if ( e_type == INTERIOR_EDGE )
e0index = 0;
else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
e0index = (*itp)->cubitedge0index;
else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
e0index = (*itp)->cubitedge1index;
else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
e0index = (*itp)->cubitedge2index;
else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
e0index = (*itp)->cubitedge0index;
else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
e1index = (*itp)->cubitedge1index;
else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
e2index = (*itp)->cubitedge2index;
}
else if ( ( (e_v0 == v1) && (e_v1 == v2) ) ||
( (e_v0 == v2) && (e_v1 == v1) ) ) {
if ( e_type == INTERSECTION_EDGE )
e1index = INTERSECTION_EDGE;
else if ( e_type == INTERIOR_EDGE )
e1index = 0;
else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
e1index = (*itp)->cubitedge0index;
else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
e1index = (*itp)->cubitedge1index;
else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
e1index = (*itp)->cubitedge2index;
else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
e0index = (*itp)->cubitedge0index;
else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
e1index = (*itp)->cubitedge1index;
else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
e2index = (*itp)->cubitedge2index;
}
else if ( ( (e_v0 == v2) && (e_v1 == v0) ) ||
( (e_v0 == v0) && (e_v1 == v2) ) ) {
if ( e_type == INTERSECTION_EDGE )
e2index = INTERSECTION_EDGE;
else if ( e_type == INTERIOR_EDGE )
e2index = 0;
else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
e2index = (*itp)->cubitedge0index;
else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
e2index = (*itp)->cubitedge1index;
else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
e2index = (*itp)->cubitedge2index;
else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
e0index = (*itp)->cubitedge0index;
else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
e1index = (*itp)->cubitedge1index;
else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
e2index = (*itp)->cubitedge2index;
}
itt++;<--- Prefer prefix ++/-- operators for non-primitive types. [+]Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
}
}
|