Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
readreg.cpp File Reference
#include <stdio.h>
#include "gridutil.h"
Include dependency graph for readreg.cpp:

Go to the source code of this file.

Functions

const char * read_reg (const char *regFile, blockConsumer &dest)
 

Function Documentation

const char* read_reg ( const char *  regFile,
blockConsumer dest 
)

Definition at line 63 of file readreg.cpp.

References blockConsumer::allocateBlock(), BLOCKSPAN_FOR, blockConsumer::consume(), cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), blockConsumer::freeBlock(), i, max(), min(), s, and v.

Referenced by read_file().

64 {
65  //Open the input file
66  FILE *in=fopen(regFile,"r");
67  if (in==NULL) return "Couldn't open input .reg file";
68 
69  //Read the block size
70  int dimArr[3];
72  for (int axis=0;axis<3;axis++)
73  {
74  double m;
75  if (1!=fscanf(in,"%d",&dimArr[axis]))
76  return "Couldn't read block dimension";
77  if (1!=fscanf(in,"%lf",&m)) return "Couldn't read block min";
78  min[axis]=m;
79  if (1!=fscanf(in,"%lf",&m)) return "Couldn't read block max";
80  max[axis]=m;
81  }
82  fclose(in);
83 
84  //Allocate return grid
85  blockDim dim(dimArr[0],dimArr[1],dimArr[2]);
86  vector3d *locs=dest.allocateBlock(dim);
87 
88  //Fill in the grid
89  blockLoc i;
90  blockSpan s(blockLoc(0,0,0),dim);
91  BLOCKSPAN_FOR(i,s) {
92  vector3d v;
93  for (int axis=0;axis<3;axis++) {
94  double scl=i[axis]/(float)(dim[axis]-1);
95  v[axis]=min[axis]+scl*(max[axis]-min[axis]);
96  }
97  locs[dim[i]]=v;
98  }
99 
100  dest.consume(dim,locs);
101  dest.freeBlock(locs);
102 
103  return NULL; //Everything worked
104 }
double s
Definition: blastest.C:80
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
virtual vector3d * allocateBlock(blockDim &dim)
Definition: read.cpp:146
#define BLOCKSPAN_FOR(i, span)
Definition: gridutil.h:230
virtual void freeBlock(vector3d *blk)
Definition: read.cpp:150
blockLoc i
Definition: read.cpp:79
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
virtual const char * consume(const blockDim &dim, vector3d *locs)=0
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function: