Alternaria
fit cylinders and ellipsoids to fungus
hypha.h
Go to the documentation of this file.
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 
00047 #ifndef HYPHA_H
00048 #define HYPHA_H
00049 
00050 
00051 #include <config.h>
00052 
00053 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK
00054 #include <OpenGL/gl.h>
00055 #include <OpenGL/glu.h>
00056 #elif defined ALTERNARIA_HAVE_OPENGL
00057 #include <GL/gl.h>
00058 #include <GL/glu.h>
00059 #endif
00060 
00061 #include <jwsc/vector/vector.h>
00062 #include <jwsc/matrix/matrix.h>
00063 #include <jwsc/matblock/matblock.h>
00064 
00065 #include <jwsc++/base/exception.h>
00066 
00067 #include "density.h"
00068 #include "structure.h"
00069 #include "spore.h"
00070 
00071 
00077 class Apical_hypha : public Apical_structure
00078 {
00079     public:
00080 
00085         Apical_hypha
00086         (
00087             float centroid_x, 
00088             float centroid_y,
00089             float centroid_z,
00090             float length,
00091             float width,
00092             float base_theta,
00093             float base_psi,
00094             float theta,
00095             float psi,
00096             float opacity,
00097             size_t level,
00098             const class Apical_hypha_density* density
00099         ) 
00100         throw (jwscxx::base::Arg_error);
00101 
00102 
00104         Apical_hypha
00105         (
00106             Structure* parent,
00107             float      length,
00108             float      width,
00109             float      base_theta,
00110             float      base_psi,
00111             float      theta,
00112             float      psi,
00113             float      opacity,
00114             const class Apical_hypha_density* density
00115         )
00116         throw (jwscxx::base::Arg_error, Apical_error);
00117 
00118 
00120         Apical_hypha(const Apical_hypha& h);
00121 
00122 
00124         Apical_hypha
00125         (
00126             const class Spore&          s, 
00127             float                       width,
00128             const Apical_hypha_density* density
00129         )
00130         throw (jwscxx::base::Arg_error);
00131 
00132 
00134         Apical_hypha* clone() const;
00135 
00136 
00138         Apical_hypha& operator= (const Apical_hypha& h);
00139 
00140 
00142         const class Apical_hypha_density* get_density() const 
00143         { return density; }
00144 
00145 
00150         Apical_hypha* split_into_apical
00151         (
00152             const Apical_hypha* rvals_1,
00153             const Apical_hypha* rvals_2
00154         ) 
00155         throw (jwscxx::base::Arg_error);
00156 
00157 
00162         Apical_hypha* merge_with_apical(const Apical_hypha* rvals) 
00163         throw (jwscxx::base::Arg_error);
00164 
00165 
00170         Apical_hypha* merge_with_apical
00171         (
00172             class Spore**        spore_out,
00173             const class Spore*   rvals
00174         ) 
00175         throw (jwscxx::base::Arg_error);
00176 
00177 
00182         class Lateral_hypha* split_into_lateral
00183         (
00184             const Apical_hypha*        rvals_1,
00185             const class Lateral_hypha* rvals_2
00186         ) 
00187         throw (jwscxx::base::Arg_error);
00188 
00189 
00194         class Lateral_hypha* merge_with_lateral
00195         (
00196             class Lateral_hypha* lateral, 
00197             const Apical_hypha*  rvals
00198         ) 
00199         throw (jwscxx::base::Arg_error);
00200 
00201 
00203         void replace(class Spore* spore) throw (jwscxx::base::Arg_error);
00204 
00205 
00207         bool draw_in_matblock_f
00208         (
00209              jwsc::Matblock_f* M_blk, 
00210              float             x, 
00211              float             y,
00212              float             z,
00213              float             x_scale,
00214              float             y_scale,
00215              float             z_scale,
00216              bool              fill = true
00217         )
00218         const;
00219 
00220 
00222 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK || defined ALTERNARIA_HAVE_OPENGL
00223         void draw_in_opengl(GLUquadric* quad, float scale) const;
00224 #endif
00225 
00226 
00231         float get_intersection
00232         (
00233             jwsc::Vector_f**      isect_out, 
00234             uint32_t              n,
00235             const jwsc::Vector_f* p1_in, 
00236             const jwsc::Vector_f* p2_in
00237         )
00238         throw (jwscxx::base::Arg_error);
00239 
00240 
00244         const char* get_type_str() const { return type_str(); }
00245 
00246 
00250         static const char* type_str() { return "Apical hypha"; }
00251 
00252 
00253     protected:
00254 
00256         void update_log_prob();
00257 
00258 
00259     protected:
00260 
00262         const class Apical_hypha_density* density;
00263 }; 
00264 
00265 
00266 
00267 
00273 class Apical_hypha_density : public Apical_structure_density
00274 {
00275     public:
00276 
00281         Apical_hypha_density() throw (jwscxx::base::Arg_error);
00282 
00283 
00285         Apical_hypha_density* clone() const;
00286 
00287 
00289         const Density::Gaussian_params& get_dwidth() const { return dwidth; }
00290 
00291 
00296         void set_dwidth
00297         (
00298             float sigma, 
00299             float min, 
00300             float max
00301         ) 
00302         throw (jwscxx::base::Arg_error);
00303 
00304 
00306         Apical_hypha* sample
00307         (
00308             float base_theta=0, 
00309             float base_psi=0,
00310             size_t level=0
00311         ) 
00312         const;
00313 
00314 
00316         Apical_hypha* sample
00317         (
00318             float centroid_x, 
00319             float centroid_y, 
00320             float centroid_z,
00321             float base_theta=0,
00322             float base_psi=0,
00323             size_t level=0
00324         ) 
00325         const throw (jwscxx::base::Arg_error);
00326 
00327 
00329         Apical_hypha* sample
00330         (
00331             Structure* parent,
00332             float      base_theta=0,
00333             float      base_psi=0
00334         ) 
00335         const throw (jwscxx::base::Arg_error);
00336 
00337 
00342         float sample_dwidth() const;
00343 
00344 
00345     protected:
00346 
00351         Density::Gaussian_params  dwidth;
00352 };
00353 
00354 
00355 
00356 
00366 class Printed_apical_hypha : public Printed_apical_structure
00367 {
00368     public: 
00369 
00371         Printed_apical_hypha(const Apical_hypha_density* density);
00372 
00373 
00378         Printed_apical_hypha
00379         (
00380             std::istream& in, 
00381             const Apical_hypha_density* density
00382         ) 
00383         throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00384 
00385 
00390         void read(std::istream& in)
00391             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00392 
00393 
00395         Apical_hypha* convert(Structure* parent) const 
00396             throw (jwscxx::base::Arg_error);
00397 
00398 
00399     protected:
00400 
00402         const Apical_hypha_density* density;
00403 };
00404 
00405 
00406 
00407 
00413 class Lateral_hypha : public Lateral_structure
00414 {
00415     public:
00416 
00421         Lateral_hypha
00422         (
00423             float centroid_x, 
00424             float centroid_y,
00425             float centroid_z,
00426             float lat_dist,
00427             float length,
00428             float width,
00429             float base_theta,
00430             float base_psi,
00431             float theta,
00432             float psi,
00433             float opacity,
00434             size_t level,
00435             const class Lateral_hypha_density* density
00436         ) 
00437         throw (jwscxx::base::Arg_error);
00438 
00439 
00441         Lateral_hypha
00442         (
00443             Structure* parent,
00444             float      lat_dist,
00445             float      length,
00446             float      width,
00447             float      base_theta,
00448             float      base_psi,
00449             float      theta,
00450             float      psi,
00451             float      opacity,
00452             const class Lateral_hypha_density* density
00453         )
00454         throw (jwscxx::base::Arg_error, Apical_error);
00455 
00456 
00458         Lateral_hypha(const Lateral_hypha& h);
00459 
00460 
00462         Lateral_hypha* clone() const;
00463 
00464 
00466         Lateral_hypha& operator= (const Lateral_hypha& h);
00467 
00468 
00470         bool draw_in_matblock_f
00471         (
00472              jwsc::Matblock_f* M_blk, 
00473              float             x, 
00474              float             y,
00475              float             z,
00476              float             x_scale,
00477              float             y_scale,
00478              float             z_scale,
00479              bool              fill = true
00480         )
00481         const;
00482 
00483 
00485 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK || defined ALTERNARIA_HAVE_OPENGL
00486         void draw_in_opengl(GLUquadric* quad, float scale) const;
00487 #endif
00488 
00489 
00494         float get_intersection
00495         (
00496             jwsc::Vector_f**      isect_out, 
00497             uint32_t              n,
00498             const jwsc::Vector_f* p1_in, 
00499             const jwsc::Vector_f* p2_in
00500         )
00501         throw (jwscxx::base::Arg_error);
00502 
00503 
00507         const char* get_type_str() const { return type_str(); }
00508 
00509 
00513         static const char* type_str() { return "Lateral hypha"; }
00514 
00515 
00516     protected:
00517 
00519         const class Lateral_hypha_density* density;
00520 }; 
00521 
00522 
00523 
00524 
00530 class Lateral_hypha_density : public Lateral_structure_density
00531 {
00532     public:
00533 
00538         Lateral_hypha_density() throw (jwscxx::base::Arg_error);
00539 
00540 
00542         Lateral_hypha_density* clone() const;
00543 
00544 
00546         Lateral_hypha* sample
00547         (
00548             float base_theta=0, 
00549             float base_psi=0,
00550             size_t level=0
00551         ) 
00552         const;
00553 
00554 
00556         Lateral_hypha* sample
00557         (
00558             float centroid_x, 
00559             float centroid_y, 
00560             float centroid_z,
00561             float base_theta=0,
00562             float base_psi=0,
00563             size_t level=0
00564         ) 
00565         const throw (jwscxx::base::Arg_error);
00566 
00567 
00569         Lateral_hypha* sample
00570         (
00571             Structure* parent,
00572             float      base_theta=0,
00573             float      base_psi=0
00574         ) 
00575         const throw (jwscxx::base::Arg_error);
00576 };
00577 
00578 
00579 
00580 
00590 class Printed_lateral_hypha : public Printed_lateral_structure
00591 {
00592     public: 
00593 
00595         Printed_lateral_hypha
00596         (
00597             const Lateral_hypha_density* level_1_density,
00598             const Lateral_hypha_density* level_n_density
00599         );
00600 
00601 
00606         Printed_lateral_hypha
00607         (
00608             std::istream& in, 
00609             const Lateral_hypha_density* level_1_density,
00610             const Lateral_hypha_density* level_n_density
00611         ) 
00612         throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00613 
00614 
00619         void read(std::istream& in)
00620             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00621 
00622 
00624         Lateral_hypha* convert(Structure* parent) const 
00625             throw (jwscxx::base::Arg_error);
00626 
00627 
00628     protected:
00629 
00634         const Lateral_hypha_density* level_1_density;
00635 
00640         const Lateral_hypha_density* level_n_density;
00641 };
00642 
00643 
00644 #endif