Beispiel #1
0
    private void CreateRibbons(List <Dictionary <string, Vector3> > residueDicts, List <int> sslist, List <int> handedlist)
    {
        //List<Dictionary<string, Vector3>> residueDicts = Molecule.Model.MoleculeModel.residueDictionaries;

        // For line ribbons
        List <Vector3> vertices0 = new List <Vector3>();
        List <Vector3> vertices1 = new List <Vector3>();
        List <Vector3> vertices2 = new List <Vector3>();

        // For flat ribbons
        List <Vector3> vertices = new List <Vector3>();
        List <Color32> colors   = new List <Color32>();
        List <Vector3> normals  = new List <Vector3>();

        switch (RIBBON_DETAIL)
        {
        case 1:
            uspacing = 10;
            break;

        case 2:
            uspacing = 5;
            break;

        case 3:
            uspacing = 2;
            break;

        default:
            uspacing = 1;
            break;
        }

        flipTestV    = new Vector3();
        splineSide1  = new BSpline(false);
        splineCenter = new BSpline(false);
        splineSide2  = new BSpline(false);

        int[]      ss          = new int[residueDicts.Count];
        int[]      handedness  = new int[residueDicts.Count];
        List <int> ssglic      = new List <int> ();  // Specific to Glic for now (split differents domains)
        int        nbRes       = residueDicts.Count;
        int        colorOffset = nbRes - 1;

        if (createss)           // if ss informations in the pdb file
        {
            ss         = sslist.ToArray();
            handedness = handedlist.ToArray();
        }
        else
        {
            CalculateSecondaryStructures(residueDicts, ss, handedness);
            nbRes = residueDicts.Count;
            // Colors and structures are misaligned without this offset. Not sure why.
            // Keeping identical offsets?
            colorOffset = nbRes - 1;
            //int arrowOffset = nbRes - 1;
            //colorOffset  = 0;

            for (int i = 1; i < nbRes - 1; i++)
            {
                if (ss [i - 1] == HELIX && ss [i + 1] == HELIX)
                {
                    ss [i] = HELIX;
                }
                if (ss [i - 1] == STRAND && ss [i + 1] == STRAND)
                {
                    ss [i] = STRAND;
                }
            }
        }

        InitCol();              //Initialization Dictionary of colors

        List <int> triangles = new List <int>();

        vIndex = 0;
        bool isArrow;

        for (int i = 0; i < nbRes; i++)
        {
            ConstructControlPoints(residueDicts, i, ss[i], handedness[i]);
            int colorIndex = (i + colorOffset) % nbRes;
            //int arrowIndex = (i+arrowOffset) % nbRes;
            isArrow = (ss[colorIndex] == STRAND && ((colorIndex + 1 == nbRes) || (ss[colorIndex + 1] != STRAND)));

            if (RENDER_MODE == 0)
            {
                GenerateSpline(0, vertices0);
                GenerateSpline(1, vertices1);
                GenerateSpline(2, vertices2);
            }
            else
            {
                if (isArrow && ARROW_WIDTH > 0f)
                {
                    GenerateArrowRibbon(vertices, normals, triangles);
                }
                else
                {
                    GenerateFlatRibbon(vertices, normals, triangles);
                }
                Color32 color;

                if (UI.UIData.ssColChain)
                {
                    color = GetColorChain(currentchain);
                    if (i > 185 && UI.UIData.ssDivCol)
                    {
                        color.g += 100;
                        color.b += 100;
                    }
                }
                else
                {
                    switch (ss[colorIndex])
                    {
                    case HELIX:
                        color = HELIX_COLOR.color;
                        break;

                    case STRAND:
                        color = STRAND_COLOR.color;
                        break;

                    default:
                        color = COIL_COLOR.color;
                        break;
                    }
                }
                for (int j = 0; j < 320; j++)
                {
                    colors.Add(color);
                }

                ssglic.Add(ss[i]);
            }
        }

        if (RENDER_MODE == 0)
        {
            // Forget that for now
        }
        else
        {
            PostProcessing.GenerateMeshes(vertices, normals, triangles, colors, ss);
        }
    }     // End of CreateRibbons
Beispiel #2
0
    private void CreateRibbons(List <Dictionary <string, Vector3> > residueDicts, List <int> sslist, List <int> handedlist)
    {
        //List<Dictionary<string, Vector3>> residueDicts = Molecule.Model.MoleculeModel.residueDictionaries;

        // For line ribbons
        List <Vector3> vertices0 = new List <Vector3>();
        List <Vector3> vertices1 = new List <Vector3>();
        List <Vector3> vertices2 = new List <Vector3>();

        // For flat ribbons
        List <Vector3> vertices = new List <Vector3>();
        List <Color32> colors   = new List <Color32>();
        List <Vector3> normals  = new List <Vector3>();

        switch (RIBBON_DETAIL)
        {
        case 1:
            uspacing = 10;
            break;

        case 2:
            uspacing = 5;
            break;

        case 3:
            uspacing = 2;
            break;

        default:
            uspacing = 1;
            break;
        }

        flipTestV    = new Vector3();
        splineSide1  = new BSpline(false);
        splineCenter = new BSpline(false);
        splineSide2  = new BSpline(false);

        int[]      ss          = new int[residueDicts.Count];
        int[]      handedness  = new int[residueDicts.Count];
        List <int> ssglic      = new List <int> ();  // Specific to Glic for now (split differents domains)
        int        nbRes       = residueDicts.Count;
        int        colorOffset = nbRes - 1;

        Debug.Log("ss.Length: " + ss.Length);

        if (createss)           // if ss informations in the pdb file
        {
            ss = sslist.ToArray();
            Debug.Log("ss.Length: " + ss.Length);
            handedness = handedlist.ToArray();
        }
        else
        {
            CalculateSecondaryStructures(residueDicts, ss, handedness);
            nbRes = residueDicts.Count;
            // Colors and structures are misaligned without this offset. Not sure why.
            // Keeping identical offsets?
            colorOffset = nbRes - 1;
            //int arrowOffset = nbRes - 1;
            //colorOffset  = 0;

            for (int i = 1; i < nbRes - 1; i++)
            {
                if (ss [i - 1] == HELIX && ss [i + 1] == HELIX)
                {
                    ss [i] = HELIX;
                }
                if (ss [i - 1] == STRAND && ss [i + 1] == STRAND)
                {
                    ss [i] = STRAND;
                }
            }
        }

        InitCol();              //Initialization Dictionary of colors

        List <int> triangles = new List <int>();

        vIndex = 0;
        bool isArrow;

        for (int i = 0; i < nbRes; i++)      // i == index of current Residue.
        {
            Residue r = MoleculeModel.residueSeq[i];
            ConstructControlPoints(residueDicts, i, ss[i], handedness[i]);
            int colorIndex = (i + colorOffset) % nbRes;
            //int arrowIndex = (i+arrowOffset) % nbRes;
            Debug.Log("ss.Length: " + ss.Length + " colorIndex: " + colorIndex + " nbRes: " + nbRes + " residueDicts.Count: " + residueDicts.Count);
            isArrow = (ss[colorIndex] == STRAND && ((colorIndex + 1 == nbRes)));              //|| (ss[colorIndex+1] != STRAND)

            if (RENDER_MODE == 0)
            {
                Debug.Log("RENDER_MODE == 0");
                GenerateSpline(0, vertices0);
                GenerateSpline(1, vertices1);
                GenerateSpline(2, vertices2);
            }
            else                 //vertices, normals, triangles are added.
            {
                Debug.Log("RENDER_MODE != 0");
                int vBefore = vertices.Count;
                int nBefore = normals.Count;
                int tBefore = triangles.Count;
                if (isArrow && ARROW_WIDTH > 0f)
                {
                    Debug.Log("before vertices.Count: " + vertices.Count);
                    GenerateArrowRibbon(vertices, normals, triangles);
                    Debug.Log("after vertices.Count: " + vertices.Count);
                }
                else
                {
                    Debug.Log("before vertices.Count: " + vertices.Count);
                    GenerateFlatRibbon(vertices, normals, triangles);
                    Debug.Log("after vertices.Count: " + vertices.Count);
                }

                int vAfter = vertices.Count;
                int nAfter = normals.Count;
                int tAfter = triangles.Count;

                r.vertices    = new List <int>(new int[] { vBefore, vAfter - 1 });
                r.normals     = new List <int>(new int[] { nBefore, nAfter - 1 });
                r.triangles   = new List <int>(new int[] { tBefore, tAfter - 1 });
                r.meshIndices = new List <int>();

                Color32 color;

                if (UI.UIData.ssColChain)
                {
                    color = GetColorChain(currentchain);
                    if (i > 185 && UI.UIData.ssDivCol)
                    {
                        color.g += 100;
                        color.b += 100;
                    }
                }
                else
                {
                    switch (ss[colorIndex])
                    {
                    case HELIX:
                        color = HELIX_COLOR.color;
                        break;

                    case STRAND:
                        color = STRAND_COLOR.color;
                        break;

                    default:
                        color = COIL_COLOR.color;
                        break;
                    }
                }
                r.colors = new List <Color32>();
                for (int j = 0; j < 320; j++)
                {
                    colors.Add(color);
                    r.colors.Add(color);
                }

                ssglic.Add(ss[i]);
            }
            MoleculeModel.residueSeq[i] = r; //@imyjimmy
        }                                    //end for loop

        if (RENDER_MODE == 0)
        {
            // Forget that for now
        }
        else
        {
            postprocessing.GenerateMeshes(vertices, normals, triangles, colors, ss, MoleculeModel.residueSeq);
        }
    }     // End of CreateRibbons