Inheritance: MonoBehaviour
Exemplo n.º 1
0
 public static Branch mapToJSON(branch item)
 {
     Branch json = new Branch();
     json.id = item.id;
     json.name = item.name;
     return json;
 }
        public IHttpActionResult Putbranch(int id, branch branch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != branch.id_Branch)
            {
                return(BadRequest());
            }

            db.Entry(branch).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!branchExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
    public loadTree(string filename)
    {
        List <String> ligaments;

        ligaments = File.ReadAllText(filename).Split('\n').ToList();
        trunk     = makeBranch(ref ligaments);
        Debug.Log(trunk.name);
        Debug.Log(trunk.length);
        Debug.Log(trunk);
    }
        public IHttpActionResult Getbranch(int id)
        {
            branch branch = db.branches.Find(id);

            if (branch == null)
            {
                return(NotFound());
            }

            return(Ok(branch));
        }
Exemplo n.º 5
0
 //once we have the main tree and we know how manny branches we have we add them to a list fro bottom to top
 branch[] connectBranches(branch mainTrunk)
 {
     List<branch> branches = new List<branch> ();
     for(int i=0; i < mainTrunk.contents.Length; i++)
     {
         if(mainTrunk.contents[i] == branchCharacter)
         {
             branches.Add(new branch(branchRules.runRules(branchLength,'o'),mainTrunk,i));
         }
     }
     return branches.ToArray();
 }
        public IHttpActionResult Postbranch(branch branch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.branches.Add(branch);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = branch.id_Branch }, branch));
        }
Exemplo n.º 7
0
        public void GetDefault_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new BranchRepository(context);

            // Act
            branch result = repository.GetDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue((bool)result.isDefault);
        }
Exemplo n.º 8
0
 //quick function to draw the tree
 void drawBranch(Vector3 startingPositon,branch _branch,tree _tree,int branchChildIndex)
 {
     for (int i =0; i < _branch.contents.Length -1; i++)
     {
         Vector3 endPoint = getDriection(_branch.rotation,_branch.contents[i]);
         Gizmos.DrawLine(startingPositon,startingPositon + endPoint);
         startingPositon += endPoint;
         if(_branch.contents[i] == branchCharacter)
         {
             drawBranch(startingPositon,_tree.branches[branchChildIndex],_tree,branchChildIndex);
             branchChildIndex++;
         }
     }
 }
Exemplo n.º 9
0
        public void GetById_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new BranchRepository(context);
            int id         = 1;

            // Act
            branch result = repository.GetById(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(id, result.id);
        }
Exemplo n.º 10
0
    public static List <branch> getBranch2(string districtId, string branchId)
    {
        CNManagerDataContext db = new CNManagerDataContext();
        var c = new List <branch>();


        var x = (from m in db.tBranches
                 where m.BranchTypeId == branchTypeId && m.Status == 1 && m.IsDisplay == true
                 select new { m.Id, m.BranchName, m.DistrictName, m.CountryName, m.Address, m.Time, m.Phone, m.Fax, m.Longitude, m.Latitude }).Skip(0).Take(1);

        if (branchId != "")
        {
            x = from m in db.tBranches
                where m.BranchTypeId == branchTypeId && m.Id == int.Parse(branchId) && m.Status == 1 && m.IsDisplay == true
                select new { m.Id, m.BranchName, m.DistrictName, m.CountryName, m.Address, m.Time, m.Phone, m.Fax, m.Longitude, m.Latitude };
        }
        else
        if (districtId != "")
        {
            x = from m in db.tBranches
                where m.BranchTypeId == branchTypeId && m.DistrictId == int.Parse(districtId) && m.Status == 1 && m.IsDisplay == true
                select new { m.Id, m.BranchName, m.DistrictName, m.CountryName, m.Address, m.Time, m.Phone, m.Fax, m.Longitude, m.Latitude };
        }

        if (x.Count() > 0)
        {
            foreach (var item in x.ToList())
            {
                var b = new branch();
                b.ID           = item.Id.ToString();
                b.Name         = item.BranchName;
                b.Add          = item.Address;
                b.Fax          = item.Fax;
                b.Latitude     = item.Latitude;
                b.Longitude    = item.Longitude;
                b.Phone        = item.Phone;
                b.Time         = item.Time;
                b.CountryName  = item.CountryName;
                b.DistrictName = item.DistrictName;
                c.Add(b);
            }
        }
        return(c);
    }
Exemplo n.º 11
0
    public branch makeBranch(ref List <String> section)
    {
        branch ret = new branch(section[0]);

        section.RemoveAt(0);
        if (section.Count > 0)
        {
            branch next = new branch(section[0]);
            while (next.level > ret.level)
            {
                branch br = makeBranch(ref section);
                ret.branches.Add(br);
                if (section.Count > 0)
                {
                    next = new branch(section[0]);
                }
            }
        }
        return(ret);
    }
Exemplo n.º 12
0
 public branch(branch other)
 {
     this.p1 = other.p1; this.p2 = other.p2; this.p3 = other.p3;
       this.R = other.R;this.length = other.length;this.deg = other.deg;
 }
Exemplo n.º 13
0
 //creates the base tree tells the connect connectBranches to make branches accordingly
 void generateTree()
 {
     branch trunk = new branch (treeRules.runRules (treeHeight, 'u'));
     myTree = new tree (trunk, connectBranches(trunk));
 }
Exemplo n.º 14
0
 public tree(branch _mainTree,branch[] _branches)
 {
     mainTree = _mainTree;
     branches = _branches;
 }
Exemplo n.º 15
0
        public static List<branch> grow(List<branch> bls, Brep b)
        {
            Random rnd = new Random();
              List<branch> output = new List<branch>();
              for (int i = 0; i < bls.Count; i++)
              {
            branch b3 = bls[i];
            if (b3.life)
            {
              branch b1 = new branch(b3.p2, b3.length, b3.deg);
              branch b2 = new branch(b3.p3, b3.length, b3.deg);
              double seed = rnd.NextDouble();
              if(seed > 0.3333 && seed < 0.666){b1.rotateBranch();}
              if(seed > 0.666){b1.rotateBranch();}
              seed = rnd.NextDouble();
              if(seed > 0.3333 && seed < 0.666){b2.rotateBranch();}
              if(seed > 0.666){b2.rotateBranch();}
              output.Add(new branch(b1));
              output.Add(new branch(b2));
              b3.life = false;
            }
              }

              for (int i = 0; i < output.Count; i++)
              {
            for (int j = 0; j < output.Count; j++)
            { if(i != j && output[j].life ){
            if(output[i].collide(output[j])){
              output[i].life = false; break;
            }
              }
            }

            for (int j = 0; j < bls.Count; j++){
              if(output[i].collide(bls[j])){
            output[i].life = false; break;
              }
            }
              }

              List<branch> output2 = new List<branch>();
              for (int i = 0; i < output.Count; i++)
              {
            if (output[i].life) output2.Add(output[i]);
              }
              return output2;
        }
Exemplo n.º 16
0
 public bool collide(branch b1)
 {
     if (this.p2.Origin.DistanceTo(b1.p2.Origin) < this.R * 2 ) return true;
       if (this.p2.Origin.DistanceTo(b1.p3.Origin) < this.R * 2 ) return true;
       if (this.p3.Origin.DistanceTo(b1.p2.Origin) < this.R * 2 ) return true;
       if (this.p3.Origin.DistanceTo(b1.p3.Origin) < this.R * 2 ) return true;
       return false;
 }
Exemplo n.º 17
0
 public branch(string _contents, branch _parent, int _parrentindex)
 {
     contents = _contents;
     parent = _parent;
     parrentIndex	= _parrentindex;
     rotation = randomRotation();
 }