Alternaria
fit cylinders and ellipsoids to fungus
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00046 #ifndef SPORE_H 00047 #define SPORE_H 00048 00049 00050 #include <config.h> 00051 00052 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK 00053 #include <OpenGL/gl.h> 00054 #include <OpenGL/glu.h> 00055 #elif defined ALTERNARIA_HAVE_OPENGL 00056 #include <GL/gl.h> 00057 #include <GL/glu.h> 00058 #endif 00059 00060 #include <jwsc/vector/vector.h> 00061 #include <jwsc/matrix/matrix.h> 00062 #include <jwsc/matblock/matblock.h> 00063 00064 #include <jwsc++/base/exception.h> 00065 00066 #include "density.h" 00067 #include "structure.h" 00068 #include "dd_spore.h" 00069 #include "hypha.h" 00070 00071 00079 class Spore : public Apical_structure 00080 { 00081 public: 00082 00087 Spore 00088 ( 00089 float centroid_x, 00090 float centroid_y, 00091 float centroid_z, 00092 float length, 00093 float width, 00094 float base_theta, 00095 float base_psi, 00096 float theta, 00097 float psi, 00098 float opacity, 00099 size_t level, 00100 const class Spore_density* density 00101 ) 00102 throw (jwscxx::base::Arg_error); 00103 00104 00106 Spore 00107 ( 00108 Structure* parent, 00109 float length, 00110 float width, 00111 float base_theta, 00112 float base_psi, 00113 float theta, 00114 float psi, 00115 float opacity, 00116 const class Spore_density* density 00117 ) 00118 throw (jwscxx::base::Arg_error, Apical_error); 00119 00120 00122 Spore 00123 ( 00124 Structure* parent, 00125 float centroid_x, 00126 float centroid_y, 00127 float centroid_z, 00128 float length, 00129 float width, 00130 float base_theta, 00131 float base_psi, 00132 float opacity, 00133 const class Spore_density* density 00134 ) 00135 throw (jwscxx::base::Arg_error, Apical_error); 00136 00137 00139 Spore(const Spore& s); 00140 00141 00143 Spore 00144 ( 00145 const class Apical_hypha& h, 00146 float width, 00147 const Spore_density* density 00148 ) 00149 throw (jwscxx::base::Arg_error); 00150 00151 00153 Spore* clone() const; 00154 00155 00157 Spore& operator= (const Spore& s); 00158 00159 00161 const class Spore_density* get_density() const { return density; } 00162 00163 00168 Spore* split_into_apical 00169 ( 00170 const Spore* rvals_1, 00171 const Spore* rvals_2 00172 ) 00173 throw (jwscxx::base::Arg_error); 00174 00175 00180 Spore* merge_with_apical(const Spore* rvals) 00181 throw (jwscxx::base::Arg_error); 00182 00183 00185 class Apical_hypha* split_into_apical 00186 ( 00187 const Apical_hypha* rvals_1, 00188 const Apical_hypha* rvals_2 00189 ) 00190 throw (jwscxx::base::Arg_error); 00191 00192 00194 void replace(class Apical_hypha* hypha) throw (jwscxx::base::Arg_error); 00195 00196 00198 bool draw_in_matrix_f 00199 ( 00200 jwsc::Matrix_f* M, 00201 float x, 00202 float y, 00203 float z, 00204 float x_scale, 00205 float y_scale, 00206 float z_scale, 00207 bool fill = true 00208 ) 00209 const; 00210 00211 00213 bool draw_in_matblock_f 00214 ( 00215 jwsc::Matblock_f* M_blk, 00216 float x, 00217 float y, 00218 float z, 00219 float x_scale, 00220 float y_scale, 00221 float z_scale, 00222 bool fill = true 00223 ) 00224 const; 00225 00226 00228 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK || defined ALTERNARIA_HAVE_OPENGL 00229 void draw_in_opengl(GLUquadric* quad, float scale) const; 00230 #endif 00231 00232 00237 float get_intersection 00238 ( 00239 jwsc::Vector_f** isect_out, 00240 uint32_t n, 00241 const jwsc::Vector_f* p1_in, 00242 const jwsc::Vector_f* p2_in 00243 ) 00244 throw (jwscxx::base::Arg_error); 00245 00246 00250 const char* get_type_str() const { return type_str(); } 00251 00252 00256 static const char* type_str() { return "Spore"; } 00257 00258 00259 protected: 00260 00262 void draw_in_zeroed_matrix_f 00263 ( 00264 jwsc::Matrix_f* M, 00265 float x, 00266 float y, 00267 float z, 00268 float x_scale, 00269 float y_scale, 00270 float z_scale, 00271 bool fill = true 00272 ) 00273 const; 00274 00276 void update_log_prob(); 00277 00278 00279 protected: 00280 00282 const class Spore_density* density; 00283 }; 00284 00285 00286 00287 00293 class Spore_density : public Apical_structure_density 00294 { 00295 public: 00296 00298 Spore_density(const class DD_spore_set* dd_spores=0) 00299 throw (jwscxx::base::Arg_error); 00300 00301 00303 Spore_density* clone() const; 00304 00305 00307 Spore* sample(float base_theta=0, float base_psi=0, size_t level=0) 00308 const; 00309 00310 00312 Spore* sample 00313 ( 00314 float centroid_x, 00315 float centroid_y, 00316 float centroid_z, 00317 float base_theta=0, 00318 float base_psi=0, 00319 size_t level=0 00320 ) 00321 const throw (jwscxx::base::Arg_error); 00322 00323 00325 Spore* sample 00326 ( 00327 Structure* parent, 00328 float base_theta=0, 00329 float base_psi=0 00330 ) 00331 const throw (jwscxx::base::Arg_error); 00332 00333 00335 const DD_spore_set* get_dd_spores() const { return dd_spores; } 00336 00337 00338 protected: 00339 00341 const DD_spore_set* dd_spores; 00342 }; 00343 00344 00345 00346 00356 class Printed_spore : public Printed_apical_structure 00357 { 00358 public: 00359 00361 Printed_spore(const Spore_density* density); 00362 00363 00368 Printed_spore(std::istream& in, const Spore_density* density) 00369 throw (jwscxx::base::IO_error, jwscxx::base::Arg_error); 00370 00371 00373 void read(std::istream& in) 00374 throw (jwscxx::base::IO_error, jwscxx::base::Arg_error); 00375 00376 00378 Spore* convert(Structure* parent) const throw (jwscxx::base::Arg_error); 00379 00380 00381 protected: 00382 00384 const Spore_density* density; 00385 }; 00386 00387 00388 #endif