mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 14:33:28 +00:00
Support vector<string> setting types
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
@@ -521,6 +522,11 @@ namespace ifcopenshell {
|
|||||||
static constexpr const char* name = "std::vector<double>";
|
static constexpr const char* name = "std::vector<double>";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct readable_name<std::vector<std::string>> {
|
||||||
|
static constexpr const char* name = "std::vector<std::string>";
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct readable_name<IteratorOutputOptions> {
|
struct readable_name<IteratorOutputOptions> {
|
||||||
static constexpr const char* name = "IteratorOutputOptions";
|
static constexpr const char* name = "IteratorOutputOptions";
|
||||||
@@ -545,7 +551,9 @@ namespace ifcopenshell {
|
|||||||
template <typename settings_t>
|
template <typename settings_t>
|
||||||
class SettingsContainer {
|
class SettingsContainer {
|
||||||
public:
|
public:
|
||||||
typedef std::variant<bool, int, double, std::string, std::set<int>, std::set<std::string>, std::vector<double>, IteratorOutputOptions, FunctionStepMethod, OutputDimensionalityTypes, TriangulationMethod> value_variant_t;
|
typedef std::variant<bool, int, double, std::string, std::set<int>, std::set<std::string>,
|
||||||
|
std::vector<double>, std::vector<std::string>, IteratorOutputOptions, FunctionStepMethod,
|
||||||
|
OutputDimensionalityTypes, TriangulationMethod> value_variant_t;
|
||||||
private:
|
private:
|
||||||
settings_t settings;
|
settings_t settings;
|
||||||
|
|
||||||
|
|||||||
@@ -515,10 +515,14 @@ assign_matrix_access(revolve);
|
|||||||
void set_(const std::string& name, const std::set<int>& val) {
|
void set_(const std::string& name, const std::set<int>& val) {
|
||||||
return $self->set(name, val);
|
return $self->set(name, val);
|
||||||
}
|
}
|
||||||
void set_(const std::string& name, const std::set<std::string>& val) {
|
void set_(const std::string& name, const std::vector<double>& val) {
|
||||||
return $self->set(name, val);
|
return $self->set(name, val);
|
||||||
}
|
}
|
||||||
void set_(const std::string& name, const std::vector<double>& val) {
|
void set_(const std::string& name, const std::vector<std::string>& val) {
|
||||||
|
// Python sequences cannot distinguish std::vector<std::string> from std::set<std::string>.
|
||||||
|
if ($self->get_type(name) == "std::set<std::string>") {
|
||||||
|
return $self->set(name, std::set<std::string>(val.begin(), val.end()));
|
||||||
|
}
|
||||||
return $self->set(name, val);
|
return $self->set(name, val);
|
||||||
}
|
}
|
||||||
ifcopenshell::geometry::Settings::value_variant_t get_(const std::string& name) {
|
ifcopenshell::geometry::Settings::value_variant_t get_(const std::string& name) {
|
||||||
|
|||||||
@@ -286,7 +286,7 @@
|
|||||||
} else if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::set<std::string>>) {
|
} else if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::set<std::string>>) {
|
||||||
std::vector<std::string> vs(t.begin(), t.end());
|
std::vector<std::string> vs(t.begin(), t.end());
|
||||||
return pythonize_vector(vs);
|
return pythonize_vector(vs);
|
||||||
} else if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::vector<double>>) {
|
} else if constexpr (is_std_vector_v<std::remove_cv_t<std::remove_reference_t<T>>>) {
|
||||||
return pythonize_vector(t);
|
return pythonize_vector(t);
|
||||||
} else {
|
} else {
|
||||||
return pythonize(t);
|
return pythonize(t);
|
||||||
|
|||||||
Reference in New Issue
Block a user