1 // OpenCSG - library for image-based CSG rendering for OpenGL
2 // Copyright (C) 2002-2016, Florian Kirsch,
3 // Hasso-Plattner-Institute at the University of Potsdam, Germany
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License,
7 // Version 2, as published by the Free Software Foundation.
8 // As a special exception, you have permission to link this library
9 // with the CGAL library and distribute executables.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 //
21 // batch.h
22 //
23 // object space optimization: If possible, several primitives are treated
24 // as a single batch
25 //
26 
27 #ifndef __OpenCSG__batch_h__
28 #define __OpenCSG__batch_h__
29 
30 #include "opencsgConfig.h"
31 #include <vector>
32 
33 namespace OpenCSG {
34 
35     class Primitive;
36 
37     /// a Batch is a list of primitives that do not overlap in screen space
38     typedef std::vector<Primitive*> Batch;
39 
40     class Batcher {
41     public:
42         /// subdivides an array of primitives into batches
43         Batcher(const std::vector<Primitive*>& primitives);
44 
45         /// returns first batch
46         std::vector<Batch>::const_iterator begin() const;
47         /// returns end of batches
48         std::vector<Batch>::const_iterator end() const;
49         /// return number of batches
50         unsigned int size() const;
51 
52     private:
53         std::vector<Batch> mBatches;
54     };
55 
56 } // namespace OpenCSG
57 
58 #endif // __OpenCSG__batch_h__
59