00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef lint
00038 static const char RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/librt/nurb_example.c,v 14.11 2006/09/16 02:04:25 lbutler Exp $ (ARL)";
00039 #endif
00040
00041 #include "common.h"
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045 #include <math.h>
00046 #include "machine.h"
00047 #include "vmath.h"
00048 #include "raytrace.h"
00049 #include "nurb.h"
00050 #include "plot3.h"
00051
00052
00053 fastf_t grid[10][10][3];
00054 fastf_t ngrid[10][10][3];
00055
00056
00057
00058 void
00059 interpolate_data()
00060 {
00061 struct face_g_snurb srf;
00062 struct face_g_snurb *srf2, *srf3;
00063 struct knot_vector new_kv;
00064
00065 rt_nurb_sinterp( &srf, 4, (const fastf_t *)grid, 10, 10 );
00066
00067 #if 0
00068
00069 pl_color( stdout, 145, 145, 255 );
00070 rt_nurb_plot_snurb( stdout, &srf );
00071 #endif
00072
00073 #if 0
00074 rt_nurb_reverse_srf( &srf );
00075 rt_nurb_kvnorm( &srf.u );
00076 rt_nurb_kvnorm( &srf.v );
00077 #endif
00078
00079
00080 rt_nurb_kvknot( &new_kv, srf.order[0], 0.0, 1.0, 100, (struct resource *)NULL);
00081 srf2 = (struct face_g_snurb *) rt_nurb_s_refine( &srf, 0, &new_kv, (struct resource *)NULL);
00082 srf3 = (struct face_g_snurb *) rt_nurb_s_refine( srf2, 1, &new_kv, (struct resource *)NULL);
00083
00084
00085 pl_color( stdout, 200, 200, 50 );
00086 rt_nurb_plot_snurb( stdout, srf3 );
00087 }
00088
00089 int main(int argc, char *argv[])
00090 {
00091
00092 fastf_t hscale;
00093 fastf_t v;
00094 int i, j;
00095
00096 hscale = 2.5;
00097
00098
00099
00100 pl_color(stdout,155, 55, 55);
00101
00102 for( i = 0; i < 10; i++)
00103 for( j = 0; j < 10; j++)
00104 {
00105 v = hscale * drand48() + 10.0;
00106 grid[i][j][0] = i;
00107 grid[i][j][1] = j;
00108 grid[i][j][2] = v;
00109
00110 pd_3move( stdout,
00111 grid[i][j][0], grid[i][j][1], grid[i][j][2] - .14);
00112 pd_3cont( stdout,
00113 grid[i][j][0], grid[i][j][1], grid[i][j][2] + .14);
00114
00115 pd_3move( stdout,
00116 grid[i][j][0] - .14, grid[i][j][1], grid[i][j][2]);
00117 pd_3cont( stdout,
00118 grid[i][j][0] + .14, grid[i][j][1], grid[i][j][2] );
00119
00120 pd_3move( stdout,
00121 grid[i][j][0], grid[i][j][1]-.14, grid[i][j][2]);
00122 pd_3cont( stdout,
00123 grid[i][j][0], grid[i][j][1]+.14, grid[i][j][2]);
00124 }
00125
00126 interpolate_data();
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137