{"id":16579029,"url":"https://github.com/kovacsv/occt-import-js","last_synced_at":"2025-05-15T17:06:04.311Z","repository":{"id":39600169,"uuid":"451186138","full_name":"kovacsv/occt-import-js","owner":"kovacsv","description":"The emscripten interface for OpenCascade import functionalities.","archived":false,"fork":false,"pushed_at":"2024-12-03T07:01:27.000Z","size":79497,"stargazers_count":209,"open_issues_count":17,"forks_count":32,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-08T15:06:03.096Z","etag":null,"topics":["3d","brep","brp","iges","igs","import","opencascade","step","stp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kovacsv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kovacsv"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-01-23T17:56:41.000Z","updated_at":"2025-05-08T05:47:41.000Z","dependencies_parsed_at":"2024-04-27T20:24:03.018Z","dependency_job_id":"64d96f57-3317-4ed5-803e-458f7d0564c8","html_url":"https://github.com/kovacsv/occt-import-js","commit_stats":{"total_commits":127,"total_committers":4,"mean_commits":31.75,"dds":0.03149606299212604,"last_synced_commit":"53e102664f82ed9de00464cdfdd1baabc918acc9"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovacsv%2Focct-import-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovacsv%2Focct-import-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovacsv%2Focct-import-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovacsv%2Focct-import-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kovacsv","download_url":"https://codeload.github.com/kovacsv/occt-import-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","brep","brp","iges","igs","import","opencascade","step","stp"],"created_at":"2024-10-11T22:16:40.621Z","updated_at":"2025-05-15T17:05:59.302Z","avatar_url":"https://github.com/kovacsv.png","language":"C++","funding_links":["https://github.com/sponsors/kovacsv"],"categories":[],"sub_categories":[],"readme":"# occt-import-js\n\nThe [emscripten](https://emscripten.org) interface for [OpenCascade](https://www.opencascade.com) import functionalities. It runs entirely in the browser, and allows you to import brep, step and iges files and access the result in JSON format.\n\n[![npm version](https://badge.fury.io/js/occt-import-js.svg)](https://badge.fury.io/js/occt-import-js)\n[![WASM Build](https://github.com/kovacsv/occt-import-js/actions/workflows/wasm_build.yml/badge.svg)](https://github.com/kovacsv/occt-import-js/actions/workflows/wasm_build.yml)\n[![Native Build](https://github.com/kovacsv/occt-import-js/actions/workflows/native_build.yml/badge.svg)](https://github.com/kovacsv/occt-import-js/actions/workflows/native_build.yml)\n\nSee it in action in [Online 3D Viewer](https://3dviewer.net/#model=https://dl.dropbox.com/s/utieopxrxwujgmd/as1_pe_203.stp), or check [this fiddle](https://jsfiddle.net/kovacsv/rzhq9gxj) for a code example.\n\n## How to install?\n\nYou can get occt-import-js from [npm](https://www.npmjs.com/package/occt-import-js):\n\n```\nnpm install occt-import-js\n```\n\n## How to use?\n\nThe library runs in the browser and as a node.js module as well.\n\nYou will need two files from the `dist` folder: `occt-import-js.js` and `occt-import-js.wasm`. The wasm file is loaded runtime by the js file. There are three public functions in the library:\n\n- `ReadBrepFile` to import brep file.\n- `ReadStepFile` to import step file.\n- `ReadIgesFile` to import iges file.\n\nAll functions have two parameters:\n\n- `content`: The file content as a `Uint8Array` object.\n- `params`: Triangulation parameters as an object, can be `null`.\n  - `linearUnit`: Defines the linear unit of the output. Possible values: `millimeter`, `centimeter`, `meter`, `inch`, `foot`. Default is `millimeter`. Has no effect on brep files.\n  - `linearDeflectionType`: Defines what the linear deflection value means. Default is `bounding_box_ratio`. Possible values:\n    - `bounding_box_ratio`: The `linearDeflection` value contains a ratio of the average bounding box.\n    - `absolute_value`: The `linearDeflection` value contains an absolute value in the unit defined by `linearUnit`.\n  - `linearDeflection`: The linear deflection value based on the value of the `linearDeflectionType` parameter.\n  - `angularDeflection`: The angular deflection value.\n\nYou can find more information about deflection values [here](https://dev.opencascade.org/doc/overview/html/occt_user_guides__mesh.html).\n\n### Use from the browser\n\nFirst, include the `occt-import-js.js` file in your website.\n\n```html\n\u003cscript type=\"text/javascript\" src=\"occt-import-js.js\"\u003e\u003c/script\u003e\n```\n\nAfter that, download the model file, and pass them to occt-import-js.\n\n```js\nocctimportjs ().then (async function (occt) {\n    let fileUrl = '../test/testfiles/simple-basic-cube/cube.stp';\n    let response = await fetch (fileUrl);\n    let buffer = await response.arrayBuffer ();\n    let fileBuffer = new Uint8Array (buffer);\n    let result = occt.ReadStepFile (fileBuffer, null);\n    console.log (result);\n});\n```\n\n### Use as a node.js module\n\nYou should require the `occt-import-js` module in your script.\n\n```js\nlet fs = require ('fs');\nconst occtimportjs = require ('occt-import-js')();\n\nocctimportjs.then ((occt) =\u003e {\n    let fileUrl = '../test/testfiles/simple-basic-cube/cube.stp';\n    let fileContent = fs.readFileSync (fileUrl);\n    let result = occt.ReadStepFile (fileContent, null);\n    console.log (result);\n});\n```\n\n### Processing the result\n\nThe result of the import is a JSON object with the following structure.\n\n- **success** (boolean): Tells if the import was successful.\n- **root** (object): The root node of the hierarchy.\n  - **name** (string): Name of the node.\n  - **meshes** (array): Indices of the meshes in the meshes array for this node.\n  - **children** (array): Array of child nodes for this node.\n- **meshes** (array): Array of mesh objects. The geometry representation is compatible with [three.js](https://github.com/mrdoob/three.js).\n  - **name** (string): Name of the mesh.\n  - **color** (array, optional): Array of r, g, and b values of the mesh color.\n  - **brep_faces** (array): Array representing the faces of the source b-rep.\n    - **first** (number): The first triangle index of the face.\n    - **last** (number): The last triangle index of the face.\n    - **color** (array): Array of r, g, and b values of the color or null.\n  - **attributes** (object)\n    - **position** (object)\n      - **array** (array): Array of number triplets defining the vertex positions.\n    - **normal** (object, optional)\n      - **array** (array): Array of number triplets defining the normal vectors.\n  - **index** (object):\n    - **array** (array): Array of number triplets defining triangles by indices.\n\n## How to build on Windows?\n\nA set of batch scripts are prepared for building on Windows.\n\n### 1. Install Prerequisites\n\nInstall [CMake](https://cmake.org) (3.6 minimum version is needed). Make sure that the cmake executable is in the PATH.\n\n### 2. Install Emscripten SDK\n\nRun the Emscripten setup script.\n\n```\ntools\\setup_emscripten_win.bat\n```\n\n### 3. Compile the WASM library\n\nRun the release build script.\n\n```\ntools\\build_wasm_win_release.bat\n```\n\n### 4. Build the native project (optional)\n\nIf you want to debug the code, it's useful to build a native project. To do that, just use cmake to generate the project of your choice.\n\n## How to run locally?\n\nTo run the demo and the examples locally, you have to start a web server. Run `npm install` from the root directory, run `npm start` and visit `http://localhost:8080`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovacsv%2Focct-import-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkovacsv%2Focct-import-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovacsv%2Focct-import-js/lists"}