• 大小: 3.02MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-31
  • 语言: 其他
  • 标签: 浙江大学  作业  

资源简介

可能有内存泄漏什么的,不过结果应该是对的。

资源截图

代码片段和文件信息

#include “HalfEdge.h“
#include 
#include 
#include 
#include 
#include 

std::tuple MakeVertexFaceSolid(const Coord& coord)
{
auto solid = new Solid;
auto face = new Face;
auto loop = new Loop;
auto vertex = new Vertex;

solid->faces.push_back(face);
face->parentSolid = solid;

face->outerLoop = loop;
loop->parentFace = face;

vertex->coord = coord;
solid->vertices.push_back(vertex);

return std::make_tuple(vertex face solid);
}

std::tuple MakeEdgeVertex(Vertex* vertex0 Loop* loop Coord coord)
{
auto vertex1 = new Vertex;
auto edge = new Edge;
auto halfEdge0 = new HalfEdge;
auto halfEdge1 = new HalfEdge;

vertex1->coord = coord;
halfEdge0->vertex = vertex0;
halfEdge1->vertex = vertex1;

halfEdge0->next = halfEdge1;
halfEdge1->pre = halfEdge0;

halfEdge0->parentEdge = edge;
halfEdge1->parentEdge = edge;
halfEdge0->parentLoop = loop;
halfEdge1->parentLoop = loop;

edge->halfEdge0 = halfEdge0;
edge->halfEdge1 = halfEdge1;

if (loop->leadingHalfEdge == nullptr) {
// if loop is empty init with halfEdge0 and halfEdge1
loop->leadingHalfEdge = halfEdge0;
halfEdge0->pre = halfEdge1;
halfEdge1->next = halfEdge0;
} else {
// loop is not empty insert halfEdge0 and halfEdge1
auto tmp = loop->find(vertex0);
halfEdge0->pre = tmp->pre;
halfEdge1->next = tmp;

halfEdge0->pre->next = halfEdge0;
halfEdge1->next->pre = halfEdge1;
}

auto solid = loop->parentFace->parentSolid;
solid->edges.push_back(edge);
solid->vertices.push_back(vertex1);

return std::make_tuple(edge vertex1);
}

std::tuple MakeEdgeFace(Loop* loop0 Vertex* vertex0 Vertex* vertex1)
{
auto solid = loop0->parentFace->parentSolid;
auto face = new Face;
auto loop1 = new Loop;
auto edge = new Edge;
auto halfEdge0 = new HalfEdge;
auto halfEdge1 = new HalfEdge;

// set face
solid->faces.push_back(face);
face->parentSolid = loop0->parentFace->parentSolid;
face->outerLoop = loop1;
// set edge
solid->edges.push_back(edge);
edge->halfEdge0 = halfEdge0;
edge->halfEdge1 = halfEdge1;
// set loop1
loop1->parentFace = face;

// find tmp half edges
auto tmphe0 = loop0->find(vertex0);
auto tmphe1 = loop0->find(vertex1);

// link two new half edges to loop
halfEdge0->next = tmphe1;
halfEdge0->pre = tmphe0->pre;
halfEdge1->next = tmphe0;
halfEdge1->pre = tmphe1->pre;

tmphe0->pre->next = halfEdge0;
tmphe1->pre->next = halfEdge1;
tmphe0->pre = halfEdge1;
tmphe1->pre = halfEdge0;

// set two half edges
halfEdge0->parentLoop = loop0;
halfEdge0->parentEdge = edge;
halfEdge1->parentLoop = loop1;
halfEdge1->parentEdge = edge;
halfEdge0->vertex = vertex0;
halfEdge1->vertex = vertex1;
// maintain two loop
loop1->leadingHalfEdge = halfEdge1;
loop0->leadingHalfEdge = halfEdge0;
return std::make_tuple(edge face);
}

st

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4212  2015-11-19 19:26  cad\cad.png

     文件    1135324  2015-11-19 17:07  cad\display\BRep.lib

     文件    2132638  2015-11-19 17:07  cad\display\CADMeshEditingLib.lib

     文件     707072  2015-11-19 17:08  cad\display\Meshframework.exe

     文件    7055696  2011-11-21 13:36  cad\display\mfc100d.dll

     文件     631616  2010-09-06 13:24  cad\display\msvcp100d.dll

     文件    1467200  2010-09-06 13:22  cad\display\msvcr100d.dll

     文件        557  2015-11-19 19:25  cad\display\out.brp

     文件       6920  2015-11-19 19:00  cad\HalfEdge.cpp

     文件       1574  2015-11-19 18:11  cad\HalfEdge.h

     文件       3085  2015-11-19 19:29  cad\main.cpp

     目录          0  2015-11-19 19:30  cad\display

     目录          0  2015-11-19 19:30  cad

     文件        312  2015-11-19 19:41  说明.txt

----------- ---------  ---------- -----  ----

             13146206                    14


评论

共有 条评论