Giter Club home page Giter Club logo

Comments (9)

rms80 avatar rms80 commented on August 19, 2024

agreed, that would be better. Would you mind checking something for me? Can you try putting this line before the code where you are writing out your OBJ, and see if it works? If it does, I will push/pop this state internally inside StandardMeshWriter, but I'm not sure how to test it on my local machine (ie my culture is dot)

System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

from geometry3sharp.

sandord avatar sandord commented on August 19, 2024

That is exactly how I currently hack this issue so I confirm it works.

from geometry3sharp.

rms80 avatar rms80 commented on August 19, 2024

OK, I added this. StandardMeshReader and StandardMeshWriter internally push/pop the current culture. Can be disabled via flags.

If you do get around to checking that this works, would be appreciated if you let me know. Thanks for reporting!

from geometry3sharp.

sandord avatar sandord commented on August 19, 2024

I haven't had the time yet to test it but I wonder why you're changing the current culture and not use the IFormatProvider argument for string conversions instead (e.g. .ToString(CultureInfo.InvariantCulture)). The latter is generally the preferred way.

from geometry3sharp.

sandord avatar sandord commented on August 19, 2024

This bug affects debugging as well. As you can see it makes reading the values pretty difficult.

image

from geometry3sharp.

rms80 avatar rms80 commented on August 19, 2024

yes, that does seem irritating.

As to our first question, I agree that is the preferred way, it's right in theory...but I am a realist. It is almost certain that at some point in the future I or another developer would forget to add the culture flag to some string. Doing it at the thread level for the exporter is safer.

your second problem...I'm not sure what to do about. To handle it I have to pass in InvariantCulture all over the place, and this is not necessarily something that every user will always want. All I can think of is adding a global static field for the entire library...

from geometry3sharp.

sandord avatar sandord commented on August 19, 2024

Not to be witty or anything but can you give some examples of cases in which users would want this library to use a culture different from InvariantCulture? I can't think of any, the library doesn't do any UI as far as I know.

I agree that sooner or later someone will forget the culture specification but you could consider adding an automated StyleCop rule for that.

from geometry3sharp.

rms80 avatar rms80 commented on August 19, 2024

It is entirely possible that someone will want to use this library to generate text files containing coordinates that will need to be read into some other software that expects numbers to be formatted in a specific culture.

One example I have personally dealt with is to work around bugs - for example if the reading software doesn't handle this properly, you might need to generate an OBJ with comma decimal separators so that it's text-reader parses them properly. We made this mistake w/ meshmixer, it would work fine as long as you only read back in files generated in the same culture. But english files opened w/ german meshmixer would go all blocky.

from geometry3sharp.

sandord avatar sandord commented on August 19, 2024

That sounds like a very solid reason. Defaulting to invariant culture with an option to override it (which I think is a common approach) sounds like the right way to go.

from geometry3sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.