private CoordinateSystem(ICoordinateSystemEntity host, bool visible) : base(host) { InitializeGuaranteedProperties(); if (visible) Visible = visible; }
public bool UpdateByCoordinateSystem(ICoordinateSystemEntity cs, int orientation, string textString, double fontSize) { this.Orientation = orientation; this.String = textString; this.FontSize = fontSize; return(true); }
public void WriteObject(ICoordinateSystemEntity entity) { WriteEntity("Origin", entity.Origin); WriteEntity("XAxis", entity.XAxis); WriteEntity("YAxis", entity.YAxis); WriteEntity("ZAxis", entity.ZAxis); }
internal override DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { DSSubDivisionMesh mesh = base.TransformBy(csEntity) as DSSubDivisionMesh; mesh.SubDivisionLevel = this.SubDivisionLevel; return(mesh); }
private static ICuboidEntity CuboidByLengthsCore(ICoordinateSystemEntity contextCoordinateSystem, double length, double width, double height) { string kMethod = "Cuboid.ByLengths"; if (length.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "length"), "length"); } if (height.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "height"), "height"); } if (width.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "width"), "width"); } if (null == contextCoordinateSystem) { throw new System.ArgumentNullException("contextCoordinateSystem"); } if (!contextCoordinateSystem.IsScaledOrtho()) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "Shear CoordinateSystem", kMethod)); } ICuboidEntity entity = HostFactory.Factory.CuboidByLengths(contextCoordinateSystem, length, width, height); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, kMethod)); } return(entity); }
public bool UpdateByCoordinateSystem(ICoordinateSystemEntity cs, int orientation, string textString, double fontSize) { this.Orientation = orientation; this.String = textString; this.FontSize = fontSize; return true; }
public ICuboidEntity CuboidByLengths(ICoordinateSystemEntity cs, double length, double width, double height) { DSGeometryApplication.Check(); ICuboidEntity cub = new CuboidEntity(new double[] { cs.Origin.X, cs.Origin.Y, cs.Origin.Z }, length, width, height); return(cub); }
internal override Geometry TransformBy(ICoordinateSystemEntity csEntity) { AssertUniScaledOrtho(csEntity); Text text = base.TransformBy(csEntity) as Text; text.Orientation = Orientation; return(text); }
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); }
private DSSurfaceCurvature(DSSurface contextSurface, double u, double v, ICoordinateSystemEntity coordinateSystemEntity) { FirstPrincipleCurvature = new DSVector(coordinateSystemEntity.XAxis); SecondPrincipleCurvature = new DSVector(coordinateSystemEntity.YAxis); GaussianCurvature = FirstPrincipleCurvature.Length * SecondPrincipleCurvature.Length; mPointOnSurface = DSPoint.ToGeometry(coordinateSystemEntity.Origin, false, contextSurface) as DSPoint; U = u; V = v; ContextSurface = contextSurface; mCoordinateSystem = DSCoordinateSystem.ToCS(coordinateSystemEntity, false); }
private SurfaceCurvature(Surface contextSurface, double u, double v, ICoordinateSystemEntity coordinateSystemEntity) { FirstPrincipleCurvature = new Vector(coordinateSystemEntity.XAxis); SecondPrincipleCurvature = new Vector(coordinateSystemEntity.YAxis); GaussianCurvature = FirstPrincipleCurvature.Length * SecondPrincipleCurvature.Length; mPointOnSurface = Point.ToGeometry(coordinateSystemEntity.Origin, false, contextSurface) as Point; U = u; V = v; ContextSurface = contextSurface; mCoordinateSystem = CoordinateSystem.ToCS(coordinateSystemEntity, false); }
public ICoordinateSystemEntity CoordinateSystemBySphericalCoordinates(ICoordinateSystemEntity contextCS, double radius, double theta, double phi) { DSGeometryApplication.Check(); CoordinateEntity cs = new CoordinateEntity(); cs.Set(new PointEntity() { X = radius * Math.Sin(DegreeToRadian(theta)) * Math.Cos(DegreeToRadian(phi)), Y = radius * Math.Sin(DegreeToRadian(theta)) * Math.Sin(DegreeToRadian(phi)), Z = radius * Math.Cos(DegreeToRadian(theta)) }, contextCS.XAxis, contextCS.YAxis, contextCS.ZAxis); return(cs); }
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 ICoordinateSystemEntity CoordinateSystemByCylindricalCoordinates(ICoordinateSystemEntity contextCS, double radius, double theta, double height) { DSGeometryApplication.Check(); CoordinateEntity cs = new CoordinateEntity(); cs.Set(new PointEntity() { X = radius * Math.Cos(DegreeToRadian(theta)), Y = radius * Math.Sin(DegreeToRadian(theta)), Z = height }, contextCS.XAxis, contextCS.YAxis, contextCS.ZAxis); return(cs); // return new CoordinateEntity() { Origin = new PointEntity() { X = radius*Math.Sin(theta), Y = radius*Math.Cos(theta), Z = height } }; // return new CoordinateEntity(); }
/// <summary> /// Transforms this geometry from source CoordinateSystem to a new /// context CoordinateSystem. /// </summary> /// <param name="fromCoordinateSystem"></param> /// <param name="contextCoordinateSystem"></param> /// <returns>Transformed Geometry.</returns> public DSGeometry Transform(DSCoordinateSystem fromCoordinateSystem, DSCoordinateSystem contextCoordinateSystem) { ICoordinateSystemEntity csEntity = contextCoordinateSystem.CSEntity.PostMultiplyBy(fromCoordinateSystem.CSEntity.Inverse()); DSGeometry geom = TransformBy(csEntity); if (null == geom) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSGeometry.Transform")); } geom.ContextCoordinateSystem = contextCoordinateSystem; SetDisplayPropertiesTo(geom.Display); return(geom); }
public string WriteEntity(ICoordinateSystemEntity cs, string paramName = null) { if (string.IsNullOrEmpty(paramName)) { paramName = string.Format("__cs_{0}", ++id); } string origin = WriteEntity(cs.Origin); string xaxis = WriteEntity(cs.XAxis); string yaxis = WriteEntity(cs.YAxis); string zaxis = WriteEntity(cs.ZAxis); mExpression.AppendFormat("{0} = CoordinateSystem.ByOriginVectors({1}, {2}, {3}, {4});", paramName, origin, xaxis, yaxis, zaxis); mExpression.AppendLine(); return(paramName); }
private static void AssertUniScaledOrtho(ICoordinateSystemEntity csEntity) { if (csEntity.IsUniscaledOrtho()) { return; } if (csEntity.IsScaledOrtho()) { throw new System.ArgumentException(string.Format(Properties.Resources.NotSupported, "Non Uniform Scaling", "Text")); } else { throw new System.ArgumentException(string.Format(Properties.Resources.NotSupported, "Shear Transform", "Text")); } }
internal override DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity); if (null == clone) { throw new System.InvalidOperationException("Failed to clone and transform cone."); } IConeEntity cone = clone as IConeEntity; if (null != cone) { return(new DSCone(cone, true)); } return(ToGeometry(clone, true)); }
internal override Geometry TransformBy(ICoordinateSystemEntity csEntity) { //Let the default code handle orthogonal transform. if (csEntity.IsScaledOrtho()) { return(base.TransformBy(csEntity)); } using (IPointEntity origin = Origin.PointEntity.CopyAndTransform(CoordinateSystem.WCS.CSEntity, csEntity) as IPointEntity) { using (IPointEntity pt = Origin.PointEntity.CopyAndTranslate(Normal.IVector) as IPointEntity) { using (IPointEntity transformPt = pt.CopyAndTransform(CoordinateSystem.WCS.CSEntity, csEntity) as IPointEntity) { Vector normal = origin.GetVectorTo(transformPt).Normalize(); return(Plane.ByOriginNormal(origin.ToPoint(false, null), normal, Size)); } } } }
private Polygon CreatePlaneVisuals(double size, bool persist) { // to display a plane we would be required to draw a rectangle in the plane // // /* * given origin, X & Y * we want to evaluate the four corner points based on size * * where o is the origin of the plane * * Y | | | v1 ______________ v2 | | | | | | | | o | | | | | v4 |______________| v3 | | X |_________________________________________ * */ ICoordinateSystemEntity coordSys = PlaneEntity.GetCoordinateSystem(); IPointEntity orig = coordSys.Origin; var xNorm = new Vector(coordSys.XAxis).Normalize().MultiplyBy(size / 2.0); var yNorm = new Vector(coordSys.YAxis).Normalize().MultiplyBy(size / 2.0); var dirv1 = yNorm - xNorm; var dirv2 = yNorm + xNorm; var dirv3 = dirv1.Negate(); var dirv4 = dirv2.Negate(); Point[] positions = { orig.Add(dirv1).ToPoint(false, null), orig.Add(dirv2).ToPoint(false, null), orig.Add(dirv3).ToPoint(false, null), orig.Add(dirv4).ToPoint(false, null) }; return(new Polygon(positions, persist)); }
private static IConeEntity CylinderByRadiusHeightCore(ICoordinateSystemEntity contextCoordinateSystem, double radius, double height) { string kMethod = "Cylinder.ByRadiusHeight"; if (radius.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "radius"), "radius"); } if (height.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "height"), "height"); } if (null == contextCoordinateSystem) { throw new System.ArgumentNullException("contextCoordinateSystem"); } if (!contextCoordinateSystem.IsUniscaledOrtho()) { if (contextCoordinateSystem.IsScaledOrtho()) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "Non Uniform Scaled CoordinateSystem", kMethod)); } else { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "Shear CoordinateSystem", kMethod)); } } IConeEntity entity = HostFactory.Factory.ConeByRadiusLength(contextCoordinateSystem, radius, radius, height); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, kMethod)); } return(entity); }
/// <summary> /// /// </summary> /// <param name="contextSurface"></param> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public static SurfaceCurvature BySurfaceParameters(Surface contextSurface, double u, double v) { if (contextSurface == null) { return(null); } ISurfaceEntity host = contextSurface.GetSurfaceEntity(); if (host == null) { return(null); } ICoordinateSystemEntity coordinateSystemEntity = host.CurvatureAtParameter(u, v); if (null != coordinateSystemEntity) { SurfaceCurvature surfCurv = new SurfaceCurvature(contextSurface, u, v, coordinateSystemEntity); return(surfCurv); } return(null); }
public virtual ICuboidEntity CuboidByLengths(ICoordinateSystemEntity cs, double length, double width, double height) { throw new NotImplementedException("Factory method CuboidByLengths not implemented"); }
private static CoordinateSystem CreateCoordinateSystem(CoordinateSystem contextCoordinateSystem, ICoordinateSystemEntity localCoordSys, bool visible) { ICoordinateSystemEntity csEntity = contextCoordinateSystem.CSEntity.PostMultiplyBy(localCoordSys); var cs = new CoordinateSystem(csEntity, visible); cs.ContextCoordinateSystem = contextCoordinateSystem; cs.LocalXAxis = new Vector(localCoordSys.XAxis); cs.LocalYAxis = new Vector(localCoordSys.YAxis); cs.LocalZAxis = new Vector(localCoordSys.ZAxis); cs.XTranslation = localCoordSys.Origin.X; cs.YTranslation = localCoordSys.Origin.Y; cs.ZTranslation = localCoordSys.Origin.Z; return cs; }
public IGeometryEntity CopyAndTransform(ICoordinateSystemEntity toCS) { throw new NotImplementedException(); }
public bool IsEqualTo(ICoordinateSystemEntity other) { return false; }
public ICoordinateSystemEntity PreMultiplyBy(ICoordinateSystemEntity other) { return this; }
public ICoordinateSystemEntity CoordinateSystemByCylindricalCoordinates(ICoordinateSystemEntity contextCS, double radius, double theta, double height) { DSGeometryApplication.Check(); CoordinateEntity cs = new CoordinateEntity(); cs.Set(new PointEntity() { X = radius * Math.Cos(DegreeToRadian(theta)), Y = radius * Math.Sin(DegreeToRadian(theta)), Z = height }, contextCS.XAxis, contextCS.YAxis, contextCS.ZAxis); return cs; // return new CoordinateEntity() { Origin = new PointEntity() { X = radius*Math.Sin(theta), Y = radius*Math.Cos(theta), Z = height } }; // return new CoordinateEntity(); }
public virtual ITextEntity TextByCoordinateSystem(ICoordinateSystemEntity parentCoordinateSystem, int orientation, string textString, double fontSize) { throw new NotImplementedException("Factory method TextByCoordinateSystem not implemented"); }
public virtual IPointEntity PointByCartesianCoordinates(ICoordinateSystemEntity cs, double x, double y, double z) { throw new NotImplementedException("Factory method PointByCartesianCoordinates not implemented"); }
public virtual IGeometryEntity CopyAndTransform(ICoordinateSystemEntity fromCS, ICoordinateSystemEntity toCS) { return this; }
public ITextEntity TextByCoordinateSystem(ICoordinateSystemEntity contextCoordinateSystem, int orientation, string textString, double fontSize) { DSGeometryApplication.Check(); return new TextEntity(); }
public IPointEntity PointByCartesianCoordinates(ICoordinateSystemEntity cs, double x, double y, double z) { DSGeometryApplication.Check(); return new PointEntity(cs.Origin.X + x,cs.Origin.Y + y,cs.Origin.Z + z); }
public virtual ICoordinateSystemEntity CoordinateSystemByUniversalTransform(ICoordinateSystemEntity contextCoordinateSys, double[] scaleFactors, double[] rotationAngles, int[] rotationSequence, double[] translationVector, bool translationSequence) { throw new NotImplementedException("Factory method CoordinateSystemByUniversalTransform not implemented"); }
public virtual ICoordinateSystemEntity CoordinateSystemBySphericalCoordinates(ICoordinateSystemEntity contextCS, double radius, double theta, double phi) { throw new NotImplementedException("Factory method CoordinateSystemBySphericalCoordinates not implemented"); }
public virtual IConeEntity ConeByRadiusLength(ICoordinateSystemEntity cs, double startRadius, double endRadius, double height) { throw new NotImplementedException("Factory method ConeByRadiusLength not implemented"); }
internal virtual DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity); return(ToGeometry(clone, true)); }
public void TransformBy(ICoordinateSystemEntity cs) { throw new NotImplementedException(); }
public bool IsEqualTo(ICoordinateSystemEntity other) { return(false); }
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 ICoordinateSystemEntity PostMultiplyBy(ICoordinateSystemEntity other) { return(other); }
public void TransformFromTo(ICoordinateSystemEntity from, ICoordinateSystemEntity to) { throw new NotImplementedException(); }
public ICoordinateSystemEntity PreMultiplyBy(ICoordinateSystemEntity other) { return(this); }
public ICoordinateSystemEntity PostMultiplyBy(ICoordinateSystemEntity other) { return other; }
public ICuboidEntity CuboidByLengths(ICoordinateSystemEntity cs, double length, double width, double height) { DSGeometryApplication.Check(); ICuboidEntity cub = new CuboidEntity(); cub.UpdateCuboid(new double[] { cs.Origin.X, cs.Origin.Y, cs.Origin.Z }, length, width, height); return cub; }
internal static CoordinateSystem ToCS(ICoordinateSystemEntity host, bool visible) { if(null != host) { return host.Owner == null ? new CoordinateSystem(host, visible) : host.Owner as CoordinateSystem; } return null; }
public ICoordinateSystemEntity CoordinateSystemByUniversalTransform(ICoordinateSystemEntity contextCoordinateSys, double[] scaleFactors, double[] rotationAngles, int[] rotationSequence, IVector translationVector, bool translationSequence) { DSGeometryApplication.Check(); return new CoordinateEntity(); }
internal PlaneEntity() { this.Origin = new PointEntity(); this.Normal = DsVector.ByCoordinates(0, 0, 1); this.contextCS = new CoordinateEntity(); }
private static ICuboidEntity CuboidByLengthsCore(ICoordinateSystemEntity contextCoordinateSystem, double length, double width, double height) { string kMethod = "Cuboid.ByLengths"; if (length.LessThanOrEqualTo(0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "length"), "length"); if (height.LessThanOrEqualTo(0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "height"), "height"); if (width.LessThanOrEqualTo(0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "width"), "width"); if (null == contextCoordinateSystem) throw new System.ArgumentNullException("contextCoordinateSystem"); if(!contextCoordinateSystem.IsScaledOrtho()) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "Shear CoordinateSystem", kMethod)); ICuboidEntity entity = HostFactory.Factory.CuboidByLengths(contextCoordinateSystem, length, width, height); if (null == entity) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, kMethod)); return entity; }
public virtual IGeometryEntity CopyAndTransform(ICoordinateSystemEntity fromCS, ICoordinateSystemEntity toCS) { return(this); }
public ICoordinateSystemEntity CoordinateSystemBySphericalCoordinates(ICoordinateSystemEntity contextCS, double radius, double theta, double phi) { DSGeometryApplication.Check(); CoordinateEntity cs = new CoordinateEntity(); cs.Set(new PointEntity() { X = radius * Math.Sin(DegreeToRadian(theta)) * Math.Cos(DegreeToRadian(phi)), Y = radius * Math.Sin(DegreeToRadian(theta)) * Math.Sin(DegreeToRadian(phi)), Z = radius * Math.Cos(DegreeToRadian(theta)) }, contextCS.XAxis, contextCS.YAxis, contextCS.ZAxis); return cs; }
internal override DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { DSSubDivisionMesh mesh = base.TransformBy(csEntity) as DSSubDivisionMesh; mesh.SubDivisionLevel = this.SubDivisionLevel; return mesh; }
internal override DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity); if (null == clone) throw new System.InvalidOperationException("Failed to clone and transform cone."); IConeEntity cone = clone as IConeEntity; if (null != cone) return new DSCone(cone, true); return ToGeometry(clone, true); }
internal override Geometry TransformBy(ICoordinateSystemEntity csEntity) { //Let the default code handle orthogonal transform. if (csEntity.IsScaledOrtho()) return base.TransformBy(csEntity); using (IPointEntity origin = Origin.PointEntity.CopyAndTransform(CoordinateSystem.WCS.CSEntity, csEntity) as IPointEntity) { using (IPointEntity pt = Origin.PointEntity.CopyAndTranslate(Normal.IVector) as IPointEntity) { using (IPointEntity transformPt = pt.CopyAndTransform(CoordinateSystem.WCS.CSEntity, csEntity) as IPointEntity) { Vector normal = origin.GetVectorTo(transformPt).Normalize(); return Plane.ByOriginNormal(origin.ToPoint(false, null), normal, Size); } } } }