Add sphere and empty test file.
This commit is contained in:
parent
8c468ba00d
commit
cb348c657f
BIN
tools/sandbox/rhino3dm_error/input/one_sphere.3dm
Normal file
BIN
tools/sandbox/rhino3dm_error/input/one_sphere.3dm
Normal file
Binary file not shown.
@ -2,11 +2,17 @@ let rhino3dm = require ('../../../libs/rhino3dm.min.js')
|
||||
let fs = require ('fs');
|
||||
let path = require ('path');
|
||||
|
||||
function GetThreeMeshesFrom3dm (rhino, rhinoFileName)
|
||||
function Open3dmFile (rhino, rhinoFileName)
|
||||
{
|
||||
let inputBuffer = fs.readFileSync (rhinoFileName, null).buffer;
|
||||
let inputArray = new Uint8Array (inputBuffer);
|
||||
let inputDoc = rhino.File3dm.fromByteArray (inputArray);
|
||||
return inputDoc;
|
||||
}
|
||||
|
||||
function GetThreeMeshesFrom3dm (rhino, rhinoFileName)
|
||||
{
|
||||
let inputDoc = Open3dmFile (rhino, rhinoFileName);
|
||||
let objects = inputDoc.objects ();
|
||||
let threeMeshes = [];
|
||||
for (let i = 0; i < objects.count; i++) {
|
||||
@ -33,9 +39,18 @@ function WriteThreeMeshesTo3dm (rhino, threeMeshes, rhinoFileName)
|
||||
|
||||
function ReadWriteRhinoFile (rhinoIn, rhinoOut, inputRhinoFile, outputRhinoFile)
|
||||
{
|
||||
let threeMeshes = GetThreeMeshesFrom3dm (rhinoIn, inputRhinoFile);
|
||||
console.log ('Meshes in ' + inputRhinoFile + ': ' + threeMeshes.length);
|
||||
let threeMeshes = [];
|
||||
if (inputRhinoFile !== null) {
|
||||
threeMeshes = GetThreeMeshesFrom3dm (rhinoIn, inputRhinoFile);
|
||||
}
|
||||
console.log ('Meshes in ' + outputRhinoFile + ': ' + threeMeshes.length);
|
||||
WriteThreeMeshesTo3dm (rhinoOut, threeMeshes, outputRhinoFile);
|
||||
let reopened = Open3dmFile (rhinoIn, outputRhinoFile);
|
||||
if (reopened !== null) {
|
||||
console.log ('SUCCESS');
|
||||
} else {
|
||||
console.log ('ERROR');
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync ('output')){
|
||||
@ -47,5 +62,7 @@ rhino3dm ().then (async function (rhinoIn) {
|
||||
ReadWriteRhinoFile (rhinoIn, rhinoOut, 'input/one_cube.3dm', 'output/one_cube.3dm');
|
||||
ReadWriteRhinoFile (rhinoIn, rhinoOut, 'input/two_cubes.3dm', 'output/two_cubes.3dm');
|
||||
ReadWriteRhinoFile (rhinoIn, rhinoOut, 'input/three_cubes.3dm', 'output/three_cubes.3dm');
|
||||
ReadWriteRhinoFile (rhinoIn, rhinoOut, 'input/one_sphere.3dm', 'output/one_sphere.3dm');
|
||||
ReadWriteRhinoFile (rhinoIn, rhinoOut, null, 'output/empty.3dm');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user