PeriDyno 1.0.0
Loading...
Searching...
No Matches
EdgePickerNode.cpp
Go to the documentation of this file.
1#include "EdgePickerNode.h"
5
6namespace dyno
7{
9
10 template<typename TDataType>
12 :Node()
13 {
14 auto edgeInteractor = std::make_shared<EdgeInteraction<TDataType>>();
15 auto pointInteractor = std::make_shared<PointInteraction<TDataType>>();
16 this->inTopology()->connect(edgeInteractor->inInitialEdgeSet());
17 this->inTopology()->connect(pointInteractor->inInitialPointSet());
18
19 this->varInteractionRadius()->connect(edgeInteractor->varInteractionRadius());
20 this->varInteractionRadius()->connect(pointInteractor->varInteractionRadius());
21
22 this->stateEdgeIndex()->connect(edgeInteractor->outEdgeIndex());
23 this->statePointIndex()->connect(pointInteractor->outPointIndex());
24
25 this->varToggleIndexOutput()->connect(edgeInteractor->varToggleIndexOutput());
26 this->varToggleIndexOutput()->connect(pointInteractor->varToggleIndexOutput());
27
30
31 this->graphicsPipeline()->pushModule(edgeInteractor);
32 this->graphicsPipeline()->pushModule(pointInteractor);
33
34 auto edgeRender1 = std::make_shared<GLWireframeVisualModule>();
35 this->varEdgeSelectedSize()->connect(edgeRender1->varRadius());
36 edgeRender1->setColor(Color(0.8f, 0.0f, 0.0f));
37 this->edgeInteractor->outSelectedEdgeSet()->connect(edgeRender1->inEdgeSet());
38 this->graphicsPipeline()->pushModule(edgeRender1);
39
40 auto edgeRender2 = std::make_shared<GLWireframeVisualModule>();
41 this->varEdgeOtherSize()->connect(edgeRender2->varRadius());
42 edgeRender2->setColor(Color(0.0f, 0.0f, 0.0f));
43 this->edgeInteractor->outOtherEdgeSet()->connect(edgeRender2->inEdgeSet());
44 this->graphicsPipeline()->pushModule(edgeRender2);
45
46 auto pointRender1 = std::make_shared<GLPointVisualModule>();
47 this->varPointSelectedSize()->connect(pointRender1->varPointSize());
48 pointRender1->setColor(Color(1.0f, 0.0f, 0.0f));
49 this->pointInteractor->outSelectedPointSet()->connect(pointRender1->inPointSet());
50 this->graphicsPipeline()->pushModule(pointRender1);
51
52 auto pointRender2 = std::make_shared<GLPointVisualModule>();
53 this->varPointOtherSize()->connect(pointRender2->varPointSize());
54 pointRender2->setColor(Color(0.0f, 0.0f, 1.0f));
55 this->pointInteractor->outOtherPointSet()->connect(pointRender2->inPointSet());
56 this->graphicsPipeline()->pushModule(pointRender2);
57
58 this->varInteractionRadius()->setRange(0.001f, 0.2f);
59 this->varInteractionRadius()->setValue(0.01f);
60 this->varPointSelectedSize()->setRange(0.0f, 0.1f);
61 this->varPointOtherSize()->setRange(0.0f, 0.1f);
62
63 auto callback1 = std::make_shared<FCallBackFunc>(std::bind(&EdgePickerNode<TDataType>::changePickingElementType, this));
64
65 this->varPickingElementType()->attach(callback1);
66
67 auto callback2 = std::make_shared<FCallBackFunc>(std::bind(&EdgePickerNode<TDataType>::changePickingType, this));
68
69 this->varPickingType()->attach(callback2);
70
71 auto callback3 = std::make_shared<FCallBackFunc>(std::bind(&EdgePickerNode<TDataType>::changeMultiSelectionType, this));
72
73 this->varMultiSelectionType()->attach(callback3);
74
75 this->edgeInteractor->outEdgeIndex()->allocate();
76 this->pointInteractor->outPointIndex()->allocate();
77 }
78
79 template<typename TDataType>
83
84 template<typename TDataType>
86 {
87 return "Interaction";
88 }
89
90 template<typename TDataType>
92 {
93 // this->inTopology()->getDataPtr()->update();
94 this->edgeInteractor->outEdgeIndex()->allocate();
95 this->pointInteractor->outPointIndex()->allocate();
96
97 this->edgeInteractor->outOtherEdgeSet()->setDataPtr(std::make_shared<EdgeSet<TDataType>>());
98 this->edgeInteractor->outSelectedEdgeSet()->setDataPtr(std::make_shared<EdgeSet<TDataType>>());
99 this->edgeInteractor->outOtherEdgeSet()->getDataPtr()->copyFrom(this->inTopology()->getData());
100
101 this->pointInteractor->outOtherPointSet()->setDataPtr(std::make_shared<PointSet<TDataType>>());
102 this->pointInteractor->outSelectedPointSet()->setDataPtr(std::make_shared<PointSet<TDataType>>());
103 this->pointInteractor->outOtherPointSet()->getDataPtr()->copyFrom(this->inTopology()->getData());
104 }
105
106 template<typename TDataType>
108 {
109 if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::Edge)
110 {
111 this->edgeInteractor->varTogglePicker()->setValue(true);
112 this->pointInteractor->varTogglePicker()->setValue(false);
113 }
114 else if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::Point)
115 {
116 this->edgeInteractor->varTogglePicker()->setValue(false);
117 this->pointInteractor->varTogglePicker()->setValue(true);
118 }
119 else if (this->varPickingElementType()->getValue() == PickingElementTypeSelection::All)
120 {
121 this->edgeInteractor->varTogglePicker()->setValue(true);
122 this->pointInteractor->varTogglePicker()->setValue(true);
123 }
124 resetStates();
125 }
126
127 template<typename TDataType>
129 {
130 if (this->varPickingType()->getValue() == PickingTypeSelection::Click)
131 {
132 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(0);
133 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(0);
134 }
135 else if (this->varPickingType()->getValue() == PickingTypeSelection::Drag)
136 {
137 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(1);
138 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(1);
139 }
140 else if (this->varPickingType()->getValue() == PickingTypeSelection::Both)
141 {
142 this->edgeInteractor->varEdgePickingType()->getDataPtr()->setCurrentKey(2);
143 this->pointInteractor->varPointPickingType()->getDataPtr()->setCurrentKey(2);
144 }
145 resetStates();
146 }
147
148 template<typename TDataType>
150 {
151 if (this->varMultiSelectionType()->getValue() == MultiSelectionType::OR)
152 {
153 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(0);
154 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(0);
155 }
156 else if (this->varMultiSelectionType()->getValue() == MultiSelectionType::XOR)
157 {
158 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(1);
159 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(1);
160 }
161 else if (this->varMultiSelectionType()->getValue() == MultiSelectionType::C)
162 {
163 this->edgeInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(2);
164 this->pointInteractor->varMultiSelectionType()->getDataPtr()->setCurrentKey(2);
165 }
166 }
167
169}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
std::shared_ptr< PointInteraction< TDataType > > pointInteractor
void resetStates() override
std::shared_ptr< EdgeInteraction< TDataType > > edgeInteractor
std::string getNodeType()
std::shared_ptr< GraphicsPipeline > graphicsPipeline()
Definition Node.cpp:320
A PointSet stores the coordinates for a set of independent points.
Definition PointSet.h:8
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25