资源简介
生成维诺图,先产生点,生成凸包,进行Delaunay三角剖分,最后生成维诺图。使用OpenGL显示结果,注释详尽,基于visual studio 2017的控制台程序。
代码片段和文件信息
/*!
* \file RgbImage.cpp
* \brief Implementation of RgbImage Class
* \date Documented on 10/08/2010
*
*/
#include “RgbImage.h“
#ifndef RGBIMAGE_DONT_USE_OPENGL
#include
#include “GL/gl.h“
#endif
/*! RgbImage constructor
* \param numRows number of rows
* \param numCols number of cols
*/
RgbImage::RgbImage( int numRows int numCols )
{
NumRows = numRows;
NumCols = numCols;
ImagePtr = new unsigned char[NumRows*GetNumBytesPerRow()];
if ( !ImagePtr ) {
fprintf(stderr “Unable to allocate memory for %ld x %ld bitmap.\n“
NumRows NumCols);
Reset();
ErrorCode = MemoryError;
}
// Zero out the image
unsigned char* c = ImagePtr;
int rowLen = GetNumBytesPerRow();
for ( int i=0; i {
for ( int j=0; j {
*(c++) = 0;
}
}
}
/* ********************************************************************
* LoadBmpFile
* Read into memory an RGB image from an uncompressed BMP file.
* Return true for success false for failure. Error code is available
* with a separate call.
* Author: Sam Buss December 2001.
**********************************************************************/
/*!
* LoadBmpFile
* \param filename input file name
* \return whether the loading is successful
*/
bool RgbImage::LoadBmpFile( const char* filename )
{
Reset();
errno_t err;
FILE* infile; // Open for reading binary data
if ((err = fopen_s(&infile filename “rb“)) != 0) {
fprintf(stderr “Unable to open file: %s\n“ filename);
ErrorCode = OpenError;
return false;
}
if ( !infile ) {
fprintf(stderr “Unable to open file: %s\n“ filename);
ErrorCode = OpenError;
return false;
}
bool fileFormatOK = false;
int bChar = fgetc( infile );
int mChar = fgetc( infile );
if ( bChar==‘B‘ && mChar==‘M‘ ) { // If starts with “BM“ for “BitMap“
skipChars( infile 4+2+2+4+4 ); // Skip 4 fields we don‘t care about
NumCols = readLong( infile );
NumRows = readLong( infile );
skipChars( infile 2 ); // Skip one field
int bitsPerPixel = readShort( infile );
skipChars( infile 4+4+4+4+4+4 ); // Skip 6 more fields
if ( NumCols>0 && NumCols<=100000 && NumRows>0 && NumRows<=100000
&& bitsPerPixel==24 && !feof(infile) ) {
fileFormatOK = true;
}
}
if ( !fileFormatOK ) {
Reset();
ErrorCode = FileFormatError;
fprintf(stderr “Not a valid 24-bit bitmap file: %s.\n“ filename);
fclose ( infile );
return false;
}
// Allocate memory
ImagePtr = new unsigned char[NumRows*GetNumBytesPerRow()];
if ( !ImagePtr ) {
fprintf(stderr “Unable to allocate memory for %ld x %ld bitmap: %s.\n“
NumRows NumCols filename);
Reset();
ErrorCode = MemoryError;
fclose ( infile );
return false;
}
unsigned char* cPtr = ImagePtr;
for ( int i=0; i int j;
for ( j=0; j *(cPtr+2) = fgetc( infile ); // Blue color value
*(cPtr+1) = fgetc( infile ); // Green color value
*cPtr = fgetc( infile ); // Red
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-04 17:56 Voronoi Diagram2D\
目录 0 2018-07-24 15:40 Voronoi Diagram2D\.vs\
目录 0 2018-07-24 15:40 Voronoi Diagram2D\.vs\Voronoi Diagram2D\
目录 0 2018-12-04 17:56 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\
文件 34816 2018-12-04 17:56 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\.suo
文件 6733824 2018-12-04 17:56 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\Browse.VC.db
目录 0 2018-07-24 15:40 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\
目录 0 2018-12-04 17:56 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\
目录 0 2018-07-26 17:37 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\597c50cab9dc43b4\
文件 50069504 2018-07-27 08:17 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\597c50cab9dc43b4\MAIN.ipch
目录 0 2018-07-24 15:40 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\638424cb7ccb77c4\
文件 50069504 2018-07-21 13:35 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\638424cb7ccb77c4\MAIN.ipch
目录 0 2018-07-24 15:40 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\b3961218084a946a\
文件 52035584 2018-07-14 14:01 Voronoi Diagram2D\.vs\Voronoi Diagram2D\v15\ipch\AutoPCH\b3961218084a946a\HEDER.ipch
目录 0 2018-07-24 15:40 Voronoi Diagram2D\MeshLib\
目录 0 2018-07-24 15:40 Voronoi Diagram2D\MeshLib\core\
目录 0 2018-07-24 15:40 Voronoi Diagram2D\MeshLib\core\bmp\
文件 11443 2018-07-05 20:32 Voronoi Diagram2D\MeshLib\core\bmp\RgbImage.cpp
文件 7829 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\bmp\RgbImage.h
目录 0 2018-07-24 15:40 Voronoi Diagram2D\MeshLib\core\Geometry\
文件 5082 2017-10-15 12:56 Voronoi Diagram2D\MeshLib\core\Geometry\Point.h
文件 6549 2017-03-10 11:59 Voronoi Diagram2D\MeshLib\core\Geometry\Point2.H
文件 4239 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Geometry\quat.h
目录 0 2018-07-24 15:40 Voronoi Diagram2D\MeshLib\core\Mesh\
文件 61863 2018-07-20 20:00 Voronoi Diagram2D\MeshLib\core\Mesh\ba
文件 11064 2017-04-11 21:08 Voronoi Diagram2D\MeshLib\core\Mesh\boundary.h
文件 24050 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Mesh\DynamicMesh.h
文件 1778 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Mesh\Edge.h
文件 1333 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Mesh\Face.h
文件 3825 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Mesh\HalfEdge.h
文件 20604 2016-01-21 19:07 Voronoi Diagram2D\MeshLib\core\Mesh\iterators.h
............此处省略19个文件信息
- 上一篇:rsa算法实现系统
- 下一篇:飞机大战全套游戏素材
评论
共有 条评论