nurb_plot.c

Go to the documentation of this file.
00001 /*                     N U R B _ P L O T . C
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 1986-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 /*@{*/
00025 /** @file nurb_plot.c
00026  *      Utilities for spline debuging.
00027  *
00028  *  Author -
00029  *      Paul Randal Stay
00030  *
00031  *
00032  *  Source -
00033  *      SECAD/VLD Computing Consortium, Bldg 394
00034  *      The U.S. Army Ballistic Research Laboratory
00035  *      Aberdeen Proving Ground, Maryland 21005
00036  *
00037  */
00038 /*@}*/
00039 
00040 #include "common.h"
00041 
00042 
00043 
00044 #include <stdio.h>
00045 #include <sys/types.h>
00046 #include <fcntl.h>
00047 
00048 #include "machine.h"
00049 #include "vmath.h"
00050 #include "raytrace.h"
00051 #include "nurb.h"
00052 #include "plot3.h"
00053 
00054 /*
00055  *                      R T _ N U R B _ P L O T _ S N U R B
00056  */
00057 void
00058 rt_nurb_plot_snurb(FILE *fp, const struct face_g_snurb *srf)
00059 {
00060         int i,j;
00061         const fastf_t * m_ptr = srf->ctl_points;
00062         int evp = RT_NURB_EXTRACT_COORDS( srf->pt_type);
00063         int rat = RT_NURB_IS_PT_RATIONAL( srf->pt_type);
00064         point_t pt;
00065 
00066         NMG_CK_SNURB(srf);
00067 
00068         for( i = 0; i < srf->s_size[0]; i++)
00069         {
00070                 for( j = 0; j < srf->s_size[1]; j++)
00071                 {
00072                        if ( rat )
00073                         {
00074                                 pt[0] = m_ptr[0]/ m_ptr[3];
00075                                 pt[1] = m_ptr[1]/ m_ptr[3];
00076                                 pt[2] = m_ptr[2]/ m_ptr[3];
00077                         } else
00078                         {
00079                                 pt[0] = m_ptr[0];
00080                                 pt[1] = m_ptr[1];
00081                                 pt[2] = m_ptr[2];
00082 
00083                         }
00084 
00085                         if( j == 0)
00086                         {
00087                                 pdv_3move( fp, pt );
00088                         } else
00089                                 pdv_3cont( fp, pt );
00090 
00091                         m_ptr += evp;
00092                 }
00093         }
00094 
00095         for( j = 0; j < srf->s_size[1]; j++)
00096         {
00097                 int stride;
00098                 stride = srf->s_size[1] * evp;
00099                 m_ptr = &srf->ctl_points[j * evp];
00100                 for( i = 0; i < srf->s_size[0]; i++)
00101                 {
00102                         if ( rat )
00103                         {
00104                                 pt[0] = m_ptr[0]/ m_ptr[3];
00105                                 pt[1] = m_ptr[1]/ m_ptr[3];
00106                                 pt[2] = m_ptr[2]/ m_ptr[3];
00107                         } else
00108                         {
00109                                 pt[0] = m_ptr[0];
00110                                 pt[1] = m_ptr[1];
00111                                 pt[2] = m_ptr[2];
00112 
00113                         }
00114 
00115 
00116                         if( i == 0)
00117                                 pdv_3move( fp, pt );
00118                         else
00119                                 pdv_3cont( fp, pt );
00120 
00121                         m_ptr += stride;
00122                 }
00123         }
00124 }
00125 
00126 /*
00127  *                      R T _ N U R B _ P L O T _ C N U R B
00128  */
00129 void
00130 rt_nurb_plot_cnurb(FILE *fp, const struct edge_g_cnurb *crv)
00131 {
00132         register int    i, k;
00133         const fastf_t * m_ptr = crv->ctl_points;
00134         int evp = RT_NURB_EXTRACT_COORDS( crv->pt_type);
00135         int rat = RT_NURB_IS_PT_RATIONAL( crv->pt_type);
00136         point_t ptr;
00137 
00138         for( i = 0; i < crv->c_size; i++)  {
00139                 if( rat )
00140                 {
00141                         for(k = 0; k < evp; k++)
00142                                 ptr[k] = m_ptr[k] / m_ptr[evp-1];
00143 
00144                 } else
00145                 {
00146                         for(k = 0; k < evp; k++)
00147                                 ptr[k] = m_ptr[k];
00148 
00149                 }
00150                 if( i == 0 )
00151                         pdv_3move( fp, ptr );
00152                 else
00153                         pdv_3cont( fp, ptr );
00154                 m_ptr += evp;
00155         }
00156 }
00157 
00158 /* Old routines included for backwards compat.  Don't use in new code. */
00159 void rt_nurb_setfile(int n)
00160 {
00161         pl_color(stdout, n * 25 % 255, n * 50 % 255, n * 75 %255);
00162 }
00163 
00164 void
00165 rt_nurb_closefile(void)
00166 {
00167 }
00168 
00169 void rt_nurb_s_plot(const struct face_g_snurb *srf)
00170 {
00171         rt_nurb_plot_snurb( stdout, srf );
00172 }
00173 
00174 /*
00175  * Local Variables:
00176  * mode: C
00177  * tab-width: 8
00178  * c-basic-offset: 4
00179  * indent-tabs-mode: t
00180  * End:
00181  * ex: shiftwidth=4 tabstop=8
00182  */

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