Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
normal.h File Reference
#include "tess.h"
+ Include dependency graph for normal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void __gl_projectPolygon (GLUtesselator *tess)
 

Function Documentation

◆ __gl_projectPolygon()

void __gl_projectPolygon ( GLUtesselator tess)
199{
200 GLUvertex *v, *vHead = &tess->mesh->vHead;
201 GLdouble norm[3];
202 GLdouble *sUnit, *tUnit;
203 int i, computedNormal = FALSE;
204
205 norm[0] = tess->normal[0];
206 norm[1] = tess->normal[1];
207 norm[2] = tess->normal[2];
208 if( norm[0] == 0 && norm[1] == 0 && norm[2] == 0 ) {
209 ComputeNormal( tess, norm );
210 computedNormal = TRUE;
211 }
212 sUnit = tess->sUnit;
213 tUnit = tess->tUnit;
214 i = LongAxis( norm );
215
216#if defined(FOR_TRITE_TEST_PROGRAM) || defined(TRUE_PROJECT)
217 /* Choose the initial sUnit vector to be approximately perpendicular
218 * to the normal.
219 */
220 Normalize( norm );
221
222 sUnit[i] = 0;
223 sUnit[(i+1)%3] = S_UNIT_X;
224 sUnit[(i+2)%3] = S_UNIT_Y;
225
226 /* Now make it exactly perpendicular */
227 w = Dot( sUnit, norm );
228 sUnit[0] -= w * norm[0];
229 sUnit[1] -= w * norm[1];
230 sUnit[2] -= w * norm[2];
231 Normalize( sUnit );
232
233 /* Choose tUnit so that (sUnit,tUnit,norm) form a right-handed frame */
234 tUnit[0] = norm[1]*sUnit[2] - norm[2]*sUnit[1];
235 tUnit[1] = norm[2]*sUnit[0] - norm[0]*sUnit[2];
236 tUnit[2] = norm[0]*sUnit[1] - norm[1]*sUnit[0];
237 Normalize( tUnit );
238#else
239 /* Project perpendicular to a coordinate axis -- better numerically */
240 sUnit[i] = 0;
241 sUnit[(i+1)%3] = S_UNIT_X;
242 sUnit[(i+2)%3] = S_UNIT_Y;
243
244 tUnit[i] = 0;
245 tUnit[(i+1)%3] = (norm[i] > 0) ? -S_UNIT_Y : S_UNIT_Y;
246 tUnit[(i+2)%3] = (norm[i] > 0) ? S_UNIT_X : -S_UNIT_X;
247#endif
248
249 /* Project the vertices onto the sweep plane */
250 for( v = vHead->next; v != vHead; v = v->next ) {
251 v->s = Dot( v->coords, sUnit );
252 v->t = Dot( v->coords, tUnit );
253 }
254 if( computedNormal ) {
255 CheckOrientation( tess );
256 }
257}
double GLdouble
Definition glu-libtess.h:65
GLUvertex vHead
Definition mesh.h:164
GLdouble t
Definition mesh.h:122
GLdouble coords[3]
Definition mesh.h:121
GLdouble s
Definition mesh.h:122
GLUvertex * next
Definition mesh.h:115
Definition mesh.h:114
static void ComputeNormal(GLUtesselator *tess, GLdouble norm[3])
Definition normal.c:76
#define S_UNIT_X
Definition normal.c:190
static int LongAxis(GLdouble v[3])
Definition normal.c:67
#define TRUE
Definition normal.c:43
#define FALSE
Definition normal.c:46
static void CheckOrientation(GLUtesselator *tess)
Definition normal.c:141
#define Dot(u, v)
Definition normal.c:49
#define S_UNIT_Y
Definition normal.c:191
GLdouble tUnit[3]
Definition tess.h:75
GLdouble sUnit[3]
Definition tess.h:74
GLdouble normal[3]
Definition tess.h:73
GLUmesh * mesh
Definition tess.h:66

References CheckOrientation(), ComputeNormal(), GLUvertex::coords, Dot, FALSE, LongAxis(), GLUtesselator::mesh, GLUvertex::next, GLUtesselator::normal, GLUvertex::s, S_UNIT_X, S_UNIT_Y, GLUtesselator::sUnit, GLUvertex::t, TRUE, GLUtesselator::tUnit, and GLUmesh::vHead.

Referenced by gluTessEndPolygon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: