/// <summary>
        /// Make a femm model using parameters
        /// This will check if file existed and use parameters the same to this one or not.
        /// If not, build new one
        /// </summary>
        /// <param name="outfile">Output femm model</param>
        /// <param name="original">The original femm model to insert into</param>
        /// <param name="forcebuild">True if build even file existed</param>
        /// <returns>0-OK,1-File existed, analyzed,-1-ERROR</returns>
        public virtual void BuildFEMModel(String outfile, FEMM femm = null)
        {
            // make sure coordinates were calculated
            if (!isPointsCoordCalculated)
            {
                throw new InvalidOperationException("Points must be calculated before make FEM model.");
            }

            if (femm == null)
            {
                femm = FEMM.DefaultFEMM;
            }

            femm.newdocument(FEMM.DocumentType.Magnetic);

            // setup problems params
            femm.mi_probdef(0, FEMM.UnitsType.millimeters, FEMM.ProblemType.planar, 1e-8, GeneralParams.MotorLength, 7, FEMM.ACSolverType.Succ_Approx);

            // build a rotor in femm
            Rotor.BuildInFEMM(femm);

            // build a stator in femm
            Stator.BuildInFEMM(femm);

            // build airgap (put label)
            Airgap.BuildInFEMM(femm);

            // clear selected, refresh, and go to natural zoom
            femm.mi_clearselected();
            femm.mi_zoomnatural();

            femm.mi_saveas(outfile);

            femm.mi_close();

            // write md5 to it
            FEMM.mi_modifyFEMMComment(outfile, GetMD5String());
        }