MCPcopy Create free account
hub / github.com/ImageEngine/cortex / mesh

Method mesh

src/IECoreScene/Font.cpp:134–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134MeshPrimitivePtr Font::Mesher::mesh( FT_Outline *outline )
135{
136 // break the contours down into our m_pointVectors
137 // structure
138 FT_Outline_Funcs_ funcs;
139 funcs.move_to = moveTo;
140 funcs.line_to = lineTo;
141 funcs.conic_to = conicTo;
142 funcs.cubic_to = cubicTo;
143 funcs.shift = 0;
144 funcs.delta = 0;
145 FT_Outline_Decompose( outline, &funcs, this );
146
147 // reverse the contours if necessary
148 if( !(outline->flags & FT_OUTLINE_REVERSE_FILL) )
149 {
150 for( unsigned i=0; i<m_pointVectors.size(); i++ )
151 {
152 std::reverse( m_pointVectors[i].begin(), m_pointVectors[i].end() );
153 }
154 }
155
156 // sort into outlines and holes
157 LoopVector outlines;
158 BoundVector outlineBounds;
159 LoopVector holes;
160 BoundVector holeBounds;
161 vector<bool> holeUsed;
162
163 for( unsigned i=0; i<m_pointVectors.size(); i++ )
164 {
165 if( m_pointVectors[i].size() )
166 {
167 // freetype explicitly joins the last segment to the beginning
168 // of the first, which gives us two coincident points. we don't
169 // want that as it confuses the triangulator.
170 m_pointVectors[i].resize( m_pointVectors[i].size() - 1 );
171 }
172 if( !m_pointVectors[i].size() )
173 {
174 continue;
175 }
176 if( polygonWinding( m_pointVectors[i].begin(), m_pointVectors[i].end() )==ClockwiseWinding )
177 {
178 holes.push_back( Loop( m_pointVectors[i].begin(), m_pointVectors[i].end() ) );
179 Box3f b = polygonBound( m_pointVectors[i].begin(), m_pointVectors[i].end() );
180 holeBounds.push_back( Box2f( V2f( b.min.x, b.min.y ), V2f( b.max.x, b.max.y ) ) );
181 holeUsed.push_back( false );
182 }
183 else
184 {
185 outlines.push_back( Loop( m_pointVectors[i].begin(), m_pointVectors[i].end() ) );
186 Box3f b = polygonBound( m_pointVectors[i].begin(), m_pointVectors[i].end() );
187 outlineBounds.push_back( Box2f( V2f( b.min.x, b.min.y ), V2f( b.max.x, b.max.y ) ) );
188 }
189 }
190
191 // triangulate each outline, along with any holes which should be associated with it

Callers 4

cachedMeshMethod · 0.45
segmentMethod · 0.45
mesh1Function · 0.45
mesh2Function · 0.45

Calls 5

triangulateMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected