Esempio n. 1
0
void computeBoundarySurface(const Vector4i *pTet, const int ntet, const int nvert, Vector3i *& pTri, int &nTri)
{
	int i;
	CMemoryMgr*  pm = new CMemoryMgr;

	//malloc the pointer buffer;
	CTriangleListItem** plist = new CTriangleListItem*[nvert];
	assert(plist!=NULL);
	for (i=0; i<nvert; i++) plist[i]=NULL;

	//insert triangles into the buffer;
	for (i=0; i<ntet; i++){
		Vector4i t = pTet[i];
		const int v0=t.x;
		const int v1=t.y;
		const int v2=t.z;
		const int v3=t.w;
		Vector3i tri0(v0, v2, v1);
		Vector3i tri1(v0, v1, v3);
		Vector3i tri2(v1, v2, v3);
		Vector3i tri3(v0, v3, v2);
		_insertTriangle(tri0, plist, *pm);
		_insertTriangle(tri1, plist, *pm);
		_insertTriangle(tri2, plist, *pm);
		_insertTriangle(tri3, plist, *pm);
	}
	
	nTri = _countValidTriangle(plist, nvert);
	pTri = _collectBoundarySurface(plist, nvert, nTri);
	delete pm;
	delete [] plist;
}
Esempio n. 2
0
int CDistanceFuncGridModel<T>::BruteForceInnerPointsStatic(const C3DModel &model, const Vector3<T> &vQuery)
{

	//In this variable we count the number on intersections
	int nIntersections = 0;
	for(unsigned int i=0;i<model.m_vMeshes.size();i++)
	{
	  const C3DMesh& mesh=model.m_vMeshes[i];
		Ray3<T> ray3(vQuery,VECTOR3(0.9,0.8,0.02) );
	  CDynamicArray<TriFace>::const_iterator faceIter;

		//Get the bounding box of the 3d model
		const AABB3<T> &rBox = mesh.GetBox();
		//Get the mesh
		if(!rBox.isPointInside(vQuery))
			continue;
		
		//reset the number of intersection to zero for the current subobject
		nIntersections=0;
	  for(faceIter=mesh.m_pFaces.begin();faceIter!=mesh.m_pFaces.end();faceIter++)
	  {
		TriFace tri=*faceIter;
		//We loop through all triangular faces of the
		// model. This variable will hold the current face
		Triangle3<T> tri3(mesh.GetVertices()[tri[0]],mesh.GetVertices()[tri[1]],mesh.GetVertices()[tri[2]]);
		//init our intersector
		CIntersectorRay3Tri3<T> intersector(ray3, tri3);
		//test for intersection
		if(intersector.Intersection())
			nIntersections++;
	  }//end for faces
		//we finished looping through the faces of the subobject
		//look if the point is inside the subobject 
		//if the number of intersection is even
		//we return false else true
		if(!(nIntersections % 2 == 0))
			return 1;

	}//end for meshes

	//The query point is not inside of any of the
	//submeshes
	return 0;
}//end BruteForceInnerPoints
Esempio n. 3
0
void computeBoundarySurface(const Vector8i *pTet, const int ntet, const int nvert, Vector4i *& pTri, int &nTri)
{
	int i;
	CMemoryMgr*  pm = new CMemoryMgr;

	//malloc the pointer buffer;
	CQuadListItem** plist = new CQuadListItem*[nvert];
	assert(plist!=NULL);
	for (i=0; i<nvert; i++) plist[i]=NULL;

	//insert triangles into the buffer;
	for (i=0; i<ntet; i++){
		Vector8i t = pTet[i];
		const int v0=t.x;
		const int v1=t.y;
		const int v2=t.z;
		const int v3=t.w;
		const int v4=t.x1;
		const int v5=t.y1;
		const int v6=t.z1;
		const int v7=t.w1;
		Vector4i tri0(v0, v3, v2, v1);
		Vector4i tri1(v4, v5, v6, v7);
		Vector4i tri2(v0, v4, v7, v3);
		Vector4i tri3(v1, v2, v6, v5);
		Vector4i tri4(v0, v1, v5, v4);
		Vector4i tri5(v2, v3, v7, v6);
		_insertQuad(tri0, plist, *pm);
		_insertQuad(tri1, plist, *pm);
		_insertQuad(tri2, plist, *pm);
		_insertQuad(tri3, plist, *pm);
		_insertQuad(tri4, plist, *pm);
		_insertQuad(tri5, plist, *pm);
	}
	
	nTri = _countValidQuad(plist, nvert);
	pTri = _collectBoundarySurface(plist, nvert, nTri);
	delete pm;
	delete [] plist;
}