|
funkalicious 0.1
|
00001 /* 00002 ** grid1.h 00003 ** 00004 00005 Copyright (C) 2009 Joseph Pingenot 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU Affero General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Affero General Public License for more details. 00016 00017 You should have received a copy of the GNU Affero General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 ** Made by Johnny Q. Hacker 00021 ** Login <solarion@borkborkbork> 00022 ** 00023 ** Started on Mon Nov 23 16:18:43 2009 Johnny Q. Hacker 00024 ** Last update Mon Nov 23 16:18:43 2009 Johnny Q. Hacker 00025 */ 00026 00027 #include <glib-2.0/glib.h> 00028 #include <gio/gio.h> 00029 #include <libdotcode/dotcode_generic.h> 00030 #include <libdotcode/matdb.h> 00031 #include <libdotcode/matdb-dotcode.h> 00032 00033 #ifndef DOTCODE_GRID1_H_ 00034 # define DOTCODE_GRID1_H_ 00035 00036 struct dotcode_grid1 { 00037 /*Number of X, Y, Z components of the grid, respectively*/ 00038 int N[3]; 00039 /*Spacing of of X, Y, Z components of the grid, respectively*/ 00040 double dx[3]; 00041 /*Array of strings containing material names*/ 00042 char **materials; 00043 /*N[0] x N[1] x N[2] array of material assignments (indices into 00044 the materials array*/ 00045 unsigned char *assignments; 00046 }; 00047 00048 enum dotcode_grid1_errors { 00049 DOTCODE_GRID1_ERROR_NOSUCHPROPERTY=DOTCODE_ERROR_LAST, 00050 DOTCODE_GRID1_ERROR_LAST 00051 }; 00052 00053 struct dotcode_grid1* dotcode_grid1_get_from_gfile(GFile* f, GError **error); 00054 GError* dotcode_grid1_write_to_gfile(GFile* f, const struct dotcode_grid1* grid); 00055 void dotcode_grid1_free(struct dotcode_grid1* grid); 00056 00057 /** 00058 *Sets up an array containing the property, by material index 00059 *\param grid the grid to use 00060 *\param mdb the material database 00061 *\param property_name the name of the property to be cached 00062 */ 00063 double* dotcode_grid1_get_property_cache(const struct dotcode_grid1* grid, const struct matdb* mdb, const char* property_name, GError **err); 00064 00065 /** 00066 *Gets a grid with the respective property. 00067 */ 00068 double* dotcode_grid1_get_property_grid(const struct dotcode_grid1* grid, const struct matdb *mdb, const char* property, GError **err); 00069 00070 /** 00071 *Gets a specified property at a grid site 00072 *\param grid the grid to pull the information from 00073 *\param property string containing the property to pull 00074 *\param index ponter to an array containing 3 ints indicating the site 00075 */ 00076 double dotcode_grid1_get_property_at_site(const struct dotcode_grid1* grid, const struct matdb *mdb, const char* property, const int* index, GError **err); 00077 /**same as dotcode_grdi1_get_property_at_site, but uses property cache instead of matdb and property string. 00078 *\param 00079 */ 00080 double dotcode_grid1_get_property_at_site_cached(const struct dotcode_grid1* grid, const double* propcache, const int* index); 00081 00082 /** 00083 *Writes the a slice of the grid material assignments out to a file in human-readalbe 00084 *format 00085 *\param grid the grid to write out 00086 *\param base the directory into which to write the file 00087 *\param coord which coordinate to write a slice out 00088 *\param x the value of the coordinate to write out 00089 *\param err pointer to a pointer in which to store the GError, if any. 00090 */ 00091 void dotcode_grid1_write_assignments_slice_text(const struct dotcode_grid1* grid, GFile* base, enum dotcode_coord coord, int index, GError **err); 00092 00093 /*Same as for writing assignment slices, but this writes properties 00094 *\param grid the grid to write out 00095 *\param property_array output of get_property_grid 00096 *\param property_name string containing the property's name 00097 *\param base the directory into which to write the file 00098 *\param coord which coordinate to write a slice out 00099 *\param x the value of the coordinate to write out 00100 *\param err pointer to a pointer in which to store the GError, if any. 00101 */ 00102 void dotcode_grid1_write_property_slice_text(const struct dotcode_grid1* grid, const double* property_array, const char* property_name, GFile* base, enum dotcode_coord coord, int index, GError **err); 00103 00104 long unsigned int dotcode_grid1_get_assignment_index(int x, int y, int z, int Nx, int Ny); 00105 00106 #endif /* !GRID1_H_ */