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

C++ VertexAttribute类代码示例

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

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



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

示例1: CCSubdivision

void Surface_Subdivision_Plugin::CCSubdivision(
	const QString& mapName,
	const QString& positionAttributeName, bool interp)
{
	MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
	if(mh == NULL)
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
	if(!position.isValid())
		return;

	pythonRecording("CCSubdivision", "", mapName, positionAttributeName,interp);

	PFP2::MAP* map = mh->getMap();
	if (interp)
		Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision<PFP2>(*map, position);
	else
		Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position);

	mh->notifyAttributeModification(position);
	mh->notifyConnectivityModification();

	foreach(View* view, mh->getLinkedViews())
		view->updateGL();
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:26,代码来源:surface_subdivision.cpp


示例2:

void ShapeMatching<PFP>::computeVelocities(VertexAttribute<VEC3, MAP>& velocity, VertexAttribute<VEC3, MAP>& fext, REAL h, REAL alpha)
{
    for(unsigned int i = velocity.begin() ; i < velocity.end() ; velocity.next(i))
    {
        velocity[i] = velocity[i] + alpha * ((m_goal[i] - m_position[i]) / h ) + (h * fext[i]) / m_mass[i];
    }
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:7,代码来源:shapeMatching.hpp


示例3: updateTF

    void updateTF (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {
        qDebug() << "UPDATING TF2";
        tf.bind();
        //mesh.setAttributeLocation(tf);
        glEnable(GL_RASTERIZER_DISCARD);
        mesh.bindBuffers();
        Tucano::Misc::errorCheckFunc(__FILE__, __LINE__);
        //VertexAttribute* va = mesh.getAttribute("nPos");

        write_va->disable();
        //glDisableVertexAttribArray(mesh.getAttributeLocation("nPos"));

        read_va->enable(tf.getAttributeLocation("inPos"));
        Tucano::Misc::errorCheckFunc(__FILE__, __LINE__);
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, write_va->getBufferID());
        glBeginTransformFeedback(GL_POINTS);
        glEnable(GL_DEPTH_TEST);
        mesh.renderPoints();
        glEndTransformFeedback();
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
        mesh.unbindBuffers();
        glDisable(GL_RASTERIZER_DISCARD);
        tf.unbind();
    }
开发者ID:brunoferraz,项目名称:advRendering,代码行数:25,代码来源:simpleTF.hpp


示例4: updateAttributeData

void ofVbo::updateAttributeData(int location, const float * attr0x, int total){
	VertexAttribute * attr = nullptr;
	if (ofIsGLProgrammableRenderer()) {
		switch (location){
			case ofShader::POSITION_ATTRIBUTE:
				attr = &positionAttribute;
				break;
			case ofShader::COLOR_ATTRIBUTE:
				attr = &colorAttribute;
				break;
			case ofShader::NORMAL_ATTRIBUTE:
				attr = &normalAttribute;
				break;
			case ofShader::TEXCOORD_ATTRIBUTE:
				attr = &texCoordAttribute;
				break;
			default:
				if(customAttributes.find(location)!=customAttributes.end()) {
					attr = &customAttributes[location];
				}
				break;
		}
	} else {
		if(customAttributes.find(location)!=customAttributes.end()) {
			attr = &customAttributes[location];
		}
	}
	if (attr !=nullptr && attr->isAllocated()) {
		attr->updateData(0, total*attr->stride, attr0x);
	}
}
开发者ID:imohame,项目名称:openFrameworks,代码行数:31,代码来源:ofVbo.cpp


示例5: computeNormal

void Surface_DifferentialProperties_Plugin::computeNormal(
	const QString& mapName,
	const QString& positionAttributeName,
	const QString& normalAttributeName,
	bool autoUpdate)
{
	MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
	if(mh == NULL)
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
	if(!position.isValid())
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
	if(!normal.isValid())
		normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);

	PFP2::MAP* map = mh->getMap();
	Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);

	computeNormalLastParameters[mapName] =
		ComputeNormalParameters(positionAttributeName, normalAttributeName, autoUpdate);

	mh->notifyAttributeModification(normal);
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:26,代码来源:surface_differentialProperties.cpp


示例6: testVAbyNames

/**
 * @brief test if map has a Vertex Attribute of VEC3 named name
 * @param map  the map
 * @param name name of attribute
 */
void testVAbyNames(MAP& map, const std::string& name)
{
	VertexAttribute<VEC3, MAP> testPos = map.getAttribute<VEC3, VERTEX, MAP>(name);
	if (testPos.isValid())
		std::cout << "Attribute "<< name <<" valid"<< std::endl;
	else
		std::cout << "Attribute "<< name <<"invalid"<< std::endl;
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:13,代码来源:simple_attribs.cpp


示例7: writeAttributeData

std::size_t VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute, GLsizei instances)
{
    Buffer *buffer = attribute.mBoundBuffer.get();

    int inputStride = attribute.stride();
    int elementSize = attribute.typeSize();
    const FormatConverter &converter = formatConverter(attribute);
    std::size_t streamOffset = 0;

    void *output = NULL;
    
    if (vertexBuffer)
    {
        output = vertexBuffer->map(attribute, spaceRequired(attribute, count, instances), &streamOffset);
    }

    if (output == NULL)
    {
        ERR("Failed to map vertex buffer.");
        return -1;
    }

    const char *input = NULL;

    if (buffer)
    {
        int offset = attribute.mOffset;

        input = static_cast<const char*>(buffer->data()) + offset;
    }
    else
    {
        input = static_cast<const char*>(attribute.mPointer);
    }

    if (instances == 0 || attribute.mDivisor == 0)
    {
        input += inputStride * start;
    }

    if (converter.identity && inputStride == elementSize)
    {
        memcpy(output, input, count * inputStride);
    }
    else
    {
        converter.convertArray(input, inputStride, count, output);
    }

    vertexBuffer->unmap();

    return streamOffset;
}
开发者ID:dog-god,项目名称:iptv,代码行数:53,代码来源:VertexDataManager.cpp


示例8:

void UniversalLoader<MapType, AttrTypeLoader>::UnpackOnVertex(MapType& map, const unsigned int* verticesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const
{
	VertexAttribute<typename AttrTypeLoader::ATTR_TYPE> attr = map.template getAttribute<typename AttrTypeLoader::ATTR_TYPE, VERTEX>(attrName);

	if (!attr.isValid())
		attr = map.template addAttribute<typename AttrTypeLoader::ATTR_TYPE, VERTEX>(attrName);

	char* p = (char*)buffer;

	for(unsigned int i = 0 ; i < hdr->meshHdr.vxCount ; i++)
	{
		AttrTypeLoader::Extract(&attr[verticesId[i]], p);
		p += AttrTypeLoader::TYPE_SIZE_IN_BUFFER;
	}
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:15,代码来源:AHEMImporterDefAttr.hpp


示例9:

bool VertexAttribute::operator==(const VertexAttribute& VertexAttribute) const
{
	if (m_nNumItems != VertexAttribute.GetNumAttributeItems()) return false;

	for (int i = 0; i < m_nNumItems; ++i)
	{
		const ATTRIBUTE_ITEM* pAttrItem = VertexAttribute.GetAttributeItem(i);

		if (m_AttributeItems[i].nSize != pAttrItem->nSize) return false;
		if (m_AttributeItems[i].eItemType != pAttrItem->eItemType) return false;
		if (!StringUtil::IsEqual(m_AttributeItems[i].szParamName, pAttrItem->szParamName)) return false;
	}

	return true;
}
开发者ID:mshandle,项目名称:spank,代码行数:15,代码来源:VertexAttribute.cpp


示例10:

void AHEMImporter<PFP>::LoadPosition(AHEMAttributeDescriptor* posDescr)
{
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP> position = map->template getAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	if (!position.isValid())
		position = map->template addAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	f.seekg(posDescr->fileStartOffset, std::ios_base::beg);
	f.read(buffer, posDescr->attributeChunkSize);

	float* q = (float*)buffer;

	for(unsigned int i = 0 ; i < hdr.meshHdr.vxCount ; i++)
	{
		position[verticesId[i]] = typename PFP::VEC3(q[0], q[1], q[2]);
		q += 3;
	}
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:18,代码来源:AHEMImporter.hpp


示例11: lookupAttribute

std::size_t StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute)
{
    for (unsigned int element = 0; element < mCache.size(); element++)
    {
        if (mCache[element].type == attribute.mType &&
            mCache[element].size == attribute.mSize &&
            mCache[element].stride == attribute.stride() &&
            mCache[element].normalized == attribute.mNormalized)
        {
            if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride())
            {
                return mCache[element].streamOffset;
            }
        }
    }

    return -1;
}
开发者ID:dog-god,项目名称:iptv,代码行数:18,代码来源:VertexDataManager.cpp


示例12: render

    /** * @brief Render the mesh given a camera and light, using a Phong shader
     * @param mesh Given mesh
     * @param camera Given camera
     * @param lightTrackball Given light camera
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {

        if (read_va == NULL)
        {
            read_va = mesh.getAttribute("positions1");
            write_va = mesh.getAttribute("positions2");
        }

        if (read_va == NULL || write_va == NULL)
            qDebug() << "AHHH morri";

        updateTF(mesh, camera, lightTrackball);
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
        simple.bind();
        // sets all uniform variables for the phong shader

        simple.setUniform("projectionMatrix", camera.getProjectionMatrix());
        simple.setUniform("modelMatrix", mesh.getModelMatrix());
        simple.setUniform("viewMatrix", camera.getViewMatrix());

        glEnable(GL_DEPTH_TEST);
        //mesh.setAttributeLocation(simple);
        mesh.bindBuffers();
//            mesh.resetLocations();
        //qDebug() << mesh.getAttribute("nPos")->getLocation();
        read_va->disable();
        write_va->enable(simple.getAttributeLocation("inPos"));


        mesh.setAttributeLocation("nColor",  simple.getAttributeLocation("inColor"));

        mesh.renderPoints();
        mesh.unbindBuffers();

        simple.unbind();

        VertexAttribute *tmp_va;
        tmp_va = read_va;
        read_va = write_va;
        write_va = tmp_va;
    }
开发者ID:brunoferraz,项目名称:advRendering,代码行数:48,代码来源:simpleTF.hpp


示例13: getVertexAttribute

      void VertexAttributeSet::combineBuffers()
      {
        // calculate stride & number of vertices
        unsigned int stride = 0;
        unsigned int numberOfVertices = 0;
        for ( unsigned int index = 0; index < static_cast<unsigned int>(AttributeID::VERTEX_ATTRIB_COUNT); ++index )
        {
          AttributeID id = static_cast<AttributeID>(index);
          if ( isEnabled( id ) )
          {
            VertexAttribute attribute = getVertexAttribute( id );
            stride += attribute.getVertexDataBytes();

            if ( !numberOfVertices )
            {
              numberOfVertices = attribute.getVertexDataCount();
            }
            else
            {
              DP_ASSERT( numberOfVertices == attribute.getVertexDataCount() );
            }
          }
        }

        // create one big buffer with all data
        BufferSharedPtr newBufferSharedPtr = BufferHost::create();
        newBufferSharedPtr->setSize( numberOfVertices * stride );
        unsigned int offset = 0;
        for ( unsigned int index = 0; index < static_cast<unsigned int>(AttributeID::VERTEX_ATTRIB_COUNT); ++index )
        {
          AttributeID id = static_cast<AttributeID>(index);
          if ( isEnabled( id ) )
          {
            VertexAttribute attributeNew;
            const VertexAttribute& attributeOld = getVertexAttribute( id );
            attributeNew.setData( attributeOld.getVertexDataSize(), attributeOld.getVertexDataType(), newBufferSharedPtr, offset, stride, numberOfVertices );

            Buffer::DataReadLock drl(attributeOld.getBuffer());
            Buffer::DataWriteLock dwl(attributeNew.getBuffer(), Buffer::MapMode::READWRITE );
            dp::util::stridedMemcpy( dwl.getPtr(), attributeNew.getVertexDataOffsetInBytes(), attributeNew.getVertexDataStrideInBytes(),
              drl.getPtr(), attributeOld.getVertexDataOffsetInBytes(), attributeOld.getVertexDataStrideInBytes(),
              attributeOld.getVertexDataBytes(), numberOfVertices
              );
            offset += attributeOld.getVertexDataBytes();
            setVertexAttribute( id, attributeNew, true );
          }
        }
      }
开发者ID:aonorin,项目名称:pipeline,代码行数:48,代码来源:VertexAttributeSet.cpp


示例14: sizeof

void AHEMImporter<PFP>::LoadTopology()
{
    // Allocate vertices

	AttributeContainer& vxContainer = map->template getAttributeContainer<VERTEX>();

	verticesId = new unsigned int[hdr.meshHdr.vxCount];

	for(unsigned int i = 0 ; i < hdr.meshHdr.vxCount ; i++)
		verticesId[i] = vxContainer.insertLine();

	// Ensure vertices are created by querying the position attribute

	VertexAttribute<typename PFP::VEC3, typename PFP::MAP> position = map->template getAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	if (!position.isValid())
		position = map->template addAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	// Read faces stream and create faces [only intra-face links]
	
	HESorter* addedHE = new HESorter[hdr.meshHdr.heCount];

	facesId = new Dart[hdr.meshHdr.faceCount];

	f.read(buffer, hdr.meshHdr.meshChunkSize);
	char* batch = buffer;

	unsigned int fId = 0;
	unsigned int heId = 0;

	while(fId < hdr.meshHdr.faceCount)
	{
		AHEMFaceBatchDescriptor* fbd = (AHEMFaceBatchDescriptor*)batch;
		stUInt32* ix = (stUInt32*)(batch + sizeof(AHEMFaceBatchDescriptor));

		for(unsigned int i = 0 ; i < fbd->batchLength ; i++)
		{
			Dart d = map->newFace(fbd->batchFaceSize);							// create face
			facesId[fId++] = d;

			unsigned int firstVx = verticesId[*ix++];							// setup face's vertices up to last HE
			unsigned int prevVx = firstVx;

			for(unsigned int k = 0 ; k < fbd->batchFaceSize - 1 ; k++)
			{
				addedHE[heId].d = d;
				addedHE[heId].vxIdFrom = prevVx;
				addedHE[heId].vxIdTo = verticesId[*ix];

				map->setDartEmbedding<VERTEX>(d, prevVx);
				d = map->phi1(d);

				prevVx = *ix++;
				heId++;
			}

			// last HE

			addedHE[heId].d = d;
			addedHE[heId].vxIdFrom = prevVx;
			addedHE[heId].vxIdTo = firstVx;

			map->setDartEmbedding<VERTEX>(d, prevVx);
			heId++;
		}

		batch = (char*)ix;
	}

	// Sort the HE for fast retrieval

	std::sort(addedHE, addedHE + hdr.meshHdr.heCount);

	// Sew faces [inter-face links]

	for(unsigned int i = 0 ; i < hdr.meshHdr.heCount ; i++)
	{
		HESorter* opposite = (HESorter*)bsearch(addedHE + i, addedHE, hdr.meshHdr.heCount, sizeof(HESorter), OppositeSearch);

		if(opposite && opposite->d == map->phi2(opposite->d))
			map->sewFaces(addedHE[i].d, opposite->d);
	}
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:83,代码来源:AHEMImporter.hpp


示例15: foff

bool MeshTablesVolume<PFP>::importOFFWithELERegions(const std::string& filenameOFF, const std::string& filenameELE, std::vector<std::string>& attrNames)
{
    VertexAttribute<VEC3> position =  m_map.template getAttribute<VEC3, VERTEX>("position") ;

    if (!position.isValid())
        position = m_map.template addAttribute<VEC3, VERTEX>("position") ;

    attrNames.push_back(position.name()) ;

    AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;

    // open files
    std::ifstream foff(filenameOFF.c_str(), std::ios::in);
    if (!foff.good())
    {
        CGoGNerr << "Unable to open OFF file " << CGoGNendl;
        return false;
    }

    std::ifstream fele(filenameELE.c_str(), std::ios::in);
    if (!fele.good())
    {
        CGoGNerr << "Unable to open ELE file " << CGoGNendl;
        return false;
    }

    std::string line;

    //OFF reading
    std::getline(foff, line);
    if(line.rfind("OFF") == std::string::npos)
    {
        CGoGNerr << "Problem reading off file: not an off file"<<CGoGNendl;
        CGoGNerr << line << CGoGNendl;
        return false;
    }

    //Reading number of vertex/faces/edges in OFF file
    unsigned int nbe;
    {
        do
        {
            std::getline(foff,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVertices;
        oss >> nbe;
        oss >> nbe;
        oss >> nbe;
    }

    //Reading number of tetrahedra in ELE file
    unsigned int nbv;
    {
        do
        {
            std::getline(fele,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVolumes;
        oss >> nbv ;
        oss >> nbv;
    }

    //Reading vertices
    std::vector<unsigned int> verticesID;
    verticesID.reserve(m_nbVertices);

    for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
    {
        do
        {
            std::getline(foff,line);
        }while(line.size() == 0);

        std::stringstream oss(line);

        float x,y,z;
        oss >> x;
        oss >> y;
        oss >> z;
        //we can read colors informations if exists
        VEC3 pos(x,y,z);

        unsigned int id = container.insertLine();
        position[id] = pos;
        verticesID.push_back(id);
    }

    // reading tetrahedra
    m_nbFaces.reserve(m_nbVolumes*4);
    m_emb.reserve(m_nbVolumes*12);

    for(unsigned i = 0; i < m_nbVolumes ; ++i)
    {
        do
        {
            std::getline(fele,line);
//.........这里部分代码省略.........
开发者ID:cgogn,项目名称:Mesher,代码行数:101,代码来源:import2tablesVolume.hpp


示例16: decimate

void Surface_Radiance_Plugin::decimate(const QString& mapName, const QString& positionAttributeName, const QString& normalAttributeName, float decimationGoal, bool halfCollapse, bool exportMeshes)
{
	MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
	if(mh == NULL)
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
	if(!position.isValid())
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
	if(!normal.isValid())
		return;

	PFP2::MAP* map = mh->getMap();

	unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(*map);

	MapParameters& mapParams = h_mapParameterSet[mh];

	if (halfCollapse)
	{
		if (mapParams.positionApproximator == NULL)
		{
			mapParams.positionApproximator = new Algo::Surface::Decimation::Approximator_HalfCollapse<PFP2, PFP2::VEC3>(*map, position);
		}

		if (mapParams.normalApproximator == NULL)
		{
			mapParams.normalApproximator = new Algo::Surface::Decimation::Approximator_HalfCollapse<PFP2, PFP2::VEC3>(*map, normal);
		}

		if (mapParams.radianceApproximator == NULL)
		{
			mapParams.radianceApproximator = new Algo::Surface::Decimation::Approximator_HalfCollapse<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(*map, mapParams.radiance);
		}

		if (mapParams.selector == NULL)
		{
			mapParams.selector = new HalfEdgeSelector_Radiance<PFP2>(
				*map,
				position,
				normal,
				mapParams.radiance,
				*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, DART>*)(mapParams.positionApproximator),
				*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, DART>*)(mapParams.normalApproximator),
				*(Algo::Surface::Decimation::Approximator<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, DART>*)(mapParams.radianceApproximator)
			);
		}
	}
	else
	{
		if (mapParams.positionApproximator == NULL)
		{
			mapParams.positionApproximator = new Algo::Surface::Decimation::Approximator_QEM<PFP2>(*map, position);
		}

		if (mapParams.normalApproximator == NULL)
		{
			mapParams.normalApproximator =
				new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, PFP2::VEC3>(
					*map,
					normal,
					position,
					((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
				);
		}

		if (mapParams.radianceApproximator == NULL)
		{
			mapParams.radianceApproximator =
				new Algo::Surface::Decimation::Approximator_InterpolateAlongEdge<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3> >(
					*map,
					mapParams.radiance,
					position,
					((Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator))->getApproximationResultAttribute()
				);
		}

		if (mapParams.selector == NULL)
		{
			mapParams.selector =
				new EdgeSelector_Radiance<PFP2>(
					*map,
					position,
					normal,
					mapParams.radiance,
					*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator),
					*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.normalApproximator),
					*(Algo::Surface::Decimation::Approximator<PFP2, Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, EDGE>*)(mapParams.radianceApproximator)
				);

			mapParams.selector =
				new Algo::Surface::Decimation::EdgeSelector_QEM<PFP2>(
					*map,
					position,
					*(Algo::Surface::Decimation::Approximator<PFP2, PFP2::VEC3, EDGE>*)(mapParams.positionApproximator)
				);
		}
	}
//.........这里部分代码省略.........
开发者ID:sujithvg,项目名称:CGoGN,代码行数:101,代码来源:surface_radiance.cpp


示例17: fp

bool MeshTablesVolume<PFP>::importTetmesh(const std::string& filename, std::vector<std::string>& attrNames)
{
    VertexAttribute<VEC3> position =  m_map.template getAttribute<VEC3, VERTEX>("position") ;

    if (!position.isValid())
        position = m_map.template addAttribute<VEC3, VERTEX>("position") ;

    attrNames.push_back(position.name()) ;

    AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;

    //open file
    std::ifstream fp(filename.c_str(), std::ios::in);
    if (!fp.good())
    {
        CGoGNerr << "Unable to open file " << filename << CGoGNendl;
        return false;
    }

    std::string line;

    fp >> line;

    if (line!="Vertices")
        CGoGNerr << "Warning tetmesh file problem"<< CGoGNendl;

    fp >> m_nbVertices;

    std::cout << "READ: "<< m_nbVertices << std::endl;

    std::getline (fp, line);

    //reading vertices
    std::vector<unsigned int> verticesID;
    verticesID.reserve(m_nbVertices+1);
    verticesID.push_back(0xffffffff);

    for(unsigned int i = 0; i < m_nbVertices; ++i)
    {
        do
        {
            std::getline (fp, line);
        } while (line.size() == 0);

        std::stringstream oss(line);

        float x,y,z;
        oss >> x;
        oss >> y;
        oss >> z;
        // TODO : if required read other vertices attributes here
        VEC3 pos(x,y,z);

        unsigned int id = container.insertLine();
        position[id] = pos;

        verticesID.push_back(id);
    }

    fp >> line;
    if (line!="Tetrahedra")
        CGoGNerr << "Warning tetmesh file problem"<< CGoGNendl;

    fp >> m_nbVolumes;
    std::getline (fp, line);

    // reading tetrahedra
    m_nbFaces.reserve(m_nbVolumes*4);
    m_emb.reserve(m_nbVolumes*12);

    for(unsigned i = 0; i < m_nbVolumes ; ++i)
    {
        do
        {
            std::getline(fp,line);
        } while(line.size() == 0);

        std::stringstream oss(line);

        m_nbFaces.push_back(4);

        int s0,s1,s2,s3;

        oss >> s0;
        oss >> s1;
        oss >> s2;
        oss >> s3;

        typename PFP::VEC3 P = position[verticesID[s0]];
        typename PFP::VEC3 A = position[verticesID[s1]];
        typename PFP::VEC3 B = position[verticesID[s2]];
        typename PFP::VEC3 C = position[verticesID[s3]];

        if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
        {
            int ui=s1;
            s1 = s2;
            s2 = ui;
        }

//.........这里部分代码省略.........
开发者ID:cgogn,项目名称:Mesher,代码行数:101,代码来源:import2tablesVolume.hpp


示例18: main

int main()
{
	// declare a map to handle the mesh
	MAP myMap;

	// add position attribute on vertices and get handler on it
	VertexAttribute<VEC3, MAP> positionAtt = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
	if (!positionAtt.isValid())
		std::cerr << "impossible to create an attribute with name position (already used ?)"<< std::endl;


	// create a topo grid of 2x2 squares
	Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 2, 2, true);
	// and embed it using position attribute
	grid.embedIntoGrid(positionAtt, 1.,1.,0.);


	VertexGeneric(myMap,positionAtt);

	// ATTRIBUTE DECLARATION

	// add an attribute of type float on orbit EDGE
	EdgeAttribute<float, MAP> lengthAtt = myMap.addAttribute<float, EDGE, MAP>("length");
	if (!lengthAtt.isValid())
		std::cerr << "impossible to create the attribute"<< std::endl;

	computeLengthEdges(myMap,positionAtt,lengthAtt);

	// add an attribute of type std::string on orbit FACE
	FaceAttribute<std::string, MAP> nameAtt = myMap.addAttribute<std::string, FACE, MAP>("name");
	if (!nameAtt.isValid())
		std::cerr << "impossible to create the attribute"<< std::endl;

	// for complex type use following template (function nameOfType not applicable)
	EdgeAttribute< NoTypeNameAttribute< std::vector<int> >, MAP> vectAtt = myMap.addAttribute< NoTypeNameAttribute< std::vector<int> >, EDGE, MAP>("vector_of_int");
	if (!vectAtt.isValid())
		std::cerr << "impossible to create the attribute"<< std::endl;

	Dart d = myMap.begin();
	// define a vertex from a dart
	Vertex v(d);
	// define a face from a dart
	Face f(d);


	// ATTRIBUTE ACCESS

	// [] operator can take a dart, a cell (only same off attribute), or an unsigned inf
	// access to any attributes with darts
	std::cout << positionAtt[d]<< std::endl;
	nameAtt[d] = "Hello";
	lengthAtt[myMap.phi1(d)] = 54.0f;

	std::vector<int> vi = {3,5,7,9,11};
	vectAtt[d]= vi;
	vectAtt[d].push_back(11);

	// access to VertexAttribute with a Vertex
	std::cout << positionAtt[v]<< std::endl;

	// access to FaceAttribute with a Face
	std::cout << nameAtt[f]<< std::endl;

	// following line does not compile because of wrong cell type
	//	std::cout << positionAtt[f]<< std::endl;
	//  possible to bypass using dart access
	std::cout << positionAtt[f.dart]<< std::endl;

	// access with unsigned int is dangerous, index must be obtain with begin/end/next (see dumpAttribute)

	// COPY, REMOVE, SWAP

	// possible to have any number of attribute a same ORBIT
	VertexAttribute<VEC3, MAP> position2Att = myMap.addAttribute<VEC3, VERTEX, MAP>("other_position");

	// copy of attribute of same type (linear complexity)
	myMap.copyAttribute(position2Att,positionAtt);

	positionAtt[v] += VEC3(0,0,1);

	computeNewPositions(myMap,positionAtt);
	dumpAttribute(positionAtt);

	//check if there is a Vertex Attribute of VEC3 named position => yes
	testVAbyNames(myMap,"position");

	// remove the attribute
	myMap.removeAttribute(positionAtt);

	//check if there is a Vertex Attribute of VEC3 named position => no
	testVAbyNames(myMap,"position");

	return 0;
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:94,代码来源:simple_attribs.cpp


示例19: fp

bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<std::string>& attrNames)
{
	VertexAttribute<VEC3, MAP> position =  m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;

	if (!position.isValid())
		position = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ;

	attrNames.push_back(position.name()) ;

	AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;

	//open file
	std::ifstream fp(filename.c_str(), std::ios::in);
	if (!fp.good())
	{
		CGoGNerr << "Unable to open file " << filename << CGoGNendl;
		return false;
	}

	std::string ligne;

	// reading number of vertices
	std::getline (fp, ligne);
	std::stringstream oss(ligne);
	oss >> m_nbVertices;

	// reading number of tetrahedra
	std::getline (fp, ligne);
	std::stringstream oss2(ligne);
	oss2 >> m_nbVolumes;

	//reading vertices
	std::vector<unsigned int> verticesID;
	verticesID.reserve(m_nbVertices);

	for(unsigned int i = 0; i < m_nbVertices; ++i)
	{
		do
		{
			std::getline (fp, ligne);
		} while (ligne.size() == 0);

		std::stringstream oss(ligne);

		float x,y,z;
		oss >> x;
		oss >> y;
		oss >> z;
		// TODO : if required read other vertices attributes here
		VEC3 pos(x,y,z);

		unsigned int id = container.insertLine();
		position[id] = pos;

		verticesID.push_back(id);
	}

	// reading volumes
	m_nbFaces.reserve(m_nbVolumes*4);
	m_emb.reserve(m_nbVolumes*12);

    unsigned int nbc = 0;

	for (unsigned int i = 0; i < m_nbVolumes ; ++i)
	{
		do
		{
			std::getline (fp, ligne);
		} while (ligne.size()==0);

		std::stringstream oss(ligne);
		int n;
		oss >> n; // type of volumes


        if(!oss.good())
        {
            oss.clear();
            char dummy;
            oss >> dummy; // type of volumes
            oss >> dummy;

            if(dummy == 'C')// connector
            {
                ++nbc;
                m_nbFaces.push_back(3);

                int s0,s1,s2,s3;

                oss >> s0;
                oss >> s1;
                oss >> s2;
                oss >> s3;

                //std::cout << "connector " << s0 << " " << s1 << " " << s2 << " " << s3 << std::endl;

                m_emb.push_back(verticesID[s0]);
                m_emb.push_back(verticesID[s1]);
                m_emb.push_back(verticesID[s2]);
                m_emb.push_back(verticesID[s3]);
//.........这里部分代码省略.........
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:101,代码来源:import2tablesVolume.hpp


示例20: fnode

bool MeshTablesVolume<PFP>::importNodeWithELERegions(const std::string& filenameNode, const std::string& filenameELE, std::vector<std::string>& attrNames)
{
    VertexAttribute<VEC3> position =  m_map.template getAttribute<VEC3, VERTEX>("position") ;

    if (!position.isValid())
        position = m_map.template addAttribute<VEC3, VERTEX>("position") ;

    attrNames.push_back(position.name()) ;

    AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;

    //open file
    std::ifstream fnode(filenameNode.c_str(), std::ios::in);
    if (!fnode.good())
    {
        CGoGNerr << "Unable to open file " << filenameNode << CGoGNendl;
        return false;
    }

    std::ifstream fele(filenameELE.c_str(), std::ios::in);
    if (!fele.good())
    {
        CGoGNerr << "Unable to open file " << filenameELE << CGoGNendl;
        return false;
    }

    std::string line;

    //Reading NODE file
    //First line: [# of points] [dimension (must be 3)] [# of attributes] [# of boundary markers (0 or 1)]
    unsigned int nbe;
    {
        do
        {
            std::getline(fnode,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVertices;
        oss >> nbe;
        oss >> nbe;
        oss >> nbe;
    }

    //Reading number of tetrahedra in ELE file
    unsigned int nbv;
    {
        do
        {
            std::getline(fele,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVolumes;
        oss >> nbv ;
        oss >> nbv;
    }

    //Reading vertices
    std::map<unsigned int,unsigned int> verticesMapID;

    for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
    {
        do
        {
            std::getline(fnode,line);
        }while(line.size() == 0);

        std::stringstream oss(line);

        int idv;
        oss >> idv;

        float x,y,z;
        oss >> x;
        oss >> y;
        oss >> z;
        //we can read colors informations if exists
        VEC3 pos(x,y,z);

        unsigned int id = container.insertLine();
        position[id] = pos;
        verticesMapID.insert(std::pair<unsigned int, unsigned int>(idv,id));
    }

    // reading tetrahedra
    m_nbFaces.reserve(m_nbVolumes*4);
    m_emb.reserve(m_nbVolumes*12);

    for(unsigned i = 0; i < m_nbVolumes ; ++i)
    {
        do
        {
            std::getline(fele,line);
        } while(line.size() == 0);

        std::stringstream oss(line);
        oss >> nbe;

        m_nbFaces.push_back(4);
//.........这里部分代码省略.........
开发者ID:cgogn,项目名称:Mesher,代码行数:101,代码来源:import2tablesVolume.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ VertexBuffer类代码示例发布时间:2022-05-31
下一篇:
C++ VertexArray类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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