Commit 08602b1b authored by Alvaro Sanchez's avatar Alvaro Sanchez Committed by Kitware Robot

Merge topic 'model-rep-rendering-improvements'

baf39424 Improve SMTKModelRepresentation rendering.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !927
parents bff43ee9 baf39424
......@@ -28,6 +28,7 @@ add_paraview_plugin(
target_link_libraries(smtkRepresentationPlugin
LINK_PUBLIC
smtkCore
vtkSMTKSourceExt
)
smtk_export_header(smtkRepresentationPlugin Exports.h)
......@@ -24,6 +24,7 @@
#include <vtkPVRenderView.h>
#include <vtkPVTrivialProducer.h>
#include "smtk/extension/vtk/source/vtkModelMultiBlockSource.h"
#include "vtkSMTKModelRepresentation.h"
vtkStandardNewMacro(vtkSMTKModelRepresentation);
......@@ -71,7 +72,7 @@ int vtkSMTKModelRepresentation::RequestData(
// Glyph points (2) and prototypes (1)
this->GlyphMapper->SetInputConnection(this->GetInternalOutputPort(2));
this->GlyphMapper->SetInputConnection(1, this->GetInternalOutputPort(1));
this->GlyphMapper->SetUseSourceTableTree(true);
this->ConfigureGlyphMapper(this->GlyphMapper.GetPointer());
}
this->CacheKeeper->Update();
......@@ -239,3 +240,33 @@ int vtkSMTKModelRepresentation::FillInputPortInformation(int port, vtkInformatio
return 0;
}
void vtkSMTKModelRepresentation::ConfigureGlyphMapper(vtkGlyph3DMapper* mapper)
{
mapper->SetUseSourceTableTree(true);
mapper->SetSourceIndexArray(VTK_INSTANCE_SOURCE);
mapper->SetSourceIndexing(true);
mapper->SetScaleArray(VTK_INSTANCE_SCALE);
mapper->SetScaling(true);
mapper->SetOrientationArray(VTK_INSTANCE_ORIENTATION);
mapper->SetOrientationMode(vtkGlyph3DMapper::ROTATION);
mapper->SetMaskArray(VTK_INSTANCE_VISIBILITY);
mapper->SetMasking(true);
}
void vtkSMTKModelRepresentation::SetMapScalars(int val)
{
if (val < 0 || val > 1)
{
vtkWarningMacro(<< "Invalid parameter for vtkSMTKModelRepresentation::SetMapScalars: " << val);
val = 0;
}
int mapToColorMode[] = { VTK_COLOR_MODE_DIRECT_SCALARS, VTK_COLOR_MODE_MAP_SCALARS };
this->EntityMapper->SetColorMode(mapToColorMode[val]);
this->GlyphMapper->SetColorMode(mapToColorMode[val]);
}
......@@ -37,15 +37,23 @@ public:
vtkTypeMacro(vtkSMTKModelRepresentation, vtkGeometryRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@{
/**
* \sa vtkPVDataRepresentation
*/
int ProcessViewRequest(vtkInformationRequestKey* request_type, vtkInformation* inInfo,
vtkInformation* outInfo) override;
int RequestData(
vtkInformation* info, vtkInformationVector** inVec, vtkInformationVector* outVec) override;
bool AddToView(vtkView* view) override;
bool RemoveFromView(vtkView* view) override;
void SetVisibility(bool val) override;
//@}
/**
* \sa vtkGeometryRepresentation
*/
void SetMapScalars(int val) override;
protected:
vtkSMTKModelRepresentation();
......@@ -54,6 +62,7 @@ protected:
int FillInputPortInformation(int port, vtkInformation* info) override;
void SetupDefaults() override;
void SetOutputExtent(vtkAlgorithmOutput* output, vtkInformation* inInfo);
void ConfigureGlyphMapper(vtkGlyph3DMapper* mapper);
vtkSmartPointer<vtkCompositePolyDataMapper2> EntityMapper;
vtkSmartPointer<vtkCompositePolyDataMapper2> SelectedEntityMapper;
......
......@@ -648,10 +648,10 @@ void vtkModelMultiBlockSource::PrepareInstanceOutput(vtkMultiBlockDataSet* insta
vtkNew<vtkIdTypeArray> instancePrototype; // block ID of prototype object
vtkNew<vtkUnsignedCharArray> instanceMask; // visibility control
instanceOrient->SetName("instance orientation");
instanceScale->SetName("instance scale");
instancePrototype->SetName("instance source");
instanceMask->SetName("instance visibility");
instanceOrient->SetName(VTK_INSTANCE_ORIENTATION);
instanceScale->SetName(VTK_INSTANCE_SCALE);
instancePrototype->SetName(VTK_INSTANCE_SOURCE);
instanceMask->SetName(VTK_INSTANCE_VISIBILITY);
instanceOrient->SetNumberOfComponents(3);
instanceScale->SetNumberOfComponents(3);
......
......@@ -22,6 +22,11 @@
#include <map>
#define VTK_INSTANCE_ORIENTATION "instance orientation"
#define VTK_INSTANCE_SCALE "instance scale"
#define VTK_INSTANCE_SOURCE "instance source"
#define VTK_INSTANCE_VISIBILITY "instance visibility"
class vtkPolyData;
class vtkPolyDataNormals;
class vtkInformationStringKey;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment