Exemplo n.º 1
0
 public override List <object> CreateGeometryObjects(List <Node> allNodes)
 {
     return(new List <object>
     {
         Sphere.ByCenterPointRadius(allNodes[NodeIndices[0]].Position.ToPoint(), Radius)
     });
 }
        /// <summary>
        /// method to generate debug geometry from a tree
        /// </summary>
        /// <typeparam name="K"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="graph"></param>
        /// <returns></returns>
        public static List <Autodesk.DesignScript.Geometry.DesignScriptEntity> ProduceGeometryFromGraph <K, T>(List <GraphVertex <K, T> > graph)

            where T : IUnfoldablePlanarFace <K>
            where K : IUnfoldableEdge
        {
            var OutputGeo = new List <Autodesk.DesignScript.Geometry.DesignScriptEntity>();

            foreach (var CurrentVertex in graph)
            {
                //generate some geometry to visualize the BFS tree

                //create a polygon from verts, grab center, project center towards
                Point center = Tesselation.MeshHelpers.SurfaceAsPolygonCenter(CurrentVertex.Face.SurfaceEntities.First());

                Sphere nodecenter = Sphere.ByCenterPointRadius(center, 1);
                OutputGeo.Add(nodecenter);

                foreach (var CurrentEdge in CurrentVertex.GraphEdges)
                {
                    Point childCenter = Tesselation.MeshHelpers.SurfaceAsPolygonCenter(CurrentEdge.Head.Face.SurfaceEntities.First());
                    Line  line        = Line.ByStartPointEndPoint(center, childCenter);
                    OutputGeo.Add(line);
                }
            }

            return(OutputGeo);
        }
Exemplo n.º 3
0
        public void BySolidNameCategoryMaterial_ValidInput()
        {
            var sphere = Sphere.ByCenterPointRadius(Point.Origin());
            var mat    = DocumentManager.Instance.ElementsOfType <Autodesk.Revit.DB.Material>().First();

            var ds = DirectShape.ByGeometry(sphere, Category.ByName("OST_GenericModel"), Material.ByName(mat.Name), "a sphere");

            Assert.NotNull(ds);
            Assert.AreEqual("a sphere", ds.Name);
            Assert.AreEqual((sphere.Tags.LookupTag(ds.InternalElement.Id.ToString()) as DirectShapeState).materialId, mat.Id.IntegerValue);
            BoundingBoxCentroid(ds).DistanceTo(Point.Origin()).ShouldBeApproximately(0);
            sphere.Dispose();
        }
Exemplo n.º 4
0
        public static List <Sphere> DisplayReleases(Frame frame, double radius = 10.0)
        {
            List <Sphere> rSpheres = new List <Sphere>();

            if (frame.Releases.u1i == true || frame.Releases.u2i == true || frame.Releases.u3i == true || frame.Releases.r1i == true || frame.Releases.r2i == true || frame.Releases.r3i == true)
            {
                Sphere s = Sphere.ByCenterPointRadius(frame.BaseCrv.PointAtParameter(0.15), radius);
                rSpheres.Add(s);
            }
            if (frame.Releases.u1j == true || frame.Releases.u2j == true || frame.Releases.u3j == true || frame.Releases.r1j == true || frame.Releases.r2j == true || frame.Releases.r3j == true)
            {
                Sphere s = Sphere.ByCenterPointRadius(frame.BaseCrv.PointAtParameter(0.85), radius);
                rSpheres.Add(s);
            }
            return(rSpheres);
        }
Exemplo n.º 5
0
        public void Tessellate(IRenderPackage package, TessellationParameters parameters)
        {
            package.RequiresPerVertexColoration = true;
            Point center = SphereNode.Center(this);

            Autodesk.DesignScript.Geometry.Geometry geometry = Sphere.ByCenterPointRadius(center, this.radius);
            byte[] color = new byte[] { 0, 200, 200, 50 };
            // As you add more data to the render package, you need
            // to keep track of the index where this coloration will
            // start from.

            geometry.Tessellate(package, parameters);

            if (package.MeshVertexCount > 0)
            {
                package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color[0], color[1], color[2], color[3]));
            }
            center.Dispose();
            geometry.Dispose();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Points by chord distance on the Featureline.
        /// </summary>
        /// <param name="curve">The curve to subdivide.</param>
        /// <param name="chord">The chord.</param>
        /// <returns></returns>
        public static IList <Point> PointsByChord(Curve curve, double chord)
        {
            Utils.Log(string.Format("Featureline.PointsByChord started...", ""));

            if (chord <= 0)
            {
                Utils.Log(string.Format("ERROR: Featureline.PointsByChord {0}", "Distance must be positive."));

                throw new Exception("Distance must be positive.");
            }

            Solid s = null;
            Point p = null;
            Curve c = null;
            Point e = null;

            IList <Point> points         = new List <Point>();
            double        startParameter = curve.ParameterAtPoint(curve.StartPoint);
            double        endParameter   = curve.ParameterAtPoint(curve.EndPoint);

            int n = Convert.ToInt32(Math.Ceiling(curve.Length / chord));

            Utils.Log(string.Format("Number of points: {0}", n));

            bool found = false;

            p = curve.StartPoint;

            points.Add(p);

            double par = startParameter;

            for (int i = 0; i < n; ++i)
            {
                Utils.Log(string.Format("Processing Point: {0}", i));

                s = Sphere.ByCenterPointRadius(p, chord);

                if (s != null)
                {
                    Utils.Log(string.Format("Sphere...", ""));

                    var intersection = s.Intersect(curve);

                    Utils.Log(string.Format("Looking for intersections...", ""));

                    if (intersection != null)
                    {
                        foreach (Geometry g in intersection)
                        {
                            if (g is Curve)
                            {
                                Utils.Log(string.Format("Curve found...", ""));

                                try
                                {
                                    c = g as Curve;
                                    e = c.EndPoint;

                                    double parameter = curve.ParameterAtPoint(e);

                                    if (parameter >= endParameter)
                                    {
                                        p     = curve.EndPoint;
                                        found = true;
                                        break;
                                    }

                                    if (parameter > par)
                                    {
                                        p   = Point.ByCoordinates(e.X, e.Y, e.Z);
                                        par = parameter;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Utils.Log(string.Format("ERROR: {0}", ex.Message));
                                    throw ex;
                                }
                            }
                        }
                    }
                }

                if (null != p)
                {
                    Utils.Log(string.Format("Parameter: {0}", par));

                    points.Add(p);
                }
                else
                {
                    Utils.Log(string.Format("ERROR: {0}", "Point is null"));
                    break;
                }

                if (found)
                {
                    break;
                }
            }

            s.Dispose();
            c.Dispose();
            e.Dispose();

            Utils.Log(string.Format("Featureline.PointsByChord completed.", ""));

            return(points);
        }