@@ -38,7 +38,9 @@ DEALINGS IN THE SOFTWARE.
3838
3939#include < boost/date_time/posix_time/posix_time.hpp>
4040
41+ #ifdef WITH_OSPRAY
4142#include < ospray/ospray.h>
43+ #endif
4244
4345using namespace SCIRun ;
4446using namespace Dataflow ::Networks;
@@ -96,6 +98,7 @@ void InterfaceWithOspray::setStateDefaults()
9698
9799namespace detail
98100{
101+ #ifdef WITH_OSPRAY
99102 class OsprayImpl
100103 {
101104 public:
@@ -114,7 +117,7 @@ namespace detail
114117
115118 // image size
116119 osp::vec2i imgSize;
117- imgSize.x = state->getValue (Parameters::ImageWidth).toInt ();
120+ imgSize.x = state->getValue (Parameters::ImageWidth).toInt ();
118121 imgSize.y = state->getValue (Parameters::ImageHeight).toInt ();
119122
120123 auto toFloat = [state](const Name& name) { return static_cast <float >(state->getValue (name).toDouble ()); };
@@ -203,7 +206,7 @@ namespace detail
203206 // complete setup of renderer
204207 ospSet1i (renderer, " aoSamples" , 1 );
205208 ospSet3f (renderer, " bgColor" , toFloat (Parameters::BackgroundColorR),
206- toFloat (Parameters::BackgroundColorG),
209+ toFloat (Parameters::BackgroundColorG),
207210 toFloat (Parameters::BackgroundColorB));
208211 ospSetObject (renderer, " model" , world);
209212 ospSetObject (renderer, " camera" , camera);
@@ -233,10 +236,10 @@ namespace detail
233236 FILE *file = fopen (fileName, " wb" );
234237 fprintf (file, " P6\n %i %i\n 255\n " , size.x , size.y );
235238 std::vector<unsigned char > out (3 * size.x );
236- for (int y = 0 ; y < size.y ; y++)
239+ for (int y = 0 ; y < size.y ; y++)
237240 {
238241 const unsigned char *in = (const unsigned char *)&pixel[(size.y - 1 - y)*size.x ];
239- for (int x = 0 ; x < size.x ; x++)
242+ for (int x = 0 ; x < size.x ; x++)
240243 {
241244 out[3 * x + 0 ] = in[4 * x + 0 ];
242245 out[3 * x + 1 ] = in[4 * x + 1 ];
@@ -249,6 +252,9 @@ namespace detail
249252 std::cout << " wrote file " << fileName << std::endl;
250253 }
251254 };
255+ #else
256+ class OsprayImpl {};
257+ #endif
252258}
253259
254260InterfaceWithOspray::InterfaceWithOspray () : GeometryGeneratingModule(staticInfo_), impl_(new detail::OsprayImpl)
@@ -260,6 +266,7 @@ InterfaceWithOspray::InterfaceWithOspray() : GeometryGeneratingModule(staticInfo
260266
261267void InterfaceWithOspray::execute ()
262268{
269+ #ifdef WITH_OSPRAY
263270 auto field = getRequiredInput (Field);
264271 auto colorMap = getOptionalInput (ColorMapObject);
265272
@@ -275,8 +282,11 @@ void InterfaceWithOspray::execute()
275282 remark (" Saving output to " + filename);
276283 impl_->writeImage (field, filename, get_state (), colorMap);
277284 get_state ()->setTransientValue (Variables::Filename, filename);
278-
285+
279286 // auto geom = builder_->buildGeometryObject(field, colorMap, *this, this);
280287 // sendOutput(SceneGraph, geom);
281288 }
289+ #else
290+ error (" Build SCIRun with WITH_OSPRAY set to true to enable this module." );
291+ #endif
282292}
0 commit comments