本文整理汇总了C#中CurveLoop.GetPlane方法的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop.GetPlane方法的具体用法?C# CurveLoop.GetPlane怎么用?C# CurveLoop.GetPlane使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurveLoop
的用法示例。
在下文中一共展示了CurveLoop.GetPlane方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlaneFromCurve
public static Plane GetPlaneFromCurve(Curve c, bool planarOnly)
{
//find the plane of the curve and generate a sketch plane
double period = c.IsBound ? 0.0 : (c.IsCyclic ? c.Period : 1.0);
var p0 = c.IsBound ? c.Evaluate(0.0, true) : c.Evaluate(0.0, false);
var p1 = c.IsBound ? c.Evaluate(0.5, true) : c.Evaluate(0.25 * period, false);
var p2 = c.IsBound ? c.Evaluate(1.0, true) : c.Evaluate(0.5 * period, false);
if (IsLineLike(c))
{
XYZ norm = null;
//keep old plane computations
if (System.Math.Abs(p0.Z - p2.Z) < Tolerance)
{
norm = XYZ.BasisZ;
}
else
{
var v1 = p1 - p0;
var v2 = p2 - p0;
var p3 = new XYZ(p2.X, p2.Y, p0.Z);
var v3 = p3 - p0;
norm = v1.CrossProduct(v3);
if (norm.IsZeroLength())
{
norm = v2.CrossProduct(XYZ.BasisY);
}
norm = norm.Normalize();
}
return new Plane(norm, p0);
}
var cLoop = new CurveLoop();
cLoop.Append(c.Clone());
if (cLoop.HasPlane())
{
return cLoop.GetPlane();
}
if (planarOnly)
return null;
// Get best fit plane using tesselation
var points = c.Tessellate().Select(x => x.ToPoint(false));
var bestFitPlane =
Autodesk.DesignScript.Geometry.Plane.ByBestFitThroughPoints(points);
return bestFitPlane.ToPlane(false);
}
示例2: ComputeHeightWidthOfCurveLoop
/// <summary>
/// Computes height and width of a curve loop with respect to the projection plane.
/// </summary>
/// <param name="curveLoop">The curve loop.</param>
/// <param name="plane">The projection plane.</param>
/// <param name="height">The height.</param>
/// <param name="width">The width.</param>
/// <returns>True if success, false if fail.</returns>
public static bool ComputeHeightWidthOfCurveLoop(CurveLoop curveLoop, Plane plane, out double height, out double width)
{
height = 0.0;
width = 0.0;
Plane localPlane = plane;
if (localPlane == null)
{
try
{
localPlane = curveLoop.GetPlane();
}
catch
{
return false;
}
}
if (curveLoop.IsRectangular(localPlane))
{
height = curveLoop.GetRectangularHeight(localPlane);
width = curveLoop.GetRectangularWidth(localPlane);
return true;
}
else
return false;
}
示例3: CreateCircleProfileDefIfPossible
private static IFCAnyHandle CreateCircleProfileDefIfPossible(ExporterIFC exporterIFC, string profileName, CurveLoop curveLoop, Plane origPlane,
XYZ projDir)
{
IFCFile file = exporterIFC.GetFile();
if (curveLoop.IsOpen())
return null;
XYZ origPlaneNorm = origPlane.Normal;
Plane curveLoopPlane = null;
try
{
curveLoopPlane = curveLoop.GetPlane();
}
catch
{
return null;
}
XYZ curveLoopPlaneNorm = curveLoopPlane.Normal;
if (!MathUtil.IsAlmostEqual(Math.Abs(origPlaneNorm.DotProduct(curveLoopPlaneNorm)), 1.0))
return null;
IList<Arc> arcs = new List<Arc>();
foreach (Curve curve in curveLoop)
{
if (!(curve is Arc))
return null;
arcs.Add(curve as Arc);
}
int numArcs = arcs.Count;
if (numArcs == 0)
return null;
double radius = arcs[0].Radius;
XYZ ctr = arcs[0].Center;
for (int ii = 1; ii < numArcs; ii++)
{
XYZ newCenter = arcs[ii].Center;
if (!newCenter.IsAlmostEqualTo(ctr))
return null;
}
double scale = exporterIFC.LinearScale;
radius *= scale;
XYZ xDir = origPlane.XVec;
XYZ yDir = origPlane.YVec;
XYZ orig = origPlane.Origin;
ctr -= orig;
IList<double> newCtr = new List<double>();
newCtr.Add(xDir.DotProduct(ctr) * scale);
newCtr.Add(yDir.DotProduct(ctr) * scale);
IFCAnyHandle location = IFCInstanceExporter.CreateCartesianPoint(file, newCtr);
IList<double> refDir = new List<double>();
refDir.Add(1.0);
refDir.Add(0.0);
IFCAnyHandle refDirectionOpt = ExporterUtil.CreateDirection(file, refDir);
IFCAnyHandle defPosition = IFCInstanceExporter.CreateAxis2Placement2D(file, location, null, refDirectionOpt);
return IFCInstanceExporter.CreateCircleProfileDef(file, IFCProfileType.Area, profileName, defPosition, radius);
}