Skip to content

Commit c1c5a3d

Browse files
committed
Made sure zone "istate" variable is consistent and querey-able. Made some
changes and cleaned-up unused variable "iordered" from zone. Continuing development. Framework is incomplete. IN 2017/06/27
1 parent 22410e0 commit c1c5a3d

2 files changed

Lines changed: 93 additions & 9 deletions

File tree

‎intecplot.cpp‎

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ inTec_Zone::inTec_Zone( inTec_File* file_ )
6262

6363
// keyword-based variables
6464
tkey = NULL;
65-
iordered = -1;
6665
ietype = -1;
6766
idatapack = -1;
6867
im = 0;
@@ -100,12 +99,26 @@ inTec_Zone::inTec_Zone( inTec_File* file_ )
10099
}
101100
}
102101

103-
inTec_Zone::~inTec_Zone( )
102+
inTec_Zone::~inTec_Zone()
104103
{
105104
#ifdef _DEBUG_
106105
printf(" i Zone object deconstructed\n");
107106
#endif
108107

108+
clear();
109+
}
110+
111+
int inTec_Zone::GetState() const
112+
{
113+
return( istate );
114+
}
115+
116+
void inTec_Zone::clear()
117+
{
118+
#ifdef _DEBUG_
119+
printf(" i Zone object clearing\n");
120+
#endif
121+
109122
// deallocate data arrays
110123
std::vector< double * > :: iterator dpi;
111124
for( dpi = var_vec.begin() ; dpi != var_vec.end() ; ++dpi ) {
@@ -150,6 +163,46 @@ inTec_Zone::~inTec_Zone( )
150163

151164
// drop T-keyword string
152165
if( tkey != NULL ) free( tkey );
166+
167+
168+
// initialize variables as if it were a fresh object
169+
istate = 0;
170+
ipos = 0;
171+
ipos_data = 0;
172+
ipos_conn = 0;
173+
174+
// keyword-based variables
175+
tkey = NULL;
176+
ietype = -1;
177+
idatapack = -1;
178+
im = 0;
179+
jm = 0;
180+
km = 0;
181+
nodes = 0;
182+
elems = 0;
183+
nv = 0;
184+
parent_zone = -1;
185+
186+
// old-style variables
187+
iold_n = 0;
188+
iold_e = 0;
189+
iold_et = -1;
190+
iold_f = -1;
191+
192+
// utility variables
193+
iparse_num = 0;
194+
node_cnt = 0;
195+
elem_cnt = 0;
196+
var_cnt = 0;
197+
icon_cnt = 0;
198+
199+
InitKeywords();
200+
201+
file = NULL;
202+
num_var = 0;
203+
icon = NULL;
204+
ncon = 0;
205+
num_var = 0;
153206
}
154207

155208
void inTec_Zone::InitKeywords()
@@ -688,7 +741,7 @@ int inTec_Zone::ManageInternals( void )
688741
#ifdef _DEBUG_
689742
printf(" i Inside ManageInternals() \n");
690743
#endif
691-
int ierror=0,iret;
744+
int ierror=0,iret=0;
692745

693746
// processing individual keywords
694747
const char *string=NULL,*string2=NULL;
@@ -909,6 +962,8 @@ int inTec_Zone::ManageInternals( void )
909962
#ifdef _DEBUG_
910963
printf(" e Exiting ManageInternals() in error (return %d) \n",iret);
911964
#endif
965+
} else {
966+
istate = 2; // implies a state of reading numerical values
912967
}
913968

914969
/*
@@ -1480,6 +1535,8 @@ int inTec_Zone::ParseNumericData( char *buf )
14801535
// set the numeric parsing state when we first try to parse data
14811536
if( iparse_num == 0 ) {
14821537
iparse_num = 1; // indicates that we are begining to parse data
1538+
} else if( iparse_num == 1 ) {
1539+
14831540
} else if( iparse_num == 2 ) {
14841541
iparse_num = 3;
14851542
#ifdef _DEBUG_
@@ -1544,7 +1601,12 @@ int inTec_Zone::ParseNumericData( char *buf )
15441601
#ifdef _DEBUG_
15451602
printf(" --- Parsing of variable data ending \n");
15461603
#endif
1547-
iparse_num = 2;
1604+
if( ietype != ORDERED ) {
1605+
iparse_num = 2;
1606+
} else {
1607+
// set state of zone to "loaded and ready" (ordered zone)
1608+
istate = 3;
1609+
}
15481610
}
15491611

15501612
var_cnt = 0;
@@ -1575,10 +1637,15 @@ int inTec_Zone::ParseNumericData( char *buf )
15751637
// termination condition
15761638
if( var_cnt == num_var ) {
15771639
var_cnt = 0;
1578-
iparse_num = 2;
15791640
#ifdef _DEBUG_
15801641
printf(" --- Parsing of numeric data ending \n");
15811642
#endif
1643+
if( ietype != ORDERED ) {
1644+
iparse_num = 2;
1645+
} else {
1646+
// set state of zone to "loaded and ready" (ordered zone)
1647+
istate = 3;
1648+
}
15821649
}
15831650
}
15841651

@@ -1588,7 +1655,7 @@ int inTec_Zone::ParseNumericData( char *buf )
15881655
// parse segments separated by spaces (expecting connectivity in one line)
15891656
if( iparse_num == 3 ) {
15901657
unsigned long n1,n2,n3,n4,n5,n6,n7,n8;
1591-
int ic;
1658+
int ic=0;
15921659

15931660
if( ietype == FETRIANGLE )
15941661
ic = sscanf( buf, "%ld %ld %ld", &n1,&n2,&n3 );
@@ -1624,6 +1691,8 @@ int inTec_Zone::ParseNumericData( char *buf )
16241691
icon_cnt += 1;
16251692
}
16261693

1694+
// indicate that the zone has been filled with data and is ready
1695+
if( icon_cnt == elems ) istate = 3;
16271696
}
16281697

16291698
return(0);
@@ -1632,7 +1701,18 @@ int inTec_Zone::ParseNumericData( char *buf )
16321701

16331702
int inTec_Zone::Dump( const char *filename )
16341703
{
1635-
if( file == NULL ) return(1);
1704+
if( filename == NULL ) {
1705+
#ifdef _DEBUG_
1706+
printf(" e You need to supply a non-null filename string \n");
1707+
#endif
1708+
return(1);
1709+
}
1710+
if( istate != 3 ) {
1711+
#ifdef _DEBUG_
1712+
printf(" e Zone is in hte wrong state: %d \n", istate );
1713+
#endif
1714+
return(2);
1715+
}
16361716

16371717
#ifdef _DEBUG_
16381718
printf(" i Dumping zone to file \"%s\"\n", filename);
@@ -2427,7 +2507,8 @@ printf("FOUND iret=%d idone_zone=%d \n", iret,idone_zone);
24272507
--iline;
24282508
//----------
24292509

2430-
//zone->Dump( (const char *) "crap.dat" );
2510+
printf("GOT HERE (zone istate=%d) \n",zone->GetState());
2511+
zone->Dump( (const char *) "crap.dat" );
24312512
// temporarily drop the zone object
24322513
#ifdef _DEBUG_
24332514
printf("HACK dropping the zone object\n");

‎intecplot.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class inTec_Zone {
2626
inTec_Zone( inTec_File* file_ );
2727
virtual ~inTec_Zone();
2828

29+
int GetState( void ) const;
2930
long GetPositionInFile( void ) const;
3031
int SetPositionInFile( long ipos_ );
3132
long GetDataPositionInFile( void ) const;
@@ -37,11 +38,13 @@ class inTec_Zone {
3738

3839
int Dump( const char *file );
3940

41+
void clear();
42+
4043
protected:
4144
void InitKeywords();
4245
int istate;
4346
char *tkey;
44-
int iordered,ietype,idatapack;
47+
int ietype,idatapack;
4548
int num_var, parent_zone, nv;
4649
unsigned long im,jm,km,nodes,elems;
4750
std::map< int, int > ivar_loc;

0 commit comments

Comments
 (0)