Пример #1
0
        private double[] GetDirection(IModelDoc2 model, object inputObj)
        {
            if (inputObj is IFace2)
            {
                ISurface surf = (inputObj as IFace2).GetSurface() as ISurface;

                if (surf.IsCylinder())
                {
                    double[] cylParams = surf.CylinderParams as double[];

                    return(new double[] { cylParams[3], cylParams[4], cylParams[5] });
                }
            }
            else if (inputObj is IFeature)
            {
                IRefPlane refPlane = (inputObj as IFeature).GetSpecificFeature2() as IRefPlane;

                if (refPlane != null)
                {
                    IMathUtility mathUtils = swApp.GetMathUtility() as IMathUtility;
                    IMathVector  vec       = mathUtils.CreateVector(new double[] { 0, 0, 1 }) as IMathVector;
                    vec = vec.MultiplyTransform(refPlane.Transform) as IMathVector;
                    return(vec.ArrayData as double[]);
                }
            }

            throw new NullReferenceException("Failed to find the direction. Please select cylindrical face or plane");
        }
Пример #2
0
        public static double[] Origin(this IRefPlane plane, IMathUtility math)
        {
            var transform   = plane.Transform;
            var originWorld = math.Point(new[] { 0.0, 0, 0 });

            return(originWorld.MultiplyTransformTs(transform).ArrayData.CastArray <double>());
        }
Пример #3
0
        public static double[] Normal(this IRefPlane plane, IMathUtility math)
        {
            var transform   = plane.Transform;
            var normalWorld = math.Vector(new[] { 0.0, 0, 1 });

            return(normalWorld.MultiplyTransformTs(transform).ArrayData.CastArray <double>());
        }
        /// <summary>
        /// 获取基准面原点
        /// </summary>
        /// <param name="plane"></param>
        /// <param name="math"></param>
        /// <returns></returns>
        public static double[] Origin(this IRefPlane plane, IMathUtility math)
        {
            var transform   = plane.Transform;
            var originWorld = math.CreatePoint(new[] { 0.0, 0, 0 }) as MathVector;

            return(((MathTransform)originWorld.MultiplyTransform(transform)).ArrayData as double[]);
        }
        /// <summary>
        /// 获取基准面的法向量
        /// </summary>
        /// <param name="plane"></param>
        /// <param name="math"></param>
        /// <returns></returns>
        public static double[] Normal(this IRefPlane plane, IMathUtility math)
        {
            var transform   = plane.Transform;
            var normalWorld = math.CreateVector(new[] { 0.0, 0, 1 }) as MathVector;

            return(((MathTransform)normalWorld.MultiplyTransform(transform)).ArrayData as double[]);
        }
Пример #6
0
 public static bool PlaneOriginAndNormalEquals(this IRefPlane p,
                                               IMathUtility math,
                                               double[] origin,
                                               double[] normal,
                                               double tol)
 {
     return(PlaneOriginEquals(p, math, origin, tol) &&
            PlaneNormalEquals(p, math, normal, tol));
 }
Пример #7
0
 public IRefPlaneObject(IRefPlane IRefPlaneinstance)
 {
     IRefPlaneInstance = IRefPlaneinstance;
 }
Пример #8
0
 public static bool PlaneNormalEquals(this IRefPlane p, IMathUtility mathUtility, double[] normal, double tol)
 {
     return(MathPointExtensions.Equals(mathUtility.Vector(p.Normal(mathUtility)), mathUtility.Vector(normal), tol));
 }
Пример #9
0
 public static bool PlaneOriginEquals(this IRefPlane p, IMathUtility mathUtility, double[] origin, double tol)
 {
     return(MathPointExtensions.Equals(mathUtility.Point(p.Origin(mathUtility)), mathUtility.Point(origin), tol));
 }
Пример #10
0
        internal SwPlane(IFeature feat, ISwDocument doc, ISwApplication app, bool created) : base(feat, doc, app, created)
        {
            m_RefPlane = feat.GetSpecificFeature2() as IRefPlane;

            m_MathUtils = OwnerApplication.Sw.IGetMathUtility();
        }
 /// <summary>
 /// 获取平面的点法式
 /// </summary>
 /// <param name="plane"></param>
 /// <param name="math"></param>
 /// <returns></returns>
 public static PointDirection3 GetPointDirection3(this IRefPlane plane, IMathUtility math)
 {
     return(new PointDirection3(new Vector3(plane.Normal(math)), new Vector3(plane.Origin(math))));
 }