Class describing a bspline surface. More...
#include <util/bsurface.h>
Public Member Functions | |
BSplineSurface (const BSplineSurface &B) | |
void | CalcFootprint (unsigned int i, unsigned int j, unsigned int level) |
void | CalcPreImage (int i, int j, unsigned int level) |
Point3d | ContourEval (double u) const |
Point2d | ContourInverse (double u) const |
vector< vector< vector < Point3d > > > * | ControlPoints () |
double | ConvertU (double u) const |
double | ConvertV (double v) const |
int | DimU () |
int | DimV () |
void | DisplayControlPoints (Matrix3d A, Point3d t) |
void | DisplaySurface () |
void | DoubleU () |
void | DoubleV () |
void | Draw (int uDiv, int vDiv) |
Render the object in the current OpenGL context. | |
void | DrawCircle (double x, double y, double z, double w) |
bool | EditLevel (unsigned int i) |
Point3d | Eval (double u, double v) const |
Point3d | EvalN (double u, double v) const |
Point3d | EvalU (double u, int m) const |
void | GetControlMesh (int i, int j, double &x, double &y, double &z) |
void | HalveU () |
void | HalveV () |
float | HasContracted (BSplineSurface *b, float u, float v) |
bool | InsideContour (vector< Point3d > shape, Point3d to_check) |
BSplineSurface | Interpolate (const BSplineSurface &BS1, const BSplineSurface &BS2, double alpha, int num_rows, int num_cols) const |
void | IsShaded (bool shaded) |
bool | LoadPatch (const char *fname) |
BSplineSurface | LowestRes () |
unsigned int | LowestResDim (int i) |
void | MovePoint (Point3d m, Matrix3d A, Point3d t) |
void | MoveRegion (Point3d dis) |
Point3d | NormalEval (double u, double v) const |
Point3d | NormalEvalN (double u, double v) const |
BSplineSurface | operator* (const double c) |
BSplineSurface | operator+ (const BSplineSurface &B) |
BSplineSurface | operator- (const BSplineSurface &B) |
BSplineSurface & | operator= (const BSplineSurface &B) |
Point3d | PartialU (double u, double v) const |
Point3d | PartialUN (double u, double v) const |
Point3d | PartialV (double u, double v) const |
Point3d | PartialVN (double u, double v) const |
bool | PointInversion (Point2d &surf_p, Point2d p0, Point3d q) const |
bool | PointInversionN (Point2d &surf_p, Point2d p0, Point3d q) const |
void | Recompute () |
Force recomputation of the surface. | |
void | RenderFootprint () |
void | RenderLine (int i1, int j1, int level1, int i2, int j2, int level2) |
void | RenderSupport (unsigned int i, unsigned int j, unsigned int level) |
void | Reset (int u, int v) |
void | Resize (unsigned int num_rows, unsigned int num_cols) |
bool | SavePatch (const char *fname) |
vector< int * > | SelectedIndicies () |
int | SelectedLevel () |
void | SelectPoint (Point3d n, Matrix3d A, Point3d t) |
void | SelectRegion (vector< Point3d > s_reg, Matrix3d A, Point3d t) |
void | SetColors (double c1[3], double c2[3], double c3[3]) |
void | SetControlMesh (int i, int j, double x, double y, double z) |
void | SetPrecision (double u, double v) |
void | SetPrevious (BSplineSurface *b) |
void | ToggleControlMesh () |
void | ToggleNormals () |
void | TogglePolygonMesh () |
void | ToggleShadedMesh () |
void | UpdateFootprint () |
void | VisualizeContraction (bool c) |
Interface to LPFG | |
void | BoundingBox (double &x1, double &y1, double &z1, double &x2, double &y2, double &z2) |
Compute the bounding box of the surface. | |
bool | IsTextured () const |
True if a texture is attached to the surface. | |
void | Load (const char *fname, double scale, int TextureId, int divU, int divV) |
Load a file describing the BSplineSurface. | |
void | Reread () |
Reread the last loaded file (if modified). | |
int | TextureId () const |
Get the texture id attached to the object (0 if none). | |
void | Transform (Matrix3d M, double x, double y, double z) |
Transform the surface using a 3D linear transformation and a translation. |
Class describing a bspline surface.
Definition at line 37 of file bsurface.h.
void util::Shapes::BSplineSurface::BoundingBox | ( | double & | x1, | |
double & | y1, | |||
double & | z1, | |||
double & | x2, | |||
double & | y2, | |||
double & | z2 | |||
) |
Compute the bounding box of the surface.
Definition at line 65 of file bsurface.cpp.
00066 { 00067 x1=x2=Control_points[0][0][0][0]; 00068 y1=y2=Control_points[0][0][0][1]; 00069 z1=z2=Control_points[0][0][0][2]; 00070 00071 for (unsigned int i=0; i<Control_points[0].size(); i++) 00072 for (unsigned int j=0; j<Control_points[0][0].size(); j++) { 00073 00074 if(Control_points[0][i][j][0]<x1) 00075 x1=Control_points[0][i][j][0]; 00076 00077 if(Control_points[0][i][j][1]<y1) 00078 y1=Control_points[0][i][j][1]; 00079 00080 if(Control_points[0][i][j][2]<z1) 00081 z1=Control_points[0][i][j][2]; 00082 00083 if(Control_points[0][i][j][0]>x2) 00084 x2=Control_points[0][i][j][0]; 00085 00086 if(Control_points[0][i][j][1]>y2) 00087 y2=Control_points[0][i][j][1]; 00088 00089 if(Control_points[0][i][j][2]>z2) 00090 z2=Control_points[0][i][j][2]; 00091 } 00092 }
void util::Shapes::BSplineSurface::Draw | ( | int | uDiv, | |
int | vDiv | |||
) |
Render the object in the current OpenGL context.
Definition at line 112 of file bsurface.cpp.
00113 { 00114 if(!precomputed) 00115 Precompute(uDiv,vDiv); 00116 //const double du = 1.0/uDiv*(n_u-degree); 00117 //const double dv = 1.0/vDiv*(n_v-degree); 00118 00119 00120 for (int i=0; i<_divU; ++i) { 00121 const double u1 = 1.0*i/uDiv; 00122 const double u2 = 1.0*(i+1)/uDiv; 00123 00124 if(!s_mesh) 00125 glBegin(GL_TRIANGLES); 00126 00127 for (int j=0; j<_divV; ++j) { 00128 bool flip=false; 00129 int id1 = PtId(i, j); 00130 int id2 = PtId(i+1,j); 00131 int id3 = PtId(i+1,j+1); 00132 int id4 = PtId(i,j+1); 00133 const double v1 = 1.0*j/vDiv; 00134 const double v2 = 1.0*(j+1)/vDiv; 00135 00136 00137 00138 00139 if(s_mesh) 00140 glBegin(GL_LINES); 00141 00142 if(contraction){ 00143 if( psurf && _ctract[id4]<0) 00144 glColor3f(0.8*(-_ctract[id4]/(-c_min))+0.2,0.2,0.2); 00145 else 00146 glColor3f(0.2,0.8*(_ctract[id4]/(c_max))+0.2,0.2); 00147 } 00148 00149 glTexCoord2d(u1, v2); 00150 glNormal3d(_nrml[id4][0],_nrml[id4][1],_nrml[id4][2]); 00151 glVertex3d(_vrtx[id4][0],_vrtx[id4][1],_vrtx[id4][2]); 00152 00153 00154 if(contraction){ 00155 if( psurf && _ctract[id1]<0) 00156 glColor3f(0.8*(-_ctract[id1]/(-c_min))+0.2,0.2,0.2); 00157 else 00158 glColor3f(0.2,0.8*(_ctract[id1]/(c_max))+0.2,0.2); 00159 } 00160 00161 00162 glTexCoord2d(u1, v1); 00163 glNormal3d(_nrml[id1][0],_nrml[id1][1],_nrml[id1][2]); 00164 glVertex3d(_vrtx[id1][0],_vrtx[id1][1],_vrtx[id1][2]); 00165 00166 00167 if(_nrml[id4]*_nrml[id2]>_nrml[id3]*_nrml[id1]) { 00168 00169 if(contraction){ 00170 if( psurf && _ctract[id2]<0) 00171 glColor3f(0.8*(-_ctract[id2]/(-c_min))+0.2,0.2,0.2); 00172 else 00173 glColor3f(0.2,0.8*(_ctract[id2]/(c_max))+0.2,0.2); 00174 } 00175 00176 00177 flip=true; 00178 glTexCoord2d(u2, v1); 00179 glNormal3d(_nrml[id2][0],_nrml[id2][1],_nrml[id2][2]); 00180 glVertex3d(_vrtx[id2][0],_vrtx[id2][1],_vrtx[id2][2]); 00181 00182 if(s_mesh) { 00183 00184 00185 if(contraction){ 00186 if( psurf && _ctract[id4]<0) 00187 glColor3f(0.8*(-_ctract[id4]/(-c_min))+0.2,0.2,0.2); 00188 else 00189 glColor3f(0.2,0.8*(_ctract[id4]/(c_max))+0.2,0.2); 00190 } 00191 00192 00193 glTexCoord2d(u1, v2); 00194 glNormal3d(_nrml[id4][0],_nrml[id4][1],_nrml[id4][2]); 00195 glVertex3d(_vrtx[id4][0],_vrtx[id4][1],_vrtx[id4][2]); 00196 } 00197 00198 00199 00200 if(contraction){ 00201 if( psurf && _ctract[id4]<0) 00202 glColor3f(0.8*(-_ctract[id4]/(-c_min))+0.2,0.2,0.2); 00203 else 00204 glColor3f(0.2,0.8*(_ctract[id4]/(c_max))+0.2,0.2); 00205 } 00206 00207 00208 glTexCoord2d(u1, v2); 00209 glNormal3d(_nrml[id4][0],_nrml[id4][1],_nrml[id4][2]); 00210 glVertex3d(_vrtx[id4][0],_vrtx[id4][1],_vrtx[id4][2]); 00211 00212 } else { 00213 00214 00215 if(contraction){ 00216 if( psurf && _ctract[id3]<0) 00217 glColor3f(0.8*(-_ctract[id3]/(-c_min))+0.2,0.2,0.2); 00218 else 00219 glColor3f(0.2,0.8*(_ctract[id3]/(c_max))+0.2,0.2); 00220 } 00221 00222 00223 glTexCoord2d(u2, v2); 00224 glNormal3d(_nrml[id3][0],_nrml[id3][1],_nrml[id3][2]); 00225 glVertex3d(_vrtx[id3][0],_vrtx[id3][1],_vrtx[id3][2]); 00226 00227 if(s_mesh) { 00228 00229 if(contraction){ 00230 if( psurf && _ctract[id4]<0) 00231 glColor3f(0.8*(-_ctract[id4]/(-c_min))+0.2,0.2,0.2); 00232 else 00233 glColor3f(0.2,0.8*(_ctract[id4]/(c_max))+0.2,0.2); 00234 } 00235 00236 00237 glTexCoord2d(u1, v2); 00238 glNormal3d(_nrml[id4][0],_nrml[id4][1],_nrml[id4][2]); 00239 glVertex3d(_vrtx[id4][0],_vrtx[id4][1],_vrtx[id4][2]); 00240 } 00241 00242 00243 if(contraction){ 00244 if( psurf && _ctract[id1]<0) 00245 glColor3f(0.8*(-_ctract[id1]/(-c_min))+0.2,0.2,0.2); 00246 else 00247 glColor3f(0.2,0.8*(_ctract[id1]/(c_max))+0.2,0.2); 00248 } 00249 00250 00251 glTexCoord2d(u1, v1); 00252 glNormal3d(_nrml[id1][0],_nrml[id1][1],_nrml[id1][2]); 00253 glVertex3d(_vrtx[id1][0],_vrtx[id1][1],_vrtx[id1][2]); 00254 } 00255 00256 00257 if(contraction){ 00258 if( psurf && _ctract[id2]<0) 00259 glColor3f(0.8*(-_ctract[id2]/(-c_min))+0.2,0.2,0.2); 00260 else 00261 glColor3f(0.2,0.8*(_ctract[id2]/(c_max))+0.2,0.2); 00262 } 00263 00264 00265 glTexCoord2d(u2, v1); 00266 glNormal3d(_nrml[id2][0],_nrml[id2][1],_nrml[id2][2]); 00267 glVertex3d(_vrtx[id2][0],_vrtx[id2][1],_vrtx[id2][2]); 00268 00269 00270 if(contraction){ 00271 if( psurf && _ctract[id3]<0) 00272 glColor3f(0.8*(-_ctract[id3]/(-c_min))+0.2,0.2,0.2); 00273 else 00274 glColor3f(0.2,0.8*(_ctract[id3]/(c_max))+0.2,0.2); 00275 } 00276 00277 00278 00279 glTexCoord2d(u2, v2); 00280 glNormal3d(_nrml[id3][0],_nrml[id3][1],_nrml[id3][2]); 00281 glVertex3d(_vrtx[id3][0],_vrtx[id3][1],_vrtx[id3][2]); 00282 00283 if(s_mesh) { 00284 00285 if(flip) { 00286 00287 if(contraction){ 00288 if( psurf && _ctract[id4]<0) 00289 glColor3f(0.8*(-_ctract[id4]/(-c_min))+0.2,0.2,0.2); 00290 else 00291 glColor3f(0.2,0.8*(_ctract[id4]/(c_max))+0.2,0.2); 00292 } 00293 00294 00295 glTexCoord2d(u1, v2); 00296 glNormal3d(_nrml[id4][0],_nrml[id4][1],_nrml[id4][2]); 00297 glVertex3d(_vrtx[id4][0],_vrtx[id4][1],_vrtx[id4][2]); 00298 } else { 00299 00300 00301 if(contraction){ 00302 if( psurf && _ctract[id1]<0) 00303 glColor3f(0.8*(-_ctract[id1]/(-c_min))+0.2,0.2,0.2); 00304 else 00305 glColor3f(0.2,0.8*(_ctract[id1]/(c_max))+0.2,0.2); 00306 } 00307 00308 00309 glTexCoord2d(u1, v1); 00310 glNormal3d(_nrml[id1][0],_nrml[id1][1],_nrml[id1][2]); 00311 glVertex3d(_vrtx[id1][0],_vrtx[id1][1],_vrtx[id1][2]); 00312 } 00313 glEnd(); 00314 } 00315 } 00316 glEnd(); 00317 } 00318 00319 00320 00321 00322 00323 /* 00324 // draw normals 00325 { 00326 GLprimitive lns(GL_LINES); 00327 for (int i=0; i<_vrtx.size(); ++i) 00328 { 00329 Point3d v = _vrtx[i]; 00330 glVertex3d(v[0],v[1],v[2]); 00331 v = v+_nrml[i]*0.2; 00332 glVertex3d(v[0],v[1],v[2]); 00333 } 00334 } 00335 */ 00336 }
bool util::Shapes::BSplineSurface::IsTextured | ( | ) | const [inline] |
True if a texture is attached to the surface.
Definition at line 59 of file bsurface.h.
void util::Shapes::BSplineSurface::Load | ( | const char * | fname, | |
double | scale, | |||
int | TextureId, | |||
int | divU, | |||
int | divV | |||
) |
Load a file describing the BSplineSurface.
fname | File name | |
scale | Scale modification | |
TextureId | texture used for rendering | |
divU | number of division in U to use in the description | |
divV | number of division in V to use in the description |
Definition at line 48 of file bsurface.cpp.
00049 { 00050 _TextureId=TextureId; 00051 _scale=scale; 00052 _divU=divU; 00053 _divV=divV; 00054 LoadPatch(fnm); 00055 precomputed=false; 00056 }
void util::Shapes::BSplineSurface::Recompute | ( | ) | [inline] |
Force recomputation of the surface.
Definition at line 71 of file bsurface.h.
void util::Shapes::BSplineSurface::Reread | ( | ) |
Reread the last loaded file (if modified).
Definition at line 58 of file bsurface.cpp.
int util::Shapes::BSplineSurface::TextureId | ( | ) | const [inline] |
Get the texture id attached to the object (0 if none).
Definition at line 63 of file bsurface.h.
void util::Shapes::BSplineSurface::Transform | ( | Matrix3d | M, | |
double | x, | |||
double | y, | |||
double | z | |||
) |
Transform the surface using a 3D linear transformation and a translation.
Definition at line 94 of file bsurface.cpp.
00095 { 00096 Point3d D; 00097 D[0]=x; 00098 D[1]=y; 00099 D[2]=z; 00100 00101 for (unsigned int i=0; i<Control_points[0].size(); i++) 00102 for (unsigned int j=0; j<Control_points[0][0].size(); j++) { 00103 00104 00105 Control_points[0][i][j]=M*(Control_points[0][i][j]); 00106 Control_points[0][i][j]=Control_points[0][i][j]+D; 00107 } 00108 00109 precomputed=false; 00110 }