Hello everyone,
I've managed to construct offsets for non-planar helix-like lines. This is because MakeOffset() doesn't work with non-planar curves.
My method involved using Geom_OffsetCurve() and creating arcs at the end of two parallel curves to put it simply.
The result is an offset wire with a certain radius.
Here's an illustration of the result with the input curve on the inside and the output wire on the outside:
I implemented this using PythonOCC and the following is my code:
However, I'm encountering a challenge when trying to fill this wire using BRepFill_Filling(). The output face appears curved and exhibits noticeable dips and rises.
I've attached images to better illustrate this issue:
Ideally, I want to achieve a more planar face that doesn't have these curves.
Here's an example of what I'm aiming for:
Could I be doing something wrong, or is it simply impossible to achieve the result I'm aiming for?
I would greatly appreciate any guidance or suggestions on this matter.
I've managed to construct offsets for non-planar helix-like lines. This is because MakeOffset() doesn't work with non-planar curves.
My method involved using Geom_OffsetCurve() and creating arcs at the end of two parallel curves to put it simply.
The result is an offset wire with a certain radius.
Here's an illustration of the result with the input curve on the inside and the output wire on the outside:
I implemented this using PythonOCC and the following is my code:
Code:
def make_offset(input_curve, radius):
# Calculate the two parallel curves using Geom_OffsetCurve
parallel_1 = Geom_OffsetCurve(input_curve, radius, gp_Dir(0, 0, 1))
parallel_2 = Geom_OffsetCurve(input_curve, radius, gp_Dir(0, 0, -1))
# Close the parallel curves with arcs of the same radius
parallel_1_start = parallel_1.Value(parallel_1.FirstParameter())
parallel_2_start = parallel_2.Value(parallel_2.FirstParameter())
parallel_1_end = parallel_1.Value(parallel_1.LastParameter())
parallel_2_end = parallel_2.Value(parallel_2.LastParameter())
# Get tangent vectors for the parallel curves
vec1 = get_tangent_vector(input_curve, input_curve.FirstParameter())
vec2 = get_tangent_vector(input_curve, input_curve.LastParameter())
# Make arcs from two points and vector
arc1 = GC_MakeArcOfCircle(parallel_1_start, vec1.Reversed(), parallel_2_start).Value()
arc2 = GC_MakeArcOfCircle(parallel_2_end, vec2, parallel_1_end).Value()
# Fill offset
fill = BRepFill_Filling()
fill.Add(BRepBuilderAPI_MakeEdge(parallel_1).Edge(), GeomAbs_C0)
fill.Add(BRepBuilderAPI_MakeEdge(arc1).Edge(), GeomAbs_C0)
fill.Add(BRepBuilderAPI_MakeEdge(parallel_2).Edge(), GeomAbs_C0)
fill.Add(BRepBuilderAPI_MakeEdge(arc2).Edge(), GeomAbs_C0)
fill.Build()
face = fill.Face()
# Make a wire from the parallel curves and arcs
wire_builder = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(arc2).Edge())
wire_builder.Add(BRepBuilderAPI_MakeEdge(parallel_1).Edge())
wire_builder.Add(BRepBuilderAPI_MakeEdge(arc1).Edge())
wire_builder.Add(BRepBuilderAPI_MakeEdge(parallel_2).Edge())
wire = wire_builder.Wire()
return wire, face
However, I'm encountering a challenge when trying to fill this wire using BRepFill_Filling(). The output face appears curved and exhibits noticeable dips and rises.
I've attached images to better illustrate this issue:
Ideally, I want to achieve a more planar face that doesn't have these curves.
Here's an example of what I'm aiming for:
Could I be doing something wrong, or is it simply impossible to achieve the result I'm aiming for?
I would greatly appreciate any guidance or suggestions on this matter.