/// <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)); }
/// <summary> /// /// </summary> /// <param name="toolSolid"></param> /// <returns></returns> public DSSurface[] Difference(DSSolid toolSolid) { string kMethod = "DSSurface.Difference"; if (null == toolSolid) { throw new System.ArgumentNullException("toolSolid"); } IGeometryEntity[] geoms = SurfaceEntity.SubtractFrom(toolSolid.SolidEntity); if (null == geoms) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethod)); } return(geoms.ConvertAll( (IGeometryEntity g) => { ISurfaceEntity s = g as ISurfaceEntity; if (null == s) { return null; } return s.ToSurf(true, this); })); }
/// <summary> /// Returns the U, V parameter at a given point of a surface /// </summary> /// <param name="point"></param> /// <returns>double[] == the first element is U, the second double is V</returns> public double[] ParameterAtPoint(DSPoint point) { System.Tuple <double, double> parametersTuple = SurfaceEntity.GetUVParameterAtPoint(point.PointEntity); List <double> parameters = new List <double>(); parameters.Add(parametersTuple.Item1); parameters.Add(parametersTuple.Item2); return(parameters.ToArray()); }
/// <summary> /// /// </summary> /// <param name="persist"></param> /// <returns></returns> protected DSBSplineSurface[] ConvertToBSplineSurface(bool persist) { if (SurfaceEntity is IBSplineSurfaceEntity) { return(new DSBSplineSurface[] { this as DSBSplineSurface }); } IBSplineSurfaceEntity[] entities = SurfaceEntity.ConvertToBSplineSurface(); return(entities.ConvertAll((IBSplineSurfaceEntity h) => h.ToBSurf(persist, this))); }
/// <summary> /// Offsets the surface by the given thickness to create a Solid. /// 'bothSides' flag can be used to choose if the surface is required /// to be offset on both sides. /// </summary> /// <param name="thickness">Thickness value in one side of the surface.</param> /// <param name="bothSides">Whether to offset surface in both sides.</param> /// <returns>Solid.</returns> public DSSolid Thicken(double thickness, bool bothSides) { ISolidEntity entity = SurfaceEntity.Thicken(thickness, bothSides); if (null == entity) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.Thicken")); } return(entity.ToSolid(true, this)); }
/// <summary> /// Split this surface using a surface as cutting tool. /// </summary> /// <param name="splittingSurface">Surface as cutting tool.</param> /// <returns>Array of surfaces.</returns> public DSSurface[] Split(DSSurface splittingSurface) { ISurfaceEntity[] splitSurfaces = SurfaceEntity.Split(splittingSurface.SurfaceEntity); if (null == splitSurfaces || splitSurfaces.Length < 1) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSurface.Split")); } return(splitSurfaces.ConvertAll((ISurfaceEntity host) => host.ToSurf(true, this))); }
/// <summary> /// /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public DSVector NormalAtParameter(double u, double v) { IVector normal = SurfaceEntity.NormalAtParameter(u, v); if (null == normal) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSBSplineSurface.NormalAtParameter")); } return(new DSVector(normal)); }
internal SurfaceConfiguration(string name) { SurfaceEntity = new SurfaceEntity { SurfacePositions = new List <SurfacePositionEntity>() }; Guid = System.Guid.NewGuid().ToString(); Name = name; IsActive = false; DeviceConfigurations = new List <SurfaceDeviceConfiguration>(); ApplyToEntity(); }
internal ArtemisSurface(RGBSurface rgbSurface, SurfaceEntity surfaceEntity, double scale) { SurfaceEntity = surfaceEntity; EntityId = surfaceEntity.Id; RgbSurface = rgbSurface; Scale = scale; Name = surfaceEntity.Name; IsActive = surfaceEntity.IsActive; // Devices are not populated here but as they are detected Devices = new List <ArtemisDevice>(); }
public void DeleteSurfaceConfiguration(ArtemisSurface surface) { if (surface == ActiveSurface) { throw new ArtemisCoreException($"Cannot delete surface entity '{surface.Name}' because it is active."); } lock (_surfaceConfigurations) { SurfaceEntity entity = surface.SurfaceEntity; _surfaceConfigurations.Remove(surface); _surfaceRepository.Remove(entity); } }
/// <summary> /// Returns a normal to the surface at the specified point /// </summary> /// <param name="pointOnSurface">Point on the surface at which the normal is required</param> /// <returns></returns> public DSVector NormalAtPoint(DSPoint pointOnSurface) { if (pointOnSurface == null) { throw new System.ArgumentNullException("pointOnSurface"); } IVector normal = SurfaceEntity.GetNormalAtPoint(pointOnSurface.PointEntity); if (normal == null) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.NormalAtPoint")); } return(new DSVector(normal)); }
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)); }
internal ArtemisSurface(RGBSurface rgbSurface, string name, double scale) { SurfaceEntity = new SurfaceEntity { DeviceEntities = new List <DeviceEntity>() }; EntityId = Guid.NewGuid(); Name = name; Scale = scale; RgbSurface = rgbSurface; IsActive = false; // Devices are not populated here but as they are detected Devices = new List <ArtemisDevice>(); ApplyToEntity(); }
internal SurfaceConfiguration(SurfaceEntity surfaceEntity) { SurfaceEntity = surfaceEntity; Guid = surfaceEntity.Guid; Name = surfaceEntity.Name; IsActive = surfaceEntity.IsActive; DeviceConfigurations = new List <SurfaceDeviceConfiguration>(); if (surfaceEntity.SurfacePositions == null) { return; } foreach (var position in surfaceEntity.SurfacePositions) { DeviceConfigurations.Add(new SurfaceDeviceConfiguration(position, this)); } }
/// <summary> /// /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <param name="offset"></param> /// <returns></returns> internal DSPoint PointAtParametersCore(ref double u, ref double v, double offset) { 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.PointAtParameters")); IPointEntity pt = SurfaceEntity.PointAtParameter(u, v); if (!offset.EqualsTo(0.0)) { DSVector normal = new DSVector(SurfaceEntity.NormalAtPoint(pt)); DSVector translation = normal.Normalize().Scale(offset); IPointEntity offsetPt = pt.Add(translation); pt.Dispose(); pt = offsetPt; } return(pt.ToPoint(true, this)); }
/// <summary> /// Returns a parallel Surface with specific distance from original surface. /// </summary> /// <param name="distance">Offset distance value.</param> /// <returns>Surface.</returns> public DSSurface Offset(double distance) { if (distance.EqualsTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.IsZero, "offset distance"), "distance"); } ISurfaceEntity surfEntity = SurfaceEntity.Offset(distance); if (null == surfEntity) { throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSurface.Offset")); } DSSurface surf = surfEntity.ToSurf(true, this); surf.Context = this; return(surf); }
internal override IPointEntity ClosestPointTo(IPointEntity otherPoint) { return(SurfaceEntity.GetClosestPoint(otherPoint)); }
internal override IGeometryEntity[] IntersectWithSurface(DSSurface surf) { return(SurfaceEntity.IntersectWith(surf.SurfaceEntity)); }
internal override IGeometryEntity[] IntersectWithPlane(DSPlane plane) { return(SurfaceEntity.IntersectWith(plane.PlaneEntity)); }
/// <summary> /// /// </summary> /// <param name="tol"></param> /// <returns></returns> private DSBSplineSurface ApproxBSplineSurface(double tol) { IBSplineSurfaceEntity surface = SurfaceEntity.ApproxBSpline(tol); return(new DSBSplineSurface(surface, true)); }
/// <summary> /// /// </summary> /// <returns></returns> private DSBSplineSurface ApproxBSplineSurface() { IBSplineSurfaceEntity surface = SurfaceEntity.ApproxBSpline(-1.0); return(new DSBSplineSurface(surface, true)); }
public void Add(SurfaceEntity surfaceEntity) { _dbContext.Surfaces.Add(surfaceEntity); }
public void Remove(SurfaceEntity surfaceEntity) { _dbContext.Surfaces.Remove(surfaceEntity); }
public DSCurve[] IsoCurve(IsoDirection isoDirection, double parameter) { ICurveEntity[] isoLineHosts = SurfaceEntity.GetIsolines((int)isoDirection, parameter); return(isoLineHosts.ToArray <DSCurve, ICurveEntity>(true)); }
public void Add(SurfaceEntity surfaceEntity) { _repository.Insert(surfaceEntity); }
public void Remove(SurfaceEntity surfaceEntity) { _repository.Delete <SurfaceEntity>(surfaceEntity.Id); }
public void Save(SurfaceEntity surfaceEntity) { _repository.Upsert(surfaceEntity); }