예제 #1
0
        /// <summary>
        /// ctor for reading curves from cof file
        /// </summary>
        /// <param name="bin">the cof file</param>
        /// <param name="sail">the sail to map to</param>
        public MouldCurve(System.IO.BinaryReader bin, Sail sail)
        {
            m_sail = sail;
            m_locked = true;
            //read label
            m_label = Utilities.ReadCString(bin);

            //read fit point positions
            int nPos = bin.ReadInt32();
            List<FixedPoint> pts = new List<FixedPoint>(nPos);
            for (int nP = 0; nP < nPos; nP++)
                pts.Add(new FixedPoint(bin.ReadDouble(), 0, 0));

            FitPoints = pts.ToArray();
            m_bGirths = new bool[pts.Count - 1];//spline all segments
            //read the spline
            m_bSpline.ReadBin(bin);

            //set the fixedpoints uv coords from the positions and spline
            double[] uv = new double[2];
            for (int nP = 0; nP < nPos; nP++)
            {
                Spline.BsVal(this[nP][0], ref uv);
                this[nP][1] = uv[0];
                this[nP][2] = uv[1];
            }
        }
예제 #2
0
 public MouldCurve(string label, Sail sail, IFitPoint[] fits)
 {
     m_sail = sail;
     m_label = label;
     if (fits != null)
         Fit(fits);
 }
예제 #3
0
 public EquationEditorForm(VariableGroup group)
 {
     InitializeComponent();
     m_group = group;
     m_sail = group.Sail;
     if (m_sail != null)
     {
         List<object> autoComplete = m_sail.GetAutoFillData(group);
         List<MouldCurve> curves = m_sail.GetCurves(group);
         //curves.ForEach(cur => { autoComplete.Add(cur); });
         curves.ForEach(curve => CurveListBox.Items.Add(curve));
         availableEqs = m_sail.GetEquations(m_group);
         EquationListBox.Items.Clear();
         foreach (KeyValuePair<string, Equation> entry in availableEqs)
         {
             //autoComplete.Add(entry.Value);
             EquationListBox.Items.Add(entry.Key);
             listView1.Items.Add(entry.Key);
             if (!m_group.ContainsKey(entry.Key))
                 listView1.Items[listView1.Items.Count - 1].Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Italic);
             //else
             //	listView1.Items[listView1.Items.Count - 1].BackColor = Color.White;
             //	EquationListBox.Items[EquationListBox.Items.Count-1]
         }
         autoCompleteTextBox1.Values = autoComplete.ToArray();
     }
 }
예제 #4
0
 public EquationEditorForm(VariableGroup group)
 {
     InitializeComponent();
     m_group = group;
     m_sail = group.Sail;
     if (m_sail != null)
     {
         List<IRebuild> watermark = m_sail.Watermark(group);
         //availableEqs = new List<Equation>();
         CurveListBox.Items.Clear();
         EquationListBox.Items.Clear();
         listView1.Items.Clear();
         foreach (IRebuild entry in watermark)
         {
             if (entry is Equation)
             {
             //	availableEqs.Add(entry as Equation);
                 EquationListBox.Items.Add(entry.Label);
                 listView1.Items.Add(entry.Label);
                 if (!m_group.ContainsKey(entry.Label))
                     listView1.Items[listView1.Items.Count - 1].Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Italic);
             }
             else if( entry is MouldCurve )
                 CurveListBox.Items.Add(entry as MouldCurve);
         }
         autoCompleteTextBox1.Values = watermark.ToArray<object>();
     }
 }
예제 #5
0
파일: RBFMould.cs 프로젝트: GabeTesta/Warps
 public void ReadCofFile(Sail sail, string cofpath)
 {
     CofMould cof = new CofMould(sail, cofpath);
     m_label = "RBF" + cof.Label;
     m_path = cof.CofPath;
     Fit(cof);
     m_Groups = cof.Groups;
 }
예제 #6
0
 /// <summary>
 /// creates a new guidecomb optionally fit to the specified points and combheights
 /// </summary>
 /// <param name="label">the name of the curve</param>
 /// <param name="sail">the sail the curve is on</param>
 /// <param name="fits">optional array of fitpoints, geodesic if 2, otherwise spline</param>
 /// <param name="combs">optonal array of comb heights, minimum 5</param>
 public GuideComb(string label, Sail sail, IFitPoint[] fits, Vect2[] combs)
     : base(label, sail, fits)
 {
     if (fits != null)
         Fit(fits);
     if (combs != null)
         FitComb(combs);
 }
예제 #7
0
 public bool ReadScript(Sail sail, IList<string> txt)
 {
     if (txt.Count == 0)
         return false;
     string line = ScriptTools.ReadLabel(txt[0]);
     if (line != null)
     {
         ReadCofFile(sail, line);
         return true;
     }
     return false;
 }
예제 #8
0
        public static bool Evaluate(Equation equation, Sail sail, out double result, bool showBox)
        {
            if (equation == null)
            {
                result = 0;
                return false;
            }

            bool worked = false;

            Expression ex = new Expression(equation.EquationText, EvaluateOptions.IgnoreCase);

            List<Equation> avails = sail.WatermarkEqs(equation);
            avails.ForEach(eq => ex.Parameters[eq.Label] = eq.Result);
            //Set up a custom delegate so NCalc will ask you for a parameter's value
            //   when it first comes across a variable

            ex.EvaluateFunction += delegate(string FunctionName, FunctionArgs args)
            {
                args.Result = EvaluateToDouble(args.Parameters[0].ParsedExpression.ToString(), FunctionName.ToLower(), sail);
            };

            try
            {
                result = Convert.ToDouble(ex.Evaluate());
                equation.SetResult(result);
                worked = true;
            }
            catch (Exception exx)
            {
                worked = double.TryParse(equation.EquationText, out result);
                equation.SetResult(result);
                Warps.Logger.logger.Instance.LogErrorException(exx);
            }
            finally
            {
                if (!worked)
                {
                    if (showBox)
                        System.Windows.Forms.MessageBox.Show("Error parsing equation");
                    result = double.NaN;
                }
            }

            return worked;
        }
예제 #9
0
        public static List<MouldCurve> ExtractCurves(string eq, Sail sail)
        {
            List<MouldCurve> param = new List<MouldCurve>();
            Expression ex = new Expression(eq);

            ex.EvaluateFunction += delegate(string name, FunctionArgs args)
            {
                if (name == "Length")
                    param.Add(sail.FindCurve(args.Parameters[0].ToString()));
                args.Result = 1;
            };

            ex.EvaluateParameter += delegate(string name, ParameterArgs args)
            {
                param.AddRange(ExtractCurves(name, sail));
                args.Result = 1;
            };

            ex.Evaluate();
            return param;
        }
예제 #10
0
파일: CofMould.cs 프로젝트: GabeTesta/Warps
        void ReadBinCurves(BinaryReader bin, Sail sail)
        {
            //read 3d curve count
            int iC = bin.ReadInt32();
            m_rigcurves = new List<RigLine>(iC);
            //read curves from bin file
            for (int nC = 0; nC < iC; nC++)
                m_rigcurves.Add(new RigLine(bin));

            //read group count
            iC = bin.ReadInt32();
            m_moucurves = new List<IGroup>(iC);
            //read curvegroups from bin file
            for (int nC = 0; nC < iC; nC++)
                m_moucurves.Add(new CurveGroup(bin, sail));
        }
예제 #11
0
파일: CofMould.cs 프로젝트: GabeTesta/Warps
        public void ReadCofFile(Sail sail, string cofPath)
        {
            if( cofPath != null )
                m_cofPath = cofPath;

            if (Path.GetExtension(m_cofPath).ToLower() == ".cof")
                ReadMFCCofFile(cofPath);
            else
                using (BinaryReader bin = new BinaryReader(File.Open(cofPath, FileMode.Open, FileAccess.Read), Encoding.ASCII))
                {
                    m_text = Utilities.ReadCString(bin);

                    ReadBinShape(bin);

                    ReadBinCurves(bin, sail);
                }
        }
예제 #12
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
        internal void ToggleLayer(Sail sail)
        {
            this[0].Layers[1].Visible = !this[0].Layers[1].Visible;
            this[1].Layers[1].Visible = !this[1].Layers[1].Visible;

            Refresh();
        }
예제 #13
0
파일: CofMould.cs 프로젝트: GabeTesta/Warps
 public CofMould(Sail sail, string cofPath)
 {
     //ReadMFCCofFile(cofPath);
     ReadCofFile(sail, cofPath);
 }
예제 #14
0
 public bool Update(Sail s)
 {
     bool ret = true;
     ret &= !double.IsNaN(U.Evaluate(s));// != Double.NaN;
     ret &= !double.IsNaN(V.Evaluate(s));
     return ret;
 }
예제 #15
0
        public virtual bool ReadScript(Sail sail, IList<string> txt)
        {
            if (txt == null || txt.Count == 0)
                return false;

            List<IFitPoint> fits = new List<IFitPoint>();
            string[] splits = txt[0].Split(':');
            Label = "";
            if (splits.Length > 0)//extract label
                Label = splits[1];
            if (splits.Length > 1)//incase label contains ":"
                for (int i = 2; i < splits.Length; i++)
                    Label += ":" + splits[i];
            Label = Label.Trim();

            string header;
            for (int nLine = 1; nLine < txt.Count; )
            {
                IList<string> lines = ScriptTools.Block(ref nLine, txt);
                //nLine += lines.Count;

                object cur = null;
                splits = lines[0].Split(':');

                if (splits.Length > 0)
                    header = splits[0].Trim('\t');
                else header = "";

                if (header == "Girth Segments")
                {
                    ReadGirthsScript(lines);

                }
                else//fit points
                {
                    cur = Utilities.CreateInstance(header);
                    if (cur != null && cur is IFitPoint)
                    {
                        (cur as IFitPoint).ReadScript(Sail, lines);
                        fits.Add(cur as IFitPoint);
                    }
                }
            }
            FitPoints = fits.ToArray();

            if (AllFitPointsValid())
                ReFit();

            return true;
        }
예제 #16
0
 public void ReadCofFile(Sail sail, string cofpath)
 {
     m_mould = new CofMould(sail, cofpath);
     m_extension = new RBFMould(m_mould);
     m_label = "Combo" + Mould.Label;
 }
예제 #17
0
        public void GetParents(Sail s, List<IRebuild> parents)
        {
            //parents.Add(m_uEqu);
            m_uEqu.GetParents(s, parents);

            //parents.Add(m_vEqu);
            m_vEqu.GetParents(s, parents);
        }
예제 #18
0
        void LoadSail(string path)
        {
            Status = String.Format("Loading {0}", path);

            Sail s = new Sail();

            s.ReadFile(path);

            m_sail = s;
            //if (s.Layout == null || s.Layout.Count == 0)
            //	CreateOuterCurves(s);
            //else

            m_tree.Add(s.WriteNode());

            AddSailtoView(s);

            Tree.ExpandToDepth(0);

            //EquationEditor.Instance.SetSail(s);

            //s.Rebuild(null);
            Status = String.Format("{0} Loaded Successfully", path);
        }
예제 #19
0
        private static double EvaluteKeyWordOnCurve(string KeyWord, string curveName, Sail sail)
        {
            switch (KeyWord)
            {
                case "length":

                    MouldCurve curve = sail.FindCurve(curveName);
                    if (curve == null)
                        return double.NaN;

                    return curve.Length;

                default:

                    return double.NaN;
            }
        }
예제 #20
0
 private void clearAll_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MessageBox.Show("Are you sure you want to clear all?", String.Format("Warps v{0}", Utilities.CurVersion), MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
     {
         Tree.ClearAll();
         View.ClearAll();
         m_sail.Layout.Clear();
         m_sail = null;
         EditorPanel = null;
     }
 }
예제 #21
0
        private void AddSailtoView(Sail s)
        {
            int nlayer = View.AddLayer("Mould", Color.Beige, true);
            s.Mould.CreateEntities(null, false).ForEach(ent => { ent.LayerIndex = nlayer; View.Add(ent); });

            nlayer = View.AddLayer("Gauss", Color.Beige, false);
            s.Mould.CreateEntities(new double[,] { { -.2, 1.2 }, { -.2, 1.2 } }, true).ForEach(ent => { ent.LayerIndex = nlayer; View.Add(ent); });

            //add the groups attached to the sail file if any
            if (s.Mould.Groups != null)
                s.Mould.Groups.ForEach(group => UpdateViews(group));

            s.Layout.ForEach(group => UpdateViews(group));

            View.ZoomFit(true);
        }
예제 #22
0
        public bool Update(Sail s)
        {
            foreach (IFitPoint fp in FitPoints)
                fp.Update(s);

            if (AllFitPointsValid())
                ReFit();
            return AllFitPointsValid();
        }
예제 #23
0
        public override bool ReadScript(Sail sail, IList<string> txt)
        {
            if (txt == null || txt.Count == 0)
                return false;

            List<IFitPoint> fits = new List<IFitPoint>();
            string[] splits = txt[0].Split(':');
            Label = "";
            if (splits.Length > 0)//extract label
                Label = splits[1];
            if (splits.Length > 1)//incase label contains ":"
                for (int i = 2; i < splits.Length; i++)
                    Label += ":" + splits[i];
            Label = Label.Trim();

            for (int nLine = 1; nLine < txt.Count; )
            {
                IList<string> lines = ScriptTools.Block(ref nLine, txt);
                //nLine += lines.Count;

                object cur = null;
                splits = lines[0].Split(':');
                if (splits.Length > 0)
                    cur = Utilities.CreateInstance(splits[0].Trim('\t'));
                if (cur != null && cur is IFitPoint)
                {
                    (cur as IFitPoint).ReadScript(Sail, lines);
                    fits.Add(cur as IFitPoint);
                }
                else if (cur != null && cur is Vect2)
                {
                    m_combPnts.Add(ParseVect2Lines(lines));
                }
            }
            FitPoints = fits.ToArray();

            FitComb(m_combPnts.ToArray());

            if (AllFitPointsValid())
                ReFit();

            return true;
        }
예제 #24
0
 public MouldCurve(MouldCurve curve)
 {
     m_sail = curve.Sail;
     m_label = curve.Label;
     Fit(curve);
 }
예제 #25
0
 public void GetParents(Sail s, List<IRebuild> parents)
 {
     if (FitPoints != null)
         foreach (IFitPoint fp in FitPoints)
             fp.GetParents(s, parents);
 }
예제 #26
0
 public CurveMaker(WarpFrame frame, Sail s)
 {
     m_frame = frame;
     m_sail = s;
     m_edit = new CurveImportEditor(this);
 }
예제 #27
0
        public bool ReadScript(Sail sail, IList<string> txt)
        {
            if (txt.Count != 3)
                return false;

            txt[1] = txt[1].Trim('\t');
            txt[2] = txt[2].Trim('\t');
            string[] split = txt[1].Split(new char[] { ':' });
            U = new Equation(split[0],split[1]);
            split = txt[2].Split(new char[] { ':' });
            V = new Equation(split[0], split[1]);
            return Update(sail);
        }
예제 #28
0
        private static double EvaluteKeyWordOnCurve(string KeyWord, string curveName, Sail sail, ref List<MouldCurve> curves)
        {
            switch (KeyWord)
            {
                case "length":

                    MouldCurve curve = sail.FindCurve(curveName);

                    if (curve == null)
                        return double.NaN;

                    if (!curves.Contains(curve))
                        curves.Add(curve);

                    return curve.Length;

                default:

                    return double.NaN;
            }
        }
예제 #29
0
 public ComboMould(Sail sail, string cofpath)
 {
     ReadCofFile(sail, cofpath);
 }
예제 #30
0
 public static bool Evaluate(Equation labelToEvaluate, Sail sail, out double result)
 {
     return Evaluate(labelToEvaluate, sail, out result, false);
 }