private static ISurfaceEntity FromCrossSectionsGuidesCore(DSCurve[] crossSections, DSCurve[] guides)
        {
            bool isClosed = crossSections[0].IsClosed;

            //Validation
            ICurveEntity[] hostXCurves = crossSections.ConvertAll((DSCurve c) => DSGeometryExtension.GetCurveEntity(c, isClosed));
            if (hostXCurves == null || hostXCurves.Length < 2)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "cross sections"), "crossSections");
            }

            ICurveEntity[] hostGuides = guides.ConvertAll(DSGeometryExtension.ToEntity <DSCurve, ICurveEntity>);
            if (hostGuides == null || hostGuides.Length < 1)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "guides"), "guides");
            }

            ISurfaceEntity entity = HostFactory.Factory.SurfaceByLoftCrossSectionsGuides(hostXCurves, hostGuides);

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.LoftFromCrossSectionsGuides"));
            }
            return(entity);
        }
Beispiel #2
0
        protected override Geometry GetGeometryCore(out bool autodispose)
        {
            ISurfaceEntity surf = FaceEntity.GetSurfaceGeometry();

            autodispose = true;
            return(Geometry.ToGeometry(surf));
        }
        private static ISurfaceEntity ByProfileAxisOriginDirectionAngleCore(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle)
        {
            if (null == profile)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "profile"), "profile");
            }

            if (null == axisOrigin)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "axis origin"), "axisOrigin");
            }

            if (null == axisDirection)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "axis direction"), "axisDirection");
            }

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

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.Revolve"));
            }
            return(entity);
        }
Beispiel #4
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);
            }));
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="curves"></param>
        /// <param name="planes"></param>
        /// <param name="surfaces"></param>
        /// <param name="solids"></param>
        /// <param name="selectPoint"></param>
        /// <param name="autoExtend"></param>
        /// <returns></returns>
        public DSSurface Trim(DSCurve[] curves, DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint, bool autoExtend)
        {
            if (null == selectPoint)
            {
                throw new System.ArgumentNullException("selectPoint");
            }

            ICurveEntity[]   hostCurves   = curves.ConvertAll(DSGeometryExtension.ToEntity <DSCurve, ICurveEntity>);
            IPlaneEntity[]   hostPlanes   = planes.ConvertAll(DSGeometryExtension.ToEntity <DSPlane, IPlaneEntity>);
            ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity <DSSurface, ISurfaceEntity>);
            ISolidEntity[]   hostSolids   = solids.ConvertAll(DSGeometryExtension.ToEntity <DSSolid, ISolidEntity>);

            IPointEntity hostPoint = selectPoint.PointEntity;

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

            ISurfaceEntity trimSurface = SurfaceEntity.Trim(hostCurves, hostPlanes, hostSurfaces, hostSolids, hostPoint, autoExtend);

            //For trim operation, if the return value is not null, hide the original tools and surfaces.
            if (null != trimSurface)
            {
                Hide(curves);
                Hide(planes);
                Hide(surfaces);
                Hide(solids);
                SetVisibility(false);
            }

            return(trimSurface.ToSurf(true, this));
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="toolSolid"></param>
        /// <returns></returns>
        public DSSurface[] Difference(DSSolid toolSolid)
        {
            string kMethod = "DSSurface.Difference";

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

            IGeometryEntity[] geoms = SurfaceEntity.SubtractFrom(toolSolid.SolidEntity);
            if (null == geoms)
            {
                throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethod));
            }

            return(geoms.ConvertAll(
                       (IGeometryEntity g) =>
            {
                ISurfaceEntity s = g as ISurfaceEntity;
                if (null == s)
                {
                    return null;
                }
                return s.ToSurf(true, this);
            }));
        }
 internal override ISurfaceEntity GetSurfaceEntity()
 {
     if (null == mSurfaceEntity)
     {
         mSurfaceEntity = SubDMeshEntity.ConvertToSurface(true);
     }
     return(mSurfaceEntity);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DSGeometryExtension.DisposeObject(ref mVertices);
         DSGeometryExtension.DisposeObject(ref mEdges);
         mSurfaceEntity.DisposeObject(); mSurfaceEntity = null;
     }
     base.Dispose(disposing);
 }
        private static ISurfaceEntity ByProfileAxisAngleCore(DSCurve profile, DSLine axis, double startAngle, double sweepAngle)
        {
            if (null == axis)
            {
                throw new System.ArgumentNullException("axis");
            }
            ISurfaceEntity surf = ByProfileAxisOriginDirectionAngleCore(profile, axis.StartPoint, axis.Direction, startAngle, sweepAngle);

            if (null == surf)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSRevolvedSurface.ByProfileAxisAngle"));
            }
            return(surf);
        }
        private static ISurfaceEntity FromCurveCore(DSCurve profile)
        {
            if (null == profile)
            {
                throw new System.ArgumentNullException("profile");
            }
            if (!profile.IsClosed || profile.IsSelfIntersecting)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.CurveNotClosed), "profile");
            }

            ISurfaceEntity entity = HostFactory.Factory.SurfacePatchFromCurve(profile.CurveEntity);

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.CreateFromCurve"));
            }
            return(entity);
        }
Beispiel #11
0
        /// <summary>
        /// Returns a parallel Surface with specific distance from original surface.
        /// </summary>
        /// <param name="distance">Offset distance value.</param>
        /// <returns>Surface.</returns>
        public DSSurface Offset(double distance)
        {
            if (distance.EqualsTo(0.0))
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZero, "offset distance"), "distance");
            }

            ISurfaceEntity surfEntity = SurfaceEntity.Offset(distance);

            if (null == surfEntity)
            {
                throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSurface.Offset"));
            }

            DSSurface surf = surfEntity.ToSurf(true, this);

            surf.Context = this;
            return(surf);
        }
Beispiel #12
0
        private static ISurfaceEntity ByProfilePathCore(DSCurve profile, DSCurve path)
        {
            if (null == profile)
            {
                throw new System.ArgumentNullException("profile");
            }

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

            ISurfaceEntity entity = HostFactory.Factory.SurfaceBySweep(profile.CurveEntity, path.CurveEntity);

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSweptSurface.ByProfilePath"));
            }
            return(entity);
        }
Beispiel #13
0
 protected TopologyMesh(SubDivisionMesh mesh, bool persist = true)
 {
     m_meshEntity = GeometryExtension.ToEntity(mesh) as ISubDMeshEntity;
     if (null != m_meshEntity)
     {
         ISurfaceEntity surface = m_meshEntity.ConvertToSurface(false);
         if (persist)
         {
             IPersistenceManager persistence_manager = persistence_manager_property.GetValue(null, null) as IPersistenceManager;
             if (null != surface && null != persistence_manager)
             {
                 m_brep = persistence_manager.Persist(surface) as IBRepEntity;
             }
         }
         else
         if (null != surface)
         {
             m_brep = surface as IBRepEntity;
         }
     }
 }
Beispiel #14
0
        /// <summary>
        /// Internal utility method
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="distance"></param>
        /// <param name="direction"></param>
        /// <returns></returns>
        internal static IBSplineSurfaceEntity[] ExtrudeAsBSplineSurfaces(this ICurveEntity profile, double distance, Vector direction)
        {
            if (null == profile || direction.IsZeroVector())
            {
                return(null);
            }

            using (IPointEntity startPt = profile.PointAtParameter(0.5))
            {
                Vector offset = direction.Normalize().Scale(distance);
                using (IPointEntity endPt = startPt.CopyAndTranslate(offset.IVector) as IPointEntity)
                {
                    using (ILineEntity path = HostFactory.Factory.LineByStartPointEndPoint(startPt, endPt))
                    {
                        using (ISurfaceEntity surf = HostFactory.Factory.SurfaceBySweep(profile, path))
                        {
                            return(surf.ConvertToBSplineSurface());
                        }
                    }
                }
            }
        }
        /// <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);
        }
Beispiel #16
0
        private static ISurfaceEntity FromCrossSectionsPathCore(DSCurve[] crossSections, DSCurve path)
        {
            if (null == path)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "path"), "path");
            }

            bool isClosed = crossSections[0].IsClosed;

            //Validation
            ICurveEntity[] hostXCurves = crossSections.ConvertAll((DSCurve c) => DSGeometryExtension.GetCurveEntity(c, isClosed));
            if (hostXCurves == null || hostXCurves.Length < 2)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "cross sections"), "crossSections");
            }

            ISurfaceEntity entity = HostFactory.Factory.SurfaceByLoftCrossSectionsPath(hostXCurves, path.CurveEntity);

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.LoftFromCrossSectionsPath"));
            }
            return(entity);
        }
Beispiel #17
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);
                });
        }
Beispiel #18
0
 public IGeometryEntity[] IntersectWith(ISurfaceEntity geometry)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
Beispiel #19
0
 public ISurfaceEntity Trim(ICurveEntity[] curves, IPlaneEntity[] planes, ISurfaceEntity[] surfaces, ISolidEntity[] solids, IPointEntity point, bool bAutoExtend)
 {
     return this;
 }
Beispiel #20
0
 public IGeometryEntity[] SliceWithSurface(ISurfaceEntity surface)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
 public string WriteEntity(ISurfaceEntity surface, string paramName)
 {
     WriteSATImport(new IGeometryEntity[] { surface }, paramName);
     return(paramName);
 }
Beispiel #22
0
 internal RevolvedSurface(ISurfaceEntity host, bool persist = false)
     : base(host, persist)
 {
     InitializeGuaranteedProperties();
 }
Beispiel #23
0
 public virtual IGeometryEntity[] IntersectWith(ISurfaceEntity surface)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
Beispiel #24
0
 public IGeometryEntity[] SliceWithSurfaces(ISurfaceEntity[] surfaces)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
Beispiel #25
0
 public void Remove(ISurfaceEntity entity)
 {
     tuioTransmitter.Remove(entity.tuioEntity);
 }
Beispiel #26
0
 public void Add(ISurfaceEntity entity)
 {
     tuioTransmitter.Add(entity.tuioEntity);
 }
Beispiel #27
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DSGeometryExtension.DisposeObject(ref mVertices);
         DSGeometryExtension.DisposeObject(ref mEdges);
         mSurfaceEntity.DisposeObject(); mSurfaceEntity = null;
     }
     base.Dispose(disposing);
 }
Beispiel #28
0
 internal override ISurfaceEntity GetSurfaceEntity()
 {
     if (null == mSurfaceEntity)
     {
         mSurfaceEntity = SubDMeshEntity.ConvertToSurface(true);
     }
     return mSurfaceEntity;
 }
Beispiel #29
0
 protected GenericSurface(ISurfaceEntity host, bool persist = false)
     : base(host, persist)
 {
 }
Beispiel #30
0
 public IGeometryEntity[] IntersectWith(ISurfaceEntity geometry)
 {
     return new IGeometryEntity[2]{new GeometryEntity(),new GeometryEntity()};
 }
Beispiel #31
0
 public ISolidEntity NonRegularSliceWithSurface(ISurfaceEntity surface)
 {
     return(new SolidEntity());
 }
Beispiel #32
0
 public virtual IGeometryEntity[] ProjectOn(ISurfaceEntity surface, IVector direction)
 {
     return new IGeometryEntity[2] { new GeometryEntity(), new GeometryEntity() };
 }
Beispiel #33
0
 public ISolidEntity Trim(IPlaneEntity[] planes, ISurfaceEntity[] surfaces, ISolidEntity[] solids, IPointEntity point)
 {
     return new SolidEntity();
 }
Beispiel #34
0
 public ISurfaceEntity[] Split(ISurfaceEntity surface)
 {
     return(new ISurfaceEntity[4] {
         new SurfaceEntity(), new SurfaceEntity(), new SurfaceEntity(), new SurfaceEntity()
     });
 }
Beispiel #35
0
 public ISolidEntity NonRegularSliceWithSurfaces(ISurfaceEntity[] surfaces)
 {
     return new SolidEntity();
 }
Beispiel #36
0
 public virtual IGeometryEntity[] IntersectWith(ISurfaceEntity surface)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
Beispiel #37
0
 internal DSSweptSurface(ISurfaceEntity host, bool persist = false)
     : base(host, persist)
 {
     InitializeGuaranteedProperties();
 }
Beispiel #38
0
 internal static Surface ToSurf(this ISurfaceEntity host, bool persist, Geometry context)
 {
     return(host.ToGeometry <Surface, ISurfaceEntity>(persist, context));
 }
Beispiel #39
0
 public ICurveEntity CurveByParameterLineOnSurface(ISurfaceEntity baseSurface, IUVEntity startParams, IUVEntity endParams)
 {
     throw new NotImplementedException();
 }
Beispiel #40
0
 public ISurfaceEntity[] Split(ISurfaceEntity surface)
 {
     return new ISurfaceEntity[4] { new SurfaceEntity(), new SurfaceEntity(), new SurfaceEntity(), new SurfaceEntity() };
 }
Beispiel #41
0
 public virtual IGeometryEntity[] ProjectOn(ISurfaceEntity surface, IVector direction)
 {
     return(new IGeometryEntity[2] {
         new GeometryEntity(), new GeometryEntity()
     });
 }
Beispiel #42
0
 public void Split(IPlaneEntity plane, ref ISurfaceEntity[] negativeHalf, ref ISurfaceEntity[] positiveHalf)
 {
     //split complete
 }
Beispiel #43
0
 protected GenericSurface(ISurfaceEntity host, bool persist = false)
     : base(host, persist)
 {
 }
Beispiel #44
0
 public ICurveEntity CurveByParameterLineOnSurface(ISurfaceEntity baseSurface, IUVEntity startParams, IUVEntity endParams) { throw new NotImplementedException(); }