Esempio n. 1
0
/**
 * These tests are meant to run on individual nodes, and should
 * not invoke MPI calls. They should not be run when MPI is running.
 * These tests do not use the threaded/MPI event loop and are the most
 * basic of the set.
 */
void nonMpiTests( Shell* s )
{
#ifdef DO_UNIT_TESTS
	if ( Shell::myNode() == 0 ) {
		unsigned int numNodes = s->numNodes();
		unsigned int numCores = s->numCores();
		if ( numCores > 0 )
		s->setHardware( 1, 1, 0 );
		testAsync();
		testMsg();
		testShell();
		testScheduling();
		testBuiltins();
		// testKinetics();
                testKsolve();
//		testKsolveProcess();
		testBiophysics();
		testDiffusion();
                testHSolve();
		// testGeom();
		testMesh();
		testSigNeur();
#ifdef USE_SMOLDYN
		// testSmoldyn();
#endif
		s->setHardware( numCores, numNodes, 0 );
	}
#endif
}
void MeshSerializerTests::testMesh_Version_1_3()
{
	testMesh(MESH_VERSION_1_0);
}
void MeshSerializerTests::testMesh_Version_1_10()
{
	testMesh(MESH_VERSION_LATEST);
}
Esempio n. 4
0
//--------------------------------------------------------------------------
void MeshSerializerTests::testMesh_Version_1_3()
{
    UnitTestSuite::getSingletonPtr()->startTestMethod(__FUNCTION__);

    testMesh(MESH_VERSION_1_0);
}
void ApexQuadricSimplifier::collapseEdge(QuadricEdge& edge)
{
	uint32_t vNr0 = edge.vertexNr[0];
	uint32_t vNr1 = edge.vertexNr[1];
	QuadricVertex* qv0 = mVertices[vNr0];
	QuadricVertex* qv1 = mVertices[vNr1];

	PX_ASSERT(qv0->bDeleted == 0);
	PX_ASSERT(qv1->bDeleted == 0);

	//FILE* f = NULL;
	//fopen_s(&f, "c:\\collapse.txt", "a");
	//fprintf_s(f, "Collapse Vertex %d -> %d\n", vNr1, vNr0);

	// contract edge to the vertex0
	qv0->pos = qv0->pos * (1.0f - edge.ratio) + qv1->pos * edge.ratio;
	qv0->q += qv1->q;

	// merge the edges
	for (uint32_t i = 0; i < qv1->mEdges.size(); i++)
	{
		QuadricEdge& ei = mEdges[qv1->mEdges[i]];
		uint32_t vi = ei.otherVertex(vNr1);
		if (vi == vNr0)
		{
			continue;
		}

		// test whether we already have this neighbor
		bool found = false;
		for (uint32_t j = 0; j < qv0->mEdges.size(); j++)
		{
			QuadricEdge& ej = mEdges[qv0->mEdges[j]];
			if (ej.otherVertex(vNr0) == vi)
			{
				found = true;
				break;
			}
		}
		if (found)
		{
			mVertices[vi]->removeEdge((int32_t)qv1->mEdges[i]);
			ei.deleted = true;
			if (ei.heapPos >= 0)
			{
				heapRemove((uint32_t)ei.heapPos, false);
			}
#if TESTING
			testHeap();
#endif
		}
		else
		{
			ei.replaceVertex(vNr1, vNr0);
			qv0->mEdges.pushBack(qv1->mEdges[i]);
		}
	}
	// remove common edge and update adjacent edges
	for (int32_t i = (int32_t)qv0->mEdges.size() - 1; i >= 0; i--)
	{
		QuadricEdge& ei = mEdges[qv0->mEdges[(uint32_t)i]];
		if (ei.otherVertex(vNr0) == vNr1)
		{
			qv0->mEdges.replaceWithLast((uint32_t)i);
		}
		else
		{
			computeCost(ei);
			if (ei.heapPos >= 0)
			{
				heapUpdate((uint32_t)ei.heapPos);
			}
#if TESTING
			testHeap();
#endif
		}
	}

	// delete collapsed triangles
	for (int32_t i = (int32_t)qv0->mTriangles.size() - 1; i >= 0; i--)
	{
		uint32_t triangleIndex = qv0->mTriangles[(uint32_t)i];
		QuadricTriangle& t = mTriangles[triangleIndex];
		if (!t.deleted && t.containsVertex(vNr1))
		{
			mNumDeletedTriangles++;
			t.deleted = true;
			//fprintf_s(f, "Delete Triangle %d\n", triangleIndex);

			PX_ASSERT(t.containsVertex(vNr0));

			for (uint32_t j = 0; j < 3; j++)
			{
				mVertices[t.vertexNr[j]]->removeTriangle((int32_t)triangleIndex);
				//fprintf_s(f, "  v %d\n", t.vertexNr[j]);
			}
		}
	}
	// update triangles
	for (uint32_t i = 0; i < qv1->mTriangles.size(); i++)
	{
		QuadricTriangle& t = mTriangles[qv1->mTriangles[i]];
		if (t.deleted)
		{
			continue;
		}
		if (t.containsVertex(vNr1))
		{
			qv0->mTriangles.pushBack(qv1->mTriangles[i]);
		}
		t.replaceVertex(vNr1, vNr0);
	}

	mNumDeletedVertices += qv1->bDeleted == 1 ? 0 : 1;
	qv1->bDeleted = 1;
	edge.deleted = true;
	//fclose(f);

#if TESTING
	testMesh();
	testHeap();
#endif
}
void MeshSerializerTests::testMesh_Version_1_2()
{
	// Exporting legacy Mesh not supported!
	// testMesh(MESH_VERSION_LEGACY);

#ifdef I_HAVE_LOT_OF_FREE_TIME
	// My sandboxing test. Takes a long time to complete!
	// Runs on all meshes and exports all to every Lod version.
	char* groups [] = { "Popular", "General", "Tests" };
	for (int i = 0; i < 3; i++) {
		StringVectorPtr meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.mesh");
		StringVector::iterator it, itEnd;
		it = meshes->begin();
		itEnd = meshes->end();
		for (; it != itEnd; it++) {
			try {
				mMesh = MeshManager::getSingleton().load(*it, groups[i]);
			}
			catch(std::exception e)
			{
				// OutputDebugStringA(e.what());
			}
			getResourceFullPath(mMesh, mMeshFullPath);
			if (!copyFile(mMeshFullPath + ".bak", mMeshFullPath)) {
				// If there is no backup, create one.
				copyFile(mMeshFullPath, mMeshFullPath + ".bak");
			}
			mOrigMesh = mMesh->clone(mMesh->getName() + ".orig.mesh", mMesh->getGroup());
			testMesh_XML();
			testMesh(MESH_VERSION_1_10);
			testMesh(MESH_VERSION_1_8);
			testMesh(MESH_VERSION_1_7);
			testMesh(MESH_VERSION_1_4);
			testMesh(MESH_VERSION_1_0);
		}
		meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.skeleton");
		it = meshes->begin();
		itEnd = meshes->end();
		for (; it != itEnd; it++) {
			mSkeleton = SkeletonManager::getSingleton().load(*it, groups[i]);
			getResourceFullPath(mSkeleton, mSkeletonFullPath);
			if (!copyFile(mSkeletonFullPath + ".bak", mSkeletonFullPath)) {
				// If there is no backup, create one.
				copyFile(mSkeletonFullPath, mSkeletonFullPath + ".bak");
			}
			SkeletonSerializer skeletonSerializer;
			skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_8);
			mSkeleton->reload();
			skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_0);
			mSkeleton->reload();
		}
	}
#endif /* ifdef I_HAVE_LOT_OF_FREE_TIME */
}