Ejemplo n.º 1
0
        public double[] TransformPoint(double[] pt, IMathTransform transform)
        {
            IMathPoint point = m_MathUtils.CreatePoint(pt) as IMathPoint;

            point = point.MultiplyTransform(transform) as IMathPoint;
            return(point.ArrayData as double[]);
        }
        public Point TransformPoint(Point point, TransformationMaxtrix transform)
        {
            IMathPoint mathPt      = m_MathUtils.CreatePoint(point.ToArray()) as IMathPoint;
            var        swTransform = m_MathUtils.CreateTransFormTransformationMaxtrix(transform);

            mathPt = mathPt.MultiplyTransform(swTransform) as IMathPoint;
            return(new Point(mathPt.ArrayData as double[]));
        }
Ejemplo n.º 3
0
        private void ExportToStl(string filePath, float[] tessTriangs, float[] tessNorms, double[] transformMatrix)
        {
            IMathUtility   mathUtils = swApp.IGetMathUtility();
            IMathTransform transform = (mathUtils.CreateTransform(transformMatrix) as IMathTransform).IInverse();

            using (FileStream fileStream = File.Create(filePath))
            {
                using (BinaryWriter writer = new BinaryWriter(fileStream))
                {
                    byte[] header = new byte[80];

                    writer.Write(header);

                    uint triangsCount = (uint)tessTriangs.Length / 9;
                    writer.Write(triangsCount);

                    for (uint i = 0; i < triangsCount; i++)
                    {
                        float normalX = tessNorms[i * 9];
                        float normalY = tessNorms[i * 9 + 1];
                        float normalZ = tessNorms[i * 9 + 2];

                        IMathVector mathVec = mathUtils.CreateVector(
                            new double[] { normalX, normalY, normalZ }) as IMathVector;

                        mathVec = mathVec.MultiplyTransform(transform) as IMathVector;

                        double[] vec = mathVec.ArrayData as double[];

                        writer.Write((float)vec[0]);
                        writer.Write((float)vec[1]);
                        writer.Write((float)vec[2]);

                        for (uint j = 0; j < 3; j++)
                        {
                            float vertX = tessTriangs[i * 9 + j * 3];
                            float vertY = tessTriangs[i * 9 + j * 3 + 1];
                            float vertZ = tessTriangs[i * 9 + j * 3 + 2];

                            IMathPoint mathPt = mathUtils.CreatePoint(
                                new double[] { vertX, vertY, vertZ }) as IMathPoint;

                            mathPt = mathPt.MultiplyTransform(transform) as IMathPoint;

                            double[] pt = mathPt.ArrayData as double[];

                            writer.Write((float)pt[0]);
                            writer.Write((float)pt[1]);
                            writer.Write((float)pt[2]);
                        }

                        ushort atts = 0;
                        writer.Write(atts);
                    }
                }
            }
        }
 /// <summary>
 /// Find the vector in model space from the point to the viewers eye.
 /// </summary>
 /// <param name="modelView"></param>
 /// <param name="mathUtility"></param>
 /// <param name="p"></param>
 /// <returns></returns>
 private static MathVector ViewVector(IModelView modelView, IMathUtility mathUtility, IMathPoint p)
 {
     var world2screen = modelView.Transform;
     var pScreen = (MathPoint) p.MultiplyTransform(world2screen);
     var vv = (IMathVector) mathUtility.CreateVector(new[] {0.0, 0, 1});
     var pScreenUp = (MathPoint) pScreen.AddVector(vv);
     var pWorldDelta = (MathPoint) pScreenUp.MultiplyTransform((MathTransform) world2screen.Inverse());
     var viewVector = (MathVector) p.Subtract(pWorldDelta);
     return viewVector;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Find the vector in model space from the point to the viewers eye.
        /// </summary>
        /// <param name="modelView"></param>
        /// <param name="mathUtility"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private static MathVector ViewVector(IModelView modelView, IMathUtility mathUtility, IMathPoint p)
        {
            var world2screen = modelView.Transform;
            var pScreen      = (MathPoint)p.MultiplyTransform(world2screen);
            var vv           = (IMathVector)mathUtility.CreateVector(new[] { 0.0, 0, 1 });
            var pScreenUp    = (MathPoint)pScreen.AddVector(vv);
            var pWorldDelta  = (MathPoint)pScreenUp.MultiplyTransform((MathTransform)world2screen.Inverse());
            var viewVector   = (MathVector)p.Subtract(pWorldDelta);

            return(viewVector);
        }
Ejemplo n.º 6
0
 public static MathPoint MultiplyTransformTs(this IMathPoint v, IMathTransform t)
 {
     return((MathPoint)v.MultiplyTransform(t));
 }