Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Triangulate.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011, The Cinder Project: http://libcinder.org
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #include "cinder/TriMesh.h"
27 #include "cinder/PolyLine.h"
28 #include "cinder/Shape2d.h"
29 #include "cinder/Path2d.h"
30 
31 struct TESStesselator;
32 
33 namespace cinder {
34 
36 class Triangulator {
37  public:
39 
41  Triangulator();
43  Triangulator( const Path2d &path, float approximationScale = 1.0f );
45  Triangulator( const Shape2d &shape, float approximationScale = 1.0f );
47  Triangulator( const PolyLine2f &polyLine );
48 
50  void addShape( const Shape2d &path, float approximationScale = 1.0f );
52  void addPath( const Path2d &path, float approximationScale = 1.0f );
54  void addPolyLine( const PolyLine2f &polyLine );
55 
58 
59  class Exception : public cinder::Exception {
60  };
61 
62  protected:
63  void allocate();
64 
66  std::shared_ptr<TESStesselator> mTess;
67 };
68 
69 } // namespace cinder
Definition: Triangulate.h:38
void addShape(const Shape2d &path, float approximationScale=1.0f)
Adds a Shape2d to the tesselation. approximationScale represents how smooth the tesselation is...
Definition: Triangulate.cpp:82
Definition: Triangulate.h:38
void allocate()
Definition: Triangulate.cpp:66
Winding
Definition: Triangulate.h:38
Triangulator()
Default constructor.
Definition: Triangulate.cpp:61
void addPath(const Path2d &path, float approximationScale=1.0f)
Adds a Path2d to the tesselation. approximationScale represents how smooth the tesselation is...
Definition: Triangulate.cpp:90
Definition: Triangulate.h:38
TriMesh2d calcMesh(Winding winding=WINDING_ODD)
Performs the tesselation, returning a TriMesh2d.
Definition: Triangulate.cpp:101
Converts an arbitrary Shape2d into a TriMesh2d.
Definition: Triangulate.h:36
void addPolyLine(const PolyLine2f &polyLine)
Adds a PolyLine2f to the tesselation.
Definition: Triangulate.cpp:96
Definition: Triangulate.h:59
Definition: Path2d.h:35
Definition: Exception.h:32
Definition: Triangulate.h:38
Definition: TriMesh.h:167
int mAllocated
Definition: Triangulate.h:65
GLclampf f
Definition: GLee.h:15307
std::shared_ptr< TESStesselator > mTess
Definition: Triangulate.h:66
Definition: Shape2d.h:34
Definition: Triangulate.h:38