Skip to content

Commit

Permalink
[1.3.19] 2024-09-20
Browse files Browse the repository at this point in the history
**Changed to c++17 standard**

*Context*
- Added capability of manually setting triangle vertices (see Context::setTriangleVertices()).
- OBJ writer checks if output directory exists, and if not it creates it (and if it can't create it an error is thrown).
- OBJ writer automatically copies all model texture files to the output directory.
- Specular material property in OBJ output models was not being set when there is a texture.
- Added version of Context::addTubeObject() that allows for explicit specification of texture mapping coordinates.
- Added method to append a segment to an existing tube object (see Context::appendTubeSegment()).
- Added methods to scale tube objects in the radial and axial directions (see Context::scaleTubeGirth() and Context::scaleTubeLength()).
- Added decrement (-=) operator for vec2, vec3, vec4, int2, int3, and int4 vector types.
- Added inequality (!-) operator for int2, int3, and int4 vector types.
- Added unary minus (multiply by -1) operator for vec2, vec3, vec4, int2, int3, and int4 vector types.
- A memory leak was fixed in helios::getImageResolutionJPEG() that would occur when JPEG image textures are used.

*Plant Architecture*
* Many significant updates to the plant architecture model. Some parameter names have changed.
- Shoots are now made up of tube objects rather than cone segments.
- Shoot tubes can be textured.
- Peduncle tube color can be explicitly specified.
- Context geometry is not updated until the end of the specified timestep (i.e., the argument of PlantArchitecture::advanceTime()). For example, if advanceTime() is given a timestep of 50 days, the Context geometry will only be updated at the end of 50 days. This makes the model run much faster.
- Library models added for lettuce and wheat.

*Photosynthesis*
*Credit to Kyle Rizzo for these updates
- Temperature response functions have been overhauled in the photosynthesis model. Users have the option to select from several different types of temperature response functions.
- Users can now choose between a rectangular hyperbolic or non-rectangular hyperbolic J light response function.
- Added a photosynthesis model (FvCB) parameter library for a range of species.
- Added helper functions to assist setting the parameters for the temperature response functions.

*Visualizer*
- A memory leak was fixed in Visualizer::addTextboxByCenter due to freetype library not being properly cleaned up.

*Radiation*
- Reflected and transmitted diffuse radiation flux values were not correct. They were not being properly scaled by the ambient diffuse flux.

*Stomatal Conductance*
*Credit to Kyle Rizzo for these updates
- Added a stomatal conductance model (BMF) parameter library for a range of species.

Co-authored-by: ktrizzo <[email protected]>
  • Loading branch information
bnbailey-psl and ktrizzo committed Sep 20, 2024
1 parent 7870796 commit 70f25f3
Show file tree
Hide file tree
Showing 892 changed files with 86,718 additions and 55,850 deletions.
2 changes: 1 addition & 1 deletion core/CMake_project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if ( WIN32 )
else()
SET(CMAKE_C_COMPILER_ID "GNU")
SET(CMAKE_CXX_COMPILER_ID "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
if( CMAKE_BUILD_TYPE STREQUAL Debug )
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
Expand Down
187 changes: 163 additions & 24 deletions core/include/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,12 @@ class Sphere : public CompoundObject {
};

//! Tube compound object class
class Tube: public CompoundObject {
class Tube : public CompoundObject {
public:

//! Default constructor
Tube(uint a_OID, const std::vector<uint> &a_UUIDs, const std::vector<vec3> &a_nodes, const std::vector<float> &a_radius, const std::vector<helios::RGBcolor> &a_colors, uint a_subdiv, const char *a_texturefile, helios::Context *a_context);
Tube(uint a_OID, const std::vector<uint> &a_UUIDs, const std::vector<vec3> &a_nodes, const std::vector<float> &a_radius, const std::vector<helios::RGBcolor> &a_colors, const std::vector<std::vector<helios::vec3>> &a_triangle_vertices,
uint a_subdiv, const char *a_texturefile, helios::Context *a_context);

//! Tube destructor
~Tube() override = default;
Expand All @@ -674,29 +675,82 @@ class Tube: public CompoundObject {

//! Get the colors at each of the tube object nodes
std::vector<helios::RGBcolor> getNodeColors() const;

//! Get positions of triangle vertices comprising the tube object
std::vector<std::vector<helios::vec3>> getTriangleVertices() const;

//! Get the number of sub-triangle divisions of the tube object
uint getSubdivisionCount() const;

//! Set the number of sphere tesselation divisions
/**
* \param[in] subdiv Number of subdivisions in zenithal and azimuthal directions.
*/
void setSubdivisionCount( uint subdiv );

//! Get the length of the tube object
float getLength() const;

//! Get the volume of the tube object
float getVolume() const;


//! Get the volume of a segment within the tube object
/**
* \param[in] segment_index Index of the tube segment
*/
float getSegmentVolume( uint segment_index ) const;

//! Append an additional segment to the existing tube object
/**
* \param[in] node_position Cartesian coordinates of the new tube segment node
* \param[in] node_radius Radius of the new tube segment node
* \param[in] node_color Color of the new tube segment node
*/
void appendTubeSegment( const helios::vec3 &node_position, float node_radius, const helios::RGBcolor &node_color );

//! Append an additional segment to the existing tube object
/**
* \param[in] node_position Cartesian coordinates of the new tube segment node
* \param[in] node_radius Radius of the new tube segment node
* \param[in] texturefile Name of image file for texture map
* \param[in] textureuv_ufrac Fractional u-coordinate of texture map at the beginning (.x) and end (.y) of the segment
*/
void appendTubeSegment( const helios::vec3 &node_position, float node_radius, const char* texturefile, const helios::vec2 &textureuv_ufrac );

//! Scale the girth of the tube object
/**
* \param[in] S Scaling factor
*/
void scaleTubeGirth( float S);

//! Set tube radii at each segment node
/**
* \param[in] node_radii Vector of radii at each tube segment node
*/
void setTubeRadii( const std::vector<float> &node_radii );

//! Scale the length of the tube object
/**
* \param[in] S Scaling factor
*/
void scaleTubeLength( float S );

//! Set tube vertex coordinates at each segment node
/**
* \param[in] node_xyz Vector of Cartesian coordinates at each tube segment node
*/
void setTubeNodes( const std::vector<helios::vec3> &node_xyz );

protected:

std::vector<helios::vec3> nodes;


std::vector<std::vector<helios::vec3>> triangle_vertices; //first index is the tube segment ring, second index is vertex within segment ring, third index is the vertex within triangle

std::vector<float> radius;

std::vector<helios::RGBcolor> colors;

uint subdiv;

void updateTriangleVertices();



friend class CompoundObject;

};
Expand Down Expand Up @@ -790,7 +844,7 @@ class Polymesh : public CompoundObject {
};

//! Cone compound object class
class Cone: public CompoundObject {
class Cone : public CompoundObject {
public:

//! Default constructor
Expand Down Expand Up @@ -1535,6 +1589,14 @@ class Triangle : public Primitive{

//! Calculate the fraction of the Triangle surface area that is solid (non-transparent)
void calculateSolidFraction( const std::map<std::string,Texture> &textures ) override;

//! Manually set the Triangle vertices
/**
* \param[in] vertex0 Cartesian coordinate of triangle vertex 0.
* \param[in] vertex1 Cartesian coordinate of triangle vertex 1.
* \param[in] vertex2 Cartesian coordinate of triangle vertex 2.
*/
void setVertices(const helios::vec3& vertex0, const helios::vec3& vertex1, const helios::vec3& vertex2 );

private:

Expand Down Expand Up @@ -1938,7 +2000,6 @@ class Context{
std::map<std::string, GlobalData> globaldata;

//---------- CONTEXT PRIVATE MEMBER VARIABLES ---------//
//NOTE: variables are initialized and documented in initializeContext() member method

//! Simulation date (Date vector)
/**
Expand Down Expand Up @@ -2394,7 +2455,16 @@ class Context{
* \note If the UUID passed to this method does not correspond to a Triangle, an error will be thrown.
*/
helios::vec3 getTriangleVertex( uint UUID, uint number ) const;


//! //! Manually set the Triangle vertices
/**
* \param[in] UUID Unique universal identifier for Triangle.
* \param[in] vertex0 Cartesian (x,y,z) coordinate of vertex 0
* \param[in] vertex1 Cartesian (x,y,z) coordinate of vertex 1
* \param[in] vertex2 Cartesian (x,y,z) coordinate of vertex 2
*/
void setTriangleVertices( uint UUID, const helios::vec3& vertex0, const helios::vec3& vertex1, const helios::vec3& vertex2 );

//! Get the Cartesian (x,y,z) center position of a voxel element
/**
* \param[in] UUID Unique universal identifier for voxel.
Expand Down Expand Up @@ -4666,7 +4736,61 @@ class Context{
* \param[in] ObjID object ID of the Tube object
*/
float getTubeObjectVolume( uint ObjID ) const;


//! get the volume of a segment within a Tube object
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] segment_index Index of the segment within the Tube object
*/
float getTubeObjectSegmentVolume( uint ObjID, uint segment_index ) const;

//! Append a tube segment to an existing tube object
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] node_position Cartesian coordinates of the node
* \param[in] radius Radius of the tube segment
* \param[in] color RGB color of the tube segment
*/
void appendTubeSegment(uint ObjID, const helios::vec3 &node_position, float radius, const RGBcolor &color );

//! Append an additional segment to the existing tube object
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] node_position Cartesian coordinates of the new tube segment node
* \param[in] node_radius Radius of the new tube segment node
* \param[in] texturefile Name of image file for texture map
* \param[in] textureuv_ufrac Fractional u-coordinate of texture map at the beginning (.x) and end (.y) of the segment
*/
void appendTubeSegment( uint ObjID, const helios::vec3 &node_position, float node_radius, const char* texturefile, const helios::vec2 &textureuv_ufrac );

//! Scale the girth for all nodes of a tube object
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] scale_factor Scaling factor to apply to the girth of the tube object
*/
void scaleTubeGirth( uint ObjID, float scale_factor );

//! Set tube radii at each segment node
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] node_radii Vector of radii at each tube segment node
*/
void setTubeRadii( uint ObjID, const std::vector<float> &node_radii );

//! Scale the length of a tube object by an arbitrary factor for all tube nodes
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] scale_factor Scaling factor to apply to the length of the tube object
*/
void scaleTubeLength( uint ObjID, float scale_factor );

//! Set tube vertex coordinates at each segment node
/**
* \param[in] ObjID object ID of the Tube object
* \param[in] node_xyz Vector of Cartesian coordinates at each tube segment node
*/
void setTubeNodes( uint ObjID, const std::vector<helios::vec3> &node_xyz );

//! Get a pointer to a Box Compound Object
/**
* \param[in] ObjID Identifier for Box Compound Object.
Expand Down Expand Up @@ -4893,38 +5017,53 @@ class Context{
//! Add a 3D tube compound object to the Context
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \image html doc/images/Tube.png "Sample image of a Tube compound object." width=0.1cm
* \param[in] Ndivs Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \return Object ID of new tube object.
* \note Ndivs must be greater than 2.
* \ingroup compoundobjects
*/
uint addTubeObject(uint Ndivs, const std::vector<vec3> &nodes, const std::vector<float> &radius );
uint addTubeObject(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius );

//! Add a 3D tube compound object to the Context and specify its diffuse color
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \param[in] Ndivs Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \param[in] color Diffuse color of each tube segment.
* \return Object ID of new tube object.
* \note Ndivs must be greater than 2.
* \ingroup compoundobjects
*/
uint addTubeObject( uint Ndivs, const std::vector<vec3> &nodes, const std::vector<float> &radius, const std::vector<RGBcolor> &color );
uint addTubeObject(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius, const std::vector<RGBcolor> &color );

//! Add a 3D tube compound object to the Context that is texture-mapped. Texture is mapped to span the entire tube.
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \param[in] texturefile Name of image file for texture map
* \return Object ID of new tube object.
* \note Ndivs must be greater than 2.
* \note The tube is textured such that the x/u direction of the image runs longitudinally along the tube.
* \ingroup compoundobjects
*/
uint addTubeObject(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius, const char* texturefile );

//! Add a 3D tube compound object to the Context that is texture-mapped
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \param[in] Ndivs Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \param[in] texturefile Name of image file for texture map
* \param[in] textureuv_ufrac Vector of texture coordinates (u/longitudinal-direction) for each node position.
* \return Object ID of new tube object.
* \note Ndivs must be greater than 2.
* \note The tube is textured such that the x/u direction of the image runs longitudinally along the tube.
* \ingroup compoundobjects
*/
uint addTubeObject( uint Ndivs, const std::vector<vec3> &nodes, const std::vector<float> &radius, const char* texturefile );
uint addTubeObject(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius, const char* texturefile, const std::vector<float> &textureuv_vfrac );

//! Add a rectangular prism tessellated with Patch primitives
/**
Expand Down Expand Up @@ -5218,27 +5357,27 @@ class Context{

//! Add a 3D tube compound object to the Context and specify its diffuse color
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \param[in] Ndivs Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \param[in] color Diffuse color of each tube segment.
* \return Vector of UUIDs for each sub-triangle
* \note Ndivs must be greater than 2.
* \ingroup compoundobjects
*/
std::vector<uint> addTube(uint Ndivs, const std::vector<vec3> &nodes, const std::vector<float> &radius, const std::vector<RGBcolor> &color );
std::vector<uint> addTube(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius, const std::vector<RGBcolor> &color );

//! Add a 3D tube compound object to the Context that is texture-mapped
/** A `tube' or `snake' compound object comprised of Triangle primitives
* \param[in] Ndivs Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] radial_subdivisions Number of radial divisions of the Tube. E.g., Ndivs = 3 would be a triangular prism, Ndivs = 4 would be a rectangular prism, etc.
* \param[in] nodes Vector of (x,y,z) positions defining Tube segments.
* \param[in] radius Radius of the tube at each node position.
* \param[in] texturefile Name of image file for texture map
* \return Vector of UUIDs for each sub-triangle
* \note Ndivs must be greater than 2.
* \ingroup compoundobjects
*/
std::vector<uint> addTube(uint Ndivs, const std::vector<vec3> &nodes, const std::vector<float> &radius, const char* texturefile );
std::vector<uint> addTube(uint radial_subdivisions, const std::vector<vec3> &nodes, const std::vector<float> &radius, const char* texturefile );

//! Add a rectangular prism tessellated with Patch primitives
/**
Expand Down
1 change: 1 addition & 0 deletions core/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <chrono>
#include <thread>
#include <iomanip>
#include <filesystem>

typedef unsigned int uint;

Expand Down
Loading

0 comments on commit 70f25f3

Please sign in to comment.