ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
material.cpp
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 #if defined(_MSC_VER)
9 #pragma warning(push)
10 #pragma warning(disable : 4789)
11 #endif
12 
14 
17 
19  std::unordered_map<std::string, cloudViewer::t::geometry::Image>)
20 PYBIND11_MAKE_OPAQUE(std::unordered_map<std::string, float>)
21 // NOTE: The following line triggers buffer overflow warnings on Windows which
22 // is why warning 4789 is disabled when building on Windows
25 
26 namespace cloudViewer {
27 namespace visualization {
28 namespace rendering {
29 
30 void pybind_material(py::module& m) {
31  py::bind_map<std::unordered_map<std::string, t::geometry::Image>>(
32  m, "TextureMaps");
33  py::bind_map<std::unordered_map<std::string, float>>(m, "ScalarProperties");
34  py::bind_map<Material::VectorPropertyMap>(m, "VectorProperties");
35  py::class_<Material, std::shared_ptr<Material>> mat(
36  m, "Material",
37  "Properties (texture maps, scalar and vector) related to "
38  "visualization. Materials are optionally set for 3D geometries "
39  "such as TriangleMesh, LineSets, and PointClouds");
40  mat.def(py::init<>())
41  .def(py::init<Material>(), "", "mat"_a)
42  .def(py::init<const std::string&>(), "", "material_name"_a)
43  .def(py::init(&Material::FromMaterialRecord), "material_record"_a,
44  "Convert from MaterialRecord.")
45  .def("__repr__", &Material::ToString)
46  .def("set_default_properties", &Material::SetDefaultProperties,
47  "Fills material with defaults for common PBR material "
48  "properties used by CloudViewer")
49  .def("is_valid", &Material::IsValid,
50  "Returns false if material is an empty material")
51  .def_property("material_name", &Material::GetMaterialName,
53  .def_property_readonly("texture_maps", &Material::GetTextureMaps)
54  .def_property_readonly("scalar_properties",
56  .def_property_readonly("vector_properties",
58 }
59 
60 } // namespace rendering
61 } // namespace visualization
62 } // namespace cloudViewer
63 
64 #if defined(_MSC_VER)
65 #pragma warning(pop)
66 #endif
void SetMaterialName(const std::string &material_name)
Set material name. The material name should match the name of a built.
Definition: Material.h:130
const std::string & GetMaterialName() const
Get the name of the material.
Definition: Material.h:57
std::string ToString() const
String reprentation for printing.
Definition: Material.cpp:43
const VectorPropertyMap & GetVectorProperties() const
Returns the map of vector properties.
Definition: Material.h:87
const ScalarPropertyMap & GetScalarProperties() const
Returns the map of scalar properties.
Definition: Material.h:74
static Material FromMaterialRecord(const MaterialRecord &mat)
Convert from MaterialRecord.
Definition: Material.cpp:149
std::unordered_map< std::string, Eigen::Vector4f, std::hash< std::string >, std::equal_to< std::string >, Eigen::aligned_allocator< std::pair< const std::string, Eigen::Vector4f > >> VectorPropertyMap
Definition: Material.h:32
const TextureMaps & GetTextureMaps() const
Returns the texture map map.
Definition: Material.h:63
PYBIND11_MAKE_OPAQUE(std::vector< char >)
Generic file read and write utility for python interface.