本文整理汇总了C#中CurveLoop类的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop类的具体用法?C# CurveLoop怎么用?C# CurveLoop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CurveLoop类属于命名空间,在下文中一共展示了CurveLoop类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetValidXVectorFromLoop
private XYZ GetValidXVectorFromLoop(CurveLoop curveLoop, XYZ zVec, XYZ origin)
{
foreach (Curve curve in curveLoop)
{
IList<XYZ> pointsToCheck = new List<XYZ>();
// If unbound, must be cyclic.
if (!curve.IsBound)
{
pointsToCheck.Add(curve.Evaluate(0, false));
pointsToCheck.Add(curve.Evaluate(Math.PI / 2.0, false));
pointsToCheck.Add(curve.Evaluate(Math.PI, false));
}
else
{
pointsToCheck.Add(curve.Evaluate(0, true));
pointsToCheck.Add(curve.Evaluate(1.0, true));
if (curve.IsCyclic)
pointsToCheck.Add(curve.Evaluate(0.5, true));
}
foreach (XYZ pointToCheck in pointsToCheck)
{
XYZ possibleVec = (pointToCheck - origin);
XYZ yVec = zVec.CrossProduct(possibleVec).Normalize();
if (yVec.IsZeroLength())
continue;
return yVec.CrossProduct(zVec);
}
}
return null;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:33,代码来源:IFCRevolvedAreaSolid.cs
示例2: IsIFCLoopCCW
/// <summary>
/// Determines if curve loop is counterclockwise.
/// </summary>
/// <param name="curveLoop">
/// The curveLoop.
/// </param>
/// <param name="normal">
/// The normal.
/// </param>
/// <returns>
/// Returns true only if the loop is counterclockwise, false otherwise.
/// </returns>
public static bool IsIFCLoopCCW(CurveLoop curveLoop, XYZ normal)
{
if (curveLoop == null)
throw new Exception("CurveLoop is null.");
// If loop is not suitable for ccw evaluation an exception is thrown
return curveLoop.IsCounterclockwise(normal);
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:20,代码来源:GeometryUtil.cs
示例3: GenerateLoop
protected override CurveLoop GenerateLoop()
{
CurveLoop curveLoop = new CurveLoop();
foreach (IFCOrientedEdge edge in EdgeList)
{
if (edge != null)
curveLoop.Append(edge.GetGeometry());
}
return curveLoop;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:10,代码来源:IFCEdgeLoop.cs
示例4: 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);
}
开发者ID:RobertiF,项目名称:Dynamo,代码行数:54,代码来源:CurveUtils.cs
示例5: CreateTransformed
/// <summary>
/// Create a copy of a curve loop with a given transformation applied.
/// </summary>
/// <param name="origLoop">The original curve loop.</param>
/// <param name="trf">The transform.</param>
/// <returns>The transformed loop.</returns>
public static CurveLoop CreateTransformed(CurveLoop origLoop, Transform trf)
{
if (origLoop == null)
return null;
CurveLoop newLoop = new CurveLoop();
foreach (Curve curve in origLoop)
{
newLoop.Append(curve.CreateTransformed(trf));
}
return newLoop;
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:18,代码来源:IFCGeometryUtil.cs
示例6: 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);
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:45,代码来源:ExtrusionExporter.cs
示例7: ToRevitType
/// <summary>
/// A PolyCurve is not a curve, this is a special extension method to convert to a Revit CurveLoop
/// </summary>
/// <param name="pcrv"></param>
/// <returns></returns>
public static Autodesk.Revit.DB.CurveLoop ToRevitType(this Autodesk.DesignScript.Geometry.PolyCurve pcrv)
{
if (!pcrv.IsClosed)
{
throw new Exception("The input PolyCurve must be closed");
}
var cl = new CurveLoop();
var crvs = pcrv.Curves();
foreach (Autodesk.DesignScript.Geometry.Curve curve in crvs)
{
Autodesk.Revit.DB.Curve converted = curve.ToNurbsCurve().ToRevitType();
cl.Append(converted);
}
return cl;
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:25,代码来源:ProtoToRevitCurve.cs
示例8: ToRevitType
public static Autodesk.Revit.DB.CurveLoop ToRevitType(this Autodesk.DesignScript.Geometry.PolyCurve pcrv,
bool performHostUnitConversion = true)
{
if (!pcrv.IsClosed)
{
throw new Exception("The input PolyCurve must be closed");
}
pcrv = performHostUnitConversion ? pcrv.InHostUnits() : pcrv;
var cl = new CurveLoop();
var crvs = pcrv.Curves();
foreach (Autodesk.DesignScript.Geometry.Curve curve in crvs)
{
Autodesk.Revit.DB.Curve converted = curve.ToNurbsCurve().ToRevitType(false);
cl.Append(converted);
}
return cl;
}
开发者ID:heegwon,项目名称:Dynamo,代码行数:21,代码来源:ProtoToRevitCurve.cs
示例9: GetFaceBoundary
private static CurveLoop GetFaceBoundary(Face face, EdgeArray faceBoundary, XYZ baseLoopOffset,
bool polygonalOnly, out FaceBoundaryType faceBoundaryType)
{
faceBoundaryType = FaceBoundaryType.Polygonal;
CurveLoop currLoop = new CurveLoop();
foreach (Edge faceBoundaryEdge in faceBoundary)
{
Curve edgeCurve = faceBoundaryEdge.AsCurveFollowingFace(face);
Curve offsetCurve = (baseLoopOffset != null) ? MoveCurve(edgeCurve, baseLoopOffset) : edgeCurve;
if (!(offsetCurve is Line))
{
if (polygonalOnly)
{
IList<XYZ> tessPts = offsetCurve.Tessellate();
int numTessPts = tessPts.Count;
for (int ii = 0; ii < numTessPts - 1; ii++)
{
Line line = Line.get_Bound(tessPts[ii], tessPts[ii + 1]);
currLoop.Append(line);
}
}
else
{
currLoop.Append(offsetCurve);
}
if (offsetCurve is Arc)
faceBoundaryType = FaceBoundaryType.LinesAndArcs;
else
faceBoundaryType = FaceBoundaryType.Complex;
}
else
currLoop.Append(offsetCurve);
}
return currLoop;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:36,代码来源:GeometryUtil.cs
示例10: ReverseOrientation
/// <summary>
/// Reverses curve loop.
/// </summary>
/// <param name="curveloop">
/// The curveloop.
/// </param>
/// <returns>
/// The reversed curve loop.
/// </returns>
public static CurveLoop ReverseOrientation(CurveLoop curveloop)
{
CurveLoop copyOfCurveLoop = CurveLoop.CreateViaCopy(curveloop);
copyOfCurveLoop.Flip();
return copyOfCurveLoop;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:15,代码来源:GeometryUtil.cs
示例11: GetCurveLoop
/// <summary>
/// Get the curve or CurveLoop representation of IFCCurve, as a CurveLoop. This will have a value, as long as Curve or CurveLoop do.
/// </summary>
public CurveLoop GetCurveLoop()
{
if (CurveLoop != null)
return CurveLoop;
if (Curve == null)
return null;
CurveLoop curveAsCurveLoop = new CurveLoop();
curveAsCurveLoop.Append(Curve);
return curveAsCurveLoop;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:14,代码来源:IFCCurve.cs
示例12: FindParentHandle
/// <summary>
/// Finds parent handle from opening CurveLoop and parent CurveLoops.
/// </summary>
/// <param name="elementHandles">The parent handles.</param>
/// <param name="curveLoops">The parent CurveLoops.</param>
/// <param name="openingLoop">The opening CurveLoop.</param>
/// <returns>The parent handle.</returns>
private static IFCAnyHandle FindParentHandle(IList<IFCAnyHandle> elementHandles, IList<CurveLoop> curveLoops, CurveLoop openingLoop)
{
// first one is roof handle, others are slabs
if (elementHandles.Count != curveLoops.Count + 1)
return null;
for (int ii = 0; ii < curveLoops.Count; ii++)
{
if (GeometryUtil.CurveLoopsInside(openingLoop, curveLoops[ii]) || GeometryUtil.CurveLoopsIntersect(openingLoop, curveLoops[ii]))
{
return elementHandles[ii + 1];
}
}
return elementHandles[0];
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:22,代码来源:OpeningUtil.cs
示例13: 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;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:71,代码来源:IFCSweptDiskSolid.cs
示例14: CreatePolyCurveLoop
/// <summary>
/// Creates an open or closed CurveLoop from a list of vertices.
/// </summary>
/// <param name="pointXYZs">The list of vertices.</param>
/// <param name="points">The optional list of IFCAnyHandles that generated the vertices, used solely for error reporting.</param>
/// <param name="id">The id of the IFCAnyHandle associated with the CurveLoop.</param>
/// <param name="isClosedLoop">True if the vertices represent a closed loop, false if not.</param>
/// <returns>The new curve loop.</returns>
/// <remarks>If isClosedLoop is true, there will be pointsXyz.Count line segments. Otherwise, there will be pointsXyz.Count-1.</remarks>
public static CurveLoop CreatePolyCurveLoop(IList<XYZ> pointXYZs, IList<IFCAnyHandle> points, int id, bool isClosedLoop)
{
int numPoints = pointXYZs.Count;
if (numPoints < 2)
return null;
IList<int> badIds = new List<int>();
int numMinPoints = isClosedLoop ? 3 : 2;
// Check distance between points; remove too-close points, and warn if result is non-collinear.
// Always include first point.
IList<XYZ> finalPoints = new List<XYZ>();
finalPoints.Add(pointXYZs[0]);
int numNewPoints = 1;
for (int ii = 1; ii < numPoints; ii++)
{
if (IFCGeometryUtil.LineSegmentIsTooShort(finalPoints[numNewPoints - 1], pointXYZs[ii]))
{
if (points != null)
badIds.Add(points[ii].StepId);
else
badIds.Add(ii+1);
}
else
{
finalPoints.Add(pointXYZs[ii]);
numNewPoints++;
}
}
// Check final segment; if too short, delete 2nd to last point.
if (isClosedLoop)
{
if (IFCGeometryUtil.LineSegmentIsTooShort(finalPoints[numNewPoints - 1], pointXYZs[0]))
{
finalPoints.RemoveAt(numNewPoints - 1);
numNewPoints--;
}
}
// This can be a very common warning, so we will restrict to verbose logging.
if (Importer.TheOptions.VerboseLogging)
{
if (badIds.Count > 0)
{
int count = badIds.Count;
string msg = null;
if (count == 1)
{
msg = "Polyline had 1 point that was too close to one of its neighbors, removing point: #" + badIds[0] + ".";
}
else
{
msg = "Polyline had " + count + " points that were too close to one of their neighbors, removing points:";
foreach (int badId in badIds)
msg += " #" + badId;
msg += ".";
}
IFCImportFile.TheLog.LogWarning(id, msg, false);
}
}
if (numNewPoints < numMinPoints)
{
if (Importer.TheOptions.VerboseLogging)
{
string msg = "PolyCurve had " + numNewPoints + " point(s) after removing points that were too close, expected at least " + numMinPoints + ", ignoring.";
IFCImportFile.TheLog.LogWarning(id, msg, false);
}
return null;
}
CurveLoop curveLoop = new CurveLoop();
for (int ii = 0; ii < numNewPoints - 1; ii++)
curveLoop.Append(Line.CreateBound(finalPoints[ii], finalPoints[ii + 1]));
if (isClosedLoop)
curveLoop.Append(Line.CreateBound(finalPoints[numNewPoints - 1], finalPoints[0]));
return curveLoop;
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:90,代码来源:IFCGeometryUtil.cs
示例15: TransformAndProjectCurveLoopToPlane
private static IList<UV> TransformAndProjectCurveLoopToPlane(ExporterIFC exporterIFC, CurveLoop loop, Plane projScaledPlane)
{
IList<UV> uvs = new List<UV>();
XYZ projDir = projScaledPlane.Normal;
foreach (Curve curve in loop)
{
XYZ point = curve.get_EndPoint(0);
XYZ scaledPoint = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, point);
UV scaledUV = ProjectPointToPlane(projScaledPlane, projDir, scaledPoint);
uvs.Add(scaledUV);
}
return uvs;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:15,代码来源:GeometryUtil.cs
示例16: GetExtrusionRangeOfCurveLoop
private static IFCRange GetExtrusionRangeOfCurveLoop(CurveLoop loop, XYZ extrusionDirection)
{
IFCRange range = new IFCRange();
bool init = false;
foreach (Curve curve in loop)
{
if (!init)
{
if (curve.IsBound)
{
IList<XYZ> coords = curve.Tessellate();
foreach (XYZ coord in coords)
{
double val = coord.DotProduct(extrusionDirection);
if (!init)
{
range.Start = val;
range.End = val;
init = true;
}
else
{
range.Start = Math.Min(range.Start, val);
range.End = Math.Max(range.End, val);
}
}
}
else
{
double val = curve.get_EndPoint(0).DotProduct(extrusionDirection);
range.Start = val;
range.End = val;
init = true;
}
}
else
{
double val = curve.get_EndPoint(0).DotProduct(extrusionDirection);
range.Start = Math.Min(range.Start, val);
range.End = Math.Max(range.End, val);
}
}
return range;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:44,代码来源:GeometryUtil.cs
示例17: Process
//.........这里部分代码省略.........
// If minGap is less than vertexEps, we won't need to do any repairing - just fix the orientation if necessary.
if (minGap < vertexEps)
{
if (attachNextSegmentToEnd)
{
// Update the curve loop end point to be the end point of the next segment after potentially being reversed.
curveLoopEndPoint = nextEndPoint;
}
else
{
canRepairFirst = curveSegments[ii] is Line;
curveLoopStartPoint = nextStartPoint;
// Update the curve loop start point to be the start point of the next segment, now at the beginning of the loop,
// after potentially being reversed.
Curve tmpCurve = curveSegments[ii];
curveSegments.RemoveAt(ii);
curveSegments.Insert(0, tmpCurve);
}
continue;
}
// The gap is too big for CurveLoop, but smaller than our maximum tolerance - we will try to fix the gap by extending
// one of the line segments around the gap. If the gap is between two Arcs, we will try to introduce a short
// segment between them, as long as the gap is larger than the short curve tolerance.
bool canRepairNext = curveSegments[ii] is Line;
bool createdRepairLine = false;
if (attachNextSegmentToEnd)
{
// Update the curve loop end point to be the end point of the next segment after potentially being reversed.
XYZ originalCurveLoopEndPoint = curveLoopEndPoint;
curveLoopEndPoint = nextEndPoint;
if (canRepairNext)
curveSegments[ii] = RepairLineAndReport(Id, originalCurveLoopEndPoint, curveLoopEndPoint, minGap);
else if (curveSegments[ii - 1] is Line) // = canRepairCurrent, only used here.
curveSegments[ii - 1] = RepairLineAndReport(Id, curveSegments[ii - 1].GetEndPoint(0), curveSegments[ii].GetEndPoint(0), minGap);
else
{
// Can't add a line to fix a gap that is smaller than the short curve tolerance.
// In the future, we may fix this gap by intersecting the two curves and extending one of them.
if (minGap < shortCurveTol + MathUtil.Eps())
Importer.TheLog.LogError(Id, "IfcCompositeCurve contains a gap between two non-linear segments that is too short to be repaired by a connecting segment.", true);
try
{
Line repairLine = Line.CreateBound(originalCurveLoopEndPoint, curveSegments[ii].GetEndPoint(0));
curveSegments.Insert(ii, repairLine);
ii++; // Skip the repair line as we've already "added" it and the non-linear segment to our growing loop.
numSegments++;
createdRepairLine = true;
}
catch
{
Importer.TheLog.LogError(Id, "IfcCompositeCurve contains a gap between two non-linear segments that can't be fixed.", true);
}
}
}
else
{
XYZ originalCurveLoopStartPoint = curveLoopStartPoint;
curveLoopStartPoint = nextStartPoint;
if (canRepairNext)
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:67,代码来源:IFCCompositeCurve.cs
示例18: ConvertCurveLoopIntoSingleCurve
/// <summary>
/// Create a curve representation of this IFCCompositeCurve from a curveloop
/// </summary>
/// <param name="curveLoop">The curveloop</param>
/// <returns>A Revit curve that is made by appending every curve in the given curveloop, if possible</returns>
private Curve ConvertCurveLoopIntoSingleCurve(CurveLoop curveLoop)
{
if (curveLoop == null)
{
return null;
}
CurveLoopIterator curveIterator = curveLoop.GetCurveLoopIterator();
Curve firstCurve = curveIterator.Current;
Curve returnCurve = null;
// We only connect the curves if they are Line, Arc or Ellipse
if (!((firstCurve is Line) || (firstCurve is Arc) || (firstCurve is Ellipse)))
{
return null;
}
XYZ firstStartPoint = firstCurve.GetEndPoint(0);
Curve currentCurve = null;
if (firstCurve is Line)
{
Line firstLine = firstCurve as Line;
while(curveIterator.MoveNext())
{
currentCurve = curveIterator.Current;
if (!(currentCurve is Line))
{
return null;
}
Line currentLine = currentCurve as Line;
if (!(firstLine.Direction.IsAlmostEqualTo(currentLine.Direction)))
{
return null;
}
}
returnCurve = Line.CreateBound(firstStartPoint, currentCurve.GetEndPoint(1));
}
else if (firstCurve is Arc)
{
Arc firstArc = firstCurve as Arc;
XYZ firstCurveNormal = firstArc.Normal;
while(curveIterator.MoveNext())
{
currentCurve = curveIterator.Current;
if (!(currentCurve is Arc))
{
return null;
}
XYZ currentStartPoint = currentCurve.GetEndPoint(0);
XYZ currentEndPoint = currentCurve.GetEndPoint(1);
Arc currentArc = currentCurve as Arc;
XYZ currentCenter = currentArc.Center;
double currentRadius = currentArc.Radius;
XYZ currentNormal = currentArc.Normal;
// We check if this circle is similar to the first circle by checking that they have the same center, same radius,
// and lie on the same plane
if (!(currentCenter.IsAlmostEqualTo(firstArc.Center) && MathUtil.IsAlmostEqual(currentRadius, firstArc.Radius)))
{
return null;
}
if (!MathUtil.IsAlmostEqual(Math.Abs(currentNormal.DotProduct(firstCurveNormal)), 1))
{
return null;
}
}
// If all of the curve segments are part of the same circle, then the returning curve will be a circle bounded
// by the start point of the first curve and the end point of the last curve.
XYZ lastPoint = currentCurve.GetEndPoint(1);
if (lastPoint.IsAlmostEqualTo(firstStartPoint))
{
firstCurve.MakeUnbound();
}
else
{
double startParameter = firstArc.GetEndParameter(0);
double endParameter = firstArc.Project(lastPoint).Parameter;
if (endParameter < startParameter)
endParameter += Math.PI * 2;
firstCurve.MakeBound(startParameter, endParameter);
}
returnCurve = firstCurve;
}
else if (firstCurve is Ellipse)
{
Ellipse firstEllipse = firstCurve as Ellipse;
double radiusX = firstEllipse.RadiusX;
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:IFCCompositeCurve.cs
示例19: CreateGeometryInternal
/// <summary>
/// Return geometry for a particular representation item.
/// </summary>
/// <param name="shapeEditScope">The geometry creation scope.</param>
/// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
/// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
/// <param name="guid">The guid of an element for which represntation is being created.</param>
/// <returns>Zero or more created geometries.</returns>
protected override IList<GeometryObject> CreateGeometryInternal(
IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
{
Transform sweptDiskPosition = (lcs == null) ? Transform.Identity : lcs;
CurveLoop baseProfileCurve = Directrix.GetCurveLoop();
if (baseProfileCurve == null)
return null;
CurveLoop trimmedDirectrix = IFCGeometryUtil.TrimCurveLoop(baseProfileCurve, StartParameter, EndParameter);
if (trimmedDirectrix == null)
return null;
CurveLoop trimmedDirectrixInLCS = IFCGeometryUtil.CreateTransformed(trimmedDirectrix, sweptDiskPosition);
// Create the disk.
Transform originTrf = null;
double startParam = 0.0; // If the directrix isn't bound, this arbitrary parameter will do.
foreach (Curve curve in trimmedDirectrixInLCS)
{
if (curve.IsBound)
startParam = curve.GetEndParameter(0);
originTrf = curve.ComputeDerivatives(startParam, false);
break;
}
if (originTrf == null)
return null;
// The X-dir of the transform of the start of the directrix will form the normal of the disk.
Plane diskPlane = new Plane(originTrf.BasisX, originTrf.Origin);
IList<CurveLoop> profileCurveLoops = new List<CurveLoop>();
CurveLoop diskOuterCurveLoop = new CurveLoop();
diskOuterCurveLoop.Append(Arc.Create(diskPlane, Radius, 0, Math.PI));
diskOuterCurveLoop.Append(Arc.Create(diskPlane, Radius, Math.PI, 2.0 * Math.PI));
profileCurveLoops.Add(diskOuterCurveLoop);
if (InnerRadius.HasValue)
{
CurveLoop diskInnerCurveLoop = new CurveLoop();
diskInnerCurveLoop.Append(Arc.Create(diskPlane, InnerRadius.Value, 0, Math.PI));
diskInnerCurveLoop.Append(Arc.Create(diskPlane, InnerRadius.Value, Math.PI, 2.0 * Math.PI));
profileCurveLoops.Add(diskInnerCurveLoop);
}
SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId);
Solid sweptDiskSolid = GeometryCreationUtilities.CreateSweptGeometry(trimmedDirectrixInLCS, 0, startParam, profileCurveLoops,
solidOptions);
IList<GeometryObject> myObjs = new List<GeometryObject>();
if (sweptDiskSolid != null)
myObjs.Add(sweptDiskSolid);
return myObjs;
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:64,代码来源:IFCSweptDiskSolid.cs
示例20: ProcessIFCPolyline
private void ProcessIFCPolyline(IFCAnyHandle ifcCurve)
{
IList<IFCAnyHandle> points = IFCAnyHandleUtil.GetAggregateInstanceAttribute<List<IFCAnyHandle>>(ifcCurve, "Points");
int numPoints = points.Count;
if (numPoints < 2)
{
string msg = "IfcPolyLine had " + numPoints + ", expected at least 2, ignoring";
IFCImportFile.TheLog.LogError(Id, msg, false);
return;
}
IList<XYZ> pointXYZs = new List<XYZ>();
foreach (IFCAnyHandle point in points)
{
XYZ pointXYZ = IFCPoint.ProcessScaledLengthIFCCartesianPoint(point);
pointXYZs.Add(pointXYZ);
}
CurveLoop = IFCGeometryUtil.CreatePolyCurveLoop(pointXYZs, points, Id, false);
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:20,代码来源:IFCCurve.cs
注:本文中的CurveLoop类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论