def main():
    fname = os.path.basename(__file__)
    name = os.path.splitext(fname)[0]

    points1 = [[0.0, 0.0, 0.0], [1.0, 0.1, 0.0], [2.0, 0.1, 0.0], [3.0, 0.1, 0.0]]
    curve1_ptr = geometry_factory.CreateCurve(points1, 2)
    curve1 = curve1_ptr.GetReference()
    curve1.Id = 1
    mpatch_export3.Export(curve1_ptr, name + "_curve1.m")

    points2 = [[0.0, 3.0, 0.0], [0.5, 1.0, 0.0], [1.0, 0.1, 0.0], [2.0, -1.0, 0.0], [3.0, -3.0, 0.0]]
    curve2_ptr = geometry_factory.CreateCurve(points2, 2)
    curve2 = curve2_ptr.GetReference()
    curve2.Id = 2
    mpatch_export3.Export(curve2_ptr, name + "_curve2.m")

    intersect_util = IsogeometricIntersectionUtility()
    [stat, points] = intersect_util.ComputeIntersection(0.5, 0.5, curve1_ptr, curve2_ptr, 30, 1.0e-6, 0)

    print("stat:", stat) # 0 is OK
    print("points:", points)

    gf1 = curve1.GridFunction(CONTROL_POINT)
    P1 = gf1.GetValue([points[0]])
    print("P1:", str(P1))

    gf2 = curve2.GridFunction(CONTROL_POINT)
    P2 = gf2.GetValue([points[1]])
    print("P2:", str(P2))
def CreatePatch():
    ## generate trajectory curve
    cpoints = []
    cpoints.append([0.0, 0.0, 0.0])
    cpoints.append([0.0, 0.0, 1.0])
    cpoints.append([1.0, 1.0, 2.0])

    order = 2
    curve_ptr = geometry_factory.CreateCurve(cpoints, order)
    curve = curve_ptr.GetReference()
    curve.Prefix = "curve"
    mpatch_export3.Export(curve, "curve.m")

    ## generate the local Frenet frame along the trajectory
    npoints = 10
    trans_list = geometry_factory.GenerateLocalFrenetFrame(curve, npoints)
    for trans in trans_list:
        print(trans)
    geometry_factory.ExportLocalFrenetFrameToMatlab(trans_list, "frame.m",
                                                    2e-1)

    ## generate a list of cut section
    rin = 0.5
    rout = 1.0
    start_angle = 45
    end_angle = 90
    axis = "z"
    ring_patches = []
    for i in range(0, npoints):
        ring_ptr = geometry_factory.CreateSmallRing([0.0, 0.0, 0.0], axis, rin,
                                                    rout, start_angle,
                                                    end_angle)
        ring = ring_ptr.GetReference()
        ring.Id = i + 1
        ring.Prefix = "ring"
        ring.ApplyTransformation(trans_list[i])
        # mpatch_export3.Export(ring, ring.Name() + "_def.m")
        ring_patches.append(ring_ptr)

    ## create the sweep volume
    order_w = 2
    vol_ptr = bsplines_patch_util.CreateConnectedPatch(ring_patches, order_w)
    return vol_ptr
Example #3
0
def main():
    fname = os.path.basename(__file__)
    name = os.path.splitext(fname)[0]

    points = [[0.0, 3.0, 0.0], [0.5, 1.0, 0.0], [1.0, 0.1, 0.0],
              [2.0, -1.0, 0.0], [3.0, -3.0, 0.0]]
    curve_ptr = geometry_factory.CreateCurve(points, 2)
    curve = curve_ptr.GetReference()
    curve.Id = 1
    mpatch_export3.Export(curve_ptr, name + "_curve.m")

    intersect_util = IsogeometricIntersectionUtility()
    A = 0.0
    B = 1.0
    C = 0.0
    D = 3.0  # -1.0
    [stat, point] = intersect_util.ComputeIntersection(0.5, curve_ptr, A, B, C,
                                                       D, 30, 1.0e-6)
    print("stat:", stat)  # 0 is OK
    print("point:", point)

    gf = curve.GridFunction(CONTROL_POINT)
    P = gf.GetValue(point)
    print("P:", str(P))