コード例 #1
0
    public void CutTool_CutUsing3NewVerticesNoLoop_TestInsertionTypes_TestCreates2Faces()
    {
        CutTool tool = ScriptableObject.CreateInstance <CutTool>();

        ToolManager.SetActiveTool(tool);

        int  originalFaceCount = m_PBMesh.faces.Count;
        Face face = m_PBMesh.faces[0];

        Assume.That(face, Is.Not.Null);

        Vertex[] vertices    = m_PBMesh.GetVertices();
        var      faceIndexes = face.distinctIndexes;

        Assume.That(faceIndexes.Count, Is.EqualTo(4));

        Vector3 pos_a = Math.Average(new Vector3[] { vertices[faceIndexes[0]].position, vertices[faceIndexes[1]].position, vertices[faceIndexes[2]].position });
        Vector3 pos_b = Math.Average(new Vector3[] { vertices[faceIndexes[1]].position, vertices[faceIndexes[2]].position, vertices[faceIndexes[3]].position });
        Vector3 pos_c = Math.Average(new Vector3[] { vertices[faceIndexes[0]].position, vertices[faceIndexes[1]].position, vertices[faceIndexes[3]].position });

        //Creating a first new vertex
        tool.UpdateCurrentPosition(face, pos_a, Vector3.up);
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.NewVertex));

        //Insert first vertex to the path
        tool.AddCurrentPositionToPath();
        Assert.That(tool.m_CutPath.Count, Is.EqualTo(1));
        //No connection is created yet
        Assert.That(tool.m_MeshConnections.Count, Is.EqualTo(0));

        //Creating a second new vertex
        tool.UpdateCurrentPosition(face, pos_b, Vector3.up);
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.NewVertex));

        //Insert 2nd point to the path
        tool.AddCurrentPositionToPath();
        Assert.That(tool.m_CutPath.Count, Is.EqualTo(2));
        //Check that the created path is connected twice to the containing face
        Assert.That(tool.m_MeshConnections.Count, Is.EqualTo(2));

        //Creating a third new vertex
        tool.UpdateCurrentPosition(face, pos_c, Vector3.up);
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.NewVertex));

        //Insert 3rd point to the path
        tool.AddCurrentPositionToPath();
        Assert.That(tool.m_CutPath.Count, Is.EqualTo(3));
        //Check that the created path is connected twice to the containing face
        Assert.That(tool.m_MeshConnections.Count, Is.EqualTo(2));

        ActionResult result = tool.DoCut();

        Assert.That(result.status, Is.EqualTo(ActionResult.Success.status));
        Assert.That(m_PBMesh.faces.Count, Is.EqualTo(originalFaceCount - 1 /*removed face*/ + 2 /*added faces*/));

        Object.DestroyImmediate(tool);
    }
コード例 #2
0
 public DrawTools(MainWin window, PictureBox pic)
 {
     this.mainWindow  = window;
     this.mainPicture = pic;
     this.pointerTool = new PointerTool(mainWindow, mainPicture);
     this.lineTool    = new LineTool(mainWindow, mainPicture);
     this.rectTool    = new RectTool(mainWindow, mainPicture);
     this.polyTool    = new PolyTool(mainWindow, mainPicture);
     this.circleTool  = new CircleTool(mainWindow, mainPicture);
     this.curveTool   = new CurveTool(mainWindow, mainPicture);
     this.fillTool    = new FillTool(mainWindow, mainPicture);
     this.resizeTool  = new ResizeTool(mainWindow, mainPicture);
     this.cutTool     = new CutTool(mainWindow, mainPicture);
 }
コード例 #3
0
    public void CutTool_EdgeToEdgeCut_TestInsertOnEdge_TestCreatesTwoFaces()
    {
        CutTool tool = ScriptableObject.CreateInstance <CutTool>();

        ToolManager.SetActiveTool(tool);

        int  originalFaceCount = m_PBMesh.faces.Count;
        Face face = m_PBMesh.faces[0];

        Assert.That(face, Is.Not.Null);

        Vertex[] vertices    = m_PBMesh.GetVertices();
        var      faceIndexes = face.distinctIndexes;

        Assert.That(faceIndexes.Count, Is.EqualTo(4));

        Vector3 pos_a = Math.Average(new Vector3[] { vertices[faceIndexes[0]].position, vertices[faceIndexes[1]].position });
        Vector3 pos_b = Math.Average(new Vector3[] { vertices[faceIndexes[2]].position, vertices[faceIndexes[3]].position });

        tool.UpdateCurrentPosition(face, pos_a, Vector3.up);
        Assert.That(tool.m_TargetFace, Is.Null);
        Assert.That(tool.m_CurrentFace, Is.EqualTo(face));
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.AddedOnEdge));

        tool.AddCurrentPositionToPath();
        Assert.That(tool.m_CutPath.Count, Is.EqualTo(1));
        Assert.That(tool.m_TargetFace, Is.EqualTo(face));
        Assert.That(tool.m_MeshConnections.Count, Is.EqualTo(0));

        tool.UpdateCurrentPosition(face, pos_b, Vector3.up);
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.NewVertex));

        tool.m_SnappingPoint = true;
        tool.UpdateCurrentPosition(face, pos_b, Vector3.up);
        Assert.That(tool.m_CurrentVertexTypes, Is.EqualTo(CutTool.VertexTypes.AddedOnEdge));

        tool.AddCurrentPositionToPath();
        Assert.That(tool.m_CutPath.Count, Is.EqualTo(2));

        ActionResult result = tool.DoCut();

        Assert.That(result.status, Is.EqualTo(ActionResult.Success.status));
        Assert.That(m_PBMesh.faces.Count, Is.EqualTo(originalFaceCount - 1 /*removed face*/ + 2 /*added faces*/));

        Object.DestroyImmediate(tool);
    }
コード例 #4
0
        public static List <WordPair> cut(string str, CutTool tool = CutTool.jieba)
        {
            try
            {
                str = ChineseStringUtility.ToSimplified(str);
                str = removeBlanks(str);
                List <WordPair> res = new List <WordPair>();
                List <Pair>     tmp = new List <Pair>();
                switch (tool)
                {
                case CutTool.jieba:
                    //jieba分词
                    PosSegmenter p = new PosSegmenter();
                    tmp = p.Cut(str).ToList();
                    break;

                case CutTool.nlpir:
                    //NLPIR-ICTCLAS分词
                    tmp = cutByICTCLAS(str);
                    break;

                default:
                    break;
                }
                foreach (var p in tmp)
                {
                    res.Add(new WordPair(p));
                }

                return(res);
            }
            catch
            {
                return(new List <WordPair>());
            }
        }
コード例 #5
0
ファイル: FCutString.cs プロジェクト: YYCatKnight/DieWorld
 public void Init()
 {
     HeadCut = new CutTool();
     HeadCut.Init(mValue);
 }