本文整理汇总了C++中Solid::edgeVertex1方法的典型用法代码示例。如果您正苦于以下问题:C++ Solid::edgeVertex1方法的具体用法?C++ Solid::edgeVertex1怎么用?C++ Solid::edgeVertex1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solid
的用法示例。
在下文中一共展示了Solid::edgeVertex1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
// Read in the obj file
Solid mesh;
OBJFileReader of;
std::ifstream in(argv[1]);
of.readToSolid(&mesh, in);
//answer part
Solid meshCopy;
mesh.copy(meshCopy);
//storing all vertices
int i=0;
SolidVertexIterator veriter(&mesh);
Vertex *allvert[mesh.numVertices()];
for(i=0;!veriter.end();i++,++veriter)
{
allvert[i]=*veriter;
}
//storing all edges
SolidEdgeIterator eiter(&mesh);
Edge *alledges[mesh.numEdges()];
for(i=0;!eiter.end();i++,++eiter)
{
alledges[i]=*eiter;
}
Edge *swapList[mesh.numFaces()];
Edge *splitSwap[2]={NULL,NULL};
//getting max face
SolidFaceIterator fciter(&mesh);
int maxfcid=-1;
for(; !fciter.end(); ++fciter)
{
if((*fciter)->id()>maxfcid)
maxfcid=(*fciter)->id();
}
//splitting and swapping by iterating through edges
SolidEdgeIterator eitercpy(&meshCopy);
int j;
double x,y,z;
for(i=0,j=0;i<(sizeof(alledges)/sizeof(*alledges));i++,++eitercpy)
{
splitSwap[0]=splitSwap[1]=NULL;
Vertex *evert1= mesh.edgeVertex1(alledges[i]);
Vertex *evert2= mesh.edgeVertex2(alledges[i]);
Vertex *ver1=mesh.edgeSplit(alledges[i],splitSwap,maxfcid);
if(splitSwap[0]!=NULL)
swapList[j++]=splitSwap[0];
if(splitSwap[1]!=NULL)
swapList[j++]=splitSwap[1];
//position of new vertex determined here
if(mesh.isBoundary(*eitercpy))
{
//printf("Check");
x=(evert1->point()(0)/2)+(evert2->point()(0)/2);
y=(evert1->point()(1)/2)+(evert2->point()(1)/2);
z=(evert1->point()(2)/2)+(evert2->point()(2)/2);
//printf("\n%f %f %f\n",x,y,z);
}
else
{
x=((evert1->point()(0))+(evert2->point()(0)))*(3.0/8.0);
y=((evert1->point()(1))+(evert2->point()(1)))*(3.0/8.0);
z=((evert1->point()(2))+(evert2->point()(2)))*(3.0/8.0);
x+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(0)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(0)/8.0);
y+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(1)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(1)/8.0);
z+=(((((*eitercpy)->halfedge(0))->he_next())->target())->point()(2)/8.0)+(((((*eitercpy)->halfedge(1))->he_next())->target())->point()(2)/8.0);
}
ver1->point()=Point(x,y,z);
}
for(i=0;i<(sizeof(swapList)/sizeof(*swapList));i++)
{
Edge *e=swapList[i];
mesh.edgeSwap(e,((e->halfedge(0))->he_next())->target(),((e->halfedge(1))->he_next())->target());
}
//new position of old vertices determined here
SolidVertexIterator veritercpy(&meshCopy);
double tem1,tem2,tem3,alpha;
for(i=0;i<(sizeof(allvert)/sizeof(*allvert));i++,++veritercpy)
{
Vertex *oldv=allvert[i];
//printf("\n%f %f %f -> ",oldv->point()(0),oldv->point()(1),oldv->point()(2));
//.........这里部分代码省略.........
示例2: main
void main(int argc, char *argv[])
{
// Read in the obj file
Solid mesh;
OBJFileReader of;
std::ifstream in(argv[1]);
of.readToSolid(&mesh, in);
SolidDelegate sodel;
SolidVertexIterator viter(&mesh);
SolidFaceIterator faceiter(&mesh);
Point deltaPL[2502];
Point Normal[2502];
Point tuettePoint[2502];
Point harmonicPoint[2502];
double innerProduct;
Point normalComp;
Point aDerv;
for (int i = 0; i < 2502; i++)
{
deltaPL[i][0] = 0.0;
deltaPL[i][1] = 0.0;
deltaPL[i][2] = 0.0;
Normal[i][0] = 0.0;
Normal[i][1] = 0.0;
Normal[i][2] = 0.0;
tuettePoint[i][0] = 0.0;
tuettePoint[i][1] = 0.0;
tuettePoint[i][2] = 0.0;
harmonicPoint[i] = { 0.0, 0.0, 0.0 };
}
for (; !viter.end(); ++viter)
{
Vertex *vertmp = *viter;
//VertexOutHalfedgeIterator voh(&mesh, vertmp);
Point norm;//calc new Norm
double totalArea = 0.0;
norm[0] = norm[1] = norm[2] = 0.0;
VertexFaceIterator vf(vertmp);
for (; !vf.end(); ++vf){
double area = 0.0;
Face *f = *vf;
Point v1 = f->halfedge()->source()->point();
Point v2 = f->halfedge()->target()->point();
Point v3 = f->halfedge()->he_next()->target()->point();
area = ((v3 - v1) ^ (v2 - v1)).norm();
Point n = f->norm();
norm += n * area;
totalArea += area;
}
Point newNorm;
norm = norm / totalArea;
double normN = norm.norm();
newNorm = norm / normN;
//Normal & Gauss Map
Normal[vertmp->id() - 1] = newNorm;
}
SolidEdgeIterator edgeiter(&mesh);
double tuetteEnergy = 0.0;
double newTEnergy = 0.0;
double harmoincEnergy = 0.0;
double newHEnergy = 0.0;
double stepLength = 0.01;
double eThreshold = 0.00001;
for (; !edgeiter.end(); ++edgeiter) {
Edge *e = *edgeiter;
Vertex *s = mesh.edgeVertex1(e);
Vertex *t = mesh.edgeVertex2(e);
tuetteEnergy += (Normal[s->id() - 1] - Normal[t->id() - 1]).norm2();
}
//harmonic K
double K, cota, cotb;
//.........这里部分代码省略.........