From 352ee09773d15fdf16895778af2df1e6b5e578ff Mon Sep 17 00:00:00 2001 From: KAHR-Alpha <113597714+KAHR-Alpha@users.noreply.github.com> Date: Sun, 17 Mar 2024 22:14:09 +0100 Subject: [PATCH 1/2] Polynomials class creation and conversion of unit vectors to inline variables --- .../build_vs2022/setup_vs_studio_debug.ps1 | 1 + src/GUI/Selene/gui_selene_gl.cpp | 6 +- src/Selene/CMakeLists.txt | 1 + src/Selene/primitives/sel_obj_box.cpp | 4 - src/Selene/primitives/sel_obj_cone.cpp | 4 - src/Selene/primitives/sel_obj_conic.cpp | 4 - src/Selene/primitives/sel_obj_cylinder.cpp | 4 - src/Selene/primitives/sel_obj_disk.cpp | 4 - src/Selene/primitives/sel_obj_lens.cpp | 4 - src/Selene/primitives/sel_obj_mesh.cpp | 4 - src/Selene/primitives/sel_obj_parabola.cpp | 4 - src/Selene/primitives/sel_obj_polynomial.cpp | 168 ++++++++++++++++++ src/Selene/primitives/sel_obj_rectangle.cpp | 4 - src/Selene/primitives/sel_obj_sphere.cpp | 4 - .../primitives/sel_obj_spherical_patch.cpp | 4 - src/Selene/sel_light.cpp | 4 +- src/Selene/sel_obj.cpp | 6 +- src/Selene/sel_obj_surface.cpp | 6 +- src/Selene/sel_obj_volume.cpp | 4 - src/Selene/selene_primitives.h | 33 ++++ src/common/geometry.h | 5 +- src/common/mesh_tools.cpp | 6 +- src/common/vector23.cpp | 6 +- 23 files changed, 213 insertions(+), 77 deletions(-) create mode 100644 src/Selene/primitives/sel_obj_polynomial.cpp diff --git a/contribs/build_vs2022/setup_vs_studio_debug.ps1 b/contribs/build_vs2022/setup_vs_studio_debug.ps1 index 55fb5573..3a9b05db 100644 --- a/contribs/build_vs2022/setup_vs_studio_debug.ps1 +++ b/contribs/build_vs2022/setup_vs_studio_debug.ps1 @@ -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" ` diff --git a/src/GUI/Selene/gui_selene_gl.cpp b/src/GUI/Selene/gui_selene_gl.cpp index 491f7c01..c853d972 100644 --- a/src/GUI/Selene/gui_selene_gl.cpp +++ b/src/GUI/Selene/gui_selene_gl.cpp @@ -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. @@ -15,10 +15,6 @@ limitations under the License.*/ #include #include -extern const Vector3 unit_vec_x; -extern const Vector3 unit_vec_y; -extern const Vector3 unit_vec_z; - namespace SelGUI { diff --git a/src/Selene/CMakeLists.txt b/src/Selene/CMakeLists.txt index fa2817a4..06a57176 100644 --- a/src/Selene/CMakeLists.txt +++ b/src/Selene/CMakeLists.txt @@ -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) diff --git a/src/Selene/primitives/sel_obj_box.cpp b/src/Selene/primitives/sel_obj_box.cpp index 7db2b2ee..1ab49c0a 100644 --- a/src/Selene/primitives/sel_obj_box.cpp +++ b/src/Selene/primitives/sel_obj_box.cpp @@ -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 { //######### diff --git a/src/Selene/primitives/sel_obj_cone.cpp b/src/Selene/primitives/sel_obj_cone.cpp index 35ce2408..2b0928a5 100644 --- a/src/Selene/primitives/sel_obj_cone.cpp +++ b/src/Selene/primitives/sel_obj_cone.cpp @@ -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 { //########## diff --git a/src/Selene/primitives/sel_obj_conic.cpp b/src/Selene/primitives/sel_obj_conic.cpp index e7e8a3db..0b3a1c9c 100644 --- a/src/Selene/primitives/sel_obj_conic.cpp +++ b/src/Selene/primitives/sel_obj_conic.cpp @@ -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 { //########### diff --git a/src/Selene/primitives/sel_obj_cylinder.cpp b/src/Selene/primitives/sel_obj_cylinder.cpp index fe4713e1..7e392d1a 100644 --- a/src/Selene/primitives/sel_obj_cylinder.cpp +++ b/src/Selene/primitives/sel_obj_cylinder.cpp @@ -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 { //############## diff --git a/src/Selene/primitives/sel_obj_disk.cpp b/src/Selene/primitives/sel_obj_disk.cpp index 06725279..c6eb17b1 100644 --- a/src/Selene/primitives/sel_obj_disk.cpp +++ b/src/Selene/primitives/sel_obj_disk.cpp @@ -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 { //########## diff --git a/src/Selene/primitives/sel_obj_lens.cpp b/src/Selene/primitives/sel_obj_lens.cpp index 16a442a6..6445786e 100644 --- a/src/Selene/primitives/sel_obj_lens.cpp +++ b/src/Selene/primitives/sel_obj_lens.cpp @@ -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 { //########## diff --git a/src/Selene/primitives/sel_obj_mesh.cpp b/src/Selene/primitives/sel_obj_mesh.cpp index 543c21c0..811678e0 100644 --- a/src/Selene/primitives/sel_obj_mesh.cpp +++ b/src/Selene/primitives/sel_obj_mesh.cpp @@ -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 { //########## diff --git a/src/Selene/primitives/sel_obj_parabola.cpp b/src/Selene/primitives/sel_obj_parabola.cpp index 9f428dd2..10592946 100644 --- a/src/Selene/primitives/sel_obj_parabola.cpp +++ b/src/Selene/primitives/sel_obj_parabola.cpp @@ -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 { //############## diff --git a/src/Selene/primitives/sel_obj_polynomial.cpp b/src/Selene/primitives/sel_obj_polynomial.cpp new file mode 100644 index 00000000..d4c8fdfe --- /dev/null +++ b/src/Selene/primitives/sel_obj_polynomial.cpp @@ -0,0 +1,168 @@ +/*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 +#include + +extern std::ofstream plog; + +namespace Sel::Primitives +{ + //################# + // Polynormial + //################# + + Polynomial::Polynomial(BoundingBox &bbox_, + std::vector &F_arr_, + std::vector &face_name_arr_) + :Primitive(bbox_, F_arr_, face_name_arr_), + coeffs(1, 0) + { + } + + + 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; + } + + + 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 &interlist, SelRay const &ray, int obj_ID, int face_last_intersect, bool first_forward) const + { + /*std::array hits; + std::array 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 &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; + } + + + 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 + } +} diff --git a/src/Selene/primitives/sel_obj_rectangle.cpp b/src/Selene/primitives/sel_obj_rectangle.cpp index ccb8df65..2bb75689 100644 --- a/src/Selene/primitives/sel_obj_rectangle.cpp +++ b/src/Selene/primitives/sel_obj_rectangle.cpp @@ -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 { //############### diff --git a/src/Selene/primitives/sel_obj_sphere.cpp b/src/Selene/primitives/sel_obj_sphere.cpp index 91eec6df..025ed8cb 100644 --- a/src/Selene/primitives/sel_obj_sphere.cpp +++ b/src/Selene/primitives/sel_obj_sphere.cpp @@ -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 { //############ diff --git a/src/Selene/primitives/sel_obj_spherical_patch.cpp b/src/Selene/primitives/sel_obj_spherical_patch.cpp index 831dbfbe..2ac55527 100644 --- a/src/Selene/primitives/sel_obj_spherical_patch.cpp +++ b/src/Selene/primitives/sel_obj_spherical_patch.cpp @@ -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 { //##################### diff --git a/src/Selene/sel_light.cpp b/src/Selene/sel_light.cpp index 4282968a..e11f2250 100644 --- a/src/Selene/sel_light.cpp +++ b/src/Selene/sel_light.cpp @@ -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. @@ -14,8 +14,6 @@ limitations under the License.*/ #include -extern const Vector3 unit_vec_x,unit_vec_y,unit_vec_z; - namespace Sel { diff --git a/src/Selene/sel_obj.cpp b/src/Selene/sel_obj.cpp index be52ff88..03097f4a 100644 --- a/src/Selene/sel_obj.cpp +++ b/src/Selene/sel_obj.cpp @@ -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. @@ -18,10 +18,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 { diff --git a/src/Selene/sel_obj_surface.cpp b/src/Selene/sel_obj_surface.cpp index 7509bee2..2bae59fe 100644 --- a/src/Selene/sel_obj_surface.cpp +++ b/src/Selene/sel_obj_surface.cpp @@ -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. @@ -16,10 +16,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 { //################### diff --git a/src/Selene/sel_obj_volume.cpp b/src/Selene/sel_obj_volume.cpp index 4c3b67bd..6b83fb8e 100644 --- a/src/Selene/sel_obj_volume.cpp +++ b/src/Selene/sel_obj_volume.cpp @@ -16,10 +16,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 { int nearest_2np1(double val) diff --git a/src/Selene/selene_primitives.h b/src/Selene/selene_primitives.h index 2a852cd5..dad0ebdf 100644 --- a/src/Selene/selene_primitives.h +++ b/src/Selene/selene_primitives.h @@ -324,6 +324,39 @@ namespace Sel::Primitives private: }; + class Polynomial: public Primitive + { + public: + Polynomial(BoundingBox &bbox, + std::vector &F_arr, + std::vector &face_name_arr); + + Vector3 anchor(int anchor) const; + std::string anchor_name(int anchor) const; + void default_N_uv(int &Nu, int &Nv, int face) const; + void finalize(); + double get_lx() const; + double get_ly() const; + double get_lz() const; + void intersect(std::vector &interlist, SelRay const &ray, int obj_ID, int face_last_intersect,bool first_forward) const; + void map_variables(std::map &variables_map); + Vector3 normal(RayInter const &inter) const; + double& ref_lx(); + double& ref_ly(); + double& ref_lz(); + void set_parameters(double lx, + double ly, + double lz); + Vector3 tangent(RayInter const &inter, + Vector3 const &normal, + bool up) const; + void xyz_to_uv(double &u, double &v, int face, + double x, double y, double z) const; + + private: + std::vector coeffs; + }; + class Rectangle: public Primitive { public: diff --git a/src/common/geometry.h b/src/common/geometry.h index 6e0db58a..fdfa34f0 100644 --- a/src/common/geometry.h +++ b/src/common/geometry.h @@ -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. @@ -102,6 +102,9 @@ class Vector3 friend std::ostream& operator << (std::ostream &strm,Vector3 const &V); }; +inline const Vector3 unit_vec_x(1.0,0,0); +inline const Vector3 unit_vec_y(0,1.0,0); +inline const Vector3 unit_vec_z(0,0,1.0); class ImVector3 { diff --git a/src/common/mesh_tools.cpp b/src/common/mesh_tools.cpp index 029d8e2f..5fa5983c 100644 --- a/src/common/mesh_tools.cpp +++ b/src/common/mesh_tools.cpp @@ -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. @@ -14,10 +14,6 @@ limitations under the License.*/ #include -extern const Vector3 unit_vec_x; -extern const Vector3 unit_vec_y; -extern const Vector3 unit_vec_z; - //###################################### //###################################### diff --git a/src/common/vector23.cpp b/src/common/vector23.cpp index 7009e8ff..e42798cd 100644 --- a/src/common/vector23.cpp +++ b/src/common/vector23.cpp @@ -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. @@ -17,10 +17,6 @@ limitations under the License.*/ extern const Imdouble Im; -extern const Vector3 unit_vec_x(1.0,0,0); -extern const Vector3 unit_vec_y(0,1.0,0); -extern const Vector3 unit_vec_z(0,0,1.0); - //############# // Vector2 //############# From 03c71b89a4d12b039f247e63b3d4e45241f3ca61 Mon Sep 17 00:00:00 2001 From: KAHR-Alpha <113597714+KAHR-Alpha@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:55:40 +0200 Subject: [PATCH 2/2] Preparing the tests for revolution polynomials --- cmake_scripts/unit_tests.cmake | 2 +- src/Selene/primitives/sel_obj_polynomial.cpp | 42 +++++++++++++++++++- src/Selene/selene_primitives.h | 20 +++++----- tests/selene/revolution_polynomial.cpp | 30 ++++++++++++++ 4 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 tests/selene/revolution_polynomial.cpp diff --git a/cmake_scripts/unit_tests.cmake b/cmake_scripts/unit_tests.cmake index 9df6e0e3..5f677c1e 100644 --- a/cmake_scripts/unit_tests.cmake +++ b/cmake_scripts/unit_tests.cmake @@ -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}) diff --git a/src/Selene/primitives/sel_obj_polynomial.cpp b/src/Selene/primitives/sel_obj_polynomial.cpp index d4c8fdfe..1b271918 100644 --- a/src/Selene/primitives/sel_obj_polynomial.cpp +++ b/src/Selene/primitives/sel_obj_polynomial.cpp @@ -27,7 +27,11 @@ namespace Sel::Primitives std::vector &F_arr_, std::vector &face_name_arr_) :Primitive(bbox_, F_arr_, face_name_arr_), - coeffs(1, 0) + inner_radius(0), + outer_radius(50e-3), + coeffs(1, 1), + effective_coeffs(coeffs), + normalized(true) { } @@ -48,6 +52,19 @@ namespace Sel::Primitives { 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() @@ -145,6 +162,29 @@ namespace Sel::Primitives return Fnorm; } + + void Polynomial::set_parameters(double outer_radius_, + double inner_radius_, + std::vector 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 +#include #include namespace Sel @@ -335,18 +336,13 @@ namespace Sel::Primitives std::string anchor_name(int anchor) const; void default_N_uv(int &Nu, int &Nv, int face) const; void finalize(); - double get_lx() const; - double get_ly() const; - double get_lz() const; void intersect(std::vector &interlist, SelRay const &ray, int obj_ID, int face_last_intersect,bool first_forward) const; void map_variables(std::map &variables_map); Vector3 normal(RayInter const &inter) const; - double& ref_lx(); - double& ref_ly(); - double& ref_lz(); - void set_parameters(double lx, - double ly, - double lz); + void set_parameters(double outer_radius, + double inner_radius, + std::vector const &coeffs, + bool normalized); Vector3 tangent(RayInter const &inter, Vector3 const &normal, bool up) const; @@ -354,7 +350,11 @@ namespace Sel::Primitives double x, double y, double z) const; private: - std::vector coeffs; + double inner_radius, outer_radius; + std::vector coeffs, effective_coeffs; + bool normalized; + + double eval(double x) const; }; class Rectangle: public Primitive diff --git a/tests/selene/revolution_polynomial.cpp b/tests/selene/revolution_polynomial.cpp new file mode 100644 index 00000000..13de82b7 --- /dev/null +++ b/tests/selene/revolution_polynomial.cpp @@ -0,0 +1,30 @@ +/*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 + +int revolution_polynomial(int argc,char *argv[]) +{ + Sel::BoundingBox bbox; + std::vector faces; + std::vector face_names; + + Sel::Primitives::Polynomial poly(bbox, faces, face_names); + + std::vector coeffs={1.0, 0.5}; + + poly.set_parameters(10e2, 0, coeffs, true); + + return 0; +}