采用欧拉操作实现扫成

这篇博客介绍了一种采用欧拉操作实现扫成的方法,适用于CAD/CG领域的学习者。通过绘制基础面,结合指定向量和距离,可以创建出三维体。主要涉及到的数据结构为半边数据结构,并提供了关键代码实现包括:添加顶点(mvfs)、添加边(mev)、添加面(mef)以及合并环(kemr)等操作。
摘要由CSDN通过智能技术生成

具体的数据结构采用半边数据结构实现,希望对于学习CAD/CG方面的朋友有所帮助~~~

具体的实现功能是:

通过绘制一个基本的面,然后通过该面通过指定的向量和距离就可以扫成为一个体。

具体的实现关键代码为:

CSolid* CEulerDoc::mvfs(GLdouble *point)
{
 CSolid *newSolid;
 CFace *newFace;
 CLoop *newLoop;
 CVertex *newVert;
 newSolid = new CSolid;
 newFace = new CFace;
 newLoop = new CLoop;
 newVert = new CVertex;

 // Set the coordinate of the new vertex
 newVert->SetCoord(point);

 // Add the new face to the new solid
 newSolid->AddFace(newFace);

 // Add the new vertex to the new solid
 newSolid->AddVertex(newVert);

 // Add the new loop to the new face
 newFace->AddLoop(newLoop);
 
 return newSolid;
}

CHalfEdge* CEulerDoc::mev(GLdouble *point1, GLdouble *point2, CLoop* lp)
{
 CSolid  *pSolid = lp->host_f->host_s;
 CVertex  *v1, *newVert;
 CEdge  *newEdge;
 CHalfEdge *he1, *he2;
 newVert = new CVertex;
 newEdge = new CEdge;
 he1 = new CHalfEdge;
 he2 = new CHalfEdge;

 // Find the start vertex of the edge
 v1 = pSolid->FindVertex(point1);
 if(!v1)
 {
  AfxMessageBox("Can't find the point1!");
  return NULL;
 }

 // Set the coordinate of the new vertex
 newVert->SetCoord(point2);

 // Set v1 as the start vertex of halfedge1
 he1->SetVertex(v1);

 // Set v2 as the start vertex of halfedge2
 he2->SetVertex(newVert);

 // Add two new halfedges to the loop
 lp->AddHalfEdge(he1, he2);

 // Set the new edge to new halfedges
 he1->edge = he2->edge = newEdge;
 newEdge->he1 = he1;
 newEdge->he2 = he2;

 // Add the new edge to the solid
 pSolid->AddEdge(newEdge);

 // Add the new vertex to the solid
 pSolid->AddVertex(newVert);

 return he1;
}

CLoop* CEulerDoc::mef(GLdouble *point1, GLdouble *point2, CLoop* lp)
{
 CSolid  *pSolid = lp->host_f->host_s;
 CVertex  *v1, *v2;
 // Find the two given vertex
 v1 = pSolid->FindVertex(point1);<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值