当前位置: 首页>>代码示例>>C#>>正文


C# Shape.Add方法代码示例

本文整理汇总了C#中Shape.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.Add方法的具体用法?C# Shape.Add怎么用?C# Shape.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shape的用法示例。


在下文中一共展示了Shape.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Untruncate

 private void Untruncate(PatternNode<Word, ShapeNode> patternNode, Shape output, bool optional, VariableBindings varBindings)
 {
     foreach (PatternNode<Word, ShapeNode> node in patternNode.Children)
     {
         var constraint = node as Constraint<Word, ShapeNode>;
         if (constraint != null && constraint.Type() == HCFeatureSystem.Segment)
         {
             FeatureStruct fs = constraint.FeatureStruct.DeepClone();
             fs.ReplaceVariables(varBindings);
             output.Add(fs, optional);
         }
         else
         {
             var quantifier = node as Quantifier<Word, ShapeNode>;
             if (quantifier != null)
             {
                 for (int i = 0; i < quantifier.MaxOccur; i++)
                     Untruncate(quantifier, output, i >= quantifier.MinOccur, varBindings);
             }
             else
             {
                 Untruncate(node, output, optional, varBindings);
             }
         }
     }
 }
开发者ID:sillsdev,项目名称:hermitcrab,代码行数:26,代码来源:AnalysisMorphologicalTransform.cs

示例2: CreateShapes

        /*
         * Detectar os ciclos dentro do grafo para transforma-los em objetos coloridos
         */
        internal String CreateShapes()
        {
            Shapes shapes = new Shapes();
            Shape shape = new Shape();
            ArrayList processedCurves = new ArrayList();

            Pixel lastPixel = null;
            Pixel firstPixel = null;
            Color color;
            bool hasCurve = true;
            foreach (Curve curve in curvesC)
            {

                Curve processingCurve = curve;
                color = processingCurve.color;
                if (!processedCurves.Contains(processingCurve))
                {
                    processedCurves.Add(processingCurve);
                    ArrayList curveArray = (ArrayList)processingCurve.curve;

                    firstPixel = getFirstPixel(curveArray);
                    lastPixel = getLastPixel(curveArray);
                    shape.Add(curve);
                    if (!firstPixel.Equals(lastPixel)) // se primeiro e ultimo são iguais, então o circuito já esta fechado
                    {
                        hasCurve = true;
                        while (hasCurve)
                        {

                            foreach (Curve newCurve in curvesC) // verifico todas as curvas procurando uma que comece ou termine com o ultimo pixel da pesquisada
                            {

                                if ((newCurve.color == color && newCurve != curve && !processedCurves.Contains(newCurve) )) // Precisa ser uma curva não processessada e com cor igual
                                {

                                    hasCurve = false;
                                    ArrayList newCurveArray = (ArrayList)newCurve.curve;
                                    TaggedUndirectedEdge<Pixel, EdgeTag> firstNewEdge = (TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0];
                                    TaggedUndirectedEdge<Pixel, EdgeTag> lastNewEdge = (TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[newCurveArray.Count - 1];

                                    if (firstNewEdge.Source.Equals(lastPixel) || firstNewEdge.Target.Equals(lastPixel) || lastNewEdge.Target.Equals(lastPixel) || lastNewEdge.Source.Equals(lastPixel)) // se a curva analizada possui o primeiro ou ultimo pixel igual a um pixel do lastEdge // simplificado apenas para conter um dos pixeis da ultima aresta da curva
                                    {
                                        if (firstNewEdge.Source.Equals(lastPixel) || firstNewEdge.Target.Equals(lastPixel))
                                        {
                                            if (newCurveArray.Count == 1)
                                            {
                                                if (((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Source.Equals(lastPixel))
                                                    lastPixel = ((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Target;
                                                else
                                                    lastPixel = ((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Source;
                                            }
                                            else lastPixel = getLastPixel(newCurveArray);
                                        }
                                        else
                                        {
                                            if (newCurveArray.Count == 1)
                                            {
                                                if (((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Source.Equals(lastPixel))
                                                    lastPixel = ((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Target;
                                                else
                                                    lastPixel = ((TaggedUndirectedEdge<Pixel, EdgeTag>)newCurveArray[0]).Source;
                                            }
                                            else
                                            {
                                                lastPixel = getFirstPixel(newCurveArray);
                                                newCurveArray.Reverse();
                                            }
                                        }

                                        processedCurves.Add(newCurve);
                                        if (!lastPixel.Equals(firstPixel))
                                        {
                                            shape.Add(newCurve);
                                            hasCurve = true;
                                            break;
                                        }
                                        else // terminou o grupo de curvas
                                        {
                                            shape.Add(newCurve);
                                            shapes.Add(shape);
                                            hasCurve = false;
                                        }

                                    }
                                }

                            }

                        }
                    }
                    else
                    {
                        shapes.Add(shape);

                    }
                    shape = new Shape();
                }
//.........这里部分代码省略.........
开发者ID:michaelrbk,项目名称:pixelart-vectorizer,代码行数:101,代码来源:Vectorize.cs

示例3: SegmentString

        private bool SegmentString(Shape shape, string str)
        {
            if (_regex == null)
                _regex = new Regex(CreateRegexString(), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            int index = 0;
            foreach (Match match in _regex.Matches(str))
            {
                if (match.Index != index)
                    break;

                if (match.Groups["vowelSeg"].Success)
                {
                    string strRep;
                    FeatureStruct phonemeFS;
                    if (!TryMultipleBaseCharacterSymbol(match, _vowels, out strRep, out phonemeFS))
                    {
                        var sb = new StringBuilder();
                        Group vowelComp = match.Groups["vowelComp"];
                        string partStrRep;
                        phonemeFS = BuildFeatStruct(match, vowelComp.Captures[0], "vowelBase", _vowels, out partStrRep);
                        sb.Append(partStrRep);
                        Group joinerGroup = match.Groups["joiner"];
                        if (joinerGroup.Success || vowelComp.Captures.Count > 1)
                        {
                            phonemeFS.AddValue(CogFeatureSystem.First, phonemeFS.DeepClone());
                            phonemeFS.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Complex);
                        }
                        else
                        {
                            phonemeFS.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Simple);
                        }
                        if (joinerGroup.Success)
                        {
                            for (int i = 0; i < joinerGroup.Captures.Count; i++)
                            {
                                string joinerStr = joinerGroup.Captures[i].Value;
                                phonemeFS.Add(BuildFeatStruct(match, vowelComp.Captures[i + 1], "vowelBase", _vowels, out partStrRep));
                                sb.Append(partStrRep);
                                FeatureStruct joinerFs = _joiners[joinerStr].FeatureStruct;
                                if (joinerFs != null)
                                    phonemeFS.PriorityUnion(joinerFs);
                            }
                        }
                        else if (vowelComp.Captures.Count > 1)
                        {
                            for (int i = 1; i < vowelComp.Captures.Count; i++)
                            {
                                phonemeFS.Add(BuildFeatStruct(match, vowelComp.Captures[i], "vowelBase", _vowels, out partStrRep));
                                sb.Append(partStrRep);
                            }
                        }
                        strRep = sb.ToString();
                    }

                    phonemeFS.AddValue(CogFeatureSystem.StrRep, strRep);
                    phonemeFS.AddValue(CogFeatureSystem.OriginalStrRep, match.Value);
                    phonemeFS.AddValue(CogFeatureSystem.Type, CogFeatureSystem.VowelType);
                    shape.Add(phonemeFS);
                }
                else if (match.Groups["consSeg"].Success)
                {
                    string strRep;
                    FeatureStruct phonemeFS;
                    if (!TryMultipleBaseCharacterSymbol(match, _consonants, out strRep, out phonemeFS))
                    {
                        var sb = new StringBuilder();
                        Group consComp = match.Groups["consComp"];
                        string compStrRep;
                        phonemeFS = BuildFeatStruct(match, consComp.Captures[0], "consBase", _consonants, out compStrRep);
                        sb.Append(compStrRep);
                        Group joinerGroup = match.Groups["joiner"];
                        if (joinerGroup.Success || consComp.Captures.Count > 1)
                        {
                            phonemeFS.AddValue(CogFeatureSystem.First, phonemeFS.DeepClone());
                            phonemeFS.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Complex);
                        }
                        else
                        {
                            phonemeFS.AddValue(CogFeatureSystem.SegmentType, CogFeatureSystem.Simple);
                        }
                        if (joinerGroup.Success)
                        {
                            for (int i = 0; i < joinerGroup.Captures.Count; i++)
                            {
                                string joinerStr = joinerGroup.Captures[i].Value;
                                phonemeFS.Add(BuildFeatStruct(match, consComp.Captures[i + 1], "consBase", _consonants, out compStrRep));
                                sb.Append(compStrRep);
                                FeatureStruct joinerFs = _joiners[joinerStr].FeatureStruct;
                                if (joinerFs != null)
                                    phonemeFS.PriorityUnion(joinerFs);
                            }
                        }
                        else if (consComp.Captures.Count > 1)
                        {
                            for (int i = 1; i < consComp.Captures.Count; i++)
                            {
                                phonemeFS.Add(BuildFeatStruct(match, consComp.Captures[i], "consBase", _consonants, out compStrRep));
                                sb.Append(compStrRep);
                            }
//.........这里部分代码省略.........
开发者ID:rmunn,项目名称:cog,代码行数:101,代码来源:Segmenter.cs


注:本文中的Shape.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。