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 | //- Class: ChollaPoint
//- Description: Temporary class for constructing the facet-based geometry
//-
//- Owner: Steven J. Owen
//- Checked by:
//- Version:
#include "ChollaPoint.hpp"
#include "ChollaCurve.hpp"
#include "ChollaSurface.hpp"
//===============================================================================
//Function: ChollaPoint (PUBLIC) (constructor)
//===============================================================================
ChollaPoint::ChollaPoint( )
{
static int count = 1;
id = count++;
myCubitPoint = NULL;
myPoint = NULL;
myMergePartner = NULL;
}
//===============================================================================
//Function: ~ChollaPoint (PUBLIC) (destructor)
//===============================================================================
ChollaPoint::~ChollaPoint()
{
}
//===============================================================================
//Function: get_surfaces (PUBLIC)
//===============================================================================
void ChollaPoint::get_surfaces(DLIList<ChollaSurface *> &surf_list)
{
int ii, jj;
ChollaCurve *curv_ptr;
DLIList<ChollaSurface*> *surf_list_ptr;
ChollaSurface *surf_ptr;
curveList.reset();
for(ii=0; ii<curveList.size(); ii++)
{
curv_ptr = curveList.get_and_step();
surf_list_ptr = curv_ptr->get_surface_list_ptr();
for(jj=0; jj<surf_list_ptr->size(); jj++)
{
surf_ptr = surf_list_ptr->get_and_step();
surf_list.append_unique( surf_ptr );
}
}
}
//===============================================================================
//Function: is_in_surface (PUBLIC)
//===============================================================================
CubitBoolean ChollaPoint::is_in_surface( ChollaSurface *cholla_surf )
{
int ii;
ChollaCurve *curv_ptr;
DLIList<ChollaSurface*> *surf_list_ptr;<--- The scope of the variable 'surf_list_ptr' can be reduced. [+]The scope of the variable 'surf_list_ptr' 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.
curveList.reset();
for(ii=0; ii<curveList.size(); ii++)
{
curv_ptr = curveList.get_and_step();
surf_list_ptr = curv_ptr->get_surface_list_ptr();
if( surf_list_ptr->is_in_list( cholla_surf ) )
return CUBIT_TRUE;
}
return CUBIT_FALSE;
}
//===============================================================================
//Function: is_in_volume (PUBLIC)
//===============================================================================
CubitBoolean ChollaPoint::is_in_volume( ChollaVolume *cholla_vol )
{
int ii;
ChollaCurve *curv_ptr; <--- The scope of the variable 'curv_ptr' can be reduced. [+]The scope of the variable 'curv_ptr' 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.
curveList.reset();
for(ii=0; ii<curveList.size(); ii++)
{
curv_ptr = curveList.get_and_step();
if( curv_ptr->is_in_volume( cholla_vol ) )
return CUBIT_TRUE;
}
return CUBIT_FALSE;
}
//===============================================================================
//Function: is_in_curve (PUBLIC)
//===============================================================================
CubitBoolean ChollaPoint::is_in_curve( ChollaCurve *chcurve )
{
for (int ii=0; ii<curveList.size(); ii++)
{
ChollaCurve *curv = curveList.get_and_step();
if (curv == chcurve)
return CUBIT_TRUE;
}
return CUBIT_FALSE;
}
//=============================================================================
//Function: verify_curves (PUBLIC)
//Description: verify that all curves at this point have this point as an adjacency
//Notes:
//=============================================================================
CubitStatus ChollaPoint::verify_curves()
{
for(int ii=0; ii<curveList.size(); ii++)
{
ChollaCurve *crv = curveList.get_and_step();
if (!crv->has_point(this))
return CUBIT_FAILURE;
}
return CUBIT_SUCCESS;
}
//EOF
|