Sorry, I don't mean to nit pick. I'm just not understanding a situation where a vector wouldn't specify a unique direction, but a map from magic numbers to directions would (and I don't like C style enums creating meaning
A more Pythonic solution to the algorithm only handling vectors that are "on axis" is to accept a vector (perhaps of 3 ints), but throw if it's not in a direction that the algorithm can handle. That way, if someone extends the algorithm later to accept a wider range of directions, the interface doesn't need to change.
Well, I like to be more extendable as well. It's just that I failed to imagine the possibility of any direction control other than those axial ones. But I may be wrong here, and I'll be happy to change it if someone can hint any possible use case.
ian.rees wrote:Where would it be more work to use the "XPositive" strings directly as you mentioned? In other words, there's nothing "positve Y"-ish about 3, so the code must be branching depending on literal values somewhere. IIRC, the data storage behind PropertyEnum can take care of the translation back-and-forth between ints and strings if it's a C++ domain issue.
Hmm... you seem like a guy that won't get bored by this little story I am going to tell you. Path.Area is pure C++ implementation. Its python object is just a thin wrap. Because of the need to expose large amount of parameters, I come up with a marco library to help the tedious task of exposing the same thing in multiple places, function argument, settings, properties, python wrappings, doc strings, etc. In my code, there is very little direct references to individual parameters, only groups. BTW, the library is in src/Mod/Path/App/ParamsHelper.h with full document, and all Path.Area's parameters are defined in AreaParams.h, if you are curious. In the process, I had my first try of boost.postprocessor, and I was having too much fun with it. It wasn't until I tried to add the string enumeration support that I realized that I went too far. It would have been better to mix pure macro iteration with meta type structure, at least for the enumeration. There are more than a dozen of enum parameters in Area. I made an attempt, but the code looked ugly, so it's been scratched. And my interests has since been shifted to other things. It is still on my to do list, though.