Open z3dev opened 3 years ago
@gilboonet might be interested in creating these now that V2 is functional. it should be slightly easier to create, test, and package now.
@z3dev I'm not sure I am skilled enough for that (I know almost nothing about git, node package and when I tried, I was able to code serializer but when I started to test it, I never managed to debug properly), but I will give it a try.
@gilboonet please try again.
To start...
And create a copy of the OBJ deserializer
Next, adjust the package information
Now, the package can be linked up with the other packages for development.
Once done, then development of the OFF deserializer can start. Of course, you will have to change the code in index.js
If you want, I can follow along. You will have to fork OpenJSCAD.org.
I created a folder for this, followed the steps and for the moment it is all ok. I will start the deserializer and will get back to you for the next steps.
I wrote the deserializer and now I need to test. Apparently the two files instantiate.test.js and translate.test.js need to be changed. What do I need to do to test ? It's the point where I was stopped last time, my test was not ok and I didn't knew how to debug.
I wrote the deserializer and now I need to test. Apparently the two files instantiate.test.js and translate.test.js need to be changed. What do I need to do to test ?
👍
Just start easy, and create a single test case.
The first test case is just to check logic, and verify the basic translation.
You can use console.log() to see the translation. And you can add console.log() to debug functions or logic if there are problems.
Expect a few issues at first. Fix bugs, and add more test cases. If working well then add some more functionality. ... repeat... repeat...
I started the first test. Put together a simple test case into translate.test.js then run "npm test. The test failed but shows no difference between observed and expected, so I don't see how to resolve that.
Great!
I suggest using something like this for testing translation, as strings can be different across operating systems. (From AMF deserializer tests)
const countOf = (search, string) => {
let count = 0
let index = string.indexOf(search)
while (index !== -1) {
count++
index = string.indexOf(search, index + 1)
}
return count
}
test('deserialize simple amf file to jscad script', (t) => {
const inputPath = path.resolve(samplesPath, 'amf/Amf_Cube.amf')
const inputFile = fs.readFileSync(inputPath)
const observed = deserializer.deserialize({ output: 'script', addMetaData: false }, inputFile)
t.is(countOf('poly3.fromPoints', observed), 12)
t.is(countOf('polygon.color', observed), 12)
t.is(countOf('geom3.create', observed), 1)
})
@gilboonet How are you progressing on the testing? I hope that you are making some good test cases. 👍
By the way, I'm working the X3D deserializer. I added a new pull request that contains the initial code. This should help you to understand how packages are 'linked' together. #757
@z3dev I replaced deepEqual() by a simpler : t.is(countOf('primitives.polyhedron', observed), 1) and the basic test is ok, but then I added a console.log(observed) and it didn't have any data fetched from the test file, so I'm not sure that I understand enough the mechanics of testing to be able to help.
The left hand view doesn’t look correct. This shows the output from console.log(observed).
There are no points or faces. So, there are some issues in the translation.
Now, you need to find out why... you can add console.log() statements to make sure data is correct, as well as check parameters being passed to functions.
@gilboonet how goes the testing? Are you making progress?
@z3dev I didn't make any progress, my code looks ok, so I didn't find what to check. I don't think I'm skilled enough for such development even if I wrote a node js off to jscad translator that works, it requires more to be able to do the same into such a big project.
@z3dev I didn't make any progress, my code looks ok, so I didn't find what to check. I don't think I'm skilled enough for such development even if I wrote a node js off to jscad translator that works, it requires more to be able to do the same into such a big project.
@gilboonet ok. it might be easier if i can comment on the code. have you created a fork of OpenJSCAD.org?
Such project deals with too many tools/libraries/technologies and I don't feel I could be helpful and instead will make others lose time to help me. I think I could provide feedback and use cases, but not contribute efficiently to the code.
Expected Behavior
Deserializer
Serializer
Actual Behavior
Not available
Steps to Reproduce the Problem
Specifications
http://www.geomview.org/docs/html/OFF.html
https://people.sc.fsu.edu/~jburkardt/data/off/off.html