speckleworks / SpeckleCore

Check a brand new Speckle at: https://github.com/specklesystems
https://speckle.systems
MIT License
38 stars 17 forks source link

Geometry Conversion RhinoCommon to DesignScript #68

Closed Eckart-S closed 6 years ago

Eckart-S commented 6 years ago

I did some more work on the DSConverter and this is what is still open and maybe SpeckleCore issues? I only did a quick test, it is not checked if geometry perfectly matches input 100%, yet.

Type Geometry UserData
     
Point ok ok
     
Vector ok No UserData possible
(SetUserData node has error)
Line Conversion not called
(uses SpecklePolyline class)
??
Rectangle (closed) Conversion not called
(uses SpecklePolyline class)

Has duplicated start + end point
??
Polyline (open) ok ok
Polyline (closed) Has duplicated start + end point ok
     
Circle (closed) Conversion not called
(uses SpeckleArc class)
??
Ellipse (closed) ok ok
Arc Circular (open) ok ok
Arc Elliptical (open) Unsupported? ??
     
Nurbs (open) Conversion does not work
(Nurbs input unsuitable)
??
Nurbs (closed) Conversion does not work
(Nurbs input unsuitable)
??
     
Polycurve (open) (ToDo) (ToDo)
Polycurve (closed) (ToDo) (ToDo)
     
Plane ok No UserData possible
(SetUserData node has error)
Mesh ok ok
     

Nurbs issues

ERROR Unable to create BSplineCurve from vertices : B-spline knot sequence is decreasing (should be non-decreasing)

NOTE Degree: Should be greater than 1 (piecewise-linear spline) and less than 26 (the maximum B-spline basis degree supported by ASM). Weights: All weight values (if supplied) should be strictly positive. Weights smaller than 1e-11 will be rejected and the function will fail. Knots: The knot vector should be a non-decreasing sequence. Interior knot multiplicity should be no larger than degree + 1 at the start/end knot and degree at an internal knot (this allows curves with G1 discontinuities to be represented). Note that non-clamped knot vectors are supported, but will be converted to clamped ones, with the corresponding changes applied to the control point/weight data. Knot Array: The array size must be num_control_points + degree + 1

What do we change in SpeckleCore, which needs to be adjusted in other places?

Eckart-S commented 6 years ago

I think there should be very clear rules about how to store data, otherwise every plugin will do this slightly different (due to API, etc.) and then the converters need to consider all those different cases and plugins.

Eckart-S commented 6 years ago

Some Images...

GH/RHINO (Source)

image

DYNAMO

image

VIEWER

image

Stream ID: B1wYYERjM

mswaidan commented 6 years ago

Vectors not visible (probably intention?)

For the moment, yes.

Circles not visible Ellipses not visible (1 of 25 made it through) Arcs circular not visible Planes not visible (probably intention?)

These should be supported. They've been tested with GH -> viewer. Will try to figure out what's going on.

didimitrie commented 6 years ago

@Eckart-S , when you have time, could you drop the gh/ rh + gh file for that geom generation?

Eckart-S commented 6 years ago

Sure, need to have a look when I'm back in the office

Eckart-S commented 6 years ago

Circles are SpeckleArc (with 360° angle) currently, btw.

didimitrie commented 6 years ago

Ok, i've been doing some tests & hopefully will be fixing some identified bugs re polylines & lines.

didimitrie commented 6 years ago

actually last commit is this https://github.com/speckleworks/SpeckleRhino/commit/7834ad4b38733a516fd9376b366ba54d1571a1dc on this issue, it's mostly speckle rhino converter stuff 🙃

Regarding the nurbs curve part, i would suggest potentially just plopping out the polyline (its displayValue) as a temporary filler. won't say it, but @teocomi could help ;)

Eckart-S commented 6 years ago

Well, Dynamo/DesignScript knows elliptical arcs hence i asked. But i think Rhino might not and possibly Revit neither, so this is kind of last last last priority :)

Planes with parameters would be cool though :) What happens if i deliver them to RH/GH with userdata attached? Ignore or explosion?

Good regarding the polylines - that's what the closed parameter is for.

Hmm i think i used Rh5. Are they proper SpeckleCircles? Some software might be weird with Arcs and 360° angle. Dynamo fix works but you never know.

mswaidan commented 6 years ago

Not sure how you make an ellipitcal arc in Rhino, but the parameters to define one are there:
From converter.js in viewer:


Ellipse( args, cb ) {
    let xRadius = args.obj.firstRadius
    let yRadius = args.obj.secondRadius
    let startAngle = args.obj.startAngle
    let endAngle = args.obj.endAngle
    let v1 = new THREE.Vector3( 0, 0, 1 )
    let v2 = new THREE.Vector3( ...args.obj.plane.Normal.value )
    let q = new THREE.Quaternion( )
    q.setFromUnitVectors( v1, v2 )
    let curve = new THREE.EllipseCurve( 0, 0, radius, radius, startAngle, endAngle, false, 0 )
    let points = curve.getPoints( 50 )
    let geometry = new THREE.Geometry( ).setFromPoints( points )
    let arc = new THREE.Line( geometry, args.layer.threeLineMaterial )
    arc.geometry.applyMatrix( new THREE.Matrix4( ).makeRotationFromQuaternion( q ) );
    arc.geometry.applyMatrix( new THREE.Matrix4( ).makeTranslation( ...args.obj.plane.Origin.value ) );
    arc.hash = args.obj.hash
    cb( null, arc )
  },
didimitrie commented 6 years ago

Re Circles: Speckle does some back to Rhino Geometry conversion basics to be able to keep user data safely.

Therefore, when you receive a circle in Gh/Rh, it gets converted into a ArcCurve, which according the rhino sdk, "represents circles and arcs". I knew there was a reason for this! The problem with casting it back to a normal Circle is that Circles are some sort of structs, and you cannot assign user dictionaries to them.

It's something that hopefully one day will be cleared & cleaned up on the rhino side...

Re Ellipses, i couldn't get mine showing up in the viewer either. image

vs

image

Here is the ref stream. We'll dig into this.

didimitrie commented 6 years ago

Can we have a status update on this one? I think most of the fixable stuff is fixed, so I will close but will reopen if needed.

I would keep viewer considerations in a different issue in https://github.com/speckleworks/SpeckleViewer.