PeriDyno 1.0.0
Loading...
Searching...
No Matches
TrianglePickerNode.cpp
Go to the documentation of this file.
5
6namespace dyno
7{
9
10 template<typename TDataType>
12 :Node()
13 {
14 auto surfaceInteractor = std::make_shared<SurfaceInteraction<TDataType>>();
15 auto edgeInteractor = std::make_shared<EdgeInteraction<TDataType>>();
16 auto pointInteractor = std::make_shared<PointInteraction<TDataType>>();
17
18 this->inTopology()->connect(surfaceInteractor->inInitialTriangleSet());
19 this->inTopology()->connect(edgeInteractor->inInitialEdgeSet());
20 this->inTopology()->connect(pointInteractor->inInitialPointSet());
21
22 this->varFloodAngle()->connect(surfaceInteractor->varFloodAngle());
23 this->varToggleFlood()->connect(surfaceInteractor->varToggleFlood());
24 this->varToggleVisibleFilter()->connect(surfaceInteractor->varToggleVisibleFilter());
25
26 this->varToggleIndexOutput()->connect(surfaceInteractor->varToggleIndexOutput());
27 this->varToggleIndexOutput()->connect(edgeInteractor->varToggleIndexOutput());
28 this->varToggleIndexOutput()->connect(pointInteractor->varToggleIndexOutput());
29
30 this->varInteractionRadius()->connect(edgeInteractor->varInteractionRadius());
31 this->varInteractionRadius()->connect(pointInteractor->varInteractionRadius());
32
33 this->stateTriQuadIndex()->connect(surfaceInteractor->outTriangleIndex());
34 this->stateEdgeIndex()->connect(edgeInteractor->outEdgeIndex());
35 this->statePointIndex()->connect(pointInteractor->outPointIndex());
36
37 this->stateSur2PointIndex()->connect(surfaceInteractor->outSur2PointIndex());
38
42
43 this->graphicsPipeline()->pushModule(surfaceInteractor);
44 this->graphicsPipeline()->pushModule(edgeInteractor);
45 this->graphicsPipeline()->pushModule(pointInteractor);
46
47 auto surfaceRender1 = std::make_shared<GLSurfaceVisualModule>();
48 surfaceRender1->setColor(Color(0.2f, 0.48f, 0.75f));
49 surfaceRender1->varAlpha()->setValue(0.95f);
50 this->surfaceInteractor->outSelectedTriangleSet()->connect(surfaceRender1->inTriangleSet());
51 this->graphicsPipeline()->pushModule(surfaceRender1);
52
53 auto surfaceRender2 = std::make_shared<GLSurfaceVisualModule>();
54 surfaceRender2->setColor(Color(0.8f, 0.52f, 0.25f));
55 surfaceRender2->varAlpha()->setValue(0.85f);
56 this->surfaceInteractor->outOtherTriangleSet()->connect(surfaceRender2->inTriangleSet());
57 this->graphicsPipeline()->pushModule(surfaceRender2);
58
59 auto edgeRender1 = std::make_shared<GLWireframeVisualModule>();
60 this->varEdgeSelectedSize()->connect(edgeRender1->varRadius());
61 edgeRender1->setColor(Color(0.8f, 0.0f, 0.0f));
62 this->edgeInteractor->outSelectedEdgeSet()->connect(edgeRender1->inEdgeSet());
63 this->graphicsPipeline()->pushModule(edgeRender1);
64
65 auto edgeRender2 = std::make_shared<GLWireframeVisualModule>();
66 this->varEdgeOtherSize()->connect(edgeRender2->varRadius());
67 edgeRender2->setColor(Color(0.0f));
68 this->edgeInteractor->outOtherEdgeSet()->connect(edgeRender2->inEdgeSet());
69 this->graphicsPipeline()->pushModule(edgeRender2);
70
71 auto pointRender1 = std::make_shared<GLPointVisualModule>();
72 this->varPointSelectedSize()->connect(pointRender1->varPointSize());
73 pointRender1->setColor(Color(1.0f, 0.0f, 0.0f));
74 this->pointInteractor->outSelectedPointSet()->connect(pointRender1->inPointSet());
75 this->graphicsPipeline()->pushModule(pointRender1);
76
77 auto pointRender2 = std::make_shared<GLPointVisualModule>();
78 this->varPointOtherSize()->connect(pointRender2->varPointSize());
79 pointRender2->setColor(Color(0.0f, 0.0f, 1.0f));
80 this->pointInteractor->outOtherPointSet()->connect(pointRender2->inPointSet());
81 this->graphicsPipeline()->pushModule(pointRender2);
82
83 this->varInteractionRadius()->setRange(0.001f , 1.0f);
84 this->varInteractionRadius()->setValue(0.01f);
85 this->varPointSelectedSize()->setRange(0.0f, 0.5f);
86 this->varPointOtherSize()->setRange(0.0f,0.5f);
87 this->varEdgeSelectedSize()->setRange(0.0f, 0.5f);
88 this->varEdgeOtherSize()->setRange(0.0f, 0.5f);
89 this->varFloodAngle()->setRange(0.0f, 180.0f);
90
91 auto callback1 = std::make_shared<FCallBackFunc>(std::bind(&TrianglePickerNode<TDataType>::changePickingElementType, this));
92
93 this->varPickingElementType()->attach(callback1);
94
95 auto callback2 = std::make_shared<FCallBackFunc>(std::bind(&TrianglePickerNode<TDataType>::changePickingType, this));
96
97 this->varPickingType()->attach(callback2);
98
99 auto callback3 = std::make_shared<FCallBackFunc>(std::bind(&TrianglePickerNode<TDataType>::changeMultiSelectionType, this));
100
101 this->varMultiSelectionType()->attach(callback3);
102
103 this->surfaceInteractor->outTriangleIndex()->allocate();
104 this->edgeInteractor->outEdgeIndex()->allocate();
105 this->pointInteractor->outPointIndex()->allocate();
106 this->surfaceInteractor->outSur2PointIndex()->allocate();
107 }
108
109 template<typename TDataType>
113
114 template<typename TDataType>
116 {
117 return "Interaction";
118 }
119
120 template<typename TDataType>
122 {
123 this->inTopology()->getDataPtr()->update();
124
125 this->surfaceInteractor->outTriangleIndex()->allocate();
126 this->edgeInteractor->outEdgeIndex()->allocate();
127 this->pointInteractor->outPointIndex()->allocate();
128
129 this->surfaceInteractor->outOtherTriangleSet()->setDataPtr(std::make_shared<TriangleSet<TDataType>>());
130 this->surfaceInteractor->outSelectedTriangleSet()->setDataPtr(std::make_shared<TriangleSet<TDataType>>());
131 this->surfaceInteractor->outSelectedTriangleSet()->getDataPtr()->getTriangles().resize(0);
132 this->surfaceInteractor->outOtherTriangleSet()->getDataPtr()->copyFrom(this->inTopology()->getData());
133
134 this->edgeInteractor->outOtherEdgeSet()->setDataPtr(std::make_shared<EdgeSet<TDataType>>());
135 this->edgeInteractor->outSelectedEdgeSet()->setDataPtr(std::make_shared<EdgeSet<TDataType>>());
136 this->edgeInteractor->outOtherEdgeSet()->getDataPtr()->copyFrom(this->inTopology()->getData());
137
138 this->pointInteractor->outOtherPointSet()->setDataPtr(std::make_shared<PointSet<TDataType>>());
139 this->pointInteractor->outSelectedPointSet()->setDataPtr(std::make_shared<PointSet<TDataType>>());
140 this->pointInteractor->outOtherPointSet()->getDataPtr()->copyFrom(this->inTopology()->getData());
141 }
142
143 template<typename TDataType>
145 {
146 if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::Surface)
147 {
148 this->surfaceInteractor->varTogglePicker()->setValue(true);
149 this->edgeInteractor->varTogglePicker()->setValue(false);
150 this->pointInteractor->varTogglePicker()->setValue(false);
151 }
152 else if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::Edge)
153 {
154 this->surfaceInteractor->varTogglePicker()->setValue(false);
155 this->edgeInteractor->varTogglePicker()->setValue(true);
156 this->pointInteractor->varTogglePicker()->setValue(false);
157 }
158 else if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::Point)
159 {
160 this->surfaceInteractor->varTogglePicker()->setValue(false);
161 this->edgeInteractor->varTogglePicker()->setValue(false);
162 this->pointInteractor->varTogglePicker()->setValue(true);
163 }
164 else if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::All)
165 {
166 this->surfaceInteractor->varTogglePicker()->setValue(true);
167 this->edgeInteractor->varTogglePicker()->setValue(true);
168 this->pointInteractor->varTogglePicker()->setValue(true);
169 }
170 resetStates();
171 }
172
173 template<typename TDataType>
175 {
176 if (this->varPickingType()->getValue() == PickingTypeSelection::Click)
177 {
178 this->surfaceInteractor->varSurfacePickingType()-> getDataPtr()->setCurrentKey(0);
179 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(0);
180 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(0);
181 }
182 else if (this->varPickingType()->getValue() == PickingTypeSelection::Drag)
183 {
184 this->surfaceInteractor->varSurfacePickingType()->getDataPtr()->setCurrentKey(1);
185 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(1);
186 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(1);
187 }
188 else if (this->varPickingType()->getValue() == PickingTypeSelection::Both)
189 {
190 this->surfaceInteractor->varSurfacePickingType()->getDataPtr()->setCurrentKey(2);
191 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(2);
192 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(2);
193 }
194 resetStates();
195 }
196
197 template<typename TDataType>
199 {
200 if (this->varMultiSelectionType()->getValue() == MultiSelectionType::OR)
201 {
202 this->surfaceInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(0);
203 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(0);
204 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(0);
205 }
206 else if (this->varMultiSelectionType()->getValue() == MultiSelectionType::XOR)
207 {
208 this->surfaceInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(1);
209 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(1);
210 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(1);
211 }
212 else if (this->varMultiSelectionType()->getValue() == MultiSelectionType::C)
213 {
214 this->surfaceInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(2);
215 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(2);
216 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(2);
217 }
218 }
219
221}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
std::shared_ptr< GraphicsPipeline > graphicsPipeline()
Definition Node.cpp:320
A PointSet stores the coordinates for a set of independent points.
Definition PointSet.h:8
std::shared_ptr< SurfaceInteraction< TDataType > > surfaceInteractor
std::shared_ptr< PointInteraction< TDataType > > pointInteractor
std::shared_ptr< EdgeInteraction< TDataType > > edgeInteractor
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25