Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utilities/rc_cmp/util.cpp File Reference
#include "util.h"
Include dependency graph for utilities/rc_cmp/util.cpp:

Go to the source code of this file.

Functions

string itoa (int n)
 Convert an int to a string. More...
 
bool check_non_numeric_char (char test_char)
 
bool check_non_numeric_char_per (char test_char)
 
bool check_non_numeric_str (string test_str)
 
bool check_non_numeric_str_per (string test_str)
 
bool check_delimiters (char *delimit, int num, char test)
 
std::vector< string > readQuoteExpression (string rStack, string rNeedle)
 Read expressions of the form x = "test" "100" "another test". More...
 
std::vector< string > readCommaExpression (string rStack, string rNeedle)
 
bool check_bool_arr (bool test[], int size)
 
long double dist (long double *coord1, long double *coord2, int size)
 
bool pnt_in_tri (pnt test, pnt p1, pnt p2, pnt p3)
 
bool side_check (pnt test, pnt p1, pnt p2, pnt check)
 
pnt cross_product (pnt vec1, pnt vec2)
 
long double dot_product (pnt vec1, pnt vec2)
 
long double nan ()
 
std::vector< string > str_tokenize (string full, string delimiters)
 
bool same_elements (std::vector< int > vector_1, std::vector< int > vector_2)
 

Function Documentation

bool check_bool_arr ( bool  test[],
int  size 
)

Definition at line 294 of file utilities/rc_cmp/util.cpp.

References i.

Referenced by Fileselect::testTecplot().

294  {
295 
296  for(int i=0; i<size; i++){
297  if(!test[i])
298  return false;
299  }
300 
301  return true;
302 
303 }
blockLoc i
Definition: read.cpp:79
void test(void)
Definition: flotsam.C:99

Here is the caller graph for this function:

bool check_delimiters ( char *  delimit,
int  num,
char  test 
)

Definition at line 51 of file utilities/rc_cmp/util.cpp.

References i.

Referenced by readCommaExpression(), and readQuoteExpression().

51  {
52 
53  //Default delimiters if none are specified
54  if(delimit == NULL){
55  num = 4;
56  delimit = "\n\t \0";
57  }
58 
59  //Check for delimiters
60  for(int i=0; i < num; i++){
61  if(test == delimit[i])
62  return true;
63  }
64 
65  return false;
66 }
blockLoc i
Definition: read.cpp:79
void test(void)
Definition: flotsam.C:99

Here is the caller graph for this function:

bool check_non_numeric_char ( char  test_char)

Definition at line 13 of file utilities/rc_cmp/util.cpp.

Referenced by check_non_numeric_str().

13  {
14 
15  int num = (int)test_char;
16 
17  if(num > 57 || num < 48)
18  return true;
19 
20  return false;
21 }

Here is the caller graph for this function:

bool check_non_numeric_char_per ( char  test_char)

Definition at line 23 of file utilities/rc_cmp/util.cpp.

Referenced by check_non_numeric_str_per().

23  {
24 
25  int num = (int)test_char;
26 
27  if(num > 57 || num < 48 || test_char == '.')
28  return true;
29 
30  return false;
31 }

Here is the caller graph for this function:

bool check_non_numeric_str ( string  test_str)

Definition at line 33 of file utilities/rc_cmp/util.cpp.

References check_non_numeric_char(), and i.

Referenced by tpz_ordered::parse_layout(), tpz_fequad::parse_layout(), ComSwitch::parseValuesFromArguments(), and Fileselect::testTecplot().

33  {
34  for(int i=0; i<test_str.length(); i++){
35  if(check_non_numeric_char(test_str[i]))
36  return true;
37  }
38 
39  return false;
40 }
bool check_non_numeric_char(char test_char)
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

Here is the caller graph for this function:

bool check_non_numeric_str_per ( string  test_str)

Definition at line 42 of file utilities/rc_cmp/util.cpp.

References check_non_numeric_char_per(), and i.

42  {
43  for(int i=0; i<test_str.length(); i++){
44  if(check_non_numeric_char_per(test_str[i]))
45  return true;
46  }
47 
48  return false;
49 }
bool check_non_numeric_char_per(char test_char)
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

pnt cross_product ( pnt  vec1,
pnt  vec2 
)

Definition at line 370 of file utilities/rc_cmp/util.cpp.

References pnt::size, and pnt::vals.

370  {
371 
372  pnt ret;
373 
374  if(vec1.size < 3 || vec2.size < 3)
375  return ret;
376 
377  ret.size = 3;
378  ret.vals = new long double[3];
379 
380  ret.vals[0] = (vec1.vals[1]*vec2.vals[2] - vec1.vals[2]*vec2.vals[1]);
381  ret.vals[1] = (vec1.vals[2]*vec2.vals[0] - vec1.vals[0]*vec2.vals[2]);
382  ret.vals[2] = (vec1.vals[0]*vec2.vals[1] - vec1.vals[1]*vec2.vals[0]);
383 
384  return ret;
385 }
int size
Definition: datatypedef.h:70
long double * vals
Definition: datatypedef.h:69
Point object that represents a single point.
Definition: datatypedef.h:68
long double dist ( long double *  coord1,
long double *  coord2,
int  size 
)

Definition at line 305 of file utilities/rc_cmp/util.cpp.

References i, Mesquite::pow(), and sqrt().

Referenced by Mesh::NodalCoordinates::closest_node(), Mesh::NodalCoordinates::closest_point(), rflu_modrepair3d::coarsn(), rflu_modrepair3d::densfn(), CImg< uintT >::dijkstra(), connect_points::get_closest(), indexed_points::get_closest(), CImg< uintT >::get_index(), Overlay::insert_node_in_blue_edge(), main(), rflu_modrepair3d::octfnd(), plag_rflu_modfindcells::plag_rflu_findcellstrajfast(), plag_rflu_modfindcells::plag_rflu_findcellstrajsafe(), project_window(), rflo_getdeformation(), rflo_laplacegridsolve(), rflo_modlaplacesmoothing::rflo_laplacegridsolve(), rflo_modmovegridframe::rflo_mgframecorrectneighbors(), rflo_modmovegridframe::rflo_mgframemovecorners(), rflo_modmovegridframe::rflo_mgframesrchneighbors(), rflu_modoles::rflu_buildstencilsoles(), rflu_modgeometrytools::rflu_computelinecellxsectfast(), rflu_modconstraintutils::rflu_getconstrtype(), rflu_modconstraintutils::rflu_getconstrvalue(), rflu_modoctree::rflu_queryoctree(), rflu_modrindstates::rflu_setrindstatefarfieldperf(), rflu_modstencilsutils::rflu_sortbfaces(), rflu_modsymmetryperiodic::rflu_sype_buildvertexmaps(), and Rocmop::smooth_vol_mesq_ng().

305  {
306 
307  long double total = 0;
308 
309  for(int i=0; i<size; i++){
310  total += pow( coord2[i] - coord1[i], 2 );
311  }
312 
313  total = sqrt(total);
314 
315  return total;
316 }
double sqrt(double d)
Definition: double.h:73
blockLoc i
Definition: read.cpp:79
double pow(double value, const Exponent &exp)

Here is the call graph for this function:

Here is the caller graph for this function:

string itoa ( int  n)

Convert an int to a string.

Parameters
nInteger to convert
Returns
String representation of the integer

Definition at line 6 of file utilities/rc_cmp/util.cpp.

References n, and s.

Referenced by compareFiles(), datafile::LogFieldMappings(), tecplot_data::parse(), tpz_ordered::parse_data(), tpz_fequad::parse_data(), tpz_ordered::parse_layout(), tpz_fequad::parse_layout(), tecplot_data::read_header(), tecplot_data::zone_error_out(), and tecplot_data::zone_status_out().

6  {
7  string s;
8  std::stringstream out;
9  out << n;
10  return out.str();
11 }
double s
Definition: blastest.C:80
const NT & n

Here is the caller graph for this function:

long double nan ( )

Definition at line 401 of file utilities/rc_cmp/util.cpp.

Referenced by Interpolate::bilinear(), and dot_product().

401  {
402 
403  //Return NaN without compiler warning
404  long double *zer = new long double;
405  *zer = 0.0;
406 
407  long double ret = ( (*zer) / (*zer) );
408  delete zer;
409 
410  return ret;
411 }

Here is the caller graph for this function:

bool pnt_in_tri ( pnt  test,
pnt  p1,
pnt  p2,
pnt  p3 
)

Definition at line 318 of file utilities/rc_cmp/util.cpp.

References side_check(), and pnt::size.

Referenced by Interpolate::getCell().

318  {
319 
320  if(test.size < 2 || p1.size < 2 || p2.size < 2 || p3.size < 2)
321  return false;
322 
323  if( side_check(test, p1, p2, p3) &&
324  side_check(test, p2, p3, p1) &&
325  side_check(test, p3, p1, p2) ){
326  return true;
327  }
328 
329  return false;
330 }
int size
Definition: datatypedef.h:70
bool side_check(pnt test, pnt p1, pnt p2, pnt check)

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<string> readCommaExpression ( string  rStack,
string  rNeedle 
)

Definition at line 187 of file utilities/rc_cmp/util.cpp.

References check_delimiters(), i, and j.

Referenced by tpz_ordered::parse_layout(), tpz_fequad::parse_layout(), Fileselect::testTecplot(), and tecplot_data::zone_detect().

187  {
188 
189  std::vector<string> null_res;
190 
191 
192  //
193  //Search for needle in stack
194  //
195 
196  bool needle_found;
197 
198  int i;
199  for(i=0; i < (rStack.length()-rNeedle.length()) + 1; i++){
200 
201  char check = '\0';
202  if( i > 0 )
203  check = rStack[i-1];
204 
205  if( i == 0 || check_delimiters(NULL, 0, check) ){
206 
207  needle_found = true;
208 
209  for(int j=0; j<rNeedle.length(); j++){
210  if( rStack[i+j] != rNeedle[j] )
211  needle_found = false;
212  }
213  }
214 
215  if(needle_found)
216  break;
217 
218  }
219 
220  //Not found
221  if(!needle_found)
222  return null_res;
223 
224  i += rNeedle.length();
225 
226 
227 
228  //
229  //Skip Whitespace, check for '='
230  //
231 
232  char c = rStack[i];
233  while(c == ' '){
234  i++;
235  c = rStack[i];
236  }
237 
238  //Check for '='
239  if(c != '=')
240  return null_res;
241  else
242  i++;
243 
244  c = rStack[i];
245  while(c == ' '){
246  i++;
247  c = rStack[i];
248  }
249 
250 
251  std::vector<string> values;
252 
253 
254  //
255  //Read Values
256  //
257 
258  //Move back one character
259  // - Neccessary due to loop
260  i--;
261 
262  do{
263 
264  i++;
265  c = rStack[i];
266 
267  //Skip whitespace
268  while(c == ' '){
269  i++;
270  c = rStack[i];
271  }
272 
273  //Read value
274  string val("");
275 
276  while(c != ' ' && c != ',' && c != '='){
277  val += rStack[i];
278 
279  i++;
280  c = rStack[i];
281  }
282 
283  if( c == '=')
284  break;
285 
286  values.push_back(val);
287  }
288  while(c == ',');
289 
290 
291  return values;
292 }
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
bool check_delimiters(char *delimit, int num, char test)

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<string> readQuoteExpression ( string  rStack,
string  rNeedle 
)

Read expressions of the form x = "test" "100" "another test".

Parameters
stack

Definition at line 77 of file utilities/rc_cmp/util.cpp.

References check_delimiters(), i, and j.

Referenced by tecplot_data::read_header().

77  {
78 
79  std::vector<string> null_res;
80 
81  //
82  //Search for needle in stack
83  //
84 
85  bool needle_found;
86 
87  int i;
88  for(i=0; i < (rStack.length()-rNeedle.length()) + 1; i++){
89 
90  char check = '\0';
91  if( i > 0 )
92  check = rStack[i-1];
93 
94  if( i == 0 || check_delimiters(NULL, 0, check) ){
95 
96  needle_found = true;
97 
98  for(int j=0; j<rNeedle.length(); j++){
99  if( rStack[i+j] != rNeedle[j] )
100  needle_found = false;
101  }
102  }
103 
104  if(needle_found)
105  break;
106 
107  }
108 
109  //Not found
110  if(!needle_found)
111  return null_res;
112 
113  i += rNeedle.length();
114 
115 
116 
117  //
118  //Skip Whitespace, check for '='
119  //
120 
121  char c = rStack[i];
122  while(c == ' '){
123  i++;
124  c = rStack[i];
125  }
126 
127  //Check for '='
128  if(c != '=')
129  return null_res;
130  else
131  i++;
132 
133  c = rStack[i];
134  while(c == ' '){
135  i++;
136  c = rStack[i];
137  }
138 
139 
140  std::vector<string> values;
141 
142 
143 
144  //
145  //Read Values
146  //
147 
148  while(c == '"'){
149 
150  //Check for valid parentheses
151  int end = rStack.length();
152 
153  i++;
154  for(end=0; end<rStack.length(); end++){
155  c = rStack[i+end];
156  if(c == '"')
157  break;
158  }
159 
160  //Read value
161  string val("");
162 
163  int limit = end+i;
164 
165  for(i; i < limit; i++){
166  val += rStack[i];
167  }
168 
169  i++;
170 
171  values.push_back(val);
172 
173  //Skip whitespace
174  c = rStack[i];
175  while(c == ' '){
176  i++;
177  c = rStack[i];
178  }
179 
180  }
181 
182  return values;
183 }
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
bool check_delimiters(char *delimit, int num, char test)

Here is the call graph for this function:

Here is the caller graph for this function:

bool same_elements ( std::vector< int >  vector_1,
std::vector< int >  vector_2 
)

Definition at line 430 of file utilities/rc_cmp/util.cpp.

Referenced by compareFiles().

430  {
431  for(int vec1_element_num = 0; vec1_element_num < vector_1.size(); vec1_element_num++){
432 
433  bool match_found = false;
434  for(int vec2_element_num = 0; vec2_element_num < vector_2.size(); vec2_element_num++){
435 
436  //check for matching element
437  if(vector_1[vec1_element_num] == vector_2[vec2_element_num]){
438  match_found = true;
439  break;
440  }
441  }
442 
443  if(!match_found)
444  return false;
445  }
446 
447  return true;
448 }

Here is the caller graph for this function:

bool side_check ( pnt  test,
pnt  p1,
pnt  p2,
pnt  check 
)

Definition at line 332 of file utilities/rc_cmp/util.cpp.

References cross_product(), dot_product(), pnt::size, and pnt::vals.

Referenced by pnt_in_tri().

332  {
333 
334  //Line to check
335  pnt line;
336  line.size = 3;
337  line.vals = new long double[3];
338 
339  line.vals[0] = p2.vals[0] - p1.vals[0];
340  line.vals[1] = p2.vals[1] - p1.vals[1];
341  line.vals[2] = 0.0;
342 
343  //Test point vector
344  pnt tpt;
345  tpt.size = 3;
346  tpt.vals = new long double[3];
347 
348  tpt.vals[0] = test.vals[0] - p1.vals[0];
349  tpt.vals[1] = test.vals[1] - p1.vals[1];
350  tpt.vals[2] = 0.0;
351 
352  //Check point vector
353  pnt checkvec;
354  checkvec.size = 3;
355  checkvec.vals = new long double[3];
356 
357  checkvec.vals[0] = check.vals[0] - p1.vals[0];
358  checkvec.vals[1] = check.vals[1] - p1.vals[1];
359  checkvec.vals[2] = 0.0;
360 
361  pnt res1 = cross_product(line, tpt);
362  pnt res2 = cross_product(line, checkvec);
363 
364  if( dot_product(res1, res2) >= 0.0 )
365  return true;
366 
367  return false;
368 }
int size
Definition: datatypedef.h:70
long double * vals
Definition: datatypedef.h:69
Point object that represents a single point.
Definition: datatypedef.h:68
VectorS3< FT > cross_product(const VectorS3< FT > &v, const VectorS3< FT > &w)
long double dot_product(pnt vec1, pnt vec2)

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<string> str_tokenize ( string  full,
string  delimiters 
)

Definition at line 413 of file utilities/rc_cmp/util.cpp.

Referenced by ComSwitch::parseValuesFromArguments().

413  {
414 
415  std::vector<string> ret;
416 
417  string::size_type start = full.find_first_not_of(delimiters, 0);
418  string::size_type end = full.find_first_of(delimiters, start);
419 
420  while(start != string::npos || end != string::npos){
421  ret.push_back(full.substr(start, end-start));
422 
423  start = full.find_first_not_of(delimiters, end);
424  end = full.find_first_of(delimiters, start);
425  }
426 
427  return ret;
428 }

Here is the caller graph for this function: