nurb_reverse.c

Go to the documentation of this file.
00001 /*                  N U R B _ R E V E R S E . C
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 1991-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 nurb_reverse.c
00025  *      Reverse the direction of a nurb surface
00026  *      by transposing the control points
00027  *
00028  *  Author -
00029  *      Paul R. Stay
00030  *
00031  *  Source -
00032  *     SECAD/VLD Computing Consortium, Bldg 394
00033  *     The U.S. Army Ballistic Research Laboratory
00034  *     Aberdeen Proving Ground, Maryland 21005
00035  *
00036  */
00037 /*@}*/
00038 
00039 #include "common.h"
00040 
00041 
00042 
00043 #include <stdio.h>
00044 #include "machine.h"
00045 #include "vmath.h"
00046 #include "nmg.h"
00047 #include "raytrace.h"
00048 #include "nurb.h"
00049 
00050 void
00051 rt_nurb_reverse_srf(struct face_g_snurb *srf)
00052 {
00053 
00054         int i,j,k;
00055         int coords;
00056         int row, col;
00057         fastf_t * p_ptr;
00058         fastf_t * tmp;
00059         fastf_t * ptr2;
00060 
00061         p_ptr = srf->ctl_points;
00062         coords = RT_NURB_EXTRACT_COORDS(srf->pt_type);
00063 
00064         row = srf->s_size[0];
00065         col = srf->s_size[1];
00066 
00067         tmp = (fastf_t *) bu_malloc(sizeof(fastf_t) * coords *
00068                 row * col, "nurb_reverse:temp");
00069 
00070         ptr2 = tmp;
00071 
00072         for(i = 0; i < row; i++)
00073         for(j = 0; j < col; j++)
00074         {
00075                 for( k = 0; k < coords; k++)
00076                        *ptr2++ = srf->ctl_points[ (j * col + i) * coords + k];
00077         }
00078 
00079         for( i = 0; i < row * col * coords; i++)
00080                 p_ptr[i] = tmp[i];
00081 
00082         srf->s_size[0] = col;
00083         srf->s_size[1] = row;
00084 
00085         i = srf->u.k_size;
00086         srf->u.k_size = srf->v.k_size;
00087         srf->v.k_size = i;
00088 
00089         p_ptr = srf->u.knots;
00090         srf->u.knots = srf->v.knots;
00091         srf->v.knots = p_ptr;
00092 
00093         bu_free((char *) tmp, "temporary storage for transpose");
00094 }
00095 
00096 /*
00097  * Local Variables:
00098  * mode: C
00099  * tab-width: 8
00100  * c-basic-offset: 4
00101  * indent-tabs-mode: t
00102  * End:
00103  * ex: shiftwidth=4 tabstop=8
00104  */

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