|
k-dot-p 0.1
|
00001 /* 00002 * materials.h++ 00003 00004 Copyright (C) 2009 Joseph Pingenot 00005 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Affero General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Affero General Public License for more details. 00015 00016 You should have received a copy of the GNU Affero General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef MATERIAL_HPP__ 00022 #define MATERIAL_HPP__ 00023 00024 #include <string> 00025 #include <glib.h> 00026 #include <libmodelxx/matdb.h++> 00027 00028 namespace kdotp { 00029 namespace libmodelxx { 00030 namespace structure { 00031 00032 enum material_property { 00033 }; 00034 00035 class material { 00036 public: 00037 material(const struct matdb* mdb, const char* mat1, const char* mat2, double x); 00038 /*For some reason, this dosn't work as a const.*/ 00039 char* get_name(); 00040 /** 00041 *Gets a property for this material. If you need speed, use 00042 * the int version. 00043 *\param ppt property name 00044 *\param err pointer to int to store the error code 00045 *\return the property, or NaN if lookup failed 00046 *\note error values are 0 for success, and 1 for failure to 00047 * find the property 00048 */ 00049 double get_property(const char* ppt, int* err); 00050 inline double get_property(int ppt) {return indexed_properties[ppt];} 00051 int get_property_index(const char* ppt, int* err); 00052 char* matname1; 00053 char* matname2; 00054 double m_x; 00055 /*This stores an array of properties*/ 00056 double* indexed_properties; 00057 /*This stores the corresponding index into the array (char* -> int*)*/ 00058 GHashTable* property_indices; 00059 /*This stores the original properties hash (char* -> double*) from matdb.*/ 00060 GHashTable* properties; 00061 /**comparison operator for material classes 00062 *\note compares string-wise matnames, and directly (i.e. ==) 00063 *\note use lenient-compare if you want to specify a tolerance 00064 */ 00065 bool operator==(const material& m2); 00066 bool operator!=(const material& m2); 00067 /**compares two materials like the operator, but uses a tolerance to compare the percentage of material1. 00068 */ 00069 bool lenient_equals(const material& m2, double tolerance=1e-10); 00070 private: 00071 material() {} 00072 }; 00073 00074 bool operator==(const material& m1, const material& m2); 00075 bool operator!=(const material& m1, const material& m2); 00076 00077 } 00078 } 00079 } 00080 00081 #endif //MATERIALS_HPP__