示例#1
0
        protected override Geometry GetGeometryCore(out bool autodispose)
        {
            IGeometryEntity entity = MeshEntity.Geometry;

            autodispose = true;
            return(Geometry.ToGeometry(entity, true));
        }
示例#2
0
        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()));
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        /// <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));
        }
示例#7
0
        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);
        }
示例#8
0
        /// <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.
        }
示例#9
0
        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());
        }
示例#11
0
        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));
        }
示例#12
0
 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));
 }
示例#13
0
        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));
        }
示例#14
0
        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);
        }
示例#15
0
 public ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength)
 {
     DSGeometryApplication.Check();
     return(new SubDMeshEntity());
 }
示例#16
0
 public virtual ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength)
 {
     throw new NotImplementedException("Factory method SubDMeshFromGeometry not implemented");
 }
示例#17
0
 public IPointEntity GetClosestPoint(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
示例#18
0
 public IGeometryEntity[] NonRegularUnionWith(IGeometryEntity geometry)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
示例#19
0
 public IGeometryEntity[] UnionWith(IGeometryEntity geometry)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
示例#20
0
 public IGeometryEntity[] SubtractFrom(IGeometryEntity geometry)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
示例#21
0
 public IGeometryEntity[] Project(IGeometryEntity geometry, IVector direction)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
示例#22
0
 public IGeometryEntity[] Intersect(IGeometryEntity[] entity)
 {
     throw new NotImplementedException();
 }
示例#23
0
 public bool DoesIntersect(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
示例#24
0
        internal virtual DSGeometry TransformBy(ICoordinateSystemEntity csEntity)
        {
            IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity);

            return(ToGeometry(clone, true));
        }
示例#25
0
        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);
        }
示例#26
0
 public IBoundingBoxEntity BoundingBoxByGeometry(IGeometryEntity geom)
 {
     throw new NotImplementedException();
 }
示例#27
0
 public IGeometryEntity[] Project(IGeometryEntity geometry, IVectorEntity direction)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
示例#28
0
 public IBoundingBoxEntity BoundingBoxByGeometryCoordinateSystem(IGeometryEntity geom, ICoordinateSystemEntity cs)
 {
     throw new NotImplementedException();
 }
示例#29
0
        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);
        }
示例#30
0
 public ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength)
 {
     DSGeometryApplication.Check();
     return new SubDMeshEntity();
 }
示例#31
0
        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);
        }
示例#32
0
 public IGeometryEntity[] Split(IGeometryEntity tool)
 {
     throw new NotImplementedException();
 }
示例#33
0
 internal DSSurface(IGeometryEntity host, bool persist = false)
     : base(host, persist)
 {
 }
示例#34
0
 public IGeometryEntity[] Trim(IGeometryEntity tool, IPointEntity pick)
 {
     throw new NotImplementedException();
 }
示例#35
0
 public IGeometryEntity[] Split(IGeometryEntity[] tools)
 {
     throw new NotImplementedException();
 }
示例#36
0
 public IGeometryEntity[] Project(IGeometryEntity iGeometryEntity, IVectorEntity iVectorEntity)
 {
     throw new NotImplementedException();
 }
示例#37
0
 internal DSGeometry(IGeometryEntity host, bool persist)
     : base(host)
 {
     InitGeometry(persist);
 }
示例#38
0
 public virtual ISubDMeshEntity SubDMeshFromGeometry(IGeometryEntity geometry, double maxEdgeLength)
 {
     throw new NotImplementedException("Factory method SubDMeshFromGeometry not implemented");
 }
示例#39
0
 public IBoundingBoxEntity BoundingBoxByGeometryCoordinateSystem(IGeometryEntity[] geom, ICoordinateSystemEntity cs) { throw new NotImplementedException(); }
示例#40
0
 public IGeometryEntity[] Project(IGeometryEntity iGeometryEntity, IVectorEntity iVectorEntity)
 {
     throw new NotImplementedException();
 }
示例#41
0
 public IBoundingBoxEntity BoundingBoxByGeometry(IGeometryEntity[] geom) { throw new NotImplementedException(); }
示例#42
0
 public IGeometryEntity[] Intersect(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
示例#43
0
 public IGeometryEntity[] SubtractFrom(IGeometryEntity geometry)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
示例#44
0
 public IGeometryEntity[] Trim(IGeometryEntity[] tools, IPointEntity pick)
 {
     throw new NotImplementedException();
 }
示例#45
0
 public ISolidEntity NonRegularUnionWithMany(IGeometryEntity[] solids)
 {
     return new SolidEntity();
 }
示例#46
0
 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);
 }
示例#47
0
 public double DistanceTo(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
示例#48
0
 public double DistanceTo(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
示例#49
0
 internal DSSurface(IGeometryEntity host, bool persist = false)
     : base(host, persist)
 {
 }
示例#50
0
 public IPointEntity GetClosestPoint(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }