void MWC64XSeedGenerator::generateRandomSeeds(Buffer<uvec2>* buffer, unsigned int seed, bool useGLSharing /*= true*/, size_t localWorkGroupSize /*= 256*/) { if (kernel_ == NULL) { return; } srand(seed); // MWC64X random number generator BufferRAM* bufferRAM = buffer->getEditableRepresentation<BufferRAM>(); uvec2* randomNumbers = static_cast<uvec2*>(bufferRAM->getData()); int nRandomSeeds = static_cast<int>(bufferRAM->getSize()); for (int i = 0; i < nRandomSeeds; ++i) { randomNumbers[i].x = static_cast<cl_uint>(rand()); } // Data will be transferred to OpenCL device before new representation is returned. if (useGLSharing) { SyncCLGL glSync; BufferCLGL* randomSeedBufferCL = buffer->getEditableRepresentation<BufferCLGL>(); glSync.addToAquireGLObjectList(randomSeedBufferCL); glSync.aquireAllObjects(); generateSeeds(randomSeedBufferCL, nRandomSeeds, localWorkGroupSize); } else { BufferCLBase* randomSeedBufferCL = buffer->getEditableRepresentation<BufferCL>(); generateSeeds(randomSeedBufferCL, nRandomSeeds, localWorkGroupSize); } }
int main(int argc, char *argv[]) { if (argc != 4) { std::cout << argv[0] << "input.m patchnum sampling\n"; exit(-1); } int patchnum = atoi(argv[2]); double threshold = atof(argv[3]); srand (static_cast <unsigned> (time(0))); //load seeds; std::vector<Patch*> patches; //loadSeeds("seed_sim.m", patches); //loadSeeds("seed2.m", patches); Mesh *mesh = new Mesh; mesh->readMFile(argv[1]); generateSeeds(mesh, patches, patchnum); for (int i = 0; i <= 500; ++i) { /*if (i % 100 == 0) { sprintf_s(buf, "center_%d.cm", i+1); saveCenters(buf, patches); }*/ clustering(mesh, patches); checkPatches(patches); update(patches); /*if (i % 100 == 0) { sprintf_s(buf, "out_%d.m", i+1); mesh->writeMFile(buf); }*/ } mesh->writeMFile("end.m"); std::cout << "end!\n"; traceBoundary(patches); DualGraph *dualGraph = generateGraph(patches); sampling(patches, avg_length); delete dualGraph; delete mesh; return 0; }