Exemple #1
0
        /*********************************************
        * VTK functions:
        * DrawModel -- Basic function to draw model
        * DrawEdgesModel -- Add grids to the model
        * LabelGetter -- Add label to the model
        *********************************************/
        public int VTKDrawModel(ref vtkPoints points,
                                ref vtkCellArray strips,
                                ref vtkFloatArray scalars,
                                ref int pointsNum,
                                FormParas paras)
        {
            // The following routine is built for general purpose

            for (int i = 0; i < NodeList.Count(); i++)
            {
                points.InsertPoint(i,
                                   NodeList[i].Node_Coord[0],
                                   0,
                                   -NodeList[i].Node_Coord[1]);
            }
            pointsNum = NodeList.Count();

            if (paras.StageID != -1)
            {
                scalars.SetNumberOfValues(ElemList.Count());
            }
            int    cnt          = 0;
            double MAX_R        = 0;
            double MAX_R_VALUE  = 0;
            int    MAX_ELEM_NUM = 0;

            foreach (ListElemBase elem in ElemList)
            {
                strips.InsertNextCell(8);
                if (paras.StageID == -1)
                {
                    scalars.InsertNextValue(elem.Elem_Modeltype[0]);
                }
                else
                {
                    if (IfElemToPropertyKeyExists(elem.Elem_Number))
                    {
                        scalars.SetValue(cnt, (float)GetElemToProperty(elem.Elem_Number));
                    }
                    else
                    {
                        scalars.SetValue(cnt, 0);
                    }
                    //MessageBox.Show(((float)GetElemToProperty(elem.Elem_Number)).ToString());
                }

                for (int i = 0; i < 8; i++)
                {
                    int NodeId = elem.Elem_Nodes[i];
                    int NodePosInPointsArray = GetNodePositionInNodeListFromNodeId(NodeId);
                    strips.InsertCellPoint(NodePosInPointsArray);
                    if (paras.StageID != -1)
                    {
                        if (NodeList[NodePosInPointsArray].Node_Coord[0] > MAX_R)
                        {
                            MAX_R = NodeList[NodePosInPointsArray].Node_Coord[0];
                            if (IfElemToPropertyKeyExists(elem.Elem_Number))
                            {
                                MAX_R_VALUE = GetElemToProperty(elem.Elem_Number);
                            }
                            else
                            {
                                MAX_R_VALUE = 0;
                            }
                            MAX_ELEM_NUM = elem.Elem_Number;
                        }
                    }
                }

                cnt++;
            }
            //MessageBox.Show(MAX_R.ToString() + ' ' + MAX_R_VALUE.ToString() + ' ' + MAX_ELEM_NUM.ToString());

            return(1);
        }