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


C++ GeometryPtr::endFaces方法代码示例

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


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

示例1: enter

/*
  Aufruf dieser Funktion erfolgt bei Traversierung des Szenengraphen
  mittels OpenSG-Funktion traverse().
  Enthaelt ein Knoten verwertbare Geometrieinformation so tragen wir
  Zeiger auf seine Geometrie (OpenSG-Strukturen) im array gla_meshInfo_
  ein.
  Nebenbei bestimmen wir für die Geometrie auch noch die World-Space-
  Transformation (evtl. existiert eine OpenSG-Funktion um diese
  Information zu erhalten, der Autor hat keine in der OpenSG-API
  entdeckt).
*/
Action::ResultE enter(NodePtr &node)
{
    int             i, j, h;
    Pnt3f           v;
    int             numFaces, numFaceVertices, vId, size;

    MeshInfo        meshInfo;
    TinyMatrix      transf;
    FaceIterator    fit;
    int             numQuads;
    NamePtr         namePtr;
    char            name[255];

    namePtr = NamePtr::dcast(node->findAttachment(Name::getClassType().getGroupId()));
    if(namePtr == osg::NullFC)
        strcpy(name, "");
    else
    {
        strcpy(name, namePtr->getFieldPtr()->getValue().c_str());
    }

    SINFO << "Node name = '" << name << "'" << endl << endLog;

    GeometryPtr geo = GeometryPtr::dcast(node->getCore());

    if(geo != NullFC)
    {
        GeoPLengthsUI32Ptr  pLength = GeoPLengthsUI32Ptr::dcast(geo->getLengths());
        GeoPTypesUI8Ptr     pTypes = GeoPTypesUI8Ptr::dcast(geo->getTypes());

        /* pLength and pTypes should not be NullFC, however VRML Importer/Exporter
		  code is instable by now, so this can happen */
        if((pLength != NullFC) && (pTypes != NullFC))
        {
            GeoPLengthsUI32::StoredFieldType * pLengthField = pLength->getFieldPtr();
            GeoPTypesUI8::StoredFieldType * pTypeField = pTypes->getFieldPtr();

            size = pLengthField->size();

            for(h = 0; h < size; h++)
            {
                if(((*pTypeField)[h] == GL_TRIANGLES) ||
                   ((*pTypeField)[h] == GL_QUADS))
                {
                    /* may quads appear in GL_TRIANGLES ? */
                    /* check if all triangles have three vertices */
                    numQuads = 0;
                    fit = geo->beginFaces();
                    while(fit != geo->endFaces())
                    {
                        numFaceVertices = fit.getLength();
                        if(numFaceVertices == 4)
                            numQuads++;
                        if(numFaceVertices > 4)
                        {
                            SWARNING <<
                                "More than 4 vertices in face!" <<
                                endl <<
                                endLog;
                            return Action::Continue;

                            // exit(1);
                        }

                        ++fit;
                    }

                    if(numQuads > 0)
                    {
                        SWARNING << "Quad encountered" << endl << endLog;
                    }

                    if(gl_sga->nodeDepth_ > 0)
                    {
                        for(i = 0; i < gl_sga->nodeDepth_; i++)
                        {
                            meshInfo.transf = meshInfo.transf * gl_sga->transf_[i];
                        }
                    }
                    else
                        meshInfo.transf.identity();

                    /* access to vertices */
                    GeoPositions3fPtr   pPos = GeoPositions3fPtr::dcast(geo->getPositions());
                    GeoPositions3f::StoredFieldType * pPosField = pPos->getFieldPtr();

                    /* access to faces */
                    numFaces = 0;
                    fit = geo->beginFaces();
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opensgplus,代码行数:101,代码来源:OSGWMSceneGraphAccess.cpp

示例2: renderScene


//.........这里部分代码省略.........
		vector<int> ct;
		ct.push_back(red);
		ct.push_back(green);
		ct.push_back(blue);

		// put in map
		color_map[index] = ct;
	}

	cout << "Colors seen in frame: "<< color_map.size()<<endl;

	map<int,vector<int> >::iterator mip;
	// for all _visible_ triangles
	int h(0);
	FaceIterator fit = TEST->beginFaces();
	float thresh = 0.95;
	int count_lines_drawn(0);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINES);

	vector<Pnt3f> cp;
	for(mip = color_map.begin();mip != color_map.end();mip++){
		int face_index = _COLORS[mip->first];
		fit.seek(face_index);

		int a = fit.getPositionIndex(0);
		int b = fit.getPositionIndex(1);
		int c = fit.getPositionIndex(2);

		FaceIterator nit;
		glBegin(GL_LINES);
		glColor3f(1.0,0,0);
		for(nit = TEST->beginFaces();nit != TEST->endFaces();++nit)
		{

			if(fit.getIndex() == nit.getIndex())
				continue;
			int a2 = nit.getPositionIndex(0);
			int b2 = nit.getPositionIndex(1);
			int c2 = nit.getPositionIndex(2);

			// a-b
			if(a == a2 || a == b2 || a == c2)
				if(b == a2 || b == b2 || b == c2){
					if(fit.getNormal(0).dot(nit.getNormal(0)) < thresh){
						count_lines_drawn++;
						//glVertex3f(fit.getPosition(0)[0],fit.getPosition(0)[1],fit.getPosition(0)[2]);
						//glVertex3f(fit.getPosition(1)[0],fit.getPosition(1)[1],fit.getPosition(1)[2]);
						_LINES.push_back(fit.getPosition(0));
						_LINES.push_back(fit.getPosition(1));
						//createControlPoints(_LINES.size()-2,fit.getPosition(0),fit.getPosition(1));
					}
					h++;
				}
			// a-c
			if(a == a2 || a == b2 || a == c2)
				if(c == a2 || c == b2 || c == c2){
					if(fit.getNormal(0).dot(nit.getNormal(0)) < thresh){
						count_lines_drawn++;
						//glVertex3f(fit.getPosition(0)[0],fit.getPosition(0)[1],fit.getPosition(0)[2]);
						//glVertex3f(fit.getPosition(2)[0],fit.getPosition(2)[1],fit.getPosition(2)[2]);
						_LINES.push_back(fit.getPosition(0));
						_LINES.push_back(fit.getPosition(2));
						//createControlPoints(_LINES.size()-2,fit.getPosition(0),fit.getPosition(2));
					}
开发者ID:stefanedm,项目名称:track,代码行数:67,代码来源:main.cpp

示例3: convertToTs


//.........这里部分代码省略.........

        /* second pass */
        numVertices = 0;
        numFaces = 0;

        for(i = 0; i < numGeometryNodes_; i++)
        {
            if((i > 0) && (meshInfo_[i].meshId != meshInfo_[i - 1].meshId))
            {
                offsetVertices += meshInfo_[i - 1].numVertices;
            }

            if((i == 0) || (meshInfo_[i].meshId != meshInfo_[i - 1].meshId))
            {
                /* set vertex data */
                for(j = 0; j < meshInfo_[i].vPtr->size(); j++)
                {
                    v[0] = (*meshInfo_[i].vPtr)[j][0];
                    v[1] = (*meshInfo_[i].vPtr)[j][1];
                    v[2] = (*meshInfo_[i].vPtr)[j][2];

                    /* transformation does matter for case of single flat mesh */
                    v = meshInfo_[i].transf * v;    /* transform into world space */

                    ts->setVertex(offsetVertices + j, v);
                }

                numVertices += meshInfo_[i].numVertices;
            }

            /* set face data */
            geoPtr = meshInfo_[i].geoPtr;

            for(fit = geoPtr->beginFaces(); fit != geoPtr->endFaces(); ++fit)
            {
                /* this should be always 3 */
                numFaceVertices = fit.getLength();
                if(numFaceVertices == 4)
                {
                    for(j = 0; j < 4; j++)
                    {
                        quadVIds[j] = fit.getPositionIndex(j);
                        (*isQuadVertex)->setBit(quadVIds[j], 1);
                    }

                    /* split quad into two triangles */
                    ts->setFace(numFaces, offsetVertices + quadVIds[0],
                                offsetVertices + quadVIds[1],
                                offsetVertices + quadVIds[2]);
                    numFaces++;
                    ts->setFace(numFaces, offsetVertices + quadVIds[2],
                                offsetVertices + quadVIds[3],
                                offsetVertices + quadVIds[0]);
                    numFaces++;
                }
                else
                {
                    if(numFaceVertices != 3)
                    {
                        printf("numFaceVertices=%d\n", numFaceVertices);

                        // exit(1);
                        return -1;
                    }

                    for(j = 0; j < 3; j++)
开发者ID:BackupTheBerlios,项目名称:opensgplus,代码行数:67,代码来源:OSGWMSceneGraphAccess.cpp


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