DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
AdjPairTracked_bind.hpp
Go to the documentation of this file.
1#pragma once
2/// @file AdjPairTracked_bind.hpp
3/// @brief pybind11 bindings for AdjPairTracked<TPair> and AdjIndexInfo.
4///
5/// AdjPairTracked<TPair> inherits from TPair, so its pybind11 class is
6/// declared as a subclass of the already-registered ArrayAdjacencyPair
7/// type. The three instantiations needed are:
8/// AdjPairTracked<tAdjPair> (NonUniformSize)
9/// AdjPairTracked<tAdj2Pair> (row_size=2)
10/// AdjPairTracked<tAdj1Pair> (row_size=1)
11
12#include "AdjIndexInfo.hpp"
14
15namespace DNDS::Geom
16{
17 // ================================================================
18 // Name helpers (follow ArrayAdjacency_bind.hpp pattern)
19 // ================================================================
20
21 template <rowsize _row_size, rowsize _row_max = _row_size, rowsize _align = NoAlign>
23 {
24 return "AdjPairTracked" + pybind11_ArrayAdjacency_name_appends<_row_size, _row_max, _align>();
25 }
26
27 template <rowsize _row_size, rowsize _row_max = _row_size, rowsize _align = NoAlign>
29
30 // ================================================================
31 // MeshAdjState enum (bound once)
32 // ================================================================
33
34 inline void pybind11_MeshAdjState_define(py::module_ &m)
35 {
36 py::enum_<MeshAdjState>(m, "MeshAdjState")
37 .value("Unknown", Adj_Unknown)
38 .value("PointToGlobal", Adj_PointToGlobal)
39 .value("PointToLocal", Adj_PointToLocal);
40 }
41
42 // ================================================================
43 // AdjIndexInfo (bound once, all methods)
44 // ================================================================
45
46 inline void pybind11_AdjIndexInfo_define(py::module_ &m)
47 {
48 py::class_<AdjIndexInfo>(m, "AdjIndexInfo")
49 .def("state", &AdjIndexInfo::state)
50 .def("isLocal", &AdjIndexInfo::isLocal)
51 .def("isGlobal", &AdjIndexInfo::isGlobal)
52 .def("isBuilt", &AdjIndexInfo::isBuilt)
53 .def("isWired", &AdjIndexInfo::isWired);
54 }
55
56 // ================================================================
57 // AdjPairTracked<ArrayAdjacencyPair<rs, rm, al>> binding
58 // ================================================================
59
60 /// Declare the pybind11 class (creates the type stub in the module).
61 /// Must be called AFTER the base ArrayAdjacencyPair type is registered
62 /// (typically by importing DNDSR.DNDS).
63 template <rowsize _row_size, rowsize _row_max = _row_size, rowsize _align = NoAlign>
64 tPy_AdjPairTracked<_row_size, _row_max, _align>
66 {
67 // Get the already-registered base class from the DNDS module
68 auto dnds_m = py::module_::import("DNDSR.DNDS");
69 auto baseCls = pybind11_ArrayAdjacencyPair_get_class<_row_size, _row_max, _align>(dnds_m);
70
71 return {m, pybind11_AdjPairTracked_name<_row_size, _row_max, _align>().c_str(), baseCls};
72 }
73
74 /// Define all AdjPairTracked-specific methods on the pybind11 class.
75 template <rowsize _row_size, rowsize _row_max = _row_size, rowsize _align = NoAlign>
77 {
79 using TAdjWS = AdjPairTracked<TPair>;
80
81 auto cls = pybind11_AdjPairTracked_declare<_row_size, _row_max, _align>(m);
82
83 cls
84 // idx member (read-only reference)
85 .def_readonly("idx", &TAdjWS::idx, py::return_value_policy::reference_internal)
86 // State queries (convenience, delegate to idx)
87 .def("state", &TAdjWS::state)
88 .def("isLocal", &TAdjWS::isLocal)
89 .def("isGlobal", &TAdjWS::isGlobal)
90 .def("isBuilt", &TAdjWS::isBuilt)
91 .def("isWired", &TAdjWS::isWired);
92 }
93
94} // namespace DNDS::Geom
Eigen::Matrix< real, 3, 3 > m
void pybind11_MeshAdjState_define(py::module_ &m)
void pybind11_AdjIndexInfo_define(py::module_ &m)
py_class_ssp< AdjPairTracked< ArrayAdjacencyPair< _row_size, _row_max, _align > > > tPy_AdjPairTracked
tPy_AdjPairTracked< _row_size, _row_max, _align > pybind11_AdjPairTracked_declare(py::module_ &m)
std::string pybind11_AdjPairTracked_name()
void pybind11_AdjPairTracked_define(py::module_ &m)
Define all AdjPairTracked-specific methods on the pybind11 class.
py::classh< T > py_class_ssp
Convenience bundle of a father, son, and attached ArrayTransformer.
MeshAdjState state() const
Flattened wrapper: inherits from TPair and adds AdjIndexInfo.