本文整理汇总了C#中Curve.GetEndPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Curve.GetEndPoint方法的具体用法?C# Curve.GetEndPoint怎么用?C# Curve.GetEndPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curve
的用法示例。
在下文中一共展示了Curve.GetEndPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateReversedCurve
/// <summary>
/// Create a new curve with the same
/// geometry in the reverse direction.
/// </summary>
/// <param name="orig">The original curve.</param>
/// <returns>The reversed curve.</returns>
/// <throws cref="NotImplementedException">If the
/// curve type is not supported by this utility.</throws>
static Curve CreateReversedCurve(
Autodesk.Revit.Creation.Application creapp,
Curve orig )
{
if( !IsSupported( orig ) )
{
throw new NotImplementedException(
"CreateReversedCurve for type "
+ orig.GetType().Name );
}
if( orig is Line )
{
return Line.CreateBound(
orig.GetEndPoint( 1 ),
orig.GetEndPoint( 0 ) );
}
else if( orig is Arc )
{
return Arc.Create( orig.GetEndPoint( 1 ),
orig.GetEndPoint( 0 ),
orig.Evaluate( 0.5, true ) );
}
else
{
throw new Exception(
"CreateReversedCurve - Unreachable" );
}
}
示例2: Stream
private void Stream(ArrayList data, Curve crv)
{
data.Add(new Snoop.Data.ClassSeparator(typeof(Curve)));
try
{
data.Add(new Snoop.Data.Double("Approximate length", crv.ApproximateLength));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Approximate length", ex));
}
try
{
data.Add(new Snoop.Data.Double("Length", crv.Length));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Length", ex));
}
try
{
data.Add(new Snoop.Data.Double("Period", crv.Period));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Period", ex));
}
try
{
data.Add(new Snoop.Data.Bool("Is bound", crv.IsBound));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Is bound", ex));
}
try
{
data.Add(new Snoop.Data.Bool("Is cyclic", crv.IsCyclic));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Is cyclic", ex));
}
try
{
data.Add(new Snoop.Data.Xyz("Start point", crv.GetEndPoint(0)));
data.Add(new Snoop.Data.Xyz("End point", crv.GetEndPoint(1)));
}
catch (System.Exception)
{
// if the curve is unbound, those don't mean anything
data.Add(new Snoop.Data.String("Start point", "N/A"));
data.Add(new Snoop.Data.String("End point", "N/A"));
}
try
{
data.Add(new Snoop.Data.Double("Start parameter", crv.GetEndParameter(0)));
data.Add(new Snoop.Data.Double("End parameter", crv.GetEndParameter(1)));
}
catch (System.Exception)
{
// if the curve is unbound, those don't mean anything
data.Add(new Snoop.Data.String("Start parameter", "N/A"));
data.Add(new Snoop.Data.String("End parameter", "N/A"));
}
try
{
data.Add(new Snoop.Data.Object("Start point reference", crv.GetEndPointReference(0)));
data.Add(new Snoop.Data.Object("End point reference", crv.GetEndPointReference(1)));
}
catch (System.Exception)
{
// if the curve is unbound, those don't mean anything
data.Add(new Snoop.Data.String("Start point reference", "N/A"));
data.Add(new Snoop.Data.String("End point reference", "N/A"));
}
try
{
data.Add(new Snoop.Data.Object("Reference", crv.Reference));
}
catch (System.Exception ex)
{
data.Add(new Snoop.Data.Exception("Reference", ex));
}
try
{
data.Add(new Snoop.Data.Object("Derivative at Start", crv.ComputeDerivatives(0.0, normalized: true)));
}
catch (System.Exception ex)
{
//.........这里部分代码省略.........
示例3: NewSketchPlaneContainCurve
/// <summary>
/// Return a new sketch plane containing the given curve.
/// Update, later: please note that the Revit API provides
/// an overload of the NewPlane method taking a CurveArray
/// argument, which could presumably be used instead.
/// </summary>
SketchPlane NewSketchPlaneContainCurve(
Curve curve)
{
XYZ p = curve.GetEndPoint( 0 );
XYZ normal = GetCurveNormal( curve );
Plane plane = _creapp.NewPlane( normal, p );
#if DEBUG
if( !(curve is Line) )
{
CurveArray a = _creapp.NewCurveArray();
a.Append( curve );
Plane plane2 = _creapp.NewPlane( a );
Debug.Assert( Util.IsParallel( plane2.Normal,
plane.Normal ), "expected equal planes" );
Debug.Assert( Util.IsZero( plane2.SignedDistanceTo(
plane.Origin ) ), "expected equal planes" );
}
#endif // DEBUG
//return _credoc.NewSketchPlane( plane ); // 2013
return SketchPlane.Create( _doc, plane ); // 2014
}
示例4: MaybeStretchBaseCurve
private static Curve MaybeStretchBaseCurve(Curve baseCurve, Curve trimmedCurve)
{
// Only works for bound curves.
if (!baseCurve.IsBound || !trimmedCurve.IsBound)
return null;
// The original end parameters.
double baseCurveParam0 = baseCurve.GetEndParameter(0);
double baseCurveParam1 = baseCurve.GetEndParameter(1);
// The trimmed curve may actually extend beyond the base curve at one end - make sure we extend the base curve.
XYZ trimmedEndPt0 = trimmedCurve.GetEndPoint(0);
XYZ trimmedEndPt1 = trimmedCurve.GetEndPoint(1);
Curve axisCurve = baseCurve.Clone();
if (axisCurve == null)
return null;
// We need to make the curve unbound before we find the trimmed end parameters, because Project finds the closest point
// on the bounded curve, whereas we want to find the closest point on the unbounded curve.
axisCurve.MakeUnbound();
IntersectionResult result0 = axisCurve.Project(trimmedEndPt0);
IntersectionResult result1 = axisCurve.Project(trimmedEndPt1);
// One of the intersection points is not on the unbound curve - abort.
if (!MathUtil.IsAlmostZero(result0.Distance) || !MathUtil.IsAlmostZero(result1.Distance))
return null;
double projectedEndParam0 = result0.Parameter;
double projectedEndParam1 = result1.Parameter;
double minParam = baseCurveParam0;
double maxParam = baseCurveParam1;
// Check that the orientation is correct.
if (axisCurve.IsCyclic)
{
XYZ midTrimmedPtXYZ = (trimmedCurve.Evaluate(0.5, true));
IntersectionResult result2 = axisCurve.Project(midTrimmedPtXYZ);
if (!MathUtil.IsAlmostZero(result2.Distance))
return null;
double projectedEndParamMid = (projectedEndParam0 + projectedEndParam1) / 2.0;
bool parametersAreNotFlipped = MathUtil.IsAlmostEqual(projectedEndParamMid, result2.Parameter);
bool trimmedCurveIsCCW = ((projectedEndParam0 < projectedEndParam1) == parametersAreNotFlipped);
if (!trimmedCurveIsCCW)
{
double tmp = projectedEndParam0; projectedEndParam0 = projectedEndParam1; projectedEndParam1 = tmp;
}
// While this looks inefficient, in practice we expect to do each while loop 0 or 1 times.
double period = axisCurve.Period;
while (projectedEndParam0 > baseCurveParam1) projectedEndParam0 -= period;
while (projectedEndParam1 < baseCurveParam0) projectedEndParam1 += period;
minParam = Math.Min(minParam, projectedEndParam0);
maxParam = Math.Max(maxParam, projectedEndParam1);
}
else
{
minParam = Math.Min(minParam, Math.Min(projectedEndParam0, projectedEndParam1));
maxParam = Math.Max(maxParam, Math.Max(projectedEndParam0, projectedEndParam1));
}
axisCurve.MakeBound(minParam, maxParam);
return axisCurve;
}
示例5: Mirror
/// <summary>
/// Given a curve, mirrors it along the given axis
/// </summary>
/// <param name="curve">curve to mirror</param>
/// <param name="axis">axis to mirror along</param>
/// <param name="app">revit application</param>
/// <returns>a mirrored curve</returns>
public static Curve Mirror(Curve curve, XYZ axis, Application app)
{
XYZ startPt = curve.GetEndPoint(0);
XYZ endPt = curve.GetEndPoint(1);
XYZ p = new XYZ();
XYZ newStart = null;
XYZ newEnd = null;
if (axis.Equals(GeomUtils.kXAxis)) {
newStart = new XYZ(startPt.X, -startPt.Y, startPt.Z);
newEnd = new XYZ(endPt.X, -endPt.Y, endPt.Z);
}
if (axis.Equals(GeomUtils.kYAxis)) {
newStart = new XYZ(-startPt.X, startPt.Y, startPt.Z);
newEnd = new XYZ(-endPt.X, -endPt.Y, endPt.Z);
}
if (axis.Equals(GeomUtils.kZAxis)) {
newStart = new XYZ(startPt.X, startPt.Y, -startPt.Z);
newEnd = new XYZ(endPt.X, endPt.Y, -endPt.Z);
}
return Line.CreateBound(startPt, endPt);
}
示例6: IsCurveInXYPlane
/// <summary>
/// Identifies if the curve lies entirely in an XY plane (Z = constant)
/// </summary>
/// <param name="curve">The curve.</param>
/// <returns>True if the curve lies in an XY plane, false otherwise.</returns>
public static bool IsCurveInXYPlane( Curve curve )
{
// quick reject - are endpoints at same Z
double zDelta = curve.GetEndPoint( 1 ).Z
- curve.GetEndPoint( 0 ).Z;
if( Math.Abs( zDelta ) > 1e-05 )
return false;
if( !( curve is Line ) && !curve.IsCyclic )
{
// Create curve loop from curve and
// connecting line to get plane
List<Curve> curves = new List<Curve>();
curves.Add( curve );
//curves.Add(Line.CreateBound(curve.GetEndPoint(1), curve.GetEndPoint(0)));
CurveLoop curveLoop = CurveLoop.Create( curves );
XYZ normal = curveLoop.GetPlane().Normal
.Normalize();
if( !normal.IsAlmostEqualTo( XYZ.BasisZ )
&& !normal.IsAlmostEqualTo( XYZ.BasisZ.Negate() ) )
{
return false;
}
}
return true;
}
示例7: CreateSurfaceOfLinearExtrusionFromCurve
/// <summary>
/// Creates an extruded surface of type IfcSurfaceOfLinearExtrusion given a base 2D curve, a direction and a length.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC class.</param>
/// <param name="baseCurve">The curve to be extruded.</param>
/// <param name="extrusionPlane">The coordinate system of the extrusion, where the normal of the plane is the direction of the extrusion.</param>
/// <param name="scaledExtrusionSize">The length of the extrusion, in IFC unit scale.</param>
/// <param name="unscaledBaseHeight">The Z value of the base level for the surface, in Revit unit scale.</param>
/// <param name="sweptCurve">The handle of the created curve entity.</param>
/// <returns>The extrusion handle.</returns>
/// <remarks>Note that scaledExtrusionSize and unscaledBaseHeight are in potentially different scaling units.</remarks>
public static IFCAnyHandle CreateSurfaceOfLinearExtrusionFromCurve(ExporterIFC exporterIFC, Curve baseCurve, Plane extrusionPlane,
double scaledExtrusionSize, double unscaledBaseHeight, out IFCAnyHandle curveHandle)
{
curveHandle = null;
IFCFile file = exporterIFC.GetFile();
XYZ extrusionDir = extrusionPlane.Normal;
// A list of IfcCurve entities.
IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, extrusionPlane, extrusionDir, true);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, baseCurve, XYZ.Zero, true);
IList<IFCAnyHandle> profileCurves = info.GetCurves();
if ((profileCurves.Count != 1) || (!IFCAnyHandleUtil.IsSubTypeOf(profileCurves[0], IFCEntityType.IfcBoundedCurve)))
return null;
curveHandle = profileCurves[0];
IFCAnyHandle sweptCurve = IFCInstanceExporter.CreateArbitraryOpenProfileDef(file, IFCProfileType.Curve, null, profileCurves[0]);
XYZ oCurveOrig = baseCurve.GetEndPoint(0);
XYZ orig = UnitUtil.ScaleLength(new XYZ(0.0, 0.0, oCurveOrig[2] - unscaledBaseHeight));
IFCAnyHandle surfaceAxis = ExporterUtil.CreateAxis(file, orig, null, null);
IFCAnyHandle direction = ExporterUtil.CreateDirection(file, extrusionDir); // zDir
return IFCInstanceExporter.CreateSurfaceOfLinearExtrusion(file, sweptCurve, surfaceAxis, direction, scaledExtrusionSize);
}
示例8: CreateReversedCurve
static Curve CreateReversedCurve(Autodesk.Revit.Creation.Application creapp, Curve orig)
{
if (orig is Autodesk.Revit.DB.Line)
{
return Autodesk.Revit.DB.Line.CreateBound(
orig.GetEndPoint(1),
orig.GetEndPoint(0));
}
else if (orig is Autodesk.Revit.DB.Arc)
{
return Autodesk.Revit.DB.Arc.Create(orig.GetEndPoint(1),
orig.GetEndPoint(0),
orig.Evaluate(0.5, true));
}
else
{
throw new Exception(
"CreateReversedCurve - Unreachable");
}
}
示例9: CurveEndpointString2d
/// <summary>
/// Return a string displaying only the XY values
/// of the two XYZ endpoints of a geometry curve
/// element.
/// </summary>
public static string CurveEndpointString2d( Curve c )
{
return string.Format( "({0},{1})",
PointString( c.GetEndPoint( 0 ) ),
PointString( c.GetEndPoint( 1 ) ) );
}
示例10: CreateProfileCurveFromCurve
private static IFCAnyHandle CreateProfileCurveFromCurve(IFCFile file, ExporterIFC exporterIFC, Curve curve, string profileName,
IDictionary<IFCFuzzyXYZ, IFCAnyHandle> cartesianPoints)
{
bool allowAdvancedCurve = ExporterCacheManager.ExportOptionsCache.ExportAs4;
IFCAnyHandle ifcCurve = GeometryUtil.CreateIFCCurveFromRevitCurve(file, exporterIFC, curve, allowAdvancedCurve, cartesianPoints);
IFCAnyHandle sweptCurve = null;
bool isBound = false;
IFCAnyHandle edgeStart = null;
IFCAnyHandle edgeEnd = null;
if (!curve.IsBound)
{
isBound = false;
}
else
{
XYZ startPoint = curve.GetEndPoint(0);
XYZ endPoint = curve.GetEndPoint(1);
if (startPoint.IsAlmostEqualTo(endPoint))
{
isBound = false;
}
else
{
edgeStart = GeometryUtil.XYZtoIfcCartesianPoint(exporterIFC, curve.GetEndPoint(0), cartesianPoints);
edgeEnd = GeometryUtil.XYZtoIfcCartesianPoint(exporterIFC, curve.GetEndPoint(1), cartesianPoints);
isBound = true;
}
}
if (!isBound)
{
sweptCurve = IFCInstanceExporter.CreateArbitraryClosedProfileDef(file, IFCProfileType.Curve, profileName, ifcCurve);
}
else
{
IFCAnyHandle trimmedCurve = null;
IFCData trim1data = IFCData.CreateIFCAnyHandle(edgeStart);
HashSet<IFCData> trim1 = new HashSet<IFCData>();
trim1.Add(trim1data);
IFCData trim2data = IFCData.CreateIFCAnyHandle(edgeEnd);
HashSet<IFCData> trim2 = new HashSet<IFCData>();
trim2.Add(trim2data);
bool senseAgreement = true;
trimmedCurve = IFCInstanceExporter.CreateTrimmedCurve(file, ifcCurve, trim1, trim2, senseAgreement, IFCTrimmingPreference.Cartesian);
sweptCurve = IFCInstanceExporter.CreateArbitraryClosedProfileDef(file, IFCProfileType.Curve, profileName, trimmedCurve);
}
return sweptCurve;
}
示例11: CreateModelCurves
public ModelCurveArray CreateModelCurves(
Curve curve)
{
var array = new ModelCurveArray();
var line = curve as Line;
if( line != null )
{
array.Append( CreateModelLine( _doc,
curve.GetEndPoint( 0 ),
curve.GetEndPoint( 1 ) ) );
return array;
}
var arc = curve as Arc;
if( arc != null )
{
var origin = arc.Center;
var normal = arc.Normal;
array.Append( CreateModelCurve(
arc, origin, normal ) );
return array;
}
var ellipse = curve as Ellipse;
if( ellipse != null )
{
var origin = ellipse.Center;
var normal = ellipse.Normal;
array.Append( CreateModelCurve(
ellipse, origin, normal ) );
return array;
}
var points = curve.Tessellate();
var p = points.First();
foreach( var q in points.Skip( 1 ) )
{
array.Append( CreateModelLine( _doc, p, q ) );
p = q;
}
return array;
}
示例12: Interruption
public Interruption(Curve a, XYZ point, double width)
{
double parameter = a.GetEndPoint(0).DistanceTo(point);
this.from = parameter - width / 2;
this.to = parameter + width / 2;
}
示例13: handleJoinsRight
/// <summary>
/// Get the Insulation Layer of Right hand joined Walls
/// </summary>
public Tuple<Curve, Curve> handleJoinsRight(Document doc, LocationCurve wallLocCurve, Curve lower, Curve upper, ref List<int> bannedWalls)
{
Tuple<Curve, Curve> existing = new Tuple<Curve, Curve>(upper, lower);
if (lower.GetType() == typeof(Arc) || lower.GetType() == typeof(NurbSpline)) return existing;
if (upper.GetType() == typeof(Arc) || upper.GetType() == typeof(NurbSpline)) return existing;
XYZ IntersectionPointLower = null;
XYZ IntersectionPointUpper = null;
ElementArray elems = wallLocCurve.get_ElementsAtJoin(1);
if (elems == null || elems.Size == 0) return existing;
foreach (Element elem in elems)
{
if (elem.GetType() == typeof(Wall))
{
Wall wnext = (Wall)elem;
if (!bannedWalls.Contains(wnext.Id.IntegerValue))
{
Tuple<Curve, Curve> curves = getInsulationLayer(doc, wnext);
Curve lowerunbound = lower.Clone();
lowerunbound.MakeUnbound();
Curve upperunbound = upper.Clone();
upperunbound.MakeUnbound();
Curve lowernext = curves.Item2.Clone();
lowernext.MakeUnbound();
IntersectionResultArray result = new IntersectionResultArray();
lowerunbound.Intersect(lowernext, out result);
if (result != null && result.Size == 1)
{
IntersectionPointLower = result.get_Item(0).XYZPoint;
}
upperunbound.Intersect(lowernext, out result);
if (result != null && result.Size == 1)
{
IntersectionPointUpper = result.get_Item(0).XYZPoint;
}
}
}
}
if (IntersectionPointLower == null || IntersectionPointUpper == null) return existing;
return new Tuple<Curve, Curve>(Line.CreateBound(upper.GetEndPoint(0), IntersectionPointUpper), Line.CreateBound(lower.GetEndPoint(0), IntersectionPointLower));
}
示例14: handleJoinsLeft
/// <summary>
/// Get the Insulation Layer of Left hand joined Walls
/// </summary>
public Curve handleJoinsLeft(Document doc, LocationCurve wallLocCurve, Curve lower, ref List<int> bannedWalls)
{
if (lower.GetType() == typeof(Arc) || lower.GetType() == typeof(NurbSpline)) return lower;
XYZ IntersectionPoint = null;
ElementArray elems = wallLocCurve.get_ElementsAtJoin(0);
if (elems == null || elems.Size == 0) return lower;
foreach (Element elem in elems)
{
if (elem.GetType() == typeof(Wall))
{
Wall wnext = (Wall)elem;
if (!bannedWalls.Contains(wnext.Id.IntegerValue))
{
Tuple<Curve, Curve> curves = getInsulationLayer(doc, wnext);
Curve lowerunbound = lower.Clone();
lowerunbound.MakeUnbound();
Curve upper = curves.Item1.Clone();
upper.MakeUnbound();
IntersectionResultArray result = new IntersectionResultArray();
lowerunbound.Intersect(upper, out result);
if (result != null && result.Size == 1)
{
IntersectionPoint = result.get_Item(0).XYZPoint;
}
}
}
}
if (IntersectionPoint == null) return lower;
Line l = Line.CreateBound(IntersectionPoint, lower.GetEndPoint(1));
return l;
}
示例15: drawInsulation
/// <summary>
/// DrawInsulation
/// </summary>
public double drawInsulation(List<ElementId> grp, Document doc, Curve lower, double distance, Curve upper, ref bool leftwing, List<Interruption> Breaks, bool zigzag)
{
double dist = distance / lower.Length;
if (dist > 1) return 100;
XYZ P1 = lower.Evaluate(dist, true);
IntersectionResultArray result = new IntersectionResultArray();
XYZ normal = lower.GetCurveTangentToEndPoint(P1);
SetComparisonResult scr = Line.CreateUnbound(P1, normal).Intersect(upper, out result);
if (result == null || result.Size == 0)
{
if (dist > 0.5) return 100;
else
{
upper = upper.Clone();
upper.MakeUnbound();
scr = Line.CreateUnbound(P1, normal).Intersect(upper, out result);
}
}
XYZ P3 = result.get_Item(0).XYZPoint;
double height = P1.DistanceTo(P3);
double r = height / 4;
double distr = (distance + r) / lower.Length;
if (distr > 1) return 100;
foreach (Interruption interrupt in Breaks)
{
if (distr > lower.ComputeNormalizedParameter(interrupt.from) && distr < lower.ComputeNormalizedParameter(interrupt.to)) return r;
}
XYZ P2 = (distr < 1) ? lower.Evaluate(distr, true) : P1;
double disth = (distance + height) / lower.Length;
SetComparisonResult scr2 = Line.CreateUnbound(P2, lower.GetCurveTangentToEndPoint(P2)).Intersect(upper, out result);
if (result == null || result.Size == 0) return 100;
XYZ P4 = (P1 != P2) ? result.get_Item(0).XYZPoint : upper.GetEndPoint(1);
if (zigzag)
drawZigZag(grp, doc, P1, P2, P3, P4, leftwing);
else
drawSoftLoop(grp, doc, P1, P2, P3, P4, leftwing);
if (leftwing) leftwing = false; else leftwing = true;
return r;
}