资源简介
计算机图形学基础案例源码--B样条曲面代码,很实用,很适合初学者参考
代码片段和文件信息
// Copyright (C) 1991 - 1999 Rational Software Corporation
#include “stdafx.h“
#include “BH_BSpline.h“
#include
BH_BSpline::BH_BSpline(int Row int Column int uOrder int vOrder int utype int vtype int Precision double* dpCtlPts)
{
iRow=Row;
iColumn=Column;
memset(dpControlPoints 0 MAXCONTROLPOINTS*sizeof(double));
if ( dpCtlPts != NULL )
set_dpControlPoints(dpCtlPts);
else
{
srand( (unsigned)time( NULL ) );
int u v;
for (v = 0; v <= iColumn; v++)
{
for (u = 0; u <= iRow; u++)
{
if ( iRow == 0 )
dpControlPoints[(v*(iRow+1)+u)*3+0] = -0.5;
else
dpControlPoints[(v*(iRow+1)+u)*3+0] = (GLdouble)u/iRow-0.5;
if ( iColumn == 0 )
dpControlPoints[(v*(iRow+1)+u)*3+1] = -0.5 ;
else
dpControlPoints[(v*(iRow+1)+u)*3+1] = (GLdouble)v/iColumn-0.5;
dpControlPoints[(v*(iRow+1)+u)*3+2] = (GLdouble)4/(iRow+iColumn)*(rand()%2);
}
}
}
memset(dpKnotsU 0 MAXKNOTS*sizeof(double));
memset(dpKnotsV 0 MAXKNOTS*sizeof(double));
UType=utype;
VType=vtype;
iUOrder=uOrder;
iVOrder=vOrder;
update_dpKnots(U);
update_dpKnots(V);
iPrecision=Precision;
bDrawControlPoints=false;
bDrawDiffVector=false;
bWireframe=true;
bTexture=false;
bLight=false;
for ( int v = 0; v for ( int u = 0; u bControlPointsSelected[v][u] = false ;
}
BH_BSpline::~BH_BSpline()
{
}
void BH_BSpline::set_dpControlPoints(double* value)
{
memcpy(dpControlPoints value (iRow+1)*(iColumn+1)*3*sizeof(double));
return;
}
void BH_BSpline::set_dpKnotsU(double* value)
{
memcpy(dpKnotsU value (iRow+iUOrder+1)*sizeof(double));
return;
}
void BH_BSpline::set_dpKnotsV(double* value)
{
memcpy(dpKnotsV value (iColumn+iVOrder+1)*sizeof(double));
return;
}
double* BH_BSpline::get_dpKnotsU()
{
return dpKnotsU ;
}
double* BH_BSpline::get_dpKnotsV()
{
return dpKnotsV ;
}
const int BH_BSpline::get_iPrecision() const
{
return iPrecision;
}
void BH_BSpline::set_iPrecision(int value)
{
iPrecision = value;
return;
}
const int BH_BSpline::get_iRow() const
{
return iRow;
}
const int BH_BSpline::get_iColumn() const
{
return iColumn;
}
void BH_BSpline::set_iUOrder(int value)
{
if ( value < 0 || value > iRow )
{
AfxMessageBox(“阶次k必须大于等于0且小于等于n“);
return;
}
iUOrder = value ;
update_dpKnots(U) ;
return;
}
void BH_BSpline::set_iVOrder(int value)
{
if ( value < 0 || value > iColumn )
{
AfxMessageBox(“阶次k必须大于等于0且小于等于n“);
return;
}
iVOrder = value ;
update_dpKnots(V) ;
return;
}
void BH_BSpline::set_UType(int type)
{
UType=type;
update_dpKnots(U);
}
void BH_BSpline::set_VType(int type)
{
VType=type;
update_dpKnots(V);
}
const int BH_BSpline::get_UType() const
{
return UType;
}
const int BH_BSpline::get_VType() const
{
return VType;
}
const int BH_BSpline::get_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24790 2008-08-23 03:42 BSpline\BH_BSpline.cpp
文件 6513 2008-02-20 23:58 BSpline\BH_BSpline.h
文件 31620 2009-01-04 18:31 BSpline\BSpline.aps
文件 4113 2009-01-04 18:48 BSpline\BSpline.clw
文件 4491 2008-08-22 16:47 BSpline\BSpline.cpp
文件 5007 2008-02-18 22:46 BSpline\BSpline.dsp
文件 522 2008-01-22 11:42 BSpline\BSpline.dsw
文件 1483 2008-01-22 11:42 BSpline\BSpline.h
文件 279552 2009-01-04 18:50 BSpline\BSpline.ncb
文件 1583 2009-01-04 18:39 BSpline\BSpline.plg
文件 15254 2008-08-28 21:54 BSpline\BSpline.rc
文件 3328 2008-02-17 18:59 BSpline\BSplineDoc.cpp
文件 1827 2008-02-17 18:59 BSpline\BSplineDoc.h
文件 1425 2008-02-04 11:23 BSpline\BSplineSettingDlg.h
文件 3310 2008-02-19 17:52 BSpline\BSplineView.h
文件 1135533 2008-01-22 16:29 BSpline\BSPLINE_UML.mdl
文件 1135533 2008-01-22 16:29 BSpline\BSPLINE_UML.md~
文件 12619 2008-02-20 22:18 BSpline\MainFrm.cpp
文件 2895 2008-02-19 17:11 BSpline\MainFrm.h
文件 1137073 2008-01-22 14:38 BSpline\model.md~
文件 5522 2008-02-20 22:40 BSpline\PrimaryFunctionView.cpp
文件 1513 2008-02-19 15:37 BSpline\PrimaryFunctionView.h
文件 4338 2008-01-22 11:40 BSpline\ReadMe.txt
文件 2088 2008-02-19 17:11 BSpline\resource.h
文件 209 2008-01-22 11:40 BSpline\StdAfx.cpp
文件 1327 2008-01-22 11:40 BSpline\StdAfx.h
文件 15 2008-02-18 22:19 BSpline\新建 文本文档.txt
文件 130048 2008-02-19 20:44 BSpline\程序说明.doc
文件 1178 2008-01-28 09:13 BSpline\Restore.1\BSpline.lst
文件 8452 2008-01-27 21:47 BSpline\Restore.1\~BH_BSpline.~cpp
............此处省略24个文件信息
评论
共有 条评论