Isocurve outside the Surface

Forums: 

Hello
Idk why my isocurve lies outside the surface. I have attached images for reference.

from OCC.Display.SimpleGui import init_display
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire
from OCC.Core.TColgp import TColgp_Array1OfPnt
from OCC.Core.gp import gp_Pnt
from OCC.Core.Geom import Geom_BezierCurve
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_ThruSections
from OCC.Core.BRepAdaptor import BRepAdaptor_Surface
from OCC.Core.Adaptor3d import Adaptor3d_IsoCurve
from OCC.Core.GeomAbs import GeomAbs_IsoU, GeomAbs_IsoV
from OCC.Core.TopExp import TopExp_Explorer
from OCC.Core.TopAbs import TopAbs_FACE

display, start_display, add_menu, add_function_to_menu = init_display()
def create_curve(points):
array_of_points = TColgp_Array1OfPnt(1, len(points))
for i, point in enumerate(points):
array_of_points.SetValue(i + 1, gp_Pnt(*point))
curve = Geom_BezierCurve(array_of_points)
edge_builder = BRepBuilderAPI_MakeEdge(curve)
return edge_builder.Edge()

# Define control points for two Bezier curves
points_curve1 = [(0, 0, 0), (1, 2, 0), (3, -1, 0), (4, 1, 0)]
points_curve2 = [(0, 3, 0), (1, 0, 0), (3, 4, 0), (4, 2, 0)]

# Create curves
curve1 = create_curve(points_curve1)
curve2 = create_curve(points_curve2)

wire = BRepBuilderAPI_MakeWire()
wire.Add(curve1)

wire2 = BRepBuilderAPI_MakeWire()
wire2.Add(curve2)

# Create the generator and add wires
generator1 = BRepOffsetAPI_ThruSections(False, True)
generator1.AddWire(wire.Wire()) # Extract the wire using the Wire() method
generator1.AddWire(wire2.Wire()) # Extract the wire using the Wire() method

# Build the shape
generator1.Build()
S1 = generator1.Shape()

explorer = TopExp_Explorer(S1, TopAbs_FACE)
faces=[]
while explorer.More():
face = explorer.Current()
faces.append(face)
explorer.Next()

# Assuming you want to draw an iso-curve on the first face
face1 = faces[0]

# Create an Adaptor3d_Surface from the B-spline surface
adaptor_surface = BRepAdaptor_Surface(face1, True)

# Choose a parameter value (u or v) for the isoparametric curve
parameter_value = 0.7 # You can adjust this value as needed
parameter_value1 = 0.9

# Create the isoparametric curve using Adaptor3d_IsoCurve
iso_curve = Adaptor3d_IsoCurve(adaptor_surface, GeomAbs_IsoU, parameter_value)
iso_curve1 = Adaptor3d_IsoCurve(adaptor_surface, GeomAbs_IsoV, parameter_value1)

bspline_curve1 = iso_curve.BSpline()
bspline_curve = iso_curve1.BSpline()

display.DisplayShape(S1, update=True)
display.DisplayShape(bspline_curve, update=False)
display.DisplayShape(bspline_curve1, update=False)

start_display()

Attachments: 
gkv311 n's picture

Adaptor3d_IsoCurve defines analythical iso-curve on a surface with specified clipping range (optional arguments, not used within your code snippet). It doesn't take into account Wires, defining Face boundaries, nor inner holes - it considers only input Surface. Therefore, the curve may pass through holes and Face boundaries unclipped.

Satoru Tobo's picture

Could you do it in the code provided?

Satoru Tobo's picture

Thank you for the help!
But how to use these boundaries
I tried this approach but still getting the same result.

w_first = 0
w_last = 1

# Create the isoparametric curve using Adaptor3d_IsoCurve
iso_curve = Adaptor3d_IsoCurve(adaptor_surface, GeomAbs_IsoU, parameter_value, w_first, w_last)
iso_curve1 = Adaptor3d_IsoCurve(adaptor_surface, GeomAbs_IsoV, parameter_value1, w_first, w_last)

Even though i checked the First and Last parameter for my curves
Still same result.
Plz help!