Alternaria
fit cylinders and ellipsoids to fungus
structure.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 
00046 #ifndef STRUCTURE_H
00047 #define STRUCTURE_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 <list>
00061 #include <vector>
00062 
00063 #include <inttypes.h>
00064 
00065 #include <jwsc/vector/vector.h>
00066 #include <jwsc/matrix/matrix.h>
00067 #include <jwsc/matblock/matblock.h>
00068 
00069 #include <jwsc++/base/exception.h>
00070 
00071 #include "density.h"
00072 #include "printable.h"
00073 
00074 
00075 
00081 class Apical_error : public jwscxx::base::Exception
00082 {
00083     public:
00084 
00086         Apical_error(const char* msg, const char* file=0, uint32_t line=0) 
00087             : jwscxx::base::Exception(msg, file, line) { }
00088 };
00089 
00090 
00091 
00092 
00101 class Structure : public Printable
00102 {
00103     public: 
00104 
00106         Structure
00107         (
00108             float length,
00109             float width,
00110             float base_theta,
00111             float base_psi,
00112             float theta,
00113             float psi,
00114             float opacity,
00115             size_t level,
00116             const class Structure_density* density
00117         )
00118         throw (jwscxx::base::Arg_error);
00119 
00120 
00122         Structure(const Structure& s);
00123 
00124 
00126         virtual ~Structure();
00127 
00128 
00130         virtual Structure* clone() const = 0;
00131 
00132 
00134         virtual Structure* recursively_clone() const = 0;
00135 
00136 
00138         virtual Structure& operator= (const Structure& s);
00139 
00140 
00142         uint32_t get_id() const { return id; }
00143 
00144 
00146         Structure* get_root();
00147 
00148 
00153         std::vector<Structure*>* get_descendants();
00154 
00155 
00157         class Apical_structure* get_apical() { return apical; }
00158 
00159 
00161         std::list<class Lateral_structure*>& get_laterals() { return laterals; }
00162 
00163 
00165         const jwsc::Vector_f* get_begin_pt() const { return begin_pt; }
00166 
00167 
00169         const jwsc::Vector_f* get_end_pt() const { return end_pt; }
00170 
00171 
00173         const jwsc::Vector_f* get_centroid() const { return centroid; }
00174 
00175 
00177         const jwsc::Vector_f* get_growth_dir() const { return growth_dir; }
00178 
00179 
00181         Structure* get_parent() const { return parent; }
00182 
00183 
00185         size_t get_level() const { return level; }
00186 
00187 
00189         float get_length() const { return length; }
00190 
00191 
00193         float get_width() const { return width; }
00194 
00195 
00197         float get_theta() const { return theta; }
00198 
00199 
00201         float get_base_theta() const { return base_theta; }
00202 
00203 
00205         float get_psi() const { return psi; }
00206 
00207 
00209         float get_base_psi() const { return base_psi; }
00210 
00211 
00213         float get_opacity() const { return opacity; }
00214 
00215 
00217         float get_log_prob() const { return log_prob; }
00218 
00219 
00224         float get_log_prob_descend() const { return log_prob+log_prob_descend; }
00225 
00226 
00230         virtual const char* get_type_str() const = 0;
00231 
00232 
00234         const class Structure_density* get_density() const 
00235         { return density; }
00236 
00237 
00239         void set_apical(class Apical_structure* s) 
00240         { apical = s; update_ancestry_log_prob(); }
00241 
00242 
00244         void add_lateral(class Lateral_structure* s) 
00245         { laterals.push_back(s); update_ancestry_log_prob(); }
00246 
00247 
00249         void remove_lateral(class Lateral_structure* s) 
00250             throw (jwscxx::base::Arg_error);
00251 
00252 
00254         void set_size(float length, float width) 
00255             throw (jwscxx::base::Arg_error);
00256 
00257 
00259         void set_length(float length) throw (jwscxx::base::Arg_error);
00260 
00261 
00263         void set_width(float width) throw (jwscxx::base::Arg_error);
00264 
00265 
00267         void set_theta(float theta) throw (jwscxx::base::Arg_error);
00268 
00269 
00271         void set_base_theta(float base_theta) throw (jwscxx::base::Arg_error);
00272 
00273 
00275         void set_psi(float psi) throw (jwscxx::base::Arg_error);
00276 
00277 
00279         void set_base_psi(float base_psi) throw (jwscxx::base::Arg_error);
00280 
00281 
00283         void set_orientation(float theta, float psi) 
00284             throw (jwscxx::base::Arg_error);
00285 
00286 
00288         void set_base_orientation(float base_theta, float base_psi) 
00289             throw (jwscxx::base::Arg_error);
00290 
00291 
00293         void set_opacity(float opacity) throw (jwscxx::base::Arg_error);
00294 
00295 
00297         virtual bool draw_in_matblock_f
00298         (
00299              jwsc::Matblock_f* M_blk, 
00300              float             x, 
00301              float             y,
00302              float             z,
00303              float             x_scale,
00304              float             y_scale,
00305              float             z_scale,
00306              bool              fill = true
00307         )
00308         const = 0;
00309 
00310 
00315         bool recursively_draw_in_matblock_f
00316         (
00317              jwsc::Matblock_f* M_blk, 
00318              float             x, 
00319              float             y,
00320              float             z,
00321              float             x_scale,
00322              float             y_scale,
00323              float             z_scale,
00324              bool              fill = true
00325         )
00326         const;
00327 
00328 
00330 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK || defined ALTERNARIA_HAVE_OPENGL
00331         virtual void draw_in_opengl(GLUquadric* quad, float scale) const = 0;
00332 #endif
00333 
00334 
00339 #if defined ALTERNARIA_HAVE_OPENGL_FRAMEWORK || defined ALTERNARIA_HAVE_OPENGL
00340         void recursively_draw_in_opengl(GLUquadric* quad, float scale) const;
00341 #endif
00342 
00343 
00348         Structure* get_terminal_apical();
00349 
00350 
00354         class Lateral_structure* get_random_lateral() 
00355             throw (jwscxx::base::Result_error);
00356 
00357 
00362         virtual float get_intersection
00363         (
00364             jwsc::Vector_f**      isect_out, 
00365             uint32_t              n,
00366             const jwsc::Vector_f* p1_in, 
00367             const jwsc::Vector_f* p2_in
00368         )
00369         throw (jwscxx::base::Arg_error) = 0;
00370 
00371 
00373         virtual void print(ostream& out=std::cout) const;
00374 
00375 
00380         void recursively_print(ostream& out=std::cout) const;
00381 
00382 
00387         void recursively_check_structure() const;
00388 
00389 
00390     protected:
00391 
00393         void update_angles() throw (jwscxx::base::Arg_error);
00394 
00396         void update_R();
00397 
00399         void recursively_update_R();
00400 
00402         void update_growth_dir_from_R();
00403 
00405         void update_growth_dir_and_length_from_pts() 
00406             throw (jwscxx::base::Arg_error);
00407 
00409         void update_centroid() throw (jwscxx::base::Arg_error);
00410 
00412         void update_begin_pt();
00413 
00415         void update_end_pt();
00416 
00418         void update_apical() throw (jwscxx::base::Arg_error);
00419 
00421         void update_laterals() throw (jwscxx::base::Arg_error);
00422 
00424         virtual void update_log_prob();
00425 
00430         void update_ancestry_log_prob();
00431 
00436         void recursively_update_levels(int level_delta) 
00437             throw (jwscxx::base::Result_error);
00438 
00442         void check_length() const throw (jwscxx::base::Arg_error);
00443 
00447         void check_width() const throw (jwscxx::base::Arg_error);
00448 
00452         void check_theta() const throw (jwscxx::base::Arg_error);
00453 
00457         void check_base_theta() const throw (jwscxx::base::Arg_error);
00458 
00462         void check_psi() const throw (jwscxx::base::Arg_error);
00463 
00465         void check_base_psi() const throw (jwscxx::base::Arg_error);
00466 
00471         void check_opacity() const throw (jwscxx::base::Arg_error);
00472 
00477         virtual void check_centroid() const throw (jwscxx::base::Arg_error) = 0;
00478 
00480         bool has_child_id(uint32_t id) const;
00481 
00482 
00483     protected:
00484 
00486         Structure* parent;
00487 
00489         class Apical_structure* apical;
00490 
00492         std::list<class Lateral_structure*> laterals;
00493 
00495         jwsc::Vector_f* begin_pt;
00496 
00498         jwsc::Vector_f* end_pt;
00499 
00501         jwsc::Vector_f* centroid;
00502 
00504         jwsc::Vector_f* growth_dir;
00505 
00507         jwsc::Matrix_f* R;
00508 
00510         const class Structure_density* density;
00511 
00513         double log_prob;
00514 
00519         double log_prob_descend;
00520 
00522         float length;
00523 
00525         float width;
00526 
00528         float theta;
00529 
00531         float base_theta;
00532 
00534         float psi;
00535 
00537         float base_psi;
00538 
00540         float opacity;
00541 
00543         uint32_t id;
00544 
00546         size_t level;
00547 
00548 
00549     private:
00550 
00552         static uint32_t generate_id();
00553 
00554 
00555     friend class Apical_structure;
00556     friend class Lateral_structure;
00557 };
00558 
00559 
00560 
00561 
00571 class Structure_density
00572 {
00573     public: 
00574 
00576         virtual ~Structure_density() { }
00577 
00578 
00580         virtual Structure_density* clone() const = 0;
00581 
00582 
00584         const Density::Uniform_params& get_centroid_x() 
00585             const { return centroid_x; }
00586 
00587 
00589         const Density::Uniform_params& get_centroid_z() 
00590             const { return centroid_z; }
00591 
00592 
00594         const Density::Uniform_params& get_centroid_y() 
00595             const { return centroid_y; }
00596 
00597 
00599         const Density::Gaussian_params& get_length() const { return length; }
00600 
00601 
00603         const Density::Gaussian_params& get_width() const { return width; }
00604 
00605 
00607         const Density::Gaussian_params& get_theta() const { return theta; }
00608 
00609 
00611         const Density::Uniform_params& get_psi() const { return psi; }
00612 
00613 
00615         const Density::Gaussian_params& get_opacity() const { return opacity; }
00616 
00617 
00619         void set_centroid_x(float min, float max) 
00620             throw (jwscxx::base::Arg_error);
00621 
00622 
00624         void set_centroid_y(float min, float max) 
00625             throw (jwscxx::base::Arg_error);
00626 
00627 
00629         void set_centroid_z(float min, float max) 
00630             throw (jwscxx::base::Arg_error);
00631 
00632 
00634         void set_length
00635         (
00636             float mu, 
00637             float sigma, 
00638             float min, 
00639             float max
00640         ) 
00641         throw (jwscxx::base::Arg_error);
00642 
00643 
00645         void set_width
00646         (
00647             float mu, 
00648             float sigma, 
00649             float min, 
00650             float max
00651         ) 
00652         throw (jwscxx::base::Arg_error);
00653 
00654 
00656         void set_theta
00657         (
00658             float mu, 
00659             float sigma, 
00660             float min, 
00661             float max
00662         ) 
00663         throw (jwscxx::base::Arg_error);
00664 
00665 
00667         void set_psi(float min, float max) throw (jwscxx::base::Arg_error);
00668 
00669 
00671         void set_opacity
00672         (
00673             float mu, 
00674             float sigma, 
00675             float min, 
00676             float max
00677         ) 
00678         throw (jwscxx::base::Arg_error);
00679 
00680 
00682         float sample_centroid_x() const;
00683 
00684 
00686         float sample_centroid_y() const;
00687 
00688 
00690         float sample_centroid_z() const;
00691 
00692 
00694         float sample_length() const;
00695 
00696 
00698         float sample_width() const;
00699 
00700 
00702         float sample_theta() const;
00703 
00704 
00706         float sample_psi() const;
00707 
00708 
00710         float sample_opacity() const;
00711 
00712 
00714         virtual Structure* sample
00715         (
00716             float base_theta, 
00717             float base_psi, 
00718             size_t level
00719         ) 
00720         const = 0;
00721 
00722 
00724         virtual Structure* sample
00725         (
00726             float centroid_x, 
00727             float centroid_y, 
00728             float centroid_z,
00729             float base_theta,
00730             float base_psi,
00731             size_t level
00732         ) 
00733         const throw (jwscxx::base::Arg_error) = 0;
00734 
00735 
00737         virtual Structure* sample
00738         (
00739             class Structure* parent,
00740             float base_theta,
00741             float base_psi
00742         ) 
00743         const throw (jwscxx::base::Arg_error) = 0;
00744 
00745 
00746     protected:
00747 
00749         Density::Uniform_params  centroid_x;
00750 
00752         Density::Uniform_params  centroid_y;
00753 
00755         Density::Uniform_params  centroid_z;
00756 
00758         Density::Gaussian_params  length;
00759 
00761         Density::Gaussian_params  width;
00762 
00764         Density::Gaussian_params  theta;
00765 
00767         Density::Uniform_params  psi;
00768 
00770         Density::Gaussian_params  opacity;
00771 };
00772 
00773 
00774 
00775 
00776 
00777 
00787 class Printed_structure
00788 {
00789     public: 
00790 
00792         virtual ~Printed_structure() { }
00793 
00794 
00796         uint32_t get_id() const { return id; }
00797 
00798 
00800         size_t get_level() const { return level; }
00801 
00802 
00804         uint32_t get_parent() const { return parent; }
00805 
00806 
00808         virtual Structure* convert(Structure* parent) const 
00809             throw (jwscxx::base::Arg_error) = 0;
00810 
00811 
00816         virtual Structure* recursively_convert
00817         (
00818             Structure* parent,
00819             std::list<class Printed_apical_structure*>::const_iterator 
00820                             apical_begin, 
00821             std::list<class Printed_apical_structure*>::const_iterator 
00822                             apical_end, 
00823             std::list<class Printed_lateral_structure*>::const_iterator 
00824                             lateral_begin, 
00825             std::list<class Printed_lateral_structure*>::const_iterator 
00826                             lateral_end
00827         ) 
00828         const throw (jwscxx::base::Arg_error) = 0;
00829 
00830 
00834         virtual void read(std::istream& in)
00835             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) = 0;
00836 
00837 
00842         static bool is_on_istream(std::istream& in, const char* type_str)
00843             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00844 
00845 
00846     protected:
00847 
00849         void read_id(std::istream& in)
00850             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00851 
00853         void read_level(std::istream& in)
00854             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00855 
00857         void read_centroid(std::istream& in)
00858             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00859 
00861         void read_length(std::istream& in)
00862             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00863 
00865         void read_width(std::istream& in)
00866             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00867 
00869         void read_theta(std::istream& in)
00870             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00871 
00873         void read_base_theta(std::istream& in)
00874             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00875 
00877         void read_psi(std::istream& in)
00878             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00879 
00881         void read_base_psi(std::istream& in)
00882             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00883 
00885         void read_opacity(std::istream& in)
00886             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00887 
00889         void read_log_prob(std::istream& in)
00890             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00891 
00893         void read_parent(std::istream& in)
00894             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00895 
00897         void read_apical(std::istream& in)
00898             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00899 
00901         void read_laterals(std::istream& in)
00902             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00903 
00904 
00905     protected:
00906 
00912         uint32_t parent;
00913 
00919         uint32_t apical;
00920 
00922         std::list<uint32_t> laterals;
00923 
00925         float centroid_x;
00926 
00928         float centroid_y;
00929 
00931         float centroid_z;
00932 
00934         double log_prob;
00935 
00937         float length;
00938 
00940         float width;
00941 
00943         float theta;
00944 
00946         float base_theta;
00947 
00949         float psi;
00950 
00952         float base_psi;
00953 
00955         float opacity;
00956 
00958         uint32_t id;
00959 
00961         size_t level;
00962 };
00963 
00964 
00974 class Apical_structure : public Structure
00975 {
00976     public: 
00977 
00982         Apical_structure
00983         (
00984             float centroid_x, 
00985             float centroid_y,
00986             float centroid_z,
00987             float length,
00988             float width,
00989             float base_theta,
00990             float base_psi,
00991             float theta,
00992             float psi,
00993             float opacity,
00994             size_t level,
00995             const class Apical_structure_density* density
00996         ) 
00997         throw (jwscxx::base::Arg_error);
00998 
00999 
01001         Apical_structure
01002         (
01003             Structure* parent,
01004             float      length,
01005             float      width,
01006             float      base_theta,
01007             float      base_psi,
01008             float      theta,
01009             float      psi,
01010             float      opacity,
01011             const class Apical_structure_density* density
01012         )
01013         throw (jwscxx::base::Arg_error, Apical_error);
01014 
01015 
01017         Apical_structure
01018         (
01019             Structure* parent,
01020             float      centroid_x,
01021             float      centroid_y,
01022             float      centroid_z,
01023             float      length,
01024             float      width,
01025             float      base_theta,
01026             float      base_psi,
01027             float      opacity,
01028             const class Apical_structure_density* density
01029         )
01030         throw (jwscxx::base::Arg_error, Apical_error);
01031 
01032 
01034         Apical_structure(const Apical_structure& s);
01035 
01036 
01038         virtual Apical_structure* clone() const = 0;
01039 
01040 
01045         virtual Apical_structure* recursively_clone() const;
01046 
01047 
01049         virtual Apical_structure& operator= (const Apical_structure& s);
01050 
01051 
01053         virtual ~Apical_structure() { }
01054 
01055 
01057         void set_position(float centroid_x, float centroid_y, float centroid_z) 
01058             throw (jwscxx::base::Arg_error);
01059 
01060 
01065         virtual Apical_structure* split_into_apical
01066         (
01067             const Apical_structure* rvals_1,
01068             const Apical_structure* rvals_2
01069         ) 
01070         throw (jwscxx::base::Arg_error);
01071 
01072 
01077         virtual Apical_structure* merge_with_apical
01078         (
01079             const Apical_structure* rvals
01080         ) 
01081         throw (jwscxx::base::Arg_error);
01082 
01083 
01088         virtual Lateral_structure* split_into_lateral
01089         (
01090             const Apical_structure*  rvals_1,
01091             const Lateral_structure* rvals_2
01092         ) 
01093         throw (jwscxx::base::Arg_error);
01094 
01095 
01100         virtual Lateral_structure* merge_with_lateral
01101         (
01102             Lateral_structure*      lateral,
01103             const Apical_structure* rvals
01104         ) 
01105         throw (jwscxx::base::Arg_error);
01106 
01107 
01109         virtual void replace(Apical_structure* s) 
01110             throw (jwscxx::base::Arg_error);
01111 
01112 
01113     protected:
01114 
01119         void update_from_parent_end_pt() throw (jwscxx::base::Arg_error);
01120 
01122         virtual void update_log_prob();
01123 
01128         void check_centroid() const throw (jwscxx::base::Arg_error);
01129 
01130 
01131     protected:
01132 
01134         const class Apical_structure_density* density;
01135 
01136 
01137     friend class Structure;
01138     friend class Lateral_structure;
01139 };
01140 
01141 
01142 
01143 
01153 class Apical_structure_density : public Structure_density
01154 {
01155     public:
01156 
01158         virtual ~Apical_structure_density() { }
01159 
01160 
01162         virtual Apical_structure* sample
01163         (
01164             float base_theta, 
01165             float base_psi,
01166             size_t level
01167         ) 
01168         const = 0;
01169 
01170 
01172         virtual Apical_structure* sample
01173         (
01174             float centroid_x, 
01175             float centroid_y, 
01176             float centroid_z,
01177             float base_theta,
01178             float base_psi,
01179             size_t level
01180         ) 
01181         const throw (jwscxx::base::Arg_error) = 0;
01182 
01183 
01185         virtual Apical_structure* sample
01186         (
01187             class Structure* parent,
01188             float base_theta,
01189             float base_psi
01190         ) 
01191         const throw (jwscxx::base::Arg_error) = 0;
01192 };
01193 
01194 
01195 
01196 
01197 
01207 class Printed_apical_structure : public Printed_structure
01208 {
01209     public: 
01210 
01212         virtual ~Printed_apical_structure() { }
01213 
01214 
01219         virtual Apical_structure* convert(Structure* parent) const 
01220             throw (jwscxx::base::Arg_error) = 0;
01221 
01222 
01227         Apical_structure* recursively_convert
01228         (
01229             Structure* parent,
01230             std::list<class Printed_apical_structure*>::const_iterator 
01231                             apical_begin, 
01232             std::list<class Printed_apical_structure*>::const_iterator 
01233                             apical_end, 
01234             std::list<class Printed_lateral_structure*>::const_iterator 
01235                             lateral_begin, 
01236             std::list<class Printed_lateral_structure*>::const_iterator 
01237                             lateral_end
01238         ) 
01239         const throw (jwscxx::base::Arg_error);
01240 };
01241 
01242 
01243 
01244 
01254 class Lateral_structure : public Structure
01255 {
01256     public: 
01257 
01262         Lateral_structure
01263         (
01264             float centroid_x, 
01265             float centroid_y,
01266             float centroid_z,
01267             float lat_dist,
01268             float length,
01269             float width,
01270             float base_theta,
01271             float base_psi,
01272             float theta,
01273             float psi,
01274             float opacity,
01275             size_t level,
01276             const class Lateral_structure_density* density
01277         ) 
01278         throw (jwscxx::base::Arg_error);
01279 
01280 
01282         Lateral_structure
01283         (
01284             Structure* parent,
01285             float      lat_dist,
01286             float      length,
01287             float      width,
01288             float      base_theta,
01289             float      base_psi,
01290             float      theta,
01291             float      psi,
01292             float      opacity,
01293             const class Lateral_structure_density* density
01294         )
01295         throw (jwscxx::base::Arg_error);
01296 
01297 
01299         Lateral_structure(const Lateral_structure& s);
01300 
01301 
01303         virtual Lateral_structure* clone() const = 0;
01304 
01305 
01310         virtual Lateral_structure* recursively_clone() const;
01311 
01312 
01314         virtual Lateral_structure& operator= (const Lateral_structure& s);
01315 
01316 
01318         virtual ~Lateral_structure() { }
01319 
01320 
01325         float get_lat_dist() const { return lat_dist; }
01326 
01327 
01329         void set_parent(Structure* parent, float lat_dist) 
01330             throw (jwscxx::base::Arg_error);
01331 
01332 
01334         void set_lat_dist(float lat_dist) throw (jwscxx::base::Arg_error);
01335 
01336 
01338         const class Lateral_structure_density* get_density() const 
01339         { return density; }
01340 
01341 
01343         virtual void print(ostream& out=std::cout) const;
01344 
01345 
01346     protected:
01347 
01352         void update_from_parent_end_pt() throw (jwscxx::base::Arg_error);
01353 
01355         void update_log_prob();
01356 
01361         void check_centroid() const throw (jwscxx::base::Arg_error);
01362 
01367         void check_lat_dist() const throw (jwscxx::base::Arg_error);
01368 
01369 
01370     protected:
01371 
01373         const class Lateral_structure_density* density;
01374 
01379         float lat_dist;
01380 
01381 
01382     friend class Structure;
01383     friend class Apical_structure;
01384 };
01385 
01386 
01387 
01388 
01398 class Lateral_structure_density : public Structure_density
01399 {
01400     public: 
01401 
01403         virtual ~Lateral_structure_density() { }
01404 
01405 
01407         virtual Lateral_structure_density* clone() const = 0;
01408 
01409 
01414         const Density::Gaussian_params& get_lat_dist() 
01415             const { return lat_dist; }
01416 
01417 
01422         void set_lat_dist
01423         (
01424             float mu, 
01425             float sigma, 
01426             float min, 
01427             float max
01428         ) 
01429         throw (jwscxx::base::Arg_error);
01430 
01431 
01433         float sample_lat_dist() const;
01434 
01435 
01437         virtual Lateral_structure* sample
01438         (
01439             float base_theta, 
01440             float base_psi,
01441             size_t level
01442         ) 
01443         const = 0;
01444 
01445 
01447         virtual Lateral_structure* sample
01448         (
01449             float centroid_x, 
01450             float centroid_y, 
01451             float centroid_z,
01452             float base_theta,
01453             float base_psi,
01454             size_t level
01455         ) 
01456         const throw (jwscxx::base::Arg_error) = 0;
01457 
01458 
01460         virtual Lateral_structure* sample
01461         (
01462             class Structure* parent,
01463             float base_theta,
01464             float base_psi
01465         ) 
01466         const throw (jwscxx::base::Arg_error) = 0;
01467 
01468 
01469     protected:
01470 
01475         Density::Gaussian_params  lat_dist;
01476 };
01477 
01478 
01479 
01480 
01481 
01491 class Printed_lateral_structure : public Printed_structure
01492 {
01493     public: 
01494 
01496         virtual ~Printed_lateral_structure() { }
01497 
01498 
01503         virtual Lateral_structure* convert(Structure* parent) const 
01504             throw (jwscxx::base::Arg_error) = 0;
01505 
01506 
01511         Lateral_structure* recursively_convert
01512         (
01513             Structure* parent,
01514             std::list<class Printed_apical_structure*>::const_iterator 
01515                             apical_begin, 
01516             std::list<class Printed_apical_structure*>::const_iterator 
01517                             apical_end, 
01518             std::list<class Printed_lateral_structure*>::const_iterator 
01519                             lateral_begin, 
01520             std::list<class Printed_lateral_structure*>::const_iterator 
01521                             lateral_end
01522         ) 
01523         const throw (jwscxx::base::Arg_error);
01524 
01525 
01526     protected:
01527 
01529         void read_lat_dist(std::istream& in)
01530             throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
01531 
01532     protected:
01533 
01535         float lat_dist;
01536 };
01537 
01538 
01539 #endif