How to use the @jscad/io-utils.ensureManifoldness function in @jscad/io-utils

To help you get started, we’ve selected a few @jscad/io-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / io / packages / x3d-serializer / index.js View on Github external
function serialize (CSG, options) {
  options && options.statusCallback && options.statusCallback({progress: 0})
  CSG = ensureManifoldness(CSG)
  const DOMImplementation = typeof document !== 'undefined' ? document.implementation : new xmldom.DOMImplementation()
  // materialPolygonLists
  // key: a color string (e.g. "0 1 1" for yellow)
  // value: an array of strings specifying polygons of this color
  //        (as space-separated indices into vertexCoords)
  var materialPolygonLists = {}
  // list of coordinates (as "x y z" strings)
  var vertexCoords = []
  // map to look up the index in vertexCoords of a given vertex
  var vertexTagToCoordIndexMap = {}

  CSG.polygons.map(function (p, i) {
    var red = 0
    var green = 0
    var blue = 1 // default color is blue
    if (p.shared && p.shared.color) {
github jscad / OpenJSCAD.org / packages / io / dxf-serializer / index.js View on Github external
let entityContents = objects.map(function (object, i) {
    if (isCAG(object)) {
      let paths = object.getOutlinePaths()
      if (options.cagTo === 'polyline') {
        return PathsToPolyine(paths, options)
      }
      return PathsToLwpolyine(paths, options)
    }
    if (isCSG(object)) {
      object = ensureManifoldness(object)
      if (options.csgTo === 'polyline') {
        return PolygonsToPolyline(object, options)
      }
      return PolygonsTo3DFaces(object, options)
    }
    if (isPath(object)) {
    // mimic a CAG outline path
      let points = object.getPoints()
      let closed = object.isClosed()
      let path = {closed: closed, points: points}
      return PathsToLwpolyine([path], options)
    }
    return ''
  })
  let section = `  0
github jscad / io / packages / dxf-serializer / index.js View on Github external
let entityContents = objects.map(function (object, i) {
    if (isCAG(object)) {
      let paths = object.getOutlinePaths()
      if (options.cagTo === 'polyline') {
        return PathsToPolyine(paths, options)
      }
      return PathsToLwpolyine(paths, options)
    }
    if (isCSG(object)) {
      object = ensureManifoldness(object)
      if (options.csgTo === 'polyline') {
        return PolygonsToPolyline(object, options)
      }
      return PolygonsTo3DFaces(object, options)
    }
    if (isPath(object)) {
    // mimic a CAG outline path
      let points = object.getPoints()
      let closed = object.isClosed()
      let path = {closed: closed, points: points}
      return PathsToLwpolyine([path], options)
    }
    return ''
  })
  let section = `  0
github jscad / io / packages / amf-serializer / index.js View on Github external
function serialize (CSG, m, options) {
  options && options.statusCallback && options.statusCallback({progress: 0})
  CSG = ensureManifoldness(CSG)
  var result = '\n\n'
  for (var k in m) {
    result += '\n'
  }
  result += '\n\n\n'

  CSG.polygons.map(function (p) { // first we dump all vertices of all polygons
    for (var i = 0; i < p.vertices.length; i++) {
      result += CSGVertextoAMFString(p.vertices[i])
    }
  })
  result += '\n'

  var n = 0
  CSG.polygons.map(function (p, i) { // then we dump all polygons
    result += '\n'
github jscad / io / packages / stl-serializer / index.js View on Github external
function serialize (data, options) {
  const defaults = {
    binary: true
  }
  options = Object.assign({}, defaults, options)

  data = ensureManifoldness(data)
  return options.binary ? binarySerializer(data, options) : asciiSerializer(data, options)
}
github jscad / OpenJSCAD.org / packages / io / stl-serializer / index.js View on Github external
objects.forEach(function (object, i) {
    if (isCSG(object) & object.polygons.length > 0) {
      csgs.push(ensureManifoldness(object))
    }
  })
  return options.binary ? serializeBinary(csgs, options) : serializeText(csgs, options)
github jscad / OpenJSCAD.org / packages / io / amf-serializer / index.js View on Github external
objects.forEach(function (object, i) {
    if (isCSG(object) && object.polygons.length > 0) {
      object = ensureManifoldness(object)
      options.id = i
      contents.push(convertCSG(object, options))
    }
  })
  return contents
github jscad / OpenJSCAD.org / packages / io / json-serializer / index.js View on Github external
objects.forEach(function (object, i) {
    if (isCSG(object) && object.polygons.length > 0) {
      let data = ensureManifoldness(object)
      contents.push(fromCSG(data, options))
    }
    if (isCAG(object) && object.sides.length > 0) {
      contents.push(fromCAG(object, options))
    }
    options.statusCallback && options.statusCallback({progress: 100 * i / objects.length})
  })
github jscad / OpenJSCAD.org / packages / io / x3d-serializer / index.js View on Github external
objects.forEach(function (object, i) {
    options.statusCallback && options.statusCallback({progress: 100 * i / objects.length})
    if (isCSG(object) && object.polygons.length > 0) {
      object = ensureManifoldness(object)
      shapes.push(convertCSG(object, options))
    }
  })
  scene = scene.concat(shapes)

@jscad/io-utils

Utilities for JSCAD IO Packages

MIT
Latest version published 2 months ago

Package Health Score

87 / 100
Full package analysis