예제 #1
0
        /// <summary>
        /// Create an IRenderPackage object provided an IGraphicItem
        /// </summary>
        /// <param name="gItem">An IGraphicItem object to tessellate.</param>
        /// <returns>An IRenderPackage object.</returns>
        public IRenderPackage CreateRenderPackageFromGraphicItem(IGraphicItem gItem)
        {
            var renderPackage = renderPackageFactory.CreateRenderPackage();

            gItem.Tessellate(renderPackage, renderPackageFactory.TessellationParameters);
            return(renderPackage);
        }
예제 #2
0
        /// <summary>
        /// Create an IRenderPackage object provided an IGraphicItem
        /// </summary>
        /// <param name="gItem">An IGraphicItem object to tessellate.</param>
        /// <returns>An IRenderPackage object.</returns>
        public IRenderPackage CreateRenderPackageFromGraphicItem(IGraphicItem gItem)
        {
            var renderPackage = renderPackageFactory.CreateRenderPackage();

            gItem.Tessellate(renderPackage, -1.0, renderPackageFactory.MaxTessellationDivisions);
            return(renderPackage);
        }
예제 #3
0
        private IRenderPackage CreateRenderPackageFromGraphicItem(IGraphicItem gItem)
        {
            var factory       = new HelixRenderPackageFactory();
            var renderPackage = factory.CreateRenderPackage();

            gItem.Tessellate(renderPackage, factory.TessellationParameters);
            return(renderPackage);
        }
예제 #4
0
파일: Watch3D.cs 프로젝트: abhicris/Dynamo
        private RenderPackage PackageRenderData(IGraphicItem gItem)
        {
            var renderPackage = new RenderPackage();

            gItem.Tessellate(renderPackage, -1.0, this.watch3dModel.ViewModel.VisualizationManager.MaxTesselationDivisions);
            renderPackage.ItemsCount++;
            return(renderPackage);
        }
예제 #5
0
        private void RevitGeometryObjectFromGraphicItem(IGraphicItem item, ref List <GeometryObject> geoms)
        {
            var geom = item as PolyCurve;

            if (geom != null)
            {
                // We extract the curves explicitly rather than using PolyCurve's ToRevitType
                // extension method.  There is a potential issue with CurveLoop which causes
                // this method to introduce corrupt GNodes.
                foreach (var c in geom.Curves())
                {
                    // Tesselate the curve.  This greatly improves performance when
                    // we're dealing with NurbsCurve's with high knot count, commonly
                    // results of surf-surf intersections.
                    geoms.AddRange(Tessellate(c));
                }

                return;
            }

            var point = item as Point;

            if (point != null)
            {
                geoms.Add(DocumentManager.Instance.CurrentUIApplication.Application.Create.NewPoint(point.ToXyz()));
                return;
            }

            var curve = item as Curve;

            if (curve != null)
            {
                // Tesselate the curve.  This greatly improves performance when
                // we're dealing with NurbsCurve's with high knot count, commonly
                // results of surf-surf intersections.
                geoms.AddRange(Tessellate(curve));
                return;
            }

            var surf = item as Surface;

            if (surf != null)
            {
                geoms.AddRange(surf.ToRevitType());
                return;
            }

            var solid = item as Solid;

            if (solid != null)
            {
                geoms.AddRange(solid.ToRevitType());
            }
        }
예제 #6
0
        internal override bool TessellateCore(IRenderPackage package)
        {
            IGraphicItem graphics = mPersistent as IGraphicItem;

            if (null != graphics)
            {
                graphics.Tessellate(package);
                return(true);
            }

            return(false);
        }
예제 #7
0
        internal void Tessellate(IRenderPackage package)
        {
            IGraphicItem graphics = mEntity as IGraphicItem;

            if (null != graphics)
            {
                graphics.Tessellate(package);
            }
            else
            {
                this.TessellateCore(package);
            }
        }
예제 #8
0
        public static List <IGraphicItem> GetGraphicItemsFromObject(object obj)
        {
            if (null == obj)
            {
                return(null);
            }

            List <IGraphicItem> items = new List <IGraphicItem>();

            System.Type objType    = obj.GetType();
            IEnumerable collection = obj as IEnumerable;

            if (null != collection)
            {
                foreach (var item in collection)
                {
                    try
                    {
                        List <IGraphicItem> graphics = GetGraphicItemsFromObject(item);
                        if (null != graphics)
                        {
                            items.AddRange(graphics);
                        }
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("GetGraphicItems: " + e);
                    }
                }
                return(items);
            }

            IGraphicItem graphicItem = obj as IGraphicItem;

            if (graphicItem != null)
            {
                items.Add(graphicItem);
                return(items);
            }

            IGraphicDataProvider dataProvider = GetGraphicDataProviderForType(objType);

            if (null == dataProvider)
            {
                dataProvider = new GraphicObjectType(objType);
                mGraphicTypes.Add(objType, dataProvider);
            }

            return(dataProvider.GetGraphicItems(obj));
        }
예제 #9
0
 //Установка обьекта для наблюдения
 public static void SetPerson(IGraphicItem viewPlayer)
 {
     player = viewPlayer;
 }
예제 #10
0
파일: NodeModel.cs 프로젝트: heegwon/Dynamo
        private void PushGraphicItemIntoPackage(IGraphicItem graphicItem, IRenderPackage package, string tag, double size)
        {
            try
            {

                graphicItem.Tessellate(package, -1.0, dynSettings.Controller.VisualizationManager.MaxTesselationDivisions);
                package.Tag = tag;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("PushGraphicItemIntoPackage: " + e);
            }
        }
예제 #11
0
 private static void PushGraphicItemIntoPackage(IGraphicItem graphicItem, IRenderPackage package, string tag, double size)
 {
     graphicItem.Tessellate(package, -1.0, 32);
     package.Tag = tag;
 }
예제 #12
0
 /// <summary>
 /// Create an IRenderPackage object provided an IGraphicItem
 /// </summary>
 /// <param name="gItem">An IGraphicItem object to tessellate.</param>
 /// <returns>An IRenderPackage object.</returns>
 public IRenderPackage CreateRenderPackageFromGraphicItem(IGraphicItem gItem)
 {
     var renderPackage = renderPackageFactory.CreateRenderPackage();
     gItem.Tessellate(renderPackage, renderPackageFactory.TessellationParameters);
     return renderPackage;
 }
예제 #13
0
 private void PushGraphicItemIntoPackage(IGraphicItem graphicItem, IRenderPackage package, string tag, 
     double size, int maxTesselationDivisions )
 {
     try
     {
         graphicItem.Tessellate(package, -1.0, maxTesselationDivisions);
         package.Tag = tag;
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("PushGraphicItemIntoPackage: " + e);
     }
 }
예제 #14
0
        private void GetTessellationDataFromGraphicItem(Guid outputPortId, IGraphicItem graphicItem, string labelKey, ref IRenderPackage package)
        {
            var packageWithTransform = package as ITransformable;

            try
            {
                var previousPointVertexCount = package.PointVertexCount;
                var previousLineVertexCount  = package.LineVertexCount;
                var previousMeshVertexCount  = package.MeshVertexCount;

                //Todo Plane tessellation needs to be handled here vs in LibG currently
                if (graphicItem is Plane plane)
                {
                    CreatePlaneTessellation(package, plane);
                }
                else
                {
                    try
                    {
                        graphicItem.Tessellate(package, factory.TessellationParameters);
                    }
                    catch (LegacyRenderPackageMethodException)
                    {
                        //At this point we have detected an implementation of Tessellate which is using legacy color methods
                        //We roll back the primary renderPackage to it previous state before calling tessellation again.
                        package = RollBackPackage(package, previousPointVertexCount, previousLineVertexCount,
                                                  previousMeshVertexCount);

                        //Now we create a renderPackage object that will allow legacy color methods
                        var legacyPackage = factory.CreateRenderPackage();
                        legacyPackage.DisplayLabels = displayLabels;
                        legacyPackage.Description   = labelKey;
                        legacyPackage.IsSelected    = isNodeSelected;

                        //Use it to get fill the tessellation data and add it to the render cache.
                        GetTessellationDataFromGraphicItem(outputPortId, graphicItem, labelKey, ref legacyPackage);

                        if (legacyPackage.MeshVertexColors.Any())
                        {
                            legacyPackage.RequiresPerVertexColoration = true;
                        }

                        renderPackageCache.Add(legacyPackage, outputPortId);

                        return;
                    }

                    //Now we validate that tessellation call has added colors for each new vertex.
                    //If any vertex colors previously existed, this will ensure the vertex color and vertex counts stays in sync.
                    EnsureColorExistsPerVertex(package, previousPointVertexCount, previousLineVertexCount,
                                               previousMeshVertexCount);

                    if (factory.TessellationParameters.ShowEdges)
                    {
                        if (graphicItem is Topology topology)
                        {
                            if (graphicItem is Surface surf)
                            {
                                foreach (var curve in surf.PerimeterCurves())
                                {
                                    curve.Tessellate(package, factory.TessellationParameters);
                                    curve.Dispose();
                                }
                            }
                            else
                            {
                                var edges = topology.Edges;
                                foreach (var geom in edges.Select(edge => edge.CurveGeometry))
                                {
                                    geom.Tessellate(package, factory.TessellationParameters);
                                    geom.Dispose();
                                }

                                edges.ForEach(x => x.Dispose());
                            }
                        }
                    }
                }

                //If the package has a transform that is not the identity matrix
                //then set requiresCustomTransform to true.
                if (packageWithTransform != null && !packageWithTransform.RequiresCustomTransform &&
                    packageWithTransform.Transform.SequenceEqual(
                        new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }) == false)
                {
                    (packageWithTransform).RequiresCustomTransform = true;
                }

                //Do not add replication labels if the tessellation call set DisplayLabels to true;
                if (package is IRenderLabels packageLabels && packageLabels.AutoGenerateLabels)
                {
                    if (package.MeshVertexCount > previousMeshVertexCount)
                    {
                        packageLabels.AddLabel(labelKey, VertexType.Mesh, package.MeshVertexCount);
                    }
                    else if (package.LineVertexCount > previousLineVertexCount)
                    {
                        packageLabels.AddLabel(labelKey, VertexType.Line, package.LineVertexCount);
                    }
                    else if (package.PointVertexCount > previousPointVertexCount)
                    {
                        packageLabels.AddLabel(labelKey, VertexType.Point, package.PointVertexCount);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(
                    "PushGraphicItemIntoPackage: " + e);
            }
        }
예제 #15
0
파일: dynWatch3D.cs 프로젝트: khoaho/Dynamo
 private static RenderPackage PackageRenderData(IGraphicItem gItem)
 {
     var renderPackage = new RenderPackage();
     gItem.Tessellate(renderPackage, -1.0, dynSettings.Controller.VisualizationManager.MaxTesselationDivisions);
     renderPackage.ItemsCount++;
     return renderPackage;
 }
예제 #16
0
 private RenderPackage PackageRenderData(IGraphicItem gItem)
 {
     var renderPackage = new RenderPackage();
     gItem.Tessellate(renderPackage, -1.0, this.DynamoViewModel.VisualizationManager.MaxTesselationDivisions);
     renderPackage.ItemsCount++;
     return renderPackage;
 }