oslo_map.c

Go to the documentation of this file.
00001 /*                      O S L O _ M A P . C
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 1990-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 
00022 /** @addtogroup nurb */
00023 /*@{*/
00024 /** @file oslo_map.c
00025  * Map the olso matrix with the old curve resulting in a new one.
00026  *
00027  * Author -
00028  *     Paul R. Stay
00029  *
00030  * Source -
00031  *     SECAD/VLD Computing Consortium, Bldg 394
00032  *     The U.S. Army Ballistic Research Laboratory
00033  *     Aberdeen Proving Ground, Maryland 21005
00034  *
00035  */
00036 
00037 #include "common.h"
00038 
00039 
00040 
00041 #include <stdio.h>
00042 #include "machine.h"
00043 #include "vmath.h"
00044 #include "raytrace.h"
00045 #include "nurb.h"
00046 
00047 /* This routine takes a oslo refinement matrix as described in the
00048  * paper "Making the Oslo Algorithm More Efficient" and maps it to the
00049  * old control points resulting in new control points.
00050  * (this procedure should probably never called by a user program but
00051  * should remain internal to the library. Bounds are given to facilitate
00052  * easier spliting of the surface.
00053  */
00054 
00055 void
00056 rt_nurb_map_oslo(struct oslo_mat *oslo, fastf_t *old_pts, fastf_t *new_pts, int o_stride, int n_stride, int lower, int upper, int pt_type)
00057                                         /* Oslo matrix  */
00058                                         /* Old control points */
00059                                         /* New control points */
00060                                         /* inc to next point of old mesh*/
00061                                         /* inc to next point of new mesh*/
00062                         /* Upper and lower bounds for curve generation */
00063 
00064 {
00065         register fastf_t *c_ptr;                /* new curve pointer */
00066         register fastf_t *o_pts;
00067         register struct oslo_mat *o_ptr;        /* oslo matrix pointer */
00068         register int    k;
00069         int     j,                              /* j loop */
00070                 i;                              /* oslo loop */
00071         int     coords;
00072 
00073         coords = RT_NURB_EXTRACT_COORDS( pt_type);
00074 
00075         c_ptr = new_pts;
00076 
00077         if ( lower != 0)
00078                 for ( i = 0,  o_ptr = oslo; i < lower; i++,  o_ptr =
00079                     o_ptr->next)
00080                         ;
00081         else
00082                 o_ptr = oslo;
00083 
00084         for ( j = lower; j < upper; j++, o_ptr = o_ptr->next) {
00085                 fastf_t o_scale;
00086                 o_pts = &old_pts[(o_ptr->offset * o_stride)];
00087 
00088                 o_scale = o_ptr->o_vec[0];
00089 
00090                 for ( k = 0; k < coords; k++)
00091                         c_ptr[k] = o_pts[k] * o_scale;
00092 
00093                 for ( i = 1; i <= o_ptr->osize; i++) {
00094                         o_scale = o_ptr->o_vec[i];
00095                         o_pts += o_stride;
00096                         for ( k = 0; k < coords; k++)
00097                                 c_ptr[k] += o_scale * o_pts[k];
00098                 }
00099                 c_ptr += n_stride;
00100         }
00101 }
00102 
00103 /*@}*/
00104 /*
00105  * Local Variables:
00106  * mode: C
00107  * tab-width: 8
00108  * c-basic-offset: 4
00109  * indent-tabs-mode: t
00110  * End:
00111  * ex: shiftwidth=4 tabstop=8
00112  */

Generated on Mon Sep 18 01:24:56 2006 for BRL-CAD by  doxygen 1.4.6