示例#1
0
        /***************************************************/

        private static BHG.PlanarSurface ToBHoMPlanarSurface(this RHG.BrepFace face)
        {
            RHG.Surface rhSurf = face.UnderlyingSurface();
            if (rhSurf == null)
            {
                return(null);
            }

            BHG.PlanarSurface bhs = rhSurf.FromRhino() as BHG.PlanarSurface;
            List <BHG.ICurve> internalBoundaries = new List <BHG.ICurve>();

            BHG.ICurve externalBoundary = bhs.ExternalBoundary;
            foreach (RHG.BrepLoop loop in face.Loops)
            {
                if (loop.LoopType == RHG.BrepLoopType.Inner)
                {
                    internalBoundaries.Add(new BHG.PolyCurve {
                        Curves = loop.Trims.Select(x => rhSurf.Pushup(x, BHG.Tolerance.Distance).FromRhino()).ToList()
                    });
                }
                else if (loop.LoopType == RHG.BrepLoopType.Outer)
                {
                    externalBoundary = new BHG.PolyCurve {
                        Curves = loop.Trims.Select(x => rhSurf.Pushup(x, BHG.Tolerance.Distance).FromRhino()).ToList()
                    }
                }
                ;
            }

            return(BH.Engine.Geometry.Create.PlanarSurface(externalBoundary, internalBoundaries));
        }
示例#2
0
 // Constructor with initial values.
 public SurfaceEmitterType(Surface srf)
 {
   Interval interval = new Interval(0,1);
   srf.SetDomain(0, interval);
   srf.SetDomain(1, interval);
   this.srf = srf;
 }
示例#3
0
    // Constructor with initial values.
    public SurfaceEnvironmentType(Surface srf, bool wrap)
    {
      environment = srf;
      Wrap = wrap;
      double width, height;
      srf.GetSurfaceSize(out width, out height);
      Width = width;
      Height = height;

      Interval widthInterval = new Interval(0, width);
      Interval heightInterval = new Interval(0, height);

      Interval u = srf.Domain(0);
      Interval v = srf.Domain(1);
      
      Surface refEnvironment = new PlaneSurface(Plane.WorldXY, widthInterval, heightInterval);
      refEnvironment.SetDomain(0, u);
      refEnvironment.SetDomain(1, v);
      RefEnvironment = refEnvironment;

      Interval uDom = RefEnvironment.Domain(0);
      Interval vDom = RefEnvironment.Domain(1);

      minX = 0;
      maxX = width;
      minY = 0;
      maxY = height;
    }
示例#4
0
        /// <summary> RunCommandPickPlane is a helper method for picking an existing surface to draw on </summary>
        /// <param name="mRhinoDoc"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        protected Result RunCommandPickPlane(RhinoDoc mRhinoDoc, RunMode mode)
        {
            //routine for picking an existing surface to draw on

            //please select a plane

            Rhino.DocObjects.ObjectType filter = Rhino.DocObjects.ObjectType.Surface;
            Rhino.DocObjects.ObjRef     objref = null;
            Rhino.Commands.Result       rc     = Rhino.Input.RhinoGet.GetOneObject("Select surface", false, filter, out objref);
            if (rc != Rhino.Commands.Result.Success || objref == null)
            {
                return(rc);
            }

            Rhino.Geometry.Surface refSrf = objref.Surface();
            refSrf.FrameAt(.5, .5, out plane1);

            Point3d  pOrigin = refSrf.PointAt(1, 1);
            Point3d  pY      = refSrf.PointAt(0.5, 1);
            Point3d  pX      = refSrf.PointAt(1, 0.75);
            Vector3d vX      = Rhino.Geometry.Point3d.Subtract(pX, pOrigin);
            Vector3d vY      = Rhino.Geometry.Point3d.Subtract(pY, pOrigin);

            plane1 = new Plane(pOrigin, vX, vY);

            Rhino.DocObjects.RhinoObject rhobj = objref.Object();
            rhobj.Select(false);

            mRhinoDoc.Objects.AddPoint(pOrigin);
            mRhinoDoc.Objects.AddPoint(pX);
            mRhinoDoc.Objects.AddPoint(pY);
            mRhinoDoc.Views.Redraw();

            return(Result.Success);
        }
示例#5
0
 // Constructor with initial values.
 public SurfaceEmitterType(Surface srf, bool continuousFlow, int creationRate, int numAgents, Vector3d velocityMin, Vector3d velocityMax)
   :base(continuousFlow, creationRate, numAgents, velocityMin, velocityMax)
 {
   Interval interval = new Interval(0, 1);
   srf.SetDomain(0, interval);
   srf.SetDomain(1, interval);
   this.srf = srf;
 }
示例#6
0
        private Face ByBrepFace(BrepFace ghBrepFace)
        {
            Rhino.Geometry.Surface ghSurface = ghBrepFace.UnderlyingSurface();

            Face untrimmedFace = BySurface(ghSurface);

            BrepLoop     ghOuterLoop = ghBrepFace.OuterLoop;
            Wire         outerWire   = null;
            BrepLoopList ghLoops     = ghBrepFace.Loops;
            List <Wire>  innerWires  = new List <Wire>();

            foreach (BrepLoop ghLoop in ghLoops)
            {
                BrepTrimList ghTrims       = ghLoop.Trims;
                List <Edge>  trimmingEdges = new List <Edge>();
                foreach (BrepTrim ghTrim in ghTrims)
                {
                    BrepEdge ghEdge = ghTrim.Edge;
                    if (ghEdge == null)
                    {
                        continue;
                        //throw new Exception("An invalid Rhino edge is encountered.");
                    }

                    Topology topology = ByCurve(ghEdge.DuplicateCurve());

                    // Edge or Wire?
                    Edge trimmingEdge = topology as Edge;
                    if (trimmingEdge != null)
                    {
                        trimmingEdges.Add(trimmingEdge);
                    }

                    Wire partialTrimmingWire = topology as Wire;
                    if (partialTrimmingWire != null)
                    {
                        List <Edge> partialTrimmingEdges = partialTrimmingWire.Edges;
                        trimmingEdges.AddRange(partialTrimmingEdges);
                    }
                }
                Wire          trimmingWire     = Wire.ByEdges(trimmingEdges);
                List <Vertex> trimmingVertices = trimmingWire.Vertices;

                if (ghLoop == ghOuterLoop)
                {
                    outerWire = trimmingWire;
                }
                else
                {
                    innerWires.Add(trimmingWire);
                }
            }

            Face outerTrimmedFace = Topologic.Utilities.FaceUtility.TrimByWire(untrimmedFace, outerWire, true);
            Face finalFace        = outerTrimmedFace.AddInternalBoundaries(innerWires);

            return(finalFace);
        }
 private bool IsSurfaceInPlane(Surface surface, Plane plane, double tolerance)
 {
   if (!surface.IsPlanar(tolerance))
     return false;
  
   var bbox = surface.GetBoundingBox(true);
   return bbox.GetCorners().All(
     corner => System.Math.Abs(plane.DistanceTo(corner)) <= tolerance);
 }
 /// <summary>
 /// Initializes a new instance of the WorldBoxEnvironmentComponent class.
 /// </summary>
 public SurfaceEnvironmentComponentOld()
   : base(RS.surfaceEnvironmentName, RS.surfaceEnvironmentComponentNickname,
       RS.surfaceEnvironmentDescription, RS.icon_srfEnvironment, RS.surfaceEnvironmentOldGuid)
 {
   Point3d pt1 = Point3d.Origin;
   Point3d pt2 = new Point3d(RS.boxBoundsDefault, 0, 0);
   Point3d pt3 = new Point3d(0, RS.boxBoundsDefault, 0);
   srf = NurbsSurface.CreateFromCorners(pt1, pt2, pt3);
 }
        static internal BRepBuilderSurfaceGeometry Convert(Rhino.Geometry.Surface faceSurface)
        {
            switch (faceSurface)
            {
            case Rhino.Geometry.NurbsSurface nurbsSurface:

                var degreeU       = nurbsSurface.Degree(0);
                var degreeV       = nurbsSurface.Degree(1);
                var knotsU        = Convert(nurbsSurface.KnotsU);
                var knotsV        = Convert(nurbsSurface.KnotsV);
                var controlPoints = Convert(nurbsSurface.Points);

                Debug.Assert(degreeU >= 1);
                Debug.Assert(degreeV >= 1);
                Debug.Assert(knotsU.Count >= 2 * (degreeU + 1));
                Debug.Assert(knotsV.Count >= 2 * (degreeV + 1));
                Debug.Assert(controlPoints.Count == (knotsU.Count - degreeU - 1) * (knotsV.Count - degreeV - 1));

                try
                {
                    if (nurbsSurface.IsRational)
                    {
                        var weights = new List <double>(controlPoints.Count);
                        foreach (var p in nurbsSurface.Points)
                        {
                            Debug.Assert(p.Weight > 0.0);
                            weights.Add(p.Weight);
                        }

                        return(BRepBuilderSurfaceGeometry.CreateNURBSSurface
                               (
                                   degreeU, degreeV, knotsU, knotsV, controlPoints, weights, false, null
                               ));
                    }
                    else
                    {
                        return(BRepBuilderSurfaceGeometry.CreateNURBSSurface
                               (
                                   degreeU, degreeV, knotsU, knotsV, controlPoints, false, null
                               ));
                    }
                }
                catch (Autodesk.Revit.Exceptions.ApplicationException e)
                {
                    Debug.Fail(e.Source, e.Message);
                    return(null);
                }
            }

            return(Convert(faceSurface.ToNurbsSurface()));
        }
        private static rg.Brep ExtrudeBrep(rg.Brep brep, rg.Vector3d dir)
        {
            if (dir.IsZero)
            {
                return(brep);
            }
            List <rg.Curve> edgeCurves = new List <rg.Curve>();
            List <rg.Brep>  breps;

            checked
            {
                int num = brep.Edges.Count - 1;
                for (int i = 0; i <= num; i++)
                {
                    if (brep.Edges[i].TrimCount == 1)
                    {
                        rg.Curve item = brep.Edges[i].DuplicateCurve();
                        edgeCurves.Add(item);
                    }
                }
                if (edgeCurves.Count == 0)
                {
                    return(brep);
                }
                breps = new List <rg.Brep>()
                {
                    brep
                };
                int num2 = edgeCurves.Count - 1;
                for (int j = 0; j <= num2; j++)
                {
                    rg.Surface extrusion = Rhino.Compute.SurfaceCompute.CreateExtrusion(edgeCurves[j], dir);
                    if (extrusion != null)
                    {
                        rg.Brep val2 = extrusion.ToBrep();
                        // val2.Faces.SplitKinkyFaces();
                        breps.Add(val2);
                    }
                }
                rg.Brep topFace = brep.DuplicateBrep();
                topFace.Translate(dir);
                breps.Add(topFace);
            }
            rg.Brep[] array = Rhino.Compute.BrepCompute.JoinBreps(breps, 0.0001);
            if (array == null)
            {
                return(brep);
            }
            return(array[0]);
        }
示例#11
0
        private Topologic.Face BySurface(Rhino.Geometry.Surface ghSurface)
        {
            SumSurface ghSumSurface = ghSurface as SumSurface;

            if (ghSumSurface != null)
            {
                return(BySumSurface(ghSumSurface));
            }

            RevSurface ghRevSurface = ghSurface as RevSurface;

            if (ghRevSurface != null)
            {
                return(ByRevSurface(ghRevSurface));
            }

            PlaneSurface ghPlaneSurface = ghSurface as PlaneSurface;

            if (ghPlaneSurface != null)
            {
                return(ByPlaneSurface(ghPlaneSurface));
            }

            //ClippingPlaneSurface ghClippingPlaneSurface = ghSurface as ClippingPlaneSurface;
            //if (ghClippingPlaneSurface != null)
            //{
            //    return ByClippingPlaneSurface(ghClippingPlaneSurface);
            //}

            Extrusion ghExtrusion = ghSurface as Extrusion;

            if (ghExtrusion != null)
            {
                return(ByExtrusion(ghExtrusion));
            }

            Rhino.Geometry.NurbsSurface ghNurbsSurface = ghSurface as Rhino.Geometry.NurbsSurface;
            if (ghNurbsSurface != null)
            {
                return(ByNurbsSurface(ghNurbsSurface));
            }

            //BrepFace ghBrepFace = ghSurface as BrepFace;
            //if (ghBrepFace != null)
            //{
            //    return ByBrepFace(ghBrepFace);
            //}

            throw new Exception("This type of surface is not yet supported.");
        }
示例#12
0
        /***************************************************/

        public static BHG.ISurface FromRhino(this RHG.Surface surface)
        {
            if (surface == null)
            {
                return(null);
            }

            if (surface.IsPlanar(BHG.Tolerance.Distance))
            {
                BHG.ICurve externalEdge = RHG.Curve.JoinCurves(surface.ToBrep().DuplicateNakedEdgeCurves(true, false)).FirstOrDefault().FromRhino();
                return(new BHG.PlanarSurface(externalEdge, new List <oM.Geometry.ICurve>()));
            }

            return(surface.ToNurbsSurface().FromRhino());
        }
示例#13
0
    // Copy Constructor
    public SurfaceEnvironmentType(SurfaceEnvironmentType environment)
    {
      this.environment = environment.environment;
      Width = environment.Width;
      Height = environment.Height;
      Wrap = environment.Wrap;
      RefEnvironment = environment.RefEnvironment;

      Interval uDom = RefEnvironment.Domain(0);
      Interval vDom = RefEnvironment.Domain(1);

      minX = uDom.Min;
      maxX = uDom.Max;
      minY = vDom.Min;
      maxY = vDom.Max;
    }
示例#14
0
        public static global::Topologic.Face ToTopologic(this Rhino.Geometry.Surface surface)
        {
            if (surface == null)
            {
                return(null);
            }

            SumSurface sumSurface = surface as SumSurface;

            if (sumSurface != null)
            {
                return(sumSurface.ToTopologic());
            }

            RevSurface revSurface = surface as RevSurface;

            if (revSurface != null)
            {
                return(revSurface.ToTopologic());
            }

            PlaneSurface planeSurface = surface as PlaneSurface;

            if (planeSurface != null)
            {
                return(planeSurface.ToTopologic());
            }

            Rhino.Geometry.Extrusion ghExtrusion = surface as Rhino.Geometry.Extrusion;
            if (ghExtrusion != null)
            {
                return(ghExtrusion.ToTopologic());
            }

            Rhino.Geometry.NurbsSurface ghNurbsSurface = surface as Rhino.Geometry.NurbsSurface;
            if (ghNurbsSurface != null)
            {
                return(ghNurbsSurface.ToTopologic());
            }


            return(null);
        }
示例#15
0
 //initialize data
 //double w_interval;
 //public double UMin { get; private set; }
 //public double UMax { get; private set; }
 //public double VMin { get; private set; }
 //public double VMax { get; private set; }
 //public double WMin { get; private set; }
 //public double WMax { get; private set; }
 public SurfaceEnvironmentType(Surface srf, int x, int y, int z)
     : base(x, y, 1)
 {
     _srf = srf;
     //UMin = _box.Min.X;
     //UMax = _box.Max.X;
     //VMin = _box.Min.Y;
     //VMax = _box.Max.Y;
        // WMin = _box.Min.Z;
     //WMax = _box.Max.Z;
     uv_positions = new Point3d[u,v,1];
     u_interval = _srf.Domain(0).Length / u;
     v_interval = _srf.Domain(1).Length / v;
     //w_interval = (WMax - WMin) / w;
     trail = new float[u, v, 1];
     temptrail = new float[u, v, 1];
     particle_ids = new int[u, v, 1];
     griddata = new int[u, v, 1];
     agedata = new int[u, v, 1];
     grid_age = 0;
     for (int i = 0; i < u; i++)
     {
         for (int j = 0; j < v; j++)
         {
             //for (int k = 0; k < w; k++)
             //{
                 uv_positions[i, j, 0] = _srf.PointAt(i * u_interval + u_interval / 2, j * v_interval + v_interval / 2);
                 trail[i, j, 0] = 0;
                 temptrail[i, j, 0] = 0;
                 particle_ids[i, j, 0] = -2;
                 griddata[i, j, 0] = 2;
                 agedata[i, j, 0] = 0;
             //}
         }
     }
     projectvalue = 5;
     diffdamp = 0.1F;
     age_flag = false;
     _escape_p = 0;
     env_type = 2;
 }
示例#16
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/


        private static BHG.ISolid ToBHoMSolid(this RHG.Brep brep)
        {
            RHG.Surface surface = brep.Surfaces.FirstOrDefault();
            switch (brep.Surfaces.Count)
            {
            case 1:
                RHG.Sphere sphere;
                if (surface.TryGetSphere(out sphere))
                {
                    return(sphere.FromRhino());
                }
                RHG.Torus torus;
                if (surface.TryGetTorus(out torus))
                {
                    return(torus.FromRhino());
                }
                break;

            case 2:
                RHG.Cone cone;
                if (surface.TryGetCone(out cone))
                {
                    return(cone.FromRhino());
                }
                break;

            case 3:
                RHG.Cylinder cylinder;
                if (surface.TryGetCylinder(out cylinder))
                {
                    return(cylinder.FromRhino());
                }
                break;
            }

            return(new BHG.BoundaryRepresentation(brep.Faces.Select(s => s.FromRhino()).ToList(), brep.GetVolume()));
        }
示例#17
0
        /***************************************************/

        private static BHG.NurbsSurface ToBHoMNurbsSurface(this RHG.BrepFace face)
        {
            RHG.Surface rhSurf = face.UnderlyingSurface();
            if (rhSurf == null)
            {
                return(null);
            }

            RHG.NurbsSurface       rhNurbsSurf = rhSurf.ToNurbsSurface();
            List <BHG.SurfaceTrim> innerTrims  = new List <BHG.SurfaceTrim>();
            List <BHG.SurfaceTrim> outerTrims  = new List <BHG.SurfaceTrim>();

            foreach (RHG.BrepLoop loop in face.Loops)
            {
                if (loop.LoopType == RHG.BrepLoopType.Outer)
                {
                    outerTrims.Add(loop.FromRhino());
                }
                else
                {
                    innerTrims.Add(loop.FromRhino());
                }
            }

            return(new BHG.NurbsSurface
                   (
                       rhNurbsSurf.Points.Select(x => x.Location.FromRhino()).ToList(),
                       rhNurbsSurf.Points.Select(x => x.Weight).ToList(),
                       rhNurbsSurf.KnotsU.ToList(),
                       rhNurbsSurf.KnotsV.ToList(),
                       rhNurbsSurf.Degree(0),
                       rhNurbsSurf.Degree(1),
                       innerTrims,
                       outerTrims
                   ));
        }
示例#18
0
    // Default Constructor.
    public SurfaceEnvironmentType()
    {
      Point3d pt1 = new Point3d(0, 0, 0);
      Point3d pt2 = new Point3d(RS.boxBoundsDefault, 0, 0);
      Point3d pt3 = new Point3d(0, RS.boxBoundsDefault, 0);
      environment = NurbsSurface.CreateFromCorners(pt1, pt2, pt3);
      Interval u = environment.Domain(0);
      Interval v = environment.Domain(1);
      pt1 = new Point3d(u.Min, v.Min, 0);
      pt2 = new Point3d(u.Max, v.Min, 0);
      pt3 = new Point3d(u.Min, v.Max, 0);
      RefEnvironment = NurbsSurface.CreateFromCorners(pt1, pt2, pt3);

      Interval uDom = RefEnvironment.Domain(0);
      Interval vDom = RefEnvironment.Domain(1);

      minX = uDom.Min;
      maxX = uDom.Max;
      minY = vDom.Min;
      maxY = vDom.Max;

      Width = maxX - minX;
      Height = maxY - minY;
    }
示例#19
0
    /// <summary>
    /// Compute the VolumeMassProperties for a single Surface.
    /// </summary>
    /// <param name="surface">Surface to measure.</param>
    /// <returns>The VolumeMassProperties for the given Surface or null on failure.</returns>
    /// <exception cref="System.ArgumentNullException">When surface is null.</exception>
    public static VolumeMassProperties Compute(Surface surface)
    {
      if (surface == null)
        throw new ArgumentNullException("surface");

      IntPtr pSurface = surface.ConstPointer();
      const double relativeTolerance = 1.0e-6;
      const double absoluteTolerance = 1.0e-6;
      IntPtr rc = UnsafeNativeMethods.ON_Surface_MassProperties(false, pSurface, relativeTolerance, absoluteTolerance);
      return IntPtr.Zero == rc ? null : new VolumeMassProperties(rc, false);
    }
示例#20
0
    internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobject_index)
    {
      if (IntPtr.Zero == pGeometry)
        return null;

      int type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);
      if (type < 0)
        return null;
      GeometryBase rc = null;

      switch (type)
      {
        case idxON_Curve: //1
          rc = new Curve(pGeometry, parent, subobject_index);
          break;
        case idxON_NurbsCurve: //2
          rc = new NurbsCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolyCurve: // 3
          rc = new PolyCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolylineCurve: //4
          rc = new PolylineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_ArcCurve: //5
          rc = new ArcCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_LineCurve: //6
          rc = new LineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_Mesh: //7
          rc = new Mesh(pGeometry, parent);
          break;
        case idxON_Point: //8
          rc = new Point(pGeometry, parent);
          break;
        case idxON_TextDot: //9
          rc = new TextDot(pGeometry, parent);
          break;
        case idxON_Surface: //10
          rc = new Surface(pGeometry, parent);
          break;
        case idxON_Brep: //11
          rc = new Brep(pGeometry, parent);
          break;
        case idxON_NurbsSurface: //12
          rc = new NurbsSurface(pGeometry, parent);
          break;
        case idxON_RevSurface: //13
          rc = new RevSurface(pGeometry, parent);
          break;
        case idxON_PlaneSurface: //14
          rc = new PlaneSurface(pGeometry, parent);
          break;
        case idxON_ClippingPlaneSurface: //15
          rc = new ClippingPlaneSurface(pGeometry, parent);
          break;
        case idxON_Annotation2: // 16
          rc = new AnnotationBase(pGeometry, parent);
          break;
        case idxON_Hatch: // 17
          rc = new Hatch(pGeometry, parent);
          break;
        case idxON_TextEntity2: //18
          rc = new TextEntity(pGeometry, parent);
          break;
        case idxON_SumSurface: //19
          rc = new SumSurface(pGeometry, parent);
          break;
        case idxON_BrepFace: //20
          {
            int faceindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
            if (pBrep != IntPtr.Zero && faceindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Faces[faceindex];
            }
          }
          break;
        case idxON_BrepEdge: // 21
          {
            int edgeindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
            if (pBrep != IntPtr.Zero && edgeindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Edges[edgeindex];
            }
          }
          break;
        case idxON_InstanceDefinition: // 22
          rc = new InstanceDefinitionGeometry(pGeometry, parent);
          break;
        case idxON_InstanceReference: // 23
          rc = new InstanceReferenceGeometry(pGeometry, parent);
          break;
#if USING_V5_SDK
        case idxON_Extrusion: //24
          rc = new Extrusion(pGeometry, parent);
          break;
#endif
        case idxON_LinearDimension2: //25
          rc = new LinearDimension(pGeometry, parent);
          break;
        case idxON_PointCloud: // 26
          rc = new PointCloud(pGeometry, parent);
          break;
        case idxON_DetailView: // 27
          rc = new DetailView(pGeometry, parent);
          break;
        case idxON_AngularDimension2: // 28
          rc = new AngularDimension(pGeometry, parent);
          break;
        case idxON_RadialDimension2: // 29
          rc = new RadialDimension(pGeometry, parent);
          break;
        case idxON_Leader: // 30
          rc = new Leader(pGeometry, parent);
          break;
        case idxON_OrdinateDimension2: // 31
          rc = new OrdinateDimension(pGeometry, parent);
          break;
        case idxON_Light: //32
          rc = new Light(pGeometry, parent);
          break;
        case idxON_PointGrid: //33
          rc = new Point3dGrid(pGeometry, parent);
          break;
        case idxON_MorphControl: //34
          rc = new MorphControl(pGeometry, parent);
          break;
        case idxON_BrepLoop: //35
          {
            int loopindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
            if (pBrep != IntPtr.Zero && loopindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Loops[loopindex];
            }
          }
          break;
        case idxON_BrepTrim: // 36
          {
            int trimindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
            if (pBrep != IntPtr.Zero && trimindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Trims[trimindex];
            }
          }
          break;
        default:
          rc = new UnknownGeometry(pGeometry, parent, subobject_index);
          break;
      }

      return rc;
    }
示例#21
0
        public void SetInputs(List <DataTree <ResthopperObject> > values)
        {
            foreach (var tree in values)
            {
                if (!_input.TryGetValue(tree.ParamName, out var inputGroup))
                {
                    continue;
                }

                if (inputGroup.AlreadySet(tree))
                {
                    LogDebug("Skipping input tree... same input");
                    continue;
                }

                inputGroup.CacheTree(tree);

                IGH_ContextualParameter contextualParameter = inputGroup.Param as IGH_ContextualParameter;
                if (contextualParameter != null)
                {
                    switch (ParamTypeName(inputGroup.Param))
                    {
                    case "Number":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            double[] doubles = new double[entree.Value.Count];
                            for (int i = 0; i < doubles.Length; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                doubles[i] = JsonConvert.DeserializeObject <double>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(doubles);
                            break;
                        }
                    }
                    break;

                    case "Integer":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            int[] integers = new int[entree.Value.Count];
                            for (int i = 0; i < integers.Length; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                integers[i] = JsonConvert.DeserializeObject <int>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(integers);
                            break;
                        }
                    }
                    break;

                    case "Point":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            Point3d[] points = new Point3d[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                points[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(points);
                            break;
                        }
                    }
                    break;

                    case "Line":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            Line[] lines = new Line[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                lines[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(lines);
                            break;
                        }
                    }
                    break;

                    case "Text":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            string[] strings = new string[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                strings[i] = restobj.Data.Trim(new char[] { '"' });
                            }
                            contextualParameter.AssignContextualData(strings);
                            break;
                        }
                    }
                    break;

                    case "Geometry":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            GeometryBase[] geometries = new GeometryBase[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                geometries[i] = Rhino.Runtime.CommonObject.FromJSON(dict) as GeometryBase;
                            }
                            contextualParameter.AssignContextualData(geometries);
                            break;
                        }
                    }
                    break;
                    }
                    continue;
                }

                inputGroup.Param.VolatileData.Clear();
                inputGroup.Param.ExpireSolution(false); // mark param as expired but don't recompute just yet!

                if (inputGroup.Param is Param_Point)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj = entree.Value[i];
                            Rhino.Geometry.Point3d rPt     = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            GH_Point data = new GH_Point(rPt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Vector)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject        restobj  = entree.Value[i];
                            Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data);
                            GH_Vector data = new GH_Vector(rhVector);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Integer)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            int        rhinoInt      = JsonConvert.DeserializeObject <int>(restobj.Data);
                            GH_Integer data          = new GH_Integer(rhinoInt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Number)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_String)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = restobj.Data;
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Line)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Line rhLine  = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            GH_Line             data    = new GH_Line(rhLine);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Curve)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            GH_Curve         ghCurve;
                            try
                            {
                                Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data);
                                Rhino.Geometry.Curve    c    = new Rhino.Geometry.PolylineCurve(data);
                                ghCurve = new GH_Curve(c);
                            }
                            catch
                            {
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                var c    = (Rhino.Geometry.Curve)Rhino.Runtime.CommonObject.FromJSON(dict);
                                ghCurve = new GH_Curve(c);
                            }
                            inputGroup.Param.AddVolatileData(path, i, ghCurve);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Circle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject      restobj  = entree.Value[i];
                            Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data);
                            GH_Circle             data     = new GH_Circle(rhCircle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Plane)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject     restobj = entree.Value[i];
                            Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data);
                            GH_Plane             data    = new GH_Plane(rhPlane);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Rectangle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject           restobj     = entree.Value[i];
                            Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data);
                            GH_Rectangle data = new GH_Rectangle(rhRectangle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Box)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject   restobj = entree.Value[i];
                            Rhino.Geometry.Box rhBox   = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data);
                            GH_Box             data    = new GH_Box(rhBox);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Surface)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj   = entree.Value[i];
                            Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data);
                            GH_Surface             data      = new GH_Surface(rhSurface);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Brep)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Brep rhBrep  = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data);
                            GH_Brep             data    = new GH_Brep(rhBrep);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Mesh)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Mesh rhMesh  = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data);
                            GH_Mesh             data    = new GH_Mesh(rhMesh);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_NumberSlider)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Boolean || inputGroup.Param is GH_BooleanToggle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            bool             boolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                            GH_Boolean       data    = new GH_Boolean(boolean);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_Panel)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }
            }
        }
 /// <summary>
 /// Constructs a periodic surface from a base surface and a direction.
 /// </summary>
 /// <param name="baseSurface">A base surface.</param>
 /// <param name="direction">0 is first parameter, 1 is second parameter.</param>
 /// <returns>A new surface; or null on error.</returns>
 public static Surface CreatePeriodicSurface(Surface baseSurface, int direction)
 {
   IntPtr const_ptr_surface = baseSurface.ConstPointer();
   IntPtr ptr_new_surface = UnsafeNativeMethods.TL_Surface_MakePeriodic(const_ptr_surface, direction);
   return CreateGeometryHelper(ptr_new_surface, null) as Surface;
 }
示例#23
0
    /// <summary>
    /// Offset this curve on a surface. This curve must lie on the surface.
    /// <para>This overload allows to specify different offsets for different curve parameters.</para>
    /// </summary>
    /// <param name="surface">A surface on which to offset.</param>
    /// <param name="curveParameters">Curve parameters corresponding to the offset distances.</param>
    /// <param name="offsetDistances">Distances to offset (+)left, (-)right.</param>
    /// <param name="fittingTolerance">A fitting tolerance.</param>
    /// <returns>Offset curves on success, or null on failure.</returns>
    /// <exception cref="ArgumentNullException">If surface, curveParameters or offsetDistances are null.</exception>
    public Curve[] OffsetOnSurface(Surface surface, double[] curveParameters, double[] offsetDistances, double fittingTolerance)
    {
      if (surface == null)
        throw new ArgumentNullException("surface");

      Brep b = Brep.CreateFromSurface(surface);
      return OffsetOnSurface(b.Faces[0], curveParameters, offsetDistances, fittingTolerance);
    }
        /***************************************************/

        public static void RenderRhinoMeshes(RHG.Surface surface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material)
        {
            pipeline.DrawBrepShaded(surface.ToBrep(), material);
        }
        public void SetInputs(List <DataTree <ResthopperObject> > values)
        {
            foreach (var tree in values)
            {
                if (!_input.TryGetValue(tree.ParamName, out var inputGroup))
                {
                    continue;
                }

                if (inputGroup.AlreadySet(tree))
                {
                    Console.WriteLine("Skipping input tree... same input");
                    continue;
                }

                inputGroup.CacheTree(tree);
                inputGroup.Param.VolatileData.Clear();
                inputGroup.Param.ExpireSolution(true);

                if (inputGroup.Param is Param_Point)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj = entree.Value[i];
                            Rhino.Geometry.Point3d rPt     = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            GH_Point data = new GH_Point(rPt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Vector)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject        restobj  = entree.Value[i];
                            Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data);
                            GH_Vector data = new GH_Vector(rhVector);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Integer)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            int        rhinoInt      = JsonConvert.DeserializeObject <int>(restobj.Data);
                            GH_Integer data          = new GH_Integer(rhinoInt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Number)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_String)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = restobj.Data;
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Line)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Line rhLine  = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            GH_Line             data    = new GH_Line(rhLine);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Curve)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            GH_Curve         ghCurve;
                            try
                            {
                                Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data);
                                Rhino.Geometry.Curve    c    = new Rhino.Geometry.PolylineCurve(data);
                                ghCurve = new GH_Curve(c);
                            }
                            catch
                            {
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                var c    = (Rhino.Geometry.Curve)Rhino.Runtime.CommonObject.FromJSON(dict);
                                ghCurve = new GH_Curve(c);
                            }
                            inputGroup.Param.AddVolatileData(path, i, ghCurve);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Circle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject      restobj  = entree.Value[i];
                            Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data);
                            GH_Circle             data     = new GH_Circle(rhCircle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Plane)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject     restobj = entree.Value[i];
                            Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data);
                            GH_Plane             data    = new GH_Plane(rhPlane);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Rectangle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject           restobj     = entree.Value[i];
                            Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data);
                            GH_Rectangle data = new GH_Rectangle(rhRectangle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Box)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject   restobj = entree.Value[i];
                            Rhino.Geometry.Box rhBox   = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data);
                            GH_Box             data    = new GH_Box(rhBox);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Surface)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj   = entree.Value[i];
                            Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data);
                            GH_Surface             data      = new GH_Surface(rhSurface);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Brep)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Brep rhBrep  = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data);
                            GH_Brep             data    = new GH_Brep(rhBrep);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Mesh)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Mesh rhMesh  = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data);
                            GH_Mesh             data    = new GH_Mesh(rhMesh);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_NumberSlider)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Boolean || inputGroup.Param is GH_BooleanToggle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            bool             boolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                            GH_Boolean       data    = new GH_Boolean(boolean);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_Panel)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }
            }
        }
示例#26
0
 /// <summary>
 /// Copies the unmanaged array to a managed counterpart.
 /// Elements are made non-const.
 /// </summary>
 /// <returns>The managed array.</returns>
 public Surface[] ToNonConstArray()
 {
   int count = UnsafeNativeMethods.ON_SurfaceArray_Count(m_ptr);
   if (count < 1)
     return new Surface[0];
   Surface[] rc = new Surface[count];
   for (int i = 0; i < count; i++)
   {
     IntPtr surface = UnsafeNativeMethods.ON_SurfaceArray_Get(m_ptr, i);
     if (IntPtr.Zero == surface)
       continue;
     rc[i] = GeometryBase.CreateGeometryHelper(surface, null) as Surface;
   }
   return rc;
 }
示例#27
0
 // Copy Constructor
 public SurfaceEmitterType(SurfaceEmitterType e)
   : base(e.continuousFlow, e.creationRate, e.numAgents, e.velocityMin, e.velocityMax)
 {
   srf = e.srf;
 }
示例#28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Unroller"/> class with surface.
 /// </summary>
 /// <param name="surface">A surface to be unrolled.</param>
 public Unroller(Surface surface)
 {
   m_surface = surface;
 }
    /// <summary>
    /// Constructs a rolling ball fillet between two surfaces.
    /// </summary>
    /// <param name="surfaceA">A first surface.</param>
    /// <param name="flipA">A value that indicates whether A should be used in flipped mode.</param>
    /// <param name="surfaceB">A second surface.</param>
    /// <param name="flipB">A value that indicates whether B should be used in flipped mode.</param>
    /// <param name="radius">A radius value.</param>
    /// <param name="tolerance">A tolerance value.</param>
    /// <returns>A new array of rolling ball fillet surfaces; this array can be empty on failure.</returns>
    /// <exception cref="ArgumentNullException">If surfaceA or surfaceB are null.</exception>
    public static Surface[] CreateRollingBallFillet(Surface surfaceA, bool flipA, Surface surfaceB, bool flipB, double radius, double tolerance)
    {
      if (surfaceA == null) throw new ArgumentNullException("surfaceA");
      if (surfaceB == null) throw new ArgumentNullException("surfaceB");

      IntPtr const_ptr_surface_a = surfaceA.ConstPointer();
      IntPtr const_ptr_surface_b = surfaceB.ConstPointer();
      using (Runtime.InteropWrappers.SimpleArraySurfacePointer srfs = new Runtime.InteropWrappers.SimpleArraySurfacePointer())
      {
        IntPtr ptr_surfaces = srfs.NonConstPointer();
        UnsafeNativeMethods.RHC_RhinoSimpleRollingBallFillet(const_ptr_surface_a, flipA,
          const_ptr_surface_b, flipB, radius, tolerance, ptr_surfaces);
        return srfs.ToNonConstArray();
      }
    }
示例#30
0
    /// <summary>
    /// Extends a curve on a surface.
    /// </summary>
    /// <param name="side">The end of the curve to extend.</param>
    /// <param name="surface">Surface that contains the curve.</param>
    /// <returns>New extended curve result on success, null on failure.</returns>
    public Curve ExtendOnSurface(CurveEnd side, Surface surface)
    {
      if (surface == null) { throw new ArgumentNullException("surface"); }
      Brep brep = surface.ToBrep();
      if (brep == null) { return null; }

      return ExtendOnSurface(side, brep.Faces[0]);
    }
示例#31
0
    /// <summary>
    /// Constructs a rolling ball fillet between two surfaces.
    /// </summary>
    /// <param name="surfaceA">A first surface.</param>
    /// <param name="uvA">A point in the parameter space of FaceA near where the fillet is expected to hit the surface.</param>
    /// <param name="surfaceB">A second surface.</param>
    /// <param name="uvB">A point in the parameter space of FaceB near where the fillet is expected to hit the surface.</param>
    /// <param name="radius">A radius value.</param>
    /// <param name="tolerance">A tolerance value used for approximating and intersecting offset surfaces.</param>
    /// <returns>A new array of rolling ball fillet surfaces; this array can be empty on failure.</returns>
    /// <exception cref="ArgumentNullException">If surfaceA or surfaceB are null.</exception>
    public static Surface[] CreateRollingBallFillet(Surface surfaceA, Point2d uvA, Surface surfaceB, Point2d uvB, double radius, double tolerance)
    {
      if (surfaceA == null) throw new ArgumentNullException("surfaceA");
      if (surfaceB == null) throw new ArgumentNullException("surfaceB");

      IntPtr pConstSurfaceA = surfaceA.ConstPointer();
      IntPtr pConstSurfaceB = surfaceB.ConstPointer();
      using (Runtime.InteropWrappers.SimpleArraySurfacePointer srfs = new Rhino.Runtime.InteropWrappers.SimpleArraySurfacePointer())
      {
        IntPtr pSurfaces = srfs.NonConstPointer();
        UnsafeNativeMethods.RHC_RhinoSimpleRollingBallFillet2(pConstSurfaceA, uvA,
          pConstSurfaceB, uvB, radius, tolerance, pSurfaces);
        return srfs.ToNonConstArray();
      }
    }
示例#32
0
文件: FromRC.cs 项目: lulzzz/Nucleus
 /// <summary>
 /// Convert a Rhino surface to a Nucleus one
 /// </summary>
 /// <param name="surface"></param>
 /// <returns></returns>
 public static Surface Convert(RC.Surface surface)
 {
     return(Convert(surface.ToBrep()));
 }
示例#33
0
 public void computeNormal(Surface s)
 {
     double u, v;
     s.ClosestPoint(this.pos, out u, out v);
     N = s.NormalAt(u, v);
 }
示例#34
0
        /***************************************************/

        public static void RenderWires(BHG.Loft surface, Rhino.Display.DisplayPipeline pipeline, Color bhColour)
        {
            RHG.Surface rSurface = surface.ToRhino();
            pipeline.DrawSurface(rSurface, bhColour, 2);
        }
示例#35
0
 /// <summary>
 /// Splits a curve into pieces using a surface.
 /// </summary>
 /// <param name="cutter">A cutting surface or polysurface.</param>
 /// <param name="tolerance">A tolerance for computing intersections.</param>
 /// <returns>An array of curves. This array can be empty.</returns>
 public Curve[] Split(Surface cutter, double tolerance)
 {
   IntPtr pConstThis = ConstPointer();
   IntPtr pConstSurface = cutter.ConstPointer();
   using (Rhino.Runtime.InteropWrappers.SimpleArrayCurvePointer pieces = new SimpleArrayCurvePointer())
   {
     IntPtr pPieces = pieces.NonConstPointer();
     UnsafeNativeMethods.RHC_RhinoCurveSplit(pConstThis, pConstSurface, tolerance, pPieces);
     return pieces.ToNonConstArray();
   }
 }
示例#36
0
        private Brep ToSurface(Face face, double tolerance)
        {
            Rhino.Geometry.Surface ghSurface = ToRhinoSurface(face);

            double width = 0.0, height = 0.0;
            bool   canGetSurfaceSize = ghSurface.GetSurfaceSize(out width, out height);

            if (!canGetSurfaceSize)
            {
                throw new Exception("Fails to get the surface size.");
            }
            double maxSize          = Math.Max(width, height);
            double maxSizeAndMargin = maxSize + 2;

            ghSurface = ghSurface.Extend(IsoStatus.North, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.South, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.West, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.East, maxSizeAndMargin, true);
            //List<Wire> wires = face.Wires;

            //List<GeometryBase> ghGeometryBases = new List<GeometryBase>();
            //foreach (Wire wire in wires)
            //{
            //    List<Object> ghCurves = ToCurves(wire);
            //    foreach (Object ghCurve in ghCurves)
            //    {
            //        GeometryBase geometryBase = ghCurve as GeometryBase;
            //        if (geometryBase != null)
            //        {
            //            ghGeometryBases.Add(geometryBase);
            //        }
            //    }
            //}


            //2.Create the Brep
            //Brep ghBrep = ghNurbsSurface.ToBrep();
            //Brep ghBrep = new Brep();

            //// 2a. Add vertices
            //List<Vertex> vertices = face.Vertices;
            //foreach (Vertex vertex in vertices)
            //{
            //    Point3d ghPoint = ToPoint(vertex);
            //    BrepVertex ghBrepVertex = ghBrep.Vertices.Add(ghPoint, 0.0);

            //    String ghBrepVertexLog = "";
            //    if (!ghBrepVertex.IsValidWithLog(out ghBrepVertexLog))
            //    {
            //        throw new Exception("Fails to create a valid BrepVertex with the following message: " + ghBrepVertexLog);
            //    }
            //}

            //// 2b. Add 3D curves and edges. The index dictionaries are used to identify the IDs of the edges.
            //List<Edge> edges = face.Edges;
            //Dictionary<Edge, Tuple<int, int>> edge2DIndices = new Dictionary<Edge, Tuple<int, int>>(); // edge, curve, reverse curve
            //Dictionary<Edge, int> edge3DIndices = new Dictionary<Edge, int>();
            //Dictionary<Edge, BrepEdge> edgeIndices = new Dictionary<Edge, BrepEdge>();
            //foreach (Edge edge in edges)
            //{
            //    Curve ghCurve3D = ToCurve(edge);
            //    Curve ghCurve2D = ghSurface.Pullback(ghCurve3D, 0.0001);

            //    // 2D curves --> need to check if the endpoints are near to previously generated points
            //    // if yes, change the value

            //    int curve3DID = ghBrep.Curves3D.Add(ghCurve3D);
            //    int curve2DID = ghBrep.Curves2D.Add(ghCurve2D);

            //    Curve ghReverseCurve2D = ghCurve2D.DuplicateCurve();
            //    ghReverseCurve2D.Reverse();
            //    int reverseCurve2DID = ghBrep.Curves2D.Add(ghReverseCurve2D);

            //    Point3d ghStartPoint = ghCurve3D.PointAtStart;
            //    Point3d ghEndPoint = ghCurve3D.PointAtEnd;

            //    int startVertexIndex = -1;
            //    int endVertexIndex = -1;
            //    foreach (BrepVertex ghBrepVertex in ghBrep.Vertices)
            //    {
            //        Point3d ghBrepPoint = ghBrepVertex.Location;

            //        if (startVertexIndex == -1 && ghBrepPoint.DistanceTo(ghStartPoint) < 0.0001)
            //        {
            //            startVertexIndex = ghBrepVertex.VertexIndex;
            //        }

            //        if (endVertexIndex == -1 && ghBrepPoint.DistanceTo(ghEndPoint) < 0.0001)
            //        {
            //            endVertexIndex = ghBrepVertex.VertexIndex;
            //        }
            //    }

            //    BrepEdge ghBrepEdge = ghBrep.Edges.Add(startVertexIndex, endVertexIndex, curve3DID, 0.0001);

            //    String brepEdgeLog = "";
            //    if (!ghBrepEdge.IsValidWithLog(out brepEdgeLog))
            //    {
            //        throw new Exception("Fails to create a valid BrepEdge with the following message: " + brepEdgeLog);
            //    }

            //    edge3DIndices.Add(edge, curve3DID);
            //    edge2DIndices.Add(edge, Tuple.Create(curve2DID, reverseCurve2DID));
            //    edgeIndices.Add(edge, ghBrepEdge);
            //}

            //// 2c. Add surface
            //int ghSurfaceIndex = ghBrep.AddSurface(ghSurface);

            //// 2d. Add face
            //BrepFace ghBrepFace = ghBrep.Faces.Add(ghSurfaceIndex);

            //// 2e. Create outer loop
            //Wire outerWire = face.ExternalBoundary;
            //ProcessFace(outerWire, ref ghBrep, ghBrepFace, BrepLoopType.Outer, ghSurface, edge2DIndices, edgeIndices);

            //// 2g. Create inner loops
            //List<Wire> innerWires = face.InternalBoundaries;
            //foreach (Wire innerWire in innerWires)
            //{
            //    ProcessFace(innerWire, ref ghBrep, ghBrepFace, BrepLoopType.Inner, ghSurface, edge2DIndices, edgeIndices);
            //}

            //String brepFaceLog = "";
            //if (!ghBrepFace.IsValidWithLog(out brepFaceLog))
            //{
            //    throw new Exception("Fails to create a valid Face with the following message: " + brepFaceLog);
            //}

            //ghBrep.Compact();

            List <GeometryBase> ghGeometryBases = new List <GeometryBase>();

            List <Edge>  outerEdges = face.ExternalBoundary.Edges;
            List <Curve> ghCurves   = new List <Curve>();

            foreach (Edge edge in outerEdges)
            {
                Curve ghCurve3D = ToCurve(edge);
                ghGeometryBases.Add(ghCurve3D);
                ghCurves.Add(ghCurve3D);
            }
            //ghGeometryBases.AddRange(ghBrep.Curves2D);
            //ghGeometryBases.AddRange(ghBrep.Trims);
            //ghGeometryBases.AddRange(ghBrep.Vertices);

            Brep ghBrep2 = Brep.CreatePatch(
                ghGeometryBases,
                ghSurface,
                20,
                20,
                true,
                true,
                tolerance,
                100.0,
                1,
                new Boolean[] { true, true, true, true },
                tolerance);
            //return ghBrep2; // always returns the trimmed surface

            BrepFace ghSurfaceAsBrepFace = ghSurface as BrepFace;

            if (ghBrep2 == null)
            {
                return(null);
            }

            List <Wire> internalBoundaries = face.InternalBoundaries;

            if (internalBoundaries.Count == 0)
            {
                return(ghBrep2);
            }

            BrepFace ghBrepFace = ghBrep2.Faces[0];
            //return ghBrepFace.ToBrep(); // may return the untrimmed surface!

            List <Curve> ghInternalCurves = new List <Curve>();

            foreach (Wire internalBoundary in internalBoundaries)
            {
                List <Object> ghCurvesFromWireAsObjects = ToCurves(internalBoundary);
                foreach (Object ghCurveFromWireAsObject in ghCurvesFromWireAsObjects)
                {
                    Curve ghCurveFromWire = ghCurveFromWireAsObject as Curve;
                    if (ghCurveFromWire != null)
                    {
                        Curve[] ghPulledCurveFromWire = ghCurveFromWire.PullToBrepFace(ghBrepFace, tolerance);
                        ghInternalCurves.AddRange(ghPulledCurveFromWire);
                    }
                }
            }
            //ghCurves.AddRange(ghInternalCurves);
            Brep ghBrep3 = ghBrepFace.Split(ghInternalCurves, tolerance);

            //return ghBrep3.Faces[0].DuplicateFace(true);
            return(ghBrep3.Faces.ExtractFace(0));
            //Brep[] ghBreps3 = ghBrep2.Split(ghInternalCurves, 0.0001);
            //return ghBreps3.First();


            //String brepLog = "";
            //if (!ghBrep.IsValidWithLog(out brepLog))
            //{
            //    throw new Exception("Fails to create a valid Brep with the following message: " + brepLog);
            //}

            //if (!ghBrep.IsValidGeometry(out brepLog))
            //{
            //    throw new Exception("Fails to create a valid Brep with the following message: " + brepLog);
            //}

            //if (!ghBrep.IsValidTopology(out brepLog))
            //{
            //    throw new Exception("Fails to create a valid Brep with the following message: " + brepLog);
            //}

            //if (!ghBrep.IsValidTolerancesAndFlags(out brepLog))
            //{
            //    throw new Exception("Fails to create a valid Brep with the following message: " + brepLog);
            //}


            //return ghBrep;
        }
示例#37
0
    /// <summary>
    /// Offset a curve on a surface. This curve must lie on the surface.
    /// <para>This overload allows to specify a surface point at which the offset will pass.</para>
    /// </summary>
    /// <param name="surface">A surface on which to offset.</param>
    /// <param name="throughPoint">2d point on the brep face to offset through.</param>
    /// <param name="fittingTolerance">A fitting tolerance.</param>
    /// <returns>Offset curves on success, or null on failure.</returns>
    /// <exception cref="ArgumentNullException">If surface is null.</exception>
    public Curve[] OffsetOnSurface(Surface surface, Point2d throughPoint, double fittingTolerance)
    {
      if (surface == null)
        throw new ArgumentNullException("surface");

      Brep b = Brep.CreateFromSurface(surface);
      return OffsetOnSurface(b.Faces[0], throughPoint, fittingTolerance);
    }
        public static Response Grasshopper(NancyContext ctx)
        {
            // load grasshopper file
            var archive = new GH_Archive();
            // TODO: stream to string
            var body = ctx.Request.Body.ToString();

            string json = string.Empty;

            using (var reader = new StreamReader(ctx.Request.Body))
            {
                json = reader.ReadToEnd();
            }

            //GrasshopperInput input = Newtonsoft.Json.JsonConvert.DeserializeObject<GrasshopperInput>(json);
            //JsonSerializerSettings settings = new JsonSerializerSettings();
            //settings.ContractResolver = new DictionaryAsArrayResolver();
            Schema input = JsonConvert.DeserializeObject <Schema>(json);

            string grasshopperXml = string.Empty;

            if (input.Algo != null)
            {
                // If request contains markup
                byte[] byteArray = Convert.FromBase64String(input.Algo);
                grasshopperXml = System.Text.Encoding.UTF8.GetString(byteArray);
            }
            else
            {
                // If request contains pointer
                string pointer = input.Pointer;
                grasshopperXml = GetGhxFromPointer(pointer);
            }
            if (!archive.Deserialize_Xml(grasshopperXml))
            {
                throw new Exception();
            }

            var definition = new GH_Document();

            if (!archive.ExtractObject(definition, "Definition"))
            {
                throw new Exception();
            }

            // Set input params
            foreach (var obj in definition.Objects)
            {
                var group = obj as GH_Group;
                if (group == null)
                {
                    continue;
                }

                if (group.NickName.Contains("RH_IN"))
                {
                    // It is a RestHopper input group!
                    GHTypeCodes code  = (GHTypeCodes)Int32.Parse(group.NickName.Split(':')[1]);
                    var         param = group.Objects()[0];
                    //GH_Param<IGH_Goo> goo = obj as GH_Param<IGH_Goo>;

                    // SetData
                    foreach (Resthopper.IO.DataTree <ResthopperObject> tree in input.Values)
                    {
                        string paramname = tree.ParamName;
                        if (group.NickName == paramname)
                        {
                            switch (code)
                            {
                            case GHTypeCodes.Boolean:
                                //PopulateParam<GH_Boolean>(goo, tree);
                                Param_Boolean boolParam = param as Param_Boolean;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path           path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Boolean> objectList = new List <GH_Boolean>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj = entree.Value[i];
                                        bool             boolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                                        GH_Boolean       data    = new GH_Boolean(boolean);
                                        boolParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Point:
                                //PopulateParam<GH_Point>(goo, tree);
                                Param_Point ptParam = param as Param_Point;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path         path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Point> objectList = new List <GH_Point>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject       restobj = entree.Value[i];
                                        Rhino.Geometry.Point3d rPt     = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                                        GH_Point data = new GH_Point(rPt);
                                        ptParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Vector:
                                //PopulateParam<GH_Vector>(goo, tree);
                                Param_Vector vectorParam = param as Param_Vector;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path          path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Vector> objectList = new List <GH_Vector>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject        restobj  = entree.Value[i];
                                        Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data);
                                        GH_Vector data = new GH_Vector(rhVector);
                                        vectorParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Integer:
                                //PopulateParam<GH_Integer>(goo, tree);
                                Param_Integer integerParam = param as Param_Integer;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path           path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Integer> objectList = new List <GH_Integer>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj = entree.Value[i];
                                        int        rhinoInt      = JsonConvert.DeserializeObject <int>(restobj.Data);
                                        GH_Integer data          = new GH_Integer(rhinoInt);
                                        integerParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Number:
                                //PopulateParam<GH_Number>(goo, tree);
                                Param_Number numberParam = param as Param_Number;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path          path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Number> objectList = new List <GH_Number>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj  = entree.Value[i];
                                        double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                                        GH_Number        data     = new GH_Number(rhNumber);
                                        numberParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Text:
                                //PopulateParam<GH_String>(goo, tree);
                                Param_String stringParam = param as Param_String;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path          path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_String> objectList = new List <GH_String>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj  = entree.Value[i];
                                        string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                                        GH_String        data     = new GH_String(rhString);
                                        stringParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Line:
                                //PopulateParam<GH_Line>(goo, tree);
                                Param_Line lineParam = param as Param_Line;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path        path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Line> objectList = new List <GH_Line>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject    restobj = entree.Value[i];
                                        Rhino.Geometry.Line rhLine  = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                                        GH_Line             data    = new GH_Line(rhLine);
                                        lineParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Curve:
                                //PopulateParam<GH_Curve>(goo, tree);
                                Param_Curve curveParam = param as Param_Curve;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path         path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Curve> objectList = new List <GH_Curve>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj = entree.Value[i];
                                        GH_Curve         ghCurve;
                                        try
                                        {
                                            Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data);
                                            Rhino.Geometry.Curve    c    = new Rhino.Geometry.PolylineCurve(data);
                                            ghCurve = new GH_Curve(c);
                                        }
                                        catch
                                        {
                                            Rhino.Geometry.NurbsCurve data = JsonConvert.DeserializeObject <Rhino.Geometry.NurbsCurve>(restobj.Data);
                                            Rhino.Geometry.Curve      c    = new Rhino.Geometry.NurbsCurve(data);
                                            ghCurve = new GH_Curve(c);
                                        }
                                        curveParam.AddVolatileData(path, i, ghCurve);
                                    }
                                }
                                break;

                            case GHTypeCodes.Circle:
                                //PopulateParam<GH_Circle>(goo, tree);
                                Param_Circle circleParam = param as Param_Circle;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path          path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Circle> objectList = new List <GH_Circle>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject      restobj  = entree.Value[i];
                                        Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data);
                                        GH_Circle             data     = new GH_Circle(rhCircle);
                                        circleParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.PLane:
                                //PopulateParam<GH_Plane>(goo, tree);
                                Param_Plane planeParam = param as Param_Plane;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path         path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Plane> objectList = new List <GH_Plane>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject     restobj = entree.Value[i];
                                        Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data);
                                        GH_Plane             data    = new GH_Plane(rhPlane);
                                        planeParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Rectangle:
                                //PopulateParam<GH_Rectangle>(goo, tree);
                                Param_Rectangle rectangleParam = param as Param_Rectangle;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path             path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Rectangle> objectList = new List <GH_Rectangle>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject           restobj     = entree.Value[i];
                                        Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data);
                                        GH_Rectangle data = new GH_Rectangle(rhRectangle);
                                        rectangleParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Box:
                                //PopulateParam<GH_Box>(goo, tree);
                                Param_Box boxParam = param as Param_Box;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path       path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Box> objectList = new List <GH_Box>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject   restobj = entree.Value[i];
                                        Rhino.Geometry.Box rhBox   = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data);
                                        GH_Box             data    = new GH_Box(rhBox);
                                        boxParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Surface:
                                //PopulateParam<GH_Surface>(goo, tree);
                                Param_Surface surfaceParam = param as Param_Surface;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path           path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Surface> objectList = new List <GH_Surface>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject       restobj   = entree.Value[i];
                                        Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data);
                                        GH_Surface             data      = new GH_Surface(rhSurface);
                                        surfaceParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Brep:
                                //PopulateParam<GH_Brep>(goo, tree);
                                Param_Brep brepParam = param as Param_Brep;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path        path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Brep> objectList = new List <GH_Brep>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject    restobj = entree.Value[i];
                                        Rhino.Geometry.Brep rhBrep  = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data);
                                        GH_Brep             data    = new GH_Brep(rhBrep);
                                        brepParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Mesh:
                                //PopulateParam<GH_Mesh>(goo, tree);
                                Param_Mesh meshParam = param as Param_Mesh;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path        path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Mesh> objectList = new List <GH_Mesh>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject    restobj = entree.Value[i];
                                        Rhino.Geometry.Mesh rhMesh  = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data);
                                        GH_Mesh             data    = new GH_Mesh(rhMesh);
                                        meshParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Slider:
                                //PopulateParam<GH_Number>(goo, tree);
                                GH_NumberSlider sliderParam = param as GH_NumberSlider;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path          path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Number> objectList = new List <GH_Number>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj  = entree.Value[i];
                                        double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                                        GH_Number        data     = new GH_Number(rhNumber);
                                        sliderParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.BooleanToggle:
                                //PopulateParam<GH_Boolean>(goo, tree);
                                GH_BooleanToggle toggleParam = param as GH_BooleanToggle;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path           path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Boolean> objectList = new List <GH_Boolean>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj   = entree.Value[i];
                                        bool             rhBoolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                                        GH_Boolean       data      = new GH_Boolean(rhBoolean);
                                        toggleParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;

                            case GHTypeCodes.Panel:
                                //PopulateParam<GH_String>(goo, tree);
                                GH_Panel panelParam = param as GH_Panel;
                                foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                                {
                                    GH_Path         path       = new GH_Path(GhPath.FromString(entree.Key));
                                    List <GH_Panel> objectList = new List <GH_Panel>();
                                    for (int i = 0; i < entree.Value.Count; i++)
                                    {
                                        ResthopperObject restobj  = entree.Value[i];
                                        string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                                        GH_String        data     = new GH_String(rhString);
                                        panelParam.AddVolatileData(path, i, data);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }

            Schema OutputSchema = new Schema();

            OutputSchema.Algo = Utils.Base64Encode(string.Empty);

            // Parse output params
            foreach (var obj in definition.Objects)
            {
                var group = obj as GH_Group;
                if (group == null)
                {
                    continue;
                }

                if (group.NickName.Contains("RH_OUT"))
                {
                    // It is a RestHopper output group!
                    GHTypeCodes code  = (GHTypeCodes)Int32.Parse(group.NickName.Split(':')[1]);
                    var         param = group.Objects()[0] as IGH_Param;
                    if (param == null)
                    {
                        continue;
                    }

                    try
                    {
                        param.CollectData();
                        param.ComputeData();
                    }
                    catch (Exception)
                    {
                        param.Phase = GH_SolutionPhase.Failed;
                        // TODO: throw something better
                        throw;
                    }

                    // Get data
                    Resthopper.IO.DataTree <ResthopperObject> OutputTree = new Resthopper.IO.DataTree <ResthopperObject>();
                    OutputTree.ParamName = group.NickName;

                    var volatileData = param.VolatileData;
                    for (int p = 0; p < volatileData.PathCount; p++)
                    {
                        List <ResthopperObject> ResthopperObjectList = new List <ResthopperObject>();
                        foreach (var goo in volatileData.get_Branch(p))
                        {
                            if (goo == null)
                            {
                                continue;
                            }
                            else if (goo.GetType() == typeof(GH_Boolean))
                            {
                                GH_Boolean ghValue = goo as GH_Boolean;
                                bool       rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <bool>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Point))
                            {
                                GH_Point ghValue = goo as GH_Point;
                                Point3d  rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Point3d>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Vector))
                            {
                                GH_Vector ghValue = goo as GH_Vector;
                                Vector3d  rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Vector3d>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Integer))
                            {
                                GH_Integer ghValue = goo as GH_Integer;
                                int        rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <int>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Number))
                            {
                                GH_Number ghValue = goo as GH_Number;
                                double    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <double>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_String))
                            {
                                GH_String ghValue = goo as GH_String;
                                string    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <string>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Line))
                            {
                                GH_Line ghValue = goo as GH_Line;
                                Line    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Line>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Curve))
                            {
                                GH_Curve ghValue = goo as GH_Curve;
                                Curve    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Curve>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Circle))
                            {
                                GH_Circle ghValue = goo as GH_Circle;
                                Circle    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Circle>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Plane))
                            {
                                GH_Plane ghValue = goo as GH_Plane;
                                Plane    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Plane>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Rectangle))
                            {
                                GH_Rectangle ghValue = goo as GH_Rectangle;
                                Rectangle3d  rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Rectangle3d>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Box))
                            {
                                GH_Box ghValue = goo as GH_Box;
                                Box    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Box>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Surface))
                            {
                                GH_Surface ghValue = goo as GH_Surface;
                                Brep       rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Brep>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Brep))
                            {
                                GH_Brep ghValue = goo as GH_Brep;
                                Brep    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Brep>(rhValue));
                            }
                            else if (goo.GetType() == typeof(GH_Mesh))
                            {
                                GH_Mesh ghValue = goo as GH_Mesh;
                                Mesh    rhValue = ghValue.Value;
                                ResthopperObjectList.Add(GetResthopperObject <Mesh>(rhValue));
                            }
                        }

                        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
            }
            string returnJson = JsonConvert.SerializeObject(OutputSchema);

            return(returnJson);
        }
示例#39
0
 /// <summary>
 /// Finds a curve by offsetting an existing curve normal to a surface.
 /// The caller is responsible for ensuring that the curve lies on the input surface.
 /// </summary>
 /// <param name="surface">Surface from which normals are calculated.</param>
 /// <param name="height">offset distance (distance from surface to result curve)</param>
 /// <returns>
 /// Offset curve at distance height from the surface.  The offset curve is
 /// interpolated through a small number of points so if the surface is irregular
 /// or complicated, the result will not be a very accurate offset.
 /// </returns>
 public Curve OffsetNormalToSurface(Surface surface, double height)
 {
   IntPtr pConstThis = ConstPointer();
   IntPtr pConstSurface = surface.ConstPointer();
   IntPtr pOffsetCurve = UnsafeNativeMethods.RHC_RhinoOffsetCurveNormal(pConstThis, pConstSurface, height);
   return GeometryBase.CreateGeometryHelper(pOffsetCurve, null) as Curve;
 }
示例#40
0
 // Default Constructor. Defaults to continuous flow, creating a new Agent every timestep.
 public SurfaceEmitterType()
 {
   srf = new PlaneSurface(Plane.WorldXY, new Interval(0, 1), new Interval(0, 1));
 }
示例#41
0
 /// <summary>
 /// Constructs a rolling ball fillet between two surfaces.
 /// </summary>
 /// <param name="surfaceA">A first surface.</param>
 /// <param name="surfaceB">A second surface.</param>
 /// <param name="radius">A radius value.</param>
 /// <param name="tolerance">A tolerance value.</param>
 /// <returns>A new array of rolling ball fillet surfaces; this array can be empty on failure.</returns>
 /// <exception cref="ArgumentNullException">If surfaceA or surfaceB are null.</exception>
 public static Surface[] CreateRollingBallFillet(Surface surfaceA, Surface surfaceB, double radius, double tolerance)
 {
   return CreateRollingBallFillet(surfaceA, false, surfaceB, false, radius, tolerance);
 }
示例#42
0
        public static Brep ToRhino(global::Topologic.Face face, double tolerance = Core.Tolerance.Distance)
        {
            Rhino.Geometry.Surface ghSurface = ToRhino(face);

            double width = 0.0, height = 0.0;
            bool   canGetSurfaceSize = ghSurface.GetSurfaceSize(out width, out height);

            if (!canGetSurfaceSize)
            {
                throw new Exception("Fails to get the surface size.");
            }
            double maxSize          = Math.Max(width, height);
            double maxSizeAndMargin = maxSize + 2;

            ghSurface = ghSurface.Extend(IsoStatus.North, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.South, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.West, maxSizeAndMargin, true);
            ghSurface = ghSurface.Extend(IsoStatus.East, maxSizeAndMargin, true);

            List <GeometryBase> ghGeometryBases = new List <GeometryBase>();

            IList <Edge> outerEdges = face.ExternalBoundary.Edges;
            List <Curve> ghCurves   = new List <Curve>();

            foreach (Edge edge in outerEdges)
            {
                Curve ghCurve3D = ToRhino(edge);
                ghGeometryBases.Add(ghCurve3D);
                ghCurves.Add(ghCurve3D);
            }

            Brep ghBrep2 = Brep.CreatePatch(
                ghGeometryBases,
                ghSurface,
                20,
                20,
                true,
                true,
                tolerance,
                100.0,
                1,
                new Boolean[] { true, true, true, true },
                tolerance);

            BrepFace ghSurfaceAsBrepFace = ghSurface as BrepFace;

            if (ghBrep2 == null)
            {
                return(null);
            }

            IList <Wire> internalBoundaries = face.InternalBoundaries;

            if (internalBoundaries.Count == 0)
            {
                return(ghBrep2);
            }

            BrepFace ghBrepFace = ghBrep2.Faces[0];

            List <Curve> ghInternalCurves = new List <Curve>();

            foreach (Wire internalBoundary in internalBoundaries)
            {
                List <Curve> ghCurvesFromWireAsObjects = ToRhino(internalBoundary);
                foreach (Curve ghCurveFromWireAsObject in ghCurvesFromWireAsObjects)
                {
                    Curve ghCurveFromWire = ghCurveFromWireAsObject as Curve;
                    if (ghCurveFromWire != null)
                    {
                        Curve[] ghPulledCurveFromWire = ghCurveFromWire.PullToBrepFace(ghBrepFace, tolerance);
                        ghInternalCurves.AddRange(ghPulledCurveFromWire);
                    }
                }
            }

            Brep ghBrep3 = ghBrepFace.Split(ghInternalCurves, tolerance);

            return(ghBrep3.Faces.ExtractFace(0));
        }
示例#43
0
 /// <summary>
 /// Constructs a periodic surface from a base surface and a direction.
 /// </summary>
 /// <param name="baseSurface">A base surface.</param>
 /// <param name="direction">0 is first parameter, 1 is second parameter.</param>
 /// <returns>A new surface; or null on error.</returns>
 public static Surface CreatePeriodicSurface(Surface baseSurface, int direction)
 {
   IntPtr pConstSurface = baseSurface.ConstPointer();
   IntPtr pNewSurf = UnsafeNativeMethods.TL_Surface_MakePeriodic(pConstSurface, direction);
   return GeometryBase.CreateGeometryHelper(pNewSurf, null) as Surface;
 }
示例#44
0
        /***************************************************/

        public static RHG.Mesh CreatePreviewMesh(RHG.Surface surface, RHG.MeshingParameters parameters)
        {
            return(CreatePreviewMesh(surface.ToBrep(), parameters));
        }