Ejemplo n.º 1
0
 /// <summary>
 /// Set the display and other attributes of a netDXF entity from those of an Nucleus object
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="attributes"></param>
 public static void SetAttributes(nDE.EntityObject entity, GeometryAttributes attributes)
 {
     if (attributes != null)
     {
         if (attributes.Brush != null)
         {
             entity.Color = Convert(attributes.Brush.BaseColour);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert a Rhino object reference to Nucleus geometry with attached
        /// attributes.
        /// </summary>
        /// <param name="objRef"></param>
        /// <returns></returns>
        public static VertexGeometry Convert(ObjRef objRef)
        {
            VertexGeometry result = Convert(objRef.Geometry());

            if (result != null)
            {
                GeometryAttributes attributes = new GeometryAttributes();
                int layerIndex = objRef.Object().Attributes.LayerIndex;
                attributes.LayerName = RhinoDoc.ActiveDoc.Layers[layerIndex].Name;
                attributes.SourceID  = objRef.ObjectId.ToString();
                result.Attributes    = attributes;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static IMesh ToIMesh(this IEnumerable <GeometryAttribute> self)
        {
            var attrs = self.Where(x => x != null).ToArray();
            var tmp   = new GeometryAttributes(self);

            switch (tmp.NumCornersPerFace)
            {
            case 3:
                return(new TriMesh(tmp.Attributes.ToEnumerable()));

            case 4:
                return(new QuadMesh(tmp.Attributes.ToEnumerable()).ToTriMesh());

            default:
                throw new Exception($"Can not convert a geometry with {tmp.NumCornersPerFace} to a triangle mesh: only quad meshes");
            }
        }