Пример #1
0
    protected override void SetOutputs(IGH_DataAccess da)
    {
      outTree = new DataTree<Point3d>();
      GH_Path trunk = new GH_Path(0); // {0}
      GH_Path branch = new GH_Path(); // {}\
      GH_Path limb = new GH_Path();

      
      for (int i = 0; i < particles.Count; i++)
      {
        IQuelea particle = particles[i];
        branch = trunk.AppendElement(i);
        DataTree<Point3d> particlePositionHistoryTree = particle.Position3DHistory.ToTree();

        for (int j = 0; j < particlePositionHistoryTree.BranchCount; j++)
        {
          limb = branch.AppendElement(j);
          //for (int k = particlePositionHistoryTree.Branch(j).Count - 1; k >= 0; k--)
          //{
          //  outTree.Add(particlePositionHistoryTree.Branch(j)[k], limb);
          //}
          outTree.AddRange(particlePositionHistoryTree.Branch(j), limb);
          
        }
      }
      da.SetDataTree(nextOutputIndex++, outTree);
    }
Пример #2
0
 protected override void SolveInstance(IGH_DataAccess da)
 {
     if (!GetInputs(da)) return;
     if (reset == true)
     {
         trailTree = new DataTree<Point3d>();
         iter = 0;
         maxid = 0;
     }
     else
     {
         foreach (Amoeba amo in p.population)
         {
             GH_Path thispath = new GH_Path(amo.ID);
             if (amo.ID > maxid)
             {
                 trailTree.Add(amo.prev_loc, thispath);
                 maxid = amo.ID;
             }
             trailTree.Add(amo.Location, thispath);
             if (trailTree.Branch(thispath).Count > history)
             {
                 trailTree.Branch(thispath).RemoveAt(0);
             }
         }
         foreach (int id in p._todie_id)
         {
             GH_Path thispath = new GH_Path(id);
             trailTree.Branch(thispath).Clear();
         }
         iter++;
     }
     SetOutputs(da);
 }
	// Returns the head node of the conversation class
	public static ConversationNode DataTreeToConversationNodes (DataTree conversationAsTree) {
		ConversationNode head = null;
		ConversationNode previous = null;
		ConversationNode pointer;

		for (int i = 0; i < conversationAsTree.Root.ChildCount; i++) {
			pointer = DataNodeToConversationNode(conversationAsTree[i]);

			if (head == null) {
				head = pointer;
			}

			if (previous != null) {
				previous.Next = pointer;
			}

			if (DEBUG) {
				Debug.Log(pointer);
				Debug.Log(pointer.Responses[0]);
			}

			previous = pointer;
		}

		return head;
	}
Пример #4
0
	public static DataTree ReadXMLAsDataTree (XmlDocument document) {
		DataTree tree = new DataTree();
		DataNode root = tree.Root;

		// Recursive Call
		ReadNode (document.DocumentElement, ref root);

		return tree;
	}
Пример #5
0
 List<Brep> GetBrepList(Mesh terrainMesh, List<double> contourZList, DataTree<Curve> contourTree)
 {
     List<Brep> splittedBrepList = new List<Brep>();
     Brep terrainRegion = GetTerrainRegion(terrainMesh);
     int i = 0;
     foreach (double z in contourZList)
     {
         Brep splittedBrep = terrainRegion.Faces[0].Split(contourTree.Branches[i++], doc.ModelAbsoluteTolerance);
         Rhino.Geometry.Transform xform = Rhino.Geometry.Transform.PlanarProjection(new Plane(new Point3d(0, 0, z), new Vector3d(0, 0, 1)));
         splittedBrep.Transform(xform);
         splittedBrepList.Add(splittedBrep);
     }
     return splittedBrepList;
 }
        protected override void SolveInstance(IGH_DataAccess da)
        {
            if (!GetInputs(da)) return;
            prop = new DataTree<double>();
            int index = 0;
            foreach (Amoeba amo in p.population)
            {
                prop.Add(amo.tempValue,new GH_Path(index));
                prop.Add(PhysaSetting.gmin, new GH_Path(index));
                prop.Add(PhysaSetting.gmax, new GH_Path(index));
                index++;
            }

            SetOutputs(da);
        }
    private static DataTree<Brep> BrepArray2DToDatatree(Brep[][] array)
    {
      DataTree<Brep> tree = new DataTree<Brep>();
      GH_Path trunk = new GH_Path();

      for (int i = 0; i < array.Length; i++)
      {
        GH_Path branch = trunk.AppendElement(i);

        for (int j = 0; j < array[i].Length; j++)
        {
          tree.Add(array[i][j], branch);
        }
      }
      return tree;
    }
Пример #8
0
    public static DataTree<Polyline> makeTiles(Mesh mesh)
    {
        DataTree < Polyline> Tree = new DataTree<Polyline>();
        for(int i = 0;i < mesh.Faces.Count;i++)
        {
          Vector3d ab = new Vector3d (mesh.Vertices[mesh.Faces[i].B] - mesh.Vertices[mesh.Faces[i].A]);
          Vector3d ac = new Vector3d (mesh.Vertices[mesh.Faces[i].C] - mesh.Vertices[mesh.Faces[i].A]);

          Point3dList pts = new Point3dList();
          pts.Add(mesh.Vertices[mesh.Faces[i].A]);
          pts.Add(mesh.Vertices[mesh.Faces[i].C]);
          pts.Add(mesh.Vertices[mesh.Faces[i].B]);
          Polyline edge = new Polyline(pts);
          Tree.Add(edge);
        }
        return Tree;
    }
Пример #9
0
        public void CreateIndentedNodes_basic()
        {
            m_DataTree = new DataTree();
            m_Slice    = GenerateSlice(Cache, m_DataTree);

            // Data taken from a running Sena 3
            var caller = CreateXmlElementFromOuterXmlOf("<part ref=\"AsLexemeForm\" label=\"Lexeme Form\" expansion=\"expanded\"><indent><part ref=\"IsAbstractBasic\" label=\"Is Abstract Form\" visibility=\"never\" /><!-- could use 'ifTrue' if we had it --><part ref=\"MorphTypeBasic\" visibility=\"ifdata\" /><part ref=\"PhoneEnvBasic\" visibility=\"ifdata\" /><part ref=\"StemNameForLexemeForm\" visibility=\"ifdata\" /></indent></part>");

            var       obj    = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create();
            const int indent = 0;
            int       insPos = 1;

            var path = GeneratePath();

            var reuseMap = new ObjSeqHashMap();
            // Data taken from a running Sena 3
            var node = CreateXmlElementFromOuterXmlOf("<slice field=\"Form\" label=\"Form\" editor=\"multistring\" ws=\"all vernacular\" weight=\"light\" menu=\"mnuDataTree-LexemeForm\" contextMenu=\"mnuDataTree-LexemeFormContext\" spell=\"no\"><properties><bold value=\"on\" /><fontsize value=\"120%\" /></properties></slice>");

            m_Slice.CreateIndentedNodes(caller, obj, indent, ref insPos, path, reuseMap, node);
        }
Пример #10
0
        private AjaxResult Find(string controller, string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                throw new RuntimeException("Query missing from find request.");
            }

            if (string.IsNullOrEmpty(controller))
            {
                throw new RuntimeException("Controller missing from find request.");
            }

            DBQuery dbQuery = GetQuery(controller, query);

            ApplyQueryParameters(dbQuery);

            DataTree result = (DataTree)dbQuery.FindAsync().Result;

            return(new AjaxResult(result));
        }
Пример #11
0
        private IMongoQuery GetSQLCollectionConditionQuery(DataTree schemaCollection)
        {
            IMongoQuery query = new QueryDocument(BsonDocument.Parse("{}"));;

            string condition = schemaCollection["collection"]["SQLfilter"];

            if (!string.IsNullOrEmpty(condition))
            {
                try
                {
                    query = new QueryDocument(BsonDocument.Parse(condition));
                }
                catch (Exception ex)
                {
                    logger.LogError("Failed to parse JSON when determining caching query", ex.Message, condition);
                }
            }

            return(query);
        }
Пример #12
0
        /// <summary/>
        public override void TestTearDown()
        {
            if (m_Slice != null)
            {
                m_Slice.Dispose();
                m_Slice = null;
            }
            if (m_DataTree != null)
            {
                m_DataTree.Dispose();
                m_DataTree = null;
            }
            if (m_Mediator != null)
            {
                m_Mediator.Dispose();
                m_Mediator = null;
            }

            base.TestTearDown();
        }
Пример #13
0
        public static DataTree <T> IE <T>(IEnumerable <T> list, int iteration = 0)
        {
            DataTree <T> tree = new DataTree <T>();

            if (iteration == -1)
            {
                int count = 0;
                foreach (var t in list)
                {
                    tree.Add(t, new GH_Path(count));
                    count++;
                }
            }
            else
            {
                tree.AddRange(list, new GH_Path(new int[] { iteration }));
            }

            return(tree);
        }
Пример #14
0
        public static DataTree <T> TripleArraysToTree <T>(T[][][] arrays, int iteration = 0)
        {
            DataTree <T> tree = new DataTree <T>();
            int          i    = 0;

            foreach (var a in arrays)
            {
                int j = 0;
                foreach (var b in a)
                {
                    if (b != null)
                    {
                        tree.AddRange(b, new GH_Path(new[] { iteration, i, j }));
                    }
                    j++;
                }
                i++;
            }
            return(tree);
        }
Пример #15
0
        public DataTree <double> DefToTree(Vector <double> u, List <Node> nodes)
        {
            DataTree <double> defTree = new DataTree <double>();
            int n = 0;

            for (int i = 0; i < u.Count; i += 3)
            {
                List <double> u_node = new List <double>(3);
                u_node.Add(u[i]);
                u_node.Add(u[i + 1]);
                u_node.Add(u[i + 2]);
                //sett til riktig node, ta hensyn til de vi har fjernet.
                nodes[i / 3].SetDeformation(u_node);

                defTree.AddRange(u_node, new GH_Path(new int[] { 0, n }));
                n++;
            }

            return(defTree);
        }
Пример #16
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var bodyData = new List <HumanBody>();

            DA.GetDataList(0, bodyData);

            var jointTree = new DataTree <System.Object>();

            for (var i = 0; i < bodyData.Count; i++)
            {
                var body = bodyData[i];
                var path = new GH_Path(i);
                for (var j = 0; j < body.joints.Count; j++)
                {
                    jointTree.Insert(body.joints[j].Position, path, j);
                }
            }

            DA.SetDataTree(0, jointTree);
        }
        public gen_core(int core_min_width, int core_min_height, Rectangle3d skin, int max_core_count, double efficiency, double deviation, bool allow_core_variation)
        {
            this.core_min_width       = core_min_width;
            this.core_min_height      = core_min_height;
            this.skin                 = skin;
            this.max_core_count       = max_core_count;
            this.efficiency           = efficiency;
            this.deviation            = deviation;
            this.allow_core_variation = allow_core_variation;

            this.locations               = new List <Point3d>();
            this.values                  = new DataTree <int>();
            this.cores                   = new List <Rectangle3d>();
            this.valid_cores             = new DataTree <Rectangle3d>();
            this.valid_core_combinations = new List <List <int> >();
            this.valid_core_locations    = new List <List <int> >();
            this.core_area               = this.skin.Area * this.efficiency;

            compute();
        }
Пример #18
0
        async Task LoadStoreAsync(string type)
        {
            if (!_dataTreeAddresses.ContainsKey(type))
            {
                throw new InvalidOperationException($"Store does not exist! {type}");
            }
            // check if already loaded? or is this a refresh function also?

            Task onHeadChange(MdLocator newXOR) => UpdateTypeStores(type, newXOR);

            var headResult = await MdAccess.LocateAsync(_dataTreeAddresses[type]).ConfigureAwait(false);

            if (!headResult.HasValue)
            {
                throw new Exception($"Error code: {headResult.ErrorCode.Value}. {headResult.ErrorMsg}");
            }
            var dataTree = new DataTree(headResult.Value, onHeadChange);

            _dataTreeCache[type] = dataTree;
        }
Пример #19
0
        private static DataTree <object> ConvertLawsonToDataTree(Dictionary <string, List <int> > data)
        {
            var patchCounter = 0;

            var output = new DataTree <object>();

            foreach (var patchKey in data.Keys)
            {
                var points = data[patchKey];
                var path   = new GH_Path(patchCounter);
                foreach (var value in points)
                {
                    output.Add(value, path);
                }

                patchCounter++;
            }

            return(output);
        }
Пример #20
0
        public DataTree <int> SequenceNeighbours(Mesh M, List <int> O, int S)
        {
            List <int>[] ff = M.GetNgonFaceAdjacencyOrdered();

            DataTree <int> dtsequence          = new DataTree <int>();
            DataTree <int> dtsequenceConnected = new DataTree <int>();
            HashSet <int>  sequence            = new HashSet <int>();

            for (int i = 0; i < O.Count; i++)
            {
                //Get current outlines
                List <int> cf = ff[O[i]];


                //Get current outlines already connected and skip not connected
                List <int> cfPlaced = new List <int>(cf.Count);

                foreach (int j in cf)
                {
                    if (sequence.Contains(j))
                    {
                        cfPlaced.Add(j);
                        dtsequenceConnected.Add(j, new GH_Path(i));
                    }
                }

                sequence.Add(O[i]);
                dtsequence.Add(O[i], new GH_Path(i));


                if (i == S)
                {
                    break;
                }
            }

            //O_ = dtsequence;
            //N = dtsequenceConnected;

            return(dtsequenceConnected);
        }
Пример #21
0
	}//eof




	/// <summary>
    /// This is the method that actually does the work.
	/// </summary>
	protected override void SolveInstance(IGH_DataAccess DA)
	{
		List<Curve> crv = new List<Curve>();
		if (!DA.GetDataList(0, crv)) return;

		DataTree<Curve> r = new DataTree<Curve>();

		for (int i = 0; i < crv.Count; ++i)
		{
			if (!isChildOfCrv(crv[i], crv))
			{
				GH_Path p = new GH_Path(0);
				r.Add(crv[i], p);
			}
		}

		bool isAnyCrvAligned = true;

		while (isAnyCrvAligned)
		{
			isAnyCrvAligned = false;
			int BC = r.BranchCount;
			for (int i = 0; i < BC; ++i)
			{
				for (int j = 0; j < crv.Count; ++j)
				{
					if (r.AllData().IndexOf(crv[j]) == -1)
					{
						GH_Path p = new GH_Path(i + 1);
						if (isChildOfCrv(crv[j], r.Branch(i)))
						{
							r.Add(crv[j], p);
							isAnyCrvAligned = true;
						}
					}
				}
			}
		}

		DA.SetDataTree(0, r);
	}//eof
Пример #22
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            treeGoo treeg = new treeGoo();

            DA.GetData(0, ref treeg);

            TreeStructure t = null;
            double        tn, sn, an, pie;

            tn = sn = an = pie = 0;
            Point3d cen = new Point3d();

            DA.GetData(0, ref t);
            DA.GetData("Center", ref cen);
            DA.GetData("Domain", ref pie);
            DA.GetData("TN", ref tn);
            DA.GetData("AN", ref sn);
            DA.GetData("SN", ref an);

            var dom  = new Interval((pie - 1) * Math.PI / 2, (3 - pie) * Math.PI / 2);
            var arcs = Enumerable.Range(0, t.Depth + 1).Select(i =>
                                                               new Arc(new Circle(cen, sn * Math.Pow(i, tn) + an), dom)).ToList();
            var layers   = treeg.Value.GetLayers(arcs.Select(i => i.ToNurbsCurve()));
            var Pointset = new DataTree <GeoNode>();
            var TigSet   = new DataTree <Curve>();

            foreach (var gLayer in layers)
            {
                var path = new GH_Path(gLayer.Level);
                Pointset.AddRange(gLayer.ToList(), path);
                TigSet.AddRange(gLayer.Draw(), path);
            }
            TigSet.RemovePath(TigSet.Paths.Last());
            DA.SetDataTree(0, TigSet);
            DA.SetDataTree(1, Pointset);
            var m = layers.ByOuterMosts();

            DA.SetDataList(2, m[GLayerSet.dets.Outermodes]);
            DA.SetDataList(3, m[GLayerSet.dets.InMiddles]);
            DA.SetDataList(4, m[GLayerSet.dets.Invalid]);
        }
Пример #23
0
        public static DataTree <int> _GraphColorHalfEdges(this Mesh M, int numberOfColors = 2)
        {
            var graph = new Advanced.Algorithms.DataStructures.Graph.AdjacencyList.Graph <int>();


            var V = M._FEFlattenV();

            foreach (var v in V)
            {
                graph.AddVertex(v);
            }

            var E = M._eehalf();

            foreach (var edges in E)
            {
                foreach (var e in edges)
                {
                    if (!graph.HasEdge(e[0], e[1]))
                    {
                        graph.AddEdge(e[0], e[1]);
                    }
                }
            }

            MColorer <int, string>     algorithm = new MColorer <int, string>();
            MColorResult <int, string> result    = algorithm.Color(graph, Letters(numberOfColors));
            DataTree <int>             dtResult  = new DataTree <int>();


            if (result.Partitions != null)
            {
                int counter = 0;
                foreach (KeyValuePair <string, List <int> > p in result.Partitions)
                {
                    dtResult.AddRange(p.Value, new GH_Path(counter++));
                }
            }

            return(dtResult);
        }
Пример #24
0
        private bool FilterDocumentByDate(DataTree reportDocument)
        {
            if (!reportDocument.Contains("date"))
            {
                return(false);
            }

            DateTime date = (DateTime)reportDocument["date"];

            if (start.HasValue && date < start)
            {
                return(false);
            }

            if (end.HasValue && date > end)
            {
                return(false);
            }

            return(true);
        }
Пример #25
0
 /// <summary>
 /// Creates directory recursive. Path with filename can be passed if file has extension.
 /// </summary>
 public static bool CreateDirectory(string path, DataTree <string> error)
 {
     if (path.IsNullOrWhiteSpace())
     {
         error.Add("Path is empty."); return(false);
     }
     try
     {
         if (!Path.GetExtension(path).IsNullOrEmpty())
         {
             path = Path.GetDirectoryName(path);
         }
         if (Directory.Exists(path))
         {
             return(true);
         }
         Directory.CreateDirectory(path);
         return(true);
     }
     catch (Exception ex) { error.Add($"Exception creating directory {path}: {ex.Message}"); return(false); }
 }
Пример #26
0
 /// <summary>
 /// Checks if file exists
 /// </summary>
 public static bool Exists(string filepath, DataTree <string> error)
 {
     try
     {
         Path.GetFullPath(filepath);
         if (filepath.IsNullOrWhiteSpace())
         {
             throw new ExpectedException($"Filename argument is null({filepath == null}) or empty({filepath == null})");
         }
         if (!File.Exists(filepath))
         {
             throw new ExpectedException($"File {filepath} doesn't exist");
         }
         return(true);
     }
     catch (Exception ex)
     {
         error.Add(ex.Message);
         return(false);
     }
 }
Пример #27
0
        /// <summary>
        /// Invalidate entries for this day's entry and user.
        /// </summary>
        /// <param name="entry"></param>
        public void InvalidateCacheEntry(DataTree entry)
        {
            logger.LogTrace("Invalidating cached entry", entry);

            if (!documents.ContainsKey(entry["_id"]))
            {
                return;
            }

            DataTree cachedEntry = documents[entry["_id"]];

            // day
            //     entries
            //         timesheetentry
            //
            DataTree day = entry.Parent.Parent.Parent;

            logger.LogTrace("Invalidating day from cache", day);

            InvalidateDay(day);
        }
        private DataTree <Mesh> GetDeformedMeshes(double scale, ref List <string> msg)
        {
            var oMeshes = new DataTree <Mesh>();

            // Same tree structure as displacements
            foreach (var path in _meshdisplacements.Paths)
            {
                var gh_path   = new GH_Path(path);
                var mesh_path = new GH_Path(path.Indices[0]);
                // Get fe mesh as starting mesh
                var mesh = _feMeshes.Branch(mesh_path)[0].DuplicateMesh();
                // Move FE Nodes according to displacements
                for (int i = 0; i < mesh.Vertices.Count; i++)
                {
                    mesh.Vertices[i] += (Point3f)(Point3d)(scale * _meshdisplacements.Branch(path)[i]); // -_-
                }
                // Add mesh to tree
                oMeshes.Add(mesh, gh_path);
            }
            return(oMeshes);
        }
Пример #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        public override void Install(DataTree parent)
        {
            CheckDisposed();

            base.Install(parent);

            MSADlgLauncher ctrl = (MSADlgLauncher)Control;

            this.Size = new System.Drawing.Size(208, 32);
            ctrl.Initialize((FdoCache)Mediator.PropertyTable.GetValue("cache"),
                            Object,
                            1,     // Maybe need a real flid?
                            "InterlinearName",
                            ContainingDataTree.PersistenceProvder,
                            Mediator,
                            "InterlinearName",
                            XmlUtils.GetOptionalAttributeValue(m_configurationNode, "ws", "analysis"));     // TODO: Get better default 'best ws'.
            MSADlglauncherView view = ctrl.MainControl as MSADlglauncherView;

            view.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(Mediator);
        }
Пример #30
0
        private DataTree <object> CorrectMesh(
            Dictionary <string, Mesh> meshes
            )
        {
            var newMeshes = new DataTree <object>();
            var j         = 0;

            foreach (var key in meshes.Keys)
            {
                var newMesh = new Mesh();

                // Check mesh normal. If the normal direction is fx Z, check that the points and mesh have the same value. If not throw an error.
                GH_Convert.ToMesh(meshes[key], ref newMesh, GH_Conversion.Primary);

                var path = new GH_Path(j);
                newMeshes.Add(newMesh, path);
                j++;
            }

            return(newMeshes);
        }
Пример #31
0
        /*******************************************/

        public static DataTree <T> DataTree <T>(List <IEnumerable <T> > data, int iteration, IList <GH_Path> paths)
        {
            DataTree <T> master = new DataTree <T>();

            if (data.Count == 0)
            {
                master.EnsurePath(0);
                return(new DataTree <T>());
            }
            else
            {
                for (int i = 0; i < data.Count; i++)
                {
                    DataTree <T> local = new DataTree <T>(data[i], paths[iteration]);
                    GH_Path      path  = paths[iteration].AppendElement(i);
                    master.EnsurePath(path);
                    master.AddRange(data[i], path);
                }
            }
            return(master);
        }
Пример #32
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // INPUT
            // declaration
            string        _XML     = String.Empty;
            List <string> _tagName = new List <string>();

            DA.GetData(0, ref _XML);
            DA.GetDataList(1, _tagName);

            // actions
            XmlDocument xmlDoc = new XmlDocument();
            //declare tree
            DataTree <string> intTree = new DataTree <string>();

            xmlDoc.LoadXml(_XML);

            if (_tagName != null)
            {
                try
                {
                    //set up tree
                    for (int i = 0; i < _tagName.Count; i++)
                    {
                        GHD.GH_Path pth = new GHD.GH_Path(i);

                        var innerTextData = xmlDoc.GetElementsByTagName(_tagName[i])[0].InnerText;
                        intTree.Add(innerTextData, pth);
                    }

                    // output
                    DA.SetDataTree(0, intTree);
                }
                catch
                {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please provide a valid keyword.");
                    return;
                }
            }
        }
Пример #33
0
        // Use Nullable to distinguish from other ActionResults that get interpreted as
        // MC2 actions
        protected DataTree GetDefaultResults(
            string rootschema,
            string collection,
            string valuename,
            string relationtarget,
            string itemid,
            string filtercontroller,
            string filteraction)
        {
            string defaultValueController = Runtime.Schema.First[collection][valuename]["defaultresultscontroller"];
            string defaultValueBlock      = Runtime.Schema.First[collection][valuename]["defaultresultsblock"];
            string relation = Runtime.Schema.First[collection][valuename]["relation"];

            if (string.IsNullOrEmpty(defaultValueController) || string.IsNullOrEmpty(defaultValueBlock))
            {
                return(null);
            }

            MC2Value result = Runtime.RunBlock(
                defaultValueController,
                defaultValueBlock,
                collection,
                valuename,
                relationtarget,
                itemid,
                filtercontroller,
                filteraction);

            if (result is MC2DataTreeValue)
            {
                // MC2 datatree value has no name and we use the relation's target
                DataTree dtResult = ((MC2DataTreeValue)result).DataTreeValue;
                dtResult.Name = relation;
                return(dtResult);
            }
            else
            {
                return(null);
            }
        }
        private DataTree <Vector3d> GetMemberDisplacements(ref List <int> memberNo, ref List <string> msg)
        {
            // Get control points
            _controlPoints.Clear();
            // Save defoirmation vectors into a tree;
            var oDisplacements = new DataTree <Vector3d>();

            memberNo = new List <int>();
            foreach (var member in _rfMembers)
            {
                if (member.Type == MemberType.NullMember)
                {
                    continue;
                }
                // Add also control points. We are just going to get one set of control points for each curve regardless of the result type
                var pts_path = new GH_Path(member.No);
                _controlPoints.EnsurePath(pts_path);
                var baseline = member.BaseLine.ToCurve();
                // Get deformations
                var memberResults = _lcresults.GetMemberDeformations(member.No, ItemAt.AtNo, MemberAxesType.GlobalAxes); // We can't sort this list
                foreach (var resulttype in memberResults.Select(x => x.Type).Distinct())
                {
                    _resultTypes.Add(resulttype);
                }
                var valueType = memberResults[0].Type; // Get deformation types to avoid duplicate control points
                memberNo.Add(member.No);
                foreach (var result in memberResults)
                {
                    var gh_path      = new GH_Path(member.No, (int)result.Type); // GET RESULT TYPES!!!
                    var displacement = new Vector3d(result.Displacements.ToPoint3d());
                    oDisplacements.Add(displacement, gh_path);
                    // Get control points
                    if (result.Type == valueType)
                    {
                        _controlPoints.Add(baseline.PointAtNormalizedLength(Math.Min(result.Location / baseline.GetLength(), 1.0)), pts_path);
                    }
                }
            }
            return(oDisplacements);
        }
Пример #35
0
        public static DataTree <int> _GraphColorFaces(this Mesh M, int numberOfColors = 2)
        {
            var graph = new Advanced.Algorithms.DataStructures.Graph.AdjacencyList.Graph <int>();



            List <int>[] adj = M.GetNgonFaceAdjacencyOrdered();

            for (int i = 0; i < adj.Length; i++)
            {
                graph.AddVertex(i);
            }

            for (int i = 0; i < adj.Length; i++)
            {
                foreach (var e in adj[i])
                {
                    if (!graph.HasEdge(i, e))
                    {
                        graph.AddEdge(i, e);
                    }
                }
            }

            MColorer <int, string>     algorithm = new MColorer <int, string>();
            MColorResult <int, string> result    = algorithm.Color(graph, Letters(numberOfColors));
            DataTree <int>             dtResult  = new DataTree <int>();


            if (result.Partitions != null)
            {
                int counter = 0;
                foreach (KeyValuePair <string, List <int> > p in result.Partitions)
                {
                    dtResult.AddRange(p.Value, new GH_Path(counter++));
                }
            }

            return(dtResult);
        }
        private void DataTree_OnNodeExpansionChanged(object sender, NodeExpansionChangedEventArgs e)
        {
            var nodedata = e.Node.Data as DirectoryNode;
            var id       = nodedata != null ? nodedata.NodeId : 1;

            if (DataTree.Equals(sender))
            {
                if (e.Node.IsExpanded)
                {
                    if (!ApplicationContext.ExpandedIds.Contains(id))
                    {
                        ApplicationContext.ExpandedIds.Add(id);
                    }
                }
                else
                {
                    if (ApplicationContext.ExpandedIds.Contains(id))
                    {
                        ApplicationContext.ExpandedIds.Remove(id);
                    }
                }
            }
            else
            {
                if (e.Node.IsExpanded)
                {
                    if (nodedata != null && nodedata.IsFolder && !ApplicationContext.LabelExpandedIds.Contains(id))
                    {
                        ApplicationContext.LabelExpandedIds.Add(id);
                    }
                }
                else
                {
                    if (ApplicationContext.LabelExpandedIds.Contains(id))
                    {
                        ApplicationContext.LabelExpandedIds.Remove(id);
                    }
                }
            }
        }
Пример #37
0
        public MC2Value trocurrentproject(DataTree itemSchema)
        {
            MC2Value value = null;

            if ((bool)Runtime.CurrentActionCall.Parameters["socialproject"] == true && (bool)Runtime.Config["application"]["features"]["enablesocialproject"])
            {
                // Todo: cache value?
                if (socialProject == null)
                {
                    socialProject = new DBQuery("tro", "getsocialproject").FindOneAsync().Result;
                }

                value = socialProject;
            }
            else if ((bool)Runtime.CurrentActionCall.Parameters["fromhomescreen"] == true)
            {
                // Use either provided project from url or user's project
                if (Runtime.CurrentActionCall.Parameters["workscheduleprojectid"].Exists)
                {
                    value = DBDocument.FindOne("project", Runtime.CurrentActionCall.Parameters["workscheduleprojectid"]);
                }
                else
                {
                    var userQuery = new DBQuery();

                    userQuery["user"][DBQuery.Condition] = Query.EQ(DBQuery.Id, new ObjectId(Runtime.SessionManager.CurrentUser["_id"]))
                                                           .ToString();

                    DataTree currentUser = userQuery.FindOne();

                    value = currentUser["currentproject"];
                }
            }
            else
            {
                value = MC2EmptyValue.EmptyValue;
            }

            return(value);
        }
Пример #38
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Structure <GH_Integer> Ts;

            if (!DA.GetDataTree(0, out Ts))
            {
                return;
            }
            if (Ts.Branches.Count == 0)
            {
                return;
            }

            if (Ts.Branches.Count == 1)
            {
                DA.SetData(0, Ts);
                return;
            }

            // converts GH_Structure in DataTree of int
            DataTree <int> Td = new DataTree <int>();

            for (int i = 0; i < Ts.Branches.Count; i++)
            {
                Td.AddRange(Ts.Branches[i].Select(n => n.Value).ToList(), Ts.Paths[i]);
            }

            DataTree <int> clusters = new DataTree <int>(); // tree for clusters
            List <int>     tP       = new List <int>();     // list of branch indexes for Td

            for (int i = 0; i < Td.BranchCount; i++)
            {
                tP.Add(i);
            }

            // start from first branch: call clusterize with 0 both as cb and sb
            clusterize(0, 0, ref Td, ref clusters, ref tP);

            DA.SetDataTree(0, clusters);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ////////////////////////
            //  Retrieve crucial (fixed) input data, exit if non-existent
            ////////////////////////

            if (!DA.GetData(0, ref clusterUrlParam)) { return; }

            ////////////////////////
            // check if cluster was properly loaded, and if parameters are correct
            // and if not, do something about it!
            ////////////////////////

            if (loadedClusterUrlParam == null ||
                loadedClusterUrlParam != clusterUrlParam)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Cluster not loaded properly - click on 'Reload Cluster' button!");
            //                MessageBox.Show("hey, don't we have a parameter mismatch?");
                //we've got a parameter mismatch
                // urge user to click on buttom to match paramcount to cluster param count
            /*                (this.m_attributes as Attributes_Custom).button.Palette = GH_Palette.Pink;
                (this.m_attributes as Attributes_Custom).ExpireLayout();
                (this.m_attributes as Attributes_Custom).PerformLayout();
                NEXT STEP - HIGHLIGHT BUTTON */

            }
            else
            {
                //successful! parameters match. so - let's run this thing:

                //get data from hairworm inputs, put into array
                for (int i = fixedParamNumInput; i < (fixedParamNumInput + clusterParamNumInput); i++)
                {
                    if (!DA.GetDataList(i, clusterInputLists[i - fixedParamNumInput])) { return; }
                    //if (!DA.GetData(i, ref clusterInput[i - fixedParamNumInput])) { return; }
            //                    debugText += "okay, input # " + i + " is: " + clusterInputs[i - fixedParamNumInput].ToString() + "\n";
            //					DA.SetData(0, debugText);
                }

                // get data from array, input into cluster
                for (int i = fixedParamNumInput; i < (fixedParamNumInput + clusterParamNumInput); i++)
                {
            //                    wormCluster.Params.Input[i - fixedParamNumInput].AddVolatileData(new GH_Path(0), 0, clusterInputs[i - fixedParamNumInput]);
                    wormCluster.Params.Input[i - fixedParamNumInput].AddVolatileDataList(new GH_Path(0), clusterInputLists[i - fixedParamNumInput]);

                }

                // RUN CLUSTER AND RECOMPUTE THIS
                wormCluster.ExpireSolution(true);

                // get computed data from cluster outputs, push into hairworm outputs
                for (int i = fixedParamNumOutput; i < (fixedParamNumOutput + clusterParamNumOutput); i++)
                {
                    // Create a copy of this data (the original data will be wiped)
                    DataTree<object> copy = new DataTree<object>();
                    copy.MergeStructure(wormCluster.Params.Output[i - fixedParamNumOutput].VolatileData, new Grasshopper.Kernel.Parameters.Hints.GH_NullHint());

                    // push into hairworm component outputs
                    DA.SetDataTree(i, copy);
                }

                DA.SetData(0, debugText);

            }

            DA.SetData(0, debugText);
        }
Пример #40
0
        DataTree<Curve> GetContourTree(Mesh mesh, List<double> contourZList)
        {
            DataTree<Curve> contourTree = new DataTree<Curve>();
            int i = 0;
            foreach (double z in contourZList)
            {
                Polyline[] contour = Rhino.Geometry.Intersect.Intersection.MeshPlane(mesh, new Plane(new Point3d(0, 0, z), new Vector3d(0, 0, 1)));
                foreach (Polyline contourItem in contour)
                {
                    PolylineCurve pCurve = new PolylineCurve(contourItem);
                    contourTree.Add(pCurve, new GH_Path(0, i));

                }
                i++;
            }
            return contourTree;
        }
Пример #41
0
    /// <summary>
    /// This procedure contains the user code. Input parameters are provided as regular arguments,
    /// Output parameters as ref arguments. You don't have to assign output parameters,
    /// they will have a default value.
    /// </summary>
    private void RunScript(int startType, int depth, double scale, Mesh inputMesh, ref object A, ref object B)
    {
        Mesh mesh = new Mesh();
        DataTree < Polyline> Tree = new DataTree<Polyline>();
        if (startType == 0){mesh = inputMesh;}
        if (startType == 1){mesh = fatC(scale);}
        if (startType == 2){mesh = thinC(scale);}
        if (startType == 3){mesh = fatCC();}
        if (startType == 4){mesh = thinCC();}

        mesh = subdiv(mesh, depth, 0);
        A = makeTiles(mesh);
        B = mesh;
    }
Пример #42
0
        DataTree<Object> GetStepTree(Mesh terrainMesh, List<double> contourZList, DataTree<Curve> contourTree, List<Brep> brepList)
        {
            DataTree<Object> stepTree = new DataTree<Object>();
            Plane basePlane = Plane.WorldXY;
            basePlane.OriginZ = terrainMesh.GetBoundingBox(true).Min.Z;

            // For each contour-plane
            for (int i = 0; i < contourTree.BranchCount; i++)
            {

                // create higher-Z pt list
                Point3dList winPtList = new Point3dList();

                foreach (Curve contourCrv in contourTree.Branches[i])
                {

                    Plane frm;
                    double t;
                    contourCrv.NormalizedLengthParameter(0.5, out t);
                    contourCrv.FrameAt(t, out frm);
                    frm.Transform(Rhino.Geometry.Transform.PlanarProjection(basePlane));

                    Point3d samplePt0, samplePt1;
                    samplePt0 = frm.Origin;
                    samplePt1 = frm.Origin;
                    samplePt0 += doc.ModelAbsoluteTolerance * frm.YAxis;
                    samplePt1 -= doc.ModelAbsoluteTolerance * frm.YAxis;
                    Ray3d ray0 = new Ray3d(samplePt0, Vector3d.ZAxis);
                    Ray3d ray1 = new Ray3d(samplePt1, Vector3d.ZAxis);
                    double rayParam0 = Rhino.Geometry.Intersect.Intersection.MeshRay(terrainMesh, ray0);
                    double rayParam1 = Rhino.Geometry.Intersect.Intersection.MeshRay(terrainMesh, ray1);

                    winPtList.Add(((rayParam0 > rayParam1) ? samplePt0 : samplePt1));
                }

                // For each splitted region in contour-plane
                foreach (BrepFace brepFace in brepList[i].Faces)
                {
                    Brep testBrep = brepFace.DuplicateFace(false);

                    foreach (Point3d pt in winPtList)
                    {

                        LineCurve testRay = new LineCurve(new Line(pt, Vector3d.ZAxis, 1000));
                        Point3d[] outPts;
                        Curve[] outCrvs;

                        bool ix = Rhino.Geometry.Intersect.Intersection.CurveBrep(testRay, testBrep, doc.ModelAbsoluteTolerance, out outCrvs, out outPts);
                        if (outPts.Length != 0)
                        {
                            stepTree.Add(testBrep, new GH_Path(i));
                            break;
                        }
                    }
                }
            }

            return stepTree;
        }
Пример #43
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Lattice()
 {
     m_nodes = new DataTree<LatticeNode>();
     m_struts = new List<Curve>();
 }
Пример #44
0
        /// <summary>
        /// Morphs cell topology to UVWI node map (morphed struts).
        /// </summary>
        public void MorphMapping(UnitCell cell, DataTree<GeometryBase> spaceTree, float[] N)
        {
            for (int u = 0; u <= N[0]; u++)
            {
                for (int v = 0; v <= N[1]; v++)
                {
                    for (int w = 0; w <= N[2]; w++)
                    {
                        // We're inside a unit cell
                        // Loop through all pairs of nodes that make up struts
                        foreach (IndexPair nodePair in cell.NodePairs)
                        {
                            // Prepare the path of the nodes (path in tree)
                            // First, get relative paths of nodes (with respect to current unit cell)
                            int[] IRel = cell.NodePaths[nodePair.I];
                            int[] JRel = cell.NodePaths[nodePair.J];
                            // Next, compute absolute paths
                            GH_Path IPath = new GH_Path(u + IRel[0], v + IRel[1], w + IRel[2]);
                            GH_Path JPath = new GH_Path(u + JRel[0], v + JRel[1], w + JRel[2]);

                            // Make sure the cell exists
                            // No cells exist beyond the boundary + 1
                            if (Nodes.PathExists(IPath) && Nodes.PathExists(JPath))
                            {
                                LatticeNode node1 = Nodes[IPath, IRel[3]];
                                LatticeNode node2 = Nodes[JPath, JRel[3]];
                                // Make sure both nodes exist:
                                // Null nodes either belong to other cells, or are beyond the upper uvw boundary.
                                if (node1 != null && node2 != null)
                                {
                                    GH_Path spacePath;

                                    // If strut is along boundary, we must use the previous morph space 
                                    // Since one does not exist beyond the boundary) 
                                    if (u == N[0] && v == N[1])
                                    {
                                        spacePath = new GH_Path(u - 1, v - 1);
                                    }
                                    else if (u == N[0])
                                    {
                                        spacePath = new GH_Path(u - 1, v);
                                    }
                                    else if (v == N[1])
                                    {
                                        spacePath = new GH_Path(u, v - 1);
                                    }                                        
                                    else
                                    {
                                        spacePath = new GH_Path(u, v);
                                    }

                                    // Retrieve uv cell space (will be casted in the tempPt loop)
                                    GeometryBase ss1 = spaceTree[spacePath, 0];
                                    GeometryBase ss2 = spaceTree[spacePath, 1];

                                    // Discretize the unit cell line for morph mapping
                                    int ptCount = 16;
                                    // Template points are unitized cell points (x,y of these points are u,v of sub-surface)
                                    var templatePts = new List<Point3d>();  
                                    Line templateLine = new Line(cell.Nodes[nodePair.I], cell.Nodes[nodePair.J]);
                                    for (int ptIndex = 0; ptIndex <= ptCount; ptIndex++)
                                    {
                                        templatePts.Add(templateLine.PointAt(ptIndex / (double)ptCount));
                                    }

                                    // We will map the lines' points to its uvw cell-space
                                    // Control points are the interpolation points in space
                                    var controlPoints = new List<Point3d>();

                                    foreach (Point3d tempPt in templatePts)
                                    {
                                        Point3d surfPt;
                                        Vector3d[] surfDerivs;
                                        // UV params on unitized sub-surface are simply the xy coordinate of the template point
                                        double uParam = tempPt.X;
                                        double vParam = tempPt.Y;
                                        // If at boundary, we're using a previous morph space, so reverse the parameter(s)
                                        if (u == N[0])
                                        {
                                            uParam = 1 - uParam;
                                        }
                                        if (v == N[1])
                                        {
                                            vParam = 1 - vParam;
                                        }

                                        // Now, we will map the template point to the uvw-space
                                        ((Surface)ss1).Evaluate(uParam, vParam, 0, out surfPt, out surfDerivs);
                                        Vector3d wVect = Vector3d.Unset;
                                        switch (ss2.ObjectType)
                                        {
                                            case ObjectType.Point:
                                                wVect = ((Point)ss2).Location - surfPt; ;
                                                break;
                                            case ObjectType.Curve:
                                                wVect = ((Curve)ss2).PointAt(uParam) - surfPt;
                                                break;
                                            case ObjectType.Surface: 
                                                Point3d surfPt2;
                                                Vector3d[] surfDerivs2;
                                                ((Surface)ss2).Evaluate(uParam, vParam, 0, out surfPt2, out surfDerivs2);
                                                wVect = surfPt2 - surfPt;
                                                break;
                                        }
                                        // The mapped point
                                        Point3d uvwPt = surfPt + wVect * (w + tempPt.Z) / N[2];
                                        controlPoints.Add(uvwPt);

                                    }

                                    // Now create interpolated curve based on control points
                                    Curve curve = Curve.CreateInterpolatedCurve(controlPoints, 3);

                                    if (curve != null && curve.IsValid)
                                    {
                                        Struts.Add(curve);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #45
0
 public static DataTree Read(string file)
 {
     DataTree data = new DataTree();
     throw new NotImplementedException();
 }
Пример #46
0
 public PositionHistoryAsDataTree(int size)
 {
   this.tree = new DataTree<Point3d>();
   this.size = size;
   this.nextPathIndex = 0;
 }
	void initCharacterList () {
		if (characterList == null) {
			characterList = DataUtil.ParseXML("Text/CharacterList");
		}
	}
Пример #48
0
        private void RunScript(List<Mesh> x, List<int> y,  List<double>  z, ref object A, ref object B, ref object C,ref object D)
        {
            try
            {
                DataTree<double> output222;
                if (temp.Count == 0)
                {
                    temp = y;
                    for (int i = 0; i < x.Count; i++)
                    {
                        GH_Path path = new GH_Path(i);
                        List<Line> output11;
                        List<double> output22;
                        Point3d output33;
                        List<Point3d> output44;
                        Print(Step(x[i], y[i], 0.5, true, out output11, out output22, out output33, out output44));
                        output1.AddRange(output11, path);
                        output2.AddRange(output22, path);
                        output3.Add(output33, path);
                        output4.AddRange(output44, path);
                    }
                }
                else
                {
                    for (int i = 0; i < y.Count; i++)
                    {
                        GH_Path path = new GH_Path(i);
                        if (y[i] != temp[i])
                        {
                            List<Line> output11;
                            List<double> output22;
                            Point3d output33;
                            List<Point3d> output44;
                            Print(Step(x[i], y[i], 0.5, true, out output11, out output22, out output33, out output44));
                            output1.Branch(path).Clear();
                            output1.Branch(path).AddRange(output11);
                            output2.Branch(path).Clear();
                            output2.Branch(path).AddRange(output22);
                            output3.Branch(path)[0] = output33;
                            output4.Branch(path).Clear();
                            output4.Branch(path).AddRange(output44);
                            temp[i] = y[i];
                        }
                    }
                }

                output222 = new DataTree<double>(output2);
                for (int i = 0; i < output222.Paths.Count; i++)
                {
                    GH_Path path = new GH_Path(i);
                    for(int j=0;j<output222.Branch(path).Count;j++){
                        output222[path, j] *= z[i];
                }}
                A = output1; B = output222; C = output3; D = output4;
            }
            catch (Exception ex)
            {
                Print(ex.ToString());
            }
        }
Пример #49
0
 public static bool Write(DataTree data)
 {
     throw new NotImplementedException();
 }
Пример #50
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Retrieve and validate inputs
            var cell = new UnitCell();
            Surface s1 = null;
            Surface s2 = null;
            int nU = 0;
            int nV = 0;
            int nW = 0;
            bool morphed = false;

            if (!DA.GetData(0, ref cell)) { return; }
            if (!DA.GetData(1, ref s1)) { return; }
            if (!DA.GetData(2, ref s2)) { return; }
            if (!DA.GetData(3, ref nU)) { return; }
            if (!DA.GetData(4, ref nV)) { return; }
            if (!DA.GetData(5, ref nW)) { return; }
            if (!DA.GetData(6, ref morphed)) { return; }

            if (!cell.isValid) { return; }
            if (!s1.IsValid) { return; }
            if (!s2.IsValid) { return; }
            if (nU == 0) { return; }
            if (nV == 0) { return; }
            if (nW == 0) { return; }

            // 2. Initialize the lattice
            var lattice = new Lattice();
            // Will contain the morphed uv spaces (as surface-surface)
            var spaceTree = new DataTree<GeometryBase>(); 
            
            // 3. Package the number of cells in each direction into an array
            float[] N = new float[3] { nU, nV, nW };

            // 4. Normalize the UV-domain
            Interval unitDomain = new Interval(0,1);
            s1.SetDomain(0, unitDomain); // s1 u-direction
            s1.SetDomain(1, unitDomain); // s1 v-direction
            s2.SetDomain(0, unitDomain); // s2 u-direction
            s2.SetDomain(1, unitDomain); // s2 v-direction

            // 5. Prepare cell (this is a UnitCell object)
            cell = cell.Duplicate();
            cell.FormatTopology();

            // 6. Map nodes to design space
            //    Loop through the uvw cell grid
            for (int u = 0; u <= N[0]; u++)
            {
                for (int v = 0; v <= N[1]; v++)
                {
                    for (int w = 0; w <= N[2]; w++)
                    {
                        // Construct cell path in tree
                        GH_Path treePath = new GH_Path(u, v, w);
                        // Fetch the list of nodes to append to, or initialise it
                        var nodeList = lattice.Nodes.EnsurePath(treePath);      

                        // This loop maps each node in the cell onto the UV-surface maps
                        for (int i = 0; i < cell.Nodes.Count; i++)
                        {
                            double usub = cell.Nodes[i].X; // u-position within unit cell (local)
                            double vsub = cell.Nodes[i].Y; // v-position within unit cell (local)
                            double wsub = cell.Nodes[i].Z; // w-position within unit cell (local)
                            double[] uvw = { u + usub, v + vsub, w + wsub }; // uvw-position (global)

                            // Check if the node belongs to another cell (i.e. it's relative path points outside the current cell)
                            bool isOutsideCell = (cell.NodePaths[i][0] > 0 || cell.NodePaths[i][1] > 0 || cell.NodePaths[i][2] > 0);
                            // Check if current uvw-position is beyond the upper boundary
                            bool isOutsideSpace = (uvw[0] > N[0] || uvw[1] > N[1] || uvw[2] > N[2]);

                            if (isOutsideCell || isOutsideSpace)
                            {
                                nodeList.Add(null);
                            }
                            else
                            {
                                // Initialize for surface 1
                                Point3d pt1; Vector3d[] derivatives1;
                                // Initialize for surface 2
                                Point3d pt2; Vector3d[] derivatives2;

                                // Evaluate point on both surfaces
                                s1.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt1, out derivatives1);
                                s2.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt2, out derivatives2);

                                // Create vector joining the two points (this is our w-range)
                                Vector3d wVect = pt2 - pt1;

                                // Create the node, accounting for the position along the w-direction
                                var newNode = new LatticeNode(pt1 + wVect * uvw[2] / N[2]);
                                // Add node to tree
                                nodeList.Add(newNode);
                            }
                        }
                    }

                    // Define the uv space tree (used for morphing)
                    if (morphed && u < N[0] && v < N[1])
                    {
                        GH_Path spacePath = new GH_Path(u, v);
                        // Set trimming interval
                        var uInterval = new Interval((u) / N[0], (u + 1) / N[0]);
                        var vInterval = new Interval((v) / N[1], (v + 1) / N[1]);
                        // Create sub-surfaces
                        Surface ss1 = s1.Trim(uInterval, vInterval);
                        Surface ss2 = s2.Trim(uInterval, vInterval);
                        // Unitize domain
                        ss1.SetDomain(0, unitDomain); ss1.SetDomain(1, unitDomain);
                        ss2.SetDomain(0, unitDomain); ss2.SetDomain(1, unitDomain); 
                        // Save to the space tree
                        spaceTree.Add(ss1, spacePath);
                        spaceTree.Add(ss2, spacePath);
                    }
                    
                }
            }

            // 7. Map struts to the node tree
            if (morphed) lattice.MorphMapping(cell, spaceTree, N);
            else lattice.ConformMapping(cell, N);

            // 8. Set output
            DA.SetDataList(0, lattice.Struts);

        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //----Declareing--------------------------------------------------------------------------

            // contains the 3 points of each face
            DataTree<Point3f> facePoints = new DataTree<Point3f>();
            // contains the coresponding topology points of each face
            DataTree<int> faceTopologyPoints = new DataTree<int>();
            // contains the face normals of each face
            List<Vector3f> faceNormals = new List<Vector3f>();

            // contains the 3 topology edges of each face
            DataTree<int> faceTopoEdgesIdx = new DataTree<int>();
            // contains the points of each topology edge
            DataTree<int> topologyEdgesTopPtsIdx = new DataTree<int>();

            // Contains the coordinates of each topology point
            List<Point3d> topologyPoints = new List<Point3d>();
            // Contains the index of neighbouring faces for each face
            DataTree<int> faceNeighbours = new DataTree<int>();
            // Contains Normals of topology vertices
            List<Vector3d> topologyNormals = new List<Vector3d>();

            // Contains the index of topology Edges for each Topology Point
            DataTree<int> TopPt_Connected_TopEdges = new DataTree<int>();

            //get Mesh from input
            Mesh M = new Mesh();
            DA.GetData<Mesh>("Mesh", ref M);

            //----End Declareing-----------------------------------------------------------------------

            //----Functions------------------------------------------------------------------------------

            // get List with sublist of 3 points per face
            for (int face_id = 0; face_id < M.Faces.Count; face_id++)
            {
                // set up the branch index
                GH_Path pth = new GH_Path(face_id);

                # region FacePoints

                //---- Face Points (Point3f)
                Point3f A, B, C, D;
                M.Faces.GetFaceVertices(face_id, out A, out B, out C, out D);

                facePoints.Add(A, pth);
                facePoints.Add(B, pth);
                facePoints.Add(C, pth);

                #endregion FacePoints

                #region FaceNormals
                //---- Face Normals (Vector3f)
                M.FaceNormals.ComputeFaceNormals();
                faceNormals.Add(M.FaceNormals[face_id]);
                #endregion FaceNormals

                #region faceTopologyPoints

                //---- Topology Points of the face (int)
                int TA = M.Faces.GetTopologicalVertices(face_id)[0];
                int TB = M.Faces.GetTopologicalVertices(face_id)[1];
                int TC = M.Faces.GetTopologicalVertices(face_id)[2];

                faceTopologyPoints.Add(TA, pth);
                faceTopologyPoints.Add(TB, pth);
                faceTopologyPoints.Add(TC, pth);

                #endregion faceTopologyPoints

                #region faceNeighbours

                //---- Neighbours of face (int)

                foreach (int i in M.TopologyEdges.GetEdgesForFace(face_id))
                {
                    if (M.TopologyEdges.GetConnectedFaces(i).Length > 1)
                    {
                        foreach (int j in M.TopologyEdges.GetConnectedFaces(i))
                        {
                            if (j != face_id)
                            { faceNeighbours.Add(j, pth); }
                        }
                    }
                    else
                    { faceNeighbours.Add(-1, pth); }
                }

                #endregion faceNeighbours

                #region Face Topology Edges

                //---- Topology Edges (int)

                foreach (int i in M.TopologyEdges.GetEdgesForFace(face_id))
                { faceTopoEdgesIdx.Add(i, pth); }

                #endregion Face Topology Edges

            }

            for (int i = 0; i < M.TopologyVertices.Count; i++)
            {
                #region topologyPoints
                //---- Topology Points (point3f)
                int[] vertIdx = M.TopologyVertices.MeshVertexIndices(i);
                topologyPoints.Add(M.Vertices[vertIdx[0]]);
                #endregion topologyPoints

                #region topologyNormals
                //---- Topology Normals
                M.FaceNormals.ComputeFaceNormals();
                Vector3d normal = new Vector3d(0, 0, 0);
                int count = 0;

                foreach (int face in M.TopologyVertices.ConnectedFaces(i))
                {
                    Vector3f temp = new Vector3f();
                    temp = M.FaceNormals[face];
                    Vector3d temp2 = new Vector3d(temp.X, temp.Y, temp.Z);
                    normal += temp2;
                    count++;
                }

                normal /= count;
                topologyNormals.Add(normal);
                #endregion topologyNormals

            }

            #region Topology Edges

            for (int i = 0; i < M.TopologyEdges.Count; i++)
            {
                topologyEdgesTopPtsIdx.Add(M.TopologyEdges.GetTopologyVertices(i).I, new GH_Path(i));
                topologyEdgesTopPtsIdx.Add(M.TopologyEdges.GetTopologyVertices(i).J, new GH_Path(i));
            }

            #endregion Topology Edges

            #region Topology Vertex connected Topology Edge

            for (int i = 0; i < topologyPoints.Count; i++)
            {
                // i = index of Topology Point
                GH_Path pth = new GH_Path(i);

                for (int j = 0; j < topologyEdgesTopPtsIdx.BranchCount; j++)
                {
                    // j = index of Topology Edge
                    foreach (int k in topologyEdgesTopPtsIdx.Branch(j))
                    {
                        if (k == i)
                        // add multiple Topology Edges to the branch index, which is representing the topology point index
                        { TopPt_Connected_TopEdges.Add(j, pth); }
                    }
                }
            }

            #endregion Topology Vertex connected Topology Edge

            //----End Functions--------------------------------------------------------------------------

            //----Set Output-----------------------------------------------------------------------------

            DA.SetDataTree(0, facePoints);
            DA.SetDataTree(1, faceTopologyPoints);
            DA.SetDataList(2, faceNormals);
            DA.SetDataTree(3, faceNeighbours);
            DA.SetDataList(4, topologyPoints);
            DA.SetDataList(5, topologyNormals);
            DA.SetDataTree(6, faceTopoEdgesIdx);
            DA.SetDataTree(7, topologyEdgesTopPtsIdx);
            DA.SetDataTree(8, TopPt_Connected_TopEdges);

            //----End Set Output-------------------------------------------------------------------------
        }
Пример #52
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool runCommand = false;
            GH_Structure<GH_Point> origPoints = new GH_Structure<GH_Point>();
            GH_Structure<GH_Point> adaptPoints = new GH_Structure<GH_Point>();
            GH_Structure<GH_Curve> curves = new GH_Structure<GH_Curve>();
            GH_Structure<GH_Vector> orientations = new GH_Structure<GH_Vector>();
            GH_Structure<GH_Vector> faceOrientations = new GH_Structure<GH_Vector>();
            DA.GetData(0, ref runCommand);
            DA.GetDataTree(1, out origPoints);
            DA.GetDataTree(2, out adaptPoints);
            DA.GetDataTree(3, out curves);
            DA.GetDataTree(4, out orientations);
            DA.GetDataTree(5, out faceOrientations);

            // Make sure the family and type is set before running the command.
            if (runCommand && (familyName == null || familyName == "Not Selected"))
            {
                message = "Please select a family/type by double-clicking on the component before running the command.";
            }
            else if (runCommand)
            {
                // Get the scale
                GHInfo ghi = new GHInfo();
                GHScale scale = ghi.GetScale(Rhino.RhinoDoc.ActiveDoc);

                // Send to Revit
                LyrebirdChannel channel = new LyrebirdChannel(appVersion);
                channel.Create();

                if (channel != null)
                {
                    string documentName = channel.DocumentName();
                    if (documentName != null)
                    {
                        // Create RevitObjects
                        List<RevitObject> obj = new List<RevitObject>();

                        #region OriginPoint Based
                        if (origPoints != null && origPoints.Branches.Count > 0)
                        {
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            // make sure the branches match the datacount
                            if (origPoints.Branches.Count == origPoints.DataCount)
                            {
                                for (int i = 0; i < origPoints.Branches.Count; i++)
                                {
                                    GH_Point ghpt = origPoints[i][0];
                                    LyrebirdPoint point = new LyrebirdPoint
                                    {
                                        X = ghpt.Value.X,
                                        Y = ghpt.Value.Y,
                                        Z = ghpt.Value.Z
                                    };

                                    RevitObject ro = new RevitObject
                                    {
                                        Origin = point,
                                        FamilyName = familyName,
                                        TypeName = typeName,
                                        Category = category,
                                        CategoryId = categoryId,
                                        GHPath = origPoints.Paths[i].ToString(),
                                        GHScaleFactor = scale.ScaleFactor,
                                        GHScaleName = scale.ScaleName
                                    };

                                    tempObjs.Add(ro);
                                }
                                obj = tempObjs;
                            }
                            else
                            {
                                // Inform the user they need to graft their inputs.  Only one point per branch
                                System.Windows.Forms.MessageBox.Show("Warning:\n\nEach Branch represents an object, " +
                                    "so origin point based elements should be grafted so that each point is on it's own branch.");
                            }
                        }
                        #endregion

                        #region AdaptiveComponents
                        else if (adaptPoints != null && adaptPoints.Branches.Count > 0)
                        {
                            // generate adaptive components
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            for (int i = 0; i < adaptPoints.Branches.Count; i++)
                            {
                                RevitObject ro = new RevitObject();
                                List<LyrebirdPoint> points = new List<LyrebirdPoint>();
                                for (int j = 0; j < adaptPoints.Branches[i].Count; j++)
                                {
                                    LyrebirdPoint point = new LyrebirdPoint(adaptPoints.Branches[i][j].Value.X, adaptPoints.Branches[i][j].Value.Y, adaptPoints.Branches[i][j].Value.Z);
                                    points.Add(point);
                                }
                                ro.AdaptivePoints = points;
                                ro.FamilyName = familyName;
                                ro.TypeName = typeName;
                                ro.Origin = null;
                                ro.Category = category;
                                ro.CategoryId = categoryId;
                                ro.GHPath = adaptPoints.Paths[i].ToString();
                                ro.GHScaleFactor = scale.ScaleFactor;
                                ro.GHScaleName = scale.ScaleName;
                                tempObjs.Add(ro);
                            }
                            obj = tempObjs;

                        }
                        #endregion

                        #region Curve Based
                        else if (curves != null && curves.Branches.Count > 0)
                        {
                            // Get curves for curve based components

                            // Determine if we're profile or line based
                            if (curves.Branches.Count == curves.DataCount)
                            {
                                // Determine if the curve is a closed planar curve
                                Curve tempCrv = curves.Branches[0][0].Value;
                                if (tempCrv.IsPlanar(0.00000001) && tempCrv.IsClosed)
                                {
                                    // Closed planar curve
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < curves.Branches.Count; i++)
                                    {
                                        Curve crv = curves[i][0].Value;
                                        List<Curve> rCurves = new List<Curve>();
                                        bool getCrvs = CurveSegments(rCurves, crv, true);
                                        if (rCurves.Count > 0)
                                        {
                                            RevitObject ro = new RevitObject();
                                            List<LyrebirdCurve> lbCurves = new List<LyrebirdCurve>();
                                            for (int j = 0; j < rCurves.Count; j++)
                                            {
                                                LyrebirdCurve lbc;
                                                lbc = GetLBCurve(rCurves[j]);
                                                lbCurves.Add(lbc);
                                            }
                                            ro.Curves = lbCurves;
                                            ro.FamilyName = familyName;
                                            ro.Category = category;
                                            ro.CategoryId = categoryId;
                                            ro.TypeName = typeName;
                                            ro.Origin = null;
                                            ro.GHPath = curves.Paths[i].ToString();
                                            ro.GHScaleFactor = scale.ScaleFactor;
                                            ro.GHScaleName = scale.ScaleName;
                                            tempObjs.Add(ro);
                                        }
                                    }
                                    obj = tempObjs;

                                }
                                else if (!tempCrv.IsClosed)
                                {
                                    // Line based.  Can only be arc or linear curves
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < curves.Branches.Count; i++)
                                    {

                                        Curve ghc = curves.Branches[i][0].Value;
                                        // Test that there is only one curve segment
                                        PolyCurve polycurve = ghc as PolyCurve;
                                        if (polycurve != null)
                                        {
                                            Curve[] segments = polycurve.Explode();
                                            if (segments.Count() != 1)
                                            {
                                                break;
                                            }
                                        }
                                        if (ghc != null)
                                        {
                                            //List<LyrebirdPoint> points = new List<LyrebirdPoint>();
                                            LyrebirdCurve lbc = GetLBCurve(ghc);
                                            List<LyrebirdCurve> lbcurves = new List<LyrebirdCurve> { lbc };

                                            RevitObject ro = new RevitObject
                                            {
                                                Curves = lbcurves,
                                                FamilyName = familyName,
                                                Category = category,
                                                CategoryId = categoryId,
                                                TypeName = typeName,
                                                Origin = null,
                                                GHPath = curves.Paths[i].ToString(),
                                                GHScaleFactor = scale.ScaleFactor,
                                                GHScaleName = scale.ScaleName
                                            };

                                            tempObjs.Add(ro);
                                        }
                                    }
                                    obj = tempObjs;
                                }
                            }
                            else
                            {
                                // Make sure all of the curves in each branch are closed
                                bool allClosed = true;
                                DataTree<CurveCheck> crvTree = new DataTree<CurveCheck>();
                                for (int i = 0; i < curves.Branches.Count; i++)
                                {
                                    List<GH_Curve> ghCrvs = curves.Branches[i];
                                    List<CurveCheck> checkedcurves = new List<CurveCheck>();
                                    GH_Path path = new GH_Path(i);
                                    for (int j = 0; j < ghCrvs.Count; j++)
                                    {
                                        Curve c = ghCrvs[j].Value;
                                        if (c.IsClosed)
                                        {
                                            AreaMassProperties amp = AreaMassProperties.Compute(c);
                                            if (amp != null)
                                            {
                                                double area = amp.Area;
                                                CurveCheck cc = new CurveCheck(c, area);
                                                checkedcurves.Add(cc);
                                            }
                                        }
                                        else
                                        {
                                            allClosed = false;
                                        }
                                    }
                                    if (allClosed)
                                    {
                                        // Sort the curves by area
                                        checkedcurves.Sort((x, y) => x.Area.CompareTo(y.Area));
                                        checkedcurves.Reverse();
                                        foreach (CurveCheck cc in checkedcurves)
                                        {
                                            crvTree.Add(cc, path);
                                        }
                                    }
                                }

                                if (allClosed)
                                {
                                    // Determine if the smaller profiles are within the larger
                                    bool allInterior = true;
                                    List<RevitObject> tempObjs = new List<RevitObject>();
                                    for (int i = 0; i < crvTree.Branches.Count; i++)
                                    {
                                        try
                                        {
                                            List<int> crvSegmentIds = new List<int>();
                                            List<LyrebirdCurve> lbCurves = new List<LyrebirdCurve>();
                                            List<CurveCheck> checkedCrvs = crvTree.Branches[i];
                                            Curve outerProfile = checkedCrvs[0].Curve;
                                            double outerArea = checkedCrvs[0].Area;
                                            List<Curve> planarCurves = new List<Curve>();
                                            planarCurves.Add(outerProfile);
                                            double innerArea = 0.0;
                                            for (int j = 1; j < checkedCrvs.Count; j++)
                                            {
                                                planarCurves.Add(checkedCrvs[j].Curve);
                                                innerArea += checkedCrvs[j].Area;
                                            }
                                            // Try to create a planar surface
                                            IEnumerable<Curve> surfCurves = planarCurves;
                                            Brep[] b = Brep.CreatePlanarBreps(surfCurves);
                                            if (b.Count() == 1)
                                            {
                                                // Test the areas
                                                double brepArea = b[0].GetArea();
                                                double calcArea = outerArea - innerArea;
                                                double diff = (brepArea - calcArea) / calcArea;

                                                if (diff < 0.1)
                                                {
                                                    // The profiles probably are all interior
                                                    foreach (CurveCheck cc in checkedCrvs)
                                                    {
                                                        Curve c = cc.Curve;
                                                        List<Curve> rCurves = new List<Curve>();
                                                        bool getCrvs = CurveSegments(rCurves, c, true);

                                                        if (rCurves.Count > 0)
                                                        {
                                                            int crvSeg = rCurves.Count;
                                                            crvSegmentIds.Add(crvSeg);
                                                            foreach (Curve rc in rCurves)
                                                            {
                                                                LyrebirdCurve lbc;
                                                                lbc = GetLBCurve(rc);
                                                                lbCurves.Add(lbc);
                                                            }
                                                        }
                                                    }
                                                    RevitObject ro = new RevitObject();
                                                    ro.Curves = lbCurves;
                                                    ro.FamilyName = familyName;
                                                    ro.Category = category;
                                                    ro.CategoryId = categoryId;
                                                    ro.TypeName = typeName;
                                                    ro.Origin = null;
                                                    ro.GHPath = crvTree.Paths[i].ToString();
                                                    ro.GHScaleFactor = scale.ScaleFactor;
                                                    ro.GHScaleName = scale.ScaleName;
                                                    ro.CurveIds = crvSegmentIds;
                                                    tempObjs.Add(ro);
                                                }
                                            }
                                            else
                                            {
                                                allInterior = false;
                                                message = "Warning:\n\nEach Branch represents an object, " +
                                                "so curve based elements should be grafted so that each curve is on it's own branch, or all curves on a branch should " +
                                                "be interior to the largest, outer boundary.";
                                            }
                                        }
                                        catch
                                        {
                                            allInterior = false;
                                            // Inform the user they need to graft their inputs.  Only one curve per branch
                                            message = "Warning:\n\nEach Branch represents an object, " +
                                                "so curve based elements should be grafted so that each curve is on it's own branch, or all curves on a branch should " +
                                                "be interior to the largest, outer boundary.";
                                        }
                                    }
                                    if (tempObjs.Count > 0)
                                    {
                                        obj = tempObjs;
                                    }
                                }
                            }
                        }
                        #endregion

                        // Orientation
                        if (orientations != null && orientations.Branches.Count > 0)
                        {
                            List<RevitObject> tempList = AssignOrientation(obj, orientations);
                            obj = tempList;
                        }

                        // face orientation
                        if (faceOrientations != null && faceOrientations.Branches.Count > 0)
                        {
                            List<RevitObject> tempList = AssignFaceOrientation(obj, faceOrientations);
                            obj = tempList;
                        }

                        // Parameters...
                        if (Params.Input.Count > 6)
                        {
                            List<RevitObject> currentObjs = obj;
                            List<RevitObject> tempObjs = new List<RevitObject>();
                            for (int r = 0; r < currentObjs.Count; r++)
                            {
                                RevitObject ro = currentObjs[r];
                                List<RevitParameter> revitParams = new List<RevitParameter>();
                                for (int i = 6; i < Params.Input.Count; i++)
                                {

                                    RevitParameter rp = new RevitParameter();
                                    IGH_Param param = Params.Input[i];
                                    string paramInfo = param.Description;
                                    string[] pi = paramInfo.Split(new[] { "\n", ":" }, StringSplitOptions.None);
                                    string paramName = null;
                                    try
                                    {
                                        paramName = pi[1].Substring(1);
                                        string paramStorageType = pi[5].Substring(1);
                                        rp.ParameterName = paramName;
                                        rp.StorageType = paramStorageType;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine(ex.Message);
                                    }
                                    if (paramName != null)
                                    {
                                        GH_Structure<IGH_Goo> data = null;
                                        try
                                        {
                                            DA.GetDataTree(i, out data);
                                        }
                                        catch (Exception ex)
                                        {
                                            Debug.WriteLine(ex.Message);
                                        }
                                        if (data != null)
                                        {
                                            string value = data[r][0].ToString();
                                            rp.Value = value;
                                            revitParams.Add(rp);
                                        }
                                    }

                                }
                                ro.Parameters = revitParams;
                                tempObjs.Add(ro);
                            }
                            obj = tempObjs;
                        }

                        // Send the data to Revit to create and/or modify family instances.
                        if (obj != null && obj.Count > 0)
                        {
                            try
                            {
                                string docName = channel.DocumentName();
                                if (docName == null || docName == string.Empty)
                                {
                                    message = "Could not contact the lyrebird server.  Make sure it's running and try again.";
                                }
                                else
                                {
                                    string nn = NickName;
                                    if (nn == null || nn.Length == 0)
                                    {
                                        nn = "LBOut";
                                    }
                                    channel.CreateOrModify(obj, InstanceGuid, NickName);
                                    message = obj.Count.ToString() + " objects sent to the lyrebird server.";
                                }
                            }
                            catch
                            {
                                message = "Could not contact the lyrebird server.  Make sure it's running and try again.";
                            }
                        }
                        channel.Dispose();
                        try
                        {
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        message = "Error\n" + "The Lyrebird Service could not be found.  Ensure Revit is running, the Lyrebird server plugin is installed, and the server is active.";
                    }
                }
            }
            else
            {
                message = null;
            }

            // Check if the revit information is set
            if (familyName != null || (familyName != "Not Selected" && typeName != "Not Selected"))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Family: " + familyName);
                sb.AppendLine("Type: " + typeName);
                sb.AppendLine("Category: " + category);
                for (int i = 0; i < inputParameters.Count; i++)
                {
                    RevitParameter rp = inputParameters[i];
                    string type = "Instance";
                    if (rp.IsType)
                    {
                        type = "Type";
                    }
                    sb.AppendLine(string.Format("Parameter{0}: {1}  /  {2}  /  {3}", (i + 1).ToString(CultureInfo.InvariantCulture), rp.ParameterName, rp.StorageType, type));
                }
                objMessage = sb.ToString();
            }
            else
            {
                objMessage = "No data type set.  Double-click to set data type";
            }

            DA.SetData(0, objMessage);
            DA.SetData(1, message);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //---- Declareing -------------------------------------------------------------------------------

            GH_Structure<GH_Point> SofistikPts;
            DA.GetDataTree("SofistikPoints", out SofistikPts);

            List<Point3d> flatclean = new List<Point3d>();
            DA.GetDataList<Point3d>("Flatten Points", flatclean);

            DataTree<int> SofistikInt = new DataTree<int>();

            //---- End Declareing ---------------------------------------------------------------------------

            //---- Functions --------------------------------------------------------------------------------

            for (int i = 0; i < flatclean.Count; i++)
            {
                Point3d fpoint = flatclean[i];

                for (int j = 0; j < SofistikPts.Paths.Count; j++)
                {
                    GH_Path pth = SofistikPts.Paths[j];
                    for (int k = 0; k < SofistikPts[pth].Count; k++)
                    {
                        GH_Point ghp = SofistikPts[pth][k];

                        if ((Math.Abs(fpoint.X - ghp.Value.X) <= 0.01) &&
                                (Math.Abs(fpoint.Y - ghp.Value.Y) <= 0.01) &&
                                (Math.Abs(fpoint.Z - ghp.Value.Z) <= 0.01))
                        {
                            SofistikInt.Add(i, pth.AppendElement(k));
                        }
                    }

                }
            }

            //---- End Functions ----------------------------------------------------------------------------

            //---- Set Output -----------------------------------------------------------------------------

            DA.SetDataTree(0, SofistikInt);

            //---- End Set Output -----------------------------------------------------------------------------
        }
        protected override void BeforeSolveInstance()
        {
            // input

            iSpringMesh = new SpringMesh();
            iPolyLine = new List<Curve>();
            iVertexStatus = new List<bool>(); // true is plate occupied, false should put triLoop
            iPolyLineID = new List<int>(); // for vertex status access the order of polyline
            iThickness = new List<double>();
            iAttractors = new List<Point3d>();
            iVertexPanel2 = new List<bool>();
            //ManualValueTree = new GH_Structure<GH_Number>();

            // output
            oInfo = string.Empty;
            oDebugList = new List<Vector3d>();
            oTriLoop = new DataTree<Brep>();
            oTriLoopID = new DataTree<string>();
            oTriLoopCurves = new DataTree<Curve>();
            oDualLoop1 = new DataTree<Brep>();
            oDualLoop2 = new DataTree<Brep>();
            oDualLoop1ID = new DataTree<string>();
            oDualLoop2ID = new DataTree<string>();
            oDualLoop1Curves = new DataTree<Curve>();
            oDualLoop2Curves = new DataTree<Curve>();
            oClosedPanel = new DataTree<Brep>();
            oTriLoopPlanCrv = new DataTree<Curve>();
            oTriLoopEffectorHoles = new DataTree<Point3d>();

            // internal use data
            topCenterPts = new List<Point3d>();
            bottomCenterPts = new List<Point3d>();
            topCenterPolygonOccupied = new List<bool>(); // not be used at this moment

            bottomCps = new List<Point3d>();
            topCps = new List<Point3d>();

            indexSortPolygon = new List<int[]>();   // array is reference type in csharp

            verticesValues = new List<double>();
            curveVerticesValues = new List<double>();
            planarVerticesValues = new List<double>();
            openingWidthVerticesValues = new List<double>();
            pointinessValues = new List<double>();
            ManualAdjustedVertexIndexies = new List<int>();
        }
Пример #55
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Retrieve and validate data
            var cell = new UnitCell();
            double radius = 0;
            double height = 0;
            int nU = 0;
            int nV = 0;
            int nW = 0;
            bool morphed = false;

            if (!DA.GetData(0, ref cell)) { return; }
            if (!DA.GetData(1, ref radius)) { return; }
            if (!DA.GetData(2, ref height)) { return; }
            if (!DA.GetData(3, ref nU)) { return; }
            if (!DA.GetData(4, ref nV)) { return; }
            if (!DA.GetData(5, ref nW)) { return; }
            if (!DA.GetData(6, ref morphed)) { return; }

            if (!cell.isValid) { return; }
            if (radius == 0) { return; }
            if (height == 0) { return; }
            if (nU == 0) { return; }
            if (nV == 0) { return; }
            if (nW == 0) { return; }

            // 2. Initialize the lattice
            var lattice = new Lattice();
            // Will contain the morphed uv spaces (as surface-surface, surface-axis or surface-point)
            var spaceTree = new DataTree<GeometryBase>(); 
            
            // 3. Define cylinder
            Plane basePlane = Plane.WorldXY;
            Surface cylinder = ( new Cylinder(new Circle(basePlane, radius), height) ).ToNurbsSurface();
            cylinder = cylinder.Transpose();
            LineCurve axis = new LineCurve(basePlane.Origin, basePlane.Origin + height*basePlane.ZAxis);

            // 4. Package the number of cells in each direction into an array
            float[] N = new float[3] { nU, nV, nW };

            // 5. Normalize the UV-domain
            Interval unitDomain = new Interval(0, 1);
            cylinder.SetDomain(0, unitDomain); // surface u-direction
            cylinder.SetDomain(1, unitDomain); // surface v-direction
            axis.Domain = unitDomain;

            // 6. Prepare cell (this is a UnitCell object)
            cell = cell.Duplicate();
            cell.FormatTopology();

            // 7. Map nodes to design space
            //    Loop through the uvw cell grid
            for (int u = 0; u <= N[0]; u++)
            {
                for (int v = 0; v <= N[1]; v++)
                {
                    for (int w = 0; w <= N[2]; w++)
                    {
                        // Construct cell path in tree
                        GH_Path treePath = new GH_Path(u, v, w);
                        // Fetch the list of nodes to append to, or initialise it
                        var nodeList = lattice.Nodes.EnsurePath(treePath);      

                        // This loop maps each node index in the cell onto the UV-surface maps
                        for (int i = 0; i < cell.Nodes.Count; i++)
                        {
                            double usub = cell.Nodes[i].X; // u-position within unit cell (local)
                            double vsub = cell.Nodes[i].Y; // v-position within unit cell (local)
                            double wsub = cell.Nodes[i].Z; // w-position within unit cell (local)
                            double[] uvw = { u + usub, v + vsub, w + wsub }; // uvw-position (global)

                            // Check if the node belongs to another cell (i.e. it's relative path points outside the current cell)
                            bool isOutsideCell = (cell.NodePaths[i][0] > 0 || cell.NodePaths[i][1] > 0 || cell.NodePaths[i][2] > 0);
                            // Check if current uvw-position is beyond the upper boundary
                            bool isOutsideSpace = (uvw[0] > N[0] || uvw[1] > N[1] || uvw[2] > N[2]);

                            if (isOutsideCell || isOutsideSpace)
                            {
                                nodeList.Add(null);
                            }
                            else
                            {
                                Point3d pt1, pt2;
                                Vector3d[] derivatives;

                                // Construct z-position vector
                                Vector3d vectorZ = height * basePlane.ZAxis * uvw[0] / N[0];
                                // Compute pt1 (on axis)
                                pt1 = basePlane.Origin + vectorZ;
                                // Compute pt2 (on surface)
                                cylinder.Evaluate(uvw[0] / N[0], uvw[1] / N[1], 2, out pt2, out derivatives);       

                                // Create vector joining these two points
                                Vector3d wVect = pt2 - pt1;
                                // Instantiate new node
                                var newNode = new LatticeNode(pt1 + wVect * uvw[2] / N[2]);
                                // Add new node to tree
                                nodeList.Add(newNode); 
                            }
                        }
                    }

                    // Define the uv space map tree (used for morphing)
                    if (morphed && u < N[0] && v < N[1])
                    {
                        GH_Path spacePath = new GH_Path(u, v);
                        // Set trimming interval
                        var uInterval = new Interval((u) / N[0], (u + 1) / N[0]);                   
                        var vInterval = new Interval((v) / N[1], (v + 1) / N[1]);
                        // Create sub-surface and sub axis
                        Surface ss1 = cylinder.Trim(uInterval, vInterval);                          
                        Curve ss2 = axis.Trim(uInterval);
                        // Unitize domains
                        ss1.SetDomain(0, unitDomain); ss1.SetDomain(1, unitDomain);                 
                        ss2.Domain = unitDomain;
                        // Save to the space tree
                        spaceTree.Add(ss1, spacePath);
                        spaceTree.Add(ss2, spacePath);
                    }
                }
            }

            // 8. Map struts to the node tree
            if (morphed)
            {
                lattice.MorphMapping(cell, spaceTree, N);
            }
            else
            {
                lattice.ConformMapping(cell, N);
            }

            // 9. Set output
            DA.SetDataList(0, lattice.Struts);            
        }
Пример #56
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Declare placeholder
            string source = null;
            string query = null;
            string indexPath = null;

            DataTree<string> queryResultTree = new DataTree<string>();

            // 2. Abort on invalid inputs.
            if (!DA.GetData(0, ref source)) { return; }
            if (source == null) { return; }
            if (source.Length == 0) { return; }
            if (!DA.GetData(1, ref query)) { return; }
            if (query == null) { return; }
            if (query.Length == 0) { return; }
            if (!DA.GetData(2, ref indexPath)) { return; }
            if (query == null) { return; }
            if (query.Length == 0) { return; }

            gh_watcher = new GH_FileWatcher(indexPath, true, gh_watcher_Changed);

            // 3. Connect to source & fetch data

            MySqlConnection connection = new MySqlConnection(source);

            try
            {
                connection.Open();
            }
            catch (Exception ex)
            {
                output.Add("Connection Failed.\n" + ex.ToString());
            }

            try
            {
                MySqlCommand command = connection.CreateCommand();
                command.CommandText = query;

                MySqlDataReader reader = command.ExecuteReader();

                int i = 0;
                while (reader.Read())
                {
                    for (int j = 0; j < reader.FieldCount; j++)
                    {
                        queryResultTree.Add(reader.GetString(j), new GH_Path(i));
                    }
                    i++;
                }
            }
            catch (Exception ex)
            {
                output.Add("Fetching failed.\n" + ex.ToString());
            }

            connection.Close();

            // 4. Output
            DA.SetDataTree(0, queryResultTree);
            DA.SetDataList(1, output);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //-----------------------------------------------------------------INPUT----------------------------------------------------------------------------//

            List<IGoal> permanentGoals = new List<IGoal>();
            DA.GetDataList(0, permanentGoals);

            List<IGoal> loadGoals = new List<IGoal>();
            DA.GetDataList(1, loadGoals);

            double fStart = 1.0;
            DA.GetData(2, ref fStart);

            double fStep = 0.1;
            DA.GetData(3, ref fStep);

            double angle = 15.0;
            DA.GetData(4, ref angle);
            angle *= Math.PI / 180.0;

            double displ = 2.0;
            DA.GetData(5, ref displ);

            double threshold = 1e-15;
            DA.GetData(6, ref threshold);

            int equilibriumIter = 100;
            DA.GetData(7, ref equilibriumIter);

            bool opt = false;
            DA.GetData(8, ref opt);

            int maxIterations = 1000;


            //--------------------------------------------------------------CALCULATE----------------------------------------------------------------------------//

            //-------------------VALUES TO STORE----------------------------//
            //Position lists
            List<Point3d> initialPositions = new List<Point3d>();
            List<Point3d> previousPositions = new List<Point3d>();
            List<Point3d> currentPositions = new List<Point3d>();
            DataTree<Point3d> vertexPositions = new DataTree<Point3d>();

            //Goal output lists
            List<object> previousGOutput = new List<object>();
            List<object> currentGOutput = new List<object>();
            DataTree<object> outputGoals = new DataTree<object>();

            //Load factors and displacements
            List<double> loadfactors = new List<double>();
            List<double> displacementsRMS = new List<double>();


            //-------------------K2 PHYSICAL SYSTEM----------------------------//
            //Initialise Kangaroo solver
            var PS = new KangarooSolver.PhysicalSystem();
            var GoalList = new List<IGoal>();

            //Assign indexes to the particles in each Goal
            foreach (IGoal pG in permanentGoals)
            {
                PS.AssignPIndex(pG, 0.01);
                GoalList.Add(pG);
            }

            foreach (IGoal lG in loadGoals)
            {
                PS.AssignPIndex(lG, 0.01);
                GoalList.Add(lG);
            }

            //Store initial loads
            List<Vector3d> initialLoads = new List<Vector3d>();
            for (int i = 0; i < loadGoals.Count; i++)
            {
                initialLoads.Add(loadGoals[i].Move[0]);
            }


            //-------------------INITIALISE VALUE LISTS----------------------------//
            //Initial vertex positions
            Point3d[] initPos = PS.GetPositionArray();
            foreach (Point3d pt in initPos)
            {
                initialPositions.Add(pt);
                previousPositions.Add(pt);
                currentPositions.Add(pt);
            }

            //Initial goal output
            List<object> initGOutput = PS.GetOutput(GoalList);
            for (int i = 0; i < permanentGoals.Count; i++)
            {
                previousGOutput.Add(initGOutput[i]);
                currentGOutput.Add(initGOutput[i]);
            }


            //-------------------LOAD INCREMENT LOOP----------------------------//
            bool run = true;
            int iter = 0;

            double LF;
            double BLF = 0.0;
            double preRMS = 0.0;

            while (run && iter < maxIterations)
            {
                LF = fStart + (fStep * iter);
                loadfactors.Add(LF);

                //Scale load goals in each iteration
                for (int i = 0; i < loadGoals.Count; i++)
                {
                    int index = GoalList.Count - loadGoals.Count + i;
                    Vector3d scaledLoad = initialLoads[i] * LF;
                    GoalList[index] = new KangarooSolver.Goals.Unary(GoalList[index].PIndex[0], scaledLoad);
                }


                //Solve equilibrium for given load increment
                int counter = 0;
                do
                {
                    PS.Step(GoalList, true, threshold);
                    counter++;
                } while (PS.GetvSum() > threshold && counter < equilibriumIter);



                //Update value lists
                GH_Path path = new GH_Path(iter);

                //Get new equilibrium positions and update position lists
                Point3d[] newPositions = PS.GetPositionArray();

                for (int k = 0; k < initialPositions.Count; k++)
                {
                    previousPositions[k] = currentPositions[k];
                    currentPositions[k] = newPositions[k];

                    if (opt)
                    {
                        vertexPositions.Add(newPositions[k], path);
                    }
                }

                //Get new goal output and update goal output lists
                List<object> newGOutput = PS.GetOutput(GoalList);
                for (int m = 0; m < permanentGoals.Count; m++)
                {
                    previousGOutput[m] = currentGOutput[m];
                    currentGOutput[m] = newGOutput[m];

                    if (opt)
                    {
                        outputGoals.Add(newGOutput[m], path);
                    }
                }



                //Does buckling occur?
                List<Vector3d> nodalDisplacements = calcDisplacement(currentPositions, initialPositions);
                double curRMS = calcDisplacementsRMS(nodalDisplacements);
                displacementsRMS.Add(curRMS);

                bool buckled = isBuckled(curRMS, preRMS, iter, fStart, fStep, angle);
                bool deflected = isDeflectionTooBig(nodalDisplacements, displ);

                if (buckled || deflected)
                {
                    run = false;
                    BLF = LF - fStep;
                }

                //Update
                preRMS = curRMS;
                iter++;
            }


            //-----------------------FLAG BUCKLED STATE----------------------------//
            if (BLF >= 1.0)
            {
                this.Message = "Works!";
            }
            else
            {
                this.Message = "Buckles!";
            }


            //-----------------------WARNING----------------------------//
            //If the maximum number of iterations has been reached
            if (iter == maxIterations)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Buckling did not occur within " + maxIterations + " load increments. Adjust load-step");
            }


            //-----------------------UPDATE VALUE LISTS----------------------------//
            //If opt is false then add results from last two iterations
            if (!opt)
            {
                for (int i = 0; i < currentPositions.Count; i++)
                {
                    vertexPositions.Add(previousPositions[i], new GH_Path(0));
                    vertexPositions.Add(currentPositions[i], new GH_Path(1));
                }

                for (int j = 0; j < currentGOutput.Count; j++)
                {
                    outputGoals.Add(previousGOutput[j], new GH_Path(0));
                    outputGoals.Add(currentGOutput[j], new GH_Path(1));
                }

            }


            //---------------------------------------------------------------OUTPUT-------------------------------------------------------------------------------//

            DA.SetData(0, BLF);
            DA.SetDataList(1, loadfactors);
            DA.SetDataList(2, displacementsRMS);
            DA.SetDataTree(3, vertexPositions);
            DA.SetDataTree(4, outputGoals);
        }
Пример #58
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //---- Declareing ---------------------------------------------------------------------------

            List<Tri_Loop_Component> All_Components = new List<Tri_Loop_Component>();
            DA.GetDataList<Tri_Loop_Component>("Components", All_Components);

            DataTree<Point3d> SofistikPoints = new DataTree<Point3d>();
            DataTree<int> SofistikIndexies = new DataTree<int>();

            DataTree<int> SofistikCrvPtIdx = new DataTree<int>();
            DataTree<Point3d> SofistikCrvPtCoo = new DataTree<Point3d>();

            DataTree<Brep> SofistikBreps = new DataTree<Brep>();
            DataTree<int> SofistikBrepsIdx = new DataTree<int>();

            DataTree<Curve> SofistikCurves = new DataTree<Curve>();

            //---- End Declareing -----------------------------------------------------------------------

            //---- Functions ----------------------------------------------------------------------------

            int componentIdx = 0;

            foreach (Tri_Loop_Component component in All_Components)
            {
                GH_Path pth1 = new GH_Path(componentIdx);

                // run / generate Informations for Sofistik
                component.SofistikInformation();
                component.SofistikCreateSurfaces();

                // Points
                for (int j = 0; j < component.SofistikPlatePoints.BranchCount; j++)
                {

                    foreach (Point3d p in component.SofistikPlatePoints.Branch(j))
                    { SofistikPoints.Add(p, pth1.AppendElement(j)); }

                    foreach (int idx in component.SofistikPlateIndexies.Branch(j))
                    { SofistikIndexies.Add(idx, pth1.AppendElement(j)); }
                }

                // CurvePoints
                for (int j = 0; j < component.SofistikCrvPtCoo.BranchCount; j++)
                {
                    GH_Path pth0 = component.SofistikCrvPtCoo.Path(j);

                    foreach (Point3d pt in component.SofistikCrvPtCoo.Branch(j))
                    {
                        //pth1.AppendElement(pth0[0]);
                        //pth1.AppendElement(pth0[1]);
                        //SofistikCrvPtCoo.Add(pt, pth1.AppendElement(pth0[0]));

                        // 2 level Tree
                        SofistikCrvPtCoo.Add(pt, pth1.AppendElement(pth0[0]));

                    }

                    foreach (int idx in component.SofistikCrvPtIdx.Branch(j))
                    {
                        //pth1.AppendElement(pth0[0]);
                        //pth1.AppendElement(pth0[1]);
                        //SofistikCrvPtIdx.Add(idx, pth1.AppendElement(pth0[0]));

                        // 2 level Tree
                        SofistikCrvPtIdx.Add(idx, pth1.AppendElement(pth0[0]));

                    }
                }

                // Curves
                for (int i = 0; i < component.SofistikCurves.BranchCount; i++)
                {
                    GH_Path pth0 = component.SofistikCurves.Path(i);

                    foreach (Curve c in component.SofistikCurves.Branch(i))
                    {
                        SofistikCurves.Add(c, pth1.AppendElement(pth0[0]));
                    }

                }

                // Surfaces
                for (int j = 0; j < component.SofistikSurfaces.BranchCount; j++)
                {

                    foreach (Brep[] p in component.SofistikSurfaces.Branch(j))
                    { SofistikBreps.Add(p[0], pth1.AppendElement(j)); }

                    foreach (int idx in component.SofistikSurfacesIdx.Branch(j))
                    { SofistikBrepsIdx.Add(idx, pth1.AppendElement(j)); }
                }

                componentIdx++;
            }

            //---- End Functions ------------------------------------------------------------------------
            //---- Set Output ---------------------------------------------------------------------------

            DA.SetDataTree(0, SofistikPoints);
            DA.SetDataTree(1, SofistikIndexies);

            DA.SetDataTree(2, SofistikCrvPtCoo);
            DA.SetDataTree(3, SofistikCrvPtIdx);

            DA.SetDataTree(4, SofistikBreps);
            DA.SetDataTree(5, SofistikBrepsIdx);

            DA.SetDataTree(6, SofistikCurves);

            //---- End Set Output -----------------------------------------------------------------------
        }
	public TreeToGraphConverter (DataTree tree)
	{
		Tree = tree;
		DirectedGraph= new DirectedGraph<string>();
	}
Пример #60
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //---- Declareing ---------------------------------------------------------------------------

            List<Tri_Loop_Component> All_Components = new List<Tri_Loop_Component>();
            DA.GetDataList<Tri_Loop_Component>("Components", All_Components);

            DataTree<Curve> All_Curves = new DataTree<Curve>();

            //// =======================================================================================
            // Added by Gene
            DataTree<Curve> All_ExtendedCurves = new DataTree<Curve>();
            DataTree<Brep> All_SingleStripeBreps = new DataTree<Brep>();

            //// =======================================================================================

            DataTree<Point3d> All_CentrePointsL01 = new DataTree<Point3d>();
            DataTree<Point3d> All_CentrePointsL02 = new DataTree<Point3d>();
            DataTree<Curve> All_PlateCrv = new DataTree<Curve>();

            DataTree<Point3d> All_PentagonPts_L01 = new DataTree<Point3d>();
            DataTree<Point3d> All_PentagonPts_L02 = new DataTree<Point3d>();

            DataTree<int> All_StripeIds = new DataTree<int>();
            DataTree<Brep> All_StripeBreps = new DataTree<Brep>();
            DataTree<Curve> All_StripeIntersectCrvs = new DataTree<Curve>();
            DataTree<Plane> All_StripeIntersectPlane = new DataTree<Plane>();

            //---- End Declareing -----------------------------------------------------------------------
            //---- Functions ----------------------------------------------------------------------------

            int componentIdx = 0;

            foreach (Tri_Loop_Component component in All_Components)
            {
                GH_Path pth1 = new GH_Path(componentIdx);

                // run / generate Informations for Sofistik
                // create output information
                for (int p = 0; p < component.CentersL01.Count; p++)
                {
                    All_CentrePointsL01.Add(component.CentersL01[p], pth1);
                    All_CentrePointsL02.Add(component.CentersL02[p], pth1);
                }

                for (int c = 0; c < component.Curves.BranchCount; c++)
                {
                    All_Curves.Add(component.Curves.Branch(c)[0], pth1.AppendElement(c));
                    All_Curves.Add(component.Curves.Branch(c)[1], pth1.AppendElement(c));

                    //// =======================================================================================
                    // Added by Gene
                    All_ExtendedCurves.Add(component.ExtendedCurves.Branch(c)[0], pth1.AppendElement(c));
                    All_ExtendedCurves.Add(component.ExtendedCurves.Branch(c)[1], pth1.AppendElement(c));
                    //// =======================================================================================
                }

                for (int sid = 0; sid < component.StripeID.BranchCount; sid++)
                {
                    All_StripeIds.Add(component.StripeID.Branch(sid)[0], pth1.AppendElement(sid));
                    All_StripeIds.Add(component.StripeID.Branch(sid)[1], pth1.AppendElement(sid));
                    All_StripeIds.Add(component.StripeID.Branch(sid)[2], pth1.AppendElement(sid));
                }

                for (int p = 0; p < component.PlateCrv.BranchCount; p++)
                {
                    All_PlateCrv.Add(component.PlateCrv.Branch(p)[0], pth1.AppendElement(p));
                    All_PlateCrv.Add(component.PlateCrv.Branch(p)[1], pth1.AppendElement(p));
                }

                for (int pent = 0; pent < component.PlanarPentagonL01.BranchCount; pent++)
                {
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[0], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[1], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[2], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[3], pth1.AppendElement(pent));
                    All_PentagonPts_L01.Add(component.PlanarPentagonL01.Branch(pent)[4], pth1.AppendElement(pent));
                }

                for (int pent = 0; pent < component.PlanarPentagonL02.BranchCount; pent++)
                {
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[0], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[1], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[2], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[3], pth1.AppendElement(pent));
                    All_PentagonPts_L02.Add(component.PlanarPentagonL02.Branch(pent)[4], pth1.AppendElement(pent));
                }

                // Information from Stripe Class
                for (int s = 0; s < component.Stripes.Count; s++)
                {
                    for (int t = 0; t < component.Stripes[s].SurfaceAtLoop.Length; t++)
                    { All_StripeBreps.Add(component.Stripes[s].SurfaceAtLoop[t], pth1.AppendElement(s)); }

                    //for (int u = 0; u < component.Stripes[s].IntersectionCurve.Length; u++)
                    //{ All_StripeIntersectCrvs.Add(component.Stripes[s].IntersectionCurve[u], pth1.AppendElement(s));}

                    All_StripeIntersectPlane.Add(component.Stripes[s].IntersectionPlane, pth1.AppendElement(s));
                }

                // ======================================================================================================
                // Gene Added

                for (int s = 0; s < component.StripesSingle.Count; s++)
                {
                    All_SingleStripeBreps.Add(component.StripesSingle[s].loop, pth1.AppendElement(s));

                    //for (int u = 0; u < component.Stripes[s].IntersectionCurve.Length; u++)
                    //{ All_StripeIntersectCrvs.Add(component.Stripes[s].IntersectionCurve[u], pth1.AppendElement(s));}

                    //All_StripeIntersectPlane.Add(component.StripesSingle[s].IntersectionPlane, pth1.AppendElement(s));
                }

                // ======================================================================================================

                componentIdx++;
            }

            //---- End Functions ------------------------------------------------------------------------
            //---- Set Output ---------------------------------------------------------------------------

            DA.SetDataTree(0, All_CentrePointsL01);
            DA.SetDataTree(1, All_CentrePointsL02);
            DA.SetDataTree(2, All_Curves);
            DA.SetDataTree(3, All_PlateCrv);
            DA.SetDataTree(4, All_PentagonPts_L01);
            DA.SetDataTree(5, All_PentagonPts_L02);
            DA.SetDataTree(6, All_StripeIds);
            DA.SetDataTree(7, All_StripeBreps);
            DA.SetDataTree(8, All_StripeIntersectPlane);

            //// =======================================================================================
            // Added by Gene

            DA.SetDataTree(9, All_ExtendedCurves);
            DA.SetDataTree(10, All_SingleStripeBreps);
            //// =======================================================================================

            //---- End Set Output -----------------------------------------------------------------------
        }