Rev 1211 | Rev 1214 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1211 | Rev 1213 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | #include "resourceunit.h"
|
25 | #include "resourceunit.h"
|
26 | #include "resourceunitspecies.h"
|
26 | #include "resourceunitspecies.h"
|
27 | #include "establishment.h"
|
27 | #include "establishment.h"
|
28 | #include "species.h"
|
28 | #include "species.h"
|
29 | #include "seeddispersal.h"
|
29 | #include "seeddispersal.h"
|
- | 30 | #include "mapgrid.h"
|
|
30 | 31 | ||
31 | double Saplings::mRecruitmentVariation = 0.1; // +/- 10% |
32 | double Saplings::mRecruitmentVariation = 0.1; // +/- 10% |
32 | double Saplings::mBrowsingPressure = 0.; |
33 | double Saplings::mBrowsingPressure = 0.; |
33 | 34 | ||
34 | 35 | ||
Line 609... | Line 610... | ||
609 | {
|
610 | {
|
610 | if (!ru || !is_occupied()) |
611 | if (!ru || !is_occupied()) |
611 | return 0; |
612 | return 0; |
612 | ResourceUnitSpecies *rus = ru->resourceUnitSpecies(species_index); |
613 | ResourceUnitSpecies *rus = ru->resourceUnitSpecies(species_index); |
613 | return rus; |
614 | return rus; |
- | 615 | }
|
|
- | 616 | ||
- | 617 | SaplingCellRunner::SaplingCellRunner(const int stand_id, const MapGrid *stand_grid) |
|
- | 618 | {
|
|
- | 619 | mRunner = 0; |
|
- | 620 | mRU = 0; |
|
- | 621 | mStandId = stand_id; |
|
- | 622 | mStandGrid = stand_grid ? stand_grid : GlobalSettings::instance()->model()->standGrid(); |
|
- | 623 | QRectF box = mStandGrid->boundingBox(stand_id); |
|
- | 624 | mRunner = new GridRunner<float>(GlobalSettings::instance()->model()->grid(), box); |
|
- | 625 | ||
- | 626 | }
|
|
- | 627 | ||
- | 628 | SaplingCell *SaplingCellRunner::next() |
|
- | 629 | {
|
|
- | 630 | if (!mRunner) |
|
- | 631 | return 0; |
|
- | 632 | while (float *n = mRunner->next()) { |
|
- | 633 | if (!n) |
|
- | 634 | return 0; // end of the bounding box |
|
- | 635 | if (mStandGrid->standIDFromLIFCoord(mRunner->currentIndex()) != mStandId) |
|
- | 636 | continue; // pixel does not belong to the target stand |
|
- | 637 | mRU = GlobalSettings::instance()->model()->ru(mRunner->currentCoord()); |
|
- | 638 | SaplingCell *sc=0; |
|
- | 639 | if (mRU) |
|
- | 640 | sc=mRU->saplingCell(mRunner->currentIndex()); |
|
- | 641 | if (sc) |
|
- | 642 | return sc; |
|
- | 643 | qDebug() << "SaplingCellRunner::next(): unexected missing SaplingCell!"; |
|
- | 644 | return 0; |
|
- | 645 | }
|
|
- | 646 | return 0; |
|
- | 647 | }
|
|
- | 648 | ||
- | 649 | QPointF SaplingCellRunner::currentCoord() const |
|
- | 650 | {
|
|
- | 651 | return mRunner->currentCoord(); |
|
614 | }
|
652 | }
|