Exemplo n.º 1
0
        public CG_PointData RemoveFields(List <string> notFoundFields)
        {
            int newCount = Fields.Count - notFoundFields.Count;

            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), newCount, PointCount), new List <string>(), Type);

            int    counter = 0;
            string field;

            bool[] contains = new bool[Fields.Count];
            for (int h = 0; h < Fields.Count; h++)
            {
                field       = Fields[h];
                contains[h] = notFoundFields.Contains(field);
                if (!contains[h])
                {
                    modified.Fields.Add(field);
                }
            }

            for (int i = 0; i < PointCount; i++)
            {
                counter = 0;
                for (int j = 0; j < Fields.Count; j++)
                {
                    if (!contains[j])
                    {
                        modified.InternalValues.SetValue(InternalValues.GetValue(j, i), counter, i);
                        counter++;
                    }
                }
            }

            return(modified);
        }
Exemplo n.º 2
0
        public CG_PointData PutValue(double Value, List <string> inFields, bool ExceptGivenFields)
        {
            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), Fields.Count, PointCount), new List <string>(), Type);

            for (int i = 0; i < Fields.Count; i++)
            {
                modified.Fields.Add(Fields[i]);
                if (inFields != null && inFields.Count > 0)
                {
                    if (inFields.Contains(Fields[i]) == !ExceptGivenFields)
                    {
                        for (int j = 0; j < PointCount; j++)
                        {
                            modified.InternalValues.SetValue(Value, i, j);
                        }
                    }
                    else
                    {
                        for (int j = 0; j < PointCount; j++)
                        {
                            modified.InternalValues.SetValue(InternalValues.GetValue(i, j), i, j);
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < PointCount; j++)
                    {
                        modified.InternalValues.SetValue(Value, i, j);
                    }
                }
            }

            return(modified);
        }
Exemplo n.º 3
0
        public CG_PointData LevelValues(double inValue, double Tolerance)
        {
            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), Fields.Count, PointCount), new List <string>(), Type);
            bool         changed  = false;

            for (int i = 0; i < Fields.Count; i++)
            {
                modified.Fields.Add(Fields[i]);

                for (int j = 0; j < PointCount; j++)
                {
                    if (TypesHelper.DoubleIsFuzzyEqual((double)InternalValues.GetValue(i, j), inValue, Tolerance))
                    {
                        modified.InternalValues.SetValue(0.0, i, j);
                        changed = true;
                    }
                    else
                    {
                        modified.InternalValues.SetValue((double)InternalValues.GetValue(i, j), i, j);
                    }
                }
            }

            return(changed ? modified : this);
        }
 public void SetObjectData(string AccessName, string Name, CG_PointData pointData)
 {
     foreach (CG_GeometryData geo in GeometriesData)
     {
         if (geo.Geometry.Name == Name)
         {
             geo.Data.Clear();
             geo.Data.Add(pointData);
             break;
         }
     }
 }
Exemplo n.º 5
0
        public void Update(CG_PointData curData)
        {
            int index;

            for (int i = 0; i < Fields.Count; i++)
            {
                index = curData.Fields.IndexOf(Fields[i]);

                if (index != -1)
                {
                    for (int j = 0; j < PointCount; j++)
                    {
                        InternalValues.SetValue(curData.InternalValues.GetValue(index, j), i, j);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public bool isFieldsCompatible(CG_PointData inData)
        {
            if (Fields.Count == inData.Fields.Count)
            {
                foreach (string field in inData.Fields)
                {
                    if (!Fields.Contains(field))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public CG_PointData FilterFields(List <string> deformers)
        {
            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), deformers.Count, PointCount), new List <string>(), Type);

            //Get deformers
            List <string> notFoundFields = new List <string>();

            //ignore deformers that don't exist in ref deformers
            int counter = 0;

            foreach (string defName in Fields)
            {
                if (deformers.Contains(defName))
                {
                    modified.Fields.Add(defName);
                    for (int j = 0; j < PointCount; j++)
                    {
                        modified.InternalValues.SetValue(InternalValues.GetValue(counter, j), modified.Fields.Count - 1, j);
                    }
                }

                counter++;
            }

            //Add deformers that don't exist in old deformers
            foreach (string defName in deformers)
            {
                if (!modified.Fields.Contains(defName))
                {
                    modified.Fields.Add(defName);
                    for (int j = 0; j < PointCount; j++)
                    {
                        modified.InternalValues.SetValue(0.0, modified.Fields.Count - 1, j);
                    }
                }
            }

            return(modified);
        }
Exemplo n.º 8
0
        public CG_PointData Blend(CG_PointData Merged, double Opacity, List <int> indices)
        {
            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), Fields.Count, PointCount), new List <string>(), Type);

            for (int i = 0; i < Fields.Count; i++)
            {
                modified.Fields.Add(Fields[i]);

                for (int j = 0; j < PointCount; j++)
                {
                    if (indices == null || indices.Count == 0 || indices.Contains(j))
                    {
                        modified.InternalValues.SetValue((double)InternalValues.GetValue(i, j) * (1 - Opacity) + (double)Merged.InternalValues.GetValue(i, j) * Opacity, i, j);
                    }
                    else
                    {
                        modified.InternalValues.SetValue((double)InternalValues.GetValue(i, j), i, j);
                    }
                }
            }

            return(modified);
        }
Exemplo n.º 9
0
        public CG_PointData ShareFields(CG_PointData inData)
        {
            //Create a full list of Fields
            List <string> fields = Fields;
            Dictionary <string, object[]> belongs = new Dictionary <string, object[]>();

            int counter = 0;

            foreach (string str in inData.Fields)
            {
                if (!fields.Contains(str))
                {
                    fields.Add(str);
                    belongs.Add(str, new object[] { inData, counter });
                }
                else
                {
                    belongs.Add(str, new object[] { this, fields.IndexOf(str) });
                }
                counter++;
            }

            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), fields.Count, PointCount), fields, Type);

            for (int i = 0; i < fields.Count; i++)
            {
                object[]     fieldInfos = belongs[fields[i]];
                CG_PointData owner      = fieldInfos[0] as CG_PointData;

                for (int j = 0; j < PointCount; j++)
                {
                    modified.InternalValues.SetValue(owner.InternalValues.GetValue((int)fieldInfos[1], j), i, j);
                }
            }

            return(modified);
        }
Exemplo n.º 10
0
        public CG_PointData TransposeFields(List <string> inFields)
        {
            CG_PointData modified = new CG_PointData(Array.CreateInstance(typeof(object), inFields.Count, PointCount), new List <string>(), Type);

            int index;

            for (int i = 0; i < inFields.Count; i++)
            {
                modified.Fields.Add(inFields[i]);
                index = Fields.IndexOf(inFields[i]);

                if (index == -1)
                {
                    index = i;
                }

                for (int j = 0; j < PointCount; j++)
                {
                    modified.InternalValues.SetValue(InternalValues.GetValue(i, j), index, j);
                }
            }

            return(modified);
        }
Exemplo n.º 11
0
 public CG_PointData Blend(CG_PointData inData, double Opacity)
 {
     return(Blend(inData, Opacity, null));
 }
Exemplo n.º 12
0
 public bool isCompatible(CG_PointData inData)
 {
     return(isPointsCompatible(inData) && isFieldsCompatible(inData));
 }
Exemplo n.º 13
0
        //Compatibility Methods

        public bool isPointsCompatible(CG_PointData inData)
        {
            return(inData.PointCount == PointCount);
        }