Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
75 namespace ACG {
76 namespace SceneGraph {
77 
78 
79 //== CLASS DEFINITION =========================================================
80 
84 class ACGDLLEXPORT Strip {
85 
86 public:
87 
92  std::vector< unsigned int > indexArray;
93 
95  std::vector< OpenMesh::FaceHandle > faceMap;
96 
99 
100 };
101 
102 bool ACGDLLEXPORT stripTextureCompare(const Strip& i,const Strip& j);
103 
104 class ACGDLLEXPORT TextureRenderInfo {
105  public:
106  TextureRenderInfo(int _textureId,int _faceCount,int _startOffset):
107  textureId(_textureId),
108  faceCount(_faceCount),
109  startOffset(_startOffset)
110  {};
111 
113  int textureId;
118 };
119 
120 
121 
126 template <class Mesh>
128 {
129 public:
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 
157 private:
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 
173 private:
174 
175  Mesh& mesh_;
176  Strips strips_;
177  OpenMesh::FPropHandleT<bool> processed_, used_;
178 
179 //===========================================================================
182 //===========================================================================
183 public:
184 
189 void invalidateStrips() { stripsValid_ = false; };
190 
191 private:
192 
193 typedef std::vector<typename Mesh::FaceHandle> FaceHandles;
194 
197 
199 void buildStrips();
200 
202 void buildStripsTriMesh();
203 
209 void buildStripsPolyMesh();
210 
211 
213 void buildStripTriMesh(typename Mesh::HalfedgeHandle _start_hh,
214  Strip& _strip,
215  FaceHandles& _faces);
216 
218 void buildStripPolyMesh(typename Mesh::HalfedgeHandle _start_hh,
219  Strip& _strip,
220  FaceHandles& _faces);
221 
224 //===========================================================================
227 //===========================================================================
228 public:
234 
240 
247 
248 private:
253  void updatePerEdgeBuffers();
254 
256  std::vector< ACG::Vec3f > perEdgeVertexBuffer_;
257 
259  std::vector< ACG::Vec4f > perEdgeColorBuffer_;
260 
263 
267 //===========================================================================
270 //===========================================================================
271 public:
277 
283 
290 
291 private:
296  void updatePerHalfedgeBuffers();
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 
320 public:
328 
336 
344 
352 
355  unsigned int perFaceVertexBufferSize(){ return perFaceVertexBuffer_.size(); };
356 
363 
364 private:
369  void updatePerFaceBuffers();
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 
387 public:
388 
393  void updatePickingVertices(ACG::GLState& _state , uint _offset = 0);
394 
402 
403 private:
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 
446 public:
447 
449  void updatePickingFaces(ACG::GLState& _state );
450 
458 
459 
460 
461 private:
462 
465 
468 
469  std::vector< ACG::Vec4uc > pickFaceColorBuf_;
470 
473  //===========================================================================
476  //===========================================================================
477 
478 public:
479 
485  void updatePickingAny(ACG::GLState& _state );
486 
494 
495 private:
496 
497  std::vector< ACG::Vec4uc > pickAnyColorBuf_;
498 
501 //===========================================================================
504 //===========================================================================
505 
506 public:
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 
554 private:
555 
563  std::string textureIndexPropertyName_;
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.cc"
588 #endif
589 //=============================================================================
590 #endif // ACG_STRIP_PROCESSOR_HH defined
591 //=============================================================================
class for managing a single triangle strip.
std::vector< ACG::Vec4uc > pickFaceColorBuf_
Call this function to update the color picking array.
ACG::Vec3f * perFaceVertexBuffer()
get a pointer to the per face vertex buffer
ACG::Vec4f * perHalfedgeColorBuffer()
get a pointer to the per edge color buffer
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
bool updatePerHalfedgeBuffers_
This flag controls if an update is really necessary.
void updatePickingVertices(ACG::GLState &_state, uint _offset=0)
ACG::Vec3f * perHalfedgeVertexBuffer()
get a pointer to the per edge vertex buffer
void invalidatePerHalfedgeBuffers()
Update of the buffers.
void setPerFaceTextureCoordinatePropertyName(std::string _perFaceTextureCoordinatePropertyName)
set the name of the property used for texture coordinate
bool updatePerEdgeBuffers_
This flag controls if an update is really necessary.
std::vector< typename Mesh::FaceHandle > FaceHandles
This flag shows if the strips have to be regenerated.
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::Vec3f > perFacePerVertexNormalBuffer_
Buffer holding vertices for per face rendering.
bool stripsValid_
This flag shows if the strips have to be regenerated.
void updatePerFaceBuffers()
Update all per face buffers.
std::vector< ACG::Vec4uc > pickEdgeColorBuf_
std::vector< ACG::Vec4uc > pickVertexColorBuf_
The color buffer used for vertex picking.
ACG::Vec4uc * pickFaceColorBuffer()
get a pointer to the per face picking color buffer
std::vector< ACG::Vec3f > perFaceVertexBuffer_
Buffer holding vertices for per face rendering.
ACG::Vec4f * perEdgeColorBuffer()
get a pointer to the per edge color buffer
std::vector< unsigned int > indexArray
This array cotains the actual triangle strip used for rendering.
std::vector< ACG::Vec3f > perFaceNormalBuffer_
Buffer holding vertices for per face rendering.
void invalidateStrips()
Force a strip update.
std::vector< ACG::Vec2f > perFaceTextureCoordArray_
Property for the per face texture index.
void updatePickingFacesTrimesh(ACG::GLState &_state)
Call this function to update the color picking array.
StripsIterator end() const
Access strips.
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
void invalidatePerEdgeBuffers()
Update of the buffers.
int textureIndex
This contains the texture index used for rendering this strip.
unsigned int perFaceVertexBufferSize()
Get the number of elements in the face picking buffers.
ACG::Vec4f * perFaceColorBuffer()
get a pointer to the per face color buffer
void updatePickingFaces(ACG::GLState &_state)
Call this function to update the color picking array.
unsigned int stripify()
Compute triangle strips, returns number of strips.
void clear()
delete all strips
std::vector< ACG::Vec3f > perEdgeVertexBuffer_
Per Edge vertex buffer (glLines)
ACG::Vec4uc * pickVertexColorBuffer()
get a pointer to the per vertex picking color buffer
bool updatePerFaceBuffers_
This flag controls if an update is really necessary.
std::vector< ACG::Vec4f > perEdgeColorBuffer_
Per Edge color buffer.
std::vector< ACG::Vec3f > perHalfedgeVertexBuffer_
Per Edge vertex buffer (glLines)
ACG::Vec4uc * pickEdgeColorBuffer()
get a pointer to the per edge picking color buffer
ACG::Vec4uc * pickAnyColorBuffer()
get a pointer to the any picking color buffer
std::vector< TextureRenderInfo > textureRenderData_
Property for the per face texture index.
void invalidatePerFaceBuffers()
Update of the buffers.
const std::string & indexPropertyName() const
get the name of the texture index property
bool stripTextureCompare(const Strip &i, const Strip &j)
Compare function for sorting Strips depending on their texture index.
std::vector< TextureRenderInfo > * textureRenderData()
get rendering information for texture data
int faceCount
Number of faces in the render step for this texture.
bool perFaceTextureIndexAvailable()
Check if textureindicies are available.
unsigned int nStrips() const
returns number of strips
void updatePickingEdges(ACG::GLState &_state, uint _offset=0)
ACG::Vec3f * perEdgeVertexBuffer()
get a pointer to the per edge vertex buffer
std::string textureIndexPropertyName_
Property for the per face texture index.
std::string perFaceTextureCoordinatePropertyName_
Property for the per face texture coordinates.
void updatePickingAny(ACG::GLState &_state)
Call this function to update the color picking array.
void buildStripPolyMesh(typename Mesh::HalfedgeHandle _start_hh, Strip &_strip, FaceHandles &_faces)
build a strip from a given halfedge (in both directions) of a polymesh
void updatePerHalfedgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
void updatePickingFacesPolymesh(ACG::GLState &_state)
Call this function to update the color picking array.
std::vector< ACG::Vec4f > perHalfedgeColorBuffer_
Per Edge color buffer.
std::vector< ACG::Vec4f > perFaceColorBuffer_
Buffer holding vertices for per face rendering.
int startOffset
Start offset in the face buffer.
std::vector< OpenMesh::FaceHandle > faceMap
This map contains for each vertex in the strips a handle to the face it closes.
void buildStripsTriMesh()
This method generates strips for triangle meshes.
ACG::Vec3f * perFaceNormalBuffer()
get a pointer to the per face normal buffer
StripsIterator begin() const
Access strips.
void setIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
StripProcessorT(Mesh &_mesh)
Default constructor.
bool perFaceTextureCoordinateAvailable()
Check if per Face Texture coordinates are available.
void updatePerEdgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
std::vector< ACG::Vec4uc > pickAnyColorBuf_
Call this function to update the color picking array.
ACG::Vec2f * perFacePerVertexTextureCoordBuffer()
get a pointer to the per face per vertex texture coor buffer
void buildStrips()
this method does the main work
ACG::Vec3f * perFacePerVertexNormalBuffer()
get a pointer to the per face per vertex normal buffer
void convexityTest(FaceHandle _fh)
Test whether face is convex.
Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh)
compute halfedge point compute visulization point for halfedge (shifted to interior of face) ...