@@ -55,7 +55,7 @@ using namespace SCIRun;
5555
5656ModuleLookupInfo ShowFieldModule::staticInfo_ (" ShowField" , " Visualization" , " SCIRun" );
5757
58- ShowFieldModule::ShowFieldModule () :
58+ ShowFieldModule::ShowFieldModule () :
5959 Module(staticInfo_)
6060{
6161 INITIALIZE_PORT (Field);
@@ -91,8 +91,11 @@ void ShowFieldModule::execute()
9191{
9292 boost::shared_ptr<SCIRun::Field> field = getRequiredInput (Field);
9393 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap = getOptionalInput (ColorMapObject);
94- GeometryHandle geom = buildGeometryObject (field, colorMap, get_state (), get_id ());
95- sendOutput (SceneGraph, geom);
94+ if (needToExecute ())
95+ {
96+ GeometryHandle geom = buildGeometryObject (field, colorMap, get_state (), get_id ());
97+ sendOutput (SceneGraph, geom);
98+ }
9699}
97100
98101RenderState ShowFieldModule::getNodeRenderState (
@@ -105,9 +108,9 @@ RenderState ShowFieldModule::getNodeRenderState(
105108 renState.set (RenderState::USE_TRANSPARENCY, state->getValue (ShowFieldModule::NodeTransparency).toBool ());
106109
107110 renState.set (RenderState::USE_SPHERE, state->getValue (ShowFieldModule::NodeAsSpheres).toBool ());
108-
111+
109112 renState.defaultColor = ColorRGB (state->getValue (ShowFieldModule::DefaultMeshColor).toString ());
110-
113+
111114 sphereScalar_ = state->getValue (ShowFieldModule::SphereScaleValue).toDouble ();
112115
113116 if (colorMap)
@@ -178,7 +181,7 @@ RenderState ShowFieldModule::getFaceRenderState(
178181GeometryHandle ShowFieldModule::buildGeometryObject (
179182 boost::shared_ptr<SCIRun::Field> field,
180183 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap,
181- ModuleStateHandle state,
184+ ModuleStateHandle state,
182185 const std::string& id)
183186{
184187 // Function for reporting progress.
@@ -273,12 +276,12 @@ void ShowFieldModule::applyColorMapScaling(
273276 {
274277 std::cerr << " Input field is not a scalar or vector field." << std::endl;
275278 return ;
276- }
279+ }
277280
278281 pass.addUniform (" uMinVal" , minv);
279282 pass.addUniform (" uMaxVal" , maxv);
280283
281- // if ( gui_make_symmetric_.get() )
284+ // if ( gui_make_symmetric_.get() )
282285 // {
283286 // float biggest = Max(Abs(minmax_.first), Abs(minmax_.second));
284287 // minmax_.first = -biggest;
@@ -289,7 +292,7 @@ void ShowFieldModule::applyColorMapScaling(
289292void ShowFieldModule::renderFaces (
290293 boost::shared_ptr<SCIRun::Field> field,
291294 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap,
292- RenderState state, Core::Datatypes::GeometryHandle geom,
295+ RenderState state, Core::Datatypes::GeometryHandle geom,
293296 unsigned int approxDiv,
294297 const std::string& id)
295298{
@@ -320,7 +323,7 @@ void ShowFieldModule::renderFacesLinear(
320323 boost::shared_ptr<SCIRun::Field> field,
321324 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap,
322325 RenderState state,
323- Core::Datatypes::GeometryHandle geom,
326+ Core::Datatypes::GeometryHandle geom,
324327 unsigned int approxDiv,
325328 const std::string& id)
326329{
@@ -401,11 +404,11 @@ void ShowFieldModule::renderFacesLinear(
401404
402405 uint32_t iboIndex = 0 ;
403406 int64_t numVBOElements = 0 ;
404-
405- while (fiter != fiterEnd)
407+
408+ while (fiter != fiterEnd)
406409 {
407410 mesh->get_nodes (nodes, *fiter);
408-
411+
409412 std::vector<Core::Geometry::Point> points (nodes.size ());
410413 std::vector<Core::Geometry::Vector> normals (nodes.size ());
411414
@@ -417,7 +420,7 @@ void ShowFieldModule::renderFacesLinear(
417420 }
418421
419422 // TODO fix so the withNormals tp be woth lighting is called correctly, and the meshes are fixed.
420- if (withNormals)
423+ if (withNormals)
421424 {
422425 if (points.size () == 4 )
423426 {
@@ -427,7 +430,7 @@ void ShowFieldModule::renderFacesLinear(
427430 Core::Geometry::Vector edge4 = points[0 ] - points[3 ];
428431
429432 Core::Geometry::Vector norm = Cross (edge1, edge2) + Cross (edge2, edge3) + Cross (edge3, edge4) + Cross (edge4, edge1);
430-
433+
431434 norm.normalize ();
432435
433436 for (size_t i = 0 ; i < nodes.size (); i++)
@@ -455,7 +458,7 @@ void ShowFieldModule::renderFacesLinear(
455458 */
456459 }
457460 }
458-
461+
459462 // Default color single face no matter the element data.
460463 if (colorScheme == GeometryObject::COLOR_UNIFORM)
461464 {
@@ -467,11 +470,11 @@ void ShowFieldModule::renderFacesLinear(
467470 {
468471 VMesh::Elem::array_type cells;
469472 mesh->get_elems (cells, *fiter);
470-
473+
471474 if (fld->is_scalar ())
472475 {
473476 fld->get_value (svals[0 ], cells[0 ]);
474-
477+
475478 if (cells.size () > 1 )
476479 {
477480 fld->get_value (svals[1 ], cells[1 ]);
@@ -480,14 +483,14 @@ void ShowFieldModule::renderFacesLinear(
480483 {
481484 svals[1 ] = svals[0 ];
482485 }
483-
486+
484487 valueToColor ( colorScheme, svals[0 ], scols[0 ], vcols[0 ] );
485488 valueToColor ( colorScheme, svals[1 ], scols[1 ], vcols[1 ] );
486489 }
487490 else if (fld->is_vector ())
488491 {
489492 fld->get_value (vvals[0 ], cells[0 ]);
490-
493+
491494 if (cells.size () > 1 )
492495 {
493496 fld->get_value (vvals[1 ], cells[1 ]);
@@ -496,14 +499,14 @@ void ShowFieldModule::renderFacesLinear(
496499 {
497500 svals[1 ] = svals[0 ];
498501 }
499-
502+
500503 valueToColor ( colorScheme, vvals[0 ], scols[0 ], vcols[0 ] );
501504 valueToColor ( colorScheme, vvals[1 ], scols[1 ], vcols[1 ] );
502505 }
503506 else if (fld->is_tensor ())
504507 {
505508 fld->get_value (tvals[0 ], cells[0 ]);
506-
509+
507510 if (cells.size () > 1 )
508511 {
509512 fld->get_value (tvals[1 ], cells[1 ]);
@@ -512,7 +515,7 @@ void ShowFieldModule::renderFacesLinear(
512515 {
513516 svals[1 ] = svals[0 ];
514517 }
515-
518+
516519 valueToColor ( colorScheme, tvals[0 ], scols[0 ], vcols[0 ] );
517520 valueToColor ( colorScheme, tvals[1 ], scols[1 ], vcols[1 ] );
518521 }
@@ -547,7 +550,7 @@ void ShowFieldModule::renderFacesLinear(
547550 scols[i] = scols[0 ];
548551 vcols[i] = vcols[0 ];
549552 }
550-
553+
551554 addFaceGeom (points, normals, withNormals, iboIndex, iboBuffer, vboBuffer,
552555 colorScheme, scols, vcols, state);
553556 }
@@ -570,7 +573,7 @@ void ShowFieldModule::renderFacesLinear(
570573 fld->get_value (vvals[i], nodes[i]);
571574 valueToColor ( colorScheme, vvals[i], scols[i], vcols[i] );
572575 }
573- }
576+ }
574577 else if (fld->is_tensor ())
575578 {
576579 for (size_t i=0 ; i<nodes.size (); i++)
@@ -579,15 +582,15 @@ void ShowFieldModule::renderFacesLinear(
579582 valueToColor ( colorScheme, tvals[i], scols[i], vcols[i] );
580583 }
581584 }
582-
585+
583586 addFaceGeom (points, normals, withNormals, iboIndex, iboBuffer, vboBuffer,
584587 colorScheme, scols, vcols, state);
585588 }
586589
587590 ++fiter;
588591 ++numVBOElements;
589592 }
590-
593+
591594 std::string uniqueNodeID = id + " face" ;
592595 std::string vboName = uniqueNodeID + " VBO" ;
593596 std::string iboName = uniqueNodeID + " IBO" ;
@@ -890,7 +893,7 @@ void ShowFieldModule::addFaceGeom(
890893 }
891894 }
892895 iboIndex += points.size ();
893- }
896+ }
894897 }
895898 else if (colorScheme == GeometryObject::COLOR_MAP)
896899 {
@@ -1106,7 +1109,7 @@ void ShowFieldModule::renderNodes(
11061109 boost::shared_ptr<SCIRun::Field> field,
11071110 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap,
11081111 RenderState state,
1109- Core::Datatypes::GeometryHandle geom,
1112+ Core::Datatypes::GeometryHandle geom,
11101113 const std::string& id)
11111114{
11121115 VField* fld = field->vfield ();
@@ -1365,7 +1368,7 @@ void ShowFieldModule::renderEdges(
13651368 boost::shared_ptr<SCIRun::Field> field,
13661369 boost::optional<boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap>> colorMap,
13671370 RenderState state,
1368- Core::Datatypes::GeometryHandle geom,
1371+ Core::Datatypes::GeometryHandle geom,
13691372 const std::string& id)
13701373{
13711374 // / \todo Cylinder edge rendering.
@@ -1458,10 +1461,10 @@ void ShowFieldModule::renderEdges(
14581461 else // if (mesh->dimensionality() == 1)
14591462 {
14601463 fld->get_value (sval0, *eiter);
1461-
1464+
14621465 sval1 = sval0;
14631466 }
1464-
1467+
14651468 valueToColor (colorScheme, sval0, scol0, vcol0);
14661469 valueToColor (colorScheme, sval1, scol1, vcol1);
14671470 }
@@ -1493,7 +1496,7 @@ void ShowFieldModule::renderEdges(
14931496 fld->get_value (tval0, *eiter);
14941497 tval1 = tval0;
14951498 }
1496-
1499+
14971500 valueToColor (colorScheme, tval0, scol0, vcol0);
14981501 valueToColor (colorScheme, tval1, scol1, vcol1);
14991502 }
@@ -1613,7 +1616,7 @@ void ShowFieldModule::renderEdges(
16131616 uniforms.push_back (GeometryObject::SpireSubPass::Uniform (" uSpecularColor" ,
16141617 glm::vec4 (1 .0f , 1 .0f , 1 .0f , 1 .0f )));
16151618 uniforms.push_back (GeometryObject::SpireSubPass::Uniform (" uSpecularPower" , 32 .0f ));
1616-
1619+
16171620 if (state.get (RenderState::USE_TRANSPARENCY))
16181621 {
16191622 uniforms.push_back (GeometryObject::SpireSubPass::Uniform (
@@ -1705,6 +1708,3 @@ AlgorithmParameterName ShowFieldModule::EdgesAsCylinders("EdgesAsCylinders");
17051708AlgorithmParameterName ShowFieldModule::DefaultMeshColor (" DefaultMeshColor" );
17061709AlgorithmParameterName ShowFieldModule::FaceTransparencyValue (" FaceTransparencyValue" );
17071710AlgorithmParameterName ShowFieldModule::SphereScaleValue (" SphereScaleValue" );
1708-
1709-
1710-
0 commit comments