PeriDyno 0.9.2
Loading...
Searching...
No Matches
StaticTriangularMesh.cpp
Go to the documentation of this file.
2
4
5#include "Topology/TriangleSet.h"
6
7namespace dyno
8{
9 IMPLEMENT_TCLASS(StaticTriangularMesh, TDataType)
10
11 template<typename TDataType>
14 {
15 auto triSet = std::make_shared<TriangleSet<TDataType>>();
16 this->stateTriangleSet()->setDataPtr(triSet);
17
18 this->stateInitialTriangleSet()->setDataPtr(std::make_shared<TriangleSet<TDataType>>());
19
20 auto surfaceRender = std::make_shared<GLSurfaceVisualModule>();
21 surfaceRender->setColor(Color(0.8f, 0.52f, 0.25f));
22 surfaceRender->setVisible(true);
23 this->stateTriangleSet()->connect(surfaceRender->inTriangleSet());
24 this->graphicsPipeline()->pushModule(surfaceRender);
25
26 auto callFileLoader = std::make_shared<FCallBackFunc>(
27 [=]() {
28 auto initTopo = this->stateInitialTriangleSet()->getDataPtr();
29 auto curTopo = this->stateTriangleSet()->getDataPtr();
30
31 std::string fileName = this->varFileName()->getValue().string();
32
33 if (fileName != "")
34 {
35 initTopo->loadObjFile(fileName);
36 curTopo->copyFrom(*initTopo);
37
38 curTopo->scale(this->varScale()->getValue());
39 curTopo->rotate(this->varRotation()->getValue() * M_PI / 180);
40 curTopo->translate(this->varLocation()->getValue());
41 }
42 }
43 );
44 this->varFileName()->attach(callFileLoader);
45
46 auto transform = std::make_shared<FCallBackFunc>(
47 [=]() {
48 auto initTopo = this->stateInitialTriangleSet()->getDataPtr();
49 auto curTopo = this->stateTriangleSet()->getDataPtr();
50
51 curTopo->copyFrom(*initTopo);
52 curTopo->scale(this->varScale()->getValue());
53 curTopo->rotate(this->varRotation()->getValue() * M_PI / 180);
54 curTopo->translate(this->varLocation()->getValue());
55 }
56 );
57 this->varLocation()->attach(transform);
58 this->varScale()->attach(transform);
59 this->varRotation()->attach(transform);
60 }
61
63}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
#define M_PI
Definition Typedef.inl:35
std::shared_ptr< GraphicsPipeline > graphicsPipeline()
Definition Node.cpp:312
A node containing a TriangleSet object.
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:24
ArrayMap< T, DeviceType::GPU > DArrayMap
Definition ArrayMap.inl:80