本文整理汇总了C++中Vertex_iterator::point方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertex_iterator::point方法的具体用法?C++ Vertex_iterator::point怎么用?C++ Vertex_iterator::point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex_iterator
的用法示例。
在下文中一共展示了Vertex_iterator::point方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: selectClosest_tmp
void Remesh::selectClosest_tmp() {
int i=0;
FILE *select = fopen("select.dat", "w");
Vertex_handle vdst;
for (Vertex_iterator vi = dst_mesh.p.vertices_begin(); vi != dst_mesh.p.vertices_end(); vi++) {
vi->id = -1;
}
for (Vertex_iterator vi = data->mesh.p.vertices_begin(); vi!=data->mesh.p.vertices_end(); vi++) {
Kernel::Point_3 closest_point = dst_mesh.closestPoint(vi->point());
cerr << i << ": " << vi->point() << " closest to " << closest_point << endl;
if(v_norm(closest_point - vi->point()) < dst_mesh.edge_avg*alg_smoothing) {
vdst = dst_mesh.vertex_mapping[closest_point];
cerr << "whose id is " << vdst->id;
vdst->weight = 2;
vdst->id = i;
cerr << " changed to " << vdst->id << endl;
} i++;
}
i=0;
for (Vertex_iterator vi = dst_mesh.p.vertices_begin(); vi != dst_mesh.p.vertices_end(); vi++) {
if(vi->weight == 2) {
fprintf(select, "%d\t%d\n", i,vi->id);
}
i++;
}
fclose(select);
cerr << "Done with printing out stuff ! Exiting " << endl;
exit(0);
}
示例3: CGALPolyhedronToVTKPolydata_converter
void CGALPolyhedronToVTKPolydata_converter(Polyhedron *polyhedron, vtkSmartPointer<vtkPolyData> polydata)
{
//convert from cgal polyhedron to vtk poly data
//first the points
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> faces = vtkSmartPointer<vtkCellArray>::New();
//iterator over all vertices in polyhedron, add them as points
std::map<Vertex_handle, vtkIdType> V;
vtkIdType inum = 0;
for ( Vertex_iterator v = polyhedron->vertices_begin(); v != polyhedron->vertices_end(); ++v)
{
points->InsertNextPoint(v->point()[0],v->point()[1],v->point()[2]);
V[v] = inum++;
}
//now iterate over all faces in polyhedron
for ( Facet_iterator i = polyhedron->facets_begin(); i != polyhedron->facets_end(); ++i)
{
Halfedge_around_facet_circulator j = i->facet_begin();
faces->InsertNextCell(CGAL::circulator_size(j));
do
{
//get indice of vertex, insert new cell point into faces
faces->InsertCellPoint(V[j->vertex()]);
} while(++j != i->facet_begin());
}
// Set the points and faces of the polydata
polydata->SetPoints(points);
polydata->SetPolys(faces);
}
示例4: transformMesh
void transformMesh( Polyhedron & poly, Transformation3 & map )
{
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
Point3 store = vi->point().transform( map );
vi->point() = store;
}
}
示例5: compute_bounding_box
void Mesh::compute_bounding_box()
{
if (size_of_vertices() == 0)
return;
float xmin, xmax, ymin, ymax, zmin, zmax;
Vertex_iterator pVertex = vertices_begin();
xmin = xmax = pVertex->point().x;
ymin = ymax = pVertex->point().y;
zmin = zmax = pVertex->point().z;
for(;pVertex != vertices_end();pVertex++)
{
const Vec3& p = pVertex->point();
xmin = qMin(xmin,p.x);
ymin = qMin(ymin,p.y);
zmin = qMin(zmin,p.z);
xmax = qMax(xmax,p.x);
ymax = qMax(ymax,p.y);
zmax = qMax(zmax,p.z);
}
m_min = Vec3(xmin, ymin, zmin);
m_max = Vec3(xmax, ymax, zmax);
m_diagLength = Vec3::distance(m_min, m_max);
m_axisLength = Vec3(m_min, m_max);
m_minMaxCenter = (m_min + m_max) / 2.0f;
}
示例6: smoothMesh
void smoothMesh( Polyhedron & poly, unsigned int nTimes )
{
int nV = poly.size_of_vertices();
const double lambda = SMOOTHING_LAMBDA;
const double mu = SMOOTHING_MU;
vector< Point3 > shrink ( nV );
vector< Point3 > expand ( nV );
for ( unsigned int k = 0; k < nTimes; ++k ) {
// copy the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
shrink [ vi->id() ] = vi->point();
}
// shrinking stage
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
moveVertex( vi, shrink[ vi->id() ], lambda );
}
// copy back the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = shrink[ vi->id() ];
expand[ vi->id() ] = shrink[ vi->id() ];
}
// expanding stage
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
moveVertex( vi, expand[ vi->id() ], mu );
}
// copy back the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = expand[ vi->id() ];
}
}
}
示例7: 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();
}
示例8:
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]);
}
}
}
}
}
示例9: changeAllPoints
void DegradeAnObject::changeAllPoints() {
for(std::vector<Polyhedron>::iterator P = polys.begin() ; P != polys.end() ; ++P) {
for ( Vertex_iterator v = P->vertices_begin(); v != P->vertices_end(); ++v) {
Point_3 p(v->point().x()+((double) rand() / (RAND_MAX)),v->point().y()+((double) rand() / (RAND_MAX)),v->point().z()+((double) rand() / (RAND_MAX)));
v->point() = p;
std::cout << v->point() << std::endl;
}
std::cout << "--" << std::endl;
}
}
示例10: 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++;
}
}
示例11: getPoints
/**
* Gets the list of points from the mesh
* @param points Stores the list of points
*/
void StoneWeatherer::getPoints( vector<Point> & points ) const {
for ( Vertex_iterator it = newDT->finite_vertices_begin(); it != newDT->finite_vertices_end(); ++it ) {
points.push_back( it->point() );
}
}
示例12: modify_vertex_position
void modify_vertex_position()
{
Polyhedron P;
Halfedge_handle h = P.make_tetrahedron();
if ( P.is_tetrahedron(h))
{
int i(0);
for(Vertex_iterator vi = P.vertices_begin(); vi != P.vertices_end(); ++vi,++i)
{
std::cout << "before changing vertex " << i << ": " << vi->point().x() << vi->point().y() << vi->point().z() << endl;
Point_3 pt(1, 0, 0);
vi->point() = pt;
std::cout << "after changing vertex " << i << ": " << vi->point().x() << vi->point().y() << vi->point().z() << endl;
}
}
}
示例13: 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;
}
示例14: 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();
}
示例15: normalizeMesh
//------------------------------------------------------------------------------
// Normalize the 3D triangulated mesh with the display window
//------------------------------------------------------------------------------
void normalizeMesh( Polyhedron & poly, vector< Segment3 > & bone )
{
Vector3 sum, ave;
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
sum = sum + ( vi->point() - CGAL::ORIGIN );
}
ave = sum / ( double )poly.size_of_vertices();
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = vi->point() - ave;
}
cerr << " ave = " << ave << endl;
Transformation3 translate( CGAL::TRANSLATION, -ave );
// fabs:absolute values-no negative values
double sideMax = 0.0;
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
if ( fabs( vi->point().x() ) > sideMax ) sideMax = fabs( vi->point().x() );
if ( fabs( vi->point().y() ) > sideMax ) sideMax = fabs( vi->point().y() );
if ( fabs( vi->point().z() ) > sideMax ) sideMax = fabs( vi->point().z() );
}
// sideMax: the largest number
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = CGAL::ORIGIN + ( vi->point() - CGAL::ORIGIN ) / sideMax;
}
Transformation3 scale( CGAL::SCALING, 1.0/sideMax );
Transformation3 composite = scale * translate;
for ( unsigned int k = 0; k < bone.size(); ++k ) {
bone[ k ] = bone[ k ].transform( composite );
}
}