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

            autodispose = true;
            return(Geometry.ToGeometry(entity, true));
        }
Exemple #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()));
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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.
        }
Exemple #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());
        }
Exemple #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));
        }
Exemple #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));
 }
Exemple #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));
        }
Exemple #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);
        }
Exemple #15
0
 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");
 }
Exemple #17
0
 public IPointEntity GetClosestPoint(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
Exemple #18
0
 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()
     });
 }
Exemple #22
0
 public IGeometryEntity[] Intersect(IGeometryEntity[] entity)
 {
     throw new NotImplementedException();
 }
Exemple #23
0
 public bool DoesIntersect(IGeometryEntity entity)
 {
     throw new NotImplementedException();
 }
Exemple #24
0
        internal virtual DSGeometry TransformBy(ICoordinateSystemEntity csEntity)
        {
            IGeometryEntity clone = GeomEntity.CopyAndTransform(DSCoordinateSystem.WCS.CSEntity, csEntity);

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