35 for (
auto &r : b.
rays) {
36 if (not(r.is_valid())) {
return;}
38 if (not(r.is_valid())) {
return;}
39 auto N =
shp.normal(r);
40 if (not(r.is_valid())) {
return;}
46 for (
auto &r : b.
rays) {
47 if (not(r.is_valid())) {
return; }
52 virtual std::unique_ptr<lpart>
clone ()
const override {
53 return std::make_unique<shape_reflect_part>(*
this);
66 ss <<
"shape_reflect_part<shape: " <<
shp <<
">";
70 static_assert(std::is_base_of<shape, T>::value,
71 "T must be derived from shape.");
106 for (
auto &r : b.
rays) {
107 if (not(r.is_valid())) {
return;}
109 if (not(r.is_valid())) {
return;}
110 auto N =
shp.normal(r);
111 if (not(r.is_valid())) {
return;}
117 for (
auto &r : b.
rays) {
118 if (not(r.is_valid())) {
return; }
123 virtual std::unique_ptr<lpart>
clone ()
const override {
124 return std::make_unique<shape_refract_part>(*
this);
136 std::stringstream ss;
137 ss <<
"shape_refract_part<shape: " <<
shp <<
"," << std::endl
138 <<
"nr: " <<
nr <<
">";
142 static_assert(std::is_base_of<shape, T>::value,
143 "T must be derived from shape.");
Class for ray bundles.
Definition: bun.h:13
std::vector< ray > rays
Vector of rays.
Definition: bun.h:16
Virtual class for elementary optical parts which can be applied to ray bundles.
Definition: lpart.h:12
Class template implementing the specialized lparts for reflective shape parts.
Definition: shape_part.h:11
virtual void apply(bun &b) override
Apply reflective shape lpart operations to the ray bundle b.
Definition: shape_part.h:34
virtual bool is_transfer() override
Is the part a transfer?
Definition: shape_part.h:56
T shp
The shape of the part.
Definition: shape_part.h:16
shape_reflect_part(T _shp)
Constructor with initialization to the shape _shp.
Definition: shape_part.h:21
virtual std::unique_ptr< lpart > clone() const override
Obtain a copy of the lpart.
Definition: shape_part.h:52
virtual bool is_renderable() override
Is the part renderable?
Definition: shape_part.h:59
virtual void intersect(bun &b) override
Apply only the eventual intersection of the lpart with ray bundle b.
Definition: shape_part.h:45
virtual std::string print_str() const override
String for printing the object.
Definition: shape_part.h:64
Class template implementing the specialized lparts for refractive shape parts.
Definition: shape_part.h:77
virtual void intersect(bun &b) override
Apply only the eventual intersection of the lpart with ray bundle b.
Definition: shape_part.h:116
virtual std::string print_str() const override
String for printing the object.
Definition: shape_part.h:135
virtual std::unique_ptr< lpart > clone() const override
Obtain a copy of the lpart.
Definition: shape_part.h:123
shape_refract_part(T _shp, double _nr)
Constructor with initialization to the shape _shp and relative refractive index _nr.
Definition: shape_part.h:91
double nr
Part's relative refractive index.
Definition: shape_part.h:84
virtual void apply(bun &b) override
Apply refractive shape lpart operations to the ray bundle b.
Definition: shape_part.h:105
virtual bool is_transfer() override
Is the part a transfer?
Definition: shape_part.h:127
virtual bool is_renderable() override
Is the part renderable?
Definition: shape_part.h:130
T shp
The shape of the part.
Definition: shape_part.h:82
void reflect(ray &r, const Vec3 &N)
Reflect ray operation.
Definition: rop.cpp:9
void refract(ray &r, const Vec3 &N, double nr)
Refract ray operation.
Definition: rop.cpp:23