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 | // *** BEGIN INCLUDES *** //
#include "GeometryFeatureTool.hpp"
#include "Body.hpp"
#include "RefEntityFactory.hpp"
#include "TopologyEntity.hpp"
#include "CastTo.hpp"
#include "RefFace.hpp"
#include "BasicTopologyEntity.hpp"
#include "TDSourceFeature.hpp"
// *** END INCLUDES *** //
GeometryFeatureTool* GeometryFeatureTool::instance_ = 0;
// *** BEGIN PUBLIC FUNCTIONS *** //
GeometryFeatureTool* GeometryFeatureTool::instance( GeometryFeatureEngine *GFEPtr )
{
// Check to see if we have created an instance of the class;
// if not, proceed to create one.
if (instance_ == 0)
{
// When creating the instance, we should always have a valid
// gfePtr. If not, complain.
instance_ = new GeometryFeatureTool(GFEPtr);
// Check to make sure there's a ref entity factory extant:
// RefEntityFactory *factory =
RefEntityFactory::instance();
}
// If there is an existing instance of the class, check if there
// is a request to set the default engine. If so, do so.
else if ( GFEPtr != NULL && !instance_->gfeList.move_to(GFEPtr) )
{
delete instance_->gfeList.remove();
instance_->gfeList.insert(GFEPtr);
}
// Return the a pointer to the instance of the class.
return instance_;
}
GeometryFeatureTool::~GeometryFeatureTool()
{
for (int i = gfeList.size(); i > 0; i--)
delete gfeList.get_and_step();
gfeList.clean_out();
instance_ = NULL;
}
// *** BEGIN ENGINE OPERATIONS *** //
void GeometryFeatureTool::add_gfe( GeometryFeatureEngine *gfe_ptr )
{
assert(gfe_ptr != 0);
if (!gfeList.move_to(gfe_ptr))
gfeList.append(gfe_ptr);
}
GeometryFeatureEngine* GeometryFeatureTool::get_engine( TopologyBridge *tb_ptr ) const
{
GeometryFeatureEngine *gfe;<--- The scope of the variable 'gfe' can be reduced. [+]The scope of the variable 'gfe' 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.
for (int i = 0; i < gfeList.size(); i++)
{
gfe = gfeList.next(i);
if (gfe->is_feature_engine(tb_ptr))
return gfe;
}
return NULL;
}
GeometryFeatureEngine* GeometryFeatureTool::get_engine( TopologyEntity *te_ptr ) const
{
GeometryFeatureEngine *gfe;<--- The scope of the variable 'gfe' can be reduced. [+]The scope of the variable 'gfe' 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.
TopologyBridge *tb_ptr = te_ptr->bridge_manager()->topology_bridge();
for (int i = 0; i < gfeList.size(); i++)
{
gfe = gfeList.next(i);
if (gfe->is_feature_engine(tb_ptr))
return gfe;
}
return NULL;
}
CubitBoolean GeometryFeatureTool::same_feature_engine( DLIList<RefEntity*> &ref_entity_list,
CubitBoolean check_children ) const
{
DLIList<RefEntity*> complete_entity_list;
//Check the check_children option and check all the children if necessary
if (check_children)
{
//Make a complete list of all the RefEntities and their children
DLIList<RefEntity*> temp = ref_entity_list;
RefEntity* ref_entity_ptr;<--- The scope of the variable 'ref_entity_ptr' can be reduced. [+]The scope of the variable 'ref_entity_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.
for (int i = 0; i < ref_entity_list.size(); i++)
{
ref_entity_ptr = ref_entity_list.get_and_step();
complete_entity_list.clean_out();
ref_entity_ptr->get_all_child_ref_entities(complete_entity_list);
temp += complete_entity_list;
}
complete_entity_list.clean_out();
complete_entity_list.merge_unique(temp);
}
//Now make sure all the RefEntities are from the same geometry engine
DLIList<TopologyEntity*> te_list;
CAST_LIST(complete_entity_list, te_list, TopologyEntity);
return same_feature_engine(te_list);
}
CubitBoolean GeometryFeatureTool::same_feature_engine( DLIList<TopologyEntity*> &topo_list ) const
{
GeometryFeatureEngine *gePtr1 = get_engine(topo_list.get_and_step());
GeometryFeatureEngine *gePtr2;<--- The scope of the variable 'gePtr2' can be reduced. [+]The scope of the variable 'gePtr2' 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.
for (int i = 1; i < topo_list.size(); i++)
{
gePtr2 = get_engine(topo_list.get_and_step());
if (gePtr1 != gePtr2)
{
return CUBIT_FALSE;
}
}
return CUBIT_TRUE;
}
// *** END ENGINE OPERATIONS *** //
// *** BEGIN FEATURE FUNCTIONS *** //
GeometryFeatureEngine::FeatureType
GeometryFeatureTool::feature_type(BasicTopologyEntity* bte)
{
// first check to see if the feature information is in the tool data
TDSourceFeature *tdss = 0;
tdss = (TDSourceFeature *)bte->
get_TD(&TDSourceFeature::is_source_feature);
if(tdss)
return tdss->source_feature();
// if the feature information is not in the tool data
// then call the engine specific FeatureEngine
TopologyEntity* topo_ptr = CAST_TO(bte, TopologyEntity);
if (!topo_ptr)
return GeometryFeatureEngine::FEATURE_UNDEFINED;
GeometryFeatureEngine* gfe = get_engine(topo_ptr);
if(!gfe)
return GeometryFeatureEngine::FEATURE_UNDEFINED;
return gfe->feature_type(bte->get_geometry_entity_ptr());
}
CubitStatus GeometryFeatureTool::get_related_by_feature(
BasicTopologyEntity* bte,
DLIList<GeometryEntity*>& return_list)
{
TopologyEntity* topo_ptr = CAST_TO(bte, TopologyEntity);
if (!topo_ptr)
return CUBIT_FAILURE;
GeometryFeatureEngine* gfe = get_engine(topo_ptr);
if(!gfe)
return CUBIT_FAILURE;
return gfe->get_related_by_feature(bte->get_geometry_entity_ptr(),return_list);
}
DLIList<GeometryFeatureEngine::FeatureType>
GeometryFeatureTool::available_feature_types(BasicTopologyEntity* bte)
{
TopologyEntity* topo_ptr = CAST_TO(bte, TopologyEntity);
DLIList<GeometryFeatureEngine::FeatureType> null_list;
if (!topo_ptr)
return null_list;
GeometryFeatureEngine* gfe = get_engine(topo_ptr);
if(!gfe)
return null_list;
return gfe->available_feature_types(bte->get_geometry_entity_ptr());
}
// *** END PUBLIC FUNCTIONS *** //
// *** BEGIN PROTECTED FUNCTIONS *** //
GeometryFeatureTool::GeometryFeatureTool( GeometryFeatureEngine* GFEPtr )
{
if (GFEPtr != NULL)
add_gfe(GFEPtr);
}
// *** END PROTECTED FUNCTIONS *** //
// *** BEGIN PRIVATE FUNCTIONS *** //
// *** END PRIVATE FUNCTIONS *** //
|