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


C++ Facet::getNormal方法代码示例

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


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

示例1: writeSTLFacet

bool STLWriter::writeSTLFacet(const Facet& facet, const bool& isBinaryMode)
{
    if(isBinaryMode)
    {
        char* c = new char[12 * sizeof(float) + 2];

        ((float*) c)[0] = facet.getNormal()[0];
        ((float*) c)[1] = facet.getNormal()[1];
        ((float*) c)[2] = facet.getNormal()[2];

        for(int i = 0; i < NUM_VERTICES; ++i)
        {
            ((float*) c)[i + 0 + 2] = facet.getVertexAt(i).x;
            ((float*) c)[i + 1 + 2] = facet.getVertexAt(i).y;
            ((float*) c)[i + 2 + 2] = facet.getVertexAt(i).z;
        }

        outputFile_.write(c, 12 * sizeof(float) + 2);
    }
    else
    {
        string s = buildFacetString(facet);
        outputFile_.write(s.data(), s.length());
    }

    return true;
}
开发者ID:rsingla92,项目名称:aegle,代码行数:27,代码来源:STLWriter.cpp

示例2: buildFacetString

string STLWriter::buildFacetString(const Facet& facet)
{
    normal n = facet.getNormal();
    vertices v = facet.getVertices();
    std::ostringstream ss;
    string ret = "\nfacet normal ";

    for(size_t i = 0; i < n.size(); ++i)
    {
        ss << n[i];
        ret += ss.str() + " ";
    }

    ret += "\n\t outer loop\n";

    for(size_t i = 0; i < v.size(); ++i)
    {
        ret += "\t\tvertex ";
        
        ss << v[i].x;
        ret += ss.str() + " ";

        ss << v[i].y;
        ret += ss.str() + " ";

        ss << v[i].z;
        ret += ss.str() + " ";
        
        ret += "\n";
    }

    ret += "\tendloop\n";
    ret += "endfacet\n";
    return ret;
}
开发者ID:rsingla92,项目名称:aegle,代码行数:35,代码来源:STLWriter.cpp

示例3: writeFacet

void STLSink::writeFacet(const Facet &facet) {
  writeFacet(facet[0], facet[1], facet[2], facet.getNormal());
}
开发者ID:aton0511,项目名称:CAMotics,代码行数:3,代码来源:STLSink.cpp

示例4: findNeighbours

void BCIViz::findNeighbours()
{
	if(!checkHull()) return;
	const int numTri = m_hull->getNumFace();
	
	Vector3F d;
	d.x = fDriverPos.x;
	d.y = fDriverPos.y;
	d.z = fDriverPos.z;
	
	d.normalize();
	
	m_hitTriangle = 0;
	for(int i = 0; i < numTri; i++)
	{
		Facet f = m_hull->getFacet(i);
		Vertex p0 = f.getVertex(0);
		
		const Vector3F nor = f.getNormal();
		
		float ddotn = d.dot(nor);
		
		if(ddotn < 10e-5 && ddotn > -10e-5) continue;
		
		float t = p0.dot(nor) / ddotn; 
		if(t < 0.f) continue;
		
		Vertex p1 = f.getVertex(1);
		Vertex p2 = f.getVertex(2);
		
		m_hitTriangle = i;
		m_hitP = d * t; 

		Vector3F e01 = p1 - p0;
		Vector3F e02 = p2 - p0;
		Vector3F tmp = e01.cross(e02);
		if(tmp.dot(nor) < 0.f) {
			Vertex sw = p1;
			p1 = p2;
			p2 = sw;
		}
		
		e01 = p1 - p0;
		Vector3F x0 = m_hitP - p0;
		
		Vector3F e12 = p2 - p1;
		Vector3F x1 = m_hitP - p1;
		
		Vector3F e20 = p0 - p2;
		Vector3F x2 = m_hitP - p2;
		
		neighbourId[0] = p0.getIndex();
		neighbourId[1] = p1.getIndex();
		neighbourId[2] = p2.getIndex();
		
		if(e01.cross(x0).dot(nor) < 0.f) continue;
		if(e12.cross(x1).dot(nor) < 0.f) continue;
		if(e20.cross(x2).dot(nor) < 0.f) continue;
		
		return;
	}
}
开发者ID:ahmidou,项目名称:aphid,代码行数:62,代码来源:bciosVizNode.cpp


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