0.1.39
Loading...
Searching...
No Matches
pyhelios.WeberPennTree.WeberPennTree Class Reference

Detailed Description

Definition at line 314 of file WeberPennTree.py.

Public Member Functions

 __init__ (self, Context context)
 
 __enter__ (self)
 
 __exit__ (self, exc_type, exc_value, traceback)
 
 __del__ (self)
 Destructor to ensure C++ resources freed even without 'with' statement.
 
 getNativePtr (self)
 
int buildTree (self, wpt_type, vec3 origin=vec3(0, 0, 0), float scale=1)
 Build a tree using either a built-in tree type or custom species name.
 
List[int] getTrunkUUIDs (self, int tree_id)
 
List[int] getBranchUUIDs (self, int tree_id)
 
List[int] getLeafUUIDs (self, int tree_id)
 
List[int] getAllUUIDs (self, int tree_id)
 
None setBranchRecursionLevel (self, int level)
 
None setTrunkSegmentResolution (self, int trunk_segs)
 
None setBranchSegmentResolution (self, int branch_segs)
 
None setLeafSubdivisions (self, int leaf_segs_x, int leaf_segs_y)
 
None loadXML (self, str filename, bool silent=False)
 Load custom tree species from XML file.
 
WeberPennTreeParameters getTreeParameters (self, Union[WPTType, str] tree_name)
 Get the architectural parameters of a tree in the library.
 
None setTreeParameters (self, Union[WPTType, str] tree_name, WeberPennTreeParameters parameters)
 Set the architectural parameters of a tree in the library.
 
None seedRandomGenerator (self, int seed)
 Seed the WeberPennTree random number generator to make tree geometry reproducible.
 

Public Attributes

 context = context
 
 wpt
 

Static Public Attributes

 WPTType = WPTType
 

Protected Member Functions

 _check_context_alive (self)
 Raise if the owning Context has been destroyed (see Context.check_context_alive).
 

Static Protected Member Functions

str _tree_name (Union[WPTType, str] tree_name, str method)
 

Protected Attributes

 _plugin_registry = get_plugin_registry()
 

Constructor & Destructor Documentation

◆ __init__()

pyhelios.WeberPennTree.WeberPennTree.__init__ ( self,
Context context )

Definition at line 317 of file WeberPennTree.py.

◆ __del__()

pyhelios.WeberPennTree.WeberPennTree.__del__ ( self)

Destructor to ensure C++ resources freed even without 'with' statement.

Definition at line 383 of file WeberPennTree.py.

Member Function Documentation

◆ __enter__()

pyhelios.WeberPennTree.WeberPennTree.__enter__ ( self)

Definition at line 372 of file WeberPennTree.py.

◆ __exit__()

pyhelios.WeberPennTree.WeberPennTree.__exit__ ( self,
exc_type,
exc_value,
traceback )

Definition at line 375 of file WeberPennTree.py.

◆ _check_context_alive()

pyhelios.WeberPennTree.WeberPennTree._check_context_alive ( self)
protected

Raise if the owning Context has been destroyed (see Context.check_context_alive).

Definition at line 369 of file WeberPennTree.py.

◆ _tree_name()

str pyhelios.WeberPennTree.WeberPennTree._tree_name ( Union[WPTType, str] tree_name,
str method )
staticprotected

Definition at line 535 of file WeberPennTree.py.

◆ buildTree()

int pyhelios.WeberPennTree.WeberPennTree.buildTree ( self,
wpt_type,
vec3 origin = vec3(0, 0, 0),
float scale = 1 )

Build a tree using either a built-in tree type or custom species name.

Parameters
wpt_typeEither WPTType enum for built-in types, or string for custom species loaded via loadXML()
originTree origin position (default: vec3(0, 0, 0))
scaleTree scale factor (default: 1.0)
Returns
Tree ID for querying tree components

Definition at line 407 of file WeberPennTree.py.

◆ getAllUUIDs()

List[int] pyhelios.WeberPennTree.WeberPennTree.getAllUUIDs ( self,
int tree_id )

Definition at line 459 of file WeberPennTree.py.

◆ getBranchUUIDs()

List[int] pyhelios.WeberPennTree.WeberPennTree.getBranchUUIDs ( self,
int tree_id )

Definition at line 445 of file WeberPennTree.py.

◆ getLeafUUIDs()

List[int] pyhelios.WeberPennTree.WeberPennTree.getLeafUUIDs ( self,
int tree_id )

Definition at line 452 of file WeberPennTree.py.

◆ getNativePtr()

pyhelios.WeberPennTree.WeberPennTree.getNativePtr ( self)

Definition at line 392 of file WeberPennTree.py.

◆ getTreeParameters()

WeberPennTreeParameters pyhelios.WeberPennTree.WeberPennTree.getTreeParameters ( self,
Union[WPTType, str] tree_name )

Get the architectural parameters of a tree in the library.

Parameters
tree_nameWPTType for a built-in species, or the name of a species loaded with loadXML() or defined with setTreeParameters().
Returns
WeberPennTreeParameters with every field of the C++ struct.
Exceptions
ValueErrorIf tree_name is not a WPTType or non-empty string.
HeliosRuntimeErrorIf no tree with that name exists in the library.

Definition at line 560 of file WeberPennTree.py.

◆ getTrunkUUIDs()

List[int] pyhelios.WeberPennTree.WeberPennTree.getTrunkUUIDs ( self,
int tree_id )

Definition at line 438 of file WeberPennTree.py.

◆ loadXML()

None pyhelios.WeberPennTree.WeberPennTree.loadXML ( self,
str filename,
bool silent = False )

Load custom tree species from XML file.

   Loads tree species definitions from an XML file into the WeberPennTree library.
   After loading, trees can be built using buildTree() with the custom species names
   defined in the XML file.
Parameters
filenamePath to XML file containing tree species definitions. Can be absolute or relative to current working directory.
silentIf True, suppress console output during loading. Default False.
Exceptions
ValueErrorIf filename is invalid or empty
FileNotFoundErrorIf XML file does not exist
HeliosRuntimeErrorIf XML file is malformed or cannot be parsed
Example
>>> wpt = WeberPennTree(context) >>> wpt.loadXML("my_custom_trees.xml") >>> tree_id = wpt.buildTree("CustomOak") # Use custom species name
Note
XML file must follow WeberPennTree XML schema. See "Creating Custom XML Files" in the WeberPennTree plugin documentation for the format.

Definition at line 520 of file WeberPennTree.py.

◆ seedRandomGenerator()

None pyhelios.WeberPennTree.WeberPennTree.seedRandomGenerator ( self,
int seed )

Seed the WeberPennTree random number generator to make tree geometry reproducible.

   WeberPennTree has its own generator, independent of Context.seedRandomGenerator(); seeding
   the Context does not make trees repeatable. The generator advances with each buildTree() call,
   so re-seed before each build that should be reproduced.
Parameters
seedNon-negative integer below 2**32.
Exceptions
ValueErrorIf seed is not an int in [0, 2**32).

Definition at line 608 of file WeberPennTree.py.

◆ setBranchRecursionLevel()

None pyhelios.WeberPennTree.WeberPennTree.setBranchRecursionLevel ( self,
int level )

Definition at line 466 of file WeberPennTree.py.

◆ setBranchSegmentResolution()

None pyhelios.WeberPennTree.WeberPennTree.setBranchSegmentResolution ( self,
int branch_segs )

Definition at line 480 of file WeberPennTree.py.

◆ setLeafSubdivisions()

None pyhelios.WeberPennTree.WeberPennTree.setLeafSubdivisions ( self,
int leaf_segs_x,
int leaf_segs_y )

Definition at line 487 of file WeberPennTree.py.

◆ setTreeParameters()

None pyhelios.WeberPennTree.WeberPennTree.setTreeParameters ( self,
Union[WPTType, str] tree_name,
WeberPennTreeParameters parameters )

Set the architectural parameters of a tree in the library.

   If ``tree_name`` is not yet in the library, a new species with that name is added, and
   ``buildTree(tree_name)`` will then build it. Parameters are validated in Python (types, Levels
   range, per-level array lengths) and again natively (e.g. Scale > 0, nCurveRes >= 1,
   0 <= BaseSize < 1); an invalid set leaves the library unchanged.
Parameters
tree_nameWPTType or species name.
parametersWeberPennTreeParameters, typically obtained from getTreeParameters() and modified.
Exceptions
ValueErrorIf tree_name or parameters are invalid.
HeliosRuntimeErrorIf the native validation rejects the parameters.

Definition at line 583 of file WeberPennTree.py.

◆ setTrunkSegmentResolution()

None pyhelios.WeberPennTree.WeberPennTree.setTrunkSegmentResolution ( self,
int trunk_segs )

Definition at line 473 of file WeberPennTree.py.

Member Data Documentation

◆ _plugin_registry

pyhelios.WeberPennTree.WeberPennTree._plugin_registry = get_plugin_registry()
protected

Definition at line 319 of file WeberPennTree.py.

◆ context

pyhelios.WeberPennTree.WeberPennTree.context = context

Definition at line 318 of file WeberPennTree.py.

◆ wpt

pyhelios.WeberPennTree.WeberPennTree.wpt
Initial value:
= wpt_wrapper.createWeberPennTreeWithBuildPluginRootDirectory(
context.getNativePtr(), str(build_dir)
)

Definition at line 360 of file WeberPennTree.py.

◆ WPTType

pyhelios.WeberPennTree.WeberPennTree.WPTType = WPTType
static

Definition at line 315 of file WeberPennTree.py.


The documentation for this class was generated from the following file: