当前位置: 首页>>代码示例>>C++>>正文


C++ PolyhedronPtr类代码示例

本文整理汇总了C++中PolyhedronPtr的典型用法代码示例。如果您正苦于以下问题:C++ PolyhedronPtr类的具体用法?C++ PolyhedronPtr怎么用?C++ PolyhedronPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PolyhedronPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UniformScaling

void Various_Processing_Component::UniformScaling (PolyhedronPtr pMesh, double scalingFactor)
{
	Affine_transformation uniformScaling(CGAL::SCALING, scalingFactor);
	std::transform(pMesh->points_begin(), pMesh->points_end(), pMesh->points_begin(), uniformScaling);

	pMesh->compute_normals();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:7,代码来源:Various_Processing_Component.cpp

示例2: 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++;

			
			
		}
		
}
开发者ID:MEPP-team,项目名称:MEPP,代码行数:30,代码来源:MSDM2_Component.cpp

示例3: Rotation

void Various_Processing_Component::Rotation (PolyhedronPtr pMesh, double xAxis, double yAxis, double zAxis, double angle)
{
	// normalize the translation vector
	double normAxis = sqrt(xAxis*xAxis + yAxis*yAxis + zAxis*zAxis);
	xAxis = xAxis / normAxis;
	yAxis = yAxis / normAxis;
	zAxis = zAxis / normAxis;

	// construction of the rotation matrix
	double c = cos(angle/180.0*PI);
	double s = sin(angle/180.0*PI);
	double m00 = xAxis*xAxis + (1.0-xAxis*xAxis)*c;
	double m01 = xAxis*yAxis*(1.0-c) - zAxis*s;
	double m02 = xAxis*zAxis*(1.0-c) + yAxis*s;
	double m10 = xAxis*yAxis*(1.0-c) + zAxis*s;
	double m11 = yAxis*yAxis + (1.0-yAxis*yAxis)*c;
	double m12 = yAxis*zAxis*(1.0-c) - xAxis*s;
	double m20 = xAxis*zAxis*(1.0-c) - yAxis*s;
	double m21 = yAxis*zAxis*(1.0-c) + xAxis*s;
	double m22 = zAxis*zAxis + (1.0-zAxis*zAxis)*c;

	// realize rotation by applying general affine transformation through matrix multiplication
	Affine_transformation rotation(m00, m01, m02, m10, m11, m12, m20, m21, m22);
	std::transform(pMesh->points_begin(), pMesh->points_end(), pMesh->points_begin(), rotation);

	pMesh->compute_normals();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:27,代码来源:Various_Processing_Component.cpp

示例4: main

int main(int argc, char* argv[])
{
  if (argc != 3)
  {
    std::cerr << "syntax: convexify <input> <output>" << std::endl;
    std::cerr << std::endl;
    std::cerr << "convexify takes the description of a 3D geometry from the input file (a Wavefront OBJ" << std::endl;
    std::cerr << "file) and constructs a new Wavefront 3D file of the convex hull of that file." << std::endl;
    return -1;
  }

  // read in the file
  IndexedTriArray mesh = IndexedTriArray::read_from_obj(std::string(argv[1])); 

  // get the vertices
  const std::vector<Origin3d>& vertices = mesh.get_vertices();

  // compute the convex hull
  PolyhedronPtr p = CompGeom::calc_convex_hull(vertices.begin(), vertices.end());    

  // write the resulting mesh to the output file
  if (!p)
  {
    std::cerr << "convexify() - fatal error computing convex hull!  (sorry I can't tell you more!" << std::endl;
    return -1;
  }

  // write the file
  p->get_mesh().write_to_obj(std::string(argv[2]));
}
开发者ID:PositronicsLab,项目名称:no-slip-and-viscous-experiments,代码行数:30,代码来源:convexify.cpp

示例5: Translation

void Various_Processing_Component::Translation (PolyhedronPtr pMesh, double xTranslation, double yTranslation, double zTranslation)
{
	Vector translationVector(xTranslation,yTranslation, zTranslation);
	Affine_transformation translation(CGAL::TRANSLATION, translationVector);
	std::transform(pMesh->points_begin(), pMesh->points_end(), pMesh->points_begin(), translation);

	pMesh->compute_normals();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:8,代码来源:Various_Processing_Component.cpp

示例6: subdivide_loop

bool Various_Tools_Component::subdivide_loop(PolyhedronPtr pMesh)
{
	Polyhedron_subdivision<Polyhedron>::Loop_subdivision(*pMesh,1);
	pMesh->compute_normals();
	pMesh->compute_type();

	return true;
}
开发者ID:VisualComputeLabinXDU,项目名称:MeshDisplay,代码行数:8,代码来源:Various_Tools_Component.cpp

示例7: subdivide_catmull

bool Various_Tools_Component::subdivide_catmull(PolyhedronPtr pMesh)
{
	Polyhedron_subdivision<Polyhedron>::CatmullClark_subdivision(*pMesh,1);
	pMesh->compute_normals();
	pMesh->compute_type();

	return true;
}
开发者ID:VisualComputeLabinXDU,项目名称:MeshDisplay,代码行数:8,代码来源:Various_Tools_Component.cpp

示例8:

bool Various_Tools_Component::subdivide_sqrt3Twice(PolyhedronPtr pMesh)
{
	CSubdivider_sqrt3<Polyhedron,Enriched_kernel> subdivider;
	subdivider.subdivide(*pMesh,2); // two iterations
	pMesh->compute_normals();
	pMesh->compute_type();

	return true;
}
开发者ID:VisualComputeLabinXDU,项目名称:MeshDisplay,代码行数:9,代码来源:Various_Tools_Component.cpp

示例9:

	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]);

				  }
				}
			}

		}
	}
开发者ID:MEPP-team,项目名称:MEPP,代码行数:56,代码来源:MSDM2_Component.cpp

示例10: ConstructFaceColorMap

	void VSA_Component::ConstructFaceColorMap(PolyhedronPtr pMesh)
{
		
                //Vertex_iterator pVertex = NULL; // MT

		Facet_iterator pFacet	=	pMesh->facets_begin();
		for(;pFacet	!= pMesh->facets_end();pFacet++)
		{

			double R=(double)(pFacet->LabelVSA)/(double)pMesh->NbFaceLabel*255.;
			int indiceLut=floor(R);

			pFacet->color(LUT_Seg[3*indiceLut],LUT_Seg[3*indiceLut+1],LUT_Seg[3*indiceLut+2]);

		}
}
开发者ID:151706061,项目名称:MEPP,代码行数:16,代码来源:VSA_Component.cpp

示例11: 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();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:56,代码来源:Various_Processing_Component.cpp

示例12: 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;
}
开发者ID:VisualComputeLabinXDU,项目名称:MeshDisplay,代码行数:45,代码来源:Various_Tools_Component.cpp

示例13: Subdivision

void Various_Processing_Component::Subdivision (PolyhedronPtr pMesh, Subdivision_type subdivisionType, int depth)
{
	if (subdivisionType==CATMULLCLARK)
		SubdivisionCatmullClark(pMesh, depth);
	else if (subdivisionType==LOOP)
		SubdivisionLoop(pMesh, depth);
	else if (subdivisionType==DOOSABIN)
		SubdivisionDooSabin(pMesh, depth);
	else if (subdivisionType==SQRT3)
		SubdivisionSqrt3(pMesh, depth);
	else if (subdivisionType==MIDPOINT)
		SubdivisionMidpoint(pMesh, depth);

	// after connectivity modification of the mesh, we need to update the related internal properties such as "m_pure_quad" or "m_pure_triangle"
	// other updates can be necessary depending on application
	pMesh->compute_type();
	pMesh->compute_normals();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:18,代码来源:Various_Processing_Component.cpp

示例14: 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;
	}
}
开发者ID:151706061,项目名称:MEPP,代码行数:22,代码来源:Canonical_Component.cpp

示例15: 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();
}
开发者ID:Fenreos,项目名称:MEPP,代码行数:60,代码来源:Various_Processing_Component.cpp


注:本文中的PolyhedronPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。