具体的数据结构采用半边数据结构实现,希望对于学习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);<