Skip to content

Commit cbfb4e5

Browse files
utkarshayachitkwrobot
authored andcommitted
Merge topic 'multiblock-colormap'
123a822 ENH: Add vtkBlockColors
2 parents 639e265 + 123a822 commit cbfb4e5

File tree

11 files changed

+392
-96
lines changed

11 files changed

+392
-96
lines changed

ParaViewCore/ClientServerCore/Rendering/vtkGeometryRepresentation.cxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,31 @@ void vtkGeometryRepresentation::SetupDefaults()
198198
keys->Delete();
199199
}
200200

201+
//----------------------------------------------------------------------------
202+
int vtkGeometryRepresentation::GetBlockColorsDistinctValues()
203+
{
204+
vtkPVGeometryFilter *geomFilter =
205+
vtkPVGeometryFilter::SafeDownCast(this->GeometryFilter);
206+
if (geomFilter)
207+
{
208+
return geomFilter->GetBlockColorsDistinctValues();
209+
}
210+
return 2;
211+
}
212+
213+
//----------------------------------------------------------------------------
214+
void vtkGeometryRepresentation::SetBlockColorsDistinctValues(
215+
int distinctValues)
216+
{
217+
vtkPVGeometryFilter *geomFilter =
218+
vtkPVGeometryFilter::SafeDownCast(this->GeometryFilter);
219+
if (geomFilter)
220+
{
221+
geomFilter->SetBlockColorsDistinctValues(distinctValues);
222+
this->MarkModified();
223+
}
224+
}
225+
201226
//----------------------------------------------------------------------------
202227
int vtkGeometryRepresentation::FillInputPortInformation(
203228
int vtkNotUsed(port), vtkInformation* info)

ParaViewCore/ClientServerCore/Rendering/vtkGeometryRepresentation.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkGeometryRepresentation : public v
6565
// representation of false, all view passes are ignored.
6666
virtual void SetVisibility(bool val);
6767

68+
// Description:
69+
// Determines the number of distinct values in vtkBlockColors
70+
// See also vtkPVGeometryFilter
71+
void SetBlockColorsDistinctValues(int distinctValues);
72+
int GetBlockColorsDistinctValues();
73+
6874
// Description:
6975
// Enable/Disable LOD;
7076
virtual void SetSuppressLOD(bool suppress)

ParaViewCore/ServerManager/Default/settings.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@
107107
<BooleanDomain name="bool"/>
108108
</IntVectorProperty>
109109

110+
<IntVectorProperty name="BlockColorsDistinctValues"
111+
number_of_elements="1"
112+
default_values="7"
113+
command="SetBlockColorsDistinctValues"
114+
panel_visibility="advanced">
115+
<Documentation>
116+
Determines the number of distinct values in
117+
vtkBlockColors. This array is added to each block if
118+
the dataset is a composite dataset. The array has one value
119+
set to the reminder of blockIndex divided by
120+
BlockColorsDistinctValues (blockIndex mod
121+
BlockColorsDistinctValues).
122+
</Documentation>
123+
<IntRangeDomain min="2" name="range" />
124+
</IntVectorProperty>
125+
110126
<IntVectorProperty name="TransferFunctionResetMode"
111127
number_of_elements="1"
112128
default_values="0"
@@ -290,6 +306,7 @@
290306

291307
<PropertyGroup label="Data Processing Options">
292308
<Property name="AutoConvertProperties" />
309+
<Property name="BlockColorsDistinctValues" />
293310
</PropertyGroup>
294311

295312
<PropertyGroup label="Multicore Support">

ParaViewCore/ServerManager/Default/vtkPVGeneralSettings.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ vtkPVGeneralSettings* vtkPVGeneralSettings::New()
4040

4141
//----------------------------------------------------------------------------
4242
vtkPVGeneralSettings::vtkPVGeneralSettings()
43-
: AutoApply(false),
43+
: BlockColorsDistinctValues(7),
44+
AutoApply(false),
4445
AutoApplyActiveOnly(false),
4546
DefaultViewType(NULL),
4647
TransferFunctionResetMode(vtkPVGeneralSettings::GROW_ON_APPLY),

ParaViewCore/ServerManager/Default/vtkPVGeneralSettings.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class VTKPVSERVERMANAGERDEFAULT_EXPORT vtkPVGeneralSettings : public vtkObject
4545
void SetAutoConvertProperties(bool val);
4646
bool GetAutoConvertProperties();
4747

48+
// Description:
49+
// Determines the number of distinct values in
50+
// vtkBlockColors. This array is added to each block if
51+
// the dataset is a composite dataset. The array has one value
52+
// set to (blockIndex % BlockColorsDistinctValues)
53+
vtkGetMacro(BlockColorsDistinctValues, int);
54+
vtkSetMacro(BlockColorsDistinctValues, int);
55+
4856
// Description:
4957
// Automatically apply changes in the 'Properties' panel.
5058
vtkGetMacro(AutoApply, bool);
@@ -144,7 +152,8 @@ class VTKPVSERVERMANAGERDEFAULT_EXPORT vtkPVGeneralSettings : public vtkObject
144152
protected:
145153
vtkPVGeneralSettings();
146154
~vtkPVGeneralSettings();
147-
155+
156+
int BlockColorsDistinctValues;
148157
bool AutoApply;
149158
bool AutoApplyActiveOnly;
150159
char* DefaultViewType;

ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,6 +3254,8 @@
32543254
panel_visibility="never" />
32553255
<Property name="BlockOpacity"
32563256
panel_visibility="never" />
3257+
<Property name="BlockColorsDistinctValues"
3258+
panel_visibility="advanced" />
32573259
</PropertyGroup>
32583260
</ExposedProperties>
32593261
</SubProxy>
@@ -8357,6 +8359,24 @@
83578359
Set the opacity for a block. Value is (index, alpha).
83588360
</Documentation>
83598361
</DoubleMapProperty>
8362+
<IntVectorProperty command="SetBlockColorsDistinctValues"
8363+
default_values="7"
8364+
name="BlockColorsDistinctValues"
8365+
number_of_elements="1"
8366+
panel_visibility="never">
8367+
<Documentation>
8368+
Determines the number of distinct values in
8369+
vtkBlockColors. This array is added to each block if
8370+
the dataset is a composite dataset. The array has one value
8371+
set to (blockIndex % BlockColorsDistinctValues)
8372+
</Documentation>
8373+
<IntRangeDomain min="2" name="range" />
8374+
<Hints>
8375+
<PropertyLink group="settings"
8376+
proxy="GeneralSettings"
8377+
property="BlockColorsDistinctValues"/>
8378+
</Hints>
8379+
</IntVectorProperty>
83608380
<!-- End of SurfaceRepresentationBase -->
83618381
</RepresentationProxy>
83628382

ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ vtkPVGeometryFilter::vtkPVGeometryFilter ()
146146
{
147147
this->OutlineFlag = 0;
148148
this->UseOutline = 1;
149+
this->BlockColorsDistinctValues = 7;
149150
this->UseStrips = 0;
150151
#ifdef VTKGL2
151152
// generating cell normals by default really slows down paraview
@@ -681,6 +682,20 @@ void vtkPVGeometryFilter::AddCompositeIndex(vtkPolyData* pd, unsigned int index)
681682
cindex->FastDelete();
682683
}
683684

685+
//----------------------------------------------------------------------------
686+
void vtkPVGeometryFilter::AddBlockColors(
687+
vtkPolyData* pd, unsigned int index)
688+
{
689+
vtkUnsignedIntArray* cindex = vtkUnsignedIntArray::New();
690+
cindex->SetNumberOfComponents(1);
691+
cindex->SetNumberOfTuples(1);
692+
cindex->FillComponent(0, index % this->BlockColorsDistinctValues);
693+
cindex->SetName("vtkBlockColors");
694+
pd->GetFieldData()->AddArray(cindex);
695+
cindex->FastDelete();
696+
}
697+
698+
684699
//----------------------------------------------------------------------------
685700
void vtkPVGeometryFilter::AddHierarchicalIndex(vtkPolyData* pd,
686701
unsigned int level, unsigned int index)
@@ -840,6 +855,8 @@ int vtkPVGeometryFilter::RequestAMRData(
840855

841856
this->CleanupOutputData(outputBlock.GetPointer(), /*doCommunicate=*/0);
842857
this->AddCompositeIndex(outputBlock.GetPointer(), amr->GetCompositeIndex(level,dataIdx));
858+
this->AddBlockColors(outputBlock.GetPointer(),
859+
amr->GetCompositeIndex(level,dataIdx));
843860
this->AddHierarchicalIndex(outputBlock.GetPointer(), level, dataIdx);
844861
}
845862
amrDatasets->SetPiece(block_id, outputBlock.GetPointer());
@@ -920,6 +937,7 @@ int vtkPVGeometryFilter::RequestCompositeData(vtkInformation*,
920937
tmpOut->FastDelete();
921938

922939
this->AddCompositeIndex(tmpOut, current_flat_index);
940+
this->AddBlockColors(tmpOut, current_flat_index);
923941
}
924942
else
925943
{

ParaViewCore/VTKExtensions/Rendering/vtkPVGeometryFilter.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkPVGeometryFilter : public vtkDataObj
6161
vtkSetMacro(UseOutline, int);
6262
vtkGetMacro(UseOutline, int);
6363

64+
// Description:
65+
// Determines the number of distinct values in vtkBlockColors
66+
vtkSetMacro(BlockColorsDistinctValues, int);
67+
vtkGetMacro(BlockColorsDistinctValues, int);
68+
6469
// Description:
6570
// When input is structured data, this flag will generate faces with
6671
// triangle strips. This should render faster and use less memory, but no
@@ -252,6 +257,7 @@ class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkPVGeometryFilter : public vtkDataObj
252257

253258
int OutlineFlag;
254259
int UseOutline;
260+
int BlockColorsDistinctValues;
255261
int UseStrips;
256262
int GenerateCellNormals;
257263
int Triangulate;
@@ -306,6 +312,12 @@ class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkPVGeometryFilter : public vtkDataObj
306312
void operator=(const vtkPVGeometryFilter&); // Not implemented
307313

308314
void AddCompositeIndex(vtkPolyData* pd, unsigned int index);
315+
// Description:
316+
// Adds a field array called "vtkBlockColors". The array is
317+
// added to each block only if the dataset is a composite
318+
// dataset. The array has one value set to
319+
// (blockIndex % BlockColorsDistinctValues)
320+
void AddBlockColors(vtkPolyData* pd, unsigned int index);
309321
void AddHierarchicalIndex(vtkPolyData* pd, unsigned int level, unsigned int index);
310322
class BoundsReductionOperation;
311323
//ETX

0 commit comments

Comments
 (0)