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


C++ TriangleMesh::triangle方法代码示例

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


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

示例1: new

  BBox3fa TriangleMeshTriangle8::update(char* prim, size_t num, void* geom) const 
  {
    BBox3fa bounds = empty;
    TriangleMesh* mesh = (TriangleMesh*) geom;
    
    for (size_t j=0; j<num; j++) 
    {
      Triangle8& dst = ((Triangle8*) prim)[j];
      
      avxi vgeomID = -1, vprimID = -1, vmask = -1;
      avx3f v0 = zero, v1 = zero, v2 = zero;

      for (size_t i=0; i<8; i++)
      {
        if (dst.primID[i] == -1) break;
        const unsigned geomID = dst.geomID[i];
        const unsigned primID = dst.primID[i];
        const TriangleMesh::Triangle& tri = mesh->triangle(primID);
        const Vec3fa p0 = mesh->vertex(tri.v[0]);
        const Vec3fa p1 = mesh->vertex(tri.v[1]);
        const Vec3fa p2 = mesh->vertex(tri.v[2]);
        bounds.extend(merge(BBox3fa(p0),BBox3fa(p1),BBox3fa(p2)));
        vgeomID [i] = geomID;
        vprimID [i] = primID;
        vmask   [i] = mesh->mask;
        v0.x[i] = p0.x; v0.y[i] = p0.y; v0.z[i] = p0.z;
        v1.x[i] = p1.x; v1.y[i] = p1.y; v1.z[i] = p1.z;
        v2.x[i] = p2.x; v2.y[i] = p2.y; v2.z[i] = p2.z;
        }
      new (&dst) Triangle8(v0,v1,v2,vgeomID,vprimID,vmask);
    }
    return bounds; 
  }
开发者ID:cpaalman,项目名称:embree,代码行数:33,代码来源:triangle8.cpp

示例2: assert

    void SpatialSplit::Split::split<false>(size_t threadIndex, size_t threadCount, LockStepTaskScheduler* scheduler, PrimRefBlockAlloc<PrimRef>& alloc, 
					   Scene* scene, TriRefList& prims, 
					   TriRefList& lprims_o, PrimInfo& linfo_o, 
					   TriRefList& rprims_o, PrimInfo& rinfo_o) const
    {
      assert(valid());
      TriRefList::item* lblock = lprims_o.insert(alloc.malloc(threadIndex));
      TriRefList::item* rblock = rprims_o.insert(alloc.malloc(threadIndex));
      linfo_o.reset();
      rinfo_o.reset();
    
      /* sort each primitive to left, right, or left and right */
      while (atomic_set<PrimRefBlock>::item* block = prims.take()) 
      {
	for (size_t i=0; i<block->size(); i++) 
	{
	  const PrimRef& prim = block->at(i); 
	  const BBox3fa bounds = prim.bounds();
	  const int bin0 = mapping.bin(bounds.lower)[dim];
	  const int bin1 = mapping.bin(bounds.upper)[dim];

	  /* sort to the left side */
	  if (bin1 < pos)
	  {
	    linfo_o.add(bounds,center2(bounds));
	    if (likely(lblock->insert(prim))) continue; 
	    lblock = lprims_o.insert(alloc.malloc(threadIndex));
	    lblock->insert(prim);
	    continue;
	  }
	  
	  /* sort to the right side */
	  if (bin0 >= pos)
	  {
	    rinfo_o.add(bounds,center2(bounds));
	    if (likely(rblock->insert(prim))) continue;
	    rblock = rprims_o.insert(alloc.malloc(threadIndex));
	    rblock->insert(prim);
	    continue;
	  }
	  
	  /* split and sort to left and right */
	  TriangleMesh* mesh = (TriangleMesh*) scene->get(prim.geomID());
	  TriangleMesh::Triangle tri = mesh->triangle(prim.primID());
	  const Vec3fa v0 = mesh->vertex(tri.v[0]);
	  const Vec3fa v1 = mesh->vertex(tri.v[1]);
	  const Vec3fa v2 = mesh->vertex(tri.v[2]);
	  
	  PrimRef left,right;
	  float fpos = mapping.pos(pos,dim);
	  splitTriangle(prim,dim,fpos,v0,v1,v2,left,right);
	
	  if (!left.bounds().empty()) {
	    linfo_o.add(left.bounds(),center2(left.bounds()));
	    if (!lblock->insert(left)) {
	      lblock = lprims_o.insert(alloc.malloc(threadIndex));
	      lblock->insert(left);
	    }
	  }
	  
	  if (!right.bounds().empty()) {
	    rinfo_o.add(right.bounds(),center2(right.bounds()));
	    if (!rblock->insert(right)) {
	      rblock = rprims_o.insert(alloc.malloc(threadIndex));
	      rblock->insert(right);
	    }
	  }
	}
	alloc.free(threadIndex,block);
      }
    }
开发者ID:JianpingCAI,项目名称:libigl,代码行数:71,代码来源:heuristic_spatial_split.cpp


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