Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > DoxygensampledLine.cc
Go to the documentation of this file.
00001 /* 00002 ** License Applicability. Except to the extent portions of this file are 00003 ** made subject to an alternative license as permitted in the SGI Free 00004 ** Software License B, Version 1.1 (the "License"), the contents of this 00005 ** file are subject only to the provisions of the License. You may not use 00006 ** this file except in compliance with the License. You may obtain a copy 00007 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 00008 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: 00009 ** 00010 ** http://oss.sgi.com/projects/FreeB 00011 ** 00012 ** Note that, as provided in the License, the Software is distributed on an 00013 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS 00014 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND 00015 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A 00016 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 00017 ** 00018 ** Original Code. The Original Code is: OpenGL Sample Implementation, 00019 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, 00020 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. 00021 ** Copyright in any portions created by third parties is as indicated 00022 ** elsewhere herein. All Rights Reserved. 00023 ** 00024 ** Additional Notice Provisions: The application programming interfaces 00025 ** established by SGI in conjunction with the Original Code are The 00026 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released 00027 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version 00028 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X 00029 ** Window System(R) (Version 1.3), released October 19, 1998. This software 00030 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation 00031 ** published by SGI, but has not been independently verified as being 00032 ** compliant with the OpenGL(R) version 1.2.1 Specification. 00033 ** 00034 ** $Date: 2006-03-12 00:07:02 +0000 (Sun, 12 Mar 2006) $ $Revision: 1.1 $ 00035 */ 00036 /* 00037 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/nurbtess/sampledLine.cc,v 1.1 2004/02/02 16:39:15 navaraf Exp $ 00038 */ 00039 00040 #include <stdlib.h> 00041 #include <stdio.h> 00042 #include <math.h> //for fabs() 00043 #include "glimports.h" 00044 #include "zlassert.h" 00045 #include "sampledLine.h" 00046 00047 void sampledLine::setPoint(Int i, Real p[2]) 00048 { 00049 points[i][0]=p[0]; 00050 points[i][1]=p[1]; 00051 } 00052 00053 00054 /*insert this single line in front of the oldList*/ 00055 sampledLine* sampledLine::insert(sampledLine *oldList) 00056 { 00057 next = oldList; 00058 return this; 00059 } 00060 00061 void sampledLine::deleteList() 00062 { 00063 sampledLine *temp, *tempNext; 00064 for(temp = this; temp != NULL; temp = tempNext) 00065 { 00066 tempNext = temp->next; 00067 delete temp; 00068 } 00069 } 00070 00071 00072 /*space of points[][2] is allocated*/ 00073 sampledLine::sampledLine(Int n_points) 00074 { 00075 npoints = n_points; 00076 points = (Real2*) malloc(sizeof(Real2) * n_points); 00077 assert(points); 00078 next = NULL; 00079 } 00080 00081 /*space of points[][2] is allocated and 00082 *points are copied 00083 */ 00084 sampledLine::sampledLine(Int n_points, Real2 pts[]) 00085 { 00086 int i; 00087 npoints = n_points; 00088 points = (Real2*) malloc(sizeof(Real2) * n_points); 00089 assert(points); 00090 for(i=0; i<npoints; i++) { 00091 points[i][0] = pts[i][0]; 00092 points[i][1] = pts[i][1]; 00093 } 00094 next = NULL; 00095 } 00096 00097 sampledLine::sampledLine(Real pt1[2], Real pt2[2]) 00098 { 00099 npoints = 2; 00100 points = (Real2*) malloc(sizeof(Real2) * 2); 00101 assert(points); 00102 points[0][0] = pt1[0]; 00103 points[0][1] = pt1[1]; 00104 points[1][0] = pt2[0]; 00105 points[1][1] = pt2[1]; 00106 next = NULL; 00107 } 00108 00109 //needs tp call init to setup 00110 sampledLine::sampledLine() 00111 { 00112 } 00113 00114 //warning: ONLY pointer is copies!!! 00115 void sampledLine::init(Int n_points, Real2 *pts) 00116 { 00117 npoints = n_points; 00118 points = pts; 00119 } 00120 00121 /*points[] is dealocated 00122 */ 00123 sampledLine::~sampledLine() 00124 { 00125 free(points); 00126 } 00127 00128 void sampledLine::print() 00129 { 00130 int i; 00131 printf("npoints=%i\n", npoints); 00132 00133 for(i=0; i<npoints; i++){ 00134 printf("(%f,%f)\n", points[i][0], points[i][1]); 00135 } 00136 00137 } 00138 00139 void sampledLine::tessellate(Real u_reso, Real v_reso) 00140 { 00141 int i; 00142 00143 Int nu, nv, n; 00144 nu = 1+(Int) (fabs((points[npoints-1][0] - points[0][0])) * u_reso); 00145 nv = 1+(Int) (fabs((points[npoints-1][1] - points[0][1])) * v_reso); 00146 00147 if(nu > nv) n = nu; 00148 else 00149 n = nv; 00150 if(n<1) 00151 n = 1; 00152 //du dv could be negative 00153 Real du = (points[npoints-1][0] - points[0][0])/n; 00154 Real dv = (points[npoints-1][1] - points[0][1])/n; 00155 Real2 *temp = (Real2*) malloc(sizeof(Real2) * (n+1)); 00156 assert(temp); 00157 00158 Real u,v; 00159 for(i=0, u=points[0][0], v=points[0][1]; i<n; i++, u+=du, v+=dv) 00160 { 00161 temp[i][0] = u; 00162 temp[i][1] = v; 00163 } 00164 temp[n][0] = points[npoints-1][0]; 00165 temp[n][1] = points[npoints-1][1]; 00166 00167 free(points); 00168 00169 npoints = n+1; 00170 points = temp; 00171 00172 } 00173 00174 void sampledLine::tessellateAll(Real u_reso, Real v_reso) 00175 { 00176 sampledLine* temp; 00177 for(temp = this; temp != NULL; temp = temp->next) 00178 { 00179 temp->tessellate(u_reso, v_reso); 00180 } 00181 } Generated on Sat May 26 2012 04:22:20 for ReactOS by
1.7.6.1
|