예제 #1
0
        public static Separator test()
        {
            Separator   level1       = new Separator();
            ColoredBone b            = new ColoredBone(@"P:\WORKING_OI_CODE\distv\data\model\scaAVG.iv");
            int         numPositions = 90;
            int         numVertices  = b.getNumberVertices();

            int[][] colors = DatParser.parseDistvColorFile(@"P:\WORKING_OI_CODE\distv\data\color\scacolor.dat", numPositions, numVertices);
            level1.addNode(b);
            uint a  = 1;
            int  bb = (int)a;

            b.setColorMap((int[])colors[0]);
            return(level1);
        }
예제 #2
0
        private void setupDistv(string rootPath)
        {
            _bones                   = new ColoredBone[NUM_BONES];
            _boneSeparators          = new Separator[NUM_BONES];
            _transformsSwitch        = new Switch[NUM_BONES];
            _inverseTransformsSwitch = new Switch[NUM_BONES];
            _colorData               = new int[NUM_BONES][][];

            for (int i = 0; i < NUM_BONES; i++)
            {
                string bonePath      = Path.Combine(rootPath, String.Format(BONE_FILE_PATTERN, WristFilesystem.ShortBoneNames[i]));
                string transformPath = Path.Combine(rootPath, String.Format(RT_FILE_PATTERN, WristFilesystem.ShortBoneNames[i]));
                string colorPath     = Path.Combine(rootPath, String.Format(COLOR_FILE_PATTERN, WristFilesystem.ShortBoneNames[i]));
                _boneSeparators[i] = new Separator();
                _bones[i]          = new ColoredBone(bonePath);

                _transformsSwitch[i]        = new Switch();
                _inverseTransformsSwitch[i] = new Switch();
                TransformRT[] tfrm = DatParser.parseRTFileWithHeaderToRT(transformPath);
                for (int j = 0; j < tfrm.Length; j++)
                {
                    Transform t1 = new Transform();
                    DatParser.addRTtoTransform(tfrm[j], t1);
                    _transformsSwitch[i].addChild(t1);

                    //now the inverse to allow us to fix another bone
                    Transform t2 = new Transform();
                    DatParser.addRTtoTransform(tfrm[j], t2);
                    t2.invert();
                    _inverseTransformsSwitch[i].addChild(t2);
                }
                _numPositions = tfrm.Length; //TODO: Check that all are the same...

                _colorData[i] = DatParser.parseDistvColorFile(colorPath, tfrm.Length, _bones[i].getNumberVertices());
                _bones[i].setupFullColorMap(_colorData[i]);

                //TODO: Add swich in with transforms....
                _boneSeparators[i].addNode(_transformsSwitch[i]);
                _boneSeparators[i].addNode(_bones[i]);
                _root.addChild(_boneSeparators[i]);
            }

            setAllColorMaps(0);
        }
예제 #3
0
        /// <summary>
        /// Will create a contour based on a distance field for the given reference bone.
        /// </summary>
        /// <param name="referenceBone">Bone on which to draw the contour</param>
        /// <param name="distanceMap">Pre-calculated distance map for the referenceBone. Distance for each vertex in order</param>
        /// <param name="cDistance">Contour Distance (mm)</param>
        /// <returns></returns>
        public static Contour createContourSingleBoneSinglePosition(ColoredBone referenceBone, double[] distanceMap, double cDistance)
        {
            /* Yes, its bad to repeat code, but I needed this pretty fast.
             */
            double[] dist = distanceMap;

            float[,] points = referenceBone.getVertices();
            int[,] conn     = referenceBone.getFaceSetIndices();

            Contour cont1 = new Contour(1); //only a single distance for this contour

            //cont1.Color = colors[0];

            double[] cDistances = new double[] { cDistance }; //create new array with single value, needed for helper function later

            int numTrian = conn.GetLength(0);

            for (int i = 0; i < numTrian; i++)
            {
                //check if all the points are out, if so, skip it
                if (dist[conn[i, 0]] > cDistance &&
                    dist[conn[i, 1]] > cDistance &&
                    dist[conn[i, 2]] > cDistance)
                {
                    continue;
                }

                double[]  triDist = { dist[conn[i, 0]], dist[conn[i, 1]], dist[conn[i, 2]] };
                float[][] triPts  =
                {
                    new float[] { points[conn[i, 0], 0], points[conn[i, 0], 1], points[conn[i, 0], 2] },
                    new float[] { points[conn[i, 1], 0], points[conn[i, 1], 1], points[conn[i, 1], 2] },
                    new float[] { points[conn[i, 2], 0], points[conn[i, 2], 1], points[conn[i, 2], 2] }
                };

                contourSingleTriangle(triDist, triPts, cont1, cDistances);
            }
            return(cont1);
        }
예제 #4
0
파일: Bone_1.cs 프로젝트: tsgouros/wv
        public void LoadIVFile()
        {
            if (!File.Exists(_ivFilename))
            {
                return;
            }

            Separator bone = new Separator();

            bone.makeHideable();
            try
            {
                _coloredBone = new ColoredBone(_ivFilename);
                bone.addNode(_coloredBone);
            }
            catch (System.ArgumentException)
            {
                //try and load non-standard bones here.... shit. This needs to be fixed
                //TODO: Better error handling...
                _coloredBone = null;
                bone.addFile(_ivFilename);
            }
            _bone = bone; //only save if we get this far, its possible to still be throwing an exception
        }