コード例 #1
0
    public override void OnInspectorGUI()
    {
        Refiner refiner = (Refiner)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Collect Logs"))
        {
            refiner.RefineLogs();
        }
    }
コード例 #2
0
            static internal bool TryRefineInternal(APC pc, BoxedExpression goal, bool tryRefineToMethodEntry, IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions> mdriver, out BoxedExpression result)
            {
                var refiner = new Refiner(pc, mdriver);

                var visitDept = 0;

                bool isVisitAborted;

                result = refiner.Refine(pc, goal, tryRefineToMethodEntry, ref visitDept, out isVisitAborted);

                Log("Result of the refinement {0}", result != null ? result.ToString() : "<null>");

                return(result != null);
            }
コード例 #3
0
        void refin(List <Vec3> vert, List <int> faceGr, List <Vector2> uv, AdaptiveOptionsCs option)
        {
            Init( );

            using (var refi = new Refiner(vert, faceGr, 3))
            {
                refi.AddChannel(new FVarChannelCs(faceGr, uv.Count));
                for (int i = 0; i < uv.Count; i++)
                {
                    refi.SetUV(uv[i].X, uv[i].Y);
                }
                refi.AddOption(option);
                refi.OnFace = OnFace;
                refi.OnUV   = OnUV;
                refi.OnVert = OnVert;
                refi.DoRefine( );
            }
        }
コード例 #4
0
ファイル: uc_searchResults.ascx.cs プロジェクト: WongMW/Demo
        /// <summary>
        /// Bind the Refinement Items with their values and counts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptRefinement_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            // Find the child refinement items repeater
            Repeater rptRefinementItems = (Repeater)e.Item.FindControl("rptRefinementItems");

            try
            {
                // Get the refinement items list and bind it to the repeater
                Refiner            refinerList     = (Refiner)e.Item.DataItem;
                List <RefinerItem> refinementItems = refinerList.RefinementItems;
                rptRefinementItems.DataSource = refinementItems;
                rptRefinementItems.DataBind();
            }
            catch (Exception ex)
            {
                Helper.LogApplicationLevelException("uc_searchResults", "rptRefinement_ItemDataBound", ex);
            }
        }
コード例 #5
0
        /// <summary>
        /// Performs refinement on the given file in order for same quality
        /// shapes present in the library.
        /// <para>
        /// The refinement process works as follows:
        /// <list type="number">
        ///		<item><description>
        ///			First of the shape will be moved to a temporary directory where
        ///			all the refinement operations will be performed.
        ///		</description></item>
        ///		<item><description>
        ///			Next the shape will be refined one step at a time for a maximum
        ///			of <see cref="Settings.MaxRefineIterations"/> attempts. If the
        ///			shapes is not refined at so many attempts then it is assumed
        ///			that the shape can not be fixed.
        ///		</description></item>
        ///		<item><description>
        ///			Lastly the shape will be moved to a specified directory depending
        ///			on the success of the refinement operation. If the shape was
        ///			successfully refined then it will be move to the
        ///			<paramref name="successMap"/>, if it could not be refined then
        ///			instead it will be moved to the <paramref name="failureMap"/>.
        ///			If one of these maps is not specified then it will be placed
        ///			back into its original folder and will stil be loaded in by the
        ///			application.
        ///		</description></item>
        /// </list>
        /// </para>
        /// </summary>
        /// <param name="file">Information about the file which needs to be refined.
        /// The file will be modified in the process of refining the shape and the
        /// original file will be lost.</param>
        /// <param name="successMap">The directory where the shape should be
        /// moved to after a successful refinement.</param>
        /// <param name="failureMap">The directory where the shape should be
        /// moved to after it could no longer be refined for further analysis.</param>
        private void Refine(ref FileInfo file,
                            string successMap = null,
                            string failureMap = null)
        {
            if (file == null || !file.Exists)
            {
                throw new ArgumentNullException(nameof(file));
            }

            // Remember the original map for later.
            string originalMap = file.Directory.Parent.FullName;

            // All modifications happen in the temp map.
            MoveFile(ref file, Settings.ShapeTempDir);

            // Refine it a maximum of X amounts of time.
            int attempts = Settings.MaxRefineIterations;

            while (!Refiner.RefineFile(file) && --attempts >= 0)
            {
                ;
            }

            // If it is refined then we add it to the final map.
            // If it is not refined then we add it to the failed map.
            if (attempts < 0 && failureMap != null)
            {
                MoveFile(ref file, failureMap);
            }
            else if (attempts >= 0 && successMap != null)
            {
                MoveFile(ref file, successMap);
            }
            else
            {
                MoveFile(ref file, originalMap);
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
#if true
            RefineMMD      refine = new RefineMMD();
            var            path   = "debugRect.pmx";//ex.pmx";
            OpenFileDialog dialog = new OpenFileDialog( );
            dialog.Filter = ".pmx|*.pmx";
            if (dialog.ShowDialog( ) == DialogResult.OK)
            {
                path = dialog.FileName;
            }
            refine.DebugRect(path);
            //RefineMMD debugRef = new RefineMMD( );
            //debugRef.DebugRect( path + "ex.pmx" );
#else
            var      exePath = AppDomain.CurrentDomain.BaseDirectory;
            var      path    = @"miku.csv";
            string[] lines   = File.ReadAllLines(path);
            //;Face,親材質名,面Index,頂点Index1,頂点Index2,頂点Index3
            //Face,"スカート腕ヘドフォン",0,858,840,855
            // のように最初の文字列がVertexだと頂点 Faceだと面になる ;が最初に来るものは説明用のものなので弾く
            var gr = lines.GroupBy(l => l.Split(',')[0]);
            var gs = gr.Where(g => !g.Key.Contains(";")).ToDictionary(s => s.Key, g => g.ToList( ));

            var Vertice = ParseCSV(gs["Vertex"]).ToList( );
            var faceGr  =            //.GroupBy( s => s.Split( ',' )[ 1 ] ).ToDictionary( s => s.Key , g => g.ToList( ) );
                          Util.ParseFaceCSVAll(gs["Face"]).SelectMany(x => x).ToList();

            var verts = new List <Vec3> {
                new Vec3(-0.5f, -0.5f, 0.5f),
                new Vec3(0.5f, -0.5f, 0.5f),
                new Vec3(-0.5f, 0.5f, 0.5f),
                new Vec3(0.5f, 0.5f, 0.5f),
                new Vec3(-0.5f, 0.5f, -0.5f),
                new Vec3(0.5f, 0.5f, -0.5f),
                new Vec3(-0.5f, -0.5f, -0.5f),
                new Vec3(0.5f, -0.5f, -0.5f),
            };

            var faces = new List <int>
            {
                0, 1, 3, 2,
                2, 3, 5, 4,
                4, 5, 7, 6,
                6, 7, 1, 0,
                1, 7, 5, 3,
                6, 0, 2, 4
            };

            var option = new AdaptiveOptionsCs(1);
            option.UseInfSharpPatch     = true;
            option.UseSingleCreasePatch = true;
            // far_tutorial_6 がパラメトリックにずらす
            // far_tutorial_3 uvなど
            using (var refi = new Refiner(Vertice, faceGr, 3))
            {
                refi.AddOption(option);
                refi.DoRefine( );
            }
#endif
        }
コード例 #7
0
 private void UpdateDisplayData()
 {
     if (sys != null && bar != null)
     {
         //*****************************
         //Code to handle the data types
         //*****************************
         ShipManagment.value_data res = sys.Get_Data(data_type);
         bar.maxValue = res.max_value;
         bar.value    = res.value;
     }
     else if (data_type == Enums.enum_system_info.flight_assist)
     {
         //*************
         //Flight assist
         //*************
         if (ship_movment.flight_assist == 1)
         {
             sr.enabled = true;
             sr.color   = Color.white;
         }
         else if (ship_movment.flight_assist == 2)
         {
             sr.enabled = true;
             sr.color   = Color.red;
         }
         else
         {
             sr.enabled = false;
         }
     }
     else if (data_type == Enums.enum_system_info.landing_zone)
     {
         //*******************
         //Landing zone assist
         //*******************
         if (ship_movment.is_in_docking_zone == true)
         {
             sr.enabled = true;
         }
         else
         {
             sr.enabled = false;
         }
     }
     else if (data_type == Enums.enum_system_info.refiner)
     {
         //*******
         //Refiner
         //*******
         if (refiner == null)
         {
             GameObject r = GameObject.Find("Refiner(Clone)");
             if (r != null)
             {
                 refiner = r.GetComponent <Refiner>();
             }
         }
         if (refiner != null && bar != null)
         {
             bar.maxValue = refiner.settings.Items_max;
             bar.value    = refiner.Bin_Item_Count();
         }
     }
 }
コード例 #8
0
ファイル: PerformSearch.cs プロジェクト: WongMW/Demo
        // GET: Results
        public ResultViewModel SearchIndex()
        {
            // Create some variables to populate later

            // List to store search result items
            var             resultsModel    = new List <ResultsModel>();
            ResultViewModel resultViewModel = new ResultViewModel();

            // instantiate a new query - reads all data from request to build the right values
            QueryModel query = new QueryModel();

            // List of facets to refine by
            List <Refiner> refinerItems = new List <Refiner>();

            // List of facets to refine by
            List <Refiner> alternateItems = new List <Refiner>();

            // List of facets that have been selected in this query (should only ever be one )
            List <RefinerItem> selectedItems = new List <RefinerItem>();

            List <SuggestsModel> suggests = new List <SuggestsModel>();

            // dunno
            ISearchResponse <ResultsModel> results = new SearchResponse <ResultsModel>();

            // storage unit to put search results information for the secondary search
            // Alongside the primary query to generate result hits, we run a second query
            // Purpose is to get counts of the available documents in other indexes, in case
            // the user wants to switch context and search another data source
            // Although its a generic result set, it has zero hits, only refiner facets and counts
            ISearchResponse <ResultsModel> catCountResultSet = new SearchResponse <ResultsModel>();

            try
            {
                // STuff to open connection to elastic
                var node     = new Uri(ElasticsearchUrl);
                var settings = new ConnectionSettings(node);
                var client   = new ElasticClient(settings);

                // get the list of refiners from the control's property
                string[] refinerList = RefinerList.Split(';');

                // The query request includes a refine parameter to choose a category to filter by
                if (query.getRefiner() == null)
                {
                    // Now run the search
                    results = PlainSearch(client, query);
                }
                else
                {
                    // there is a refinement on the query request so pass it through to the next step
                    selectedItems.Add(query.getRefiner());

                    resultViewModel.SelectedRefiners = selectedItems;
                    results = RefinedSearch(client, query);
                }

                catCountResultSet = runCategoryCountSearch(client, query);


                if (results.Hits.Any())
                {
                    // Populate the document hits model and get the highlighted summary
                    foreach (Hit <ResultsModel> hit in results.Hits)
                    {
                        try
                        {
                            ResultsModel resultItem = GetDocumentWithHighlight(hit);
                            string       resultUrl  = "/"; // if we have no hit url, we have a problem. Use this relative URL to site home page

                            //                        if (resultItem.SiteSection != null && String.Equals(resultItem.SiteSection.ToLower(), "website"))
                            if (resultItem.SiteSection != null && resultItem.SiteSection.ToLower().StartsWith("website"))
                            {
                                resultItem.link = hit.Id;  // Sitefinity docs have an ID that needs to be translated to a URL

                                if (resultItem.ContentType != null && string.Equals(resultItem.ContentType, "Telerik.Sitefinity.Libraries.Model.Document"))
                                {
                                    resultUrl = getUrlFromDocumentGUID(Guid.Parse(resultItem.Id));
                                }
                                else if (resultItem.ContentType != null && String.Equals(resultItem.ContentType, "Telerik.Sitefinity.News.Model.NewsItem"))
                                {
                                    resultUrl = getUrlFromNewsItemGUID(Guid.Parse(resultItem.Id));
                                }
                                else if (resultItem.ContentType != null && String.Equals(resultItem.ContentType, "Telerik.Sitefinity.Lists.Model.ListItem"))
                                {
                                    resultUrl = GetListItemURLById(Guid.Parse(resultItem.Id));
                                }
                                else if (resultItem.ContentType != null && String.Equals(resultItem.ContentType, "Telerik.Sitefinity.Pages.Model.PageNode"))
                                {
                                    resultUrl = GetUrlByPageNodeId(Guid.Parse(resultItem.Id), cultInfoEN.ToString(), true);
                                }
                                else if (resultItem.SiteSubsection != null && resultItem.SiteSubsection.ToLower().Equals("products"))
                                {
                                    resultUrl = resultItem.link;
                                }
                            }
                            else if (resultItem.SiteSection != null)
                            {
                                // Other, external web-crawled docs have a URL as their link ??? need to check
                                resultUrl = resultItem.link;
                            }

                            resultItem.ResultUrl = resultUrl;
                            resultItem.is_secure = hit.Source.is_secure;
                            resultItem.indexName = query.getIndexLabel();
                            resultsModel.Add(resultItem);
                        }
                        catch (Exception ex)
                        {
                            //skipping results without resultUrl
                        }
                    }

                    // get the refiners
                    if (results.Aggregations.Count > 0)
                    {
                        string currentRefinerName = null;
                        if (query.getRefiner() != null && query.getRefiner().RefinementName != null)
                        {
                            currentRefinerName = query.getRefiner().RefinementName;
                        }

                        foreach (var refinerItem in results.Aggregations)
                        {
                            // if refiner has already been selected, do not display it
                            if (currentRefinerName == null || !String.Equals(currentRefinerName.ToLower(), refinerItem.Key.ToLower()))
                            {
                                Refiner refiners = new Refiner();

                                refiners.RefinerName = refinerItem.Key.ToUpper();
                                // get the refiners from the search result
                                var aggregates = results.Aggs.Terms(refinerItem.Key).Buckets.ToList();
                                List <RefinerItem> refinementItems = GetRefinerList(aggregates, refinerItem.Key);
                                refiners.RefinementItems = refinementItems;

                                refinerItems.Add(refiners);
                            }
                        }
                    }

                    if (catCountResultSet != null && catCountResultSet.Aggregations.Count > 0)
                    {
                        string currentIndex = query.getIndexName();  // should never be null - all queries must have an index
                        foreach (var alternateIndexItem in catCountResultSet.Aggregations)
                        {
                            // should only be one set of aggregations called "alternate_sources"
                            if (String.Equals(alternateIndexItem.Key.ToLower(), "alternate_sources"))
                            {
                                Refiner            alternates         = new Refiner();
                                var                aggregates         = catCountResultSet.Aggs.Terms(alternateIndexItem.Key).Buckets.ToList();
                                List <RefinerItem> alternateItemsList = GetAlternatesList(aggregates, alternateIndexItem.Key, query.getQueryText());
                                alternates.RefinementItems = alternateItemsList;
                                alternateItems.Add(alternates);
                            }
                        }
                    }



                    // Get the results information
                    resultViewModel.NumHits = (int)results.Total;
                }

                // Get the pagination data
                var pager = new Pager((int)resultViewModel.NumHits, query.getPageNumber());

                resultViewModel.ResultModel       = resultsModel;
                resultViewModel.RefinersModel     = refinerItems;
                resultViewModel.AlternativesModel = alternateItems;
                resultViewModel.Pager             = pager;
                resultViewModel.QueryTerm         = query.getQueryText();
                resultViewModel.indexName         = query.getIndexName();
                resultViewModel.indexDisplayName  = query.getIndexLabel();
                if (query.getIndexLabel().Equals("all content"))
                {
                    resultViewModel.AllIndexesNumHits = (int)results.Total;
                }
                else
                {
                    resultViewModel.AllIndexesNumHits = (int)results.Total + (int)catCountResultSet.Total;
                }


                if (resultViewModel.SelectedRefiners == null)
                {
                    // Should already have assigned this to the result object if the query had a refine parameter
                    // but add it again just in case
                    resultViewModel.SelectedRefiners = selectedItems;
                }

                foreach (string s in GetSpellcheckSuggestions(client, query))
                {
                    SuggestsModel suggest = new SuggestsModel();
                    suggest.SuggestText = s;
                    suggest.SuggestUrl  = "/search-landing?indexCatalogue=_all&searchQuery=" + s;
                    suggests.Add(suggest);
                }

                resultViewModel.SpellSuggestions = suggests;

                return(resultViewModel);
            }
            catch (Exception ex)
            {
                string stack      = ex.StackTrace;
                string ex_message = ex.Message;
                return(resultViewModel);
            }
        }
コード例 #9
0
ファイル: uc_searchResults.ascx.cs プロジェクト: WongMW/Demo
        /// <summary>
        /// Bind the results to the controls
        /// </summary>
        /// <param name="resultViewModel">resultViewModel</param>
        private void BindResults(ResultViewModel resultViewModel)
        {
            string index = Request.QueryString["indexCatalogue"];

            if (resultViewModel.RefinersModel.Count() == 1)
            {
                // We have one facet in the results - lets see how many categories
                Refiner _refiner = resultViewModel.RefinersModel.FirstOrDefault();
                if (_refiner != null)
                {
                    CategoryCount = _refiner.RefinementItems.Count;
                }
            }

            // Number of results from running query over all indexes
            Int32 AllIndexesNumHits = resultViewModel.AllIndexesNumHits;

            // Number of results from running query with filters over a selected index
            Int32 ThisQueryNumHits = resultViewModel.NumHits;

            // There are some hits in at least one of the other non-selected index
            if (AllIndexesNumHits > ThisQueryNumHits)
            {
                AlternateIndexHasHits = true;
            }

            lblPrimarySearchLabel.Text = "You searched for " + resultViewModel.QueryTerm;
            lblPrimaryResultCount.Text = AllIndexesNumHits.ToString() + " results";

            // Build the link to !"Search All Content"
            lnk_SearchAllIndexes.Text        = "Search All Content (" + AllIndexesNumHits.ToString() + ")";
            lnk_SearchAllIndexes.NavigateUrl = "/search-landing?searchQuery=" + resultViewModel.QueryTerm + "&indexCatalogue=_all";


            lnk_RemoveRefine.Text        = resultViewModel.indexDisplayName + " (" + ThisQueryNumHits.ToString() + ")";
            lnk_RemoveRefine.NavigateUrl = "/search-landing?searchQuery=" + resultViewModel.QueryTerm + "&indexCatalogue=_all";

            String hitLabel   = (ThisQueryNumHits > 1) ? "hits" : "hit";
            String indexLabel = (index.Equals("_all")) ? " " + hitLabel + " from all content sources" : " " + hitLabel + " from <span class='result_source result_" + index + "'>" + resultViewModel.indexDisplayName + "</span>";

            lblDetailedResultCount.Text = "Search Results : " + ThisQueryNumHits.ToString() + indexLabel;

            Int32 currentPage = resultViewModel.Pager.CurrentPage;
            Int32 firstHit    = resultViewModel.Pager.PageSize * (resultViewModel.Pager.CurrentPage - 1) + 1;
            Int32 lastHit     = 0;

            if (firstHit + resultViewModel.Pager.PageSize > resultViewModel.NumHits)
            {
                lastHit = resultViewModel.NumHits;
            }
            else
            {
                lastHit = firstHit + resultViewModel.Pager.PageSize - 1;
            }

            if (lastHit == firstHit)
            {
                lblShowingHits.Text = "";
            }
            else
            {
                lblShowingHits.Text = "showing results " + firstHit.ToString() + " to " + lastHit.ToString();
            }

            try
            {
                // Bind the result list to the control
                rptResults.DataSource = resultViewModel.ResultModel;
                rptResults.DataBind();
            }
            catch (Exception ex)
            {
                Helper.LogApplicationLevelException("uc_searchResults", "Bind the result list to the control", ex);
            }

            // Bind the refiner groups list to the control
            if (index.ToLower().Equals("taxsource"))
            {
                try
                {
                    rptRefinement.DataSource = resultViewModel.RefinersModel;
                    rptRefinement.DataBind();
                }
                catch (Exception ex)
                {
                    Helper.LogApplicationLevelException("uc_searchResults", "Bind the refiner groups list to the control (1)", ex);
                }
            }

            try
            {
                // Bind the refiner groups list to the control
                rptAlternateIndex.DataSource = resultViewModel.AlternativesModel;
                rptAlternateIndex.DataBind();
            }
            catch (Exception ex)
            {
                Helper.LogApplicationLevelException("uc_searchResults", "Bind the refiner groups list to the control (2)", ex);
            }

            try
            {
                // Bind selected refiner info
                searchBreadcrumb.DataSource = resultViewModel.SelectedRefiners;
                searchBreadcrumb.DataBind();
            }
            catch (Exception ex)
            {
                Helper.LogApplicationLevelException("uc_searchResults", "Bind selected refiner info", ex);
            }


            // Bind paging information
            BindPagingControl(resultViewModel.Pager);
        }
コード例 #10
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        Enums.enum_resorce_type rt = enum_resorce_type.asset;
        ItemResorce             ir = other.gameObject.GetComponent <ItemResorce>();

        if (ir != null)
        {
            rt = ir.GetResorceType();
        }
        if (rt == enum_resorce_type.material || rt == enum_resorce_type.pickup || rt == enum_resorce_type.blueprint)
        {
            //**********************************
            //We need to see if this is a pickup
            //**********************************
            if (ir != null && ir.Item_type == enum_item.pickup)
            {
                Recipe           item    = ir.Spawn_Any_Module_Upgrade_Material();
                InventoryManager storage = GetComponentInParent <InventoryManager>();
                if (item.resorce_type == enum_resorce_type.material)
                {
                    UnityFunctions.SendAlert(enum_status.Info, "Collected Item: " + item.item_type.ToString());
                    storage.Store_Material(item.item_type);
                    Destroy(other.gameObject);
                }
                else if (item.resorce_type == enum_resorce_type.module)
                {
                    //GameObject refab = Resources.Load(item.prefab_path) as GameObject;
                    GameObject refab = item.preFab;
                    if (refab == null)
                    {
                        UnityFunctions.SendAlert(enum_status.Info, "Null object");
                    }
                    GameObject obj_module = Instantiate(refab, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
                    UnityFunctions.SendAlert(enum_status.Info, "Collected Module: " + obj_module.name.ToString());
                    ModuleSystemInfo ms = obj_module.GetComponent <ModuleSystemInfo>();
                    ms.SetStartHealth();
                    storage.Store_Module(obj_module);
                    Destroy(other.gameObject);
                }
            }
            else
            {
                //************************************************
                //Else must be a material this goes to the refiner
                //************************************************
                refiner = gameObject.transform.parent.GetComponentInChildren <Refiner>();
                if (refiner != null)
                {
                    //Need to be added to the refiner
                    refiner.AddItemToRefiner(other.gameObject);
                    if (ir.GetNeedsRefining() == true)
                    {
                        UnityFunctions.SendAlert(enum_status.Info, "Refining Material: " + other.gameObject.name.ToString());
                    }
                    else
                    {
                        UnityFunctions.SendAlert(enum_status.Info, "Collected: " + other.gameObject.name.ToString());
                    }
                }
            }
        }
        else
        {
            if (module_ir != null && module_ir.Item_type == enum_item.module_shield)
            {
                DamageShield();
            }
            else
            {
                DamageShip();
            }
        }
    }