数字几何处理实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Asignment2
完成人
学号:
这一实验主要实现了以下三项要求:
1.Implementation of a simple disk parameterization method (of a disk topology
mesh, i.e.,genus zero with a single boundary) using uniform and discrete
harmonic (i.e cotangent)barycentric coordinates with circular boundary.
e of parameterization for texture mapping.
putation of parameterization distortion as the overall distortion of triangle
areas and angles.
在这一次实验中遇到的问题主要有:
在键盘操作编程中由于数字的处理不合适总会出现当repeat number减小到1时会出现错误导致之后的操作不能运行。

经过单独对其进行限制处理后得到解决。

在这几次实验中主要的收获有:
逐渐熟悉使用visual studio来进行图像数字处理的一些基本操作和重要算法的实现。

对3D模型有了跟深入的了解并激发了对数字几何处理方面如3D扫描的兴趣。

这是一门非常有意思的课程而且很大程度上增强了我动手操作的能力。

主要代码如下:
ParamViewer::
ParamViewer(const char* _title, int _width, int _height, int iRepeat)
: MeshViewer(_title, _width, _height)
{
_Repeat = iRepeat*5;
mesh_.request_vertex_colors();
mesh_.add_property(vpos_);
mesh_.add_property(vparam_u_);
mesh_.add_property(vparam_h_);
mesh_.add_property(texcoord_u_);
mesh_.add_property(texcoord_h_);
mesh_.add_property(eweight_);
mesh_.add_property(vparam_index_);
add_draw_mode("UV Domain");
add_draw_mode("Textured mesh");
_TextureCoordinates_u=NULL;
_TextureCoordinates_h=NULL;
_ParameterizationMode_ = NoParameterization;
init();
}
ParamViewer::
~ParamViewer()
{
if (glIsTexture(textureID_))
glDeleteTextures( 1, &textureID_); if (_TextureCoordinates_u)
delete [] _TextureCoordinates_u;
if (_TextureCoordinates_h)
delete [] _TextureCoordinates_h;
}
void
ParamViewer::
init()
{
// base class first
MeshViewer::init();
// generate checkerboard-like image
GLubyte tex[256][256][3];
int index=0;
for (int x=0; x<256; ++x)
{
for (int y=0; y<256; ++y)
{
if ((x<128&&y<128) ||(x>128&&y>128))
{
tex[x][y][0] = 0;
tex[x][y][1] = 255;
tex[x][y][2] = 0;
}
else
{
tex[x][y][0] = 255;
tex[x][y][1] = 255;
tex[x][y][2] = 255;
}
}
}
// generate texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (!glIsTexture(textureID_))
glGenTextures(1, &textureID_);
glBindTexture(GL_TEXTURE_2D, textureID_);
// copy texture to GL
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256,
0, GL_RGB, GL_UNSIGNED_BYTE, tex);
}
//-----------------------------------------------------------------------------
......
......
......
void
ParamViewer::
keyboard(int key, int x, int y)
{
switch (toupper(key))
{
case 'O':
{
//.pts (point cloud) file opening
CFileDialog dlg(TRUE, LPCTSTR("off"), LPCTSTR("*.off"));
if (dlg.DoModal() == IDOK){
mesh_.clear();
open_mesh(dlg.GetPathName().GetBuffer());
}
break;
}
case 'U':
{
_ParameterizationMode_ = Uniform;
if (!_ParameterizationComputed_u)
{
calc_uniform_parameterization();
ComputeTextureCoordinates(256, 256, _Repeat, _ParameterizationMode_);
calc_distortion(_ParameterizationMode_);
_ParameterizationComputed_u = true;
}
glutPostRedisplay();
break;
}
case 'H':
{
_ParameterizationMode_ = Harmonic;
if (!_ParameterizationComputed_h)
{
calc_harmonic_parameterization();
ComputeTextureCoordinates(256, 256, _Repeat, _ParameterizationMode_);
calc_distortion(_ParameterizationMode_);
_ParameterizationComputed_h = true;
}
glutPostRedisplay();
break;
}
case 'R': {
_Repeat++;
ComputeTextureCoordinates(256, 256, _Repeat, Uniform);
ComputeTextureCoordinates(256, 256, _Repeat, Harmonic);
printf("Number of repeats: %d\n",_Repeat);
glutPostRedisplay();
break;
}
case 'E': {
if (_Repeat>1) _Repeat--;
ComputeTextureCoordinates(256, 256, _Repeat, Uniform);
ComputeTextureCoordinates(256, 256, _Repeat, Harmonic);
printf("Number of repeats: %d\n",_Repeat);
glutPostRedisplay();
break;
}
default:
{
MeshViewer::keyboard(key, x, y);
break;
}
}
}
主要实验结果截图如下:1 SOLID FLAT
2 SOLID SMOOTH
3 UV DOMAIN
3 TEXTURED MESH 1).number of repeat=5
2). number of repeat=10
3).number of repeat=25
3)。

相关文档
最新文档