Skip to content

Commit

Permalink
[1.3.12] 2024-06-03
Browse files Browse the repository at this point in the history
*utilities/create_project.sh script*
- syntheticannotation plug-in was missing from this script, which also caused run_samples.sh to fail to run its self-test.

*Context*
- Added Context::cleanDeletedUUIDs() to delete UUIDs from a vector when the corresponding primitive does not exist. This is useful, for example, to update UUID vectors when deleting some primitives, such as after calling cropDomain().
- Added fix for edge case in getFileExtension() to consider case where the filename starts with a '.' and had no extension.
- Performance improvements when adding geometry with textures. Existence of the texture file is now only checked when a new texture is added.
- Performance improvements when loading geometry with textures from XML file. The solid fraction is not re-calculated if it was previously written to the XML file being read.

*Radiation*
- In-place version of RadiationModel::scaleSpectrum() was not actually added in the last commit.
- Added a check to make sure that the radiation camera position and 'lookat' coordinates are not the same.
- Added a check in RadiationModel::writeNormCameraImage() to throw an error if the camera data does not exist. This check was there for RadiationModel::writeCameraImage(), but was missing in RadiationModel::writeNormCameraImage() which could cause an uncaught error.
- Added support for periodic boundary conditions with depth images.
- Changed previous version of RadiationModel::writeDepthImage() to RadiationModel::writeDepthImageData() (writes ASCII files with depth image data).
- Added new RadiationModel::writeDepthImage(), which writes a JPEG version of (normalized) depth images.
- Removed previously deprecated version of RadiationModel::addRadiationCamera(). Use versions that take a CameraProperties struct instead.
- Behavior of twosided_flag = 0 was changed for direct sources. Previously, primitives could receive direct radiation from the back side when twosided_flag = 0, but now they cannot.
- twosided_flag = 2 was not implemented correctly and was not working in most cases.
- Added case for twosided_flag = 3 to make the primitive completely invisible to any radiation.
- Added ability to visualize radiation sources by adding their geometry to the Context. See RadiationModel::enableLightModelVisualization().
- Added ability to visualize radiation cameras by adding their geometry to the Context. See RadiationModel::enableCameraModelVisualization().
  • Loading branch information
bnbailey-psl committed Jun 3, 2024
1 parent 7345c95 commit dcc0b5f
Show file tree
Hide file tree
Showing 655 changed files with 24,198 additions and 22,100 deletions.
18 changes: 18 additions & 0 deletions core/include/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,24 @@ class Context{

//!Get all primitive UUIDs currently in the Context
std::vector<uint> getAllUUIDs() const;

//! Delete UUIDs from vector if primitives no longer exist (1D vector)
/**
* \param[inout] UUIDs Vector of primitive UUIDs. UUIDs for primitives that do not exist will be deleted from the vector.
*/
void cleanDeletedUUIDs( std::vector<uint> &UUIDs ) const;

//! Delete UUIDs from vector if primitives no longer exist (2D vector)
/**
* \param[inout] UUIDs Vector of primitive UUIDs. UUIDs for primitives that do not exist will be deleted from the vector.
*/
void cleanDeletedUUIDs( std::vector<std::vector<uint>> &UUIDs ) const;

//! Delete UUIDs from vector if primitives no longer exist (3D vector)
/**
* \param[inout] UUIDs Vector of primitive UUIDs. UUIDs for primitives that do not exist will be deleted from the vector.
*/
void cleanDeletedUUIDs( std::vector<std::vector<std::vector<uint>>> &UUIDs ) const;

//-------- Primitive Data Methods ---------- //

Expand Down
92 changes: 45 additions & 47 deletions core/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ std::minstd_rand0* Context::getRandomGenerator(){

void Context::addTexture( const char* texture_file ){
if( textures.find(texture_file)==textures.end() ){//texture has not already been added

//texture must have type PNG or JPEG
std::string fn = texture_file;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addTexture): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texture_file) ){
helios_runtime_error("ERROR (Context::addTexture): Texture file " + std::string(texture_file) + " does not exist.");
}

Texture text( texture_file );
textures[ texture_file ] = text;
}
Expand Down Expand Up @@ -1189,15 +1199,6 @@ uint Context::addPatch( const vec3& center, const vec2& size, const SphericalCoo

uint Context::addPatch( const vec3& center, const vec2& size, const SphericalCoord& rotation, const char* texture_file ){

//texture must have type PNG or JPEG
std::string fn = texture_file;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addPatch): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texture_file) ){
helios_runtime_error("ERROR (Context::addPatch): Texture file " + std::string(texture_file) + " does not exist.");
}

addTexture( texture_file );

auto* patch_new = (new Patch( texture_file, textures.at(texture_file).getSolidFraction(), 0, currentUUID ));
Expand Down Expand Up @@ -1226,15 +1227,6 @@ uint Context::addPatch( const vec3& center, const vec2& size, const SphericalCoo

uint Context::addPatch( const vec3& center, const vec2& size, const SphericalCoord& rotation, const char* texture_file, const helios::vec2& uv_center, const helios::vec2& uv_size ){

//texture must have type PNG or JPEG
std::string fn = texture_file;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addPatch): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texture_file) ){
helios_runtime_error("ERROR (Context::addPatch): Texture file " + std::string(texture_file) + " does not exist.");
}

if( size.x==0 || size.y==0 ){
helios_runtime_error("ERROR (Context::addPatch): Size of patch must be greater than 0.");
}
Expand Down Expand Up @@ -1300,15 +1292,6 @@ uint Context::addTriangle( const vec3& vertex0, const vec3& vertex1, const vec3&

uint Context::addTriangle( const helios::vec3& vertex0, const helios::vec3& vertex1, const helios::vec3& vertex2, const char* texture_file, const helios::vec2& uv0, const helios::vec2& uv1, const helios::vec2& uv2 ){

//texture must have type PNG or JPEG
std::string fn = texture_file;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addTriangle): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texture_file) ){
helios_runtime_error("ERROR (Context::addTriangle): Texture file " + std::string(texture_file) + " does not exist.");
}

addTexture( texture_file );

std::vector<helios::vec2> uv;
Expand Down Expand Up @@ -1684,6 +1667,36 @@ std::vector<uint> Context::getAllUUIDs() const{
return UUIDs;
}

void Context::cleanDeletedUUIDs( std::vector<uint> &UUIDs ) const {
for (int i = UUIDs.size() - 1; i >= 0; i--) {
if (!doesPrimitiveExist(UUIDs.at(i))) {
UUIDs.erase(UUIDs.begin() + i);
}
}
}

void Context::cleanDeletedUUIDs( std::vector<std::vector<uint>> &UUIDs ) const{
for( int j=UUIDs.size()-1; j>=0; j-- ){
for( int i=UUIDs.at(j).size()-1; i>=0; i-- ){
if( !doesPrimitiveExist(UUIDs.at(j).at(i)) ){
UUIDs.at(j).erase( UUIDs.at(j).begin()+i );
}
}
}
}

void Context::cleanDeletedUUIDs( std::vector<std::vector<std::vector<uint>>> &UUIDs ) const{
for( int k=UUIDs.size()-1; k>=0; k-- ) {
for (int j = UUIDs.at(k).size() - 1; j >= 0; j--) {
for (int i = UUIDs.at(k).at(j).size() - 1; i >= 0; i--) {
if (!doesPrimitiveExist(UUIDs.at(k).at(j).at(i))) {
UUIDs.at(k).at(j).erase(UUIDs.at(k).at(j).begin() + i);
}
}
}
}
}

void Context::addTimeseriesData(const char* label, float value, const Date &date, const Time &time ){

//floating point value corresponding to date and time
Expand Down Expand Up @@ -3993,15 +4006,6 @@ uint Context::addTileObject(const vec3 &center, const vec2 &size, const Spherica

uint Context::addTileObject(const vec3 &center, const vec2 &size, const SphericalCoord &rotation, const int2 &subdiv, const char* texturefile ){

//texture must have type PNG or JPEG
std::string fn = texturefile;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addTileObject): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texturefile) ){
helios_runtime_error("ERROR (Context::addTileObject): Texture file " + std::string(texturefile) + " does not exist.");
}

if( size.x==0 || size.y==0 ){
helios_runtime_error("ERROR (addTileObject): Size of tile must be greater than 0.");
}
Expand Down Expand Up @@ -5253,15 +5257,6 @@ std::vector<uint> Context::addTile(const vec3 &center, const vec2 &size, const S

std::vector<uint> Context::addTile(const vec3 &center, const vec2 &size, const SphericalCoord &rotation, const int2 &subdiv, const char* texturefile ){

//texture must have type PNG or JPEG
std::string fn = texturefile;
std::string ext = getFileExtension(fn);
if( ext != ".png" && ext != ".PNG" && ext != ".jpg" && ext != ".jpeg" && ext != ".JPG" && ext != ".JPEG" ){
helios_runtime_error("ERROR (Context::addTile): Texture file " + fn + " is not PNG or JPEG format.");
}else if( !doesTextureFileExist(texturefile) ){
helios_runtime_error("ERROR (Context::addTile): Texture file " + std::string(texturefile) + " does not exist.");
}

std::vector<uint> UUID;

vec2 subsize;
Expand All @@ -5278,10 +5273,13 @@ std::vector<uint> Context::addTile(const vec3 &center, const vec2 &size, const S

addTexture( texturefile );
std::vector<std::vector<bool> > alpha;
int2 sz;
int2 sz = textures.at(texturefile).getSize();
if( textures.at(texturefile).hasTransparencyChannel() ){
alpha = *textures.at(texturefile).getTransparencyData();
sz = textures.at(texturefile).getSize();
}

if( subdiv.x>=sz.x || subdiv.y>=sz.y ){
helios_runtime_error("ERROR (Context::addTile): The resolution of the texture image '" + std::string(texturefile) + "' is lower than the number of tile subdivisions. Increase resolution of the texture image.");
}

for( uint j=0; j<subdiv.y; j++ ){
Expand Down
22 changes: 11 additions & 11 deletions core/src/Context_fileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ std::vector<uint> Context::loadXML( const char* filename, bool quiet ){
}

// * Patch Solid Fraction * //
float solid_fraction = 1;
float solid_fraction = -1;
if( XMLparser::parse_solid_fraction(p,solid_fraction)==2 ){
helios_runtime_error("ERROR (Context::loadXML): Solid fraction given in 'patch' block contains invalid data.");
}
Expand All @@ -1356,20 +1356,20 @@ std::vector<uint> Context::loadXML( const char* filename, bool quiet ){
}

// * Add the Patch * //
if( strcmp(texture_file.c_str(),"none")==0 ){
if( strcmp(texture_file.c_str(),"none")==0 ){ //no texture file was given
ID=addPatch( make_vec3(0,0,0), make_vec2(1,1), make_SphericalCoord(0,0), color );
}else{
}else{ //has a texture file
std::string texture_file_copy;
if( solid_fraction!=1.f ){
if( solid_fraction<1.f && solid_fraction>=0.f ){ //solid fraction was given in the XML, and is not equal to 1.0
texture_file_copy = texture_file;
texture_file = "lib/images/solid.jpg"; //load dummy solid texture
texture_file = "lib/images/solid.jpg"; //load dummy solid texture to avoid re-calculating the solid fraction
}
if( uv.empty() ){
if( uv.empty() ){ //custom (u,v) coordinates were not given
ID=addPatch( make_vec3(0,0,0), make_vec2(1,1), make_SphericalCoord(0,0), texture_file.c_str() );
}else{
ID=addPatch( make_vec3(0,0,0), make_vec2(1,1), make_SphericalCoord(0,0), texture_file.c_str(), 0.5*(uv.at(2)+uv.at(0)), uv.at(2)-uv.at(0) );
}
if( solid_fraction!=1.f ) {
if( solid_fraction<1.f && solid_fraction>=0.f ) { //replace dummy texture and set the solid fraction
getPrimitivePointer_private(ID)->setTextureFile(texture_file_copy.c_str());
addTexture(texture_file_copy.c_str());
getPrimitivePointer_private(ID)->setSolidFraction(solid_fraction);
Expand Down Expand Up @@ -1422,7 +1422,7 @@ std::vector<uint> Context::loadXML( const char* filename, bool quiet ){
}

// * Triangle Solid Fraction * //
float solid_fraction = 1;
float solid_fraction = -1;
if( XMLparser::parse_solid_fraction(tri,solid_fraction)==2 ){
helios_runtime_error("ERROR (Context::loadXML): Solid fraction given in 'triangle' block contains invalid data.");
}
Expand All @@ -1449,12 +1449,12 @@ std::vector<uint> Context::loadXML( const char* filename, bool quiet ){
ID = addTriangle( vert_pos.at(0), vert_pos.at(1), vert_pos.at(2), color );
}else{
std::string texture_file_copy;
if( solid_fraction!=1.f ){
if( solid_fraction<1.f && solid_fraction>=0.f ){ //solid fraction was given in the XML, and is not equal to 1.0
texture_file_copy = texture_file;
texture_file = "lib/images/solid.jpg"; //load dummy solid texture
texture_file = "lib/images/solid.jpg"; //load dummy solid texture to avoid re-calculating the solid fraction
}
ID = addTriangle( vert_pos.at(0), vert_pos.at(1), vert_pos.at(2), texture_file.c_str(), uv.at(0), uv.at(1), uv.at(2) );
if( solid_fraction!=1.f ) {
if( solid_fraction<1.f && solid_fraction>=0.f ) {
getPrimitivePointer_private(ID)->setTextureFile(texture_file_copy.c_str());
addTexture(texture_file_copy.c_str());
getPrimitivePointer_private(ID)->setSolidFraction(solid_fraction);
Expand Down
6 changes: 5 additions & 1 deletion core/src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2820,8 +2820,12 @@ std::string helios::getFileExtension( const std::string &filepath ){
return "";
}

//edge case when filepath starts with '.' and there is no file extension (e.g., './myfile')
if( filepath.find_last_of('.')==0 ){
ext = "";

//edge case when file is in a hidden directory AND there is no file extension (return empty string)
if( filepath.find_last_of('/')<filepath.size() && filepath.at(filepath.find_last_of('.')-1)=='/' ){
}else if( filepath.find_last_of('/')<filepath.size() && filepath.at(filepath.find_last_of('.')-1)=='/' ){
ext = "";
}

Expand Down
27 changes: 26 additions & 1 deletion doc/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -1639,4 +1639,29 @@ The radiation model has been re-designed, with the following primary additions:
- ColorCalibration::addColorboard() was changed to accept everything that is needed to fully define the colorboard. Accordingly, ColorCalibration::setColorboardReflectivity() was removed.
- Argument order of ColorCalibration::addDefaultColorboard() was changed to be consistent with ColorCalibration::addColorboard() and typical Helios convention.
- Added method to output optional primitive data (reflectivity and transmissivity values).
- Updated calibrated_CREE6500K_Basler-acA2500-20gc_spectral_response_[*] spectra in the camera library to be properly normalized.
- Updated calibrated_CREE6500K_Basler-acA2500-20gc_spectral_response_[*] spectra in the camera library to be properly normalized.

[1.3.12] 2024-06-03

*utilities/create_project.sh script*
- syntheticannotation plug-in was missing from this script, which also caused run_samples.sh to fail to run its self-test.

*Context*
- Added Context::cleanDeletedUUIDs() to delete UUIDs from a vector when the corresponding primitive does not exist. This is useful, for example, to update UUID vectors when deleting some primitives, such as after calling cropDomain().
- Added fix for edge case in getFileExtension() to consider case where the filename starts with a '.' and had no extension.
- Performance improvements when adding geometry with textures. Existence of the texture file is now only checked when a new texture is added.
- Performance improvements when loading geometry with textures from XML file. The solid fraction is not re-calculated if it was previously written to the XML file being read.

*Radiation*
- In-place version of RadiationModel::scaleSpectrum() was not actually added in the last commit.
- Added a check to make sure that the radiation camera position and 'lookat' coordinates are not the same.
- Added a check in RadiationModel::writeNormCameraImage() to throw an error if the camera data does not exist. This check was there for RadiationModel::writeCameraImage(), but was missing in RadiationModel::writeNormCameraImage() which could cause an uncaught error.
- Added support for periodic boundary conditions with depth images.
- Changed previous version of RadiationModel::writeDepthImage() to RadiationModel::writeDepthImageData() (writes ASCII files with depth image data).
- Added new RadiationModel::writeDepthImage(), which writes a JPEG version of (normalized) depth images.
- Removed previously deprecated version of RadiationModel::addRadiationCamera(). Use versions that take a CameraProperties struct instead.
- Behavior of twosided_flag = 0 was changed for direct sources. Previously, primitives could receive direct radiation from the back side when twosided_flag = 0, but now they cannot.
- twosided_flag = 2 was not implemented correctly and was not working in most cases.
- Added case for twosided_flag = 3 to make the primitive completely invisible to any radiation.
- Added ability to visualize radiation sources by adding their geometry to the Context. See RadiationModel::enableLightModelVisualization().
- Added ability to visualize radiation cameras by adding their geometry to the Context. See RadiationModel::enableCameraModelVisualization().
2 changes: 1 addition & 1 deletion doc/UserGuide.dox
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! \mainpage Helios Documentation v1.3.11
/*! \mainpage Helios Documentation v1.3.12

<p> <br> </p>

Expand Down
2 changes: 1 addition & 1 deletion doc/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="Helios_logo_small.png"/></td>
<td id="projectalign">
<div id="projectname"><span id="projectnumber">&#160;v1.3.11</span>
<div id="projectname"><span id="projectnumber">&#160;v1.3.12</span>
</div>
</td>
</tr>
Expand Down
Loading

0 comments on commit dcc0b5f

Please sign in to comment.