Example #1
0
 public void EnableUVMap(bool isUVMap, FEWorld world)
 {
     if ((UVArray != null) == isUVMap)
     {
         return;
     }
     if (isUVMap)
     {
         uint ptCnt = VertexArray.PointCount;
         UVArray = new double[ptCnt * 2];
         if (!world.IsFieldValueId(ValueId))
         {
             return;
         }
         FieldValue fv         = world.GetFieldValue(ValueId);
         uint       quantityId = fv.QuantityId;
         uint       coCnt      = world.GetCoordCount(quantityId);
         for (int coId = 0; coId < coCnt; coId++)
         {
             double[] c = world.GetCoord(quantityId, coId);
             UVArray[coId * 2 + 0] = c[0] * TexScale;
             UVArray[coId * 2 + 1] = c[1] * TexScale;
         }
     }
     else
     {
         UVArray = null;
     }
 }
Example #2
0
        public void SetTexScale(double scale, FEWorld world)
        {
            TexScale = scale;

            if (UVArray != null)
            {
                if (!world.IsFieldValueId(ValueId))
                {
                    return;
                }
                FieldValue fv         = world.GetFieldValue(ValueId);
                uint       quantityId = fv.QuantityId;
                uint       coCnt      = world.GetCoordCount(quantityId);
                for (int coId = 0; coId < coCnt; coId++)
                {
                    double[] c = world.GetCoord(quantityId, coId);
                    UVArray[coId * 2 + 0] = c[0] * TexScale;
                    UVArray[coId * 2 + 1] = c[1] * TexScale;
                }
            }
        }
Example #3
0
        private void Set(uint valueId, FieldDerivativeType valueDt, FEWorld world)
        {
            System.Diagnostics.Debug.Assert(world.IsFieldValueId(valueId));
            ValueId = valueId;
            var mesh = world.Mesh;

            uint dim = world.Dimension;
            {
                if (dim == 2)
                {
                    SutableRotMode = RotMode.RotMode2D;
                }
                else if (dim == 3)
                {
                    SutableRotMode = RotMode.RotMode3D;
                }
            }
            FieldValue fv = world.GetFieldValue(valueId);

            if (fv.Type == FieldValueType.Vector2 || fv.Type == FieldValueType.Vector3)
            {
                Type = VectorFieldDrawerType.Vector;
            }
            else if (fv.Type == FieldValueType.SymmetricTensor2)
            {
                Type = VectorFieldDrawerType.SymmetricTensor2;
            }

            {
                DrawParts.Clear();
                IList <uint> meshIds = mesh.GetIds();
                foreach (uint meshId in meshIds)
                {
                    VectorFieldDrawPart dp = new VectorFieldDrawPart(meshId, world);
                    DrawParts.Add(dp);
                }
            }

            Update(world);
        }
Example #4
0
        private void Set(uint valueId, FieldDerivativeType valueDt, bool isntDisplacementValue,
                         FEWorld world,
                         uint colorValueId, FieldDerivativeType colorValueDt)
        {
            var mesh = world.Mesh;

            if (!world.IsFieldValueId(valueId))
            {
                throw new ArgumentException();
                //return;
            }
            if (world.IsFieldValueId(colorValueId))
            {
                IsColorLegendDraw = true;
            }
            else
            {
                IsColorLegendDraw = false;
            }

            ValueId               = valueId;
            ValueDt               = valueDt;
            ColorValueId          = colorValueId;
            ColorValueDt          = colorValueDt;
            IsntDisplacementValue = isntDisplacementValue;

            var  fv         = world.GetFieldValue(valueId);
            uint quantityId = fv.QuantityId;
            uint dim        = world.Dimension;
            uint ptCnt      = 0;

            if (IsNsvDraw)
            {
                ptCnt = fv.GetPointCount();
                // あとで実装する
                throw new NotImplementedException();
            }
            else
            {
                ptCnt = world.GetCoordCount(quantityId);
            }

            uint drawDim;

            if (!IsntDisplacementValue &&
                dim == 2 &&
                (fv.Type == FieldValueType.Scalar || fv.Type == FieldValueType.ZScalar))
            {
                drawDim = 3;
            }
            else
            {
                drawDim = dim;
            }
            VertexArray.SetSize(ptCnt, drawDim);

            {
                bool isNormal = (NormalArray != null);
                if (NormalArray != null)
                {
                    NormalArray = null;
                }
                if (isNormal)
                {
                    NormalArray = new double[ptCnt * 3];
                }
            }

            {
                bool isUv = (UVArray != null);
                if (UVArray != null)
                {
                    UVArray = null;
                }
                if (isUv)
                {
                    UVArray = new double[ptCnt * 2];
                }
            }

            if (drawDim == 2)
            {
                SutableRotMode = RotMode.RotMode2D;
            }
            else if (dim == 3)
            {
                SutableRotMode = RotMode.RotMode3D;
            }
            else
            {
                SutableRotMode = RotMode.RotMode2DH;
            }

            {
                DrawParts.Clear();
                IList <uint> meshIds = mesh.GetIds();
                foreach (uint meshId in meshIds)
                {
                    if (IsNsvDraw)
                    {
                        // あとで実装する
                        throw new NotImplementedException();
                    }
                    else
                    {
                    }
                    FaceFieldDrawPart dp = new FaceFieldDrawPart(meshId, world, valueId);
                    DrawParts.Add(dp);
                }
            }

            Update(world);
        }
Example #5
0
        public void Update(FEWorld world)
        {
            FieldValue fv         = world.GetFieldValue(ValueId);
            uint       quantityId = fv.QuantityId;
            uint       dim        = world.Dimension;

            uint ptCnt = 0;

            if (IsNsvDraw)
            {
                ptCnt = fv.GetPointCount();
                // あとで実装する
                throw new NotImplementedException();
            }
            else
            {
                ptCnt = world.GetCoordCount(quantityId);
            }
            System.Diagnostics.Debug.Assert(VertexArray.PointCount == ptCnt);

            if (!IsntDisplacementValue)
            {
                // 変位を伴う場合

                if (dim == 2 &&
                    (fv.Type == FieldValueType.Scalar || fv.Type == FieldValueType.ZScalar))
                {
                    // 垂直方向の変位として捉える

                    System.Diagnostics.Debug.Assert(VertexArray.Dimension == 3);
                    for (int coId = 0; coId < ptCnt; coId++)
                    {
                        double[]            coord = world.GetCoord(quantityId, coId);
                        FieldDerivativeType dt    = ValueDt;
                        double value = fv.GetShowValue(coId, 0, dt);
                        VertexArray.VertexCoordArray[coId * 3 + 0] = coord[0];
                        VertexArray.VertexCoordArray[coId * 3 + 1] = coord[1];
                        VertexArray.VertexCoordArray[coId * 3 + 2] = value;
                    }
                }
                else
                {
                    System.Diagnostics.Debug.Assert(VertexArray.Dimension == dim);
                    for (int coId = 0; coId < ptCnt; coId++)
                    {
                        double[]            coord = world.GetCoord(quantityId, coId);
                        FieldDerivativeType dt    = ValueDt;
                        for (int iDim = 0; iDim < dim; iDim++)
                        {
                            double value = fv.GetShowValue(coId, iDim, dt);
                            VertexArray.VertexCoordArray[coId * dim + iDim] = coord[iDim] + value;
                        }
                    }
                }
            }
            else
            {
                System.Diagnostics.Debug.Assert(VertexArray.Dimension == dim);
                for (int coId = 0; coId < ptCnt; coId++)
                {
                    double[] coord = world.GetCoord(quantityId, coId);
                    for (int iDim = 0; iDim < dim; iDim++)
                    {
                        VertexArray.VertexCoordArray[coId * dim + iDim] = coord[iDim];
                    }
                }
            }

            if (world.IsFieldValueId(ColorValueId))
            {
                FieldValue          colorfv = world.GetFieldValue(ColorValueId);
                FieldDerivativeType dt      = ColorValueDt;
                bool isBubble        = colorfv.IsBubble;
                uint colorQuantityId = colorfv.QuantityId;
                uint colorPtCnt      = world.GetCoordCount(colorQuantityId);
                if (!ColorMap.IsFixedMinMax)
                {
                    double min;
                    double max;

                    colorfv.GetMinMaxShowValue(out min, out max, 0, dt);
                    ColorMap.MinValue = min;
                    ColorMap.MaxValue = max;
                }

                if (!isBubble)
                {
                    // color is assigned to vertex
                    if (ColorArray == null)
                    {
                        ColorArray = new float[colorPtCnt * 4];
                    }
                    for (int coId = 0; coId < colorPtCnt; coId++)
                    {
                        double   value = colorfv.GetShowValue(coId, 0, dt);
                        double[] color = ColorMap.GetColor(value);
                        ColorArray[coId * 4]     = (float)color[0];
                        ColorArray[coId * 4 + 1] = (float)color[1];
                        ColorArray[coId * 4 + 2] = (float)color[2];
                        ColorArray[coId * 4 + 3] = 0.0f;
                    }
                }
                else
                {
                    // color is assigned to face
                    for (int idp = 0; idp < DrawParts.Count; idp++)
                    {
                        FaceFieldDrawPart dp = DrawParts[idp];
                        dp.SetColors(ColorValueId, dt, world, ColorMap);
                    }
                }
            }

            if (NormalArray != null)
            {
                MakeNormal();
            }


            if (UVArray != null)
            {
                for (int coId = 0; coId < ptCnt; coId++)
                {
                    double[] coord = world.GetCoord(quantityId, coId);
                    UVArray[coId * 2 + 0] = coord[0] * TexScale;
                    UVArray[coId * 2 + 1] = coord[1] * TexScale;
                }
            }
        }
Example #6
0
        private void Set(uint valueId, FieldDerivativeType valueDt,
                         bool isntDisplacementValue,
                         bool isDrawInnerEdge,
                         FEWorld world)
        {
            var mesh = world.Mesh;

            if (!world.IsFieldValueId(valueId))
            {
                throw new ArgumentException();
                //return;
            }

            ValueId = valueId;
            ValueDt = valueDt;
            IsntDisplacementValue = isntDisplacementValue;

            var fv = world.GetFieldValue(ValueId);

            // 線要素を生成
            uint quantityId = fv.QuantityId;

            if (isDrawInnerEdge)
            {
                // 内部の全ての辺を描画
                LineFEs = world.MakeBoundOfElements(quantityId);
            }
            else
            {
                // 境界の辺だけ描画
                LineFEs = new List <LineFE>();
                IList <MeshBarArray> barArrays = mesh.GetBarArrays();
                foreach (MeshBarArray barArray in barArrays)
                {
                    uint        eCadId   = barArray.ECadId;
                    IList <int> allCoIds = world.GetCoordIdsFromCadId(quantityId, eCadId, CadElementType.Edge);

                    for (int i = 0; i < (allCoIds.Count - 1); i++)
                    {
                        int    workFEOrder = 1;
                        LineFE lineFE      = new LineFE(workFEOrder);
                        {
                            int[] coIds = { allCoIds[i], allCoIds[i + 1] };
                            lineFE.SetVertexCoordIds(coIds);
                            lineFE.SetNodeCoordIds(coIds);
                        }
                        LineFEs.Add(lineFE);
                    }
                }
            }

            int feOrder;
            {
                LineFE lineFE = LineFEs[0]; // 先頭の要素
                feOrder     = lineFE.Order;
                LinePtCount = lineFE.NodeCount;
            }

            uint ptCnt = LineCount * LinePtCount;
            uint dim   = world.Dimension;

            uint drawDim;

            if (!IsntDisplacementValue &&
                dim == 2 &&
                (fv.Type == FieldValueType.Scalar || fv.Type == FieldValueType.ZScalar))
            {
                drawDim = 3;
            }
            else
            {
                drawDim = dim;
            }
            VertexArray.SetSize(ptCnt, drawDim);

            if (drawDim == 2)
            {
                SutableRotMode = RotMode.RotMode2D;
            }
            else if (dim == 3)
            {
                SutableRotMode = RotMode.RotMode3D;
            }
            else
            {
                SutableRotMode = RotMode.RotMode2DH;
            }


            Update(world);
        }