vtkGeometryRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
16 #ifndef vtkGeometryRepresentation_h
17 #define vtkGeometryRepresentation_h
18 
20 #include "vtkParaViewDeprecation.h" // for PV_DEPRECATED
21 #include "vtkProperty.h" // needed for VTK_POINTS etc.
22 #include "vtkRemotingViewsModule.h" // needed for exports
23 #include "vtkVector.h" // for vtkVector.
24 
25 #include <set> // needed for std::set
26 #include <string> // needed for std::string
27 #include <unordered_map> // needed for std::unordered_map
28 #include <vector> // needed for std::vector
29 
31 class vtkMapper;
34 class vtkPVLODActor;
35 class vtkScalarsToColors;
36 class vtkTexture;
37 class vtkTransform;
38 
40 {
41 // This is defined to either vtkQuadricClustering or vtkmLevelOfDetail in the
42 // implementation file:
44 }
45 
47 {
48 
49 public:
50  static vtkGeometryRepresentation* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
60  int ProcessViewRequest(vtkInformationRequestKey* request_type, vtkInformation* inInfo,
61  vtkInformation* outInfo) override;
62 
67  void SetVisibility(bool val) override;
68 
70 
74  void SetBlockColorsDistinctValues(int distinctValues);
75  int GetBlockColorsDistinctValues();
77 
81  virtual void SetSuppressLOD(bool suppress) { this->SuppressLOD = suppress; }
82 
84 
89  vtkBooleanMacro(DisableLighting, bool);
90  vtkSetMacro(DisableLighting, bool);
91  vtkGetMacro(DisableLighting, bool);
94 
101  vtkSetMacro(Ambient, double);
102  vtkSetMacro(Diffuse, double);
103  vtkSetMacro(Specular, double);
104  vtkGetMacro(Ambient, double);
105  vtkGetMacro(Diffuse, double);
106  vtkGetMacro(Specular, double);
108 
110  {
111  POINTS = VTK_POINTS,
112  WIREFRAME = VTK_WIREFRAME,
113  SURFACE = VTK_SURFACE,
114  SURFACE_WITH_EDGES = 3
115  };
116 
118 
122  void SetCoordinateShiftScaleMethod(int val);
123  int GetCoordinateShiftScaleMethod();
125 
127 
131  vtkSetClampMacro(Representation, int, POINTS, SURFACE_WITH_EDGES);
132  vtkGetMacro(Representation, int);
134 
139  virtual void SetRepresentation(const char*);
140 
144  vtkDataObject* GetRenderedDataObject(int port) override;
145 
147 
152  vtkSetMacro(RequestGhostCellsIfNeeded, bool);
153  vtkGetMacro(RequestGhostCellsIfNeeded, bool);
154  vtkBooleanMacro(RequestGhostCellsIfNeeded, bool);
156 
161  virtual void SetNormalArray(const char* val);
162 
167  virtual void SetTCoordArray(const char* val);
168 
173  virtual void SetTangentArray(const char* val);
174 
175  //***************************************************************************
176  // Forwarded to vtkPVGeometryFilter
177  virtual void SetUseOutline(int);
178  void SetTriangulate(int);
179  void SetNonlinearSubdivisionLevel(int);
180  void SetMatchBoundariesIgnoringCellOrder(int);
181  virtual void SetGenerateFeatureEdges(bool);
182 
183  //***************************************************************************
184  // Forwarded to vtkProperty.
185  virtual void SetAmbientColor(double r, double g, double b);
186  virtual void SetColor(double r, double g, double b);
187  virtual void SetDiffuseColor(double r, double g, double b);
188  virtual void SetLighting(bool lighting);
189  virtual void SetEdgeColor(double r, double g, double b);
190  virtual void SetInteractiveSelectionColor(double r, double g, double b);
191  virtual void SetInterpolation(int val);
192  virtual void SetLineWidth(double val);
193  virtual void SetOpacity(double val);
194  virtual void SetEdgeOpacity(double val);
195  virtual void SetPointSize(double val);
196  virtual void SetSpecularColor(double r, double g, double b);
197  virtual void SetSpecularPower(double val);
198  virtual void SetLuminosity(double val);
199  virtual void SetRenderPointsAsSpheres(bool);
200  virtual void SetRenderLinesAsTubes(bool);
201  virtual void SetRoughness(double val);
202  virtual void SetMetallic(double val);
203  virtual void SetEdgeTint(double r, double g, double b);
204  virtual void SetAnisotropy(double val);
205  virtual void SetAnisotropyRotation(double val);
206  virtual void SetBaseIOR(double val);
207  virtual void SetCoatIOR(double val);
208  virtual void SetCoatStrength(double val);
209  virtual void SetCoatRoughness(double val);
210  virtual void SetCoatNormalScale(double val);
211  virtual void SetCoatColor(double r, double g, double b);
212  virtual void SetBaseColorTexture(vtkTexture* tex);
213  virtual void SetMaterialTexture(vtkTexture* tex);
214  virtual void SetAnisotropyTexture(vtkTexture* tex);
215  virtual void SetNormalTexture(vtkTexture* tex);
216  virtual void SetCoatNormalTexture(vtkTexture* tex);
217  virtual void SetEmissiveTexture(vtkTexture* tex);
218  virtual void SetNormalScale(double val);
219  virtual void SetOcclusionStrength(double val);
220  virtual void SetEmissiveFactor(double rval, double gval, double bval);
221  virtual void SetShowTexturesOnBackface(bool);
222 
223  //***************************************************************************
224  // Forwarded to Actor.
225  virtual void SetOrientation(double, double, double);
226  virtual void SetOrigin(double, double, double);
227  virtual void SetPickable(int val);
228  virtual void SetPosition(double, double, double);
229  virtual void SetScale(double, double, double);
230  virtual void SetTexture(vtkTexture*);
231  virtual void SetUserTransform(const double[16]);
232  PARAVIEW_DEPRECATED_IN_5_13_0("Use SetTextureTransform instead")
233  virtual void SetFlipTextures(bool);
234 
235  //***************************************************************************
236  // Forwarded to all textures
237  virtual void SetTextureTransform(vtkTransform*);
238  vtkGetObjectMacro(TextureTransform, vtkTransform);
239  virtual void SetRepeatTextures(bool);
240  vtkGetMacro(RepeatTextures, bool);
241  virtual void SetInterpolateTextures(bool);
242  vtkGetMacro(InterpolateTextures, bool);
243  virtual void SetUseMipmapTextures(bool);
244  vtkGetMacro(UseMipmapTextures, bool);
245 
246  //***************************************************************************
247  // Forwarded to Mapper and LODMapper.
248  virtual void SetInterpolateScalarsBeforeMapping(int val);
249  virtual void SetLookupTable(vtkScalarsToColors* val);
250  virtual void SetColorMissingArraysWithNanColor(bool val);
251  virtual void SetSeamlessU(bool);
252  virtual void SetSeamlessV(bool);
254 
261  virtual void SetMapScalars(int val);
262  virtual void SetStatic(int val);
264 
268  virtual void SetSelection(vtkSelection* selection);
269 
273  vtkPVLODActor* GetActor() { return this->GetRenderedProp(); }
274 
276 
282  vtkSetStringMacro(ActiveAssembly);
283  vtkGetStringMacro(ActiveAssembly);
285 
287 
290  void AddBlockSelector(const char* selector);
291  void RemoveAllBlockSelectors();
293 
295 
298  void SetBlockColor(const char* selector, double r, double g, double b);
299  void RemoveAllBlockColors();
301 
303 
306  void SetBlockOpacity(const char* selector, double opacity);
307  void RemoveAllBlockOpacities();
309 
311 
314  void SetBlockInterpolateScalarsBeforeMapping(const char* selector, bool interpolate);
315  void RemoveAllBlockInterpolateScalarsBeforeMappings();
317 
319 
324  void SetBlockMapScalars(const char* selector, int val);
325  void RemoveAllBlockMapScalars();
327 
329 
332  void SetBlockArrayName(const char* selector, int assoc, const char* arrayName);
333  void RemoveAllBlockArrayNames();
335 
337 
343  void SetBlockLookupTableSelector(const char* selector);
344  void RemoveAllBlockLookupTableSelectors();
345  void SetBlockLookupTable(vtkScalarsToColors* lut);
346  void RemoveAllBlockLookupTables();
348 
352  const char* GetColorArrayName();
353 
361  static bool GetBounds(
362  vtkDataObject* dataObject, double bounds[6], vtkCompositeDataDisplayAttributes* cdAttributes);
363 
365 
369  virtual void SetEnableScaling(int v);
370  virtual void SetScalingArrayName(const char*);
371  virtual void SetScalingFunction(vtkPiecewiseFunction* pwf);
373 
377  virtual void SetMaterial(const char*);
378 
380 
386  vtkSetMacro(UseDataPartitions, bool);
387  vtkGetMacro(UseDataPartitions, bool);
389 
391 
394  virtual void SetUseShaderReplacements(bool);
395  vtkGetMacro(UseShaderReplacements, bool);
397 
403  virtual void SetShaderReplacements(const char*);
404 
409  void SetArrayIdNames(const char* pointArray, const char* cellArray) override;
410 
412 
424  vtkSetMacro(PlaceHolderDataType, int);
425  vtkGetMacro(PlaceHolderDataType, int);
427 
428 protected:
430  ~vtkGeometryRepresentation() override;
431 
438  virtual void SetupDefaults();
439 
443  int FillInputPortInformation(int port, vtkInformation* info) override;
444 
455  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
456 
460  int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
461  vtkInformationVector* outputVector) override;
462 
468  bool AddToView(vtkView* view) override;
469 
475  bool RemoveFromView(vtkView* view) override;
476 
480  virtual void UpdateColoringParameters();
481 
485  virtual vtkPVLODActor* GetRenderedProp() { return this->Actor; }
486 
487  // Progress Callback
488  void HandleGeometryRepresentationProgress(vtkObject* caller, unsigned long, void*);
489 
497  void PopulateBlockAttributes(vtkCompositeDataDisplayAttributes* attrs, vtkDataObject* outputData);
498 
503  void ComputeVisibleDataBounds();
504 
508  void UpdateShaderReplacements();
509 
516  virtual bool NeedsOrderedCompositing();
517 
521  virtual void SetPointArrayToProcess(int p, const char* val);
522 
526  void UpdateGeneralTextureTransform();
527 
532 
537 
538  char* ActiveAssembly = nullptr;
543  double Ambient;
544  double Specular;
545  double Diffuse;
549  double VisibleDataBounds[6];
550 
552 
554 
556 
559 
560  bool BlockAttrChanged = false;
562  bool UpdateBlockAttrLOD = false;
563 
564  // This is used to be able to create the correct placeHolder in RequestData for the client
565  int PlaceHolderDataType = VTK_PARTITIONED_DATA_SET_COLLECTION;
566 
567  // These block variables are similar to the ones in vtkCompositeDataDisplayAttributes
568  // Some of them are exposed and some others are not because, as of now, they are not needed.
569 
571 
574  std::set<std::string> BlockSelectors;
575  std::unordered_map<std::string, vtkVector3d> BlockColors;
576  std::unordered_map<std::string, double> BlockOpacities;
577  std::unordered_map<std::string, bool> BlockInterpolateScalarsBeforeMapping;
578  std::unordered_map<std::string, int> BlockColorModes;
579  std::unordered_map<std::string, std::pair<int /*assoc*/, std::string>> BlockArrayNames;
580  std::vector<std::string> BlockLookupTableSelectors;
581  std::vector<vtkScalarsToColors*> BlockLookupTables;
584 
587  std::unordered_map<std::string, bool> BlockScalarVisibilities;
588  std::unordered_map<std::string, bool> BlockUseLookupTableScalarRanges;
589  std::unordered_map<vtkDataObject*, vtkIdType> BlockFieldDataTupleIds;
591 private:
592  bool DisableLighting = false;
594  void operator=(const vtkGeometryRepresentation&) = delete;
595 };
596 
597 #endif
vtkGeometryRepresentation_detail::DecimationFilterType * Decimator
std::unordered_map< std::string, vtkVector3d > BlockColors
Configurable through vtkGeometryRepresentation API.
virtual vtkPVLODActor * GetRenderedProp()
Used in ConvertSelection to locate the prop used for actual rendering.
#define VTKREMOTINGVIEWS_EXPORT
std::unordered_map< std::string, bool > BlockUseLookupTableScalarRanges
Configured internally in vtkGeometryRepresentation.
vtkPVDataRepresentation adds some ParaView specific API to data representations.
#define VTK_SURFACE
std::unordered_map< std::string, double > BlockOpacities
Configurable through vtkGeometryRepresentation API.
std::unordered_map< std::string, bool > BlockScalarVisibilities
Configured internally in vtkGeometryRepresentation.
std::unordered_map< std::string, int > BlockColorModes
Configurable through vtkGeometryRepresentation API.
info
Geometry filter that does outlines for volumes.
std::unordered_map< std::string, bool > BlockInterpolateScalarsBeforeMapping
Configurable through vtkGeometryRepresentation API.
representation for showing any datasets as external shell of polygons.
#define PARAVIEW_DEPRECATED_IN_5_13_0(reason)
std::vector< std::string > BlockLookupTableSelectors
Configurable through vtkGeometryRepresentation API.
vtkPVGeometryFilter * LODOutlineFilter
std::set< std::string > BlockSelectors
Configurable through vtkGeometryRepresentation API.
#define VTK_POINTS
std::vector< vtkScalarsToColors * > BlockLookupTables
Configurable through vtkGeometryRepresentation API.
an actor that supports multiple levels of detail
Definition: vtkPVLODActor.h:25
std::unordered_map< vtkDataObject *, vtkIdType > BlockFieldDataTupleIds
Configured internally in vtkGeometryRepresentation.
port
std::unordered_map< std::string, std::pair< int, std::string > > BlockArrayNames
Configurable through vtkGeometryRepresentation API.
#define VTK_WIREFRAME
virtual void SetSuppressLOD(bool suppress)
Enable/Disable LOD;.