Skip to content

Commit 565955d

Browse files
committed
manual color works
1 parent df244cc commit 565955d

File tree

3 files changed

+111
-27
lines changed

3 files changed

+111
-27
lines changed

src/ExampleNets/regression/interfaceWithOspray.srn5

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<networkFile class_id="0" tracking_level="0" version="6">
55
<networkInfo class_id="1" tracking_level="0" version="0">
66
<modules class_id="2" tracking_level="0" version="0">
7-
<count>4</count>
7+
<count>5</count>
88
<item_version>0</item_version>
99
<item class_id="3" tracking_level="0" version="0">
1010
<first>ConvertQuadSurfToTriSurf:0</first>
@@ -22,6 +22,58 @@
2222
</state>
2323
</second>
2424
</item>
25+
<item>
26+
<first>CreateFieldData:0</first>
27+
<second>
28+
<module>
29+
<package_name_>SCIRun</package_name_>
30+
<category_name_>ChangeFieldData</category_name_>
31+
<module_name_>CreateFieldData</module_name_>
32+
</module>
33+
<state>
34+
<stateMap>
35+
<count>3</count>
36+
<item_version>0</item_version>
37+
<item class_id="8" tracking_level="0" version="0">
38+
<first class_id="9" tracking_level="0" version="0">
39+
<name>BasisString</name>
40+
</first>
41+
<second class_id="10" tracking_level="0" version="0">
42+
<name>BasisString</name>
43+
<value class_id="11" tracking_level="0" version="0">
44+
<which>2</which>
45+
<value>Linear</value>
46+
</value>
47+
</second>
48+
</item>
49+
<item>
50+
<first>
51+
<name>FormatString</name>
52+
</first>
53+
<second>
54+
<name>FormatString</name>
55+
<value>
56+
<which>2</which>
57+
<value>Scalar</value>
58+
</value>
59+
</second>
60+
</item>
61+
<item>
62+
<first>
63+
<name>FunctionString</name>
64+
</first>
65+
<second>
66+
<name>FunctionString</name>
67+
<value>
68+
<which>2</which>
69+
<value>RESULT = X;</value>
70+
</value>
71+
</second>
72+
</item>
73+
</stateMap>
74+
</state>
75+
</second>
76+
</item>
2577
<item>
2678
<first>CreateLatVol:0</first>
2779
<second>
@@ -34,13 +86,13 @@
3486
<stateMap>
3587
<count>6</count>
3688
<item_version>0</item_version>
37-
<item class_id="8" tracking_level="0" version="0">
38-
<first class_id="9" tracking_level="0" version="0">
89+
<item>
90+
<first>
3991
<name>DataAtLocation</name>
4092
</first>
41-
<second class_id="10" tracking_level="0" version="0">
93+
<second>
4294
<name>DataAtLocation</name>
43-
<value class_id="11" tracking_level="0" version="0">
95+
<value>
4496
<which>0</which>
4597
<value>0</value>
4698
</value>
@@ -54,7 +106,7 @@
54106
<name>ElementSizeNormalized</name>
55107
<value>
56108
<which>0</which>
57-
<value>0</value>
109+
<value>1</value>
58110
</value>
59111
</second>
60112
</item>
@@ -78,7 +130,7 @@
78130
<name>XSize</name>
79131
<value>
80132
<which>0</which>
81-
<value>16</value>
133+
<value>3</value>
82134
</value>
83135
</second>
84136
</item>
@@ -90,7 +142,7 @@
90142
<name>YSize</name>
91143
<value>
92144
<which>0</which>
93-
<value>16</value>
145+
<value>3</value>
94146
</value>
95147
</second>
96148
</item>
@@ -102,7 +154,7 @@
102154
<name>ZSize</name>
103155
<value>
104156
<which>0</which>
105-
<value>16</value>
157+
<value>3</value>
106158
</value>
107159
</second>
108160
</item>
@@ -144,7 +196,7 @@
144196
</item>
145197
</modules>
146198
<connections class_id="12" tracking_level="0" version="0">
147-
<count>3</count>
199+
<count>4</count>
148200
<item_version>0</item_version>
149201
<item class_id="13" tracking_level="0" version="0">
150202
<moduleId1_>ConvertQuadSurfToTriSurf:0</moduleId1_>
@@ -159,7 +211,7 @@
159211
</port2_>
160212
</item>
161213
<item>
162-
<moduleId1_>CreateLatVol:0</moduleId1_>
214+
<moduleId1_>CreateFieldData:0</moduleId1_>
163215
<port1_>
164216
<name>OutputField</name>
165217
<id>0</id>
@@ -170,6 +222,18 @@
170222
<id>0</id>
171223
</port2_>
172224
</item>
225+
<item>
226+
<moduleId1_>CreateLatVol:0</moduleId1_>
227+
<port1_>
228+
<name>OutputField</name>
229+
<id>0</id>
230+
</port1_>
231+
<moduleId2_>CreateFieldData:0</moduleId2_>
232+
<port2_>
233+
<name>InputField</name>
234+
<id>0</id>
235+
</port2_>
236+
</item>
173237
<item>
174238
<moduleId1_>GetFieldBoundary:0</moduleId1_>
175239
<port1_>
@@ -185,7 +249,7 @@
185249
</connections>
186250
</networkInfo>
187251
<modulePositions class_id="15" tracking_level="0" version="0">
188-
<count>4</count>
252+
<count>5</count>
189253
<item_version>0</item_version>
190254
<item class_id="16" tracking_level="0" version="0">
191255
<first>ConvertQuadSurfToTriSurf:0</first>
@@ -194,11 +258,18 @@
194258
<second>-1.52000000000000000e+02</second>
195259
</second>
196260
</item>
261+
<item>
262+
<first>CreateFieldData:0</first>
263+
<second>
264+
<first>-2.28000000000000000e+02</first>
265+
<second>-3.80000000000000000e+02</second>
266+
</second>
267+
</item>
197268
<item>
198269
<first>CreateLatVol:0</first>
199270
<second>
200271
<first>-3.04000000000000000e+02</first>
201-
<second>-3.04000000000000000e+02</second>
272+
<second>-5.32000000000000000e+02</second>
202273
</second>
203274
</item>
204275
<item>
@@ -225,12 +296,16 @@
225296
<item_version>0</item_version>
226297
</connectionNotes>
227298
<moduleTags class_id="19" tracking_level="0" version="0">
228-
<count>4</count>
299+
<count>5</count>
229300
<item_version>0</item_version>
230301
<item class_id="20" tracking_level="0" version="0">
231302
<first>ConvertQuadSurfToTriSurf:0</first>
232303
<second>-1</second>
233304
</item>
305+
<item>
306+
<first>CreateFieldData:0</first>
307+
<second>-1</second>
308+
</item>
234309
<item>
235310
<first>CreateLatVol:0</first>
236311
<second>-1</second>

src/Modules/Visualization/InterfaceWithOspray.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ DEALINGS IN THE SOFTWARE.
3131
// #include <Core/Algorithms/Visualization/RenderFieldState.h>
3232
// #include <Core/Datatypes/Legacy/Field/VMesh.h>
3333
// #include <Core/Datatypes/Legacy/Field/Field.h>
34-
// #include <Core/Datatypes/Legacy/Field/VField.h>
34+
#include <Core/Datatypes/Legacy/Field/VField.h>
3535
// #include <Core/Datatypes/Color.h>
3636
#include <Core/Datatypes/ColorMap.h>
3737
// #include <Core/GeometryPrimitives/Vector.h>
@@ -136,13 +136,6 @@ class GeometryBuilder
136136
using namespace detail;
137137
#endif
138138

139-
InterfaceWithOspray::InterfaceWithOspray() : GeometryGeneratingModule(staticInfo_)
140-
{
141-
INITIALIZE_PORT(Field);
142-
INITIALIZE_PORT(ColorMapObject);
143-
INITIALIZE_PORT(SceneGraph);
144-
}
145-
146139
void InterfaceWithOspray::setStateDefaults()
147140
{
148141
// auto state = get_state();
@@ -197,7 +190,7 @@ void InterfaceWithOspray::setStateDefaults()
197190
// // is more up in the air.
198191
}
199192

200-
namespace
193+
namespace detail
201194
{
202195
class OsprayImpl
203196
{
@@ -228,16 +221,22 @@ namespace
228221
float cam_view[] = { 0.5f, 0.5f, 1.f };
229222

230223
std::vector<float> vertex, color;
224+
auto vfield = field->vfield();
231225
//float maxColor = max;
232226
{
227+
double value;
233228
for (const auto& node : facade->nodes())
234229
{
235230
auto point = node.point();
236231
vertex.push_back(static_cast<float>(point.x()));
237232
vertex.push_back(static_cast<float>(point.y()));
238233
vertex.push_back(static_cast<float>(point.z()));
239234
vertex.push_back(0);
240-
color.push_back(0.8f);
235+
236+
vfield->get_value(value, node.index());
237+
//std::cout << "Node: " << node.index() << " value: " << value << std::endl;
238+
239+
color.push_back(value / 2.0f);
241240
color.push_back(0.5f);
242241
color.push_back(0.5f);
243242
color.push_back(1.0f);
@@ -345,6 +344,12 @@ namespace
345344
};
346345
}
347346

347+
InterfaceWithOspray::InterfaceWithOspray() : GeometryGeneratingModule(staticInfo_), impl_(new detail::OsprayImpl)
348+
{
349+
INITIALIZE_PORT(Field);
350+
INITIALIZE_PORT(ColorMapObject);
351+
INITIALIZE_PORT(SceneGraph);
352+
}
348353

349354
void InterfaceWithOspray::execute()
350355
{
@@ -353,12 +358,11 @@ void InterfaceWithOspray::execute()
353358

354359
if (needToExecute())
355360
{
356-
OsprayImpl impl;
357361
// for (int inc : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
358362
// {
359363
// osprayImpl::renderLatVol(latVol, inc*0.2, GetParam());
360364
// }
361-
impl.writeImage(field, "scirunOsprayOutput.ppm", 0.2);
365+
impl_->writeImage(field, "scirunOsprayOutput.ppm", 0.2);
362366

363367
//updateAvailableRenderOptions(field);
364368
//auto geom = builder_->buildGeometryObject(field, colorMap, *this, this);

src/Modules/Visualization/InterfaceWithOspray.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ DEALINGS IN THE SOFTWARE.
3333
#include <Core/Thread/Interruptible.h>
3434
#include <Modules/Visualization/share.h>
3535

36+
namespace detail
37+
{
38+
class OsprayImpl;
39+
}
40+
3641
namespace SCIRun {
3742

3843
namespace Core
@@ -108,7 +113,7 @@ namespace SCIRun {
108113

109114
virtual void setStateDefaults() override;
110115
private:
111-
116+
boost::shared_ptr<detail::OsprayImpl> impl_;
112117
};
113118

114119

0 commit comments

Comments
 (0)