20 #if !defined(__MITSUBA_BIDIR_PATH_H_)
21 #define __MITSUBA_BIDIR_PATH_H_
59 inline Path(
size_t size) : m_vertices(size) { }
62 inline Path(
const Path &path) : m_vertices(path.m_vertices),
63 m_edges(path.m_edges) { }
81 void initialize(
const Scene *scene,
Float time,
130 int randomWalkFromPixel(
const Scene *scene,
Sampler *sampler,
131 int nSteps,
const Point2i &pixelPosition,
int rrStart,
174 static std::pair<int, int> alternatingRandomWalkFromPixel(
const Scene *scene,
175 Sampler *sampler,
Path &emitterPath,
int nEmitterSteps,
176 Path &sensorPath,
int nSensorSteps,
const Point2i &pixelPosition,
210 return m_vertices.size();
220 return m_edges.size();
228 return (
int) m_edges.size();
233 #if MTS_BD_DEBUG == 1
234 if (index >= m_vertices.size())
237 index, m_vertices.size());
239 return m_vertices[index];
244 #if MTS_BD_DEBUG == 1
245 if (index >= m_vertices.size())
248 index, m_vertices.size());
250 return m_vertices[index];
255 if (index >= m_vertices.size())
257 return m_vertices[index];
262 if (index >= m_vertices.size())
264 return m_vertices[index];
269 #if MTS_BD_DEBUG == 1
270 if (index >= m_edges.size())
273 index, m_edges.size());
275 return m_edges[index];
280 #if MTS_BD_DEBUG == 1
281 if (index >= m_edges.size())
284 index, m_edges.size());
286 return m_edges[index];
291 if (index >= m_edges.size())
293 return m_edges[index];
298 if (index >= m_edges.size())
300 return m_edges[index];
323 for (
int s=0; s<l; ++s)
327 for (
int t=length(); t>m; --t)
328 weight *= m_vertices[t]->weight[
ERadiance]
343 if (p.
length() != length())
346 for (
size_t i=0; i<m_vertices.size(); ++i) {
347 if (m_vertices[i]->type != p.
vertex(i)->
type ||
368 for (
int s=0; s<k-1; ++s)
378 return lum != 0.0f ? (weight / lum) :
Spectrum(0.0f);
417 const Path &emitterSubpath,
419 const Path &sensorSubpath,
int s,
int t,
420 bool direct,
bool lightImage);
429 void collapseTo(
PathEdge &edge)
const;
436 std::swap(supernode, m_vertices[0]);
437 std::swap(sample, m_vertices[1]);
438 std::swap(edge, m_edges[0]);
456 m_edges.push_back(edge);
457 m_vertices.push_back(vertex);
461 void append(
const Path &path);
476 void append(
const Path &path,
size_t start,
size_t end,
bool reverse =
false);
482 void release(
size_t start,
size_t end,
MemoryPool &pool);
486 return m_vertices[length()-1]->getSamplePosition();
496 bool operator==(
const Path &path)
const;
500 return !operator==(path);
507 std::string toString()
const;
510 std::string summarize()
const;
515 std::vector<PathVertexPtr> m_vertices;
516 std::vector<PathEdgePtr> m_edges;
bool matchesConfiguration(const Path &p) const
Determine whether another path of the same length matches the configuration of this path...
Definition: path.h:342
Bidirectional path vertex data structure.
Definition: vertex.h:48
const PathEdgePtr & edge(size_t index) const
Return an edge by its index (const version)
Definition: path.h:279
Spectrum getPrefixSuffixWeight(int l, int m) const
Return the spectrally varying path weight that corresponds to a prefix of length l and a suffix of le...
Definition: path.h:320
void append(PathVertex *vertex)
Append a vertex to this path.
Definition: path.h:442
Path(const Path &path)
Copy constructor.
Definition: path.h:62
int length() const
Return the length of the path. This is just the number of edges.
Definition: path.h:227
void append(PathEdge *edge)
Append an edge to this path.
Definition: path.h:445
const PathVertexPtr & vertex(size_t index) const
Return an vertex by its index (const version)
Definition: path.h:243
PathVertexPtr vertexOrNull(size_t index)
Return an vertex by its index (or NULL if out of bounds)
Definition: path.h:254
Spectrum getRelativeWeight() const
Return the relative spectrally varying path weight associated with this path.
Definition: path.h:364
void clear()
Clear the path.
Definition: path.h:490
Principal scene data structure.
Definition: scene.h:49
#define SLog(level, fmt,...)
Write a Log message to the console (static version - to be used outside of classes that derive from O...
Definition: logger.h:49
Base class of all sample generators.
Definition: sampler.h:66
bool operator!=(const Path &path) const
Compare this path against another path.
Definition: path.h:499
void append(PathEdge *edge, PathVertex *vertex)
Append an edge and a vertex to this path.
Definition: path.h:455
Bidirectional path data structure.
Definition: path.h:46
size_t vertexCount() const
Return the number of vertices stored in this path.
Definition: path.h:209
Path(size_t size)
Create a new path of the specified size.
Definition: path.h:59
PathVertex * PathVertexPtr
Definition: path.h:49
PathEdgePtr edgeOrNull(size_t index) const
Return an edge by its index (or NULL if out of bounds, const version)
Definition: path.h:297
Importance transport.
Definition: common.h:40
Float getLuminance() const
Return the luminance in candelas.
void swapEndpoints(PathVertexPtr &supernode, PathEdgePtr &edge, PathVertexPtr &sample)
Swap the two endpoint vertices of a path with the provided values.
Definition: path.h:435
Path()
Create a new, empty path.
Definition: path.h:56
PathEdgePtr & edge(size_t index)
Return an edge by its index.
Definition: path.h:268
EVertexType type
Specifies one of several possible path vertex types.
Definition: vertex.h:94
size_t edgeCount() const
Return the number of edges stored in this path.
Definition: path.h:219
Bidirectional path edge data structure.
Definition: edge.h:46
Error message, causes an exception to be thrown.
Definition: formatter.h:33
PathEdge * PathEdgePtr
Definition: path.h:48
PathVertexPtr vertexOrNull(size_t index) const
Return an vertex by its index (or NULL if out of bounds, const version)
Definition: path.h:261
bool isConnectable() const
Returns whether or not this vertex can be deterministically connected to other vertices.
Definition: vertex.h:740
Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range...
Definition: spectrum.h:663
PathVertexPtr & vertex(size_t index)
Return an vertex by its index.
Definition: path.h:232
Radiance transport.
Definition: common.h:38
PathEdgePtr edgeOrNull(size_t index)
Return an edge by its index (or NULL if out of bounds)
Definition: path.h:290
ETransportMode
Specifies the transport mode when sampling or evaluating a scattering function.
Definition: common.h:33
const Point2 & getSamplePosition() const
Return the sample position associated with the path.
Definition: path.h:485