vcCurveData

vcCurveData provides access to mathematical information used for rendering curves and curved surfaces in components.

Curve Types

The types of curves supported in the 3D world are:

  • Spline
  • Polyline
  • Non-uniform rational basis spline (NURBS)

Access

You can use the CurveData property of a vcCompactLineSet object to get a handle for a vcCurveData object.

Methods

Name Return Type Parameters Description
clearCurves None None Removes all curves from set.
createCurveNurbs Integer Integer degree, List of vcVector pts Adds a new NURBS to set, and then returns the index of curve in set.
createCurvePolyLine Integer List of vcVector pts Adds a new polyline to set, and then returns the index of curve in set.
createCurveSpline Integer Integer degree, List of vcVector pts, List of Integer multiplicities, List of Real knots, List of Real weights Adds a new spline to set, and then returns the index of curve in set.
deleteCurve None Integer curve Deletes a curve at a given index in set.

Note: Update the scene in order to show visualization changes in the 3D world.

getCurveEnds 4-tuple (vcVector pt1, vcVector pt2, Real w1, Real w2) Integer curve Returns curve end point information for a curve at a given index in set.

The information defines both curve endpoint vectors and their weight values, for example if a NURBS curve is selected.

getCurveLength Real Integer curve Returns the length of a curve at a given index in set.
getCurveMinCurveDistance 3-tuple (Real min_dist, Real curve_dist, Real othercurve_dist) Integer curve, Integer othercurve Returns the minimum distance between two curves at given indices in set.

The returned value describes the minimum distance between curves and minimum distance between either end points of curves.

getCurveMinDistance 2-tuple (Real min_dist_to_point, Real curve_dist) Integer curve, vcVector point Returns the minimum distance of a curve at a given index in set to a given point as well as the length of curve.
getCurvePoint vcVector Integer curve, Real distance Returns a point on a curve at a given index in set and distance from beginning of curve.
getCurvePointAndDerivate 2-tuple(vcVector point, vcVector derivate) Integer curve, Real distance Returns a point and first derivate vector of a curve at a given index in set and distance from beginning of curve.
getCurvePointCount Integer Integer curve Returns the total number of points for a curve at a given index in set.
getCurvePositions List of vcMatrix Integer curve Returns a list of position matrices for each point on a curve at a given index in set.

getCurveType Enumeration Integer curve Returns the type of curve at a given index in set.

See Topology Constants for more information.

getPolyLineCurvePoints List of vcVector Integer curve Returns a list of points for a polyline at a given index in set; otherwise returns an empty list.
getSplineCurveControlPoint List of vcVector Integer curve Returns a list of control points for a spline at a given index in set; otherwise returns an empty list.
getSplineCurveControlWeights List of Real Integer curve Returns a list of control weight values for a spline at a given index in set; otherwise returns an empty list.
getSplineCurveDegree Integer Integer curve Returns the degree of a spline at a given index in set.
getSplineCurveKnots 2-tuple (List of Integer multiplicities, List of real knots) Integer curve Returns spline knot multiplicities (knot recurrence) and knot values for a curve at a given index in set.

Examples

Example. Create and access curve data

#Create a Geometry feature then a Python script behavior

#Copy the following script in the Python script

from vcScript import *

import vcVector

comp = getComponent()

geof = comp.getFeature("Geometry")

tset = None

if geof.Geometry.GeometrySetCount == 0:

  cset = geof.Geometry.createGeometrySet(VC_COMPACTLINESET)

else:

  cset = geof.Geometry.GeometrySets[0]

# Get Curve interface

curves = cset.CurveData

print "0. Curve count"

print "CurveCount = ", curves.CurveCount

print "1. Clear curves"

curves.clearCurves()

print "CurveCount = ", curves.CurveCount

print "2. Create Curve"

# Define curve degree

Degree = 3

# Add knot values and multipliers

Knots = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]

KnotMultiplicities = [4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4]

# Add control points

pts = []

pts.append(vcVector.new(12438, 0, 4622.7))

pts.append(vcVector.new(12409, 0, 4519.525))

pts.append(vcVector.new(11815, 0, 3660))

pts.append(vcVector.new(11193, 0, 2970))

pts.append(vcVector.new(10570, 0, 1880))

pts.append(vcVector.new(9948, 0, 518))

pts.append(vcVector.new(9325, 0, 0))

pts.append(vcVector.new(8703, 0, 0))

pts.append(vcVector.new(8080, 0, 0))

pts.append(vcVector.new(7458, 0, 0))

pts.append(vcVector.new(6835, 0, 0))

pts.append(vcVector.new(6213, 0, 0))

pts.append(vcVector.new(5590, 0, 0))

pts.append(vcVector.new(4968, 0, 0))

pts.append(vcVector.new(4345, 0, 0))

pts.append(vcVector.new(3723, 0, 0))

pts.append(vcVector.new(3100, 0, 0))

pts.append(vcVector.new(2478, 0, 0))

pts.append(vcVector.new(1855, 0, 0))

pts.append(vcVector.new(1233, 0, 0))

pts.append(vcVector.new(610, 0, 0))

pts.append(vcVector.new(339, 0, 1000))

pts.append(vcVector.new(246, 0, 1550))

pts.append(vcVector.new(210, 0, 1780))

weigths = []

curve = curves.createCurveSpline(Degree, pts, KnotMultiplicities, Knots, weigths)

print "Curve created ",curve

pts = []

pts.append(vcVector.new(300, 100, 100))

pts.append(vcVector.new(600, 50, 200))

pts.append(vcVector.new(900, 0, 400))

pts.append(vcVector.new(1000, -20, 900))

curve2 = curves.createCurveNurbs(Degree, pts)

print "Curve2 created ",curve2

print "3. Get curve length"

length = curves.getCurveLength(curve)

print "Curve length = ",length

print "4. Get curve ends"

sp, ep, sw, ew = curves.getCurveEnds(curve)

print "Curve start point(",sp.X,",",sp.Y,",",sp.Z,") weight = ",sw

print "Curve end point(",ep.X,",",ep.Y,",",ep.Z,") weight = ",ew

print "5. Get point at curve using distance"

p = curves.getCurvePoint(curve, length*0.5)

print "Curve point(",p.X,",",p.Y,",",p.Z,")"

print "6. Get point minimum projected distance to curve"

point = vcVector.new(10000,0,500)

min_dist, dist = curves.getCurveMinDistance(curve, point)

print "Curve Min distance ",min_dist," at curve distance ",dist

p = curves.getCurvePoint(curve, dist)

print "Curve projected point(",p.X,",",p.Y,",",p.Z,")"

print "7. Get curve point and derivate"

p, d = curves.getCurvePointAndDerivate(curve, 15000)

print "Curve point(",p.X,",",p.Y,",",p.Z,")"

print "Curve normalized derivate(",d.X,",",d.Y,",",d.Z,")"

print "8. Get two curves minimum distance"

min_dist, dist1, dist2 = curves.getCurveMinCurveDistance(curve, curve2)

print "Curve & curve2 Min distance ",min_dist," at curve dist1 ",dist1, " dist2 ",dist2

p1 = curves.getCurvePoint(curve, dist1)

print "Curve projected point(",p1.X,",",p1.Y,",",p1.Z,")"

p2 = curves.getCurvePoint(curve2, dist2)

print "Curve2 projected point(",p2.X,",",p2.Y,",",p2.Z,")"

pts = []

pts.append(p1)

pts.append(p2)

curve3 = curves.createCurveNurbs(1, pts)

print "Curve3 created ",curve3

cset.update()

comp.rebuild()

# Inquiry curve information

print

print "CurveCount=",curves.CurveCount

print

for c in range(0,curves.CurveCount):

  print "Curve[",c,"]"

  type = curves.getCurveType(c)

  if type == VC_CURVE_POLYLINE:

    print " Type=Polyline"

    for p in curves.getPolyLineCurvePoints(c):

      print " P(",p.X,",",p.Y,",",p.Z,")"

  if type == VC_CURVE_SPLINE:

    print " Type=Spline"

    print " Degree=",curves.getSplineCurveDegree(c)

    for p in curves.getSplineCurveControlPoints(c):

      print " P(",p.X,",",p.Y,",",p.Z,")"

    weights = curves.getSplineCurveControlWeights(c)

    print " Weights=",weights

    knots,kms = curves.getSplineCurveKnots(c)

    print " Knots=",knots

    print " Kms=",kms