Support IGES format #279

This commit is contained in:
kovacsv 2022-07-03 17:34:34 +02:00
parent f806549e9c
commit f43327ddd8
10 changed files with 48 additions and 22 deletions

View File

@ -22,7 +22,7 @@ The repository is separated into two parts. See more information in the [Develop
## Supported file formats
* **Import**: obj, 3ds, stl, ply, gltf, glb, off, 3dm, fbx, dae, wrl, 3mf, ifc, stp, bim.
* **Import**: obj, 3ds, stl, ply, gltf, glb, off, 3dm, fbx, dae, wrl, 3mf, ifc, stp, igs, bim.
* **Export**: obj, stl, ply, gltf, glb, off, 3dm, bim.
## Features

View File

@ -3,6 +3,11 @@ importScripts ('occt-import-js.js');
onmessage = async function (ev)
{
let occt = await occtimportjs ();
let result = occt.ReadStepFile (ev.data);
let result = null;
if (ev.data.format === 'step') {
result = occt.ReadStepFile (ev.data.buffer);
} else if (ev.data.format === 'iges') {
result = occt.ReadIgesFile (ev.data.buffer);
}
postMessage (result);
};

File diff suppressed because one or more lines are too long

Binary file not shown.

14
package-lock.json generated
View File

@ -12,7 +12,7 @@
"@simonwep/pickr": "1.8.2",
"draco3d": "1.5.2",
"fflate": "0.7.3",
"occt-import-js": "0.0.8",
"occt-import-js": "0.0.10",
"rhino3dm": "7.14.0",
"three": "0.142.0",
"web-ifc": "0.0.35"
@ -4011,9 +4011,9 @@
}
},
"node_modules/occt-import-js": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/occt-import-js/-/occt-import-js-0.0.8.tgz",
"integrity": "sha512-on+mZRbQImhEnB6hhw8wXLP5jTebVqlJ6nxtjUgBE5ZBGFYLFwitQeS6y3yrbEsrg9SjOgwNtAJYNAEWy/x+VA=="
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/occt-import-js/-/occt-import-js-0.0.10.tgz",
"integrity": "sha512-DvFitPZswkOqkkM7YvuIlykHp30e3Da1f83hVdVQ0WegcwNe933RF2/iQ0AnpO/T0SNnfjXSA0d68My8XWIr+Q=="
},
"node_modules/omggif": {
"version": "1.0.10",
@ -8378,9 +8378,9 @@
"dev": true
},
"occt-import-js": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/occt-import-js/-/occt-import-js-0.0.8.tgz",
"integrity": "sha512-on+mZRbQImhEnB6hhw8wXLP5jTebVqlJ6nxtjUgBE5ZBGFYLFwitQeS6y3yrbEsrg9SjOgwNtAJYNAEWy/x+VA=="
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/occt-import-js/-/occt-import-js-0.0.10.tgz",
"integrity": "sha512-DvFitPZswkOqkkM7YvuIlykHp30e3Da1f83hVdVQ0WegcwNe933RF2/iQ0AnpO/T0SNnfjXSA0d68My8XWIr+Q=="
},
"omggif": {
"version": "1.0.10",

View File

@ -9,8 +9,8 @@
"repository": "github:kovacsv/Online3DViewer",
"keywords": [
"3d", "viewer",
"obj", "3ds", "stl", "ply", "gltf", "glb", "off",
"3dm", "fbx", "dae", "wrl", "3mf", "ifc", "stp", "bim"
"obj", "3ds", "stl", "ply", "gltf", "glb", "off", "3dm",
"fbx", "dae", "wrl", "3mf", "ifc", "stp", "igs", "bim"
],
"files": [
"build/o3dv.min.js",
@ -56,7 +56,7 @@
"rhino3dm": "7.14.0",
"three": "0.142.0",
"web-ifc": "0.0.35",
"occt-import-js" : "0.0.8"
"occt-import-js" : "0.0.10"
},
"eslintConfig": {
"env": {

View File

@ -10,7 +10,7 @@ import { ImporterO3dv } from './importero3dv.js';
import { ImporterObj } from './importerobj.js';
import { ImporterOff } from './importeroff.js';
import { ImporterPly } from './importerply.js';
import { ImporterStp } from './importerstp.js';
import { ImporterOcct } from './importerocct.js';
import { ImporterStl } from './importerstl.js';
import { ImporterBim } from './importerbim.js';
import { ImporterThree3mf, ImporterThreeDae, ImporterThreeFbx, ImporterThreeWrl } from './importerthree.js';
@ -90,7 +90,7 @@ export class Importer
new ImporterBim (),
new Importer3dm (),
new ImporterIfc (),
new ImporterStp (),
new ImporterOcct (),
new ImporterThreeFbx (),
new ImporterThreeDae (),
new ImporterThreeWrl (),

View File

@ -6,7 +6,7 @@ import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
import { ImporterBase } from './importerbase.js';
import { ColorToMaterialConverter } from './importerutils.js';
export class ImporterStp extends ImporterBase
export class ImporterOcct extends ImporterBase
{
constructor ()
{
@ -16,7 +16,7 @@ export class ImporterStp extends ImporterBase
CanImportExtension (extension)
{
return extension === 'stp' || extension === 'step';
return extension === 'stp' || extension === 'step' || extension === 'igs' || extension === 'iges';
}
GetUpDirection ()
@ -42,7 +42,7 @@ export class ImporterStp extends ImporterBase
}
let onModelConverted = (ev) => {
this.ImportStepContent (ev.data, onFinish);
this.ImportResultJson (ev.data, onFinish);
this.worker.removeEventListener ('message', onModelConverted);
};
@ -53,11 +53,24 @@ export class ImporterStp extends ImporterBase
onFinish ();
});
let format = null;
if (this.extension === 'stp' || this.extension === 'step') {
format = 'step';
} else if (this.extension === 'igs' || this.extension === 'iges') {
format = 'iges';
} else {
onFinish ();
return;
}
let fileBuffer = new Uint8Array (fileContent);
this.worker.postMessage (fileBuffer);
this.worker.postMessage ({
format : format,
buffer : fileBuffer
});
}
ImportStepContent (stepContent, onFinish)
ImportResultJson (stepContent, onFinish)
{
if (!stepContent.success) {
return;

View File

@ -31,10 +31,10 @@ import { ImporterGltf } from './import/importergltf.js';
import { ImporterIfc } from './import/importerifc.js';
import { ImporterO3dv } from './import/importero3dv.js';
import { ImporterObj } from './import/importerobj.js';
import { ImporterOcct } from './import/importerocct.js';
import { ImporterOff } from './import/importeroff.js';
import { ImporterPly } from './import/importerply.js';
import { ImporterStl } from './import/importerstl.js';
import { ImporterStp } from './import/importerstp.js';
import { ImporterThreeSvg } from './import/importersvg.js';
import { ImporterThreeBase, ImporterThreeFbx, ImporterThreeDae, ImporterThreeWrl, ImporterThree3mf } from './import/importerthree.js';
import { ColorToMaterialConverter, NameFromLine, ParametersFromLine, ReadLines, IsPowerOfTwo, NextPowerOfTwo, UpdateMaterialTransparency } from './import/importerutils.js';
@ -161,10 +161,10 @@ export {
ImporterIfc,
ImporterO3dv,
ImporterObj,
ImporterOcct,
ImporterOff,
ImporterPly,
ImporterStl,
ImporterStp,
ImporterThreeSvg,
ImporterThreeBase,
ImporterThreeFbx,

View File

@ -190,6 +190,14 @@
<td class="center red">&#x2717</td>
<td><a href="https://github.com/kovacsv/occt-import-js">occt-import-js</a></td>
</tr>
<tr>
<td>IGES</td>
<td>igs</td>
<td>text</td>
<td class="center green">&#x2713</td>
<td class="center red">&#x2717</td>
<td><a href="https://github.com/kovacsv/occt-import-js">occt-import-js</a></td>
</tr>
<tr>
<td>Industry Foundation Classes</td>
<td>ifc</td>