• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ AddVertex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: contour

// adds an arc to the given center, start point, pen width, and angle (degrees).
bool VRML_LAYER::AppendArc( double aCenterX, double aCenterY, double aRadius,
                            double aStartAngle, double aAngle, int aContourID )
{
    if( aContourID < 0 || (unsigned int) aContourID >= contours.size() )
    {
        error = "AppendArc(): invalid contour (out of range)";
        return false;
    }

    aAngle = aAngle / 180.0 * M_PI;
    aStartAngle = aStartAngle / 180.0 * M_PI;

    int nsides = calcNSides( aRadius, aAngle );

    double da = aAngle / nsides;

    bool fail = false;

    if( aAngle > 0 )
    {
        aAngle += aStartAngle;
        for( double ang = aStartAngle; ang < aAngle; ang += da )
            fail |= !AddVertex( aContourID, aCenterX + aRadius * cos( ang ),
                                aCenterY + aRadius * sin( ang ) );
    }
    else
    {
        aAngle += aStartAngle;
        for( double ang = aStartAngle; ang > aAngle; ang += da )
            fail |= !AddVertex( aContourID, aCenterX + aRadius * cos( ang ),
                                aCenterY + aRadius * sin( ang ) );
    }

    return !fail;
}
开发者ID:PatMart,项目名称:kicad-source-mirror,代码行数:36,代码来源:vrml_layer.cpp


示例2: add

bool add(int which_poly, int x, int y) 
{ 
    bool res = false;
    vertex *v; 

    v = (vertex*)malloc(sizeof(vertex)); 
    v->x = x; 
    v->y = y;
    v->alpha = 0.;
    v->internal = false;
    v->linkTag = 0;

    if (which_poly == 1) 
    { 
	v->next = s_size+1 ;
	res = AddVertex(s,s_size,v);
    } 
    else if (which_poly == 2) 
    { 
	v->next = c_size+1 ;
	res = AddVertex(c,c_size,v);
    } 
    else {
	printf("%d is not a valid polygon index.\n",which_poly);
	exit(1);
    }
    free(v);

    return res;
}
开发者ID:ablimit,项目名称:hadoopgis,代码行数:30,代码来源:driver.c


示例3: Drawable

Mesh::Mesh(Program &program)
	: Drawable(program)
	, vbuffer(-1)
	, nbuffer(-1)
	, tbuffer(-1)
	, fbuffer(-1)
	, texture(NULL)
{
	AddVertex(-1.0, -1.0, -1.0);
	AddVertex(-1.0, 1.0, -1.0);
	AddVertex(1.0, 1.0, -1.0);
	AddVertex(1.0, -1.0, -1.0);

	AddTexcoord(0, 1);
	AddTexcoord(0, 0);
	AddTexcoord(1, 0);
	AddTexcoord(1, 1);

	AddColour(1.0, 0.0, 0.0);
	AddColour(0.0, 1.0, 0.0);
	AddColour(0.0, 0.0, 1.0);
	AddColour(1.0, 1.0, 1.0);

	AddNormal(0.0, 0.0, 1.0);
	AddNormal(0.0, 0.0, 1.0);
	AddNormal(0.0, 0.0, 1.0);
	AddNormal(0.0, 0.0, 1.0);

	AddFace(0, 1, 2);
	AddFace(2, 3, 0);
	InitBuffers();
}
开发者ID:Wynjones1,项目名称:game,代码行数:32,代码来源:drawable.cpp


示例4: SetTexture

	void CDX9Renderer::Box(const rect& r, cr_float angle, point hotspot, const color& c)
	{
		// No support for textured lines
		SetTexture(NULL);

		quad q((r - hotspot).rotate_to_quad(angle, r.topleft()));

		BeginBatch(batch_linestrip);
		CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());

		D3DCOLOR color = c.getD3DCOLOR();

		// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
		AddVertex(color, q.tl, 0.0f, 0.0f);
		AddVertex(color, q.tr, 0.0f, 0.0f);
		AddVertex(color, q.br, 0.0f, 0.0f);
		AddVertex(color, q.bl, 0.0f, 0.0f);

		unsigned short index = draw_op->vertex_count;
		AddIndex(index);
		AddIndex(index + 1);
		AddIndex(index + 2);
		AddIndex(index + 3);
		AddIndex(index);

		draw_op->vertex_count += 4;
		draw_op->index_count += 5;
	}
开发者ID:segafan,项目名称:Construct-classic,代码行数:28,代码来源:CDX9Renderer_Batch.cpp


示例5: fgets

void Mesh::ReadVertexData(FILE *fp, int num, bool have_normals, bool have_tex)
{
	double n[3];
	double v[3];
	double t[2];
	char buf[1024];
	for(int i = 0; i < num; i++)
	{
		fgets(buf, 1024, fp);
		if(have_normals && have_tex)
		{
			sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf %lf", v, v+1, v+2, n, n+1, n+2, t, t+1);
			AddVertex(v);
			AddNormal(n);
			AddTexcoord(t);
		}
		else if(have_normals)
		{
			sscanf(buf, "%lf %lf %lf %lf %lf %lf", v, v+1, v+2, n, n+1, n+2);
			AddVertex(v);
			AddNormal(n);
		}
		else if(have_tex)
		{
			sscanf(buf, "%lf %lf %lf %lf %lf", v, v+1, v+2, t, t+1);
			AddVertex(v);
			AddTexcoord(t);
		}
		else
		{
			sscanf(buf, "%lf %lf %lf", v, v+1, v+2);
			AddVertex(v);
		}
	}
}
开发者ID:Wynjones1,项目名称:game,代码行数:35,代码来源:drawable.cpp


示例6: AddVertex

void CircleEvaluator::Evaluate() {
    // Add the vertexes specified
    double x;
    double y;
    double pi = 3.14159265;

    // We parametrically evaluate the circle
    // x = sin(t)
    // y = cos(t)
    // t goes from 0 to 2pi
    // 0 degrees = 0rad, 90 degrees = pi/2rad, etc.

    double startRad = m_StartArcDegrees / 180 * pi;
    double endRad = m_EndArcDegrees / 180 * pi;
    double radPerPoint = m_DegreesPerPoint / 180 * pi;

    if (startRad > endRad)
        endRad += 2*pi;

    double currentRad = startRad;

    do {
        x = m_Radius*sin(currentRad) + m_XOrigin;
        y = m_Radius*cos(currentRad) + m_YOrigin;

        AddVertex(x,y);
        currentRad += radPerPoint;
    } while (currentRad < endRad);

    x = m_Radius*sin(endRad) + m_XOrigin;
    y = m_Radius*cos(endRad) + m_YOrigin;

    AddVertex(x, y);
}
开发者ID:jpoirier,项目名称:GlassCockpit,代码行数:34,代码来源:CircleEvaluator.cpp


示例7: DeleteVertices

bool CFuzzyMembershipFunction::InitTriangle (long x1, long x2, long x3)
{
  if ((x1 < x2) && (x2 < x3))
  {
    CFuzzyElement FE;
    DeleteVertices();

    // Left vertex.
    FE.SetValue(x1);
    FE.SetMembership(0.0);
    AddVertex(FE);

    // Peak vertex.
    FE.SetValue(x2);
    FE.SetMembership(1.0);
    AddVertex(FE);

    // Right vertex.
    FE.SetValue(x3);
    FE.SetMembership(0.0);
    AddVertex(FE);

    return true;
  }

  return false;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:27,代码来源:FuzzyMembershipFunction.cpp


示例8: printf

/**
 * @function BuildManifold
 */
void HP2D::BuildManifold( Vertex* _v0 ) {
	
	Vertex* va;
    std::vector<Vertex*> S;
	std::vector<Vertex*> B;

	printf("Build Manifold \n");
	AddVertex( _v0 );	
	EnQueue( _v0 );

	while( mQ.size() != 0 ) {
		va = DeQueue();
		S = Successors( va );

		for( unsigned int i = 0; i < S.size(); ++i ) {
			AddVertex( S[i] );
			AddEdge( va, S[i] );
			if( S[i]->GetDist() < DIST_MAX ) {		
				EnQueue( S[i] );
			}
			B = GetAdjacent2( va );
			for( unsigned j = 0; j < B.size(); ++j ) {
				if( CheckPosNeighbors( B[j], S[i] ) == true ) {
					AddEdge( S[i], B[j] );
				}
			}
		}		
	}
}
开发者ID:ana-GT,项目名称:Homo2D,代码行数:32,代码来源:HP2D.cpp


示例9: AddTriangle

    /** Add triangle to connectivity information */
    int32 AddTriangle( const FVector &a, const FVector &b, const FVector &c )
    {
        // Map vertices
        int32 VertexA = AddVertex( a );
        int32 VertexB = AddVertex( b );
        int32 VertexC = AddVertex( c );

        // Make sure triangle is not degenerated
        if ( VertexA!=VertexB && VertexB!=VertexC && VertexC!=VertexA )
        {
            // Setup connectivity info
            int32 TriangleIndex = Triangles.Num();
            Vertices[ VertexA ].AddTriangleLink( TriangleIndex );
            Vertices[ VertexB ].AddTriangleLink( TriangleIndex );
            Vertices[ VertexC ].AddTriangleLink( TriangleIndex );

            // Create triangle
            new ( Triangles ) FMeshConnectivityTriangle( VertexA, VertexB, VertexC );
            return TriangleIndex;
        }
        else
        {
            // Degenerated triangle
            return INDEX_NONE;
        }
    }
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:27,代码来源:StaticMeshEdit.cpp


示例10: NewContour

// adds a circle the existing list; if 'hole' is true the contour is
// a hole. Returns true if OK.
bool VRML_LAYER::AddCircle( double x, double y, double rad, int csides, bool hole )
{
    int pad = NewContour();

    if( pad < 0 )
    {
        error = "AddCircle(): failed to add a contour";
        return false;
    }

    if( csides < 6 )
        csides = CalcNSides( rad, maxdev );

    // even numbers give prettier results
    if( csides & 1 )
        csides += 1;

    double da = M_PI * 2.0 / csides;

    bool fail = false;

    if( hole )
    {
        for( double angle = 0; angle < M_PI * 2; angle += da )
            fail |= !AddVertex( pad, x + rad * cos( angle ), y - rad * sin( angle ) );
    }
    else
    {
        for( double angle = 0; angle < M_PI * 2; angle += da )
            fail |= !AddVertex( pad, x + rad * cos( angle ), y + rad * sin( angle ) );
    }

    return !fail;
}
开发者ID:jerkey,项目名称:kicad,代码行数:36,代码来源:vrml_board.cpp


示例11: AddVertex

int AdjList::AddEdge(const Vertex& from, const Vertex& to, int cost)
{

	if(!hasVertex(from))
	{
		AddVertex(from);
	}
	
	if(!hasVertex(to))
	{
		AddVertex(to);
	}
	
	for(auto& vinfo: m_vinfoList)
	{
		if(from == vinfo.m_vertex)
		{
			for(const auto& edge: vinfo.m_edges)
			{
				if(edge.m_to == to)
				{
					return -1; // already added
				}
			}
			vinfo.m_edges.push_back({to, cost});
			return GRAPH_OK;
		}
	}

	return GRAPH_ERROR_VERTEX_NOT_FOUND;
}
开发者ID:jnyabe,项目名称:lang,代码行数:31,代码来源:adj_list.cpp


示例12: AddFacet

void Scene::Extrude (int n, float* x, float* y, float depth, 
		     const Trafo& P, const ColorB* color)
{
  int n1 = n-1, n2 = 2*n-2;
     
  // add front and back polygonal with n vertices
  // the back polygonal has reverse orientation

  Facet &front = AddFacet(n),
        &back  = AddFacet(n);
    
  if (color) {
    front.SetColor(*color);
    back.SetColor(*color);
  }

  // create vertices and link them to facets
  int i;
  for (i = 0; i < n; i++) { 
    front(i) = &AddVertex( P * Vertex(x[i],y[i],0.0) );
    back(i)  = &AddVertex( P * Vertex(x[n1-i],y[n1-i],-depth) );
    if (color) {
      front[i].SetColor(*color);
      back[i].SetColor(*color);
    }
  }

  // create n facets for the sides and link the vertices
  for (i = 0; i < n; i++) { 
    Facet &side = AddFacet(4, front(i), back(n1-i),
			   back((n2-i)%n), front((i+1)%n) );
    if (color) side.SetColor(*color);
  }
}
开发者ID:lucafuji,项目名称:Gene-Correlation,代码行数:34,代码来源:scnextrude.cpp


示例13: AddVertex

void kexCpuVertList::AddLine(float x1, float y1, float z1,
                          float x2, float y2, float z2,
                          byte r, byte g, byte b, byte a) {
    
    *(roverIndices++) = vertexCount; indiceCount++;
    AddVertex(x1, y1, z1, 0, 0, r, g, b, a);
    *(roverIndices++) = vertexCount; indiceCount++;
    AddVertex(x2, y2, z2, 0, 0, r, g, b, a);
}
开发者ID:svkaiser,项目名称:TurokEX,代码行数:9,代码来源:cpuVertexList.cpp


示例14: AddVertex

void CSimpleUGraph< ObjT, Compare >::AddEdge( const ObjT &oV1, const ObjT & oV2 )
{
  typename boost::graph_traits<Graph>::edge_descriptor e;
  bool bAdded;
  AddVertex( oV1 );   // should lazy these two - check to see if vertex is there first
  AddVertex( oV2 );
  Vertex u = oDataToVertexMap[ oV1 ];
  Vertex v = oDataToVertexMap[ oV2 ];
  boost::tie( e, bAdded ) = add_edge( v, u, oBoostGraph );    // add edge
}
开发者ID:CMU-Suter-Group,项目名称:XDMXX,代码行数:10,代码来源:SimpleGraph.tmpl.cpp


示例15: AddBaseTriangle

/// <summary>
/// Helper function to create a face for the base octahedron.
/// </summary>
/// <param name="mesh">Mesh</param>
/// <param name="p1">Vertex 1.</param>
/// <param name="p2">Vertex 2.</param>
/// <param name="p3">Vertex 3.</param>
void AddBaseTriangle(D3DVECTOR& p1, D3DVECTOR& p2, D3DVECTOR& p3)
{
    AddVertex(p1.x, p1.y, p1.z, p1.x, p1.y, p1.z, 0, 0);
    AddVertex(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z, 0, 0);
    AddVertex(p3.x, p3.y, p3.z, p3.x, p3.y, p3.z, 0, 0);
    
    AddIndex(nextIndex++);
    AddIndex(nextIndex++);
    AddIndex(nextIndex++);
}
开发者ID:AnthonyNystrom,项目名称:NuGenBioChemDX,代码行数:17,代码来源:Sphere.cpp


示例16: ReadData

/* Read network from the training file */
void ReadData()
{
  FILE *fin;
  char name_v1[MAX_STRING], name_v2[MAX_STRING], str[2 * MAX_STRING + 10000];
  int vid;
  double weight;

  fin = fopen(network_file, "rb");
  if (fin == NULL)
  {
    printf("ERROR: network file not found!\n");
    exit(1);
  }
  num_edges = 0;
  while (fgets(str, sizeof(str), fin)) num_edges++;
  fclose(fin);
  printf("Number of edges: %lld          \n", num_edges);

  edge_source_id = (int *)malloc(num_edges*sizeof(int));
  edge_target_id = (int *)malloc(num_edges*sizeof(int));
  edge_weight = (double *)malloc(num_edges*sizeof(double));
  if (edge_source_id == NULL || edge_target_id == NULL || edge_weight == NULL)
  {
    printf("Error: memory allocation failed!\n");
    exit(1);
  }

  fin = fopen(network_file, "rb");
  num_vertices = 0;
  for (int k = 0; k != num_edges; k++)
  {
    fscanf(fin, "%s %s %lf", name_v1, name_v2, &weight);

    if (k % 10000 == 0)
    {
      printf("Reading edges: %.3lf%%%c", k / (double)(num_edges + 1) * 100, 13);
      fflush(stdout);
    }

    vid = SearchHashTable(name_v1);
    if (vid == -1) vid = AddVertex(name_v1);
    vertex[vid].degree += weight;
    edge_source_id[k] = vid;

    vid = SearchHashTable(name_v2);
    if (vid == -1) vid = AddVertex(name_v2);
    vertex[vid].degree += weight;
    edge_target_id[k] = vid;

    edge_weight[k] = weight;
  }
  fclose(fin);
  printf("Number of vertices: %d          \n", num_vertices);
}
开发者ID:chentingpc,项目名称:LINE,代码行数:55,代码来源:line.cpp


示例17: LoadMeshInstanceIntoToy

void LoadMeshInstanceIntoToy(CConversionScene* pScene, CConversionMeshInstance* pMeshInstance, const Matrix4x4& mParentTransformations)
{
	if (!pMeshInstance->IsVisible())
		return;

	CConversionMesh* pMesh = pMeshInstance->GetMesh();

	for (size_t m = 0; m < pScene->GetNumMaterials(); m++)
	{
		for (size_t j = 0; j < pMesh->GetNumFaces(); j++)
		{
			size_t k;
			CConversionFace* pFace = pMesh->GetFace(j);

			if (pFace->m == ~0)
				continue;

			CConversionMaterial* pMaterial = NULL;
			CConversionMaterialMap* pConversionMaterialMap = pMeshInstance->GetMappedMaterial(pFace->m);

			if (!pConversionMaterialMap)
				continue;

			if (!pConversionMaterialMap->IsVisible())
				continue;

			if (pConversionMaterialMap->m_iMaterial != m)
				continue;

			while (g_asTextures.size() <= pConversionMaterialMap->m_iMaterial)
			{
				g_asTextures.push_back(pScene->GetMaterial(pConversionMaterialMap->m_iMaterial)->GetDiffuseTexture());
				g_aaflData.push_back();
			}

			size_t iMaterial = pConversionMaterialMap->m_iMaterial;

			CConversionVertex* pVertex0 = pFace->GetVertex(0);

			for (k = 2; k < pFace->GetNumVertices(); k++)
			{
				CConversionVertex* pVertex1 = pFace->GetVertex(k-1);
				CConversionVertex* pVertex2 = pFace->GetVertex(k);

				AddVertex(iMaterial, mParentTransformations * pMesh->GetVertex(pVertex0->v), pMesh->GetUV(pVertex0->vu));
				AddVertex(iMaterial, mParentTransformations * pMesh->GetVertex(pVertex1->v), pMesh->GetUV(pVertex1->vu));
				AddVertex(iMaterial, mParentTransformations * pMesh->GetVertex(pVertex2->v), pMesh->GetUV(pVertex2->vu));
			}
		}
	}
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:51,代码来源:loadsource.cpp


示例18: AddVertex

//-----------------------------------------------------------------------------
bool SimpleMesh::AddFace(const std::vector<Vector3<float> > &verts){

  unsigned int ind1, ind2, ind3;
  AddVertex(verts.at(0), ind1);
  AddVertex(verts.at(1), ind2);
  AddVertex(verts.at(2), ind3);

  Face tri(ind1, ind2, ind3);
  mFaces.push_back(tri);
  // Compute and assign a normal
  mFaces.back().normal = FaceNormal(mFaces.size() - 1);

  return true;
}
开发者ID:ikee,项目名称:tnm079,代码行数:15,代码来源:SimpleMesh.cpp


示例19: sizeof

bool CFuzzyMembershipFunction::Read (std::istream& stream)
{
  // Check the fuzzy membership function type type
  EFileTypes FileType;
  stream.read((char*)&FileType, sizeof(FileType));
  if (FileType != fFuzzyMembershipFunction)
  {
    return false;
  }

  // Read in number of characters in the name.
  unsigned short NumCharsInName;
  stream.read((char*)&NumCharsInName, sizeof(NumCharsInName));

  // Read in name one character at a time.
  m_Name.erase();
  for (unsigned short s = 0; s < NumCharsInName; s++)
  {
    m_Name += stream.get();
  }

  // Read in Tnorm.
  stream.read((char*)&m_Tnorm,sizeof(m_Tnorm));

  // Read in Tconorm.
  stream.read((char*)&m_Tconorm,sizeof(m_Tconorm));

  // Read in number of CFuzzyElements in the membership function.
  long NumVertices;
  stream.read((char*)&NumVertices, sizeof(NumVertices));

  // Read in each CFuzzyElement.
  CFuzzyElement FE;
  for (long v = 0; v < NumVertices; v++)
  {
    // Read in value. 
    long Value;
    stream.read((char*)&Value, sizeof(Value));
    FE.SetValue(Value);

    // Read in membership.
    double Membership;
    stream.read((char*)&Membership, sizeof(Membership));
    FE.SetMembership(Membership);

    // Read in Tnorm. 
    ETnormOperations Tnorm;
    stream.read((char*)&Tnorm,sizeof(Tnorm));
    FE.SetTnorm(Tnorm);

    // Read in Tconorm.
    ETconormOperations Tconorm;
    stream.read((char*)&Tconorm,sizeof(Tconorm));
    FE.SetTconorm(Tconorm);

    AddVertex(FE);
  }

  return true;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:60,代码来源:FuzzyMembershipFunction.cpp


示例20: LoadSU2Vertices

int LoadSU2Vertices(FILE *FilHdl, Mesh *Msh)
{
	int iVer, d, ref;
	double crd[3], bufDbl;
	char str[1024];
	
	rewind(FilHdl);
	
	Msh->NbrVer = GetSU2KeywordValue (FilHdl, "NPOIN=");
	
	if ( Msh->NbrVer > Msh->MaxNbrVer ) {
		printf("  ## ERROR: LoadSU2Vertices: INCONSISTENT NUMBER OF VERTICES.\n");
		return 0;
	}
	
  for (iVer=1; iVer<=Msh->NbrVer; iVer++) {
		
    crd[2] = 0;
		
    for (d=0; d<Msh->Dim; d++) {
      fscanf(FilHdl, "%lf", &bufDbl);
      crd[d] = bufDbl;
    }
    
    fscanf(FilHdl, "%d", &ref);
    fgets (str, sizeof str, FilHdl);
    
		AddVertex(Msh, iVer, crd);
  }
	
	return 1;
}
开发者ID:rfenrich,项目名称:MULTIF,代码行数:32,代码来源:SU2io.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AddWaypoint函数代码示例发布时间:2022-05-30
下一篇:
C++ AddVectoredExceptionHandler函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap