internal override IGeometryEntity[] ProjectOn(Geometry other, Vector direction) { IVector dir = direction.IVector; Surface surf = other as Surface; if (null != surf) { return(surf.SurfaceEntity.Project(PointEntity, dir)); } Curve curve = other as Curve; if (null != curve) { IPointEntity pt = curve.CurveEntity.Project(PointEntity, dir); return(new IGeometryEntity[] { pt }); } Plane plane = other as Plane; if (null != plane) { IPointEntity pt = plane.PlaneEntity.Project(PointEntity, dir); return(new IGeometryEntity[] { pt }); } Solid solid = other as Solid; if (null != solid) { return(solid.SolidEntity.Project(PointEntity, dir)); } return(base.ProjectOn(other, direction)); }
public void Set(IPointEntity origin, IVectorEntity xAxis, IVectorEntity yAxis, IVectorEntity zAxis) { this.Origin = origin; this.XAxis = xAxis; this.YAxis = yAxis; this.ZAxis = zAxis; }
public void UpdateCone(IPointEntity startPoint, IPointEntity endPoint, double startRadius, double endRadius) { this.StartPoint = startPoint; this.EndPoint = endPoint; this.StartRadius = startRadius; this.EndRadius = endRadius; }
// TODO: To be fixed - pratapa /// <summary> /// /// </summary> /// <param name="planes"></param> /// <param name="surfaces"></param> /// <param name="solids"></param> /// <param name="selectPoint"></param> /// <returns></returns> public DSSolid Trim(DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint) { IPlaneEntity[] hostPlanes = planes.ConvertAll(DSGeometryExtension.ToEntity <DSPlane, IPlaneEntity>); ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity <DSSurface, ISurfaceEntity>); ISolidEntity[] hostSolids = solids.ConvertAll(DSGeometryExtension.ToEntity <DSSolid, ISolidEntity>); if (selectPoint == null) { throw new System.ArgumentNullException("selectPoint"); } IPointEntity hostPoint = selectPoint.PointEntity; if (hostPlanes == null && hostSurfaces == null && hostSolids == null) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "DSGeometry", "DSSolid.Trim")); } ISolidEntity trimSolid = SolidEntity.Trim(hostPlanes, hostSurfaces, hostSolids, hostPoint); if (null == trimSolid) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Trim")); } Hide(planes); Hide(surfaces); Hide(solids); SetVisibility(false); return(new DSSolid(trimSolid, true)); }
public IConeEntity ConeByPointsRadii(IPointEntity startPoint, IPointEntity endPoint, double startRadius, double endRadius) { DSGeometryApplication.Check(); ConeEntity cone = new ConeEntity(); cone.UpdateCone(startPoint, endPoint, startRadius, endRadius); return cone; }
public ILineEntity ReadLine() { using (IPointEntity start = ReadPoint("StartPoint"), end = ReadPoint("EndPoint")) { return(HostFactory.Factory.LineByStartPointEndPoint(start, end)); } }
public CoordinateEntity(IPointEntity origin, IVectorEntity xAxis, IVectorEntity yAxis, IVectorEntity zAxis) { this.Origin = origin; this.XAxis = xAxis; this.YAxis = yAxis; this.ZAxis = zAxis; }
/// <summary> /// /// </summary> /// <param name="curves"></param> /// <param name="planes"></param> /// <param name="surfaces"></param> /// <param name="solids"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSCurve[] curves, DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint, bool autoExtend) { if (null == selectPoint) { throw new System.ArgumentNullException("selectPoint"); } ICurveEntity[] hostCurves = curves.ConvertAll(DSGeometryExtension.ToEntity <DSCurve, ICurveEntity>); IPlaneEntity[] hostPlanes = planes.ConvertAll(DSGeometryExtension.ToEntity <DSPlane, IPlaneEntity>); ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity <DSSurface, ISurfaceEntity>); ISolidEntity[] hostSolids = solids.ConvertAll(DSGeometryExtension.ToEntity <DSSolid, ISolidEntity>); IPointEntity hostPoint = selectPoint.PointEntity; if (hostCurves == null && hostPlanes == null && hostSurfaces == null && hostSolids == null) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "DSGeometry", "DSSurface.Trim")); } ISurfaceEntity trimSurface = SurfaceEntity.Trim(hostCurves, hostPlanes, hostSurfaces, hostSolids, hostPoint, autoExtend); //For trim operation, if the return value is not null, hide the original tools and surfaces. if (null != trimSurface) { Hide(curves); Hide(planes); Hide(surfaces); Hide(solids); SetVisibility(false); } return(trimSurface.ToSurf(true, this)); }
public IArcEntity ArcByCenterPointRadiusAngle(IPointEntity center, double radius, double startAngle, double endAngle, IVectorEntity normal) { DSGeometryApplication.Check(); double sweepAngle = endAngle - startAngle; return(new ArcEntity(center, normal, radius, startAngle, sweepAngle)); }
public IBSplineSurfaceEntity BSplineSurfaceByControlVertices(IPointEntity[][] controlVertices, int uDegree, int vDegree) { DSGeometryApplication.Check(); IBSplineSurfaceEntity surface = new BSplineSurfaceEntity(); surface.UpdateByPoles(controlVertices, uDegree, vDegree); return surface; }
/// <summary> /// Extracts the polygonal faces from the given mesh and returns them /// as an array of Polygons. /// </summary> /// <returns>Array of Polygons.</returns> public DSPolygon[] ExtractPolygon() { int nFaces = FaceIndices.Length; List <IPolygonEntity> polygons = new List <IPolygonEntity>(); for (int iFace = 0; iFace < nFaces; ++iFace) { int nVerts = FaceIndices[iFace].Length; IPointEntity[] vertices = new IPointEntity[nVerts]; for (int i = 0; i < nVerts; ++i) { vertices[i] = Vertices[FaceIndices[iFace][i]].PointEntity; } IPolygonEntity polygon = HostFactory.Factory.PolygonByVertices(vertices); if (null == polygon) { continue; } polygons.Add(polygon); } return(polygons.ToArray().ToArray <DSPolygon, IPolygonEntity>(true)); //don't persist returned polygons. }
public IArcEntity ArcByCenterPointStartPointSweepAngle(IPointEntity centerPoint, IPointEntity startPoint, double sweepAngle, IVector normal) { DSGeometryApplication.Check(); double radius = startPoint.DistanceTo(centerPoint); double startAngle = 30; return new ArcEntity(centerPoint, normal, radius, startAngle, sweepAngle); }
public ISphereEntity SphereByCenterPointRadius(IPointEntity centerPoint, double radius) { DSGeometryApplication.Check(); ISphereEntity sph = new SphereEntity(centerPoint, radius); return(sph); }
private Point ProjectOnGeometry(Geometry contextGeometry, Vector direction) { IPointEntity closestPoint = null; if (null == direction) { return(contextGeometry.ClosestPointTo(this)); } else { IGeometryEntity[] entities = ProjectOn(contextGeometry, direction); if (null == entities || entities.Length == 0) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "Project along direction")); } int nearestIndex = GetIndexOfNearestGeometry(entities, PointEntity); IGeometryEntity closestGeometry = entities[nearestIndex]; //Clone the closest geometry closestPoint = closestGeometry.Clone() as IPointEntity; //Done with projected entities, dispose them. entities.DisposeObject(); } return(new Point(closestPoint, true)); }
public IPlaneEntity PlaneByOriginNormal(IPointEntity origin, IVectorEntity normal) { DSGeometryApplication.Check(); IPlaneEntity plane = new PlaneEntity(origin, normal); return(plane); }
public IBSplineSurfaceEntity BSplineSurfaceByPoints(IPointEntity[][] points, int uDegree, int vDegree) { DSGeometryApplication.Check(); IBSplineSurfaceEntity surface = new BSplineSurfaceEntity(); surface.UpdateByPoints(points, uDegree, vDegree); return surface; }
public ILineEntity LineByStartPointEndPoint(IPointEntity startPoint, IPointEntity endPoint) { DSGeometryApplication.Check(); LineEntity lnhost = new LineEntity(); lnhost.UpdateEndPoints(startPoint, endPoint); return(lnhost); }
public IConeEntity ConeByPointsRadii(IPointEntity startPoint, IPointEntity endPoint, double startRadius, double endRadius) { DSGeometryApplication.Check(); ConeEntity cone = new ConeEntity(); cone.UpdateCone(startPoint, endPoint, startRadius, endRadius); return(cone); }
public IArcEntity ArcByCenterPointStartPointSweepAngle(IPointEntity centerPoint, IPointEntity startPoint, double sweepAngle, IVectorEntity normal) { DSGeometryApplication.Check(); double radius = startPoint.DistanceTo(centerPoint); double startAngle = 30; return(new ArcEntity(centerPoint, normal, radius, startAngle, sweepAngle)); }
internal ArcEntity(IPointEntity center, IVectorEntity normal, double radius, double startAngle, double sweepAngle) { this.CenterPoint = center; this.Normal = normal; this.Radius = radius; this.StartAngle = startAngle; this.SweepAngle = sweepAngle; }
internal ArcEntity(IPointEntity center, IVector normal, double radius, double startAngle, double sweepAngle) { this.CenterPoint = center; this.Normal = normal; this.Radius = radius; this.StartAngle = startAngle; this.SweepAngle = sweepAngle; }
private Plane Offset(Vector offset) { IPointEntity origin = Origin.PointEntity; IPointEntity newOrigin = origin.Add(offset); Plane plane = Plane.ByOriginNormal(newOrigin.ToPoint(false, null), Normal, Size); plane.Context = this; return(plane); }
public ICircleEntity ReadCircle() { using (IPointEntity cen = ReadPoint("CenterPoint")) { double radius = ReadDouble("Radius"); IVector normal = ReadVector("Normal"); return(HostFactory.Factory.CircleByCenterPointRadius(cen, radius, normal)); } }
public NurbsSurfaceEntity(IPointEntity[][] pts, int degreeU, int degreeV, int p) { if (p == 0) this.Points = pts; else this.Poles = pts; this.DegreeU = degreeU; this.DegreeV = degreeV; }
public override string ToString() { IPointEntity pos = VertexEntity.GetPointGeometry(); int nEdges = VertexEntity.GetAdjacentEdgeCount(); int nFaces = VertexEntity.GetAdjacentFaceCount(); var f6 = GeometryExtension.DoublePrintFormat; string position = string.Format("Position({0}, {1}, {2})", pos.X.ToString(f6), pos.Y.ToString(f6), pos.Z.ToString(f6)); return(string.Format("Vertex({0}, AdjacentEdges = {1}, AdjacentFaces = {2})", position, nEdges, nFaces)); }
public IConeEntity ConeByRadiusLength(ICoordinateSystemEntity cs, double startRadius, double endRadius, double height) { DSGeometryApplication.Check(); ConeEntity cone = new ConeEntity(); IPointEntity startPoint = cs.Origin; IPointEntity endPoint = new PointEntity(cs.Origin.X, cs.Origin.Y, cs.Origin.Z + height); cone.UpdateCone(startPoint, endPoint, startRadius, endRadius); return(cone); }
public string WriteEntity(IPointEntity point, string paramName = null) { if (string.IsNullOrEmpty(paramName)) { paramName = string.Format("__point_{0}", ++id); } mExpression.AppendFormat("{0} = Point.ByCoordinates({1}, {2}, {3});", paramName, point.X, point.Y, point.Z); mExpression.AppendLine(); return(paramName); }
internal virtual IPointEntity ClosestPointTo(IPointEntity otherPoint) { try { return(GeomEntity.GetClosestPoint(otherPoint)); } catch (System.NotImplementedException) { throw new System.InvalidOperationException(string.Format(Properties.Resources.NotSupported, "ClosestPointTo", GetType().Name)); } }
public IArcEntity ReadArc() { using (IPointEntity cen = ReadPoint("CenterPoint")) { double radius = ReadDouble("Radius"); double startAngle = ReadDouble("StartAngle"); double sweepAngle = ReadDouble("SweepAngle"); double endAngle = startAngle + sweepAngle; IVector normal = ReadVector("Normal"); return(HostFactory.Factory.ArcByCenterPointRadiusAngle(cen, radius, startAngle, endAngle, normal)); } }
public IArcEntity ArcByCenterPointStartPointSweepPoint(IPointEntity centerPoint, IPointEntity startPoint, IPointEntity sweepPoint) { DSGeometryApplication.Check(); Vector start_center = Vector.ByCoordinates(startPoint.X - centerPoint.X, startPoint.Y - centerPoint.Y, startPoint.Z - centerPoint.Z); Vector sweep_center = Vector.ByCoordinates(sweepPoint.X - centerPoint.X, sweepPoint.Y - centerPoint.Y, sweepPoint.Z - centerPoint.Z); Vector normal = start_center.Cross(sweep_center); double radius = start_center.GetLength(); Vector Axis = Vector.ByCoordinates(1, 0, 0); double startAngle = Math.Acos(start_center.Dot(Axis) / (start_center.GetLength() * Axis.GetLength())); double sweepAngle = Math.Acos(start_center.Dot(sweep_center) / (start_center.GetLength() * sweep_center.GetLength())); return new ArcEntity(centerPoint, normal.ToIVector(), radius, startAngle, sweepAngle); }
public ICoordinateSystemEntity ReadCoordinateSystem() { ICoordinateSystemEntity cs = HostFactory.Factory.CoordinateSystemByData(null); using (IPointEntity origin = ReadPoint("Origin")) { IVector xAxis = ReadVector("XAxis"); IVector yAxis = ReadVector("YAxis"); IVector zAxis = ReadVector("ZAxis"); cs.Set(origin, xAxis, yAxis, zAxis); return(cs); } }
public IArcEntity ArcByCenterPointStartPointSweepPoint(IPointEntity centerPoint, IPointEntity startPoint, IPointEntity sweepPoint) { DSGeometryApplication.Check(); Vector start_center = Vector.ByCoordinates(startPoint.X - centerPoint.X, startPoint.Y - centerPoint.Y, startPoint.Z - centerPoint.Z); Vector sweep_center = Vector.ByCoordinates(sweepPoint.X - centerPoint.X, sweepPoint.Y - centerPoint.Y, sweepPoint.Z - centerPoint.Z); Vector normal = start_center.Cross(sweep_center); double radius = start_center.GetLength(); Vector Axis = Vector.ByCoordinates(1, 0, 0); double startAngle = Math.Acos(start_center.Dot(Axis) / (start_center.GetLength() * Axis.GetLength())); double sweepAngle = Math.Acos(start_center.Dot(sweep_center) / (start_center.GetLength() * sweep_center.GetLength())); return(new ArcEntity(centerPoint, normal.ToIVector(), radius, startAngle, sweepAngle)); }
internal static bool EqualsTo(this IPointEntity thisValue, IPointEntity value) { if (Object.ReferenceEquals(thisValue, value)) { return(true); } if (null == thisValue || null == value) { return(false); } return(GeometryExtension.Equals(thisValue.X, value.X) && GeometryExtension.Equals(thisValue.Y, value.Y) && GeometryExtension.Equals(thisValue.Z, value.Z)); }
private static IPointEntity ByCartesianCoordinatesCore(CoordinateSystem contextCoordinateSystem, double xTranslation, double yTranslation, double zTranslation) { if (contextCoordinateSystem == null) { return(ByCoordinatesCore(xTranslation, yTranslation, zTranslation)); } IPointEntity pos = HostFactory.Factory.PointByCartesianCoordinates(contextCoordinateSystem.CSEntity, xTranslation, yTranslation, zTranslation); if (pos == null) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "Point.ByCartesianCoordinates")); } return(pos); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="direction"></param> /// <returns></returns> public Point Project(Point point, Vector direction) { if (point == null || direction == null || direction.IsZeroVector()) { return(null); } IPointEntity projectedPt = PlaneEntity.Project(point.PointEntity, direction.IVector); if (null == projectedPt) { return(null); } return(projectedPt.ToPoint(true, this)); }
internal DSCoordinateSystem GetCSAtParameters(double u, double v) { bool uchange = DSGeometryExtension.ClipParamRange(ref u); bool vchange = DSGeometryExtension.ClipParamRange(ref v); // TO DO - throw a warning each time a condition above is satisfied. //throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "u or v parameter", "Surface.PointAtUVParameters")); IPointEntity pos = SurfaceEntity.PointAtParameter(u, v); DSPoint origin = pos.ToPoint(false, null); DSVector xAxis = new DSVector(SurfaceEntity.TangentAtUParameter(u, v)); DSVector yAxis = new DSVector(SurfaceEntity.TangentAtVParameter(u, v)); DSVector zAxis = xAxis.Cross(yAxis); return(DSCoordinateSystem.ByOriginVectors(origin, xAxis, yAxis, zAxis, false, true, false)); }
/// <summary> /// Returns the closest point on the Geometry object to another point /// </summary> /// <param name="otherPoint">The other point for classification</param> /// <returns>point on this geometry</returns> public DSPoint ClosestPointTo(DSPoint otherPoint) { if (null == otherPoint) { throw new System.ArgumentNullException("otherPoint"); } IPointEntity entity = ClosestPointTo(otherPoint.PointEntity); if (null == entity) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "ClosestPointTo")); } return(entity.ToPoint(true, this)); }
public ISolidEntity Trim(IPlaneEntity[] planes, ISurfaceEntity[] surfaces, ISolidEntity[] solids, IPointEntity point) { return new SolidEntity(); }
public void UpdateSphere(IPointEntity centerPoint, double radius) { this.CenterPoint = centerPoint; this.Radius = radius; }
public SphereEntity(IPointEntity centerPoint, double radius) { this.CenterPoint = centerPoint; this.Radius = radius; }
internal BSplineCurveEntity(IPointEntity[] controlVertices, int degree, bool periodic) { this.ControlVertices = controlVertices; this.degree = degree; this.periodic = periodic; }
public void UpdateEndPoints(IPointEntity start, IPointEntity end) { StartPoint = start; EndPoint = end; }
internal IPointEntity[] PointsAtEqualArcLengthCore(int numberOfPoints) { if (numberOfPoints < 1) throw new System.ArgumentException(string.Format(Properties.Resources.LessThan, "number of points", "one"), "numberOfPoints"); double length = Length; if (numberOfPoints == 1 || length.EqualsTo(0.0)) return new[] { StartPoint.PointEntity.Clone() as IPointEntity }; bool isClosed = IsClosed; if (numberOfPoints == 2 && !isClosed) return new[] { StartPoint.PointEntity.Clone() as IPointEntity, EndPoint.PointEntity.Clone() as IPointEntity }; double steps = (isClosed ? length / numberOfPoints : length / (numberOfPoints - 1)); IPointEntity[] pts = new IPointEntity[numberOfPoints]; for (int i = 0; i < numberOfPoints; ++i) { double dist = i * steps; pts[i] = CurveEntity.PointAtDistance(dist); } return pts; }
public IUVEntity UVParameterAtPoint(IPointEntity point) { throw new NotImplementedException(); }
public virtual IConeEntity ConeByPointsRadius(IPointEntity startPoint, IPointEntity endPoint, double startRadius, double endRadius) { throw new NotImplementedException("Factory method ConeByPointsRadius not implemented"); }
public bool UpdateByPoints(IPointEntity[][] points, int uDegree, int vDegree) { this.Points = points; this.DegreeU = uDegree; this.DegreeV = vDegree; return true; }
public void UpdateVertices(IPointEntity[] positions) { this.Positions = positions; }
internal PolygonEntity() { Positions = new IPointEntity[2] { new PointEntity(), new PointEntity(1,1,1) }; }
public bool UpdateSolidByRevolve(ICurveEntity profileCurve, IPointEntity originPoint, IVectorEntity revolveAxis, double startAngle, double sweepAngle) { return false; }
public void Rotate(IPointEntity origin, IVectorEntity axis, double degrees) { throw new NotImplementedException(); }
public IGeometryEntity[] Project(IPointEntity PointEntity, IVectorEntity dir) { throw new NotImplementedException(); }
internal override IPointEntity ClosestPointTo(IPointEntity otherPoint) { return PlaneEntity.Project(otherPoint, Normal.IVector); }
internal override IPointEntity ClosestPointTo(IPointEntity otherPoint) { return CurveEntity.GetClosestPointTo(otherPoint, false); }
public ICoordinateSystemEntity Rotation(double rotationAngle, IVectorEntity axis, IPointEntity origin) { return new CoordinateEntity(); }
public bool UpdateByPoles(IPointEntity[][] poles, int uDegree, int vDegree) { this.Poles = poles; this.UDegree = uDegree; this.VDegree = vDegree; return true; }
public void Scale2D(IPointEntity from, IPointEntity to) { throw new NotImplementedException(); }
internal override IPointEntity ClosestPointTo(IPointEntity otherPoint) { return SurfaceEntity.GetClosestPoint(otherPoint); }