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

"Bevel a Curve (Surface)" node et al #4268

Merged
merged 20 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/nodes/modifier_make/bevel_curve.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Bevel a Curve
=============
Bevel a Curve (Mesh)
====================

Functionality
-------------
Expand Down
175 changes: 175 additions & 0 deletions docs/nodes/surface/bevel_curve.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
Bevel a Curve (Surface)
=======================

Functionality
-------------

This node provides functionality similar to Blender's standard "bevel curve"
feature_. More precisely, it extrudes one flat curve (called "profile curve")
along another curve (path). Scale of "profile curve" may vary along the curve,
as it is controlled by third curve (called "taper curve").

.. _feature: https://docs.blender.org/manual/en/latest/modeling/curves/properties/geometry.html

It is in general not a trivial task to rotate a 3D object along a vector,
because there are always 2 other axes of object and it is not clear where
should they be directed to. So, this node supports 3 different algorithms of
object rotation calculation. In many simple cases, all these algorithms will
give exactly the same result. But in more complex setups, or in some corner
cases, results can be very different. So, just try all algorithms and see which
one fits you better.

* "Frenet" or "Zero-Twist" algorithms give very good results in case when
extrusion curve has non-zero curvature in all points. If the extrusion curve
has zero curvature points, or, even worse, it has straight segments, these
algorithms will either make "flipping" surface, or give an error.
* "Householder", "Tracking" and "Rotation difference" algorithms are
"curve-agnostic", they work independently of curve by itself, depending only
on tangent direction. They give "good enough" result (at least, without
errors or sudden flips) for all extrusion curves, but may make twisted
surfaces in some special cases.
* "Track normal" algorithm is supposed to give good results without twisting
for all extrusion curves. It will give better results with higher values of
"resolution" parameter, but that may be slow.

**Note 1**: Taper is supposed to be an open Curve, elongated along one of
coordinate axes (X, Y or Z). That must be the orientation axis, i.e. the axis
perpendicular to the plane of bevel object.

In the most common case, "profile curve" will lay in XY plane, so that
orientation axis will be Z.

This node can function in several modes:

* Generic surface. In this mode, the node can process arbitrary Curve objects,
and will generate a generic Surface object.
* NURBS surface by simple algorithm. In this mode, the node can process only
NURBS or NURBS-like curves, and will generate a NURBS surface. This algorithm
generates a minimal amount of control points; so, the generated surface may
follow the path curve only approximately. On the other hand, this is the
fastest of NURBS modes of this node.
* NURBS surface with refinement. In this mode, the node can process only
NURBS or NURBS-like curves, and will generate a NURBS surface. This algorithm
first refines taper curve (i.e., adds some number of additional knots in it),
and then applies the "simple" algorithm. This algorithm produces more control
points, and that allows it to generate a surface which follows the path and
taper curves more precisely.
* NURBS Gordon surface:

* Refine taper curve;
* Generate a number of copies of taper curve, bent along the path curve, and
rotated around it, according to the profile curve.
* Generate a number of copies of profile curve, rotated and placed along the
path curve, scaled according to the taper curve.
* Use these two series of curves to generate a surface by use of Gordon
algorithm.

For smooth curves, Gordon algorithm is supposed to be the most precise of
NURBS modes of this node; but it is also the slowest one.

**Note 2**: Gordon algorithm does not support use of rational curves as either
profile or taper.

**Note 3**: Gordon algorithm can not produce surfaces with hard edges. If
you provide it with profile curve which has hard turns (discontinuities of
curve's derivative), the output will look weird.

With last two modes, this node can generate a surface with large number of
control points. It can be wise to use "Remove excessive knots" node to simplify
the surface.

Inputs
------

This node has the following inputs:

* **Path**. Path curve. This input is mandatory.
* **Profile**. Profile curve. This input is mandatory.
* **Taper**. Taper curve. If this input is not connected, constant taper will
be used.
* **Resolution**. Path length calculation resolution. This input is available
only when **Samples distribution** parameter is set to **Curve length**. The
default value is 50.
* **ProfileCopies**. This input is available only when **Mode** parameter is
set to **NURBS**, and **Precision** parameter is set to **Gordon**. Number of
copies of profile curve to be generated and distributed along the path curve,
in order to build a Gordon surface. The default value is 10.
* **TaperRefine**. This input is available only when **Mode** parameter is
set to **NURBS**, and **Precision** parameter is set to **Refine** or
**Gordon**. Number of additional knots to be inserted in the taper curve. The
default value is 20.
* **TaperCopies**. This input is available only when **Mode** parameter is
set to **NURBS**, and **Precision** parameter is set to **Gordon**. Number of
copies of the taper curve to be rotated and bent along the path curve, in
order to build a Gordon surface. The default value is 10.

Parameters
----------

This node has the following parameters:

* **Mode**. The following modes are available:

* **Generic**. The node will process arbitrary curves and output a generic
Surface object.
* **NURBS**. The node will process NURBS or NURBS-like curves and output a
NURBS surface.

The default mode is **Generic**.

* **Precision**. This parameter is only available when **Mode** algorithm is
set to **NURBS**. Defines the algorithm to be used to generate control points
of the NURBS surface. The available options are: **Simple**, **Refine** and
**Gordon**. See Functionality section for description of these algorithms.
* **Orientation**. The axis of "bevel object", which should be oriented along
the path. Default value is Z (which means that bevel object should lay in XY plane).
* **Algorithm**. Rotation calculation algorithm. Available values are:

* Householder: calculate rotation by using Householder's reflection matrix
(see Wikipedia_ article).
* Tracking: use the same algorithm as in Blender's "TrackTo" kinematic
constraint. This algorithm gives you a bit more flexibility comparing to
other, by allowing to select the Up axis.
* Rotation difference: calculate rotation as rotation difference between two
vectors.
* Frenet: rotate the space according to curve's Frenet frame.
* Zero-Twist: rotate the space according to curve's "zero-twist" frame.
* Track normal: try to maintain constant normal direction by tracking it along the curve.

Default value is Householder.

* **Up axis**. Axis of donor object that should point up in result. This
parameter is available only when Tracking algorithm is selected. Value of
this parameter must differ from **Orientation** parameter, otherwise you will
get an error. Default value is X.
* **Samples distribution**. This defines how the scaling of the space along the path
curve is to be calculated. The available options are:

* **Curve parameter**. Scale the space proportional to curve's T parameter.
* **Curve length**. Scale the space proportional to curve's length. This
usually gives more natural results, but takes more time to compute.

The default option is **Curve parameter**.

.. _Wikipedia: https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections

Outputs
-------

This node has the following output:

* **Surface**. The generated Surface object.

Examples of Usage
-----------------

Example 1:

.. image:: https://user-images.githubusercontent.com/284644/128608455-8bcf578f-6de4-4f28-a7aa-c5c0737d998e.png

Example 2:

.. image:: https://user-images.githubusercontent.com/284644/128609193-25240b31-1e4f-49d3-81f0-0df70863ccec.png

.. image:: https://user-images.githubusercontent.com/284644/128609192-06d65d48-7875-4dce-a084-c4e4c700be04.png

1 change: 1 addition & 0 deletions docs/nodes/surface/surface_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Surface
interpolating_surface
revolution_surface
taper_sweep
bevel_curve
extrude_vector
extrude_point
extrude_curve
Expand Down
19 changes: 19 additions & 0 deletions docs/nodes/surface/taper_sweep.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ This node has the following inputs:
* **Point**. The point on the taper axis line. The default value is `(0, 0, 0)`.
* **Direction**. The directing vector of the taper axis line. The default value is `(0, 0, 1)` (Z axis).

Parameters
----------

This node has the following parameters:

* **NURBS**. If enabled, the node will expect NURBS (or NURBS-like) curves as
input, and output a NURBS surface. Otherwise, the node can process arbitrary
curves, and will output a generic Surface object. Unchecked by default.
* **Scale**. This defines the scale of resulting surface in the plane
perpendicular to taper axis. The available options are:

* **Unit**.
* **Profile**. The surface will be scaled in order to match the profile curve.
* **Taper**. The surface will be scaled in order to match the taper curve.

Outputs
-------

Expand All @@ -40,3 +55,7 @@ The taper curve is generated by "filleting" some line; the profile curve is fill

.. image:: https://user-images.githubusercontent.com/284644/79348542-8ee88080-7f4e-11ea-972b-50b9d6909734.png

Example of NURBS mode:

.. image:: https://user-images.githubusercontent.com/284644/128603194-ae5b6c3f-a4f8-43ae-89f9-00bb0ac05953.png

1 change: 1 addition & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
---
SvExRevolutionSurfaceNode
SvExTaperSweepSurfaceNode
SvBendCurveSurfaceNode
SvExExtrudeCurveVectorNode
SvExExtrudeCurveCurveSurfaceNode
SvExExtrudeCurvePointNode
Expand Down
4 changes: 2 additions & 2 deletions nodes/modifier_make/bevel_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
class SvBevelCurveNode(bpy.types.Node, SverchCustomTreeNode):
"""
Triggers: Bevel Curve
Tooltip: Bevel a Curve (a.k.a. Extrude along Path)
Tooltip: Bevel a Curve (a.k.a. Extrude along Path) - mesh
"""

bl_idname = 'SvBevelCurveNode'
bl_label = 'Bevel a Curve'
bl_label = 'Bevel a Curve (Mesh)'
bl_icon = 'MOD_CURVE'

algorithms = [
Expand Down
Loading