Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing "Solid Section" node #4878

Merged
merged 8 commits into from
Jan 17, 2023
Merged

Conversation

rendetto
Copy link
Contributor

@rendetto rendetto commented Jan 16, 2023

Solid Section

SectionNodeMenuV2

The node will generate Curves and Points from intersecting different Shapes including Solids, Solid Faces, Solid Edges, NURBS Surfaces and NURBS Curves.

This node can operate on pair of objects ("Shape A" intersects "Shape B") or on pair of lists of objects.

Inputs

The node has the following inputs:

  • Shape A. The first object to perform operation on. This input is
    mandatory and can accept a list of Shapes*.

  • Shape B. The second object to perform operation on. This input is
    mandatory and can accept a list of Shapes*.

    Curves (NURBS Curves and Solid Edges) cannot be mixed with other Shape types.
    For example [NURBS_Curve, Solid_Edge, Solid] is not a valid input list.

    Valid inputs are [NURBS_Curve1, NURBS_Curve2, Solid_Edge] or [NURBS_Curve, Solid_Edge]
    or [NURBS_Surface1, Solid, NURBS_Surface2] etc.

Options

This node has the following parameters:

  • NURBS Output. This parameter is available in the N panel only. If
    checked, the node will generate curves in NURBS representation. Otherwise, it
    will generate standard FreeCAD curves (Solid Edge curves). Unchecked by default.

Outputs

The has the following outputs:

  • Vertices. The resulting intersection (puncture) Points or endpoints of the intersection Curves.
  • Curves. The resulting intersection Curves.

Product variations of the Section operation:

  • Solid × Curve → Point (common case) or Curve (if the curve or part of the curve overlays with the solid)

  • Solid × Surface → Curve (common case) or Point (when both are only touching)

  • Curve × Surface → Point (common case) or Curve (if the curve or part of the curve overlays with the surface)

  • Solid × Solid → Curve (common case) or Point (when both are only touching)

  • Surface × Surface → Curve (common case) or Point (when both are only touching)

  • Curve × Curve → Point (common case) or Curve (if curves overlay at a certain segment)

If no intersections are found the node will output empty lists.

Examples

Curve × CurvePoints:
SVSectionNode_CurveXCurve

Curves × SurfacePoints and Curve:
SVSectionNode_CurveXSurface

Surface × List of SurfaceCurves:
SVSectionNode_SurfaceXListOfSurfaces

Surface × SolidCurves:
SVSectionNode_SurfaceXSolid

@rendetto
Copy link
Contributor Author

I'm not sure how to read this failing test:

FAIL: test_full_menu_presets (ui_tests.UiTests) (path='/home/runner/work/sverchok/sverchok/installation/blender/2.93/scripts/addons/sverchok/menus/full_nortikin.yaml')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/sverchok/sverchok/installation/blender/2.93/scripts/addons/sverchok/tests/ui_tests.py", line 100, in test_full_menu_presets
    self.assertEqual(preset_nodes, index_nodes)
AssertionError: Items in the second set but not the first:
'SvSolidSectionNode'

I replicated how SvSolidBooleanNode was done and didn't expected this error. Is it a show stopper?

@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

At last run tests are passed.

...and some minor changes.
@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

@rendetto should we merge this, or maybe you want to add something?

@rendetto
Copy link
Contributor Author

rendetto commented Jan 17, 2023

Err.. maybe it will be more appropriate to rename make_solid to make_section? I'll make one final pass for more appropriate variable and method names.

@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

okay, then please add a comment here when you think it will be ready for merge.

Add more appropriate variable and method names.
@rendetto
Copy link
Contributor Author

@portnov I just did the renaming pass. I'm feeling a bit uncomfortable as I'm replacing the term "Solid" with the term "Shape". Will you approve this terminology twist?

@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

ok.

@rendetto
Copy link
Contributor Author

In that case please merge it. I don't plan adding more things at this stage. Thanks a lot for the help!

@portnov portnov merged commit c1d5d38 into nortikin:master Jan 17, 2023
@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

@rendetto FYI.
Screenshot_20230117_234903
It seems FreeCAD finds the intersection line just point-by-point, and gives us degree-1 curve, i.e. just a polyline with a lot of points. Well, it's better than nothing :)

@portnov
Copy link
Collaborator

portnov commented Jan 17, 2023

This is how one can make a more nice curve.
Screenshot_20230117_235906

@rendetto
Copy link
Contributor Author

rendetto commented Jan 17, 2023

It seems FreeCAD finds the intersection line just point-by-point, and gives us degree-1 curve, i.e. just a polyline with a lot of points.

Yes, I just checked this with FreeCAD and that's what Section operation does there too. BUT also noticed that there is an option in the tool to approximate the result. I did a quick search and found approximate( ) method in TopoShape API. It doesn't seem to have any parameters but it looks like it could be a valid option that we can use.

FreeCADApproximateSection

EDIT: It seems that this approximate( ) method is not directly usable ...or at least I failed to do that.

@portnov
Copy link
Collaborator

portnov commented Jan 18, 2023

@rendetto there is approximate method in FreeCAD.Part.BSplineCurve class. It may be of use.
But that should, I think, be used in Sverchok as yet another implementation of "Approximate NURBS Curve" node, in addition to SciPY and Geomdl.

approximate(...)
    Replaces this B-Spline curve by approximating a set of points.
    The function accepts keywords as arguments.
     
    [approximate](http://localhost:8080/Part.html#BSplineCurve-approximate)(Points = list_of_points)
     
    Optional arguments :
     
    DegMin = integer (3) : Minimum degree of the curve.
    DegMax = integer (8) : Maximum degree of the curve.
    Tolerance = float (1e-3) : approximating tolerance.
    Continuity = string ('C2') : Desired continuity of the curve.
    Possible values : 'C0','G1','C1','G2','C2','C3','CN'
     
    LengthWeight = float, CurvatureWeight = float, TorsionWeight = float
    If one of these arguments is not null, the functions approximates the
    points using variational smoothing algorithm, which tries to minimize
    additional criterium:
    LengthWeight*CurveLength + CurvatureWeight*Curvature + TorsionWeight*Torsion
    Continuity must be C0, C1(with DegMax >= 3) or C2(with DegMax >= 5).
     
    Parameters = list of floats : knot sequence of the approximated points.
    This argument is only used if the weights above are all null.
     
    ParamType = string ('Uniform','Centripetal' or 'ChordLength')
    Parameterization type. Only used if weights and Parameters above aren't specified.
     
    Note : Continuity of the spline defaults to C2. However, it may not be applied if
    it conflicts with other parameters ( especially DegMax ).

@rendetto
Copy link
Contributor Author

there is approximate method in FreeCAD.Part.BSplineCurve class. It may be of use.
But that should, I think, be used in Sverchok as yet another implementation of "Approximate NURBS Curve" node, in addition to SciPY and Geomdl.

Yes, it sounds most appropriate for it to be there. I don't feel confident enough to dive into such thing yet :/
It looks like an interesting alternative and yet it will do similar things so it's not crucial but nice to have.
I found that CurvesWB is using the method and at first glance it works pretty good. Unfortunately the only way to compare the ones we have with this one is to have them all in.

@portnov
Copy link
Collaborator

portnov commented Jan 18, 2023

You can always experiment by use of scripted node.

@portnov portnov added the Solids label Jan 18, 2023
@rendetto
Copy link
Contributor Author

Yeah, I already started gathering the info and reading about but don't know If I will succeed. Too many new things and almost zero experience :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants