ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
TextureRendererBase.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <vtkSmartPointer.h>
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 class vtkActor;
17 class vtkLODActor;
18 class vtkPolyData;
19 class vtkRenderer;
20 class vtkRenderWindow;
21 
22 // Forward declarations
23 class ccMaterialSet;
24 class ccMaterial;
25 
26 namespace PclUtils {
27 namespace renders {
28 
29 // Forward declarations
30 class MaterialConverter;
31 
35 enum class RenderingMode {
36  PBR, // Physically Based Rendering (VTK 9+)
37  MULTI_TEXTURE, // Traditional multi-texture rendering
38  MATERIAL_ONLY // Material properties only, no textures
39 };
40 
49 public:
50  TextureRendererBase() = default;
51  virtual ~TextureRendererBase() = default;
52 
60  virtual bool CanHandle(size_t material_count,
61  bool has_pbr_textures,
62  bool has_multiple_map_kd) const = 0;
63 
67  virtual RenderingMode GetMode() const = 0;
68 
77  virtual bool Apply(vtkLODActor* actor,
78  const class ccMaterialSet* materials,
79  vtkPolyData* polydata,
80  vtkRenderer* renderer) = 0;
81 
90  virtual bool Update(vtkActor* actor,
91  const class ccMaterialSet* materials,
92  vtkPolyData* polydata,
93  vtkRenderer* renderer) = 0;
94 
98  virtual std::string GetName() const = 0;
99 
100 protected:
104  void ClearTextures(vtkActor* actor);
105 
109  bool ValidateActor(vtkActor* actor) const;
110 
114  bool ValidateMaterials(const class ccMaterialSet* materials) const;
115 };
116 
117 } // namespace renders
118 } // namespace PclUtils
Base class for all texture renderers.
virtual RenderingMode GetMode() const =0
Get the rendering mode this renderer implements.
void ClearTextures(vtkActor *actor)
Helper: Clear all textures from actor.
bool ValidateActor(vtkActor *actor) const
Helper: Validate actor.
virtual bool Apply(vtkLODActor *actor, const class ccMaterialSet *materials, vtkPolyData *polydata, vtkRenderer *renderer)=0
Apply rendering to actor.
virtual bool Update(vtkActor *actor, const class ccMaterialSet *materials, vtkPolyData *polydata, vtkRenderer *renderer)=0
Update existing actor with new materials.
virtual std::string GetName() const =0
Get renderer name for logging.
virtual bool CanHandle(size_t material_count, bool has_pbr_textures, bool has_multiple_map_kd) const =0
Check if this renderer can handle the given material.
bool ValidateMaterials(const class ccMaterialSet *materials) const
Helper: Validate materials.
Mesh (triangle) material.
Mesh (triangle) material.
Definition: ecvMaterial.h:28
RenderingMode
Rendering mode enumeration.