Giter VIP home page Giter VIP logo

Comments (5)

eric-schleicher avatar eric-schleicher commented on May 15, 2024 1

see verbnurbs by @pboyer

from jsketcher.

xibyte avatar xibyte commented on May 15, 2024

Also current algorithm isn't very robust and fails in some corner cases.

from jsketcher.

iamnotstone avatar iamnotstone commented on May 15, 2024

After think twice about the whole things.I think it's a timing to start a new project which include brep, csg algorithms and triangulation algorithms. And take advantage of algorithms supported by verb-nurbs which include tessellate and intersection algorithm of nurbs surface.

I have to learn more about nurbs-surface/curve before doing this.

By the way, triangulation of plane face with nurbs-curve in outer loop can easily improved by add the code below in '.../3d/triangulation.js'

export function TriangulateFace(face) {
function arr(v) {
return [v.x, v.y, v.z];
}

function vertexCallback(data, out) {
out.push(data);
}
function combinecallback(coords, data, weight) {
//throw 'should never happen cuz brep is non-manifold'
}
function edgeCallback(flag) {
}

var tessy = new libtess.GluTesselator();
// tessy.gluTessProperty(libtess.gluEnum.GLU_TESS_WINDING_RULE, libtess.windingRule.GLU_TESS_WINDING_POSITIVE);
tessy.gluTessCallback(libtess.gluEnum.GLU_TESS_VERTEX_DATA, vertexCallback);
tessy.gluTessCallback(libtess.gluEnum.GLU_TESS_BEGIN, begincallback);
tessy.gluTessCallback(libtess.gluEnum.GLU_TESS_ERROR, errorcallback);
tessy.gluTessCallback(libtess.gluEnum.GLU_TESS_COMBINE, combinecallback);
tessy.gluTessCallback(libtess.gluEnum.GLU_TESS_EDGE_FLAG, edgeCallback);

const normal = arr(face.surface.normal);
tessy.gluTessNormal(normal[0], normal[1], normal[2]);

const vertices = [];
tessy.gluTessBeginPolygon(vertices);

for (let loop of face.loops) {
tessy.gluTessBeginContour();
for (let e of loop.halfEdges) {

+++ if(e.edge.curve.isLine)
tessy.gluTessVertex(arr(e.vertexA.point), e.vertexA);
+++ else if(e.edge.curve.isNurbsCurve){
+++ tessy.gluTessVertex(arr(e.vertexA.point), e.vertexA);
+++ let nurbsVectors = e.edge.curve.verb.tessellate()
+++ nurbsVectors.shift()

+++ nurbsVectors.forEach(v => {
+++ let midVertex = new Vertex(v[0], v[1], v[2])
+++ tessy.gluTessVertex(v, midVertex)}
+++ )

  }
}
tessy.gluTessEndContour();

}
....

from jsketcher.

iamnotstone avatar iamnotstone commented on May 15, 2024

@xibyte Thanks for your explain on gluTessNormal. The code before is just for a plane face with nurbs-curve in its ourerLoop. I know it do not works for nurbs -surface. In fact, I found tessellate algorithm was originally supported in verbnurbs by @pboyer .So I think if we can adjust the structure of our code and make use of the algorithm in verbnurb directly ? May be we can even adjust the code in the verbnurbs?

from jsketcher.

xibyte avatar xibyte commented on May 15, 2024

done in 8204748

from jsketcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.