ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

tobezier.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 
00035 /* 
00036  * tobezier.c++
00037  *
00038  * $Date: 2006-03-12 00:07:02 +0000 (Sun, 12 Mar 2006) $ $Revision: 1.1 $
00039  * $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libnurbs/internals/tobezier.cc,v 1.1 2004/02/02 16:39:13 navaraf Exp $
00040  */
00041 
00042 #include "glimports.h"
00043 #include "myassert.h"
00044 #include "mystdio.h"
00045 #include "mystring.h"
00046 #include "quilt.h"
00047 #include "knotvector.h"
00048 
00049 /* local type definitions */
00050 struct Breakpt {        /* breakpoints  */
00051     Knot        value;      /* value    */
00052     int         multi;      /* multiplicity */
00053     int         def;        /* deficit */
00054 };
00055 
00056 struct Knotspec {       /* knotvector format */
00057     long        order;      /* order of spline  */
00058     Knot_ptr        inkbegin;   /* input knot sequence */
00059     Knot_ptr        inkend;     /* location after last knot */
00060     Knot_ptr        outkbegin;  /* in-process knot subsequence */
00061     Knot_ptr        outkend;    /* location after last knot */
00062     Knot_ptr        kleft;      /* */
00063     Knot_ptr        kright;     /* */
00064     Knot_ptr        kfirst;     /* */
00065     Knot_ptr        klast;      /* */
00066     Knot_ptr        sbegin;     /* conversion factor values */
00067     Breakpt *       bbegin;     /* in-process breakpoints */
00068     Breakpt *       bend;       /* last breakpoint */
00069     int         ncoords;    /* coordinates per control point */
00070     int         prestride;  /* stride between input points */
00071     int         poststride; /* stride between output points */
00072     int         preoffset;  /* scaled point offset  */
00073     int         postoffset; /* scaled point offset  */
00074     int         prewidth;   /* width of dimension   */
00075     int         postwidth;  /* width of dimension   */
00076     int         istransformed;  /* was dimension transformed */
00077     Knotspec *      next;       /* next knotspec */
00078     Knotspec *      kspectotrans;   /* knotspec in transformation direction */
00079 
00080             Knotspec( void );
00081             ~Knotspec( void );
00082     void        factors( void );
00083     void        insert( REAL * );
00084     void        preselect();
00085     void        select( void );
00086     void        copy( INREAL *, REAL * );
00087     void        breakpoints( void );
00088     void        knots( void );
00089     void        transform( REAL * );
00090     void        showpts( REAL * );
00091     
00092     void        pt_io_copy( REAL *, INREAL * );
00093     void        pt_oo_copy( REAL *, REAL * );
00094     void        pt_oo_sum( REAL*, REAL*, REAL*, Knot, Knot );
00095 };
00096 
00097 struct Splinespec {     /* a non-uniform tensor element */
00098             Splinespec( int );
00099                         ~Splinespec(void);
00100     Knotspec        *kspec; /* format of each param. dir. */
00101     int         dim;        /* domain dimension */
00102     REAL *      outcpts;    /* Bezier control points */
00103 
00104     void        kspecinit( Knotvector & );
00105     void        kspecinit( Knotvector &, Knotvector & );
00106     void        select( void );
00107     void        layout( long );
00108     void        setupquilt( Quilt_ptr );
00109     void        copy( INREAL * );
00110     void        transform( void );
00111 };
00112 
00113 /*-----------------------------------------------------------------------------
00114  * Quilt::toBezier - convert from NURBS to rational Bezier 
00115  *-----------------------------------------------------------------------------
00116  */
00117 
00118 void
00119 Quilt::toBezier( 
00120     Knotvector& knotvector, /* a knot vector */
00121     INREAL *ctlpts,     /* input contol points */
00122     long ncoords )      /* number of coordinates per control point */
00123 {
00124     Splinespec spline( 1 );
00125     spline.kspecinit( knotvector );
00126     spline.select();
00127     spline.layout( ncoords );
00128     spline.setupquilt( this );
00129     spline.copy( ctlpts );
00130     spline.transform();
00131 }
00132 
00133 void
00134 Quilt::toBezier( 
00135     Knotvector& sknotvector,    /* a knot vector */
00136     Knotvector& tknotvector,    /* a knot vector */
00137     INREAL *ctlpts,     /* input contol points */
00138     long ncoords )      /* number of coordinates per control point */
00139 {
00140     Splinespec spline( 2 );
00141     spline.kspecinit( sknotvector, tknotvector );
00142     spline.select();
00143     spline.layout( ncoords );
00144     spline.setupquilt( this );
00145     spline.copy( ctlpts );
00146     spline.transform();
00147 }
00148 Splinespec::Splinespec( int dimen )
00149 {
00150     dim = dimen;
00151 }
00152 
00153 Splinespec::~Splinespec( void )
00154 {
00155     /* Note: do NOT delete 'outcpts' here since its address (not contents)
00156      * is copied in 'cpts' in this file in function Splinespec::setupquilt().
00157      * This block of memory will eventually be deleted in file quilt.c++ in
00158      * function Quilt::deleteMe() through 'cpts' so do NOT delete it here!
00159      */ 
00160     Knotspec *ktrav= kspec;         //start at beginning of list 
00161     while (ktrav != 0) {            //any items to delete? 
00162        Knotspec *deleteThis= ktrav; //remember to delete this 
00163        ktrav= ktrav->next;          //go to next item if any
00164        delete deleteThis;           //delete it
00165     }   
00166 } /* ~Splinespec() */
00167 
00168 /*-----------------------------------------------------------------------------
00169  * Splinespec::kspecinit - initialize Splinespec structure
00170  *
00171  * Client: Quilt::toBezier
00172  *-----------------------------------------------------------------------------
00173  */
00174 
00175 void
00176 Splinespec::kspecinit( Knotvector& knotvector )
00177 {
00178     kspec = new Knotspec;
00179     kspec->inkbegin = knotvector.knotlist;
00180     kspec->inkend = knotvector.knotlist + knotvector.knotcount;
00181     kspec->prestride = (int) knotvector.stride; 
00182     kspec->order = knotvector.order;
00183     kspec->next = NULL;
00184 }
00185 
00186 void
00187 Splinespec::kspecinit( Knotvector& sknotvector, Knotvector& tknotvector )
00188 {
00189     kspec = new Knotspec;
00190     Knotspec *tkspec = new Knotspec;
00191 
00192     kspec->inkbegin = sknotvector.knotlist;
00193     kspec->inkend = sknotvector.knotlist + sknotvector.knotcount;
00194     kspec->prestride = (int) sknotvector.stride; 
00195     kspec->order = sknotvector.order;
00196     kspec->next = tkspec;
00197 
00198     tkspec->inkbegin = tknotvector.knotlist;
00199     tkspec->inkend = tknotvector.knotlist + tknotvector.knotcount;
00200     tkspec->prestride = (int) tknotvector.stride; 
00201     tkspec->order = tknotvector.order;
00202     tkspec->next = NULL;
00203 }
00204 
00205 
00206 /*-----------------------------------------------------------------------------
00207  * Splinespec::select - select the subsegments to copy
00208  *
00209  * Client: gl_quilt_to_bezier   
00210  *-----------------------------------------------------------------------------
00211  */
00212 
00213 void
00214 Splinespec::select( )
00215 {
00216     for( Knotspec *knotspec = kspec; knotspec; knotspec = knotspec->next ) {
00217     knotspec->preselect();
00218     knotspec->select();
00219     }
00220 }
00221 
00222 /*-----------------------------------------------------------------------------
00223  * Splinespec::layout - 
00224  *
00225  * Client: gl_quilt_to_bezier   
00226  *-----------------------------------------------------------------------------
00227  */
00228 
00229 void
00230 Splinespec::layout( long ncoords )
00231 {
00232 
00233     long stride = ncoords;
00234     for( Knotspec *knotspec = kspec; knotspec; knotspec=knotspec->next ) {
00235     knotspec->poststride = (int) stride;
00236     stride *= ((knotspec->bend-knotspec->bbegin)*knotspec->order + knotspec->postoffset);
00237         knotspec->preoffset  *= knotspec->prestride;
00238     knotspec->prewidth  *= knotspec->poststride;
00239     knotspec->postwidth *= knotspec->poststride;
00240     knotspec->postoffset *= knotspec->poststride;
00241         knotspec->ncoords = (int) ncoords;
00242     }
00243     outcpts = new REAL[stride];
00244     assert( outcpts != 0 );  
00245 }
00246 
00247 /*-----------------------------------------------------------------------------
00248  * Splinespec::copy - copy the control points of current subobject
00249  *
00250  * Client: gl_quilt_to_bezier
00251  *-----------------------------------------------------------------------------
00252  */
00253 
00254 void
00255 Splinespec::copy( INREAL *incpts )
00256 {
00257     kspec->copy( incpts, outcpts );
00258 }
00259 
00260 /*-----------------------------------------------------------------------------
00261  * Splinespec::setupquilt - assign all quilt variables from knotspec 
00262  *
00263  * Client: gl_quilt_to_bezier
00264  *-----------------------------------------------------------------------------
00265  */
00266 
00267 void
00268 Splinespec::setupquilt( Quilt_ptr quilt )
00269 {
00270     Quiltspec_ptr qspec = quilt->qspec;
00271     quilt->eqspec = qspec + dim;
00272     for( Knotspec *knotspec = kspec; knotspec; knotspec=knotspec->next, qspec++ ) {
00273     qspec->stride   = knotspec->poststride;
00274     qspec->width    = knotspec->bend - knotspec->bbegin;
00275     qspec->order    = (int) knotspec->order;
00276     qspec->offset   = knotspec->postoffset;
00277     qspec->index    = 0;
00278     qspec->bdry[0]  = (knotspec->kleft == knotspec->kfirst) ? 1 : 0;
00279     qspec->bdry[1]  = (knotspec->kright == knotspec->klast) ? 1 : 0;
00280     qspec->breakpoints = new Knot[qspec->width+1];
00281     Knot_ptr k =  qspec->breakpoints;
00282     for( Breakpt *bk = knotspec->bbegin; bk <= knotspec->bend; bk++ )
00283         *(k++) = bk->value;
00284     }
00285     quilt->cpts = outcpts;
00286     quilt->next = 0;
00287 }
00288 
00289 /*-----------------------------------------------------------------------------
00290  * Splinespec::transform - convert a spline to Bezier format
00291  *
00292  * Client: gl_quilt_to_bezier
00293  *-----------------------------------------------------------------------------
00294  */
00295 
00296 void
00297 Splinespec::transform( void )
00298 {
00299     Knotspec *knotspec;
00300     for( knotspec = kspec; knotspec; knotspec=knotspec->next )
00301         knotspec->istransformed = 0;
00302 
00303     for( knotspec = kspec; knotspec; knotspec=knotspec->next ) {
00304     for( Knotspec *kspec2 = kspec; kspec2; kspec2=kspec2->next )
00305         kspec2->kspectotrans = knotspec;
00306     kspec->transform( outcpts );
00307     knotspec->istransformed = 1;
00308     }
00309 }
00310 
00311 
00312 /*-----------------------------------------------------------------------------
00313  * Knotspec::Knotspec -  constuct a knot spec 
00314  *-----------------------------------------------------------------------------
00315  */
00316 
00317 Knotspec::Knotspec( void )
00318 {
00319     bbegin = 0;
00320     sbegin = 0;
00321     outkbegin = 0;
00322 }
00323 
00324 /*-----------------------------------------------------------------------------
00325  * Knotspec::copy -  copy the control points along minor direction 
00326  *
00327  * Client: Splinespec::copy
00328  *-----------------------------------------------------------------------------
00329  */
00330 
00331 void
00332 Knotspec::copy( INREAL *inpt, REAL *outpt )
00333 {
00334     inpt = (INREAL *) (((char *) inpt) + preoffset);
00335 
00336     if( next ) {
00337         for( REAL *lpt=outpt+prewidth; outpt != lpt; outpt += poststride ) {
00338         next->copy( inpt, outpt );
00339         inpt = (INREAL *) (((char *) inpt) + prestride);
00340     }
00341    } else {
00342         for( REAL *lpt=outpt+prewidth; outpt != lpt; outpt += poststride ) {
00343         pt_io_copy( outpt, inpt );
00344         inpt = (INREAL *) (((char *) inpt) + prestride);
00345     }
00346      }
00347 }
00348 
00349 /*-----------------------------------------------------------------------------
00350  * Knotspec::showpts - print out points before transformation
00351  *
00352  * Client: Knotspec::select
00353  *-----------------------------------------------------------------------------
00354  */
00355 void
00356 Knotspec::showpts( REAL *outpt )
00357 {
00358     if( next ) {
00359         for( REAL *lpt=outpt+prewidth; outpt != lpt; outpt += poststride )
00360         next->showpts( outpt );
00361     } else {
00362         for( REAL *lpt=outpt+prewidth; outpt != lpt; outpt += poststride )
00363         dprintf(  "show %g %g %g\n", outpt[0], outpt[1], outpt[2] );
00364     }
00365 }
00366 
00367 /*-----------------------------------------------------------------------------
00368  * Knotspec::factors - precompute scale factors     
00369  *     - overwrites knot vector, actual new knot vector is NOT produced
00370  *
00371  * Client: Knotspec::select
00372  *-----------------------------------------------------------------------------
00373  */
00374 
00375 void
00376 Knotspec::factors( void )
00377 {
00378     Knot *mid = (outkend - 1) - order + bend->multi;
00379     Knot_ptr fptr = sbegin;
00380 
00381     for( Breakpt *bpt = bend; bpt >= bbegin; bpt-- ) {
00382         mid -= bpt->multi;      // last knot less than knot to insert
00383     int def = bpt->def - 1;     // number of knots to insert
00384     if( def <= 0 ) continue;
00385     Knot kv = bpt->value;       // knot to insert
00386 
00387     Knot *kf = (mid-def) + (order-1);
00388     for( Knot *kl = kf + def; kl != kf; kl-- ) {
00389         Knot *kh, *kt;
00390         for( kt=kl, kh=mid; kt != kf; kh--, kt-- ) 
00391         *(fptr++) = (kv - *kh) / (*kt - *kh);
00392         *kl = kv;
00393     }
00394     }
00395 }
00396 
00397 /*-----------------------------------------------------------------------------
00398  * Knotspec::insert - convert subobject in direction of kspec into Bezier
00399  *
00400  * Client: Knotspec::transform
00401  *-----------------------------------------------------------------------------
00402  */
00403 
00404 void
00405 Knotspec::insert( REAL *p )
00406 {
00407     Knot_ptr fptr = sbegin;
00408     REAL *srcpt = p + prewidth - poststride;
00409     REAL *dstpt = p + postwidth + postoffset - poststride;
00410     Breakpt *bpt = bend;
00411 
00412    for( REAL *pend = srcpt - poststride*bpt->def; srcpt != pend; pend +=poststride ) {
00413     REAL *p1 = srcpt;
00414     for( REAL *p2 = srcpt-poststride; p2 != pend; p1 = p2, p2 -= poststride ) {
00415         pt_oo_sum( p1, p1, p2, *fptr, 1.0-*fptr );
00416         fptr++;
00417     }
00418     }
00419 
00420     for( --bpt; bpt >= bbegin; bpt-- ) {
00421 
00422     for( int multi = bpt->multi; multi > 0; multi-- ) {
00423         pt_oo_copy( dstpt, srcpt );
00424         dstpt -= poststride;
00425         srcpt -= poststride;    
00426     }
00427     
00428     for( REAL *pend = srcpt - poststride*bpt->def; srcpt != pend; pend +=poststride, dstpt-=poststride ) {
00429         pt_oo_copy( dstpt, srcpt );
00430         REAL *p1 = srcpt;
00431 
00432         for( REAL *p2 = srcpt-poststride; p2 != pend; p1=p2, p2 -= poststride ) {
00433         pt_oo_sum( p1, p1, p2, *fptr, 1.0-*fptr );
00434         fptr++;
00435         }
00436     }
00437     }
00438 }
00439 
00440 /*-----------------------------------------------------------------------------
00441  * Knotspec::preselect - initialize kspec for processing
00442  *
00443  * Client: Splinespec::select
00444  *-----------------------------------------------------------------------------
00445  */
00446 
00447 void
00448 Knotspec::preselect( void )
00449 {
00450     Knot kval; 
00451 
00452     /* position klast after last knot of "last" breakpoint */
00453     for( klast = inkend - order, kval = *klast; klast != inkend; klast++ ) 
00454     if( ! identical( *klast, kval ) ) break;
00455 
00456     /* position kfirst after last knot of "first" breakpoint */
00457     for( kfirst = inkbegin+order-1, kval= *kfirst;  kfirst != inkend; kfirst++ )
00458     if( ! identical( *kfirst, kval ) ) break;
00459 
00460     /* compute multiplicity of first breakpoint */
00461     Knot_ptr k;
00462     for( k  = kfirst - 1; k >= inkbegin; k-- ) 
00463     if( ! identical( kval, *k ) ) break;    
00464     k++;
00465 
00466     /* allocate space for breakpoints -
00467        use worst case estimate on number of breakpoints */
00468 
00469     bbegin = new Breakpt[(klast - kfirst)+1];
00470     /* record multiplicity and value of first breakpoint */
00471     bbegin->multi = kfirst - k;
00472     bbegin->value = kval;
00473     bend = bbegin;
00474 
00475     kleft = kright = kfirst;
00476 }
00477 
00478 
00479 /*-----------------------------------------------------------------------------
00480  * Knotspec::select - Knotspec::select segments and precompute scale factors
00481  *
00482  * Client: Splinespec::select
00483  *-----------------------------------------------------------------------------
00484  */
00485 
00486 void
00487 Knotspec::select( void )
00488 {
00489     breakpoints();
00490     knots();
00491     factors();
00492     
00493     preoffset   = kleft - (inkbegin + order);
00494     postwidth   = (int)((bend - bbegin) * order);
00495     prewidth    = (int)((outkend - outkbegin) - order);
00496     postoffset  = (bbegin->def > 1) ? (bbegin->def-1) : 0;
00497 }
00498  
00499 /*-----------------------------------------------------------------------------
00500  * Knotspec::breakpoints - compute breakpoints for knotspec
00501  *
00502  * Client: Knotspec::select
00503  *-----------------------------------------------------------------------------
00504  */
00505 
00506 void
00507 Knotspec::breakpoints( void )
00508 {
00509     Breakpt *ubpt   = bbegin;
00510     Breakpt *ubend  = bend;
00511     long    nfactors    = 0;
00512 
00513     ubpt->value = ubend->value;
00514     ubpt->multi = ubend->multi;
00515 
00516     kleft = kright;
00517 
00518     for( ; kright != klast; kright++ ) {
00519         if ( identical(*kright,ubpt->value) ) {
00520         (ubpt->multi)++;
00521     } else {
00522             ubpt->def = (int) (order - ubpt->multi);
00523             nfactors += (ubpt->def * (ubpt->def - 1)) / 2;
00524         (++ubpt)->value = *kright;
00525         ubpt->multi = 1;
00526     }
00527     }
00528     ubpt->def = (int) (order - ubpt->multi);
00529     nfactors += (ubpt->def * (ubpt->def - 1)) / 2;
00530 
00531     bend = ubpt;
00532 
00533     if( nfactors ) {        
00534         sbegin = new Knot[nfactors];
00535     } else {
00536     sbegin = NULL;
00537     }
00538 }
00539 
00540 
00541 /*-----------------------------------------------------------------------------
00542  * Knotspec::knots - copy relevant subsequence of knots into temporary area
00543  *
00544  * Client: Knotspec::select
00545  *-----------------------------------------------------------------------------
00546  */
00547 
00548 void
00549 Knotspec::knots( void )
00550 {
00551     Knot_ptr inkpt = kleft - order;
00552     Knot_ptr inkend = kright  + bend->def;
00553 
00554     /* allocate space for knots and factors */
00555     outkbegin = new Knot[inkend-inkpt];
00556     Knot_ptr outkpt;
00557     for( outkpt = outkbegin; inkpt != inkend; inkpt++, outkpt++ ) 
00558     *outkpt = *inkpt;
00559 
00560     outkend = outkpt;
00561 }
00562 
00563 
00564 /*-----------------------------------------------------------------------------
00565  * Knotspec::transform -    convert a spline along a given direction 
00566  *
00567  * Client: Splienspec::transform
00568  *-----------------------------------------------------------------------------
00569  */
00570 
00571 void
00572 Knotspec::transform( REAL *p )
00573 {
00574    if( next ) {
00575     if( this == kspectotrans ) {
00576         next->transform( p );
00577     } else {
00578         if( istransformed ) {
00579         p += postoffset;
00580         for( REAL *pend = p + postwidth; p != pend; p += poststride )
00581             next->transform( p );
00582         } else {
00583         REAL *pend = p + prewidth;
00584         for( ; p != pend; p += poststride )
00585             next->transform( p );
00586         }
00587     }
00588    } else {
00589     if( this == kspectotrans ) {
00590         insert( p );
00591     } else {
00592         if( istransformed ) {
00593         p += postoffset;
00594         for( REAL *pend = p + postwidth; p != pend; p += poststride )
00595             kspectotrans->insert( p );
00596         } else {
00597         REAL *pend = p + prewidth;
00598         for( ; p != pend; p += poststride )
00599             kspectotrans->insert( p );
00600         }
00601     }
00602    }
00603 }
00604 
00605 /*-----------------------------------------------------------------------------
00606  * Knotspec::~Knotspec - free space alocated for knotspec
00607  *-----------------------------------------------------------------------------
00608  */
00609 
00610 Knotspec::~Knotspec( void )
00611 {
00612     if( bbegin ) delete[] bbegin;
00613     if( sbegin ) delete[] sbegin;
00614     if( outkbegin ) delete[] outkbegin;
00615 }
00616 
00617 
00618 /*-----------------------------------------------------------------------------
00619  * pt_io_copy - make internal copy of input cntrl pt. of x coords
00620  *-----------------------------------------------------------------------------
00621  */
00622 
00623 void
00624 Knotspec::pt_io_copy( REAL *topt, INREAL *frompt )
00625 {
00626     switch( ncoords ) {
00627     case 4:
00628         topt[3] = (REAL) frompt[3];
00629     case 3:
00630         topt[2] = (REAL) frompt[2];
00631     case 2:
00632         topt[1] = (REAL) frompt[1];
00633     case 1:
00634         topt[0] = (REAL) frompt[0];
00635     break;
00636     default: {
00637         for( int i = 0; i < ncoords; i++ )
00638         *topt++ = (REAL) *frompt++;
00639     }
00640     }
00641 }
00642 
00643 /*-----------------------------------------------------------------------------
00644  * pt_oo_copy - make internal copy of internal cntrl pt. of x coords
00645  *-----------------------------------------------------------------------------
00646  */
00647 
00648 void
00649 Knotspec::pt_oo_copy( REAL *topt, REAL *frompt )
00650 {
00651     switch( ncoords ) {
00652     case 4:
00653         topt[3] = frompt[3];
00654     case 3:
00655         topt[2] = frompt[2];
00656     case 2:
00657         topt[1] = frompt[1];
00658     case 1:
00659         topt[0] = frompt[0];
00660     break;
00661     default:
00662     memcpy( topt, frompt, ncoords * sizeof( REAL ) );
00663     }
00664 }
00665 
00666 /*-----------------------------------------------------------------------------
00667  * pt_oo_sum - compute affine combination of internal cntrl pts
00668  *-----------------------------------------------------------------------------
00669  */
00670 
00671 void
00672 Knotspec::pt_oo_sum( REAL *x, REAL *y, REAL *z, Knot a, Knot b )
00673 {
00674     switch( ncoords ) {
00675     case 4:
00676         x[3] = a * y[3]  +  b * z[3];
00677     case 3:
00678         x[2] = a * y[2]  +  b * z[2];
00679     case 2:
00680         x[1] = a * y[1]  +  b * z[1];
00681     case 1:
00682         x[0] = a * y[0]  +  b * z[0];
00683     break;
00684     default: {
00685           for( int i = 0; i < ncoords; i++ )
00686               *x++ = a * *y++   +   b * *z++;
00687     }
00688     }
00689 }

Generated on Sun May 27 2012 04:23:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.