ReactOS 0.4.16-dev-336-gb667d82
Slicer Class Reference

#include <slicer.h>

Inheritance diagram for Slicer:
Collaboration diagram for Slicer:

Public Member Functions

 Slicer (Backend &)
 
 ~Slicer (void)
 
void slice (Arc_ptr)
 
void slice_old (Arc_ptr)
 
void slice_new (Arc_ptr)
 
void evalStream (primStream *)
 
void evalRBArray (rectBlockArray *rbArray, gridWrap *grid)
 
void outline (Arc_ptr)
 
void setstriptessellation (REAL, REAL)
 
void setisolines (int)
 
void set_ulinear (int ulinear_flag)
 
void set_vlinear (int vlinear_flag)
 
- Public Member Functions inherited from CoveAndTiler
 CoveAndTiler (Backend &)
 
 ~CoveAndTiler (void)
 
void coveAndTile (void)
 
- Public Member Functions inherited from TrimRegion
 TrimRegion ()
 
void init (REAL)
 
void advance (REAL, REAL, REAL)
 
void setDu (REAL)
 
void init (long, Arc_ptr)
 
void getPts (Arc_ptr)
 
void getPts (Backend &)
 
void getGridExtent (TrimVertex *, TrimVertex *)
 
void getGridExtent (void)
 
int canTile (void)
 
- Public Member Functions inherited from Mesher
 Mesher (Backend &)
 
 ~Mesher (void)
 
void init (unsigned int)
 
void mesh (void)
 
- Public Member Functions inherited from Hull
 Hull (void)
 
 ~Hull (void)
 
void init (void)
 
GridTrimVertexnextlower (GridTrimVertex *)
 
GridTrimVertexnextupper (GridTrimVertex *)
 

Private Member Functions

void outline (void)
 
void initGridlines (void)
 
void advanceGridlines (long)
 

Private Attributes

Backendbackend
 
REAL oneOverDu
 
REAL du
 
REAL dv
 
int isolines
 
int ulinear
 
int vlinear
 

Additional Inherited Members

- Public Attributes inherited from TrimRegion
Trimline left
 
Trimline right
 
Gridline top
 
Gridline bot
 
Uarray uarray
 

Detailed Description

Definition at line 49 of file slicer.h.

Constructor & Destructor Documentation

◆ Slicer()

Slicer::Slicer ( Backend b)

Definition at line 1181 of file slicer.cc.

1182 : CoveAndTiler( b ), Mesher( b ), backend( b )
1183{
1184 oneOverDu = 0;
1185 du = 0;
1186 dv = 0;
1187 isolines = 0;
1188 ulinear = 0;
1189 vlinear = 0;
1190}
Definition: mesher.h:47
REAL du
Definition: slicer.h:74
int vlinear
Definition: slicer.h:82
REAL oneOverDu
Definition: slicer.h:73
int ulinear
Definition: slicer.h:81
int isolines
Definition: slicer.h:75
REAL dv
Definition: slicer.h:74
Backend & backend
Definition: slicer.h:72
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ ~Slicer()

Slicer::~Slicer ( void  )

Definition at line 1192 of file slicer.cc.

1193{
1194}

Member Function Documentation

◆ advanceGridlines()

void Slicer::advanceGridlines ( long  )
private

◆ evalRBArray()

void Slicer::evalRBArray ( rectBlockArray rbArray,
gridWrap grid 
)

Definition at line 1001 of file slicer.cc.

1002{
1003 Int i,j,k;
1004
1005 Int n_vlines=grid->get_n_vlines();
1006 //the reason to switch the position of v_max and v_min is because of the
1007 //the orientation problem. glEvalMesh generates quad_strip clockwise, but
1008 //we need counter-clockwise.
1009 backend.surfgrid(grid->get_u_min(), grid->get_u_max(), grid->get_n_ulines()-1,
1010 grid->get_v_max(), grid->get_v_min(), n_vlines-1);
1011
1012
1013 for(j=0; j<rbArray->get_n_elements(); j++)
1014 {
1015 rectBlock* block = rbArray->get_element(j);
1016 Int low = block->get_lowGridLineIndex();
1017 Int high = block->get_upGridLineIndex();
1018
1019 for(k=0, i=high; i>low; i--, k++)
1020 {
1021 backend.surfmesh(block->get_leftIndices()[k+1], n_vlines-1-i, block->get_rightIndices()[k+1]-block->get_leftIndices()[k+1], 1);
1022 }
1023 }
1024}
void surfmesh(long, long, long, long)
Definition: backend.cc:136
void surfgrid(REAL, REAL, long, REAL, REAL, long)
Definition: backend.cc:126
Real get_u_min()
Definition: gridWrap.h:73
Int get_n_vlines()
Definition: gridWrap.h:72
Real get_v_max()
Definition: gridWrap.h:76
Real get_u_max()
Definition: gridWrap.h:74
Real get_v_min()
Definition: gridWrap.h:75
Int get_n_ulines()
Definition: gridWrap.h:71
rectBlock * get_element(Int i)
Definition: rectBlock.h:70
Int get_n_elements()
Definition: rectBlock.h:69
int Int
Definition: definitions.h:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369
static unsigned int block
Definition: xmlmemory.c:101

Referenced by slice_new().

◆ evalStream()

void Slicer::evalStream ( primStream pStream)

Definition at line 1027 of file slicer.cc.

1028{
1029 Int i,j,k;
1030 k=0;
1031/* TrimVertex X;*/
1032 TrimVertex *trimVert =/*&X*/ (TrimVertex*)malloc(sizeof(TrimVertex));
1033 trimVert -> nuid = 0;//???
1034 Real* vertices = pStream->get_vertices(); //for efficiency
1035 for(i=0; i<pStream->get_n_prims(); i++)
1036 {
1037
1038 //ith primitive has #vertices = lengths[i], type=types[i]
1039 switch(pStream->get_type(i)){
1041
1042 backend.bgntfan();
1043
1044 for(j=0; j<pStream->get_length(i); j++)
1045 {
1046 trimVert->param[0] = vertices[k];
1047 trimVert->param[1] = vertices[k+1];
1048 backend.tmeshvert(trimVert);
1049
1050// backend.tmeshvert(vertices[k], vertices[k+1]);
1051 k += 2;
1052 }
1053 backend.endtfan();
1054 break;
1055
1056 default:
1057 fprintf(stderr, "evalStream: not implemented yet\n");
1058 exit(1);
1059
1060 }
1061 }
1062 free(trimVert);
1063}
void tmeshvert(GridTrimVertex *)
Definition: backend.cc:269
void bgntfan()
Definition: backend.cc:185
void endtfan()
Definition: backend.cc:197
REAL param[2]
Definition: trimvertex.h:45
Int get_length(Int i)
Int get_n_prims()
Int get_type(Int i)
Real * get_vertices()
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
float Real
Definition: definitions.h:36
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
@ PRIMITIVE_STREAM_FAN
#define exit(n)
Definition: config.h:202

Referenced by Subdivider::drawSurfaces(), and slice_new().

◆ initGridlines()

void Slicer::initGridlines ( void  )
private

◆ outline() [1/2]

void Slicer::outline ( Arc_ptr  jarc)

Definition at line 1292 of file slicer.cc.

1293{
1294 jarc->markverts();
1295
1296 if( jarc->pwlArc->npts >= 2 ) {
1298 for( int j = jarc->pwlArc->npts-1; j >= 0; j-- )
1299 backend.linevert( &(jarc->pwlArc->pts[j]) );
1301 }
1302}
void linevert(TrimVertex *)
Definition: backend.cc:487
void bgnoutline(void)
Definition: backend.cc:477
void endoutline(void)
Definition: backend.cc:507

Referenced by Subdivider::outline().

◆ outline() [2/2]

void Slicer::outline ( void  )
private

Definition at line 1266 of file slicer.cc.

1267{
1269 Hull::init( );
1270
1272 while( (nextupper( &upper )) ) {
1273 if( upper.isGridVert() )
1274 backend.linevert( upper.g );
1275 else
1276 backend.linevert( upper.t );
1277 }
1279
1281 while( (nextlower( &lower )) ) {
1282 if( lower.isGridVert() )
1283 backend.linevert( lower.g );
1284 else
1285 backend.linevert( lower.t );
1286 }
1288}
Side upper
Definition: hull.h:63
void init(void)
Definition: hull.cc:63
GridTrimVertex * nextupper(GridTrimVertex *)
Definition: hull.cc:116
GridTrimVertex * nextlower(GridTrimVertex *)
Definition: hull.cc:142
Side lower
Definition: hull.h:62

Referenced by slice_old().

◆ set_ulinear()

void Slicer::set_ulinear ( int  ulinear_flag)
inline

Definition at line 63 of file slicer.h.

64 {
65 ulinear = ulinear_flag;
66 }

Referenced by Subdivider::tessellation().

◆ set_vlinear()

void Slicer::set_vlinear ( int  vlinear_flag)
inline

Definition at line 67 of file slicer.h.

68 {
69 vlinear = vlinear_flag;
70 }

Referenced by Subdivider::tessellation().

◆ setisolines()

void Slicer::setisolines ( int  x)

Definition at line 1197 of file slicer.cc.

1198{
1199 isolines = x;
1200}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by Subdivider::render().

◆ setstriptessellation()

void Slicer::setstriptessellation ( REAL  x,
REAL  y 
)

Definition at line 1203 of file slicer.cc.

1204{
1205 assert(x > 0 && y > 0);
1206 du = x;
1207 dv = y;
1208 setDu( du );
1209}
void setDu(REAL)
Definition: trimregion.cc:50
#define assert(x)
Definition: debug.h:53
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by Subdivider::tessellation().

◆ slice()

void Slicer::slice ( Arc_ptr  loop)

Definition at line 1165 of file slicer.cc.

1166{
1167#ifdef USE_READ_FLAG
1168 if(read_flag("flagFile"))
1169 slice_new(loop);
1170 else
1171 slice_old(loop);
1172
1173#else
1174 slice_new(loop);
1175#endif
1176
1177}
void slice_new(Arc_ptr)
Definition: slicer.cc:1068
void slice_old(Arc_ptr)
Definition: slicer.cc:1212

Referenced by Subdivider::render().

◆ slice_new()

void Slicer::slice_new ( Arc_ptr  loop)

Definition at line 1068 of file slicer.cc.

1069{
1070//count++;
1071//if(count == 78) count=1;
1072//printf("count=%i\n", count);
1073//if( ! (4<= count && count <=4)) return;
1074
1075
1076 Int num_ulines;
1077 Int num_vlines;
1078 Real uMin, uMax, vMin, vMax;
1079 Real mydu, mydv;
1080 uMin = uMax = loop->tail()[0];
1081 vMin = vMax = loop->tail()[1];
1082 mydu = (du>0)? du: -du;
1083 mydv = (dv>0)? dv: -dv;
1084
1085 for(Arc_ptr jarc=loop->next; jarc != loop; jarc = jarc->next)
1086 {
1087
1088 if(jarc->tail()[0] < uMin)
1089 uMin = jarc->tail()[0];
1090 if(jarc->tail()[0] > uMax)
1091 uMax = jarc->tail()[0];
1092 if(jarc->tail()[1] < vMin)
1093 vMin = jarc->tail()[1];
1094 if(jarc->tail()[1] > vMax)
1095 vMax = jarc->tail()[1];
1096 }
1097
1098 if (uMax == uMin)
1099 return; // prevent divide-by-zero. Jon Perry. 17 June 2002
1100
1101 if(mydu > uMax - uMin)
1102 num_ulines = 2;
1103 else
1104 {
1105 num_ulines = 3 + (Int) ((uMax-uMin)/mydu);
1106 }
1107 if(mydv>=vMax-vMin)
1108 num_vlines = 2;
1109 else
1110 {
1111 num_vlines = 2+(Int)((vMax-vMin)/mydv);
1112 }
1113
1114 Int isRect = is_rect(loop);
1115
1116 if(isRect && (num_ulines<=2 || num_vlines<=2))
1117 {
1118 if(vlinear)
1120 else if(ulinear)
1121 triangulateRect(loop, backend, -1, ulinear, vlinear);
1122 else
1124 }
1125
1126 else if(isRect)
1127 {
1128 triangulateRectGen(loop, num_ulines-2, num_vlines-2, backend);
1129 }
1130 else if( (num_ulines<=2 || num_vlines <=2) && ulinear)
1131 {
1133 }
1134 else if( (!ulinear) && (!vlinear) && (num_ulines == 2) && (num_vlines > 2))
1135 {
1137 }
1138 else
1139 {
1140 directedLine* poly = arcLoopToDLineLoop(loop);
1141
1142 gridWrap grid(num_ulines, num_vlines, uMin, uMax, vMin, vMax);
1143 primStream pStream(20, 20);
1144 rectBlockArray rbArray(20);
1145
1146 sampleMonoPoly(poly, &grid, ulinear, vlinear, &pStream, &rbArray);
1147
1148 evalStream(&pStream);
1149
1150 evalRBArray(&rbArray, &grid);
1151
1152#ifdef COUNT_TRIANGLES
1153 num_triangles += pStream.num_triangles();
1154 num_quads += rbArray.num_quads();
1155#endif
1157 }
1158
1159#ifdef COUNT_TRIANGLES
1160 printf("num_triangles=%i\n", num_triangles);
1161 printf("num_quads = %i\n", num_quads);
1162#endif
1163}
void evalStream(primStream *)
Definition: slicer.cc:1027
void evalRBArray(rectBlockArray *rbArray, gridWrap *grid)
Definition: slicer.cc:1001
void deleteSinglePolygonWithSline()
directedLine * arcLoopToDLineLoop(Arc_ptr loop)
Definition: slicer.cc:948
Int compV2InY(Real A[2], Real B[2])
class Arc * Arc_ptr
Definition: arc.h:50
#define printf
Definition: freeldr.h:97
void monoTriangulationFunBackend(Arc_ptr loop, Int(*compFun)(Real *, Real *), Backend *backend)
void sampleMonoPoly(directedLine *polygon, gridWrap *grid, Int ulinear, Int vlinear, primStream *pStream, rectBlockArray *rbArray)
static void triangulateRectGen(Arc_ptr loop, int n_ulines, int n_vlines, Backend &backend)
Definition: slicer.cc:778
static Int is_rect(Arc_ptr loop)
Definition: slicer.cc:220
static void triangulateRect(Arc_ptr loop, Backend &backend, int TB_or_LR, int ulinear, int vlinear)
Definition: slicer.cc:319
int vMax
Definition: tritemp.h:142
int vMin
Definition: tritemp.h:142

Referenced by slice().

◆ slice_old()

void Slicer::slice_old ( Arc_ptr  loop)

Definition at line 1212 of file slicer.cc.

1213{
1214 loop->markverts();
1215
1216 Arc_ptr extrema[4];
1217 loop->getextrema( extrema );
1218
1219 unsigned int npts = loop->numpts();
1220 TrimRegion::init( npts, extrema[0] );
1221
1222 Mesher::init( npts );
1223
1224 long ulines = uarray.init( du, extrema[1], extrema[3] );
1225//printf("ulines = %i\n", ulines);
1226 Varray varray;
1227 long vlines = varray.init( dv, extrema[0], extrema[2] );
1228//printf("vlines = %i\n", vlines);
1229 long botv = 0;
1230 long topv;
1231 TrimRegion::init( varray.varray[botv] );
1232 getGridExtent( &extrema[0]->pwlArc->pts[0], &extrema[0]->pwlArc->pts[0] );
1233
1234 for( long quad=0; quad<varray.numquads; quad++ ) {
1236 uarray.uarray[ulines-1],
1237 ulines-1,
1238 varray.vval[quad],
1239 varray.vval[quad+1],
1240 varray.voffset[quad+1] - varray.voffset[quad] );
1241
1242 for( long i=varray.voffset[quad]+1; i <= varray.voffset[quad+1]; i++ ) {
1243 topv = botv++;
1244 advance( topv - varray.voffset[quad],
1245 botv - varray.voffset[quad],
1246 varray.varray[botv] );
1247 if( i == vlines )
1248 getPts( extrema[2] );
1249 else
1250 getPts( backend );
1251 getGridExtent();
1252 if( isolines ) {
1253 outline();
1254 } else {
1255 if( canTile() )
1256 coveAndTile();
1257 else
1258 mesh();
1259 }
1260 }
1261 }
1262}
void coveAndTile(void)
Definition: coveandtiler.cc:78
void mesh(void)
Definition: mesher.cc:141
void outline(void)
Definition: slicer.cc:1266
int canTile(void)
Definition: trimregion.cc:102
void getGridExtent(void)
Definition: trimregion.cc:80
Uarray uarray
Definition: trimregion.h:57
void init(REAL)
Definition: trimregion.h:73
void advance(REAL, REAL, REAL)
Definition: trimregion.h:79
void getPts(Arc_ptr)
Definition: trimregion.cc:66
REAL * uarray
Definition: uarray.h:52
long init(REAL, Arc_ptr, Arc_ptr)
Definition: uarray.cc:59
Definition: varray.h:43
long numquads
Definition: varray.h:51
REAL * varray
Definition: varray.h:48
long init(REAL, Arc *, Arc *)
Definition: varray.cc:98
long voffset[1000]
Definition: varray.h:50
REAL vval[1000]
Definition: varray.h:49
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
Definition: quads.c:63

Referenced by slice().

Member Data Documentation

◆ backend

Backend& Slicer::backend
private

Definition at line 72 of file slicer.h.

Referenced by evalRBArray(), evalStream(), outline(), slice_new(), and slice_old().

◆ du

REAL Slicer::du
private

Definition at line 74 of file slicer.h.

Referenced by setstriptessellation(), slice_new(), slice_old(), and Slicer().

◆ dv

REAL Slicer::dv
private

Definition at line 74 of file slicer.h.

Referenced by setstriptessellation(), slice_new(), slice_old(), and Slicer().

◆ isolines

int Slicer::isolines
private

Definition at line 75 of file slicer.h.

Referenced by setisolines(), slice_old(), and Slicer().

◆ oneOverDu

REAL Slicer::oneOverDu
private

Definition at line 73 of file slicer.h.

Referenced by Slicer().

◆ ulinear

int Slicer::ulinear
private

Definition at line 81 of file slicer.h.

Referenced by set_ulinear(), slice_new(), and Slicer().

◆ vlinear

int Slicer::vlinear
private

Definition at line 82 of file slicer.h.

Referenced by set_vlinear(), slice_new(), and Slicer().


The documentation for this class was generated from the following files: