示例#1
0
        internal void SetSubDDisplayOverride(SubD dynamicSubD)
        {
            IntPtr rhSubObjectPtr    = ConstPointer();
            IntPtr dynamicSubDRefPtr = dynamicSubD.ON_SubDRef_Pointer();

            UnsafeNativeMethods.CRhinoSubDObject_SetSubDDisplayOverride(rhSubObjectPtr, dynamicSubDRefPtr);
        }
        static DB.GeometryObject ToShape(SubD subD, double factor)
        {
            // Try using DB.BRepBuilder
            if (SubDEncoder.ToSolid(subD, factor) is DB.Solid solid)
            {
                return(solid);
            }

            Debug.WriteLine("Try meshing the subD.");
            return(SubDEncoder.ToMesh(subD, factor));
        }
示例#3
0
        /// <summary>
        /// Add a new vertex to the end of the Vertex list.
        /// </summary>
        /// <param name="tag">The type of vertex tag, such as smooth or corner.</param>
        /// <param name="vertex">Location of new vertex.</param>
        /// <returns>The newly added vertex.</returns>
        /// <exception cref="ArgumentOutOfRangeException">If tag is unset or non-defined.</exception>
        /// <since>7.0</since>
        public SubDVertex Add(SubDVertexTag tag, Point3d vertex)
        {
            if (!SubD.IsSubDVertexTagDefined(tag))
            {
                throw new ArgumentOutOfRangeException("tag");
            }

            IntPtr ptr_subd   = m_subd.NonConstPointer();
            uint   id         = 0;
            IntPtr ptr_vertex = UnsafeNativeMethods.ON_SubD_AddVertex(ptr_subd, tag, vertex, ref id);

            if (ptr_vertex != IntPtr.Zero)
            {
                return(new SubDVertex(m_subd, ptr_vertex, id));
            }

            return(null);
        }
示例#4
0
        /// <summary>
        /// Add a new edge to the list.
        /// </summary>
        /// <param name="tag">The type of edge tag, such as smooth or corner.</param>
        /// <param name="v0">First vertex.</param>
        /// <param name="v1">Second vertex.</param>
        /// <exception cref="ArgumentOutOfRangeException">If tag is unset or non-defined.</exception>
        /// <since>7.0</since>
        public SubDEdge Add(SubDEdgeTag tag, SubDVertex v0, SubDVertex v1)
        {
            if (!SubD.IsSubDEdgeTagDefined(tag))
            {
                throw new ArgumentOutOfRangeException("tag");
            }

            IntPtr ptr_subd = m_subd.NonConstPointer();

            IntPtr v0_ptr = v0.NonConstPointer();
            IntPtr v1_ptr = v1.NonConstPointer();

            uint   id       = 0;
            IntPtr ptr_edge = UnsafeNativeMethods.ON_SubD_AddEdge(ptr_subd, tag, v0_ptr, v1_ptr, ref id);

            if (ptr_edge != IntPtr.Zero)
            {
                return(new SubDEdge(m_subd, ptr_edge, id));
            }

            GC.KeepAlive(v0);
            GC.KeepAlive(v1);
            return(null);
        }
示例#5
0
        public Schema Solve()
        {
            HasErrors = false;
            Schema outputSchema = new Schema();

            outputSchema.Algo = "";

            // solve definition
            Definition.Enabled = true;
            Definition.NewSolution(false, GH_SolutionMode.CommandLine);

            LogRuntimeMessages(Definition.ActiveObjects(), outputSchema);

            foreach (var kvp in _output)
            {
                var param = kvp.Value;
                if (param == null)
                {
                    continue;
                }

                // Get data
                var outputTree = new DataTree <ResthopperObject>();
                outputTree.ParamName = kvp.Key;

                var volatileData = param.VolatileData;
                for (int p = 0; p < volatileData.PathCount; p++)
                {
                    var resthopperObjectList = new List <ResthopperObject>();
                    foreach (var goo in volatileData.get_Branch(p))
                    {
                        if (goo == null)
                        {
                            continue;
                        }

                        switch (goo)
                        {
                        case GH_Boolean ghValue:
                        {
                            bool rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <bool>(rhValue));
                        }
                        break;

                        case GH_Point ghValue:
                        {
                            Point3d rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Point3d>(rhValue));
                        }
                        break;

                        case GH_Vector ghValue:
                        {
                            Vector3d rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Vector3d>(rhValue));
                        }
                        break;

                        case GH_Integer ghValue:
                        {
                            int rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <int>(rhValue));
                        }
                        break;

                        case GH_Number ghValue:
                        {
                            double rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <double>(rhValue));
                        }
                        break;

                        case GH_String ghValue:
                        {
                            string rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <string>(rhValue));
                        }
                        break;

                        case GH_SubD ghValue:
                        {
                            SubD rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <SubD>(rhValue));
                        }
                        break;

                        case GH_Line ghValue:
                        {
                            Line rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Line>(rhValue));
                        }
                        break;

                        case GH_Curve ghValue:
                        {
                            Curve rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Curve>(rhValue));
                        }
                        break;

                        case GH_Circle ghValue:
                        {
                            Circle rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Circle>(rhValue));
                        }
                        break;

                        case GH_Plane ghValue:
                        {
                            Plane rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Plane>(rhValue));
                        }
                        break;

                        case GH_Rectangle ghValue:
                        {
                            Rectangle3d rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Rectangle3d>(rhValue));
                        }
                        break;

                        case GH_Box ghValue:
                        {
                            Box rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Box>(rhValue));
                        }
                        break;

                        case GH_Surface ghValue:
                        {
                            Brep rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Brep>(rhValue));
                        }
                        break;

                        case GH_Brep ghValue:
                        {
                            Brep rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Brep>(rhValue));
                        }
                        break;

                        case GH_Mesh ghValue:
                        {
                            Mesh rhValue = ghValue.Value;
                            resthopperObjectList.Add(GetResthopperObject <Mesh>(rhValue));
                        }
                        break;
                        }
                    }

                    GhPath path = new GhPath(new int[] { p });
                    outputTree.Add(path.ToString(), resthopperObjectList);
                }

                outputSchema.Values.Add(outputTree);
            }


            if (outputSchema.Values.Count < 1)
            {
                throw new System.Exceptions.PayAttentionException("Looks like you've missed something..."); // TODO
            }
            return(outputSchema);
        }
示例#6
0
 internal SubDFaceList(SubD parent)
 {
     m_subd = parent;
 }
示例#7
0
 internal SubDEdgeList(SubD parent)
 {
     m_subd = parent;
 }
示例#8
0
 internal SubDVertexList(SubD parent)
 {
     m_subd = parent;
 }
示例#9
0
        internal static Brep ToRawBrep(/*const*/ SubD subD, double scaleFactor)
        {
            var brep = subD.ToBrep();

            return(BrepEncoder.EncodeRaw(ref brep, scaleFactor) ? brep : default);