Skip to content

Commit

Permalink
Merge pull request #40 from KAHR-Alpha/feature/Selene-polynomial-surf…
Browse files Browse the repository at this point in the history
…aces-of-revolution

Feature/selene polynomial surfaces of revolution
  • Loading branch information
KAHR-Alpha authored Jul 24, 2024
2 parents 97a5057 + 03c71b8 commit 862a3f8
Show file tree
Hide file tree
Showing 25 changed files with 284 additions and 78 deletions.
2 changes: 1 addition & 1 deletion cmake_scripts/unit_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ create_test_sourcelist(Tests
${test_names})

add_executable(UnitTests UnitTests.cpp ${cpp_tests} ${test_scripts})
target_link_libraries(UnitTests lua_interface)
target_link_libraries(UnitTests lua_interface selene_core)
target_link_libraries(UnitTests ${LUA_LIBRARIES})

foreach(test ${test_names})
Expand Down
1 change: 1 addition & 0 deletions contribs/build_vs2022/setup_vs_studio_debug.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cmake -B "cmake_build_VS" -G "Visual Studio 17 2022" `
-DTASK="Build CLI+GUI" `
-DINSTALL_PATH="${build_path}/Aether" `
-DDEVTESTS=1 `
-DEigen3_DIR="${build_path}/eigen/include/eigen3" `
-DFFTW_INCLUDES="${build_path}/fftw" `
-DFFTW_LIB="${build_path}/fftw/libfftw3-3.lib" `
-DLUA_LIBRARY="${build_path}/lua/lib/lua.lib" `
Expand Down
6 changes: 1 addition & 5 deletions src/GUI/Selene/gui_selene_gl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*Copyright 2008-2022 - Loïc Le Cunff
/*Copyright 2008-2024 - Loïc Le Cunff
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,6 @@ limitations under the License.*/
#include <gui_selene_gl.h>
#include <selene.h>

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace SelGUI
{

Expand Down
1 change: 1 addition & 0 deletions src/Selene/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(selene_src sel_analysis.cpp
primitives/sel_obj_lens.cpp
primitives/sel_obj_mesh.cpp
primitives/sel_obj_parabola.cpp
primitives/sel_obj_polynomial.cpp
primitives/sel_obj_rectangle.cpp
primitives/sel_obj_sphere.cpp
primitives/sel_obj_spherical_patch.cpp)
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//#########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_cone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_conic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//###########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##############
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_lens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##########
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_parabola.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//##############
Expand Down
208 changes: 208 additions & 0 deletions src/Selene/primitives/sel_obj_polynomial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/*Copyright 2008-2024 - Loïc Le Cunff
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/

#include <selene.h>
#include <selene_primitives.h>

extern std::ofstream plog;

namespace Sel::Primitives
{
//#################
// Polynormial
//#################

Polynomial::Polynomial(BoundingBox &bbox_,
std::vector<Sel::SelFace> &F_arr_,
std::vector<std::string> &face_name_arr_)
:Primitive(bbox_, F_arr_, face_name_arr_),
inner_radius(0),
outer_radius(50e-3),
coeffs(1, 1),
effective_coeffs(coeffs),
normalized(true)
{
}


Vector3 Polynomial::anchor(int anchor) const
{
return Vector3(0);
}


std::string Polynomial::anchor_name(int anchor) const
{
return "Center";
}


void Polynomial::default_N_uv(int &Nu,int &Nv,int face_) const
{
Nu=Nv=64;
}


double Polynomial::eval(double x) const
{
double r=0;

for(double const &c : effective_coeffs)
{
r=x*(c+r);
}

return r;
}


void Polynomial::finalize()
{
/*int NFc=6;
F_arr.resize(NFc);
bbox.xm=-lx/2.0;
bbox.xp=+lx/2.0;
bbox.ym=-ly/2.0;
bbox.yp=+ly/2.0;
bbox.zm=-lz/2.0;
bbox.zp=+lz/2.0;
face_name_arr.resize(NFc);
face_name_arr[0]="Face XM";
face_name_arr[1]="Face XP";
face_name_arr[2]="Face YM";
face_name_arr[3]="Face YP";
face_name_arr[4]="Face ZM";
face_name_arr[5]="Face ZP";*/
}


void Polynomial::intersect(std::vector<RayInter> &interlist, SelRay const &ray, int obj_ID, int face_last_intersect, bool first_forward) const
{
/*std::array<double,6> hits;
std::array<int,6> face_labels={0,1,2,3,4,5};
double &t_x1=hits[0],&t_x2=hits[1];
double &t_y1=hits[2],&t_y2=hits[3];
double &t_z1=hits[4],&t_z2=hits[5];
t_x1=(-lx/2.0-ray.start.x)*ray.inv_dir.x;
t_x2=(+lx/2.0-ray.start.x)*ray.inv_dir.x;
t_y1=(-ly/2.0-ray.start.y)*ray.inv_dir.y;
t_y2=(+ly/2.0-ray.start.y)*ray.inv_dir.y;
t_z1=(-lz/2.0-ray.start.z)*ray.inv_dir.z;
t_z2=(+lz/2.0-ray.start.z)*ray.inv_dir.z;
Vector3 V;
V=ray.start+t_x1*ray.dir;
if(V.y>ly/2.0 || V.y<-ly/2.0 ||
V.z>lz/2.0 || V.z<-lz/2.0) t_x1=-1;
V=ray.start+t_x2*ray.dir;
if(V.y>ly/2.0 || V.y<-ly/2.0 ||
V.z>lz/2.0 || V.z<-lz/2.0) t_x2=-1;
V=ray.start+t_y1*ray.dir;
if(V.x>lx/2.0 || V.x<-lx/2.0 ||
V.z>lz/2.0 || V.z<-lz/2.0) t_y1=-1;
V=ray.start+t_y2*ray.dir;
if(V.x>lx/2.0 || V.x<-lx/2.0 ||
V.z>lz/2.0 || V.z<-lz/2.0) t_y2=-1;
V=ray.start+t_z1*ray.dir;
if(V.x>lx/2.0 || V.x<-lx/2.0 ||
V.y>ly/2.0 || V.y<-ly/2.0) t_z1=-1;
V=ray.start+t_z2*ray.dir;
if(V.x>lx/2.0 || V.x<-lx/2.0 ||
V.y>ly/2.0 || V.y<-ly/2.0) t_z2=-1;
if(first_forward)
push_first_forward(interlist,ray,obj_ID,hits,face_labels);
else
push_full_forward(interlist,ray,obj_ID,hits,face_labels);*/
}


void Polynomial::map_variables(std::map<std::string,double*> &variables_map)
{
/*variables_map["box_length_x"]=&lx;
variables_map["box_length_y"]=&ly;
variables_map["box_length_z"]=&lz;*/
}


Vector3 Polynomial::normal(RayInter const &inter) const
{
Vector3 Fnorm;
/*int const &face_inter=inter.face;
if(face_inter==0) Fnorm=-unit_vec_x;
else if(face_inter==1) Fnorm= unit_vec_x;
else if(face_inter==2) Fnorm=-unit_vec_y;
else if(face_inter==3) Fnorm= unit_vec_y;
else if(face_inter==4) Fnorm=-unit_vec_z;
else if(face_inter==5) Fnorm= unit_vec_z;*/

return Fnorm;
}


void Polynomial::set_parameters(double outer_radius_,
double inner_radius_,
std::vector<double> const &coeffs_,
bool normalized_)
{
outer_radius = outer_radius_;
inner_radius = inner_radius_;
coeffs = coeffs_;
normalized = normalized_;

effective_coeffs = coeffs;

if(normalized)
{
for(std::size_t i=0; i<effective_coeffs.size(); i++)
for(std::size_t j=i; j<effective_coeffs.size(); j++)
{
effective_coeffs[j] /= outer_radius;
}
}
}


Vector3 Polynomial::tangent(RayInter const &inter,Vector3 const &normal,bool up) const
{
int const &face_inter=inter.face;

Sel::SelFace const &face=F_arr[face_inter];

int tangent_type;
Vector3 tangent;

// Todo

return tangent;
}


void Polynomial::xyz_to_uv(double &u,double &v,int face_,double x,double y,double z) const
{
// Todo
}
}
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//###############
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//############
Expand Down
4 changes: 0 additions & 4 deletions src/Selene/primitives/sel_obj_spherical_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ limitations under the License.*/

extern std::ofstream plog;

extern const Vector3 unit_vec_x;
extern const Vector3 unit_vec_y;
extern const Vector3 unit_vec_z;

namespace Sel::Primitives
{
//#####################
Expand Down
4 changes: 1 addition & 3 deletions src/Selene/sel_light.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*Copyright 2008-2022 - Loïc Le Cunff
/*Copyright 2008-2024 - Loïc Le Cunff
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,8 +14,6 @@ limitations under the License.*/

#include <selene.h>

extern const Vector3 unit_vec_x,unit_vec_y,unit_vec_z;

namespace Sel
{

Expand Down
Loading

0 comments on commit 862a3f8

Please sign in to comment.