MCPcopy
hub / github.com/jscad/OpenJSCAD.org / convertToSolid

Function convertToSolid

src/core/convertToSolid.js:11–34  ·  view source on GitHub ↗

* convert objects to a single solid * @param {Array} objects the list of objects * @return {Object} solid : the single CSG object

(objects, params)

Source from the content-addressed store, hash-verified

9 * @return {Object} solid : the single CSG object
10 */
11function convertToSolid (objects, params) {
12 if (objects.length === undefined) {
13 if ((objects instanceof CAG) || (objects instanceof CSG)) {
14 var obj = objects
15 objects = [obj]
16 } else {
17 throw new Error('Cannot convert object (' + typeof (objects) + ') to solid')
18 }
19 }
20
21 var solid = null
22 for (var i = 0; i < objects.length; i++) {
23 let obj = objects[i]
24 if (obj instanceof CAG) {
25 obj = obj.extrude({offset: [0, 0, 0.1]}) // convert CAG to a thin solid CSG
26 }
27 if (solid !== null) {
28 solid = solid.unionForNonIntersecting(obj)
29 } else {
30 solid = obj
31 }
32 }
33 return solid
34}
35
36function convertToSolid2 (objects, params) {
37 const {convertCSG, convertCAG} = params

Callers 1

processor.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected