本文整理汇总了C++中PolyhedronPtr::vertices_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ PolyhedronPtr::vertices_begin方法的具体用法?C++ PolyhedronPtr::vertices_begin怎么用?C++ PolyhedronPtr::vertices_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolyhedronPtr
的用法示例。
在下文中一共展示了PolyhedronPtr::vertices_begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LaplacianSmoothing
void Various_Processing_Component::LaplacianSmoothing (PolyhedronPtr pMesh, double deformFactor, int iteraNum, bool preserveBoundaries)
{
Vertex_iterator pVertex;
int numVertex = pMesh->size_of_vertices();
Vector * newPositions = new Vector[numVertex];
for (int i=0; i<iteraNum; i++)
{
int n = 0;
for (pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end(); pVertex++)
{
Vector currentVector = pVertex->point() - CGAL::ORIGIN;
// do not smooth the boundary vertices if demanded by user
bool is_border_vertex = false;
bool stopFlag = false;
Halfedge_around_vertex_circulator hav = (*pVertex).vertex_begin();
do
{
if (hav->is_border()==true)
{
is_border_vertex = true;
stopFlag = true;
}
hav++;
} while ((hav!=(*pVertex).vertex_begin())&&(stopFlag==false));
if ((preserveBoundaries==true)&&(is_border_vertex==true))
{
newPositions[n] = currentVector;
n++;
continue;
}
std::size_t degree = (*pVertex).vertex_degree();
double alpha = 1.0/degree;
Vector vectemp = Point3d(0,0,0) - CGAL::ORIGIN;
Halfedge_around_vertex_circulator h = (*pVertex).vertex_begin();
do
{
vectemp = vectemp+(h->opposite()->vertex()->point()-CGAL::ORIGIN-currentVector)*alpha;
++h;
} while (h != (*pVertex).vertex_begin());
newPositions[n] = currentVector + deformFactor*vectemp;
n++;
}
n = 0;
for (pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end(); pVertex++)
{
pVertex->point() = Point3d(0,0,0) + newPositions[n];
n++;
}
}
delete [] newPositions;
newPositions = 0;
pMesh->compute_normals();
}
示例2:
void MSDM2_Component::ConstructColorMap(PolyhedronPtr P, int MetricOrHausdorff)
{
if(MetricOrHausdorff==1)
{
if(P->IsDistanceComputed==true)
{
double R;
int indiceLut;
Vertex_iterator pVertex = NULL;
if(MaxMSDM2>MinMSDM2)
{
for (pVertex = P->vertices_begin();
pVertex != P->vertices_end();
pVertex++)
{
R=(pVertex->MSDM2_Local-MinMSDM2)/(MaxMSDM2-MinMSDM2)*255;
indiceLut=floor(R);
pVertex->color(LUT_CourbureClust[3*indiceLut],LUT_CourbureClust[3*indiceLut+1],LUT_CourbureClust[3*indiceLut+2]);
}
}
}
}
else
{
if(P->IsDistanceComputed==true)
{
double R;
int indiceLut;
Vertex_iterator pVertex = NULL;
if(MaxMSDM2>MinMSDM2)
{
for (pVertex = P->vertices_begin();
pVertex != P->vertices_end();
pVertex++)
{
float d=sqrt((pVertex->point()-pVertex->match)*(pVertex->point()-pVertex->match));
R=(d-MinMSDM2)/(MaxMSDM2-MinMSDM2)*255;
indiceLut=floor(R);
pVertex->color(LUT_CourbureClust[3*indiceLut],LUT_CourbureClust[3*indiceLut+1],LUT_CourbureClust[3*indiceLut+2]);
}
}
}
}
}
示例3: NoiseAdditionUniform
void Various_Processing_Component::NoiseAdditionUniform (PolyhedronPtr pMesh, double noiseIntensity, bool preserveBoundaries)
{
// mesh centre calculation based on discrete "moment".
//TODO: maybe in the future it will be based on volume moment.
int numVertex = pMesh->size_of_vertices();;
Vector centroid = Point3d(0,0,0) - CGAL::ORIGIN;
double distancetoCentroid = 0.0;
Vertex_iterator pVertex;
for (pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end(); pVertex++)
{
Vector vectemp = pVertex->point() - CGAL::ORIGIN;
centroid = centroid + vectemp;
}
centroid = centroid/numVertex;
// calculate the average distance from vertices to mesh centre
for (pVertex = pMesh->vertices_begin(); pVertex!= pMesh->vertices_end(); pVertex++)
{
Vector vectemp = pVertex->point() - CGAL::ORIGIN;
distancetoCentroid = distancetoCentroid + (double)std::sqrt((vectemp - centroid) * (vectemp - centroid));
}
distancetoCentroid = distancetoCentroid/numVertex;
// add random uniform-distributed (between [-noiseLevel, +noiseLevel])
srand((unsigned)time(NULL));
double noisex, noisey, noisez;
double noiseLevel = distancetoCentroid * noiseIntensity;
for (pVertex = pMesh->vertices_begin(); pVertex!= pMesh->vertices_end(); pVertex++)
{
// keep boundaries untouched if demanded by user
bool is_border_vertex = false;
bool stopFlag = false;
Halfedge_around_vertex_circulator hav = (*pVertex).vertex_begin();
do
{
if (hav->is_border()==true)
{
is_border_vertex = true;
stopFlag = true;
}
hav++;
} while ((hav!=(*pVertex).vertex_begin())&&(stopFlag==false));
if ((preserveBoundaries==true)&&(is_border_vertex==true))
continue;
noisex = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
noisey = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
noisez = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
Vector temp = Point3d(noisex, noisey, noisez) - CGAL::ORIGIN;
pVertex->point() = pVertex->point() + temp;
}
// for correct rendering, we need to update the mesh normals
pMesh->compute_normals();
}
示例4: tree
void MSDM2_Component::Matching_Multires_Init(PolyhedronPtr m_PolyDegrad, PolyhedronPtr m_PolyOriginal , Facet * _TabMatchedFacet)
{
// constructs AABB tree
AABB_Tree tree(m_PolyOriginal->facets_begin(),m_PolyOriginal->facets_end());
tree.accelerate_distance_queries();
//Searching for the closest point and facet for each vertex
int ind=0;
for(Vertex_iterator pVertex = m_PolyDegrad->vertices_begin();
pVertex != m_PolyDegrad->vertices_end();
pVertex++)
{
pVertex->MSDM2_Local=0;
// computes closest point and primitive id
Point_and_primitive_id pp = tree.closest_point_and_primitive(pVertex->point());
Point3d Nearest=pp.first;
Facet_iterator f_Nearest = pp.second; // closest primitive id
pVertex->match=Nearest;
_TabMatchedFacet[ind]=*f_Nearest;
ind++;
}
}
示例5: printClickedVertices
string Various_Tools_Component::printClickedVertices(PolyhedronPtr pMesh,double x,double y,int tolerance)
{
GLdouble *model;GLdouble *proj;GLint *view;
view = new GLint[4];
proj = new GLdouble[16];
model = new GLdouble[16];
glGetIntegerv(GL_VIEWPORT,view);
glGetDoublev(GL_MODELVIEW_MATRIX,model);
glGetDoublev(GL_PROJECTION_MATRIX,proj);
y = view[3] - y;
GLdouble wx,wy,wz;
char szInfoVertex[256];
string sInfoVertex = "";
int vertexID = 0;
//VertexID + 4就是该顶点在.obj文件中的行数
for(Vertex_iterator pVertex = pMesh->vertices_begin();pVertex != pMesh->vertices_end();pVertex++)
{
gluProject(pVertex->point().x(),pVertex->point().y
(),pVertex->point().z(),model,proj,view,&wx,&wy,&wz);
if (wz > 0.0 && wz < 1.0)
{
if (x > floor(wx)-tolerance && x < floor(wx)+tolerance)
{
if (y > floor(wy) - tolerance && y < floor(wy)+tolerance)
{
sprintf(szInfoVertex, "Vertex: %u - (%lf, %lf, %lf)", vertexID, pVertex->point().x(), pVertex->point().y(), pVertex->point().z());
sInfoVertex.assign(szInfoVertex);
}
}
}
vertexID++;
}
delete [] view;
delete [] model;
delete [] proj;
return sInfoVertex;
}
示例6: Init
// Description : Initialize all flags -verticeces and facets- to FREE and give order to vertices
// This function is called within every conquest.
void Init(PolyhedronPtr pMesh)
{
int i = 0;
// vertices flags initialization
Vertex_iterator pVertex = NULL;
for(pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end(); i++,pVertex++)
{
pVertex->Vertex_Flag_S = FREE;
pVertex->Vertex_Number_S = i;
pVertex->Vertex_Sign_S = NOSIGN;
}
// facets flag initialization.
Facet_iterator pFace = NULL;
for(pFace = pMesh->facets_begin(); pFace != pMesh->facets_end(); pFace++)
{
pFace->Facet_Flag_S = FREE;
}
}
示例7: New_Position
void mepp_component_Boolean_Operations_plugin::New_Position()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
// active viewer
if (mw->activeMdiChild() != 0)
{
float x, y, z;
double a, b, c, w;
Viewer* viewer = (Viewer *)mw->activeMdiChild();
ScenePtr S = viewer->getScenePtr();
for(int i = 0; i<viewer->getScenePtr()->get_nb_polyhedrons(); i++)
{
Vertex_iterator pVertex = NULL;
PolyhedronPtr P = S->get_polyhedron(i);
viewer->frame(i)->getPosition(x,y,z);
viewer->frame(i)->getOrientation(a,b,c,w);
Vec T(x, y, z);
Quaternion Q(a, b, c, w);
for (pVertex = P->vertices_begin(); pVertex != P->vertices_end(); pVertex++)
{
Vec V = Q * Vec(pVertex->point().x(), pVertex->point().y(), pVertex->point().z()) + T;
pVertex->point() = CGAL::ORIGIN + Vector(V[0], V[1], V[2]);
}
viewer->frame(i)->setPosition(0,0,0);
viewer->frame(i)->setOrientation(0,0,0,1);
}
viewer->show();
viewer->recreateListsAndUpdateGL();
}
QApplication::restoreOverrideCursor();
}
示例8: CoordinateQuantization
// TODO: fixing after quantization the potentially introduced degeneracies, such as removing the null surface facet
void Various_Processing_Component::CoordinateQuantization (PolyhedronPtr pMesh, int bitDepth)
{
Vertex_iterator pVertex;
double quantizationLevel = std::pow(2.0,bitDepth);
pVertex = pMesh->vertices_begin();
Point3d point = pVertex->point();
double xmax = double(point.x());
double xmin = xmax;
double ymax = double(point.y());
double ymin = ymax;
double zmax = double(point.z());
double zmin = zmax;
pVertex++;
for (; pVertex != pMesh->vertices_end(); pVertex++)
{
point = pVertex->point();
double x = double(point.x());
double y = double(point.y());
double z = double(point.z());
if (x>xmax)
xmax = x;
if (x<xmin)
xmin = x;
if (y>ymax)
ymax = y;
if (y<ymin)
ymin = y;
if (z>zmax)
zmax = z;
if (z<zmin)
zmin = z;
}
double xstep = (xmax-xmin)/quantizationLevel;
double ystep = (ymax-ymin)/quantizationLevel;
double zstep = (zmax-zmin)/quantizationLevel;
for (pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end();pVertex++)
{
point = pVertex->point();
double x = double(point.x());
double y = double(point.y());
double z = double(point.z());
double xquantified, yquantified, zquantified;
double xint = 1.0*std::floor((x-xmin)/xstep)*xstep + xmin;
double xfrac = x - xint;
if (xfrac<=(0.5*xstep))
xquantified = xint;
else
xquantified = xint + xstep;
double yint = 1.0*std::floor((y-ymin)/ystep)*ystep + ymin;
double yfrac = y - yint;
if (yfrac<=(0.5*ystep))
yquantified = yint;
else
yquantified = yint +ystep;
double zint = 1.0*std::floor((z-zmin)/zstep)*zstep + zmin;
double zfrac = z - zint;
if (zfrac<=(0.5*zstep))
zquantified = zint;
else
zquantified = zint + zstep;
pVertex->point() = Point3d(xquantified,yquantified,zquantified);
}
pMesh->compute_normals();
}
示例9: NoiseAdditionGaussian
// this time, we add Gaussian-distributed additive noise to the mesh vertex coordinates
// the standard deviation of the Gaussian distribution is "noiseLevel = distancetoCentroid * noiseIntensity"
void Various_Processing_Component::NoiseAdditionGaussian (PolyhedronPtr pMesh, double noiseIntensity, bool preserveBoundaries)
{
int numVertex = pMesh->size_of_vertices();;
Vector centroid = Point3d(0,0,0) - CGAL::ORIGIN;
double distancetoCentroid = 0.0;
Vertex_iterator pVertex;
for (pVertex = pMesh->vertices_begin(); pVertex != pMesh->vertices_end(); pVertex++)
{
Vector vectemp = pVertex->point() - CGAL::ORIGIN;
centroid = centroid + vectemp;
}
centroid = centroid/numVertex;
for (pVertex = pMesh->vertices_begin(); pVertex!= pMesh->vertices_end(); pVertex++)
{
Vector vectemp = pVertex->point() - CGAL::ORIGIN;
distancetoCentroid = distancetoCentroid + (double)std::sqrt((vectemp - centroid) * (vectemp - centroid));
}
distancetoCentroid = distancetoCentroid/numVertex;
srand((unsigned)time(NULL));
double noisex, noisey, noisez;
double * gaussNumbers = new double[3];
double noiseLevel = distancetoCentroid * noiseIntensity;
for (pVertex = pMesh->vertices_begin(); pVertex!= pMesh->vertices_end(); pVertex++)
{
bool is_border_vertex = false;
bool stopFlag = false;
Halfedge_around_vertex_circulator hav = (*pVertex).vertex_begin();
do
{
if (hav->is_border()==true)
{
is_border_vertex = true;
stopFlag = true;
}
hav++;
} while ((hav!=(*pVertex).vertex_begin())&&(stopFlag==false));
if ((preserveBoundaries==true)&&(is_border_vertex==true))
continue;
// pseudo-random Gaussian-distributed numbers generation from uniformly-distributed pseudo-random numbers
double x, y, r2;
for (int i=0; i<3; i++)
{
do
{
x = -1.0 + 2.0 * 1.0*rand()/RAND_MAX;
y = -1.0 + 2.0 * 1.0*rand()/RAND_MAX;
r2 = x * x + y * y;
} while ((r2>1.0)||(r2==0.0));
gaussNumbers[i] = y * sqrt(-2.0 * log(r2) / r2);
}
noisex = noiseLevel * gaussNumbers[0];
noisey = noiseLevel * gaussNumbers[1];
noisez = noiseLevel * gaussNumbers[2];
Vector temp = Point3d(noisex, noisey, noisez) - CGAL::ORIGIN;
pVertex->point() = pVertex->point() + temp;
}
pMesh->compute_normals();
delete [] gaussNumbers;
gaussNumbers = 0;
}