31 this->varHorizon()->attach(
32 std::make_shared<FCallBackFunc>(
34 this->stateHorizon()->setValue(this->varHorizon()->getValue());
38 this->varHorizon()->setValue(0.0085);
40 auto integrator = std::make_shared<ParticleIntegrator<TDataType>>();
41 this->stateTimeStep()->connect(integrator->inTimeStep());
42 this->statePosition()->connect(integrator->inPosition());
43 this->stateVelocity()->connect(integrator->inVelocity());
47 auto elasticity = std::make_shared<LinearElasticitySolver<TDataType>>();
48 this->stateHorizon()->connect(elasticity->inHorizon());
49 this->stateTimeStep()->connect(elasticity->inTimeStep());
50 this->stateRestPosition()->connect(elasticity->inX());
51 this->statePosition()->connect(elasticity->inY());
52 this->stateVelocity()->connect(elasticity->inVelocity());
53 this->stateBonds()->connect(elasticity->inBonds());
56 auto pointRenderer = std::make_shared<GLPointVisualModule>();
57 pointRenderer->setColor(
Color(1, 0.2, 1));
58 pointRenderer->setColorMapMode(GLPointVisualModule::PER_OBJECT_SHADER);
59 pointRenderer->varPointSize()->setValue(0.002f);
60 this->stateTriangleSet()->connect(pointRenderer->inPointSet());
61 this->stateVelocity()->connect(pointRenderer->inColor());
66 auto wireRenderer = std::make_shared<GLWireframeVisualModule>();
67 wireRenderer->varBaseColor()->setValue(
Color(1.0, 0.8, 0.8));
68 wireRenderer->varRadius()->setValue(0.001f);
69 wireRenderer->varRenderMode()->setCurrentKey(GLWireframeVisualModule::CYLINDER);
70 this->stateTriangleSet()->connect(wireRenderer->inEdgeSet());
73 auto surfaceRenderer = std::make_shared<GLSurfaceVisualModule>();
74 this->stateTriangleSet()->connect(surfaceRenderer->inTriangleSet());
87 auto input = this->inTriangleSet()->getDataPtr();
89 auto ts = this->stateTriangleSet()->getDataPtr();
94 ts->requestPointNeighbors(nbr);
95 auto& pts = ts->getPoints();
97 this->statePosition()->resize(pts.size());
98 this->stateVelocity()->resize(pts.size());
100 this->statePosition()->assign(pts);
101 this->stateVelocity()->reset();
103 if (this->stateBonds()->isEmpty()) {
104 this->stateBonds()->allocate();
107 auto nbrPtr = this->stateBonds()->getDataPtr();
109 this->stateOldPosition()->assign(this->statePosition()->getData());
110 this->stateRestPosition()->assign(this->statePosition()->getData());