Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        private IRenderPackage CreateRenderPackageFromGraphicItem(IGraphicItem gItem)
        {
            var factory       = new HelixRenderPackageFactory();
            var renderPackage = factory.CreateRenderPackage();

            gItem.Tessellate(renderPackage, factory.TessellationParameters);
            return(renderPackage);
        }
Ejemplo n.º 4
0
        private RenderPackage PackageRenderData(IGraphicItem gItem)
        {
            var renderPackage = new RenderPackage();

            gItem.Tessellate(renderPackage, -1.0, this.watch3dModel.ViewModel.VisualizationManager.MaxTesselationDivisions);
            renderPackage.ItemsCount++;
            return(renderPackage);
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 6
0
        internal override bool TessellateCore(IRenderPackage package)
        {
            IGraphicItem graphics = mPersistent as IGraphicItem;

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

            return(false);
        }
Ejemplo n.º 7
0
        internal void Tessellate(IRenderPackage package)
        {
            IGraphicItem graphics = mEntity as IGraphicItem;

            if (null != graphics)
            {
                graphics.Tessellate(package);
            }
            else
            {
                this.TessellateCore(package);
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 9
0
 //Установка обьекта для наблюдения
 public static void SetPerson(IGraphicItem viewPlayer)
 {
     player = viewPlayer;
 }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
 private static void PushGraphicItemIntoPackage(IGraphicItem graphicItem, IRenderPackage package, string tag, double size)
 {
     graphicItem.Tessellate(package, -1.0, 32);
     package.Tag = tag;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 15
0
 private static RenderPackage PackageRenderData(IGraphicItem gItem)
 {
     var renderPackage = new RenderPackage();
     gItem.Tessellate(renderPackage, -1.0, dynSettings.Controller.VisualizationManager.MaxTesselationDivisions);
     renderPackage.ItemsCount++;
     return renderPackage;
 }
Ejemplo n.º 16
0
 private RenderPackage PackageRenderData(IGraphicItem gItem)
 {
     var renderPackage = new RenderPackage();
     gItem.Tessellate(renderPackage, -1.0, this.DynamoViewModel.VisualizationManager.MaxTesselationDivisions);
     renderPackage.ItemsCount++;
     return renderPackage;
 }