Developer Documentation
Loading...
Searching...
No Matches
StripProcessorT.hh
1/*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40\*===========================================================================*/
41
42/*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Date$ *
46 * *
47\*===========================================================================*/
48
49//=============================================================================
50//
51// CLASS StripProcessorT
52//
53//=============================================================================
54
55
56#ifndef ACG_STRIP_PROCESSOR_HH
57#define ACG_STRIP_PROCESSOR_HH
58
59
60//== INCLUDES =================================================================
61
62#include <vector>
63#include <OpenMesh/Core/Utils/Property.hh>
64#include <OpenMesh/Core/IO/MeshIO.hh>
65
66#include "../Config/ACGDefines.hh"
67
68#include <ACG/GL/GLState.hh>
69
70//== FORWARDDECLARATIONS ======================================================
71
72
73//== NAMESPACES ===============================================================
74
75namespace ACG {
76namespace SceneGraph {
77
78
79//== CLASS DEFINITION =========================================================
80
84class ACGDLLEXPORT Strip {
85
86public:
87
92 std::vector< unsigned int > indexArray;
93
95 std::vector< OpenMesh::FaceHandle > faceMap;
96
99
100};
101
102bool ACGDLLEXPORT stripTextureCompare(const Strip& i,const Strip& j);
103
104class ACGDLLEXPORT TextureRenderInfo {
105 public:
106 TextureRenderInfo(int _textureId,int _faceCount,int _startOffset):
107 textureId(_textureId),
108 faceCount(_faceCount),
109 startOffset(_startOffset)
110 {};
111
118};
119
120
121
126template <class Mesh>
128{
129public:
130
131 typedef unsigned int Index;
132 typedef std::vector<Strip> Strips;
133 typedef typename Strips::const_iterator StripsIterator;
134 typedef typename Mesh::FaceHandle FaceHandle;
135
137 StripProcessorT(Mesh& _mesh);
138
141
143 unsigned int stripify();
144
146 void clear() { Strips().swap(strips_); }
147
149 unsigned int nStrips() const { return strips_.size(); }
150
152 StripsIterator begin() const { return strips_.begin(); }
154 StripsIterator end() const { return strips_.end(); }
155
156
157private:
158
159
160
162 void convexityTest(FaceHandle _fh);
163
164 OpenMesh::FPropHandleT<bool>::reference processed(typename Mesh::FaceHandle _fh) {
165 return mesh_.property(processed_, _fh);
166 }
167 OpenMesh::FPropHandleT<bool>::reference used(typename Mesh::FaceHandle _fh) {
168 return mesh_.property(used_, _fh);
169 }
170
171
172
173private:
174
175 Mesh& mesh_;
176 Strips strips_;
177 OpenMesh::FPropHandleT<bool> processed_, used_;
178
179//===========================================================================
182//===========================================================================
183public:
184
189void invalidateStrips() { stripsValid_ = false; };
190
191private:
192
193typedef std::vector<typename Mesh::FaceHandle> FaceHandles;
194
197
199void buildStrips();
200
202void buildStripsTriMesh();
203
210
211
213void buildStripTriMesh(typename Mesh::HalfedgeHandle _start_hh,
214 Strip& _strip,
215 FaceHandles& _faces);
216
218void buildStripPolyMesh(typename Mesh::HalfedgeHandle _start_hh,
219 Strip& _strip,
220 FaceHandles& _faces);
221
224//===========================================================================
227//===========================================================================
228public:
234
240
247
248private:
253 void updatePerEdgeBuffers();
254
256 std::vector< ACG::Vec3f > perEdgeVertexBuffer_;
257
259 std::vector< ACG::Vec4f > perEdgeColorBuffer_;
260
263
267//===========================================================================
270//===========================================================================
271public:
277
283
290
291private:
297
298
302 typename Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh);
303
305 std::vector< ACG::Vec3f > perHalfedgeVertexBuffer_;
306
308 std::vector< ACG::Vec4f > perHalfedgeColorBuffer_;
309
312
315//===========================================================================
318//===========================================================================
319
320public:
328
336
344
352
355 unsigned int perFaceVertexBufferSize(){ return perFaceVertexBuffer_.size(); };
356
363
364private:
370
372 std::vector< ACG::Vec3f > perFaceVertexBuffer_;
373 std::vector< ACG::Vec4f > perFaceColorBuffer_;
374 std::vector< ACG::Vec3f > perFaceNormalBuffer_;
375 std::vector< ACG::Vec3f > perFacePerVertexNormalBuffer_;
376
379
382//===========================================================================
385//===========================================================================
386
387public:
388
393 void updatePickingVertices(ACG::GLState& _state , uint _offset = 0);
394
402
403private:
404
406 std::vector< ACG::Vec4uc > pickVertexColorBuf_;
407
408
411//===========================================================================
414//===========================================================================
415
416 public:
417
422 void updatePickingEdges(ACG::GLState& _state , uint _offset = 0 );
423
431
432
433
434 private:
435
436 std::vector< ACG::Vec4uc > pickEdgeColorBuf_;
437
438
441//===========================================================================
444//===========================================================================
445
446public:
447
449 void updatePickingFaces(ACG::GLState& _state );
450
458
459
460
461private:
462
465
468
469 std::vector< ACG::Vec4uc > pickFaceColorBuf_;
470
473 //===========================================================================
476 //===========================================================================
477
478public:
479
485 void updatePickingAny(ACG::GLState& _state );
486
494
495private:
496
497 std::vector< ACG::Vec4uc > pickAnyColorBuf_;
498
501//===========================================================================
504//===========================================================================
505
506public:
513 void setIndexPropertyName( std::string _indexPropertyName );
514
516 const std::string& indexPropertyName() const { return textureIndexPropertyName_; };
517
524 void setPerFaceTextureCoordinatePropertyName( std::string _perFaceTextureCoordinatePropertyName );
525
531
538
544
552 std::vector< TextureRenderInfo >* textureRenderData(){ return &textureRenderData_; };
553
554private:
555
564
571
572 std::vector< ACG::Vec2f > perFaceTextureCoordArray_;
573
574 std::vector< TextureRenderInfo > textureRenderData_;
575
578};
579
580
581//=============================================================================
582} // namespace SceneGraph
583} // namespace ACG
584//=============================================================================
585#if defined(INCLUDE_TEMPLATES) && !defined(ACG_STRIP_PROCESSOR_C)
586#define ACG_STRIP_PROCESSOR_TEMPLATES
587#include "StripProcessorT_impl.hh"
588#endif
589//=============================================================================
590#endif // ACG_STRIP_PROCESSOR_HH defined
591//=============================================================================
unsigned int nStrips() const
returns number of strips
std::vector< ACG::Vec4uc > pickFaceColorBuf_
Call this function to update the color picking array.
void convexityTest(FaceHandle _fh)
Test whether face is convex.
void updatePerFaceBuffers()
Update all per face buffers.
ACG::Vec3f * perHalfedgeVertexBuffer()
get a pointer to the per edge vertex buffer
std::vector< ACG::Vec3f > perFaceVertexBuffer_
Buffer holding vertices for per face rendering.
void setPerFaceTextureCoordinatePropertyName(std::string _perFaceTextureCoordinatePropertyName)
set the name of the property used for texture coordinate
void updatePickingEdges(ACG::GLState &_state, uint _offset=0)
bool updatePerEdgeBuffers_
This flag controls if an update is really necessary.
ACG::Vec3f * perFacePerVertexNormalBuffer()
get a pointer to the per face per vertex normal buffer
std::string textureIndexPropertyName_
Property for the per face texture index.
ACG::Vec4uc * pickEdgeColorBuffer()
get a pointer to the per edge picking color buffer
void updatePickingFacesTrimesh(ACG::GLState &_state)
Call this function to update the color picking array.
std::vector< typename Mesh::FaceHandle > FaceHandles
This flag shows if the strips have to be regenerated.
std::vector< ACG::Vec3f > perFacePerVertexNormalBuffer_
Buffer holding vertices for per face rendering.
bool stripsValid_
This flag shows if the strips have to be regenerated.
bool perFaceTextureIndexAvailable()
Check if textureindicies are available.
void updatePickingVertices(ACG::GLState &_state, uint _offset=0)
const std::string & indexPropertyName() const
get the name of the texture index property
void updatePerEdgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
void invalidatePerHalfedgeBuffers()
Update of the buffers.
ACG::Vec2f * perFacePerVertexTextureCoordBuffer()
get a pointer to the per face per vertex texture coor buffer
ACG::Vec4f * perHalfedgeColorBuffer()
get a pointer to the per edge color buffer
ACG::Vec4uc * pickAnyColorBuffer()
get a pointer to the any picking color buffer
ACG::Vec3f * perFaceNormalBuffer()
get a pointer to the per face normal buffer
void updatePickingFaces(ACG::GLState &_state)
Call this function to update the color picking array.
std::vector< ACG::Vec4uc > pickEdgeColorBuf_
std::vector< ACG::Vec3f > perHalfedgeVertexBuffer_
Per Edge vertex buffer (glLines)
StripsIterator begin() const
Access strips.
bool perFaceTextureCoordinateAvailable()
Check if per Face Texture coordinates are available.
std::vector< ACG::Vec3f > perFaceNormalBuffer_
Buffer holding vertices for per face rendering.
ACG::Vec3f * perEdgeVertexBuffer()
get a pointer to the per edge vertex buffer
void buildStripPolyMesh(typename Mesh::HalfedgeHandle _start_hh, Strip &_strip, FaceHandles &_faces)
build a strip from a given halfedge (in both directions) of a polymesh
std::vector< TextureRenderInfo > * textureRenderData()
get rendering information for texture data
ACG::Vec4uc * pickVertexColorBuffer()
get a pointer to the per vertex picking color buffer
void buildStripTriMesh(typename Mesh::HalfedgeHandle _start_hh, Strip &_strip, FaceHandles &_faces)
build a strip from a given halfedge (in both directions) of a triangle mesh
std::vector< ACG::Vec4f > perFaceColorBuffer_
Buffer holding vertices for per face rendering.
void invalidateStrips()
Force a strip update.
void updatePerHalfedgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
ACG::Vec3f * perFaceVertexBuffer()
get a pointer to the per face vertex buffer
void setIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
std::string perFaceTextureCoordinatePropertyName_
Property for the per face texture coordinates.
void invalidatePerEdgeBuffers()
Update of the buffers.
void updatePickingAny(ACG::GLState &_state)
Call this function to update the color picking array.
std::vector< ACG::Vec4uc > pickAnyColorBuf_
Call this function to update the color picking array.
ACG::Vec4f * perFaceColorBuffer()
get a pointer to the per face color buffer
void invalidatePerFaceBuffers()
Update of the buffers.
void updatePickingFacesPolymesh(ACG::GLState &_state)
Call this function to update the color picking array.
void buildStripsTriMesh()
This method generates strips for triangle meshes.
unsigned int perFaceVertexBufferSize()
Get the number of elements in the face picking buffers.
std::vector< ACG::Vec3f > perEdgeVertexBuffer_
Per Edge vertex buffer (glLines)
ACG::Vec4f * perEdgeColorBuffer()
get a pointer to the per edge color buffer
std::vector< ACG::Vec4f > perHalfedgeColorBuffer_
Per Edge color buffer.
std::vector< ACG::Vec4f > perEdgeColorBuffer_
Per Edge color buffer.
unsigned int stripify()
Compute triangle strips, returns number of strips.
void buildStrips()
this method does the main work
std::vector< ACG::Vec2f > perFaceTextureCoordArray_
Property for the per face texture index.
Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh)
compute halfedge point compute visulization point for halfedge (shifted to interior of face)
bool updatePerFaceBuffers_
This flag controls if an update is really necessary.
bool updatePerHalfedgeBuffers_
This flag controls if an update is really necessary.
std::vector< TextureRenderInfo > textureRenderData_
Property for the per face texture index.
StripsIterator end() const
Access strips.
ACG::Vec4uc * pickFaceColorBuffer()
get a pointer to the per face picking color buffer
std::vector< ACG::Vec4uc > pickVertexColorBuf_
The color buffer used for vertex picking.
class for managing a single triangle strip.
std::vector< unsigned int > indexArray
This array cotains the actual triangle strip used for rendering.
std::vector< OpenMesh::FaceHandle > faceMap
This map contains for each vertex in the strips a handle to the face it closes.
int textureIndex
This contains the texture index used for rendering this strip.
int textureId
Id of the texture to be rendered.
int faceCount
Number of faces in the render step for this texture.
int startOffset
Start offset in the face buffer.
Kernel::FaceHandle FaceHandle
Scalar type.
Definition PolyMeshT.hh:139
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition PolyMeshT.hh:137
Kernel::Point Point
Coordinate type.
Definition PolyMeshT.hh:112
bool stripTextureCompare(const Strip &i, const Strip &j)
Compare function for sorting Strips depending on their texture index.
Namespace providing different geometric functions concerning angles.