ReactOS  0.4.11-dev-721-g95bc44e
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 ( 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 }
int vlinear
Definition: slicer.h:82
int isolines
Definition: slicer.h:75
REAL du
Definition: slicer.h:74
Mesher(Backend &)
Definition: mesher.cc:55
REAL dv
Definition: slicer.h:74
CoveAndTiler(Backend &)
Definition: coveandtiler.cc:52
int ulinear
Definition: slicer.h:81
Backend & backend
Definition: slicer.h:72
REAL oneOverDu
Definition: slicer.h:73
Slicer::~Slicer ( void  )

Definition at line 1192 of file slicer.cc.

1193 {
1194 }

Member Function Documentation

void Slicer::advanceGridlines ( long  )
private
void Slicer::evalRBArray ( rectBlockArray rbArray,
gridWrap grid 
)

Definition at line 1001 of file slicer.cc.

Referenced by slice_new().

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 }
static unsigned int block
Definition: xmlmemory.c:118
Int get_n_vlines()
Definition: gridWrap.h:72
void surfmesh(long, long, long, long)
Definition: backend.cc:136
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
Int * get_leftIndices()
Definition: rectBlock.h:51
Real get_u_max()
Definition: gridWrap.h:74
GLenum GLclampf GLint i
Definition: glfuncs.h:14
Real get_u_min()
Definition: gridWrap.h:73
Int get_upGridLineIndex()
Definition: rectBlock.h:49
Real get_v_min()
Definition: gridWrap.h:75
Int get_n_elements()
Definition: rectBlock.h:69
Int get_n_ulines()
Definition: gridWrap.h:71
void surfgrid(REAL, REAL, long, REAL, REAL, long)
Definition: backend.cc:126
Real get_v_max()
Definition: gridWrap.h:76
Backend & backend
Definition: slicer.h:72
Int get_lowGridLineIndex()
Definition: rectBlock.h:50
int k
Definition: mpi.c:3369
rectBlock * get_element(Int i)
Definition: rectBlock.h:70
Int * get_rightIndices()
Definition: rectBlock.h:52
int Int
Definition: definitions.h:37
void Slicer::evalStream ( primStream pStream)

Definition at line 1027 of file slicer.cc.

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

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)){
1040  case PRIMITIVE_STREAM_FAN:
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 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
void bgntfan()
Definition: backend.cc:185
Int get_length(Int i)
#define free
Definition: debug_ros.c:5
void tmeshvert(GridTrimVertex *)
Definition: backend.cc:269
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void endtfan()
Definition: backend.cc:197
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Real * get_vertices()
Int get_type(Int i)
float Real
Definition: definitions.h:36
REAL param[2]
Definition: trimvertex.h:45
Int get_n_prims()
FILE * stderr
#define malloc
Definition: debug_ros.c:4
void exit(int exitcode)
Definition: _exit.c:33
Backend & backend
Definition: slicer.h:72
int k
Definition: mpi.c:3369
int Int
Definition: definitions.h:37
void Slicer::initGridlines ( void  )
private
void Slicer::outline ( Arc_ptr  jarc)

Definition at line 1292 of file slicer.cc.

Referenced by Subdivider::outline().

1293 {
1294  jarc->markverts();
1295 
1296  if( jarc->pwlArc->npts >= 2 ) {
1297  backend.bgnoutline();
1298  for( int j = jarc->pwlArc->npts-1; j >= 0; j-- )
1299  backend.linevert( &(jarc->pwlArc->pts[j]) );
1300  backend.endoutline();
1301  }
1302 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
void endoutline(void)
Definition: backend.cc:507
void linevert(TrimVertex *)
Definition: backend.cc:487
void bgnoutline(void)
Definition: backend.cc:477
Backend & backend
Definition: slicer.h:72
void Slicer::outline ( void  )
private

Definition at line 1266 of file slicer.cc.

Referenced by slice_old().

1267 {
1269  Hull::init( );
1270 
1271  backend.bgnoutline();
1272  while( (nextupper( &upper )) ) {
1273  if( upper.isGridVert() )
1274  backend.linevert( upper.g );
1275  else
1276  backend.linevert( upper.t );
1277  }
1278  backend.endoutline();
1279 
1280  backend.bgnoutline();
1281  while( (nextlower( &lower )) ) {
1282  if( lower.isGridVert() )
1283  backend.linevert( lower.g );
1284  else
1285  backend.linevert( lower.t );
1286  }
1287  backend.endoutline();
1288 }
TrimVertex * t
GridTrimVertex * nextupper(GridTrimVertex *)
Definition: hull.cc:116
void endoutline(void)
Definition: backend.cc:507
Side upper
Definition: hull.h:63
GridTrimVertex * nextlower(GridTrimVertex *)
Definition: hull.cc:142
GridVertex * g
Side lower
Definition: hull.h:62
void linevert(TrimVertex *)
Definition: backend.cc:487
void init(void)
Definition: hull.cc:63
void bgnoutline(void)
Definition: backend.cc:477
Backend & backend
Definition: slicer.h:72
void Slicer::set_ulinear ( int  ulinear_flag)
inline

Definition at line 63 of file slicer.h.

Referenced by Subdivider::tessellation().

64  {
65  ulinear = ulinear_flag;
66  }
int ulinear
Definition: slicer.h:81
void Slicer::set_vlinear ( int  vlinear_flag)
inline

Definition at line 67 of file slicer.h.

Referenced by Subdivider::tessellation().

68  {
69  vlinear = vlinear_flag;
70  }
int vlinear
Definition: slicer.h:82
void Slicer::setisolines ( int  x)

Definition at line 1197 of file slicer.cc.

Referenced by Subdivider::render().

1198 {
1199  isolines = x;
1200 }
int isolines
Definition: slicer.h:75
INT x
Definition: msvc.h:62
void Slicer::setstriptessellation ( REAL  x,
REAL  y 
)

Definition at line 1203 of file slicer.cc.

Referenced by Subdivider::tessellation().

1204 {
1205  assert(x > 0 && y > 0);
1206  du = x;
1207  dv = y;
1208  setDu( du );
1209 }
#define assert(x)
Definition: debug.h:53
REAL du
Definition: slicer.h:74
REAL dv
Definition: slicer.h:74
void setDu(REAL)
Definition: trimregion.cc:50
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void Slicer::slice ( Arc_ptr  loop)

Definition at line 1165 of file slicer.cc.

Referenced by Subdivider::render().

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 }
VARIANT loop
void slice_old(Arc_ptr)
Definition: slicer.cc:1212
void slice_new(Arc_ptr)
Definition: slicer.cc:1068
void Slicer::slice_new ( Arc_ptr  loop)

Definition at line 1068 of file slicer.cc.

Referenced by slice().

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)
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  {
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 }
int vlinear
Definition: slicer.h:82
VARIANT loop
const SWvertex * vMax
Definition: s_aatritemp.h:45
void deleteSinglePolygonWithSline()
Int compV2InY(Real A[2], Real B[2])
void sampleMonoPoly(directedLine *polygon, gridWrap *grid, Int ulinear, Int vlinear, primStream *pStream, rectBlockArray *rbArray)
directedLine * arcLoopToDLineLoop(Arc_ptr loop)
Definition: slicer.cc:948
static Int is_rect(Arc_ptr loop)
Definition: slicer.cc:220
REAL du
Definition: slicer.h:74
const SWvertex * vMin
Definition: s_aatritemp.h:45
void monoTriangulationFunBackend(Arc_ptr loop, Int(*compFun)(Real *, Real *), Backend *backend)
class Arc * Arc_ptr
Definition: arc.h:50
REAL dv
Definition: slicer.h:74
void evalStream(primStream *)
Definition: slicer.cc:1027
float Real
Definition: definitions.h:36
static void triangulateRect(Arc_ptr loop, Backend &backend, int TB_or_LR, int ulinear, int vlinear)
Definition: slicer.cc:319
static void triangulateRectGen(Arc_ptr loop, int n_ulines, int n_vlines, Backend &backend)
Definition: slicer.cc:778
int ulinear
Definition: slicer.h:81
Backend & backend
Definition: slicer.h:72
void evalRBArray(rectBlockArray *rbArray, gridWrap *grid)
Definition: slicer.cc:1001
#define printf
Definition: config.h:203
int Int
Definition: definitions.h:37
void Slicer::slice_old ( Arc_ptr  loop)

Definition at line 1212 of file slicer.cc.

Referenced by slice().

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 }
long numquads
Definition: varray.h:51
void getGridExtent(void)
Definition: trimregion.cc:80
VARIANT loop
void init(REAL)
Definition: trimregion.h:73
Definition: varray.h:43
void mesh(void)
Definition: mesher.cc:141
int isolines
Definition: slicer.h:75
GLenum GLclampf GLint i
Definition: glfuncs.h:14
REAL vval[1000]
Definition: varray.h:49
void outline(void)
Definition: slicer.cc:1266
REAL * uarray
Definition: uarray.h:52
Uarray uarray
Definition: trimregion.h:57
REAL du
Definition: slicer.h:74
void getPts(Arc_ptr)
Definition: trimregion.cc:66
long init(REAL, Arc *, Arc *)
Definition: varray.cc:98
void init(void)
Definition: hull.cc:63
void coveAndTile(void)
Definition: coveandtiler.cc:78
class Arc * Arc_ptr
Definition: arc.h:50
REAL dv
Definition: slicer.h:74
void advance(REAL, REAL, REAL)
Definition: trimregion.h:79
int canTile(void)
Definition: trimregion.cc:102
long init(REAL, Arc_ptr, Arc_ptr)
Definition: uarray.cc:59
void surfgrid(REAL, REAL, long, REAL, REAL, long)
Definition: backend.cc:126
Backend & backend
Definition: slicer.h:72
long voffset[1000]
Definition: varray.h:50
REAL * varray
Definition: varray.h:48

Member Data Documentation

Backend& Slicer::backend
private

Definition at line 72 of file slicer.h.

REAL Slicer::du
private

Definition at line 74 of file slicer.h.

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

REAL Slicer::dv
private

Definition at line 74 of file slicer.h.

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

int Slicer::isolines
private

Definition at line 75 of file slicer.h.

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

REAL Slicer::oneOverDu
private

Definition at line 73 of file slicer.h.

Referenced by Slicer().

int Slicer::ulinear
private

Definition at line 81 of file slicer.h.

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

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: