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 | //-------------------------------------------------------------------------
// Filename : MidPlaneTool.hpp
//
// Purpose : Create a mide surface between the two planar
// surfaces passed in by the tool.
//
// Special Notes :
//
// Creator : David White
//
// Creation Date : 9/30/00
//-------------------------------------------------------------------------
#include "MidPlaneTool.hpp"
#include "CubitVector.hpp"
#include "CubitPlane.hpp"
#include "RefFace.hpp"
#include "RefEdge.hpp"
#include "Loop.hpp"
#include "Body.hpp"
#include "CubitMessage.hpp"
#include "GeometryModifyTool.hpp"
#include "GeometryQueryTool.hpp"
#include "DLIList.hpp"
CubitStatus MidPlaneTool::sort_surfaces(RefFace* base_face,
RefFace* predecessor,
DLIList <RefFace*> &mid_surfaces)
{
DLIList <Loop*> loop_list;
DLIList <RefEdge*> loop_edges;
DLIList <RefFace*> edge_faces;
RefFace *next_face;
RefEdge *temp_edge;<--- The scope of the variable 'temp_edge' can be reduced. [+]The scope of the variable 'temp_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.
Loop* temp_loop;<--- The scope of the variable 'temp_loop' can be reduced. [+]The scope of the variable 'temp_loop' 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.
base_face->ordered_loops( loop_list );
if(loop_list.size() == 1)
{
if(surfIndex%2==1)
{
mid_surfaces.append(base_face);
}
if ( predecessor == NULL )
{
PRINT_ERROR("Bad logic in mid-plane extraction of sorting surfaces.\n");
return CUBIT_SUCCESS;
}
//Now test to see if there are other surfaces attached to this
//single loop (other than predecessor)
DLIList <RefFace*> other_surfs;
CubitStatus tmp_stat = get_other_surfs(base_face, predecessor, other_surfs);
if ( tmp_stat != CUBIT_SUCCESS )
return CUBIT_FAILURE;
int jj;
for ( jj = other_surfs.size(); jj > 0; jj-- )
{
next_face = other_surfs.get_and_step();
surfIndex++;
sort_surfaces(next_face,base_face,mid_surfaces);
surfIndex--;
}
return CUBIT_SUCCESS;
}
if(surfIndex%2==1)
{
mid_surfaces.append(base_face);
}
loop_list.reset();
loop_list.remove();
for ( int ii = loop_list.size(); ii > 0; ii-- )
{
temp_loop = loop_list.get_and_step();
loop_edges.clean_out();
edge_faces.clean_out();
temp_loop->ref_edges( loop_edges );
temp_edge = loop_edges.get();
temp_edge->ref_faces( edge_faces );
if( edge_faces.size() > 2 )
{
PRINT_ERROR("Bad Logic.\n");
return CUBIT_FAILURE;
}
if(edge_faces.size() == 2)
{
if(edge_faces.get() == base_face)
{
next_face = edge_faces.next();
} else
{
next_face = edge_faces.get();
}
surfIndex++;
sort_surfaces(next_face,base_face,mid_surfaces);
surfIndex--;
}
}
return CUBIT_SUCCESS;
}
CubitStatus MidPlaneTool::get_other_surfs(RefFace* base_face,
RefFace* predecessor,
DLIList <RefFace*> &other_surfs)
{
DLIList <Loop*> loop_list;
DLIList <RefEdge*> loop_edges;
DLIList <RefFace*> edge_faces;
RefFace *temp_face;
RefEdge *temp_edge;
Loop* temp_loop;<--- The scope of the variable 'temp_loop' can be reduced. [+]The scope of the variable 'temp_loop' 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.
base_face->loops( loop_list );
for ( int ii = loop_list.size(); ii > 0; ii-- )
{
temp_loop = loop_list.get_and_step();
loop_edges.clean_out();
temp_loop->ref_edges( loop_edges );
for ( int jj = loop_edges.size(); jj > 0; jj-- )
{
temp_edge = loop_edges.get_and_step();
edge_faces.clean_out();
temp_edge->ref_faces( edge_faces );
for ( int kk = edge_faces.size(); kk > 0; kk-- )
{
temp_face = edge_faces.get_and_step();
if ( ( temp_face != base_face ) && ( temp_face != predecessor ) )
{
other_surfs.append_unique( temp_face );
}
}
}
}
return CUBIT_SUCCESS;
}
|