本文整理汇总了C#中CurveLoop.Count方法的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop.Count方法的具体用法?C# CurveLoop.Count怎么用?C# CurveLoop.Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurveLoop
的用法示例。
在下文中一共展示了CurveLoop.Count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CurveLoopIsARectangle
private static bool CurveLoopIsARectangle(CurveLoop curveLoop, out IList<int> cornerIndices)
{
cornerIndices = new List<int>(4);
// looking for four orthogonal lines in one curve loop.
int sz = curveLoop.Count();
if (sz < 4)
return false;
IList<Line> lines = new List<Line>();
foreach (Curve curve in curveLoop)
{
if (!(curve is Line))
return false;
lines.Add(curve as Line);
}
sz = lines.Count;
int numAngles = 0;
// Must have 4 right angles found, and all other lines collinear -- if not, not a rectangle.
for (int ii = 0; ii < sz; ii++)
{
double dot = lines[ii].Direction.DotProduct(lines[(ii + 1) % sz].Direction);
if (MathUtil.IsAlmostZero(dot))
{
if (numAngles > 3)
return false;
cornerIndices.Add(ii);
numAngles++;
}
else if (MathUtil.IsAlmostEqual(dot, 1.0))
{
XYZ line0End1 = lines[ii].GetEndPoint(1);
XYZ line1End0 = lines[(ii + 1) % sz].GetEndPoint(0);
if (!line0End1.IsAlmostEqualTo(line1End0))
return false;
}
else
return false;
}
return (numAngles == 4);
}
示例2: SplitSweptDiskIntoValidPieces
private IList<GeometryObject> SplitSweptDiskIntoValidPieces(CurveLoop trimmedDirectrixInWCS, IList<CurveLoop> profileCurveLoops, SolidOptions solidOptions)
{
// If we have 0 or 1 curves, there is nothing we can do here.
int numCurves = trimmedDirectrixInWCS.Count();
if (numCurves < 2)
return null;
// We will attempt to represent the original description in as few pieces as possible.
IList<Curve> directrixCurves = new List<Curve>();
foreach (Curve directrixCurve in trimmedDirectrixInWCS)
{
if (directrixCurve == null)
{
numCurves--;
if (numCurves < 2)
return null;
continue;
}
directrixCurves.Add(directrixCurve);
}
IList<GeometryObject> sweptDiskPieces = new List<GeometryObject>();
// We will march along the directrix one curve at a time, trying to build a bigger piece of the sweep. At the point that we throw an exception,
// we will take the last biggest piece and start over.
CurveLoop currentCurveLoop = new CurveLoop();
Solid bestSolidSoFar = null;
double pathAttachmentParam = directrixCurves[0].GetEndParameter(0);
for (int ii = 0; ii < numCurves; ii++)
{
currentCurveLoop.Append(directrixCurves[ii]);
try
{
Solid currentSolid = GeometryCreationUtilities.CreateSweptGeometry(currentCurveLoop, 0, pathAttachmentParam, profileCurveLoops,
solidOptions);
bestSolidSoFar = currentSolid;
}
catch
{
if (bestSolidSoFar != null)
{
sweptDiskPieces.Add(bestSolidSoFar);
bestSolidSoFar = null;
}
}
// This should only happen as a result of the catch loop above. We want to protect against the case where one or more pieces of the sweep
// are completely invalid.
while (bestSolidSoFar == null && (ii < numCurves))
{
try
{
currentCurveLoop = new CurveLoop();
currentCurveLoop.Append(directrixCurves[ii]);
profileCurveLoops = CreateProfileCurveLoopsForDirectrix(directrixCurves[ii], out pathAttachmentParam);
Solid currentSolid = GeometryCreationUtilities.CreateSweptGeometry(currentCurveLoop, 0, pathAttachmentParam, profileCurveLoops,
solidOptions);
bestSolidSoFar = currentSolid;
break;
}
catch
{
ii++;
}
}
}
return sweptDiskPieces;
}
示例3: SafeIsCurveLoopClockwise
/// <returns>true if the curve loop is clockwise, false otherwise.</returns>
private static bool SafeIsCurveLoopClockwise(CurveLoop curveLoop, XYZ dir)
{
if (curveLoop == null)
return false;
if (curveLoop.IsOpen())
return false;
if ((curveLoop.Count() == 1) && !(curveLoop.First().IsBound))
return false;
return !curveLoop.IsCounterclockwise(dir);
}
示例4: CreateIShapeProfileDefIfPossible
/// <summary>
/// Determines if a curveloop can be exported as an I-Shape profile.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="profileName">The name of the profile.</param>
/// <param name="curveLoop">The curve loop.</param>
/// <param name="origPlane">The plane of the loop.</param>
/// <param name="projDir">The projection direction.</param>
/// <returns>The IfcIShapeProfileDef, or null if not possible.</returns>
/// <remarks>This routine works with I-shaped curveloops projected onto origPlane, in either orientation;
/// it does not work with H-shaped curveloops.</remarks>
private static IFCAnyHandle CreateIShapeProfileDefIfPossible(ExporterIFC exporterIFC, string profileName, CurveLoop curveLoop, Plane origPlane,
XYZ projDir)
{
IFCFile file = exporterIFC.GetFile();
if (curveLoop.IsOpen())
return null;
if (curveLoop.Count() != 12 && curveLoop.Count() != 16)
return null;
// All curves must be lines, except for 4 optional fillets; get direction vectors and start points.
XYZ xDir = origPlane.XVec;
XYZ yDir = origPlane.YVec;
// The list of vertices, in order. startVertex below is the upper-right hand vertex, in UV-space.
IList<UV> vertices = new List<UV>();
// The directions in UV of the line segments. directions[ii] is the direction of the line segment starting with vertex[ii].
IList<UV> directions = new List<UV>();
// The lengths in UV of the line segments. lengths[ii] is the length of the line segment starting with vertex[ii].
IList<double> lengths = new List<double>();
// turnsCCW[ii] is true if directions[ii+1] is clockwise relative to directions[ii] in UV-space.
IList<bool> turnsCCW = new List<bool>();
IList<Arc> fillets = new List<Arc>();
IList<int> filletPositions = new List<int>();
int idx = 0;
int startVertex = -1;
int startFillet = -1;
UV upperRight = null;
double lowerBoundU = 1e+30;
double upperBoundU = -1e+30;
foreach (Curve curve in curveLoop)
{
if (!(curve is Line))
{
if (!(curve is Arc))
return null;
fillets.Add(curve as Arc);
filletPositions.Add(idx); // share the index of the next line segment.
continue;
}
Line line = curve as Line;
XYZ point = line.GetEndPoint(0);
UV pointProjUV = GeometryUtil.ProjectPointToPlane(origPlane, projDir, point);
if (pointProjUV == null)
return null;
pointProjUV = UnitUtil.ScaleLength(pointProjUV);
if ((upperRight == null) || ((pointProjUV.U > upperRight.U - MathUtil.Eps()) && (pointProjUV.V > upperRight.V - MathUtil.Eps())))
{
upperRight = pointProjUV;
startVertex = idx;
startFillet = filletPositions.Count;
}
if (pointProjUV.U < lowerBoundU)
lowerBoundU = pointProjUV.U;
if (pointProjUV.U > upperBoundU)
upperBoundU = pointProjUV.U;
vertices.Add(pointProjUV);
XYZ direction3d = line.Direction;
UV direction = new UV(direction3d.DotProduct(xDir), direction3d.DotProduct(yDir));
lengths.Add(UnitUtil.ScaleLength(line.Length));
bool zeroU = MathUtil.IsAlmostZero(direction.U);
bool zeroV = MathUtil.IsAlmostZero(direction.V);
if (zeroU && zeroV)
return null;
// Accept only non-rotated I-Shapes.
if (!zeroU && !zeroV)
return null;
direction.Normalize();
if (idx > 0)
{
if (!MathUtil.IsAlmostZero(directions[idx - 1].DotProduct(direction)))
return null;
turnsCCW.Add(directions[idx - 1].CrossProduct(direction) > 0);
}
directions.Add(direction);
//.........这里部分代码省略.........