Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
range.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_RENDER_RANGE_H_)
21 #define __MITSUBA_RENDER_RANGE_H_
22 
23 #include <mitsuba/core/sched.h>
24 
26 
27 /**
28  * \brief A work unit specifying a range of some quantity to be processed.
29  *
30  * An example usage is in \ref ParticleProcess, where this class specifies
31  * sequences of particles to be traced.
32  *
33  * \ingroup librender
34  */
36 public:
37  inline void set(const WorkUnit *wu) {
38  const RangeWorkUnit *other = static_cast<const RangeWorkUnit *>(wu);
39  m_rangeStart = other->m_rangeStart;
40  m_rangeEnd = other->m_rangeEnd;
41  }
42 
43  inline void load(Stream *stream) {
44  m_rangeStart = stream->readSize();
45  m_rangeEnd = stream->readSize();
46  }
47 
48  inline void save(Stream *stream) const {
49  stream->writeSize(m_rangeStart);
50  stream->writeSize(m_rangeEnd);
51  }
52 
53  inline std::string toString() const {
54  std::ostringstream oss;
55  oss << "RangeWorkUnit[rangeStart=" << m_rangeStart
56  << ", rangeEnd=" << m_rangeEnd << "]";
57  return oss.str();
58  }
59 
60  inline void setRange(size_t start, size_t end) {
61  m_rangeStart = start;
62  m_rangeEnd = end;
63  }
64 
65  inline size_t getRangeStart() const {
66  return m_rangeStart;
67  }
68 
69  inline size_t getRangeEnd() const {
70  return m_rangeEnd;
71  }
72 
73  inline size_t getSize() const {
74  return m_rangeEnd - m_rangeStart + 1;
75  }
76 
78 private:
79  size_t m_rangeStart, m_rangeEnd;
80 };
81 
83 
84 #endif /* __MITSUBA_RENDER_RANGE_H_ */
A work unit specifying a range of some quantity to be processed.
Definition: range.h:35
void load(Stream *stream)
Fill the work unit with content acquired from a binary data stream.
Definition: range.h:43
size_t getRangeEnd() const
Definition: range.h:69
size_t getRangeStart() const
Definition: range.h:65
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
void set(const WorkUnit *wu)
Copy the content of another work unit of the same type.
Definition: range.h:37
Abstract work unit – represents a small amount of information that encodes part of a larger processin...
Definition: sched.h:47
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
std::string toString() const
Return a string representation.
Definition: range.h:53
#define MTS_EXPORT_RENDER
Definition: platform.h:109
size_t getSize() const
Definition: range.h:73
void save(Stream *stream) const
Serialize a work unit to a binary data stream.
Definition: range.h:48
void writeSize(size_t value)
Write a size value to the stream.
Definition: stream.h:214
#define MTS_NAMESPACE_END
Definition: platform.h:138
void setRange(size_t start, size_t end)
Definition: range.h:60
size_t readSize()
Read a size value from the stream.
Definition: stream.h:367