Example #1
0
void KdCluster::leafWriteGroup(KdTreeNode *node, const BoundingBox & box)
{
	const unsigned num = node->getNumPrims();
	if(num < 1) return;
	
	m_groupGeometries[m_currentGroup] = new GeometryArray;
	
	GeometryArray * curGrp = m_groupGeometries[m_currentGroup];
	curGrp->create(num);
	
	unsigned start = node->getPrimStart();
	sdb::VectorArray<Primitive> &indir = indirection();
	//sdb::VectorArray<Primitive> &prims = primitives();
	int igeom, icomponent;
	unsigned igroup = 0;
	for(unsigned i = 0; i < num; i++) {
		//unsigned *iprim = indir[start + i];
		//Primitive * prim = prims.get(*iprim);
		Primitive * prim = indir[start + i];
		prim->getGeometryComponent(igeom, icomponent);
		Geometry * geo = m_stream.geometry(igeom);
		if(geo->type() == TGeometryArray) {
			GeometryArray * ga = (GeometryArray *)geo;
			Geometry * comp = ga->geometry(icomponent);
			
			BoundingBox comb = ga->calculateBBox(icomponent);

// do not add straddling geo			
			if(comb.getMax(0) <= box.getMax(0) && 
				comb.getMax(1) <= box.getMax(1) && 
				comb.getMax(2) <= box.getMax(2)) 
			{
				curGrp->setGeometry(comp, igroup);
				igroup++;
			}
		}
		else {
			std::cout<<" grouping only works with geometry arry.";
		}
		//indir.next();
	}
	
	curGrp->setNumGeometries(igroup);
	m_nodeGroupInd[node] = m_currentGroup;
	m_currentGroup++;
}
Example #2
0
void BccInterface::testBlockMesh()
{
    BlockBccMeshBuilder builder;
    AOrientedBox box1;
    box1.setExtent(Vector3F(28.f, 14.f, 1.f));
    box1.setCenter(Vector3F(0.1f, -2.f, 1.f));
	
	AOrientedBox box2;
	Matrix33F rot; rot.set(Quaternion(0.f, 1.f, 0.f, .5f));
	box2.setOrientation(rot);
    box2.setExtent(Vector3F(18.f, 4.f, 1.f));
    box2.setCenter(Vector3F(2.1f, 13.f, -1.f));
	
	GeometryArray boxes;
	boxes.create(2);
	boxes.setGeometry(&box1, 0);
	boxes.setGeometry(&box2, 1);
	unsigned nv, nt, ns;
    builder.build(&boxes, nt, nv, ns);
	std::cout<<"\n tet nt nv ns "<<nt<<" "<<nv<<" "<<ns;
	m_tetMesh = new ATetrahedronMeshGroup;
	m_tetMesh->create(nv, nt, ns);
	builder.getResult(m_tetMesh);
}