protected override Geometry GetGeometryCore(out bool autodispose) { IGeometryEntity entity = MeshEntity.Geometry; autodispose = true; return(Geometry.ToGeometry(entity, true)); }
public static bool ExportToSAT(DSGeometry[] geometry, string filePath) { List <IGeometryEntity> hosts = new List <IGeometryEntity>(); foreach (DSGeometry geom in geometry) { IGeometryEntity geomEntity = geom.GeomEntity as IGeometryEntity; if (null != geomEntity) { hosts.Add(geomEntity); } } if (hosts.Count == 0) { return(false); } if (!filePath.EndsWith(".sat")) { filePath += ".sat"; } if (!Path.IsPathRooted(filePath)) { string foldername = Path.GetDirectoryName(DSGeometrySettings.RootModulePath); filePath = Path.Combine(foldername, filePath); } return(HostFactory.Factory.SaveSat(filePath, hosts.ToArray())); }
internal static DSGeometry ToGeometry(IGeometryEntity host, bool persist = false, DSGeometry context = null) { if (host == null) { return(null); } if (host.Owner != null) { return(host.Owner as DSGeometry); } Func <IGeometryEntity, bool, DSGeometry> constructor = GetGeomConstructor(host); if (null == constructor) { throw new InvalidOperationException(string.Format("Can't locate DSGeometry constructor for type: {0}.", host.GetType())); } DSGeometry geom = constructor(host, persist); if (null != context) { geom.Context = context; } return(geom); }
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)); }
/// <summary> /// /// </summary> /// <param name="offset"></param> /// <returns></returns> protected virtual DSGeometry Translate(DSVector offset) { IGeometryEntity clone = GeomEntity.CopyAndTranslate(offset.IVector); if (null == clone) { throw new InvalidOperationException("Failed to clone and translate geometry."); } DSGeometry geom = ToGeometry(clone, true); return(geom); }
static DSSolid CreateSolid(IGeometryEntity host, bool persist) { ISolidEntity entity = host as ISolidEntity; if (null == entity) { return(null); } if (entity.IsNonManifold()) { return(new DSNonManifoldSolid(entity, persist)); } return(DSSolid.CreateSolid(entity, persist)); }
private static Func <IGeometryEntity, bool, DSGeometry> GetGeomConstructor(IGeometryEntity host) { Type type = host.GetType(); Type[] interfaces = type.GetInterfaces(); for (int i = interfaces.Length - 1; i >= 0; --i) { Func <IGeometryEntity, bool, DSGeometry> constructor; if (mGeometryContructors.TryGetValue(interfaces[i], out constructor)) { return(constructor); } } return(null); }
/// <summary> /// /// </summary> /// <returns></returns> public Geometry SelectNearest(Geometry[] contextGeometries) { if (contextGeometries == null) { throw new System.ArgumentNullException("contextGeometries"); } IGeometryEntity[] hostentities = contextGeometries.ConvertAll(GeometryExtension.ToEntity <Geometry, IGeometryEntity>); if (hostentities == null) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "contextGeometries", "SelectNearest"), "contextGeometries"); } int nearestIndex = GetIndexOfNearestGeometry(hostentities, PointEntity); IGeometryEntity nearestGeom = hostentities[nearestIndex]; return(Geometry.ToGeometry(nearestGeom, false)); //returning one of the existing geometry, so persist is no-op. }
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)); }
/// <summary> /// Creates geometry from given set of data /// </summary> /// <param name="geomType">Geometry type</param> /// <param name="data">Collection of input data to create geometry from</param> /// <returns>Collection of Geometry created using the given data</returns> public static Geometry[] CreateGeometryFromData(string geomType, Array data) { Func <GeometryDataSerializer, IDesignScriptEntity> reader = mSerializers.GetReader(geomType); if (reader == null) { return(null); } List <Geometry> geometry = new List <Geometry>(); GeometryDataSerializer stream = new GeometryDataSerializer(data); while (!stream.DoneReading()) { IGeometryEntity entity = reader(stream) as IGeometryEntity; geometry.Add(Geometry.ToGeometry(entity, true)); } return(geometry.ToArray()); }
static Solid CreateGeometry(IGeometryEntity host, bool persist) { IConeEntity cone = host as IConeEntity; if (null == cone) { return(null); } if (cone.Owner != null) { return(cone.Owner as Solid); } if (IsCylinder(cone)) { return(new Cylinder(cone, persist)); } return(Cone.ToCone(cone, persist)); }
private DSSolid[] SliceWithPlanes(DSPlane[] planes, bool isRegular) { IPlaneEntity[] planeHosts = planes.ConvertAll(DSGeometryExtension.ToEntity <DSPlane, IPlaneEntity>); if (null == planeHosts || planeHosts.Length == 0) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "planes", "DSSolid.SliceWithPlanes"), "planes"); } IGeometryEntity[] solids = null; if (isRegular) { solids = SolidEntity.SliceWithPlanes(planeHosts); } else { solids = new IGeometryEntity[] { SolidEntity.NonRegularSliceWithPlanes(planeHosts) } }; if (solids == null || solids.Length == 0) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.SliceWithPlanes")); } return(solids.ToArray <DSSolid, IGeometryEntity>(true)); }
public DSSolid[] Slice(DSPlane plane, bool isRegular) { if (null == plane) { throw new ArgumentNullException("plane"); } IGeometryEntity[] solids = null; if (isRegular) { solids = SolidEntity.SliceWithPlane(plane.PlaneEntity); } else { solids = new IGeometryEntity[] { SolidEntity.NonRegularSliceWithPlane(plane.PlaneEntity) } }; if (solids == null || solids.Length == 0) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Slice")); } return(solids.ToArray <DSSolid, IGeometryEntity>(true)); }
internal IPersistentObject Persist() { if (null != mPersistent) { return(mPersistent); } //In the absense of persistent manager, bail out. if (null == HostFactory.PersistenceManager) { return(null); } IGeometryEntity geometry = HostImpl as IGeometryEntity; if (geometry == null) { return(null); } DisposeDisplay(); mPersistent = HostFactory.PersistenceManager.Persist(geometry); return(mPersistent); }
public ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength) { DSGeometryApplication.Check(); return(new SubDMeshEntity()); }
public virtual ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength) { throw new NotImplementedException("Factory method SubDMeshFromGeometry not implemented"); }
public IPointEntity GetClosestPoint(IGeometryEntity entity) { throw new NotImplementedException(); }
public IGeometryEntity[] NonRegularUnionWith(IGeometryEntity geometry) { return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }; }
public IGeometryEntity[] UnionWith(IGeometryEntity geometry) { return(new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }); }
public IGeometryEntity[] SubtractFrom(IGeometryEntity geometry) { return(new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }); }
public IGeometryEntity[] Project(IGeometryEntity geometry, IVector direction) { return(new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }); }
public IGeometryEntity[] Intersect(IGeometryEntity[] entity) { throw new NotImplementedException(); }
public bool DoesIntersect(IGeometryEntity entity) { throw new NotImplementedException(); }
internal virtual DSGeometry TransformBy(ICoordinateSystemEntity csEntity) { IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity); return(ToGeometry(clone, true)); }
static Solid CreateGeometry(IGeometryEntity host, bool persist) { IConeEntity cone = host as IConeEntity; if (null == cone) return null; if (cone.Owner != null) return cone.Owner as Solid; if (IsCylinder(cone)) return new Cylinder(cone, persist); return Cone.ToCone(cone, persist); }
public IBoundingBoxEntity BoundingBoxByGeometry(IGeometryEntity geom) { throw new NotImplementedException(); }
public IGeometryEntity[] Project(IGeometryEntity geometry, IVectorEntity direction) { return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }; }
public IBoundingBoxEntity BoundingBoxByGeometryCoordinateSystem(IGeometryEntity geom, ICoordinateSystemEntity cs) { throw new NotImplementedException(); }
public DSSolid[] Slice(DSPlane plane, bool isRegular) { if (null == plane) throw new ArgumentNullException("plane"); IGeometryEntity[] solids = null; if (isRegular) solids = SolidEntity.SliceWithPlane(plane.PlaneEntity); else solids = new IGeometryEntity[] { SolidEntity.NonRegularSliceWithPlane(plane.PlaneEntity) }; if (solids == null || solids.Length == 0) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Slice")); return solids.ToArray<DSSolid, IGeometryEntity>(true); }
public ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength) { DSGeometryApplication.Check(); return new SubDMeshEntity(); }
static DSSolid CreateSolid(IGeometryEntity host, bool persist) { ISolidEntity entity = host as ISolidEntity; if (null == entity) return null; if (entity.IsNonManifold()) return new DSNonManifoldSolid(entity, persist); return DSSolid.CreateSolid(entity, persist); }
public IGeometryEntity[] Split(IGeometryEntity tool) { throw new NotImplementedException(); }
internal DSSurface(IGeometryEntity host, bool persist = false) : base(host, persist) { }
public IGeometryEntity[] Trim(IGeometryEntity tool, IPointEntity pick) { throw new NotImplementedException(); }
public IGeometryEntity[] Split(IGeometryEntity[] tools) { throw new NotImplementedException(); }
public IGeometryEntity[] Project(IGeometryEntity iGeometryEntity, IVectorEntity iVectorEntity) { throw new NotImplementedException(); }
internal DSGeometry(IGeometryEntity host, bool persist) : base(host) { InitGeometry(persist); }
public IBoundingBoxEntity BoundingBoxByGeometryCoordinateSystem(IGeometryEntity[] geom, ICoordinateSystemEntity cs) { throw new NotImplementedException(); }
public IBoundingBoxEntity BoundingBoxByGeometry(IGeometryEntity[] geom) { throw new NotImplementedException(); }
public IGeometryEntity[] Intersect(IGeometryEntity entity) { throw new NotImplementedException(); }
public IGeometryEntity[] SubtractFrom(IGeometryEntity geometry) { return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() }; }
public IGeometryEntity[] Trim(IGeometryEntity[] tools, IPointEntity pick) { throw new NotImplementedException(); }
public ISolidEntity NonRegularUnionWithMany(IGeometryEntity[] solids) { return new SolidEntity(); }
private DSSolid[] SliceWithPlanes(DSPlane[] planes, bool isRegular) { IPlaneEntity[] planeHosts = planes.ConvertAll(DSGeometryExtension.ToEntity<DSPlane, IPlaneEntity>); if (null == planeHosts || planeHosts.Length == 0) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "planes", "DSSolid.SliceWithPlanes"), "planes"); IGeometryEntity[] solids = null; if (isRegular) solids = SolidEntity.SliceWithPlanes(planeHosts); else solids = new IGeometryEntity[] { SolidEntity.NonRegularSliceWithPlanes(planeHosts) }; if (solids == null || solids.Length == 0) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.SliceWithPlanes")); return solids.ToArray<DSSolid, IGeometryEntity>(true); }
public double DistanceTo(IGeometryEntity entity) { throw new NotImplementedException(); }