![]() |
0.1.8
|
High-level interface for plant architecture modeling and procedural plant generation. More...
High-level interface for plant architecture modeling and procedural plant generation.
PlantArchitecture provides access to the comprehensive plant library with 25+ plant models including trees (almond, apple, olive, walnut), crops (bean, cowpea, maize, rice, soybean), and other plants. This class enables procedural plant generation, time-based growth simulation, and plant community modeling.
This class requires the native Helios library built with PlantArchitecture support. Use context managers for proper resource cleanup.
Examples
Definition at line 189 of file PlantArchitecture.py.
Public Member Functions | |
__init__ (self, Context context) | |
Initialize PlantArchitecture with a Helios context. | |
__enter__ (self) | |
Context manager entry. | |
__exit__ (self, exc_type, exc_val, exc_tb) | |
Context manager exit - cleanup resources. | |
None | loadPlantModelFromLibrary (self, str plant_label) |
Load a plant model from the built-in library. | |
int | buildPlantInstanceFromLibrary (self, vec3 base_position, float age) |
Build a plant instance from the currently loaded library model. | |
List[int] | buildPlantCanopyFromLibrary (self, vec3 canopy_center, vec2 plant_spacing, int2 plant_count, float age) |
Build a canopy of regularly spaced plants from the currently loaded library model. | |
None | advanceTime (self, float dt) |
Advance time for plant growth and development. | |
List[str] | getAvailablePlantModels (self) |
Get list of all available plant models in the library. | |
List[int] | getAllPlantObjectIDs (self, int plant_id) |
Get all object IDs for a specific plant. | |
List[int] | getAllPlantUUIDs (self, int plant_id) |
Get all primitive UUIDs for a specific plant. | |
None | enableSoftCollisionAvoidance (self, Optional[List[int]] target_object_UUIDs=None, Optional[List[int]] target_object_IDs=None, bool enable_petiole_collision=False, bool enable_fruit_collision=False) |
Enable soft collision avoidance for procedural plant growth. | |
None | disableCollisionDetection (self) |
Disable collision detection for plant growth. | |
None | setSoftCollisionAvoidanceParameters (self, float view_half_angle_deg=80.0, float look_ahead_distance=0.1, int sample_count=256, float inertia_weight=0.4) |
Configure parameters for soft collision avoidance algorithm. | |
None | setCollisionRelevantOrgans (self, bool include_internodes=False, bool include_leaves=True, bool include_petioles=False, bool include_flowers=False, bool include_fruit=False) |
Specify which plant organs participate in collision detection. | |
None | enableSolidObstacleAvoidance (self, List[int] obstacle_UUIDs, float avoidance_distance=0.5, bool enable_fruit_adjustment=False, bool enable_obstacle_pruning=False) |
Enable hard obstacle avoidance for specified geometry. | |
None | setStaticObstacles (self, List[int] target_UUIDs) |
Mark geometry as static obstacles for collision detection optimization. | |
List[int] | getPlantCollisionRelevantObjectIDs (self, int plant_id) |
Get object IDs of collision-relevant geometry for a specific plant. | |
None | writePlantMeshVertices (self, int plant_id, Union[str, Path] filename) |
Write all plant mesh vertices to file for external processing. | |
None | writePlantStructureXML (self, int plant_id, Union[str, Path] filename) |
Save plant structure to XML file for later loading. | |
None | writeQSMCylinderFile (self, int plant_id, Union[str, Path] filename) |
Export plant structure in TreeQSM cylinder format. | |
List[int] | readPlantStructureXML (self, Union[str, Path] filename, bool quiet=False) |
Load plant structure from XML file. | |
int | addPlantInstance (self, vec3 base_position, float current_age) |
Create an empty plant instance for custom plant building. | |
None | deletePlantInstance (self, int plant_id) |
Delete a plant instance and all associated geometry. | |
int | addBaseStemShoot (self, int plant_id, int current_node_number, AxisRotation base_rotation, float internode_radius, float internode_length_max, float internode_length_scale_factor_fraction, float leaf_scale_factor_fraction, float radius_taper, str shoot_type_label) |
Add a base stem shoot to a plant instance (main trunk/stem). | |
int | appendShoot (self, int plant_id, int parent_shoot_id, int current_node_number, AxisRotation base_rotation, float internode_radius, float internode_length_max, float internode_length_scale_factor_fraction, float leaf_scale_factor_fraction, float radius_taper, str shoot_type_label) |
Append a shoot to the end of an existing shoot. | |
int | addChildShoot (self, int plant_id, int parent_shoot_id, int parent_node_index, int current_node_number, AxisRotation shoot_base_rotation, float internode_radius, float internode_length_max, float internode_length_scale_factor_fraction, float leaf_scale_factor_fraction, float radius_taper, str shoot_type_label, int petiole_index=0) |
Add a child shoot at an axillary bud position on a parent shoot. | |
bool | is_available (self) |
Check if PlantArchitecture is available in current build. | |
Public Attributes | |
context = context | |
Protected Attributes | |
_plantarch_ptr = None | |
pyhelios.PlantArchitecture.PlantArchitecture.__init__ | ( | self, | |
Context | context ) |
Initialize PlantArchitecture with a Helios context.
context | Active Helios Context instance |
PlantArchitectureError | If plugin not available in current build |
RuntimeError | If plugin initialization fails |
Definition at line 201 of file PlantArchitecture.py.
pyhelios.PlantArchitecture.PlantArchitecture.__enter__ | ( | self | ) |
Context manager entry.
Definition at line 230 of file PlantArchitecture.py.
pyhelios.PlantArchitecture.PlantArchitecture.__exit__ | ( | self, | |
exc_type, | |||
exc_val, | |||
exc_tb ) |
Context manager exit - cleanup resources.
Definition at line 234 of file PlantArchitecture.py.
int pyhelios.PlantArchitecture.PlantArchitecture.addBaseStemShoot | ( | self, | |
int | plant_id, | ||
int | current_node_number, | ||
AxisRotation | base_rotation, | ||
float | internode_radius, | ||
float | internode_length_max, | ||
float | internode_length_scale_factor_fraction, | ||
float | leaf_scale_factor_fraction, | ||
float | radius_taper, | ||
str | shoot_type_label ) |
Add a base stem shoot to a plant instance (main trunk/stem).
This method creates the primary shoot originating from the plant base. The base stem is typically the main trunk or primary stem from which all other shoots branch. Specify growth parameters to control the shoot's morphology and development. **IMPORTANT - Shoot Type Requirement**: Shoot types must be defined before use. The standard workflow is to load a plant model first using loadPlantModelFromLibrary(), which defines shoot types that can then be used for custom building. The shoot_type_label must match a shoot type defined in the loaded model.
plant_id | ID of the plant instance |
current_node_number | Starting node number for this shoot (typically 1) |
base_rotation | Orientation as AxisRotation(pitch, yaw, roll) in degrees |
internode_radius | Base radius of internodes in meters (must be > 0) |
internode_length_max | Maximum internode length in meters (must be > 0) |
internode_length_scale_factor_fraction | Scale factor for internode length (0-1 typically) |
leaf_scale_factor_fraction | Scale factor for leaf size (0-1 typically) |
radius_taper | Rate of radius decrease along shoot (0-1, where 1=no taper) |
shoot_type_label | Label identifying shoot type - must match a type from loaded model |
ValueError | If parameters are invalid (negative IDs, non-positive dimensions, empty label) |
PlantArchitectureError | If shoot creation fails or shoot type doesn't exist |
Examples
Definition at line 1131 of file PlantArchitecture.py.
int pyhelios.PlantArchitecture.PlantArchitecture.addChildShoot | ( | self, | |
int | plant_id, | ||
int | parent_shoot_id, | ||
int | parent_node_index, | ||
int | current_node_number, | ||
AxisRotation | shoot_base_rotation, | ||
float | internode_radius, | ||
float | internode_length_max, | ||
float | internode_length_scale_factor_fraction, | ||
float | leaf_scale_factor_fraction, | ||
float | radius_taper, | ||
str | shoot_type_label, | ||
int | petiole_index = 0 ) |
Add a child shoot at an axillary bud position on a parent shoot.
This method creates a lateral branch shoot emerging from a specific node on the parent shoot. Child shoots enable creation of branching architectures, with control over branch angle, size, and which petiole position the branch emerges from (for plants with multiple petioles per node). **IMPORTANT - Shoot Type Requirement**: The shoot_type_label must match a shoot type defined in a loaded plant model. Load a model with loadPlantModelFromLibrary() before calling this method.
plant_id | ID of the plant instance |
parent_shoot_id | ID of the parent shoot |
parent_node_index | Index of the parent node where child emerges (0-based) |
current_node_number | Starting node number for this child shoot |
shoot_base_rotation | Orientation as AxisRotation(pitch, yaw, roll) in degrees |
internode_radius | Base radius of child shoot internodes in meters (must be > 0) |
internode_length_max | Maximum internode length in meters (must be > 0) |
internode_length_scale_factor_fraction | Scale factor for internode length (0-1 typically) |
leaf_scale_factor_fraction | Scale factor for leaf size (0-1 typically) |
radius_taper | Rate of radius decrease along shoot (0-1, where 1=no taper) |
shoot_type_label | Label identifying shoot type - must match loaded model |
petiole_index | Which petiole at the node to branch from (default: 0) |
ValueError | If parameters are invalid (negative values, non-positive dimensions, empty label) |
PlantArchitectureError | If child shoot creation fails, parent doesn't exist, or shoot type not defined |
Examples
Definition at line 1330 of file PlantArchitecture.py.
int pyhelios.PlantArchitecture.PlantArchitecture.addPlantInstance | ( | self, | |
vec3 | base_position, | ||
float | current_age ) |
Create an empty plant instance for custom plant building.
This method creates a new plant instance at the specified location without any shoots or organs. Use addBaseStemShoot(), appendShoot(), and addChildShoot() to manually construct the plant structure. This provides low-level control over plant architecture, enabling custom morphologies not available in the plant library.
base_position | Cartesian (x,y,z) coordinates of plant base as vec3 |
current_age | Current age of the plant in days (must be >= 0) |
ValueError | If age is negative |
PlantArchitectureError | If plant creation fails |
Examples
Definition at line 1027 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.advanceTime | ( | self, | |
float | dt ) |
Advance time for plant growth and development.
This method updates all plants in the simulation, potentially adding new phytomers, growing existing organs, transitioning phenological stages, and updating plant geometry.
dt | Time step to advance in days (must be >= 0) |
ValueError | If dt is negative |
PlantArchitectureError | If time advancement fails |
Examples
Definition at line 386 of file PlantArchitecture.py.
int pyhelios.PlantArchitecture.PlantArchitecture.appendShoot | ( | self, | |
int | plant_id, | ||
int | parent_shoot_id, | ||
int | current_node_number, | ||
AxisRotation | base_rotation, | ||
float | internode_radius, | ||
float | internode_length_max, | ||
float | internode_length_scale_factor_fraction, | ||
float | leaf_scale_factor_fraction, | ||
float | radius_taper, | ||
str | shoot_type_label ) |
Append a shoot to the end of an existing shoot.
This method extends an existing shoot by appending a new shoot at its terminal bud. Useful for creating multi-segmented shoots with varying properties along their length, such as shoots with different growth phases or developmental stages. **IMPORTANT - Shoot Type Requirement**: The shoot_type_label must match a shoot type defined in a loaded plant model. Load a model with loadPlantModelFromLibrary() before calling this method.
plant_id | ID of the plant instance |
parent_shoot_id | ID of the parent shoot to extend |
current_node_number | Starting node number for this shoot |
base_rotation | Orientation as AxisRotation(pitch, yaw, roll) in degrees |
internode_radius | Base radius of internodes in meters (must be > 0) |
internode_length_max | Maximum internode length in meters (must be > 0) |
internode_length_scale_factor_fraction | Scale factor for internode length (0-1 typically) |
leaf_scale_factor_fraction | Scale factor for leaf size (0-1 typically) |
radius_taper | Rate of radius decrease along shoot (0-1, where 1=no taper) |
shoot_type_label | Label identifying shoot type - must match loaded model |
ValueError | If parameters are invalid (negative IDs, non-positive dimensions, empty label) |
PlantArchitectureError | If shoot appending fails, parent doesn't exist, or shoot type not defined |
Examples
Definition at line 1224 of file PlantArchitecture.py.
List[int] pyhelios.PlantArchitecture.PlantArchitecture.buildPlantCanopyFromLibrary | ( | self, | |
vec3 | canopy_center, | ||
vec2 | plant_spacing, | ||
int2 | plant_count, | ||
float | age ) |
Build a canopy of regularly spaced plants from the currently loaded library model.
canopy_center | Cartesian (x,y,z) coordinates of canopy center as vec3 |
plant_spacing | Spacing between plants in x- and y-directions (meters) as vec2 |
plant_count | Number of plants in x- and y-directions as int2 |
age | Age of all plants in days (must be >= 0) |
ValueError | If age is negative or plant count values are not positive |
PlantArchitectureError | If canopy building fails |
Examples
Definition at line 338 of file PlantArchitecture.py.
int pyhelios.PlantArchitecture.PlantArchitecture.buildPlantInstanceFromLibrary | ( | self, | |
vec3 | base_position, | ||
float | age ) |
Build a plant instance from the currently loaded library model.
base_position | Cartesian (x,y,z) coordinates of plant base as vec3 |
age | Age of the plant in days (must be >= 0) |
ValueError | If age is negative |
PlantArchitectureError | If plant building fails |
RuntimeError | If no model has been loaded |
Examples
Definition at line 295 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.deletePlantInstance | ( | self, | |
int | plant_id ) |
Delete a plant instance and all associated geometry.
This method removes a plant from the simulation, deleting all shoots, organs, and associated primitives from the context. The plant ID becomes invalid after deletion and should not be used in subsequent operations.
plant_id | ID of the plant instance to delete |
ValueError | If plant_id is negative |
PlantArchitectureError | If plant deletion fails or plant doesn't exist |
Examples
Definition at line 1067 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.disableCollisionDetection | ( | self | ) |
Disable collision detection for plant growth.
This method turns off the collision detection system, allowing plants to grow without checking for obstacles. This improves performance but plants may grow through obstacles and other geometry.
PlantArchitectureError | If disabling fails |
Examples
Definition at line 546 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.enableSoftCollisionAvoidance | ( | self, | |
Optional[List[int]] | target_object_UUIDs = None, | ||
Optional[List[int]] | target_object_IDs = None, | ||
bool | enable_petiole_collision = False, | ||
bool | enable_fruit_collision = False ) |
Enable soft collision avoidance for procedural plant growth.
This method enables the collision detection system that guides plant growth away from obstacles and other plants. The system uses cone-based gap detection to find optimal growth directions that minimize collisions while maintaining natural plant architecture.
target_object_UUIDs | List of primitive UUIDs to avoid collisions with. If empty, avoids all geometry in the context. |
target_object_IDs | List of compound object IDs to avoid collisions with. |
enable_petiole_collision | Enable collision detection for leaf petioles |
enable_fruit_collision | Enable collision detection for fruit organs |
PlantArchitectureError | If collision detection activation fails |
Examples
Definition at line 514 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.enableSolidObstacleAvoidance | ( | self, | |
List[int] | obstacle_UUIDs, | ||
float | avoidance_distance = 0.5, | ||
bool | enable_fruit_adjustment = False, | ||
bool | enable_obstacle_pruning = False ) |
Enable hard obstacle avoidance for specified geometry.
This method configures solid obstacles that plants cannot grow through. Unlike soft collision avoidance (which guides growth), solid obstacles cause complete growth termination when encountered within the avoidance distance.
obstacle_UUIDs | List of primitive UUIDs representing solid obstacles |
avoidance_distance | Minimum distance to maintain from obstacles (meters). Growth stops if obstacles are closer. Default 0.5m. |
enable_fruit_adjustment | Adjust fruit positions away from obstacles |
enable_obstacle_pruning | Remove plant organs that penetrate obstacles |
ValueError | If obstacle_UUIDs is empty or avoidance_distance is non-positive |
PlantArchitectureError | If solid obstacle configuration fails |
Examples
Definition at line 697 of file PlantArchitecture.py.
List[int] pyhelios.PlantArchitecture.PlantArchitecture.getAllPlantObjectIDs | ( | self, | |
int | plant_id ) |
Get all object IDs for a specific plant.
plant_id | ID of the plant instance |
ValueError | If plant_id is negative |
PlantArchitectureError | If retrieval fails |
Examples
Definition at line 439 of file PlantArchitecture.py.
List[int] pyhelios.PlantArchitecture.PlantArchitecture.getAllPlantUUIDs | ( | self, | |
int | plant_id ) |
Get all primitive UUIDs for a specific plant.
plant_id | ID of the plant instance |
ValueError | If plant_id is negative |
PlantArchitectureError | If retrieval fails |
Examples
Definition at line 467 of file PlantArchitecture.py.
List[str] pyhelios.PlantArchitecture.PlantArchitecture.getAvailablePlantModels | ( | self | ) |
Get list of all available plant models in the library.
PlantArchitectureError | If retrieval fails |
Examples
Available models: almond, apple, bean, cowpea, maize, rice, soybean, tomato, wheat, ...
Definition at line 413 of file PlantArchitecture.py.
List[int] pyhelios.PlantArchitecture.PlantArchitecture.getPlantCollisionRelevantObjectIDs | ( | self, | |
int | plant_id ) |
Get object IDs of collision-relevant geometry for a specific plant.
This method returns the subset of plant geometry that participates in collision detection, as filtered by setCollisionRelevantOrgans(). Useful for visualization and debugging collision detection behavior.
plant_id | ID of the plant instance |
ValueError | If plant_id is negative |
PlantArchitectureError | If retrieval fails |
Examples
Definition at line 785 of file PlantArchitecture.py.
bool pyhelios.PlantArchitecture.PlantArchitecture.is_available | ( | self | ) |
Check if PlantArchitecture is available in current build.
Definition at line 1389 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.loadPlantModelFromLibrary | ( | self, | |
str | plant_label ) |
Load a plant model from the built-in library.
plant_label | Plant model identifier from library. Available models include: "almond", "apple", "bean", "bindweed", "butterlettuce", "capsicum",
"cheeseweed", "cowpea", "easternredbud", "grapevine_VSP", "maize",
"olive", "pistachio", "puncturevine", "rice", "sorghum", "soybean",
"strawberry", "sugarbeet", "tomato", "cherrytomato", "walnut", "wheat"
|
ValueError | If plant_label is empty or invalid |
PlantArchitectureError | If model loading fails |
Examples
Definition at line 261 of file PlantArchitecture.py.
List[int] pyhelios.PlantArchitecture.PlantArchitecture.readPlantStructureXML | ( | self, | |
Union[str, Path] | filename, | ||
bool | quiet = False ) |
Load plant structure from XML file.
This method reads plant architecture data from an XML file previously saved with writePlantStructureXML(). The loaded plants are added to the current context and can be grown, modified, or analyzed like any other plants.
filename | Path to XML file to load (absolute or relative to current working directory) |
quiet | If True, suppress console output during loading (default: False) |
ValueError | If filename is empty |
PlantArchitectureError | If file doesn't exist, cannot be parsed, or loading fails |
Examples
Definition at line 981 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.setCollisionRelevantOrgans | ( | self, | |
bool | include_internodes = False, | ||
bool | include_leaves = True, | ||
bool | include_petioles = False, | ||
bool | include_flowers = False, | ||
bool | include_fruit = False ) |
Specify which plant organs participate in collision detection.
This method allows filtering which organs are considered during collision detection, enabling optimization by excluding organs unlikely to cause problematic collisions.
include_internodes | Include stem internodes in collision detection |
include_leaves | Include leaf blades in collision detection |
include_petioles | Include leaf petioles in collision detection |
include_flowers | Include flowers in collision detection |
include_fruit | Include fruit in collision detection |
PlantArchitectureError | If organ filtering fails |
Examples
Definition at line 647 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.setSoftCollisionAvoidanceParameters | ( | self, | |
float | view_half_angle_deg = 80.0, | ||
float | look_ahead_distance = 0.1, | ||
int | sample_count = 256, | ||
float | inertia_weight = 0.4 ) |
Configure parameters for soft collision avoidance algorithm.
These parameters control the cone-based gap detection algorithm that guides plant growth away from obstacles. Adjusting these values allows fine-tuning the balance between collision avoidance and natural growth patterns.
view_half_angle_deg | Half-angle of detection cone in degrees (0-180). Default 80° provides wide field of view. |
look_ahead_distance | Distance to look ahead for collisions in meters. Larger values detect distant obstacles. Default 0.1m. |
sample_count | Number of ray samples within cone. More samples improve accuracy but reduce performance. Default 256. |
inertia_weight | Weight for previous growth direction (0-1). Higher values make growth smoother but less responsive. Default 0.4. |
ValueError | If parameters are outside valid ranges |
PlantArchitectureError | If parameter setting fails |
Examples
Definition at line 587 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.setStaticObstacles | ( | self, | |
List[int] | target_UUIDs ) |
Mark geometry as static obstacles for collision detection optimization.
This method tells the collision detection system that certain geometry will not move during the simulation. The system can then build an optimized Bounding Volume Hierarchy (BVH) for these obstacles, significantly improving collision detection performance in scenes with many static obstacles.
target_UUIDs | List of primitive UUIDs representing static obstacles |
ValueError | If target_UUIDs is empty |
PlantArchitectureError | If static obstacle configuration fails |
Examples
Definition at line 747 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.writePlantMeshVertices | ( | self, | |
int | plant_id, | ||
Union[str, Path] | filename ) |
Write all plant mesh vertices to file for external processing.
This method exports all vertex coordinates (x,y,z) for every primitive in the plant, writing one vertex per line. Useful for external processing such as computing bounding volumes, convex hulls, or performing custom geometric analysis.
plant_id | ID of the plant instance to export |
filename | Path to output file (absolute or relative to current working directory) |
ValueError | If plant_id is negative or filename is empty |
PlantArchitectureError | If plant doesn't exist or file cannot be written |
Examples
Definition at line 822 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.writePlantStructureXML | ( | self, | |
int | plant_id, | ||
Union[str, Path] | filename ) |
Save plant structure to XML file for later loading.
This method exports the complete plant architecture to an XML file, including all shoots, phytomers, organs, and their properties. The saved plant can be reloaded later using readPlantStructureXML().
plant_id | ID of the plant instance to save |
filename | Path to output XML file (absolute or relative to current working directory) |
ValueError | If plant_id is negative or filename is empty |
PlantArchitectureError | If plant doesn't exist or file cannot be written |
Examples
Definition at line 871 of file PlantArchitecture.py.
None pyhelios.PlantArchitecture.PlantArchitecture.writeQSMCylinderFile | ( | self, | |
int | plant_id, | ||
Union[str, Path] | filename ) |
Export plant structure in TreeQSM cylinder format.
This method writes the plant structure as a series of cylinders following the TreeQSM format (Raumonen et al., 2013). Each row represents one cylinder with columns for radius, length, start position, axis direction, branch topology, and other structural properties. Useful for biomechanical analysis and quantitative structure modeling.
plant_id | ID of the plant instance to export |
filename | Path to output file (absolute or relative, typically .txt extension) |
ValueError | If plant_id is negative or filename is empty |
PlantArchitectureError | If plant doesn't exist or file cannot be written |
Examples
Definition at line 928 of file PlantArchitecture.py.
|
protected |
Definition at line 220 of file PlantArchitecture.py.
pyhelios.PlantArchitecture.PlantArchitecture.context = context |
Definition at line 219 of file PlantArchitecture.py.