PeriDyno 1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PolygonSetToTriangleSet.h
Go to the documentation of this file.
1#pragma once
2#include "Node.h"
4
6#include "Topology/TriangleSet.h"
7
8namespace dyno
9{
10 template<typename TDataType>
12 {
14 public:
15 typedef typename TDataType::Real Real;
16 typedef typename TDataType::Coord Coord;
17 typedef typename ::dyno::Transform<Real, 3> Transform;
18
20 {
21 this->outTriangleSet()->setDataPtr(std::make_shared<TriangleSet<DataType3f>>());
22 if (this->outPolygon2Triangles()->isEmpty())
23 {
24 this->outPolygon2Triangles()->allocate();
25 }
26 };
28
29 std::string caption() override { return "PolygonSetToTriangleSetModule"; }
30
32
34
35 DEF_ARRAYLIST_OUT(uint, Polygon2Triangles, DeviceType::GPU, "");
36
37 public:
38
39 void convert(std::shared_ptr<PolygonSet<TDataType>> polygonset, std::shared_ptr<TriangleSet<TDataType>> triset, DArrayList<uint>& poly2tri);
40
41 protected:
42 bool apply() override
43 {
44 auto& poly2tri = this->outPolygon2Triangles()->getData();
45 convert(this->inPolygonSet()->constDataPtr(), this->outTriangleSet()->getDataPtr(), poly2tri);
46
47 return true;
48 };
49 };
50 IMPLEMENT_TCLASS(PolygonSetToTriangleSetModule, TDataType)
51
52
53
54 template<typename TDataType>
56 {
58 public:
59 typedef typename TDataType::Real Real;
60 typedef typename TDataType::Coord Coord;
61
63
64 std::string caption() override { return "PolygonSetToTriangleSet"; }
65
67
69
70 DEF_ARRAYLIST_STATE(uint,Polygon2Triangles,DeviceType::GPU,"");
71
72
73
74 protected:
75 void resetStates() override
76 {
77 if (this->statePolygon2Triangles()->isEmpty())
78 {
79 this->statePolygon2Triangles()->allocate();
80 }
81 auto& poly2triId = this->statePolygon2Triangles()->getData();
82
83 mPolygonSetToTriangleSetMoudle->convert(this->inPolygonSet()->constDataPtr(),this->stateTriangleSet()->getDataPtr(), poly2triId);
84 };
85 void updateStates() override {};
86
87 private:
88 std::shared_ptr<PolygonSetToTriangleSetModule<DataType3f>> mPolygonSetToTriangleSetMoudle;
89 };
90
92}
#define DECLARE_TCLASS(name, T1)
Definition Object.h:87
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
a class to store polygon whose vertex number is greater or equal than 3
Definition PolygonSet.h:29
std::string caption() override
Return the caption.
DEF_INSTANCE_IN(PolygonSet< TDataType >, PolygonSet, "")
void convert(std::shared_ptr< PolygonSet< TDataType > > polygonset, std::shared_ptr< TriangleSet< TDataType > > triset, DArrayList< uint > &poly2tri)
DEF_ARRAYLIST_OUT(uint, Polygon2Triangles, DeviceType::GPU, "")
DEF_INSTANCE_OUT(TriangleSet< TDataType >, TriangleSet, "")
DEF_INSTANCE_IN(PolygonSet< TDataType >, PolygonSet, "")
std::shared_ptr< PolygonSetToTriangleSetModule< DataType3f > > mPolygonSetToTriangleSetMoudle
DEF_INSTANCE_STATE(TriangleSet< TDataType >, TriangleSet, "")
std::string caption() override
Return the caption.
DEF_ARRAYLIST_STATE(uint, Polygon2Triangles, DeviceType::GPU,"")
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
ArrayList< ElementType, DeviceType::GPU > DArrayList
Definition ArrayList.inl:83
unsigned int uint
Definition VkProgram.h:14