Пример #1
0
        /// <summary>
        /// Returns a solid by doing a non-regular union (if 'isRegular' is set
        /// to false) of two solids (manifold or non-manifold)
        /// </summary>
        /// <param name="otherSolid">The other solid</param>
        /// <param name="isRegular">Switch for Regular or Non-regular Union</param>
        /// <returns>Solid</returns>
        public DSSolid Union(DSSolid otherSolid, bool isRegular)
        {
            if (otherSolid == null)
            {
                return(this);
            }
            IGeometryEntity[] solids = null;
            if (isRegular)
            {
                solids = SolidEntity.UnionWith(otherSolid.SolidEntity);
            }
            else
            {
                solids = SolidEntity.NonRegularUnionWith(otherSolid.SolidEntity);
            }

            if (null == solids || solids.Length == 0)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
            }

            ISolidEntity solidhost = solids[0] as ISolidEntity;

            if (solidhost == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
            }

            return(solidhost.ToSolid(true, this));
        }
Пример #2
0
        protected override DSGeometry GetGeometryCore(out bool autodispose)
        {
            ISolidEntity solid = ShellEntity.GetSolidGeometry();

            autodispose = true;
            return(DSGeometry.ToGeometry(solid));
        }
Пример #3
0
        private static ISolidEntity RevolveCore(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }
            if (axisOrigin == null)
            {
                throw new ArgumentNullException("axisOrigin");
            }
            if (axisDirection == null)
            {
                throw new ArgumentNullException("axisDirection");
            }
            if (!profile.IsPlanar)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "profile"), "profile");
            }
            if (DSGeometryExtension.Equals(axisDirection.Length, 0.0))
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "axisDirection"), "axisDirection");
            }
            if (DSGeometryExtension.Equals(sweepAngle, 0.0))
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "sweepAngle"), "sweepAngle");
            }

            ISolidEntity entity = HostFactory.Factory.SolidByRevolve(profile.CurveEntity, axisOrigin.PointEntity, axisDirection.IVector, startAngle, sweepAngle);

            if (entity == null)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.Revolve"));
            }
            return(entity);
        }
Пример #4
0
        public static DSSurface[] SelectTrim(DSSurface[] surfaces, DSSolid trimmingSolid, bool keepInside)
        {
            string kMethodName = "DSSurface.SelectTrim";

            if (null == trimmingSolid)
            {
                throw new System.ArgumentNullException("trimmingSolid");
            }

            ISurfaceEntity[] surfacehosts = surfaces.ConvertAll(DSGeometryExtension.ToEntity <DSSurface, ISurfaceEntity>);
            if (surfacehosts == null || surfacehosts.Length == 0)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "surfaces", kMethodName), "surfaces");
            }

            ISolidEntity trimmingEntity = trimmingSolid.SolidEntity;

            DSSurface[] result = SelectTrimCore(surfacehosts, trimmingEntity, keepInside);
            if (null != result)
            {
                Hide(surfaces);
                Hide(trimmingSolid);
            }

            return(result);
        }
Пример #5
0
        protected override Geometry GetGeometryCore(out bool autodispose)
        {
            ISolidEntity entity = CellEntity.GetSolidGeometry();

            autodispose = true;
            return(Geometry.ToGeometry(entity));
        }
Пример #6
0
        // TODO: To be fixed - pratapa
        /// <summary>
        ///
        /// </summary>
        /// <param name="planes"></param>
        /// <param name="surfaces"></param>
        /// <param name="solids"></param>
        /// <param name="selectPoint"></param>
        /// <returns></returns>
        public DSSolid Trim(DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint)
        {
            IPlaneEntity[]   hostPlanes   = planes.ConvertAll(DSGeometryExtension.ToEntity <DSPlane, IPlaneEntity>);
            ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity <DSSurface, ISurfaceEntity>);
            ISolidEntity[]   hostSolids   = solids.ConvertAll(DSGeometryExtension.ToEntity <DSSolid, ISolidEntity>);
            if (selectPoint == null)
            {
                throw new System.ArgumentNullException("selectPoint");
            }
            IPointEntity hostPoint = selectPoint.PointEntity;

            if (hostPlanes == null && hostSurfaces == null && hostSolids == null)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "DSGeometry", "DSSolid.Trim"));
            }

            ISolidEntity trimSolid = SolidEntity.Trim(hostPlanes, hostSurfaces, hostSolids, hostPoint);

            if (null == trimSolid)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Trim"));
            }

            Hide(planes);
            Hide(surfaces);
            Hide(solids);
            SetVisibility(false);

            return(new DSSolid(trimSolid, true));
        }
Пример #7
0
        private static DSSolid[] SelectTrimCore(ISolidEntity[] solidhosts, ISolidEntity trimmingEntity, bool keepInside)
        {
            List <IGeometryEntity> geometries = new List <IGeometryEntity>();

            foreach (var solid in solidhosts)
            {
                IGeometryEntity[] geometryHosts;
                if (keepInside)
                {
                    geometryHosts = trimmingEntity.IntersectWith(solid);
                }
                else
                {
                    geometryHosts = solid.SubtractFrom(trimmingEntity);
                }

                if (null != geometryHosts)
                {
                    geometries.AddRange(geometryHosts);
                }
            }

            IGeometryEntity[] geoms = geometries.ToArray();
            return(geoms.ConvertAll(
                       (IGeometryEntity g) =>
            {
                ISolidEntity s = g as ISolidEntity;
                if (null == s)
                {
                    return null;
                }
                return s.ToSolid(true, null);
            }));
        }
Пример #8
0
        private static DSSurface[] SelectTrimCore(ISurfaceEntity[] surfacehosts, ISolidEntity trimmingEntity, bool keepInside)
        {
            List <IGeometryEntity> geometries = new List <IGeometryEntity>();

            foreach (var surf in surfacehosts)
            {
                if (keepInside)
                {
                    geometries.AddRange(trimmingEntity.IntersectWith(surf));
                }
                else
                {
                    IGeometryEntity[] trimmedSurfaces = surf.SubtractFrom(trimmingEntity);
                    if (trimmedSurfaces != null)
                    {
                        geometries.AddRange(trimmedSurfaces);
                    }
                }
            }

            IGeometryEntity[] geoms = geometries.ToArray();
            return(geoms.ConvertAll(
                       (IGeometryEntity g) =>
            {
                ISurfaceEntity s = g as ISurfaceEntity;
                if (null == s)
                {
                    return null;
                }
                return s.ToSurf(true, null);
            }));
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public DSSolid Regularise()
        {
            ISolidEntity host = SolidEntity.Regularise();

            if (host == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Regularise"));
            }
            return(host.ToSolid(true, this));
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bConvertAsSmooth"></param>
        /// <returns></returns>
        public DSSolid ConvertToSolid(bool bConvertAsSmooth)
        {
            ISolidEntity entity = SubDMeshEntity.ConvertToSolid(bConvertAsSmooth);

            if (null == entity)
            {
                throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSubDivisionMesh.ConvertToSolid"));
            }

            return(entity.ToSolid(true, this));
        }
Пример #11
0
        /// <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));
        }
Пример #12
0
        /// <summary>
        /// Returns a non-manifold solid by imposing the input regular solid onto
        /// the given solid
        /// </summary>
        /// <param name="otherSolid">The other solid</param>
        /// <returns>Returns a Non-manifold Solid</returns>
        public DSNonManifoldSolid Impose(DSSolid otherSolid)
        {
            if (otherSolid == null)
            {
                throw new ArgumentNullException("otherSolid");
            }

            ISolidEntity host = SolidEntity.NonRegularImpose(otherSolid.SolidEntity);

            if (host == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Impose"));
            }
            return(host.ToSolid(true, this) as DSNonManifoldSolid);
        }
Пример #13
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));
        }
Пример #14
0
        private static ISolidEntity LoftFromCrossSectionsGuidesCore(DSCurve[] crossSections, DSCurve[] guides)
        {
            //Get all closed host xsections.
            ICurveEntity[] xsections = crossSections.ConvertAll((DSCurve c) => DSGeometryExtension.GetCurveEntity(c, true));
            if (xsections == null || xsections.Length < 2)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "cross sections"), "crossSections");
            }

            ISolidEntity entity = HostFactory.Factory.SolidByLoftCrossSectionsGuides(xsections, guides.ConvertAll(DSGeometryExtension.ToEntity <DSCurve, ICurveEntity>));

            if (entity == null)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.LoftFromCrossSectionsGuides"));
            }
            return(entity);
        }
Пример #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="otherSolid"></param>
        /// <returns></returns>
        public DSSolid Intersect(DSSolid otherSolid)
        {
            if (otherSolid == null)
            {
                throw new ArgumentNullException("otherSolid");
            }

            IGeometryEntity[] solids = SolidEntity.IntersectWith(otherSolid.SolidEntity);
            if (solids == null || solids.Length == 0 || solids[0] == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Impose"));
            }

            ISolidEntity host = solids[0] as ISolidEntity;

            return(host.ToSolid(true, this));
        }
Пример #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uniformFaceThickness"></param>
        /// <returns></returns>
        public DSSolid ThinShell(double uniformFaceThickness)
        {
            if (uniformFaceThickness.EqualsTo(0.0))
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsZero, "uniformFaceThickness"), "uniformFaceThickness");
            }
            if (uniformFaceThickness < 0)
            {
                throw new ArgumentException(string.Format(Properties.Resources.LessThanZero, "uniformFaceThickness"), "uniformFaceThickness");
            }

            ISolidEntity host = SolidEntity.ThinShell(uniformFaceThickness, uniformFaceThickness);

            if (null == host)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.ThinShell"));
            }

            return(host.ToSolid(true, this));
        }
Пример #17
0
        private static ISolidEntity LoftFromCrossSectionsPathCore(Curve[] crossSections, Curve path)
        {
            //Get all closed host xsections.
            ICurveEntity[] xsections = crossSections.ConvertAll((Curve c) => GeometryExtension.GetCurveEntity(c, true));
            if (xsections == null || xsections.Length < 2)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "cross sections"), "crossSections");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            ISolidEntity entity = HostFactory.Factory.SolidByLoftCrossSectionsPath(xsections, path.CurveEntity);

            if (entity == null)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "Solid.LoftFromCrossSectionsPath"));
            }
            return(entity);
        }
Пример #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="internalFaceThickness"></param>
        /// <param name="externalFaceThickness"></param>
        /// <returns></returns>
        public DSSolid ThinShell(double internalFaceThickness, double externalFaceThickness)
        {
            if (internalFaceThickness.EqualsTo(0.0) || internalFaceThickness < 0)
            {
                return(null);
            }

            if (externalFaceThickness.EqualsTo(0.0) || externalFaceThickness < 0)
            {
                return(null);
            }

            ISolidEntity host = SolidEntity.ThinShell(internalFaceThickness, externalFaceThickness);

            if (null == host)
            {
                return(null);
            }

            return(host.ToSolid(true, this));
        }
Пример #19
0
        /// <summary>
        /// Returns a solid by doing a non-regular unite (if 'isRegular' is set
        /// to false) of one solid with an array of solids (any combination of
        /// manifold or non-manifold)
        /// </summary>
        /// <param name="otherSolids">An array of solids</param>
        /// <param name="isRegular">Switch for Regular or Non-regular Union</param>
        /// <returns>Returns a solid</returns>
        public DSSolid Union(DSSolid[] otherSolids, bool isRegular)
        {
            ISolidEntity[] othersolidhosts = otherSolids.ConvertAll(DSGeometryExtension.ToEntity <DSSolid, ISolidEntity>);
            if (null == othersolidhosts || (othersolidhosts.Length == 0))
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "otherSolids", "DSSolid.Union"), "otherSolids");
            }

            if (isRegular)
            {
                return(UnionCore(SolidEntity, othersolidhosts, true));
            }

            ISolidEntity host = SolidEntity.NonRegularUnionWithMany(othersolidhosts);

            if (host == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
            }
            return(host.ToSolid(true, this));
        }
Пример #20
0
        private static ISolidEntity SweepCore(DSCurve profile, DSCurve path)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (!profile.IsClosed)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "profile"), "profile");
            }

            ISolidEntity entity = HostFactory.Factory.SolidBySweep(profile.CurveEntity, path.CurveEntity);

            if (entity == null)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.Sweep"));
            }
            return(entity);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thisEntity"></param>
        /// <param name="othersolidhosts"></param>
        /// <param name="persist"></param>
        /// <returns></returns>
        internal static DSSolid UnionCore(ISolidEntity thisEntity, ISolidEntity[] othersolidhosts, bool persist)
        {
            ISolidEntity host = thisEntity;

            foreach (var solidhost in othersolidhosts)
            {
                if (host == solidhost)
                {
                    continue;
                }

                IGeometryEntity[] solids = host.UnionWith(solidhost);
                if (solids != null && solids.Length > 0 && solids[0] != null)
                {
                    host = solids[0] as ISolidEntity;
                }
                else
                {
                    throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
                }
            }

            return(host.ToSolid(persist, null));
        }
Пример #22
0
        private static DSSurface[] SelectTrimCore(ISurfaceEntity[] surfacehosts, ISolidEntity trimmingEntity, bool keepInside)
        {
            List<IGeometryEntity> geometries = new List<IGeometryEntity>();
            foreach (var surf in surfacehosts)
            {
                if (keepInside)
                    geometries.AddRange(trimmingEntity.IntersectWith(surf));
                else
                {
                    IGeometryEntity[] trimmedSurfaces = surf.SubtractFrom(trimmingEntity);
                    if(trimmedSurfaces!=null)
                        geometries.AddRange(trimmedSurfaces);
                }
            }

            IGeometryEntity[] geoms = geometries.ToArray();
            return geoms.ConvertAll(
                (IGeometryEntity g) =>
                {
                    ISurfaceEntity s = g as ISurfaceEntity;
                    if (null == s)
                        return null;
                    return s.ToSurf(true, null);
                });
        }
Пример #23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="thisEntity"></param>
        /// <param name="othersolidhosts"></param>
        /// <param name="persist"></param>
        /// <returns></returns>
        internal static DSSolid UnionCore(ISolidEntity thisEntity, ISolidEntity[] othersolidhosts, bool persist)
        {
            ISolidEntity host = thisEntity;
            foreach (var solidhost in othersolidhosts)
            {
                if (host == solidhost)
                    continue;

                IGeometryEntity[] solids = host.UnionWith(solidhost);
                if (solids != null && solids.Length > 0 && solids[0] != null)
                    host = solids[0] as ISolidEntity;
                else
                    throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
            }

            return host.ToSolid(persist, null);
        }
Пример #24
0
 public IGeometryEntity[] SubtractFrom(ISolidEntity trimmingEntity)
 {
     throw new NotImplementedException();
 }
Пример #25
0
 public ISolidEntity NonRegularImpose(ISolidEntity geometry)
 {
     return new SolidEntity();
 }
Пример #26
0
 public ISolidEntity CSGIntersect(ISolidEntity geometry)
 {
     throw new NotImplementedException();
 }
Пример #27
0
 public ISolidEntity Trim(IPlaneEntity[] planes, ISurfaceEntity[] surfaces, ISolidEntity[] solids, IPointEntity point)
 {
     return new SolidEntity();
 }
Пример #28
0
 public virtual IGeometryEntity[] IntersectWith(ISolidEntity solid)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
Пример #29
0
 internal DSSolid(ISolidEntity entity, bool persist = false)
     : base(entity, persist)
 {
     InitializeGuaranteedProperties();
 }
Пример #30
0
        private static DSSolid[] SelectTrimCore(ISolidEntity[] solidhosts, ISolidEntity trimmingEntity, bool keepInside)
        {
            List<IGeometryEntity> geometries = new List<IGeometryEntity>();
            foreach (var solid in solidhosts)
            {
                IGeometryEntity[] geometryHosts;
                if (keepInside)
                    geometryHosts = trimmingEntity.IntersectWith(solid);
                else
                    geometryHosts = solid.SubtractFrom(trimmingEntity);

                if (null != geometryHosts)
                    geometries.AddRange(geometryHosts);
            }

            IGeometryEntity[] geoms = geometries.ToArray();
            return geoms.ConvertAll(
                (IGeometryEntity g) =>
                {
                    ISolidEntity s = g as ISolidEntity;
                    if (null == s)
                        return null;
                    return s.ToSolid(true, null);
                });
        }
Пример #31
0
 internal DSSolid(ISolidEntity entity, bool persist = false)
     : base(entity, persist)
 {
     InitializeGuaranteedProperties();
 }
Пример #32
0
 internal static DSSolid CreateSolid(ISolidEntity host, bool persist)
 {
     return new DSSolid(host, persist);
 }
Пример #33
0
 public virtual IGeometryEntity[] IntersectWith(ISolidEntity solid)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
Пример #34
0
 internal DSNonManifoldSolid(ISolidEntity entity, bool persist = false)
     : base(entity, persist)
 {
 }
Пример #35
0
 public ISurfaceEntity Trim(ICurveEntity[] curves, IPlaneEntity[] planes, ISurfaceEntity[] surfaces, ISolidEntity[] solids, IPointEntity point, bool bAutoExtend)
 {
     return this;
 }
Пример #36
0
 public ISolidEntity NonRegularImpose(ISolidEntity geometry)
 {
     return(new SolidEntity());
 }
Пример #37
0
 internal DSNonManifoldSolid(ISolidEntity entity, bool persist = false)
     : base(entity, persist)
 {
 }
Пример #38
0
 public ISolidEntity CSGDifference(ISolidEntity geometry)
 {
     throw new NotImplementedException();
 }
 public string WriteEntity(ISolidEntity solid, string paramName)
 {
     WriteSATImport(new IGeometryEntity[] { solid }, paramName);
     return(paramName);
 }
Пример #40
0
 public IGeometryEntity[] IntersectWith(ISolidEntity geometry)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
Пример #41
0
 public IGeometryEntity[] Difference(ISolidEntity iSolidEntity)
 {
     throw new NotImplementedException();
 }
Пример #42
0
 public IGeometryEntity[] IntersectWith(ISolidEntity geometry)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
Пример #43
0
 public IGeometryEntity[] SubtractFrom(ISolidEntity trimmingEntity)
 {
     throw new NotImplementedException();
 }
Пример #44
0
 internal static DSSolid CreateSolid(ISolidEntity host, bool persist)
 {
     return(new DSSolid(host, persist));
 }
Пример #45
0
 internal static Solid ToSolid(this ISolidEntity host, bool persist, Geometry context)
 {
     return(host.ToGeometry <Solid, ISolidEntity>(persist, context));
 }