コード例 #1
0
ファイル: Mesh.cpp プロジェクト: andikan/GaussMesh
void Mesh::runCDT()
{
	PointSet *ps = new PointSet();
	for(uint i = 0; i < this->pNum; i++)
		ps->addPoint(new Point(i, this->vertexBuffer[i*9], this->vertexBuffer[i*9+1]));
	// Start with pointSet sorted by x
	ps->sortPSet(X);
	this->ps = ps;
	
	printf("Start DT\n");
	CDT(*ps);
	#ifdef MESHSHADER
	this->loadEdgeFromPointSet(*ps);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	this->shader->render(GL_ARRAY_BUFFER, this->VBid, this->assm, 0, this->pNum, true);
	glfwSwapBuffers();
	printf("End DT\n");
	system("pause");
	#endif
	
	printf("Start Constrained\n");
	boundConstraint(*ps);
	#ifdef MESHSHADER
	this->loadEdgeFromPointSet(*ps);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	this->shader->render(GL_ARRAY_BUFFER, this->VBid, this->assm, 0, this->pNum, true);
	glfwSwapBuffers();
	printf("End Constrained\n");
	system("pause");
	#endif
	
	printf("Creating Spine\n");
	int baseID = pruneAndSpine(*ps);
	#ifdef MESHSHADER
	this->loadEdgeFromPointSet(*ps);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	this->shader->render(GL_ARRAY_BUFFER, this->VBid, this->assm, 0, this->pNum, true);
	glfwSwapBuffers();
	printf("End Creating\n");
	system("pause");
	#endif
	
	printf("Bubbling Up\n");
	vector<Point*> spine = getSpine(*ps, baseID);
	bubbleUp(*ps, spine, 1);
	bubbleUp(*ps, spine, -1);
	#ifdef MESHSHADER
	this->loadEdgeFromPointSet(*ps);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	this->shader->render(GL_ARRAY_BUFFER, this->VBid, this->assm, 0, this->pNum, true);
	glfwSwapBuffers();
	printf("End Bubbling\n");
	system("pause");
	#endif

	cleanSpineBase(*ps, spine);
	setAllPointNormal(*ps);
	printf("Finished\n");
	
	this->loadTriangleFromPointSet(*ps);
}