Ejemplo n.º 1
0
        /// <summary>
        /// Implement this function to draw all shaded meshes.
        /// If the viewport does not support shading, this function will not be called.
        /// </summary>
        /// <param name="args"> Drawing arguments. </param>
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (Value == null)
            {
                return;
            }

            // Robot meshes
            if (Value.Meshes != null)
            {
                for (int i = 0; i != Value.Meshes.Count; i++)
                {
                    args.Pipeline.DrawMeshShaded(Value.Meshes[i], new Rhino.Display.DisplayMaterial(System.Drawing.Color.FromArgb(225, 225, 225), 0));
                }
            }

            // External axis meshes
            for (int i = 0; i != Value.ExternalAxes.Count; i++)
            {
                if (Value.ExternalAxes[i].IsValid == true)
                {
                    if (Value.ExternalAxes[i].BaseMesh != null)
                    {
                        args.Pipeline.DrawMeshShaded(Value.ExternalAxes[i].BaseMesh, new Rhino.Display.DisplayMaterial(System.Drawing.Color.FromArgb(225, 225, 225), 0));
                    }

                    if (Value.ExternalAxes[i].LinkMesh != null)
                    {
                        args.Pipeline.DrawMeshShaded(Value.ExternalAxes[i].LinkMesh, new Rhino.Display.DisplayMaterial(System.Drawing.Color.FromArgb(225, 225, 225), 0));
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     foreach (var mesh in GetPreviewMeshes() ?? Enumerable.Empty <Rhino.Geometry.Mesh>())
     {
         args.Pipeline.DrawMeshShaded(mesh, args.Material);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Implement this function to draw all shaded meshes.
        /// If the viewport does not support shading, this function will not be called.
        /// </summary>
        /// <param name="args"> Drawing arguments. </param>
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (this.Value is Movement movement1)
            {
                Plane plane = movement1.GetGlobalTargetPlane();

                if (plane != Plane.Unset)
                {
                    args.Pipeline.DrawDirectionArrow(plane.Origin, plane.ZAxis, System.Drawing.Color.Blue);
                    args.Pipeline.DrawDirectionArrow(plane.Origin, plane.XAxis, System.Drawing.Color.Red);
                    args.Pipeline.DrawDirectionArrow(plane.Origin, plane.YAxis, System.Drawing.Color.Green);
                }
            }

            else if (this.Value is ActionGroup group)
            {
                for (int i = 0; i < group.Actions.Count; i++)
                {
                    if (group.Actions[i] is Movement movement2)
                    {
                        Plane plane = movement2.GetGlobalTargetPlane();

                        if (plane != Plane.Unset)
                        {
                            args.Pipeline.DrawDirectionArrow(plane.Origin, plane.ZAxis, System.Drawing.Color.Blue);
                            args.Pipeline.DrawDirectionArrow(plane.Origin, plane.XAxis, System.Drawing.Color.Red);
                            args.Pipeline.DrawDirectionArrow(plane.Origin, plane.YAxis, System.Drawing.Color.Green);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
    void IGH_PreviewData.DrawViewportMeshes(GH_PreviewMeshArgs args)
    {
      if (!IsValid)
        return;

      if (meshes == null)
      {
        using (var ga = Convert.GraphicAttributes.Push())
        {
          ga.MeshingParameters = args.MeshingParameters;
          meshes = Enumerable.Repeat(Value, 1).GetPreviewMeshes().ToArray();

          var element = Value.IsElementGeometry ?
            Revit.ActiveDBDocument.GetElement(Reference.ParseFromStableRepresentation(Revit.ActiveDBDocument, UniqueID)) :
            null;

          if (element is Instance instance)
          {
            var transform = instance.GetTransform();
            transform.Origin = transform.Origin.Multiply(Revit.ModelUnits);
            var xform = transform.ToRhino();

            foreach (var mesh in meshes)
              mesh.Transform(xform);
          }

          foreach (var mesh in meshes)
            mesh.Normals.ComputeNormals();
        }
      }

      foreach (var mesh in meshes ?? Enumerable.Empty<Rhino.Geometry.Mesh>())
        args.Pipeline.DrawMeshShaded(mesh, args.Material);
    }
Ejemplo n.º 5
0
 public override void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     if (Region is object)
     {
         args.Pipeline.DrawBrepShaded(Region, args.Material);
     }
 }
Ejemplo n.º 6
0
        /***************************************************/

        public virtual void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (!m_IsMeshPreviewable)   //Flagged as not previewable - return
            {
                return;
            }

            if (m_PreviewMesh == null)  //No preview mesh set yet
            {
                //Create and store mesh. Will return values for surface type objects (surfaces, breps, meshes etc)
                m_PreviewMesh = Render.ICreatePreviewMesh(m_RhinoGeometry, args.MeshingParameters);

                if (m_PreviewMesh == null)
                {
                    m_IsMeshPreviewable = false;    //If no mesh could be extracted, set flag as not required to check again for the same geometry
                    return;
                }
            }

            if (m_PreviewMesh != null)
            {
                if (m_PreviewMesh.VertexColors.Count > 0)   //If colours are set (RenderMeshes) draw these colours
                {
                    args.Pipeline.DrawMeshFalseColors(m_PreviewMesh);
                }
                else
                {
                    Rhino.Display.DisplayMaterial mat = Render.RenderMaterial(args.Material, m_PreviewMaterial);    //If material is default GH material, BHoM default will be used, if not, default GH material is used.
                    args.Pipeline.DrawMeshShaded(m_PreviewMesh, mat);
                }
            }
        }
Ejemplo n.º 7
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     //TODO
     if (Value?.Geometry != null)
     {
         args.Pipeline.DrawMeshShaded(SectionMesh, args.Material);
     }
 }
Ejemplo n.º 8
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     // no need to draw meshes
     if (Value != null)
     {
         drawSupportLine(args.Pipeline, DrawUtil.DrawColorSupports, true);
     }
 }
Ejemplo n.º 9
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     if (Value.Geometry is Mesh)
     {
         var material = Value.Material ?? args.Material;
         args.Pipeline.DrawMeshShaded(Value.Geometry as Mesh, material);
     }
 }
Ejemplo n.º 10
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     /*if (Value != null)
      * {
      *  Mesh mesh = SupportMesh;
      *  if (mesh != null) args.Pipeline.DrawMeshShaded(mesh, args.Material);
      * }*/
 }
Ejemplo n.º 11
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     if (RenderMesh == null)
     {
         return;
     }
     args.Pipeline.DrawMeshShaded(RenderMesh, args.Material);
 }
Ejemplo n.º 12
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     /*
      * if (!(Value is null))
      * {
      * args.Pipeline.DrawBrepShaded(Value, DrawUtil.DrawMaterialLoads);
      * }
      */
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Implement this function to draw all shaded meshes.
        /// If the viewport does not support shading, this function will not be called.
        /// </summary>
        /// <param name="args"> Drawing arguments. </param>
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            Plane plane = Value.GetGlobalTargetPlane();

            if (plane != Plane.Unset)
            {
                args.Pipeline.DrawDirectionArrow(plane.Origin, plane.ZAxis, System.Drawing.Color.Blue);
                args.Pipeline.DrawDirectionArrow(plane.Origin, plane.XAxis, System.Drawing.Color.Red);
                args.Pipeline.DrawDirectionArrow(plane.Origin, plane.YAxis, System.Drawing.Color.Green);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Implement this function to draw all shaded meshes.
        /// If the viewport does not support shading, this function will not be called.
        /// </summary>
        /// <param name="args"> Drawing arguments. </param>
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (Value == null)
            {
                return;
            }

            if (Value.Mesh != null)
            {
                args.Pipeline.DrawMeshShaded(Value.Mesh, new Rhino.Display.DisplayMaterial(System.Drawing.Color.FromArgb(225, 225, 225), 0));
            }
        }
Ejemplo n.º 15
0
        void IGH_PreviewData.DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (!IsValid)
            {
                return;
            }

            foreach (var mesh in Meshes(args.MeshingParameters))
            {
                args.Pipeline.DrawMeshShaded(mesh, args.Material);
            }
        }
Ejemplo n.º 16
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     //Draw shape.
     if (args.Material.Diffuse == System.Drawing.Color.FromArgb(255, 150, 0, 0)) // this is a workaround to change colour between selected and not
     {
         args.Pipeline.DrawMeshShaded(Value.DisplayMesh, UI.Colour.Element3dFace);
     }
     else
     {
         args.Pipeline.DrawMeshShaded(Value.DisplayMesh, UI.Colour.Element2dFaceSelected);
     }
 }
Ejemplo n.º 17
0
        /***************************************************/
        /**** Public Methods  - Interfaces              ****/
        /***************************************************/

        public static void IRenderRhinoMeshes(this object obj, GH_PreviewMeshArgs args, Color custom)
        {
            if (obj == null)
            {
                return;
            }
            DisplayMaterial material = RenderMaterial(args.Material, custom);

            try
            {
                RenderRhinoMeshes(obj as dynamic, args.Pipeline, material);
            }
            catch (Exception) { }
        }
Ejemplo n.º 18
0
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (Value != null)
            {
                var col = args.Material.Diffuse;
                var areaStrcMaterial = args.Material;
                if (!DrawUtil.CheckSelection(col))
                {
                    areaStrcMaterial = DrawUtil.DrawMaterialStructure;
                }

                args.Pipeline.DrawBrepShaded(Value, areaStrcMaterial);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// draw all shaded meshes
        /// </summary>
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (Value == null)
            {
                return;
            }

            if (args.Pipeline.SupportsShading)
            {
                var c = args.Material.Diffuse;
                c = System.Drawing.Color.FromArgb((int)(args.Material.Transparency * 255), c);

                args.Pipeline.DrawMeshShaded(Value.Display, args.Material);
            }
        }
Ejemplo n.º 20
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     if (args.Pipeline.SupportsShading)
     {
         if (this._mesh == null)
         {
             if (this.m_value == null)
             {
                 return;
             }
             MeshingParameters @params = args.MeshingParameters;
             if (@params == null)
             {
                 return;
             }
             if (this._extrusion == null)
             {
                 // Set extrusion
                 List <Brep> breps = Utilities.CreateSectionSweeps(this.Value);
                 _extrusion = Brep.JoinBreps(breps, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)[0];
             }
             Mesh[] rc = Mesh.CreateFromBrep(this._extrusion, @params);
             if (rc == null)
             {
                 this._mesh = new Mesh();
             }
             else if (rc.Length == 1)
             {
                 this._mesh = rc[0];
             }
             else
             {
                 this._mesh = new Mesh();
                 Mesh[] array = rc;
                 for (int j = 0; j < array.Length; j++)
                 {
                     Mesh i = array[j];
                     this._mesh.Append(i);
                 }
             }
         }
         if (this._mesh == null)
         {
             return;
         }
         args.Pipeline.DrawMeshShaded(this._mesh, args.Material);
     }
 }
Ejemplo n.º 21
0
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (!(Value is null))
            {
                Rhino.Display.DisplayMaterial areaLoadMaterial = new Rhino.Display.DisplayMaterial(args.Material);

                System.Drawing.Color col = DrawUtil.DrawColorLoads;

                areaLoadMaterial.Diffuse      = col;
                areaLoadMaterial.Specular     = col;
                areaLoadMaterial.Emission     = col;
                areaLoadMaterial.BackDiffuse  = col;
                areaLoadMaterial.BackSpecular = col;
                areaLoadMaterial.BackEmission = col;

                args.Pipeline.DrawBrepShaded(Value, areaLoadMaterial);
            }
        }
Ejemplo n.º 22
0
        /***************************************************/
        /**** Public Methods  - Interfaces              ****/
        /***************************************************/

        public static void IRenderMeshes(this BHG.IGeometry geometry, GH_PreviewMeshArgs args)
        {
            if (geometry == null)
            {
                return;
            }
            else if (!(geometry is BHG.ISurface) & !(geometry is BHG.Mesh))
            {
                return;
            }
            DisplayMaterial bhMaterial = RenderMaterial(args.Material, Color.FromArgb(80, 255, 41, 105));//BHoM pink!

            try
            {
                RenderMeshes(geometry as dynamic, args.Pipeline, bhMaterial);
            }
            catch (Exception) { }
        }
Ejemplo n.º 23
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     //Draw shape.
     if (args.Material.Diffuse == System.Drawing.Color.FromArgb(255, 150, 0, 0)) // this is a workaround to change colour between selected and not
     {
         args.Pipeline.DrawMeshShaded(Value.Mesh, UI.Colour.Element2dFace);
         //Mesh mesh = Value.Mesh.DuplicateMesh();
         //mesh.fac
         //for (int i = 0; i < Value.Mesh.Faces.Count; i++)
         //{
         //    int[] face = new int[] { i };
         //    args.Pipeline.DrawMeshShaded(Value.Mesh,
         //        UI.Colour.FaceCustom(Value.Colours[i]), face);
         //}
     }
     else
     {
         args.Pipeline.DrawMeshShaded(Value.Mesh, UI.Colour.Element2dFaceSelected);
     }
 }
Ejemplo n.º 24
0
        public override void DrawViewportMeshes(IGH_PreviewArgs args)
        {
            if (_allPreviewItems == null || _allPreviewItems.Count == 0)
            {
                return;
            }

            foreach (var previewItem in _allPreviewItems)
            {
                try
                {
                    var drawArgs = new GH_PreviewMeshArgs(args.Viewport, args.Display, new DisplayMaterial(previewItem.DrawColor), MeshingParameters.FastRenderMesh);
                    previewItem.Geo.DrawViewportMeshes(drawArgs);
                }
                catch (Exception e)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message);
                }
            }
        }
Ejemplo n.º 25
0
        public void DrawViewportMeshes(GH_PreviewMeshArgs args)
        {
            if (Value != null)
            {
                System.Drawing.Color          col = args.Material.Diffuse;
                Rhino.Display.DisplayMaterial areaStrcMaterial = new Rhino.Display.DisplayMaterial(args.Material);
                if (!DrawUtil.CheckSelection(col))
                {
                    col = DrawUtil.DrawColorStructuralElements;

                    areaStrcMaterial.Diffuse      = col;
                    areaStrcMaterial.Specular     = col;
                    areaStrcMaterial.Emission     = col;
                    areaStrcMaterial.BackDiffuse  = col;
                    areaStrcMaterial.BackSpecular = col;
                    areaStrcMaterial.BackEmission = col;
                }

                args.Pipeline.DrawBrepShaded(Value, areaStrcMaterial);
            }
        }
Ejemplo n.º 26
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     //Draw shape.
     if (Value.Brep != null)
     {
         if (Value.Member.Type == MemberType.VOID_CUTTER_2D)
         {
         }
         else
         {
             if (args.Material.Diffuse == System.Drawing.Color.FromArgb(255, 150, 0, 0)) // this is a workaround to change colour between selected and not
             {
                 args.Pipeline.DrawBrepShaded(Value.Brep, UI.Colour.Member2dFace);       //UI.Colour.Member2dFace
             }
             else
             {
                 args.Pipeline.DrawBrepShaded(Value.Brep, UI.Colour.Member2dFaceSelected);
             }
         }
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// 绘制预览网格,(仅未被选中时显示伪色),用于重写DrawViewportMeshes内
        /// </summary>
        /// <param name="mesh">要绘制的网格</param>
        /// <param name="component">电池本体,默认输入this</param>
        /// <param name="args">预览变量,默认输入 args</param>
        public static void Draw1Meshes(int a, IGH_Component component, IGH_PreviewArgs args)
        {
            List <GH_Mesh>     lmesh = ((GH_Structure <GH_Mesh>)component.Params.Output[a].VolatileData).FlattenData();
            bool               set   = component.Attributes.GetTopLevel.Selected;
            GH_PreviewMeshArgs args2 = new GH_PreviewMeshArgs(args.Viewport, args.Display,
                                                              (set ? args.ShadeMaterial_Selected : args.ShadeMaterial), args.MeshingParameters);

            if (lmesh.Count == 0)
            {
                return;                   ///避免网格不存在
            }
            Mesh mesh = lmesh[0].Value;

            if (mesh.VertexColors.Count > 0 && !set) //仅存在着色且未被选取时
            {
                args2.Pipeline.DrawMeshFalseColors(mesh);
            }
            else
            {
                args2.Pipeline.DrawMeshShaded(mesh, args2.Material);
            }
        }
Ejemplo n.º 28
0
 public void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
     //Draw shape.
     if (Value.SolidMesh != null)
     {
         if (!Value.Member.IsDummy)
         {
             if (args.Material.Diffuse == System.Drawing.Color.FromArgb(255, 150, 0, 0)) // this is a workaround to change colour between selected and not
             {
                 args.Pipeline.DrawMeshShaded(Value.SolidMesh, UI.Colour.Element2dFace); //UI.Colour.Member2dFace
             }
             else
             {
                 args.Pipeline.DrawMeshShaded(Value.SolidMesh, UI.Colour.Element2dFaceSelected);
             }
         }
         else
         {
             args.Pipeline.DrawMeshShaded(Value.SolidMesh, UI.Colour.Dummy2D);
         }
     }
 }
Ejemplo n.º 29
0
 public override void DrawViewportMeshes(IGH_PreviewArgs args)
 {
     if ((this.m_items != null))
     {
         if (this.Attributes.Selected)
         {
             GH_PreviewMeshArgs args2 = new GH_PreviewMeshArgs(args.Viewport, args.Display, args.ShadeMaterial_Selected, args.MeshingParameters);
             foreach (GH_CustomPreviewItem item in this.m_items)
             {
                 item.m_obj.DrawViewportMeshes(args2);
             }
         }
         else
         {
             foreach (GH_CustomPreviewItem item2 in this.m_items)
             {
                 Rhino.Display.DisplayMaterial lastColor = new Rhino.Display.DisplayMaterial(item2.m_col);
                 GH_PreviewMeshArgs            args3     = new GH_PreviewMeshArgs(args.Viewport, args.Display, lastColor, args.MeshingParameters);
                 item2.m_obj.DrawViewportMeshes(args3);
             }
         }
     }
 }
Ejemplo n.º 30
0
 public override void DrawViewportMeshes(GH_PreviewMeshArgs args)
 {
 }