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