World::World(Panel& panel,const LevelDef& ldef) : _levelDef(ldef), _panel(panel), _background(panel,ldef) { createActors(panel); }
bool SimpleShear::generate(std::string& message) { scene = shared_ptr<Scene>(new Scene); createActors(scene); // Box walls shared_ptr<Body> w1; // The left one : createBox(w1,Vector3r(-thickness/2.0,(height)/2.0,0),Vector3r(thickness/2.0,5*(height/2.0+thickness),width/2.0)); scene->bodies->insert(w1); shared_ptr<Body> w2; // The lower one : createBox(w2,Vector3r(length/2.0,-thickness/2.0,0),Vector3r(length/2.0,thickness/2.0,width/2.0)); YADE_PTR_CAST<FrictMat> (w2->material)->frictionAngle = sphereFrictionDeg * Mathr::PI/180.0; // so that we have phi(spheres-inferior wall)=phi(sphere-sphere) scene->bodies->insert(w2); shared_ptr<Body> w3; // The right one createBox(w3,Vector3r(length+thickness/2.0,height/2.0,0),Vector3r(thickness/2.0,5*(height/2.0+thickness),width/2.0)); scene->bodies->insert(w3); shared_ptr<Body> w4; // The upper one createBox(w4,Vector3r(length/2.0,height+thickness/2.0,0),Vector3r(length/2.0,thickness/2.0,width/2.0)); YADE_PTR_CAST<FrictMat> (w4->material)->frictionAngle = sphereFrictionDeg * Mathr::PI/180.0; // so that we have phi(spheres-superior wall)=phi(sphere-sphere) scene->bodies->insert(w4); // To close the front and the back of the box shared_ptr<Body> w5; // behind createBox(w5,Vector3r(length/2.0,height/2.0,-width/2.0-thickness/2.0), Vector3r(2.5*length/2.0,height/2.0+thickness,thickness/2.0)); scene->bodies->insert(w5); shared_ptr<Body> w6; // the front createBox(w6,Vector3r(length/2.0,height/2.0,width/2.0+thickness/2.0), Vector3r(2.5*length/2.0,height/2.0+thickness,thickness/2.0)); scene->bodies->insert(w6); // the list which will contain the positions of centers and the radii of the created spheres vector<BasicSphere> sphere_list; // to use the TriaxialTest method : string out=GenerateCloud(sphere_list,Vector3r(0,0,-width/2.0),Vector3r(length,height,width/2.0),1000,0.3,0.7);// tries to generate a sample of 1000 spheres, with a required porosity of 0.7 cout << out << endl; // to use a text file : // std::pair<string,bool> res=ImportCloud(sphere_list,filename); vector<BasicSphere>::iterator it = sphere_list.begin(); vector<BasicSphere>::iterator it_end = sphere_list.end(); shared_ptr<Body> body; for (;it!=it_end; ++it) { createSphere(body,it->first,it->second); scene->bodies->insert(body); } return true; }
void initializePhysx() { // Init Physx physx::PxFoundation* foundation = PxCreateFoundation( PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback ); if( !foundation ) std::cerr << "PxCreateFoundation failed!" << std::endl; gPhysicsSDK = PxCreatePhysics( PX_PHYSICS_VERSION, *foundation, physx::PxTolerancesScale() ); if( gPhysicsSDK == NULL ) { std::cerr << "Error creating PhysX3 device." << std::endl; std::cerr << "Exiting.." << std::endl; exit(1); } if( !PxInitExtensions( *gPhysicsSDK )) std::cerr << "PxInitExtensions failed!" << std::endl; // Create Scene physx::PxSceneDesc sceneDesc( gPhysicsSDK->getTolerancesScale() ); sceneDesc.gravity = physx::PxVec3( 0.0f, gravity, 0.0f ); if( !sceneDesc.cpuDispatcher ) { physx::PxDefaultCpuDispatcher* mCpuDispatcher = physx::PxDefaultCpuDispatcherCreate(1); if( !mCpuDispatcher ) std::cerr << "PxDefaultCpuDispatcherCreate failed!" << std::endl; sceneDesc.cpuDispatcher = mCpuDispatcher; } if( !sceneDesc.filterShader ) sceneDesc.filterShader = gDefaultFilterShader; gScene = gPhysicsSDK->createScene(sceneDesc); if( !gScene ) std::cerr << "createScene failed!" << std::endl; gScene->setVisualizationParameter(physx::PxVisualizationParameter::eSCALE, 1.0); gScene->setVisualizationParameter(physx::PxVisualizationParameter::eCOLLISION_SHAPES, 1.0f); // Create Actors createActors(); }
QMap<QString, vtkActor *> GeometryBase::actors() { if (m_actors.size() == 0) createActors(); return m_actors; }
bool CohesiveTriaxialTest::generate(std::string& message) { // unsigned int startId=boost::numeric::bounds<unsigned int>::highest(), endId=0; // record forces from group 2 scene = shared_ptr<Scene>(new Scene); createActors(scene); positionRootBody(scene); shared_ptr<Body> body; if(boxWalls) { // bottom box Vector3r center = Vector3r( (lowerCorner[0]+upperCorner[0])/2, lowerCorner[1]-thickness/2.0, (lowerCorner[2]+upperCorner[2])/2); Vector3r halfSize = Vector3r( 1.5*std::abs(lowerCorner[0]-upperCorner[0])/2+thickness, thickness/2.0, 1.5*std::abs(lowerCorner[2]-upperCorner[2])/2+thickness); createBox(body,center,halfSize,wall_bottom_wire); if(wall_bottom) { scene->bodies->insert(body); triaxialcompressionEngine->wall_bottom_id = body->getId(); //triaxialStateRecorder->wall_bottom_id = body->getId(); // forcerec->startId = body->getId(); // forcerec->endId = body->getId(); } //forcerec->id = body->getId(); // top box center = Vector3r( (lowerCorner[0]+upperCorner[0])/2, upperCorner[1]+thickness/2.0, (lowerCorner[2]+upperCorner[2])/2); halfSize = Vector3r( 1.5*std::abs(lowerCorner[0]-upperCorner[0])/2+thickness, thickness/2.0, 1.5*std::abs(lowerCorner[2]-upperCorner[2])/2+thickness); createBox(body,center,halfSize,wall_top_wire); if(wall_top) { scene->bodies->insert(body); triaxialcompressionEngine->wall_top_id = body->getId(); //triaxialStateRecorder->wall_top_id = body->getId(); } // box 1 center = Vector3r( lowerCorner[0]-thickness/2.0, (lowerCorner[1]+upperCorner[1])/2, (lowerCorner[2]+upperCorner[2])/2); halfSize = Vector3r( thickness/2.0, 1.5*std::abs(lowerCorner[1]-upperCorner[1])/2+thickness, 1.5*std::abs(lowerCorner[2]-upperCorner[2])/2+thickness); createBox(body,center,halfSize,wall_1_wire); if(wall_1) { scene->bodies->insert(body); triaxialcompressionEngine->wall_left_id = body->getId(); //triaxialStateRecorder->wall_left_id = body->getId(); } // box 2 center = Vector3r( upperCorner[0]+thickness/2.0, (lowerCorner[1]+upperCorner[1])/2, (lowerCorner[2]+upperCorner[2])/2); halfSize = Vector3r( thickness/2.0, 1.5*std::abs(lowerCorner[1]-upperCorner[1])/2+thickness, 1.5*std::abs(lowerCorner[2]-upperCorner[2])/2+thickness); createBox(body,center,halfSize,wall_2_wire); if(wall_2) { scene->bodies->insert(body); triaxialcompressionEngine->wall_right_id = body->getId(); //triaxialStateRecorder->wall_right_id = body->getId(); } // box 3 center = Vector3r( (lowerCorner[0]+upperCorner[0])/2, (lowerCorner[1]+upperCorner[1])/2, lowerCorner[2]-thickness/2.0); halfSize = Vector3r( 1.5*std::abs(lowerCorner[0]-upperCorner[0])/2+thickness, 1.5*std::abs(lowerCorner[1]-upperCorner[1])/2+thickness, thickness/2.0); createBox(body,center,halfSize,wall_3_wire); if(wall_3) { scene->bodies->insert(body); triaxialcompressionEngine->wall_back_id = body->getId(); //triaxialStateRecorder->wall_back_id = body->getId(); } // box 4 center = Vector3r( (lowerCorner[0]+upperCorner[0])/2, (lowerCorner[1]+upperCorner[1])/2, upperCorner[2]+thickness/2.0); halfSize = Vector3r( 1.5*std::abs(lowerCorner[0]-upperCorner[0])/2+thickness, 1.5*std::abs(lowerCorner[1]-upperCorner[1])/2+thickness, thickness/2.0); createBox(body,center,halfSize,wall_3_wire); if(wall_4) { scene->bodies->insert(body); triaxialcompressionEngine->wall_front_id = body->getId(); //triaxialStateRecorder->wall_front_id = body->getId(); } } //convert the original sphere vector (with clump info) to a BasicSphere vector. vector<BasicSphere> sphere_list; typedef boost::tuple<Vector3r,Real,int> tupleVector3rRealInt; if(importFilename!=""){ vector<boost::tuple<Vector3r,Real,int> >sphereListClumpInfo = Shop::loadSpheresFromFile(importFilename,lowerCorner,upperCorner); FOREACH(tupleVector3rRealInt t, sphereListClumpInfo){ sphere_list.push_back(make_pair(boost::get<0>(t),boost::get<1>(t))); };