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 | //- File: CAEntitySense.cpp
//- Owner: Corey Ernst
//- Description: Cubit Attribute for entity colors.
//- Checked By:
//- Version:
#include "CAEntitySense.hpp"
#include "RefEntity.hpp"
#include "RefEdge.hpp"
#include "RefFace.hpp"
#include "BridgeManager.hpp"
#include "BasicTopologyEntity.hpp"
#include "CastTo.hpp"
#include "CubitMessage.hpp"
CubitAttrib* CAEntitySense_creator(RefEntity* entity, const CubitSimpleAttrib &p_csa)
{
return new CAEntitySense(entity, p_csa);
}
CAEntitySense::CAEntitySense(RefEntity* new_attrib_owner,
const CubitSimpleAttrib &csa_ptr)
: CubitAttrib(new_attrib_owner)
{
std::vector<int, std::allocator<int> > i_list = csa_ptr.int_data_list();
if( i_list.size() > 0)
{
int i = i_list[0];
if( i == -1 )
entitySense = CUBIT_UNKNOWN;
else if( i == 0 )
entitySense = CUBIT_FORWARD;
else if( i == 1 )
entitySense = CUBIT_REVERSED;
}
else
entitySense = CUBIT_UNKNOWN;
}
CAEntitySense::CAEntitySense(RefEntity* new_attrib_owner)
: CubitAttrib(new_attrib_owner)
{
entitySense = CUBIT_FORWARD;
}
CAEntitySense::~CAEntitySense()
{
}
CubitStatus CAEntitySense::actuate()
{
if ( hasActuated)
return CUBIT_SUCCESS;
if ( !attribOwnerEntity )
return CUBIT_FAILURE;
deleteAttrib = CUBIT_FALSE;
int dimension = attribOwnerEntity->dimension();
if( 1 == dimension || 2 == dimension )
{
BasicTopologyEntity* bte_ptr = CAST_TO(attribOwnerEntity, BasicTopologyEntity);
CubitSense tmp_sense = CUBIT_UNKNOWN;<--- Variable 'tmp_sense' is assigned a value that is never used.
if( bte_ptr )
{
tmp_sense = bte_ptr->bridge_manager()->topology_bridge()->bridge_sense();
if( tmp_sense != entitySense )
{
if( 1==dimension )
{
RefEdge *ref_edge = dynamic_cast<RefEdge*>( bte_ptr );
ref_edge->reverse_tangent();
}
else if( 2 == dimension )
{
RefFace *ref_face = dynamic_cast<RefFace*>( bte_ptr );
ref_face->reverse_normal();
}
}
}
}
hasActuated = CUBIT_TRUE;
return CUBIT_SUCCESS;
}
CubitStatus CAEntitySense::update()
{
int dimension = attribOwnerEntity->dimension();
if( 1 == dimension || 2 == dimension )
{
BasicTopologyEntity* bte_ptr = CAST_TO(attribOwnerEntity, BasicTopologyEntity);
entitySense = CUBIT_UNKNOWN;
if( bte_ptr )
entitySense = bte_ptr->bridge_manager()->topology_bridge()->bridge_sense();
}
if( entitySense == CUBIT_FORWARD || entitySense == CUBIT_UNKNOWN )
delete_attrib(CUBIT_TRUE);
return CUBIT_SUCCESS;
}
CubitSimpleAttrib CAEntitySense::cubit_simple_attrib()
{
std::vector<CubitString> cs_list;
std::vector<int, std::allocator<int> > i_list;
i_list.push_back( entitySense );
cs_list.push_back(att_internal_name());
CubitSimpleAttrib csattrib_ptr(&cs_list, NULL, &i_list);
return csattrib_ptr;
}
void CAEntitySense::print()
{
// print info on this attribute
PRINT_INFO("CAEntitySense: owner = %s %d: color ",
attribOwnerEntity->class_name(), attribOwnerEntity->id());
if( entitySense == CUBIT_UNKNOWN )
PRINT_INFO(" CUBIT_UNKNOWN\n");
else if( entitySense == CUBIT_FORWARD )
PRINT_INFO(" CUBIT_FORWARD\n");
else if( entitySense == CUBIT_REVERSED )
PRINT_INFO(" CUBIT_REVERSED\n");
}
|