nurb_copy.c

Go to the documentation of this file.
00001 /*                     N U R B _ C O P Y . 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_copy.c
00025  *      Duplicate the nurb surface.
00026  *  Author -
00027  *      Paul Randal Stay
00028  *
00029  *  Source -
00030  *      SECAD/VLD Computing Consortium, Bldg 394
00031  *      The U.S. Army Ballistic Research Laboratory
00032  *      Aberdeen Proving Ground, Maryland 21005
00033  *
00034  */
00035 /*@}*/
00036 
00037 #include "common.h"
00038 
00039 
00040 
00041 #include <stdio.h>
00042 #include "machine.h"
00043 #include "vmath.h"
00044 #include "nmg.h"
00045 #include "raytrace.h"
00046 #include "nurb.h"
00047 
00048 struct face_g_snurb *
00049 rt_nurb_scopy(const struct face_g_snurb *srf, struct resource *res)
00050 {
00051         register struct face_g_snurb * n;
00052         int i;
00053 
00054         NMG_CK_SNURB(srf);
00055 
00056         n = (struct face_g_snurb *) rt_nurb_new_snurb( srf->order[0], srf->order[1],
00057                 srf->u.k_size, srf->v.k_size,
00058                 srf->s_size[0],srf->s_size[1],
00059                 srf->pt_type, res);
00060 
00061         for( i = 0; i < srf->u.k_size; i++)
00062                 n->u.knots[i] =  srf->u.knots[i];
00063 
00064         for( i = 0; i < srf->v.k_size; i++)
00065                 n->v.knots[i] =  srf->v.knots[i];
00066 
00067         for ( i = 0; i <  srf->s_size[0] * srf->s_size[1] *
00068                 RT_NURB_EXTRACT_COORDS(srf->pt_type); i++)
00069         {
00070 
00071                 n->ctl_points[i] = srf->ctl_points[i];
00072         }
00073 
00074         return (struct face_g_snurb *) n;
00075 }
00076 
00077 struct edge_g_cnurb *
00078 rt_nurb_crv_copy(const struct edge_g_cnurb *crv)
00079 {
00080         register struct edge_g_cnurb * n;
00081         int i;
00082 
00083         NMG_CK_CNURB( crv );
00084 
00085         n = (struct edge_g_cnurb *) rt_nurb_new_cnurb( crv->order,
00086                 crv->k.k_size, crv->c_size, crv->pt_type);
00087 
00088         for( i = 0; i < crv->k.k_size; i++)
00089                 n->k.knots[i] = crv->k.knots[i];
00090 
00091         for( i = 0; i < crv->c_size *
00092                 RT_NURB_EXTRACT_COORDS(crv->pt_type); i++)
00093                 n->ctl_points[i] = crv->ctl_points[i];
00094 
00095         return (struct edge_g_cnurb *) n;
00096 }
00097 
00098 /*
00099  * Local Variables:
00100  * mode: C
00101  * tab-width: 8
00102  * c-basic-offset: 4
00103  * indent-tabs-mode: t
00104  * End:
00105  * ex: shiftwidth=4 tabstop=8
00106  */

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