Example #1
0
        private void SplitBegin(int x, int y)
        {
            SplitData data = this.CalcSplitBounds();

            if ((data.target != null) && (this.minSize < this.maxSize))
            {
                this.anchor      = new Point(x, y);
                this.splitTarget = data.target;
                this.splitSize   = this.GetSplitSize(x, y);
                try
                {
                    if (this.splitterMessageFilter != null)
                    {
                        this.splitterMessageFilter = new SplitterMessageFilter(this);
                    }
                    Application.AddMessageFilter(this.splitterMessageFilter);
                }
                finally
                {
                    CodeAccessPermission.RevertAssert();
                }

                base.Capture = true; //Internal
                this.DrawSplitBar(1);
            }
        }
Example #2
0
        /// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.SplitBegin"]/*' />
        /// <devdoc>
        ///     Begins the splitter moving.
        /// </devdoc>
        /// <internalonly/>
        private void SplitBegin(int x, int y)
        {
            SplitData spd = CalcSplitBounds();

            if (spd.target != null && (minSize < maxSize))
            {
                anchor      = new Point(x, y);
                splitTarget = spd.target;
                splitSize   = GetSplitSize(x, y);

                //



                IntSecurity.UnmanagedCode.Assert();
                try {
                    if (splitterMessageFilter != null)
                    {
                        splitterMessageFilter = new SplitterMessageFilter(this);
                    }
                    Application.AddMessageFilter(splitterMessageFilter);
                }
                finally {
                    CodeAccessPermission.RevertAssert();
                }
                CaptureInternal = true;
                DrawSplitBar(DRAW_START);
            }
        }
Example #3
0
        /// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.SplitBegin"]/*' />
        /// <devdoc>
        ///     Begins the splitter moving.
        /// </devdoc>
        /// <internalonly/>
        private void SplitBegin(int x, int y)
        {
            SplitData spd = CalcSplitBounds();

            if (spd.target != null && (minSize < maxSize))
            {
                anchor      = new Point(x, y);
                splitTarget = spd.target;
                splitSize   = GetSplitSize(x, y);

                // SECREVIEW : We need a message filter to capture the ESC key
                //           : to cancel the split action.
                //           : The method PreFilterMessage is adorned with a LinkDemand.
                //
                IntSecurity.UnmanagedCode.Assert();
                try {
                    if (splitterMessageFilter != null)
                    {
                        splitterMessageFilter = new SplitterMessageFilter(this);
                    }
                    Application.AddMessageFilter(splitterMessageFilter);
                }
                finally {
                    CodeAccessPermission.RevertAssert();
                }
                CaptureInternal = true;
                DrawSplitBar(DRAW_START);
            }
        }
Example #4
0
        protected override CommandResult ExecuteCore(CancellationToken cancellationToken = default)
        {
            SplitData splitData = SplitData.Create(
                Options.Filter.Regex,
                Options.Input,
                Options.MaxCount,
                omitGroups: Options.OmitGroups,
                cancellationToken);

            var outputWriter = new OutputWriter(Options.HighlightOptions);

            int count = outputWriter.WriteSplits(splitData, Options, cancellationToken);

            WriteLine();

            if (ShouldLog(Verbosity.Detailed) ||
                Options.IncludeSummary)
            {
                Verbosity verbosity = (Options.IncludeSummary) ? Verbosity.Minimal : Verbosity.Detailed;

                WriteGroups(splitData.GroupDefinitions, verbosity: verbosity);
                WriteLine(verbosity);

                WriteCount(
                    (Options.ContentDisplayStyle == ContentDisplayStyle.Value && Options.ModifyOptions.HasAnyFunction) ? "Values" : "Splits",
                    count,
                    Colors.Message_OK,
                    verbosity);

                WriteLine(verbosity);
            }

            return((count > 0) ? CommandResult.Success : CommandResult.NoMatch);
        }
Example #5
0
        private SplitData CalcSplitBounds()
        {
            SplitData data    = new SplitData();
            Control   control = this.FindTarget();

            data.target = control;
            if (control != null)
            {
                switch (control.Dock)
                {
                case DockStyle.Top:
                case DockStyle.Bottom:
                    this.initTargetSize = control.Bounds.Height;
                    break;

                case DockStyle.Left:
                case DockStyle.Right:
                    this.initTargetSize = control.Bounds.Width;
                    break;
                }

                Control parentInternal             = this.ParentInternal;
                Control.ControlCollection controls = parentInternal.Controls;
                int count = controls.Count;
                int num2  = 0;
                int num3  = 0;
                for (int i = 0; i < count; i++)
                {
                    Control control3 = controls[i];
                    if (control3 != control)
                    {
                        switch (control3.Dock)
                        {
                        case DockStyle.Top:
                        case DockStyle.Bottom:
                            num3 += control3.Height;
                            break;

                        case DockStyle.Left:
                        case DockStyle.Right:
                            num2 += control3.Width;
                            break;
                        }
                    }
                }

                Size clientSize = parentInternal.ClientSize;
                if (this.Horizontal)
                {
                    this.maxSize = (clientSize.Width - num2) - this.minExtra;
                }
                else
                {
                    this.maxSize = (clientSize.Height - num3) - this.minExtra;
                }
                data.dockWidth  = num2;
                data.dockHeight = num3;
            }
            return(data);
        }
Example #6
0
        //提交方案:
        private string submitDesign(string unit, string UserCode, string password, SplitData sdata)
        {
            object cookieLogin = null;
            //LoginResult loginResult = login3DWeb("meiwu"/*单位名称*/, "15915831930"/*手机号*/, "pwd123456"/*密码*/);
            LoginResult loginResult = login3DWeb(unit /*单位名称*/, UserCode /*手机号*/, password /*密码*/);

            if (loginResult.success)
            {
                cookieLogin = loginResult.msg as CookieContainer;
            }
            else
            {
                return(loginResult.msg.ToString());
            }

            //SplitData sdata = new SplitData();
            //填充sdata信息
            //...

            string      result      = split3DWeb(cookieLogin as CookieContainer, JSONHelper.SerializeObject(sdata));
            LoginResult splitResult = JSONHelper.DeserializeJsonToObject <LoginResult>(result);

            // MessageBox.Show(splitResult.msg);
            return(splitResult.msg.ToString());
        }
Example #7
0
        Mesh CreateEditedMesh(MeshData data, SplitData split, bool noTopologyUpdate = false, Mesh prev = null)
        {
            if (noTopologyUpdate)
            {
                if (data.numPoints != prev.vertexCount)
                {
                    return(null);
                }
            }

            var mesh  = noTopologyUpdate ? Instantiate <Mesh>(prev) : new Mesh();
            var flags = data.flags;

            if (flags.hasPoints)
            {
                mesh.vertices = split.points;
            }
            if (flags.hasNormals)
            {
                mesh.normals = split.normals;
            }
            if (flags.hasTangents)
            {
                mesh.tangents = split.tangents;
            }
            if (flags.hasUV)
            {
                mesh.uv = split.uv;
            }
            if (flags.hasColors)
            {
                mesh.colors = split.colors;
            }
            if (flags.hasBones)
            {
                mesh.boneWeights = split.boneWeights;
                mesh.bindposes   = data.bindposes;
            }

            if (!noTopologyUpdate && flags.hasIndices)
            {
                if (split.numSubmeshes == 0)
                {
                    mesh.SetIndices(split.indices, MeshTopology.Triangles, 0);
                }
                else
                {
                    mesh.subMeshCount = split.numSubmeshes;
                    for (int smi = 0; smi < split.numSubmeshes; ++smi)
                    {
                        var submesh = split.GetSubmesh(smi);
                        mesh.SetIndices(submesh.indices, MeshTopology.Triangles, smi);
                    }
                }
            }
            mesh.RecalculateBounds();
            mesh.UploadMeshData(false);
            return(mesh);
        }
Example #8
0
        /// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.CalcSplitBounds"]/*' />
        /// <devdoc>
        ///     Calculates the bounding criteria for the splitter.
        /// </devdoc>
        /// <internalonly/>
        private SplitData CalcSplitBounds()
        {
            SplitData spd    = new SplitData();
            Control   target = FindTarget();

            spd.target = target;
            if (target != null)
            {
                switch (target.Dock)
                {
                case DockStyle.Left:
                case DockStyle.Right:
                    initTargetSize = target.Bounds.Width;
                    break;

                case DockStyle.Top:
                case DockStyle.Bottom:
                    initTargetSize = target.Bounds.Height;
                    break;
                }
                Control parent = ParentInternal;
                Control.ControlCollection children = parent.Controls;
                int count = children.Count;
                int dockWidth = 0, dockHeight = 0;
                for (int i = 0; i < count; i++)
                {
                    Control ctl = children[i];
                    if (ctl != target)
                    {
                        switch (((Control)ctl).Dock)
                        {
                        case DockStyle.Left:
                        case DockStyle.Right:
                            dockWidth += ctl.Width;
                            break;

                        case DockStyle.Top:
                        case DockStyle.Bottom:
                            dockHeight += ctl.Height;
                            break;
                        }
                    }
                }
                Size clientSize = parent.ClientSize;
                if (Horizontal)
                {
                    maxSize = clientSize.Width - dockWidth - minExtra;
                }
                else
                {
                    maxSize = clientSize.Height - dockHeight - minExtra;
                }
                spd.dockWidth  = dockWidth;
                spd.dockHeight = dockHeight;
            }
            return(spd);
        }
Example #9
0
 public void SendAcknowledgeMentToDevice(TcpSession tcpSession, string msg)
 {
     try
     {
         Console.WriteLine("Acknowledgement message  : " + msg);
         if (tcpSession != null)
         {
             tcpSession.Send(SplitData.StringToByteArray(msg.Trim()));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine($"public void SendAcknowledgeMent(Socket _socket) {ex}");
     }
 }
Example #10
0
    public Task <SplitData> SplitAsync()
    {
        return(Task <SplitData> .Factory.StartNew(() => {
            SplitData data = new SplitData(this);
            children = new Octree[8];
            for (int i = 0; i < 8; i++)
            {
                Vector3 coff = childOffsets[i];
                Octree child = new Octree(body, this, localArea.center + coff *SIZE *voxelSize * .25f, depth + 1, i);

                data.Add(child.GenerateMesh(true));
                children[i] = child;
            }

            return data;
        }, TaskCreationOptions.None));
    }
Example #11
0
        public static string BuildAcknowledgeMessage(string receiveMessage)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                sb.Append("4d43475004");
                //sb.Append(ReceiveMessage.Substring(8, 2));
                sb.Append(receiveMessage.Substring(10, 8));


                for (int k = 11; k <= 15; k++)
                {
                    sb.Append("00");
                }
                sb.Append(receiveMessage.Substring(22, 2));
                for (int k = 17; k <= 27; k++)
                {
                    sb.Append("00");
                }

                int res = 0;
                for (int y = 8; y < sb.ToString().Length; y++)
                {
                    res += Convert.ToInt32(SplitData.ReadData(sb.ToString(), y, 2, 1));
                    y++;
                }

                string Errorchecksumack = res.ToString("x");
                if (Errorchecksumack.Length == 1)
                {
                    Errorchecksumack = "0" + Errorchecksumack;
                }
                int o = Errorchecksumack.Length;

                string cs = Errorchecksumack.Substring(o - 2, 2);
                sb.Append(cs);
            }
            catch (Exception)
            {
                throw;
            }

            return(sb.ToString());
        }
Example #12
0
        public List <SplitData> SplitList()
        {
            List <SplitData> splitList = new List <SplitData>();

            this.Open();

            int recordCount = this.RetrieveRecords();

            this.MoveFirst();

            for (int x = 1; x <= recordCount; x++)
            {
                SplitData splitData = new SplitData(this, x);
                splitList.Add(splitData);
            }

            return(splitList);
        }
Example #13
0
        private List <SplitData> GenerateSampleData()
        {
            List <SplitData>   data = new List <SplitData>();
            List <Participant> part = new List <Participant>();

            part.Add(new Participant("Derrick Rose", true, true));
            part.Add(new Participant("James Harden", true, false));
            part.Add(new Participant("Chris Paul", true, false));

            SplitData sample = new SplitData(DateTime.Now, part, 100, "Derrick Rose");

            data.Add(sample);

            SplitData sample2 = new SplitData(DateTime.Now, part, 100, "Derrick Rose2");

            data.Add(sample2);

            return(data);
        }
Example #14
0
        /// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.SplitBegin"]/*' />
        /// <devdoc>
        ///     Begins the splitter moving.
        /// </devdoc>
        /// <internalonly/>
        private void SplitBegin(int x, int y)
        {
            SplitData spd = CalcSplitBounds();

            if (spd.target != null && (minSize < maxSize))
            {
                anchor      = new Point(x, y);
                splitTarget = spd.target;
                splitSize   = GetSplitSize(x, y);

                if (splitterMessageFilter != null)
                {
                    splitterMessageFilter = new SplitterMessageFilter(this);
                }
                Application.AddMessageFilter(splitterMessageFilter);

                CaptureInternal = true;
                DrawSplitBar(DRAW_START);
            }
        }
Example #15
0
        public override void OnReceived(TcpSession tcpSession, byte[] buffer, long offset, long size)
        {
            var receivedDataByteArray = new byte[size];

            Array.Copy(buffer, receivedDataByteArray, size);
            var receivedData = ParserInfo.ParserDataType == ParserDataType.Hex
                ? SplitData.GetHexValueFromByteArray(receivedDataByteArray)
                : Encoding.UTF8.GetString(receivedDataByteArray);

            Console.WriteLine($"{receivedData}");
            if (ParserInfo.IsAknowledge)
            {
                SendAcknowledgeMent(tcpSession, receivedData);
            }
            RavenDB.RavenDbConnector.Add(new RavenDB.GpsData {
                Data = receivedData
            });
            Rabbitmq.RabbitBusProvider.AddToQueue(new Rabbitmq.GpsData {
                DeviceName = ParserInfo.ParserName, CreatedDateTime = DateTime.Now, Message = receivedData
            }, ParserInfo.ParserName);
            //Rabbitmq.QueueHandler.AddToSubscriber(ParserInfo.ParserName, ReceivedData);
            if (ParserInfo.IsForwardData)
            {
                if (!string.IsNullOrEmpty(ParserInfo.RedirectIp) && ParserInfo.RedirectPort > 0)
                {
                    if (TcpForwarder == null)
                    {
                        Console.WriteLine($"Forwarding data:{receivedData}");

                        TcpForwarder = new TcpForwarder(IPAddress.Parse(ParserInfo.RedirectIp), ParserInfo.RedirectPort);
                        TcpForwarder.ForwardData(receivedDataByteArray);
                    }
                    else
                    {
                        Console.WriteLine($"Forwarding data:{receivedData}");
                        TcpForwarder.ForwardData(receivedDataByteArray);
                    }
                }
            }
        }
Example #16
0
 public static bool GetSplitData(ExportShopDoc.ExportShopDocDlg.OperData input, out SplitData sSplitData)
 {
     sSplitData = new SplitData();
     try
     {
         sSplitData.OperName           = input.OperName.Split(',');
         sSplitData.OperToolID         = input.ToolName.Split(',');
         sSplitData.OperHolderID       = input.HolderDescription.Split(',');
         sSplitData.OperToolFeed       = input.ToolFeed.Split(',');
         sSplitData.OperCuttingTime    = input.CuttingTime.Split(',');
         sSplitData.OperToolNo         = input.ToolNumber.Split(',');
         sSplitData.OperToolSpeed      = input.ToolSpeed.Split(',');
         sSplitData.OperPartStock      = input.PartStock.Split(',');
         sSplitData.OperPartFloorStock = input.PartFloorStock.Split(',');
         sSplitData.OperCuttingLength  = input.CuttingLength.Split(',');
         sSplitData.OperCutterLife     = input.CutterLife.Split(',');
         sSplitData.OperExtension      = input.Extension.Split(',');
     }
     catch (System.Exception ex)
     {
         return(false);
     }
     return(true);
 }
Example #17
0
        private void recursiveBSP_WaveletsByConsts(List <GeoWave> GeoWaveArr, int GeoWaveID, int seed = 0)
        {
            //CALC APPROX_SOLUTION FOR GEO WAVE
            double Error = GeoWaveArr[GeoWaveID].calc_MeanValueReturnError(training_label, GeoWaveArr[GeoWaveID].pointsIdArray);

            if (Error < userConfig.approxThresh || GeoWaveArr[GeoWaveID].pointsIdArray.Count() <= userConfig.minNodeSize || userConfig.boundLevelDepth <= GeoWaveArr[GeoWaveID].level)
            {
                return;
            }

            var ran1 = new Random(seed);
            var ran2 = new Random(GeoWaveID);
            int one  = ran1.Next(0, int.MaxValue / 10);
            int two  = ran2.Next(0, int.MaxValue / 10);

            bool[] Dim2TakeNode = getDim2Take(one + two);

            Dictionary <SplitType, SplitData> splitsData = new Dictionary <SplitType, SplitData>();

            GeoWave currentWave = GeoWaveArr[GeoWaveID];

            if (userConfig.useSVMRegression)
            {
                doSVMRegressopSplit(currentWave, splitsData, Error, Dim2TakeNode);
            }
            if (userConfig.useLinearRegression)
            {
                doLinearRegressionSplit(currentWave, splitsData, Error, Dim2TakeNode);
            }
            if (userConfig.useIsotropicSplits)
            {
                doIsotropicSplit(currentWave, splitsData, Error, Dim2TakeNode);
            }
            if (userConfig.useSVMClassification)
            {
                doSvmClassificationSplit(currentWave, splitsData, Error, Dim2TakeNode);
            }
            if (true)
            {
                doGiniIndexIsotropicSplit(currentWave, splitsData, Error, Dim2TakeNode);
            }

            SplitType bestSplitType = SplitType.NO_SPLIT;
            double    lowestError   = Error;

            foreach (SplitType splitType in splitsData.Keys)
            {
                SplitData splitData = splitsData[splitType];
                if (splitData.error < lowestError)
                {
                    lowestError   = splitData.error;
                    bestSplitType = splitType;
                }
            }

            if (SplitType.NO_SPLIT == bestSplitType)
            {
                return;
            }
            currentWave.splitType = bestSplitType;
            if (SplitType.REGULAR_ISOTROPIC_SPLITS == currentWave.splitType || SplitType.GINI_INDEX_ISOTROPIC_CLASSIFICATION_SPLITS == currentWave.splitType)
            {
                IsotropicSplitData splitData = (IsotropicSplitData)splitsData[currentWave.splitType];
                currentWave.isotropicSplitsParameters.dimIndexSplitter = splitData.dimIndex;
                currentWave.isotropicSplitsParameters.splitValue       = splitData.splitValue;
            }

            GeoWave child0 = splitsData[bestSplitType].child0;
            GeoWave child1 = splitsData[bestSplitType].child1;


            //SET TWO CHILDS
            child0.parentID = child1.parentID = GeoWaveID;
            child0.child0   = child1.child0 = -1;
            child0.child1   = child1.child1 = -1;
            child0.level    = child1.level = currentWave.level + 1;

            child0.computeNormOfConsts(currentWave, Convert.ToDouble(userConfig.partitionType));
            child1.computeNormOfConsts(currentWave, Convert.ToDouble(userConfig.partitionType));
            GeoWaveArr.Add(child0);
            GeoWaveArr.Add(child1);
            currentWave.child0 = GeoWaveArr.Count - 2;
            currentWave.child1 = GeoWaveArr.Count - 1;

            //RECURSION STEP !!!
            recursiveBSP_WaveletsByConsts(GeoWaveArr, currentWave.child0, seed);
            recursiveBSP_WaveletsByConsts(GeoWaveArr, currentWave.child1, seed);
        }
Example #18
0
        public static string BuildAcknowledgeMessage(string message, out string IMEI)
        {
            IMEI = string.Empty;
            string acknowledge = string.Empty;

            try
            {
                string packetType = message.Substring(6, 2);

                byte[] receivedMessageArray = SplitData.StringToByteArray(message);

                int messageLength = receivedMessageArray[2];
                var serialNumber  = receivedMessageArray.Skip(2 + 1 + messageLength - 4).Take(2).ToArray();

                switch (packetType)
                {
                case "01":
                    serialNumber.CopyTo(loginResponse, 4);

                    var sendCRC = CrcGenerator.crc_bytes(loginResponse.Skip(2).Take(loginResponse.Length - 6).ToArray());

                    loginResponse[loginResponse.Length - 4] = (byte)((sendCRC >> 8) & 0xFF);
                    loginResponse[loginResponse.Length - 3] = (byte)((sendCRC) & 0xFF);

                    IMEI = Encoding.ASCII.GetString(receivedMessageArray.Skip(4).Take(messageLength - 5).ToArray());

                    acknowledge = SplitData.GetHexValueFromByteArray(loginResponse);

                    Console.WriteLine("Imei : '{0}'", IMEI);

                    Console.WriteLine("Acknowledge Location Data : '{0}'", acknowledge);

                    break;

                case "13":
                    serialNumber.CopyTo(heartbeatResponse, 4);
                    sendCRC = CrcGenerator.crc_bytes(heartbeatResponse.Skip(2).Take(heartbeatResponse.Length - 6).ToArray());


                    heartbeatResponse[heartbeatResponse.Length - 4] = (byte)((sendCRC >> 8) & 0xFF);
                    heartbeatResponse[heartbeatResponse.Length - 3] = (byte)((sendCRC) & 0xFF);



                    acknowledge = SplitData.GetHexValueFromByteArray(heartbeatResponse);

                    Console.WriteLine("Send Message : '{0}'", acknowledge);

                    break;

                case "16":
                case "26":
                    int alarmPacketLen = alarmResponse.Length - 5;
                    alarmResponse[2] = (byte)(alarmPacketLen & 0xFF);

                    serialNumber.CopyTo(alarmResponse, alarmPacketLen - 1);

                    sendCRC = CrcGenerator.crc_bytes(alarmResponse.Skip(2).Take(alarmPacketLen - 1).ToArray());

                    alarmResponse[alarmPacketLen + 1] = (byte)((sendCRC >> 8) & 0xFF);
                    alarmResponse[alarmPacketLen + 2] = (byte)((sendCRC) & 0xFF);

                    acknowledge = SplitData.GetHexValueFromByteArray(alarmResponse);

                    Console.WriteLine("Acknowledge Location Data : '{0}'", acknowledge);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(acknowledge);
        }
Example #19
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string datafilename;
            string inifilename;
            string projectFolderName;

            if (splitMDL == 0)
            {
                Console.WriteLine("Starting batch split for " + files.Count.ToString() + " file(s)" + System.Environment.NewLine);
                foreach (string file in files)
                {
                    SplitData splitdata = new SplitData();
                    splitdata.dataFile = file;
                    string folder_parent = Directory.GetParent(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)).ToString();
                    templateFolder = Path.Combine(folder_parent, "GameConfig");
                    if (!Directory.Exists(templateFolder))
                    {
                        templateFolder = Path.Combine(Directory.GetParent(folder_parent).ToString(), "GameConfig");
                    }
                    List <string> inilist = FindRelevantINIFiles(file, splitTemplate);
                    foreach (string iniitem in inilist)
                    {
                        splitdata.iniFile = iniitem;
                        splitDataList.Add(splitdata);
                    }
                }

                foreach (SplitData CurrentSplitData in splitDataList)
                {
                    datafilename = CurrentSplitData.dataFile;
                    inifilename  = CurrentSplitData.iniFile;

                    Console.WriteLine("Splitting file: " + datafilename);
                    if (out_path == "")
                    {
                        projectFolderName = Path.GetDirectoryName(datafilename);
                    }
                    else
                    {
                        projectFolderName = out_path;
                    }

                    if (projectFolderName[projectFolderName.Length - 1] != '/')
                    {
                        projectFolderName = string.Concat(projectFolderName, '/');
                    }
                    Console.WriteLine("Output folder: " + projectFolderName);

                    if (!File.Exists(datafilename))
                    {
                        Console.WriteLine(datafilename + " not found. Aborting.");
                        continue;
                    }

                    if (!Directory.Exists(projectFolderName))
                    {
                        // try creating the directory
                        bool created = true;

                        try
                        {
                            // check to see if trailing charcter closes
                            Directory.CreateDirectory(projectFolderName);
                        }
                        catch
                        {
                            created = false;
                        }

                        if (!created)
                        {
                            // couldn't create directory.
                            Console.WriteLine("Output folder did not exist and couldn't be created.");
                            continue;
                        }
                    }

                    if (!File.Exists(inifilename))
                    {
                        if (inifilename.Length > 9 && File.Exists(inifilename.Substring(0, inifilename.Length - 9) + ".ini"))
                        {
                            inifilename = inifilename.Substring(0, inifilename.Length - 9) + ".ini";
                        }
                        else if (Path.GetExtension(datafilename).ToLowerInvariant() == ".nb")
                        {
                            Console.WriteLine("Splitting NB file without INI data");
                            inifilename = null;
                        }
                        else
                        {
                            Console.WriteLine(inifilename + " not found. Aborting.");
                            continue;
                        }
                    }
                    if (inifilename != null)
                    {
                        Console.WriteLine("Using split data: " + inifilename);
                    }
                    bool nmeta   = labelMode == 2; // If labels are stripped, run split with the nometa parameter
                    bool nlabels = labelMode != 1; // If labels are address-based or stripped, prevent split from loading the labels file if it exists
                    Console.WriteLine("Skip full labels: " + nlabels.ToString());
                    Console.WriteLine("Strip labels: " + nmeta.ToString());
                    switch (Path.GetExtension(datafilename).ToLowerInvariant())
                    {
                    case ".dll":
                        SplitTools.SplitDLL.SplitDLL.SplitDLLFile(datafilename, inifilename, projectFolderName, nmeta, nlabels);
                        break;

                    case ".nb":
                        SplitTools.Split.SplitNB.SplitNBFile(datafilename, false, projectFolderName, 0, inifilename);
                        break;

                    default:
                        SplitTools.Split.SplitBinary.SplitFile(datafilename, inifilename, projectFolderName, nmeta, nlabels);
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("Starting split for " + files[0] + System.Environment.NewLine);
                Console.WriteLine("Output folder: " + out_path + System.Environment.NewLine);
                SplitTools.SAArc.sa2MDL.Split(splitMDL > 1, files[0], out_path, files.Skip(1).ToArray());
            }
            Console.WriteLine("Split job finished.");
        }
Example #20
0
        Mesh CreateEditedMesh(MeshData data, SplitData split)
        {
            var mesh = new Mesh();

#if UNITY_2017_3_OR_NEWER
            mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
#endif

            var flags = data.flags;
            if (flags.hasPoints)
            {
                tmpV3.Resize(split.numPoints);
                data.ReadPoints(tmpV3, split);
                mesh.SetVertices(tmpV3);
            }
            if (flags.hasNormals)
            {
                tmpV3.Resize(split.numPoints);
                data.ReadNormals(tmpV3, split);
                mesh.SetNormals(tmpV3);
            }
            if (flags.hasTangents)
            {
                tmpV4.Resize(split.numPoints);
                data.ReadTangents(tmpV4, split);
                mesh.SetTangents(tmpV4);
            }
            if (flags.hasUV0)
            {
                tmpV2.Resize(split.numPoints);
                data.ReadUV0(tmpV2, split);
                mesh.SetUVs(0, tmpV2);
            }
            if (flags.hasUV1)
            {
                tmpV2.Resize(split.numPoints);
                data.ReadUV1(tmpV2, split);
                mesh.SetUVs(1, tmpV2);
            }
            if (flags.hasColors)
            {
                tmpC.Resize(split.numPoints);
                data.ReadColors(tmpC, split);
                mesh.SetColors(tmpC);
            }
            if (flags.hasBones)
            {
                var tmpW = new PinnedList <BoneWeight>();
                tmpW.Resize(split.numPoints);
                data.ReadBoneWeights(tmpW, split);
                mesh.bindposes   = data.bindposes;
                mesh.boneWeights = tmpW;
            }
            if (flags.hasIndices)
            {
                if (split.numSubmeshes == 0)
                {
                    tmpI.Resize(split.numIndices);
                    data.ReadIndices(tmpI, split);
                    mesh.SetIndices(tmpI, MeshTopology.Triangles, 0);
                }
                else
                {
                    mesh.subMeshCount = split.numSubmeshes;
                    for (int smi = 0; smi < split.numSubmeshes; ++smi)
                    {
                        var submesh = split.GetSubmesh(smi);
                        mesh.SetIndices(submesh.indices, MeshTopology.Triangles, smi);
                    }
                }
            }
            if (flags.hasBlendshapes)
            {
                tmpV3.Resize(split.numPoints);
                tmpV3a.Resize(split.numPoints);
                tmpV3b.Resize(split.numPoints);

                int numBlendShapes = data.numBlendShapes;
                for (int bi = 0; bi < numBlendShapes; ++bi)
                {
                    var bsd       = data.GetBlendShapeData(bi);
                    var name      = bsd.name;
                    var numFrames = bsd.numFrames;
                    for (int fi = 0; fi < numFrames; ++fi)
                    {
                        bsd.ReadPoints(fi, tmpV3, split);
                        bsd.ReadNormals(fi, tmpV3a, split);
                        bsd.ReadTangents(fi, tmpV3b, split);
                        mesh.AddBlendShapeFrame(name, bsd.GetWeight(fi), tmpV3, tmpV3a, tmpV3b);
                    }
                }
            }

            mesh.RecalculateBounds();
            mesh.UploadMeshData(false);
            return(mesh);
        }
Example #21
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string datafilename;
            string inifilename;
            string projectFolderName;

            if (splitMDL == 0)
            {
                Console.WriteLine("Starting batch split for " + files.Count.ToString() + " file(s)" + System.Environment.NewLine);
                foreach (string file in files)
                {
                    SplitData splitdata = new SplitData();
                    splitdata.dataFile = file;
                    string folder_parent = Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)).ToString();
#if DEBUG
                    folder_parent = Path.Combine(folder_parent, "Configuration");
                    if (!Directory.Exists(Path.Combine(folder_parent, game_path)))
                    {
                        folder_parent = Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)).ToString();
                    }
#endif
                    List <string> inilist = FindRelevantINIFiles(file, Path.Combine(folder_parent, game_path));
                    if (inilist.Count > 0)
                    {
                        foreach (string iniitem in inilist)
                        {
                            splitdata.iniFile = Path.Combine(folder_parent, game_path, iniitem);
                            SplitDataList.Add(splitdata);
                        }
                    }
                    else
                    {
                        splitdata.iniFile = Path.Combine(folder_parent, game_path, Path.GetFileNameWithoutExtension(file) + ".ini");
                        SplitDataList.Add(splitdata);
                    }
                }

                foreach (SplitData CurrentSplitData in SplitDataList)
                {
                    datafilename = CurrentSplitData.dataFile;
                    inifilename  = CurrentSplitData.iniFile;

                    Console.WriteLine("Splitting file: " + datafilename);
                    if (out_path == "")
                    {
                        projectFolderName = Path.GetDirectoryName(datafilename);
                    }
                    else
                    {
                        projectFolderName = out_path;
                    }

                    if (projectFolderName[projectFolderName.Length - 1] != '/')
                    {
                        projectFolderName = string.Concat(projectFolderName, '/');
                    }
                    Console.WriteLine("Output folder: " + projectFolderName);

                    if (!File.Exists(datafilename))
                    {
                        Console.WriteLine(datafilename + " not found. Aborting.");
                        continue;
                    }

                    if (!Directory.Exists(projectFolderName))
                    {
                        // try creating the directory
                        bool created = true;

                        try
                        {
                            // check to see if trailing charcter closes
                            Directory.CreateDirectory(projectFolderName);
                        }
                        catch
                        {
                            created = false;
                        }

                        if (!created)
                        {
                            // couldn't create directory.
                            Console.WriteLine("Output folder did not exist and couldn't be created.");
                            continue;
                        }
                    }

                    if (!File.Exists(inifilename))
                    {
                        if (inifilename.Length > 9 && File.Exists(inifilename.Substring(0, inifilename.Length - 9) + ".ini"))
                        {
                            inifilename = inifilename.Substring(0, inifilename.Length - 9) + ".ini";
                        }
                        else if (Path.GetExtension(datafilename).ToLowerInvariant() == ".nb")
                        {
                            Console.WriteLine("Splitting NB file without INI data");
                            inifilename = null;
                        }
                        else
                        {
                            Console.WriteLine(inifilename + " not found. Aborting.");
                            continue;
                        }
                    }
                    if (inifilename != null)
                    {
                        Console.WriteLine("Using split data: " + inifilename);
                    }
                    switch (Path.GetExtension(datafilename).ToLowerInvariant())
                    {
                    case ".dll":
                        SA_Tools.SplitDLL.SplitDLL.SplitDLLFile(datafilename, inifilename, projectFolderName);
                        break;

                    case ".nb":
                        SA_Tools.Split.SplitNB.SplitNBFile(datafilename, false, projectFolderName, 0, inifilename);
                        break;

                    default:
                        SA_Tools.Split.Split.SplitFile(datafilename, inifilename, projectFolderName);
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("Starting split for " + files[0] + System.Environment.NewLine);
                Console.WriteLine("Output folder: " + out_path + System.Environment.NewLine);
                SA_Tools.SAArc.sa2MDL.Split(splitMDL > 1, files[0], out_path, files.Skip(1).ToArray());
            }
            Console.WriteLine("Split job finished.");
        }
        private void tryPath(String path)
        {
            if (!watchers.ContainsKey(path)) {
            Console.WriteLine("Checking " + path);
              }

              splitData[path] = new SplitData();
              if (!File.Exists(path + "\\stats0")) {
            watchers[path] = null;
            return;
              }
              Console.WriteLine("Start watch path " + path);

              FileSystemWatcher watcher = new FileSystemWatcher();
              watcher.Path = path;
              watcher.Changed += new FileSystemEventHandler(
            (object source, FileSystemEventArgs eargs) => {
              Console.WriteLine(eargs.Name);
              if (eargs.Name == "stats0" &&
              eargs.ChangeType == WatcherChangeTypes.Changed) {
            pulseSplit(path);
              }
            });
              watcher.Error += (object source, ErrorEventArgs e) => {
            Console.WriteLine("Lost directory " + path);
            lock(watchers) {
              watchers[path] = null;
            }
              };
              watcher.EnableRaisingEvents = true;
              watchers[path] = watcher;
        }
Example #23
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public void ToSplit()
        {
            //string designId = Request["designId"] ?? "";



            string cabinetType = Request["CabinetType"] ?? "Wardrobe"; //衣柜、橱柜
            string DesignerID  = Request["DesignerID"] ?? "";
            string DesignerNo  = Request["DesignerNo"] ?? "";
            string result      = "";
            string uid         = "meiwu";
            //福满多测试
            string pwd = "pwd123456";

            //string SolutionFileUrl = "";
            //string TaskID = "";

            string ReferenceID = DesignerID;
            string CustomerID  = "";

            //string lid = "13760865705";
            //string designId = "3FO4IH68IPBB";

            string   lid      = "";
            string   designId = "";
            string   Password = "";
            Database db1      = new Database("BE_RoomDesignerKJLRelation_Proc", "CHENINFO", 0, 0, DesignerNo, "", "");

            using (SqlDataReader dr = db1.ExecuteReader())
            {
                if (dr.Read())
                {
                    uid      = dr["CompanyCode"].ToString();
                    lid      = dr["UserCode"].ToString();
                    designId = dr["KJLDesignID"].ToString();
                    Password = dr["Password"].ToString();
                    Password = CEncrypt.DecryptString(Password);
                    Password = "******";
                }
                else
                {
                    throw new Exception(DesignerNo);
                }
            }



            LoginResult restCache;

            //if (CacheHelpers.GetCache("LoginResult") != null)
            //{
            //    restCache = (LoginResult)CacheHelpers.GetCache("LoginResult");
            //    if (!restCache.success)
            //    {
            //        restCache = login3DWeb(uid, lid, pwd);
            //        CacheHelpers.SetCache("LoginResult", restCache, new TimeSpan(23, 0, 0));
            //    }
            //}
            //else
            //{
            //    restCache = login3DWeb(uid, lid, pwd);
            //    CacheHelpers.SetCache("LoginResult", restCache, new TimeSpan(23, 0, 0));
            //}


            restCache = login3DWeb(uid, lid, pwd);

            SplitData sdata = new SplitData();

            try
            {
                Database db = new Database("BE_RoomDesignerKJLRelation_Proc", "CHENSPLID", 0, 0, designId, "", "");
                using (SqlDataReader rd = db.ExecuteReader())
                {
                    if (rd.Read())
                    {
                        sdata.appName        = cabinetType;
                        sdata.obsDesignId    = designId;
                        sdata.cusOrderId     = rd[0].ToString();
                        sdata.cusName        = rd[1].ToString();;
                        sdata.cusPhone       = rd[2].ToString();;
                        sdata.cusAddress     = rd[3].ToString();;
                        sdata.beginOrderData = rd[4].ToString();
                        DesignerID           = rd[5].ToString();
                        CustomerID           = rd[6].ToString();
                        sdata.endOrderData   = "";

                        CookieContainer cc = restCache.msg as CookieContainer;

                        //process=1橱柜;process=2衣柜
                        LoginResult cResult = check3DWeb(cc, 2);
                        if (cResult.success == false)
                        {
                            //throw new Exception(cResult.msg.ToString());
                            WriteMessage(0, cResult.msg.ToString());
                        }
                        //result = split3DWeb(cc, JsonConvert.SerializeObject(sdata));
                        result = submitDesign(uid, lid, Password, sdata);


                        if (result.IndexOf("成功") != -1)
                        {
                            string uploadPath = "/temp/" + DateTime.Now.ToString("yyyyMMdd") + "/SolutionFile/";

                            string ServerPath = Server.MapPath(uploadPath);


                            if (!Directory.Exists(ServerPath))
                            {
                                Directory.CreateDirectory(ServerPath);
                            }



                            string filepath = ServerPath + DesignerNo + ".zip";
                            uploadPath = uploadPath + DesignerNo + ".zip";
                            //FileStream fs = new FileStream(filepath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);

                            string rst = separateBill(uid, lid, Password, filepath, designId, "衣柜");
                            if (rst.IndexOf("false") != -1)
                            {
                                WriteMessage(0, rst);
                            }
                            else
                            {
                                WriteMessage(1, uploadPath);
                            }


                            //LoginResult loginResult = JsonConvert.DeserializeObject<LoginResult>(result);
                            //Uri url = new Uri(loginResult.msg.ToString());
                            //byte[] byteArray = Encoding.UTF8.GetBytes(url.Query.Substring(1));
                            ////Cookie cookieRequest = new Cookie("Cid", "FFFFFFFFFFFFFFFF");

                            ////cookieRequest.Domain = "120.77.62.58";
                            //HttpWebRequest request = WebRequest.Create(loginResult.msg.ToString()) as HttpWebRequest;

                            //request.Method = "POST";
                            //request.KeepAlive = false;
                            //request.ContentType = "application/x-www-form-urlencoded";
                            //request.ContentLength = byteArray.Length;
                            ////request.CookieContainer = new CookieContainer();
                            //request.CookieContainer = cc;
                            //Stream requestStream = request.GetRequestStream();
                            //requestStream.Write(byteArray, 0, byteArray.Length);
                            //requestStream.Flush();
                            //requestStream.Close();

                            //HttpWebResponse response = request.GetResponse() as HttpWebResponse;

                            ////CookieContainer cookieResponse = new CookieContainer();
                            ////cookieResponse.Add(response.Cookies);
                            //Stream stream = response.GetResponseStream();
                            //byte[] bArr = new byte[1024];
                            //int size = stream.Read(bArr, 0, (int)bArr.Length);



                            //string uploadPath = "/temp/" + DateTime.Now.ToString("yyyyMMdd") + "/SolutionFile/";

                            //string ServerPath = Server.MapPath(uploadPath);


                            //if (!Directory.Exists(ServerPath))
                            //{
                            //    Directory.CreateDirectory(ServerPath);
                            //}



                            //string filepath = ServerPath + DesignerNo + ".zip";
                            //uploadPath = uploadPath + DesignerNo + ".zip";
                            //FileStream fs = new FileStream(filepath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                            //while (size > 0)
                            //{
                            //    //stream.Write(bArr, 0, size);
                            //    fs.Write(bArr, 0, size);
                            //    size = stream.Read(bArr, 0, (int)bArr.Length);
                            //}
                            //fs.Close();
                            //stream.Close();
                        }
                        else
                        {
                            WriteMessage(0, result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            //Response.Write(result);
        }
        private SplitData CalcSplitBounds()
        {
            SplitData data = new SplitData();
            Control control = this.FindTarget();
            data.target = control;
            if (control != null)
            {
                switch (control.Dock)
                {
                    case DockStyle.Top:
                    case DockStyle.Bottom:
                        this.initTargetSize = control.Bounds.Height;
                        break;

                    case DockStyle.Left:
                    case DockStyle.Right:
                        this.initTargetSize = control.Bounds.Width;
                        break;
                }
                Control parentInternal = this.ParentInternal;
                Control.ControlCollection controls = parentInternal.Controls;
                int count = controls.Count;
                int num2 = 0;
                int num3 = 0;
                for (int i = 0; i < count; i++)
                {
                    Control control3 = controls[i];
                    if (control3 != control)
                    {
                        switch (control3.Dock)
                        {
                            case DockStyle.Top:
                            case DockStyle.Bottom:
                                num3 += control3.Height;
                                break;

                            case DockStyle.Left:
                            case DockStyle.Right:
                                num2 += control3.Width;
                                break;
                        }
                    }
                }
                Size clientSize = parentInternal.ClientSize;
                if (this.Horizontal)
                {
                    this.maxSize = (clientSize.Width - num2) - this.minExtra;
                }
                else
                {
                    this.maxSize = (clientSize.Height - num3) - this.minExtra;
                }
                data.dockWidth = num2;
                data.dockHeight = num3;
            }
            return data;
        }
        private void attemptToCreateAssembly()
        {
            //TODO: This node should always be a good start node, but may be an erroneous one, check for this.
            var curNode = gg.MetaNodes.Where(x => x.Lowest_Reference_Position != 0).MaxBy(x => (x.AvgKmerCoverage * x.ConstituentNodes.Count));//*(.2/x.Lowest_Reference_Position));//.MinBy(x => x.Lowest_Reference_Position);

            //Let's try just going with the forward primer
            //var match = forwardPrimer.Substring(0, gg.MegaNodes.First().LeadingKmer.Length);
            //var rc_match = ((new Bio.Sequence(Bio.Alphabets.NoGapDNA, match)).GetReverseComplementedSequence() as Bio.Sequence).ConvertToString();
            //var curNode = gg.MegaNodes.Where(x => x.Sequence.Contains(match) || x.Sequence.Contains(rc_match)).First();
            _greedyPathAssembly = new PossibleAssembly();
            if (!curNode.CircularLoop)
            {
                MitoPaintedAssembler.RaiseStatusEvent("\tAttempting to find greedy path, frequencies of majority split below");
                //now to attempt to loop back to the start node
                //will move along while greedily grabbing the next node with the highest kmer coverage
                //constantly oriented everyone so we go right ot left
                while (true)
                {
                    assemblyNodes.Add(curNode);
                    _greedyPathAssembly.AddMetaNode(curNode);
                    var possibles = curNode.GetOutgoingNodes().ToList();
                    if (possibles.Count > 0)
                    {
                        SplitData sd = new SplitData(possibles);
                        PathSplits.Add(sd);
                        if (possibles.Count > 1)
                        {
                            if (sd.MaxFrequency < MinimumGreedySplit)
                            {
                                MinimumGreedySplit = sd.MaxFrequency;
                            }
                            MitoPaintedAssembler.RaiseStatusEvent("\tPossible Paths: " + possibles.Count
                                                                  + "  Frequency: " + sd.MaxFrequency.ToString("P1")
                                                                  + "  Range: " + curNode.Lowest_Reference_Position.ToString() + "-" + curNode.Highest_Reference_Position.ToString());
                        }
                        curNode = sd.BestPath.NeighborNode;
                        if (assemblyNodes.Contains(curNode))
                        {
                            FormsCompleteLoop = true;
                            break;
                        }
                    }
                    else
                    {
                        FormsCompleteLoop = false; SuccessfulAssembly = false; break;
                    }
                }
            }
            else
            {
                FormsCompleteLoop = true;
                assemblyNodes.Add(curNode);
                _greedyPathAssembly.AddMetaNode(curNode);
                MinimumGreedySplit = 1.0;
            }
            int length = assemblyNodes.Sum(x => x.LengthOfNode);

            //now, did we form an assembly?
            if (FormsCompleteLoop || Math.Abs(length - AssemblyLength) < 100)
            {
                SuccessfulAssembly = true;
                _greedyPathAssembly.FinalizeAndOrientToReference();
                AssemblyLength = (int)_greedyPathAssembly.Sequence.Count;
                //TODO: More sophisticated criteria than larger than 8 kb to validate assembly
                if (AssemblyLength > StaticResources.SIZE_DIF_BETWEEN_LARGE_AND_SMALL_DELETION)
                {
                    SuccessfulAssembly = true;
                    MitoPaintedAssembler.RaiseStatusEvent("\tSuccessful assembly of length: " + AssemblyLength.ToString());
                }
                else
                {
                    SuccessfulAssembly = false;
                    MitoPaintedAssembler.RaiseStatusEvent("\tAssembly failed.  Only recovered sequence of length: " + AssemblyLength.ToString());
                }
            }
        }
Example #26
0
 /// <include file='doc\Splitter.uex' path='docs/doc[@for="Splitter.CalcSplitBounds"]/*' />
 /// <devdoc>
 ///     Calculates the bounding criteria for the splitter.
 /// </devdoc>
 /// <internalonly/>
 private SplitData CalcSplitBounds() {
     SplitData spd = new SplitData();
     Control target = FindTarget();
     spd.target = target;
     if (target != null) {
         switch (target.Dock) {
             case DockStyle.Left:
             case DockStyle.Right:
                 initTargetSize = target.Bounds.Width;
                 break;
             case DockStyle.Top:
             case DockStyle.Bottom:
                 initTargetSize = target.Bounds.Height;
                 break;
         }
         Control parent = ParentInternal;
         Control.ControlCollection children = parent.Controls;
         int count = children.Count;
         int dockWidth = 0, dockHeight = 0;
         for (int i = 0; i < count; i++) {
             Control ctl = children[i];
             if (ctl != target) {
                 switch (((Control)ctl).Dock) {
                     case DockStyle.Left:
                     case DockStyle.Right:
                         dockWidth += ctl.Width;
                         break;
                     case DockStyle.Top:
                     case DockStyle.Bottom:
                         dockHeight += ctl.Height;
                         break;
                 }
             }
         }
         Size clientSize = parent.ClientSize;
         if (Horizontal) {
             maxSize = clientSize.Width - dockWidth - minExtra;
         }
         else {
             maxSize = clientSize.Height - dockHeight - minExtra;
         }
         spd.dockWidth = dockWidth;
         spd.dockHeight = dockHeight;
     }
     return spd;
 }
 public void setSplit(SplitData split)
 {
     this.split = split;
 }
Example #28
0
        public static Mesh split(Mesh mesh, Plane splitPlane)
        {
            List <SplitData> ld = new List <SplitData> ();

            Vector3[] v   = mesh.vertices;
            int[]     tri = mesh.triangles;
            for (int i = 0, max = tri.Length; i < max; i += 3)
            {
                Vector3 v1 = v [tri [i]];
                Vector3 v2 = v [tri [i + 1]];
                Vector3 v3 = v [tri [i + 2]];
                float   d1 = splitPlane.GetDistanceToPoint(v1);
                float   d2 = splitPlane.GetDistanceToPoint(v2);
                float   d3 = splitPlane.GetDistanceToPoint(v3);
                if (d1 * d2 < 0 || d1 * d3 < 0 || d2 * d3 < 0)         //存在新交点,该面片需要重构
                {
                    SplitData data = new SplitData();
                    data.tri = i;
                    data.d1  = d1;
                    data.d2  = d2;
                    data.d3  = d3;
                    ld.Add(data);
                }
            }

            //修改面拓扑结构
            int            nvStart = v.Length;
            List <Vector3> nv      = new List <Vector3> ();
            List <int>     ntri    = new List <int> ();

            for (int i = 0, max = ld.Count; i < max; ++i)
            {
                //建立点的环状排列,这样后面建立三角形的顶点顺序才正确
                int[]     vidx = new int[5];
                int       k    = 0;
                int       n    = 0;
                SplitData data = ld [i];
                Vector3   v1   = v [tri [data.tri]];
                Vector3   v2   = v [tri [data.tri + 1]];
                Vector3   v3   = v [tri [data.tri + 2]];
                vidx [k++] = tri [data.tri];
                if (data.d1 * data.d2 < 0)
                {
                    //添加切割点时,可以使用映射表查询,排除一条边上重复生成切割点
                    nv.Add(v1 - data.d1 / (data.d1 - data.d2) * (v1 - v2));
                    vidx [n = k++] = nvStart++;
                }
                vidx [k++] = tri [data.tri + 1];
                if (data.d2 * data.d3 < 0)
                {
                    nv.Add(v2 - data.d2 / (data.d2 - data.d3) * (v2 - v3));
                    vidx [n = k++] = nvStart++;
                }
                vidx [k++] = tri [data.tri + 2];
                if (data.d3 * data.d1 < 0)
                {
                    nv.Add(v3 - data.d3 / (data.d3 - data.d1) * (v3 - v1));
                    vidx [n = k++] = nvStart++;
                }

                //建立新面片
                tri [data.tri]     = vidx [n];
                tri [data.tri + 1] = vidx [(n + 1) % k];
                tri [data.tri + 2] = vidx [(n + 2) % k];
                ntri.Add(vidx [n]);
                ntri.Add(vidx [(n + 2) % k]);
                ntri.Add(vidx [(n + 3) % k]);
                if (k > 4)
                {
                    ntri.Add(vidx [n]);
                    ntri.Add(vidx [(n + 3) % k]);
                    ntri.Add(vidx [(n + 4) % k]);
                }
            }

            //合并顶点和面
            Vector3[] nnv   = new Vector3[v.Length + nv.Count];
            int[]     nntri = new int[tri.Length + ntri.Count];
            for (int i = 0, max = v.Length; i < max; ++i)
            {
                nnv [i] = v [i];
            }
            for (int i = 0, j = v.Length, max = nv.Count; i < max; ++i)
            {
                nnv [j++] = nv [i];
            }
            for (int i = 0, max = tri.Length; i < max; ++i)
            {
                nntri [i] = tri [i];
            }
            for (int i = 0, j = tri.Length, max = ntri.Count; i < max; ++i)
            {
                nntri [j++] = ntri[i];
            }

            Mesh newMesh = new Mesh();

            newMesh.vertices  = nnv;
            newMesh.triangles = nntri;
            newMesh.RecalculateNormals();
            return(newMesh);
        }