Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh = default(Mesh);
            var countA = default(int);
            var countZ = default(int);
            var thickness = default(double);
            var plane = default(Plane);
            var radius = default(double);
            var deeper = default(double);
            var project = default(bool);
            var projectDistance = default(double);

            DA.GetData(0, ref mesh);
            DA.GetData(1, ref countA);
            DA.GetData(2, ref countZ);
            DA.GetData(3, ref thickness);
            DA.GetData(4, ref plane);
            DA.GetData(5, ref radius);
            DA.GetData(6, ref deeper);
            DA.GetData(7, ref project);
            DA.GetData(8, ref projectDistance);


            // --- Execute

            var unit = DocumentTolerance();

            var result = Radial.Create(mesh, plane, thickness, deeper, radius, countA, countZ, unit, project, projectDistance);


            // --- Output

            DA.SetEnum2D(0, result.CurvesA);
            DA.SetEnum2D(1, result.CurvesZ);
            DA.SetEnum1D(2, result.PlanesA);
            DA.SetEnum1D(3, result.PlanesZ);
        }
Ejemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh            = default(Mesh);
            var countA          = default(int);
            var countZ          = default(int);
            var thickness       = default(double);
            var plane           = default(Plane);
            var radius          = default(double);
            var deeper          = default(double);
            var project         = default(bool);
            var projectDistance = default(double);

            DA.GetData(0, ref mesh);
            DA.GetData(1, ref countA);
            DA.GetData(2, ref countZ);
            DA.GetData(3, ref thickness);
            DA.GetData(4, ref plane);
            DA.GetData(5, ref radius);
            DA.GetData(6, ref deeper);
            DA.GetData(7, ref project);
            DA.GetData(8, ref projectDistance);


            // --- Execute

            var unit = DocumentTolerance();

            var result = Radial.Create(mesh, plane, thickness, deeper, radius, countA, countZ, unit, project, projectDistance);


            // --- Output

            DA.SetEnum2D(0, result.CurvesA);
            DA.SetEnum2D(1, result.CurvesZ);
            DA.SetEnum1D(2, result.PlanesA);
            DA.SetEnum1D(3, result.PlanesZ);
        }
Ejemplo n.º 3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh = default(Mesh);
            var planes = new List<Plane>();
            var thickness = default(double);
            var deeper = default(double);

            DA.GetData(0, ref mesh);
            DA.GetDataList(1, planes);
            DA.GetData(2, ref thickness);
            DA.GetData(3, ref deeper);


            // --- Execute

            var tolerance = DocumentTolerance();

            var slitPlanes = new SlitPlane[planes.Count];

            for (int i = 0; i < planes.Count; i++)
                slitPlanes[i] = new SlitPlane(mesh, planes[i], tolerance);

            var bbox = mesh.GetBoundingBox(false);
            var dmax = bbox.Diagonal.Length;
                      
            for (int i = 0; i < planes.Count; i++)
            {
                for (int j = i + 1; j < planes.Count; j++)
                {
                    var a = planes[i];
                    var b = planes[j];

                    var origin = default(Vector3d);
                    var direction = default(Vector3d);

                    if (a.Normal.IsParallelTo(b.Normal) != 0)
                        continue;

                    IntersectPlanes(a, b, out origin, out direction);

                    var cPlane = new Plane(bbox.Center, direction);
                    origin = (Vector3d)cPlane.ClosestPoint((Point3d)origin);                    

                    var originA = origin.Map2D(a);
                    var directionA = direction.Map2D(a);

                    var originB = origin.Map2D(b);
                    var directionB = direction.Map2D(b);

                    var line = new LineCurve((Point3d)(origin - dmax * direction), ((Point3d)origin + dmax * direction));

                    var alpha = Vector3d.VectorAngle(a.Normal, b.Normal);
                    var t = thickness * Math.Tan(alpha / 2);

                    slitPlanes[i].AddSlit(line.PointAtStart, line.PointAtEnd, t, deeper);
                    slitPlanes[j].AddSlit(line.PointAtEnd, line.PointAtStart, t, deeper);
                }
            }


            // --- Output

            DA.SetEnum2D(0, slitPlanes.Select(o => o.GetResult()));
        }
Ejemplo n.º 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh = default(Mesh);
            var thickness = default(double);
            var plane = default(Plane);
            var border = default(double);

            DA.GetData(0, ref mesh);
            DA.GetData(1, ref thickness);
            DA.GetData(2, ref plane);
            DA.GetData(3, ref border);


            // --- Check

            if (thickness <= 0)
                throw new Exception(@"Thickness must be a positive value!");

            if (border < 0)
                throw new Exception(@"Border must be a positive value!");

            if (!mesh.IsValid)
                throw new Exception(@"Mesh is not valid!");

            if (!mesh.IsClosed)
                throw new Exception(@"Mesh is not closed!");


            // --- Execute

            var unit = DocumentTolerance();

            var box = mesh.Box(plane);

            var corners = box.GetCorners();

            var origin = corners[0];
            var unitX = box.Plane.XAxis;
            var unitY = box.Plane.YAxis;
            var unitZ = box.Plane.ZAxis;

            var layerCount = (int)Math.Round(box.Z.Length / thickness);

            var olines = new List<List<IntPoint>>[layerCount];
            var offset = new List<List<IntPoint>>[layerCount];
            var ilines = new List<List<IntPoint>>[layerCount];
            var planes = new Plane[layerCount];

            for (int i = 0; i < layerCount; i++)
            {
                var z = (i + 0.5) * thickness;

                var sectionOrigin = origin + z * unitZ;
                var sectionPlane = new Plane(sectionOrigin, unitZ);

                planes[i] = sectionPlane;

                olines[i] = mesh.Section(sectionPlane, unit);
                offset[i] = Offset(olines[i], -border / unit);
            }

            if (border > 0)
            {
                ilines[0] = new List<List<IntPoint>>();

                for (int i = 1; i < layerCount - 1; i++)
                    ilines[i] = Intersect(Intersect(offset[i], offset[i - 1]), offset[i + 1]);

                ilines[layerCount - 1] = new List<List<IntPoint>>();
            }


            // --- Output

            DA.SetEnum2D(0, olines.Select((o, i) => o.ToCurves(planes[i], unit)));
            if (border > 0) DA.SetEnum2D(1, ilines.Select((o, i) => o.ToCurves(planes[i], unit)));
            DA.SetEnum1D(2, planes);
        }
Ejemplo n.º 5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh      = default(Mesh);
            var thickness = default(double);
            var plane     = default(Plane);
            var border    = default(double);

            DA.GetData(0, ref mesh);
            DA.GetData(1, ref thickness);
            DA.GetData(2, ref plane);
            DA.GetData(3, ref border);


            // --- Check

            if (thickness <= 0)
            {
                throw new Exception(@"Thickness must be a positive value!");
            }

            if (border < 0)
            {
                throw new Exception(@"Border must be a positive value!");
            }

            if (!mesh.IsValid)
            {
                throw new Exception(@"Mesh is not valid!");
            }

            if (!mesh.IsClosed)
            {
                throw new Exception(@"Mesh is not closed!");
            }


            // --- Execute

            var unit = DocumentTolerance();

            var box = mesh.Box(plane);

            var corners = box.GetCorners();

            var origin = corners[0];
            var unitX  = box.Plane.XAxis;
            var unitY  = box.Plane.YAxis;
            var unitZ  = box.Plane.ZAxis;

            var layerCount = (int)Math.Round(box.Z.Length / thickness);

            var olines = new List <List <IntPoint> > [layerCount];
            var offset = new List <List <IntPoint> > [layerCount];
            var ilines = new List <List <IntPoint> > [layerCount];
            var planes = new Plane[layerCount];

            for (int i = 0; i < layerCount; i++)
            {
                var z = (i + 0.5) * thickness;

                var sectionOrigin = origin + z * unitZ;
                var sectionPlane  = new Plane(sectionOrigin, unitZ);

                planes[i] = sectionPlane;

                olines[i] = mesh.Section(sectionPlane, unit);
                offset[i] = Offset(olines[i], -border / unit);
            }

            if (border > 0)
            {
                ilines[0] = new List <List <IntPoint> >();

                for (int i = 1; i < layerCount - 1; i++)
                {
                    ilines[i] = Intersect(Intersect(offset[i], offset[i - 1]), offset[i + 1]);
                }

                ilines[layerCount - 1] = new List <List <IntPoint> >();
            }


            // --- Output

            DA.SetEnum2D(0, olines.Select((o, i) => o.ToCurves(planes[i], unit)));
            if (border > 0)
            {
                DA.SetEnum2D(1, ilines.Select((o, i) => o.ToCurves(planes[i], unit)));
            }
            DA.SetEnum1D(2, planes);
        }
Ejemplo n.º 6
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh      = default(Mesh);
            var planes    = new List <Plane>();
            var thickness = default(double);
            var deeper    = default(double);

            DA.GetData(0, ref mesh);
            DA.GetDataList(1, planes);
            DA.GetData(2, ref thickness);
            DA.GetData(3, ref deeper);


            // --- Execute

            var tolerance = DocumentTolerance();

            var slitPlanes = new SlitPlane[planes.Count];

            for (int i = 0; i < planes.Count; i++)
            {
                slitPlanes[i] = new SlitPlane(mesh, planes[i], tolerance);
            }

            var bbox = mesh.GetBoundingBox(false);
            var dmax = bbox.Diagonal.Length;

            for (int i = 0; i < planes.Count; i++)
            {
                for (int j = i + 1; j < planes.Count; j++)
                {
                    var a = planes[i];
                    var b = planes[j];

                    var origin    = default(Vector3d);
                    var direction = default(Vector3d);

                    if (a.Normal.IsParallelTo(b.Normal) != 0)
                    {
                        continue;
                    }

                    IntersectPlanes(a, b, out origin, out direction);

                    var cPlane = new Plane(bbox.Center, direction);
                    origin = (Vector3d)cPlane.ClosestPoint((Point3d)origin);

                    var originA    = origin.Map2D(a);
                    var directionA = direction.Map2D(a);

                    var originB    = origin.Map2D(b);
                    var directionB = direction.Map2D(b);

                    var line = new LineCurve((Point3d)(origin - dmax * direction), ((Point3d)origin + dmax * direction));

                    var alpha = Vector3d.VectorAngle(a.Normal, b.Normal);
                    var t     = thickness * Math.Tan(alpha / 2);

                    slitPlanes[i].AddSlit(line.PointAtStart, line.PointAtEnd, t, deeper);
                    slitPlanes[j].AddSlit(line.PointAtEnd, line.PointAtStart, t, deeper);
                }
            }


            // --- Output

            DA.SetEnum2D(0, slitPlanes.Select(o => o.GetResult()));
        }