18 #include "Geometry/mathlib.h"
28 std::cerr <<
"Error : ray without source or receptor computeLongueur" << endl;
50 longueur = posSource.distance(posRecep);
70 longueur += posLastEvent.distance(posRecepteur);
86 std::vector<boost::shared_ptr<Event>>::iterator iter =
events.begin();
88 vec3 previous = (*iter)->getPosition();
89 vec3 current(0., 0., 0.);
92 while (iter !=
events.end())
94 current = (*iter)->getPosition();
95 length += current.distance(previous);
107 std::cerr <<
"Error : ray without source or receptor computeTrueLength" << endl;
119 closestPoint = ref.closestPointOnLine(posSource, lastPos);
122 return posSource.distance(closestPoint);
134 posLastEvent =
events.back()->getPosition();
137 closestPoint = ref.closestPointOnLine(posLastEvent, lastPos);
141 return length += closestPoint.distance(posLastEvent);
153 std::cerr <<
"Error : ray without source (computePertinentLength)" << endl;
160 vec3 current(0., 0., 0.), previous(0., 0., 0.);
176 s =
dynamic_cast<Source*
>(pertinentEvent);
190 e =
dynamic_cast<Event*
>(pertinentEvent);
196 std::vector<boost::shared_ptr<Event>>::reverse_iterator rit =
events.rbegin();
198 previous = (*rit)->getPosition();
201 while ((rit !=
events.rend()) && ((*rit).get() != e))
204 current = (*rit)->getPosition();
205 pertinent_length += current.distance(previous);
210 posLastEvent =
vec3(
events.back()->getPosition());
212 closestPoint = ref.closestPointOnLine(posLastEvent, lastPos);
215 return (pertinent_length += closestPoint.distance(posLastEvent));
229 for (std::vector<boost::shared_ptr<Event>>::iterator iter =
events.begin(); iter !=
events.end(); ++iter)
231 if ((*iter)->getType() == evType)
233 res = (
Base*)((*iter).get());
242 vector<unsigned int> result;
244 for (
unsigned int i = 0; i <
events.size(); i++)
246 result.push_back(
events.at(i)->getShape()->getFaceId());
255 vector<unsigned int> result;
257 for (
unsigned int i = 0; i <
events.size(); i++)
259 result.push_back(
events.at(i)->getShape()->getPrimitiveId());
272 return distance * angle;
275 return (
decimal)(2. * distance * sqrt(angle /
M_PI));
306 return std::make_pair(SR, SD);
314 for (
size_t i = 0; i <
events.size(); i++)
325 for (
size_t i = 0; i <
events.size(); i++)
329 if (
events.at(i)->getType() == typeEv)
std::pair< bitSet, bitSet > signature
Base class of Event, Material, PostFilter, Ray, Repere, Scene, Shape, Simulation, Source.
Class describing an event (reflection, diffraction, ...)
virtual int getType() const
Return the event type.
virtual int getInitialNbResponseLeft() const
Return the number of rays to launch after event.
decimal computeTrueLength(const vec3 &ref, const vec3 &lastPos, vec3 &closestPoint)
Compute ray length from source to closestPoint.
std::vector< boost::shared_ptr< Event > > events
Events list for the ray.
bitSet getSRBitSet(const unsigned int &source_id, const unsigned int &receptor_id)
Compute the bitSet associated with a source and a receptor.
decimal getSolidAngle(bool &diffraction)
Compute the solid angle associated with the ray (depends on the type of source which generated the ra...
Source * source
Pointer to the source of the ray.
vector< unsigned int > getPrimitiveHistory()
Return the array of primitives id encountered by the ray.
void * recepteur
Pointer to the receptor of the ray.
vector< unsigned int > getEventSignature()
decimal getThickness(const decimal &distance, bool diffraction)
Compute the thickness of the ray after having traveled a certain distance depending on the type of so...
vec3 getPosition() const
Return starting point ray.
Base * getLastPertinentEventOrSource(typeevent evType=DIFFRACTION)
Return a pointer to the last event of type evType or source if none.
signature getSignature(const typeevent &typeEv=SPECULARREFLEXION)
Compute the signature (i.e. std::pair<unsigned int, unsigned int>) of the ray)
vector< unsigned int > getFaceHistory()
Return the array of faces id encountered by the ray.
bitSet getEventsBitSet(const typeevent &typeEv)
Compute the bitSet associated with a list of events of type evType.
decimal computePertinentLength(const vec3 &ref, const vec3 &lastPos, vec3 &closestPoint)
Compute ray length from last pertinent event (i.e. source or last diffraction) to the nearest point o...
decimal longueur
Distance traveled by the ray.
decimal computeEventsSequenceLength()
Compute the length of the sequence of events.
void computeLongueur()
Compute the distance traveled (length) by the ray and the result is set into the longueur attribute.
Receptor inherits from a Sphere Shape.
int getInitialRayCount()
Get the initial rays counter.
vec3 getPosition()
Get the position of the Source.
unsigned int getId()
Get the Source id.
base_vec3< decimal > vec3