コード例 #1
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
 public override void _Ready()
 {
     Brace brace = (Brace)GetNode("Brace");
     brace.anchor = this;
     braces.Add(brace);
     setActive(false);
 }
コード例 #2
0
    public static void Valid(string s)
    {
        bool expected = true;
        bool actual   = Brace.validBraces(s);

        Assert.AreEqual(expected, actual);
    }
コード例 #3
0
        static void Main(string[] args)
        {
            Program a = new Program();

            var b = a.A;
            var c = a.Filter(b);

            var d = a.Call(a.Brace1, b);
            var e = a.Call(a.Brace2, b);

            var f = a.Call(a.Brace1, c);
            var g = a.Call(a.Brace2, c);

            a.Sink(d);
            a.Sink(e); // False positive!!!
            a.Sink(f);
            a.Sink(g);

            Brace anonBrace = i => i;

            var h = a.Call(anonBrace, b);
            var j = a.Call(anonBrace, c);

            a.Sink(h);
            a.Sink(j);
        }
コード例 #4
0
        public BraceVisual3D(Color color, TeethVisual3D p, bool generatedSample)
        {
            if (p != null)
            {
                this.parent = p;
                gc          = this.parent.gc;
                tc          = this.parent.tc;
                bc          = this.parent.bc;
                wc          = this.parent.wc;

                Id = p.Id + "_brace" + bc.Children.Count.ToString("00") + "." + p.Parent.Parent.patient.Id;;

                if (model == null)
                {
                    model = new Brace();
                }
                model.Id       = Id;
                model.Location = (IsOuterBrace ? Smile.OUTERBRACE : Smile.INNERBRACE);

                if (generatedSample)
                {
                    sample(color);
                }

                Bind(parent);
                //BindingOperations.SetBinding(this, TransformProperty, new Binding("TargetTransform") { Source = this });
                //BindingOperations.SetBinding(this.Manipulator,CombinedManipulator.TargetTransformProperty,new Binding("TargetTransform") { Source = this });
            }
        }
コード例 #5
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
 public void removeBraceFromList(Brace brace)
 {
     braces.Remove(brace);
     if (braces.Count == 0)
         destory();
     else
     {
         List<Brace> connected = new List<Brace>();
         braces[0].ConnectedBraces(connected);
         if (connected.Count != braces.Count)
         {
             Brace notConnectedBrace = null;
             List<Brace> notConnected = new List<Brace>();
             for(int i = 0; i < braces.Count; i++)  // TODO: lots of repeated checks
             {
                 if (!connected.Contains(braces[i]))
                 {
                     notConnectedBrace = braces[i];
                     notConnectedBrace.ConnectedBraces(notConnected);
                 }
             }
             foreach(Brace nbrace in notConnected)
                 braces.Remove(nbrace);
             
             GD.Print(braces.Count);
             constructor.newSumAnchor(notConnected, this);
             CenterGravity();
         }
     }
 }
コード例 #6
0
 static void Main()
 {
     string[] arr = new[] { "()", "[(])", "{([]{()})}", "{([]{()})}(", "{([]{()})" };
     foreach (string sample in arr)
     {
         Console.WriteLine("{0}: {1}", sample, Brace.validBraces(sample));
     }
 }
コード例 #7
0
        public void Construct_Brace()
        {
            var l = new Line(Vector3.Origin, new Vector3(5, 5, 5));
            var b = new Brace(l, new WideFlangeProfile("test"));

            Assert.Equal(BuiltInMaterials.Steel, b.Material);
            Assert.Equal(l, b.CenterLine);
        }
コード例 #8
0
        private static IfcMember ToIfc(this Brace column, Guid id,
                                       IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape)
        {
            var member = new IfcMember(IfcGuid.ToIfcGuid(id), null,
                                       null, null, null, localPlacement, shape, null, IfcMemberTypeEnum.NOTDEFINED);

            return(member);
        }
コード例 #9
0
    public void connect(Brace brace)
    {
        var       connectorScene = GD.Load <PackedScene>("res://Scenes/Assets/Connector.tscn");
        Connector connector      = (Connector)connectorScene.Instance();

        GetParent().AddChild(connector);
        connector.setShape(this, brace);
    }
コード例 #10
0
 public void Test2()
 {
     Assert.AreEqual(false, Brace.ValidBraces("[(])"));
     Assert.AreEqual(true, Brace.ValidBraces("{[()]}"));
     Assert.AreEqual(true, Brace.ValidBraces("{([])}"));
     Assert.AreEqual(true, Brace.ValidBraces("{[]()}"));
     Assert.AreEqual(true, Brace.ValidBraces("[](){}"));
 }
コード例 #11
0
        private static IfcMember ToIfc(this Brace column,
                                       IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape)
        {
            var member = new IfcMember(IfcGuid.ToIfcGuid(Guid.NewGuid()), null,
                                       null, null, null, localPlacement, shape, null);

            return(member);
        }
コード例 #12
0
        public static CustomAttributeEditorBrace CreateCustomAttributEditorBrace(Brace model)
        {
            var brace = new CustomAttributeEditorBrace();

            brace.Type = "Brace";
            //TODO: assign the model data to the editor
            brace.Id       = model.Id;
            brace.Location = model.Location;
            return(brace);
        }
コード例 #13
0
        public void Brace()
        {
            this.Name = "Brace";
            var line  = new Line(Vector3.Origin, new Vector3(3, 3, 3));
            var brace = new Brace(line, this._testProfile, BuiltInMaterials.Steel);

            Assert.Equal(BuiltInMaterials.Steel, brace.Material);
            Assert.Equal(line, brace.Curve);
            this.Model.AddElement(brace);
        }
コード例 #14
0
    public override void _Process(float delta)
    {
        if (hasActiveAnchor())
        {
            activeAnchor.Position = GetGlobalMousePosition();

            if (Input.IsActionJustReleased("spawn_anchor"))
            {
                if (rayCastinTerrain() || rayCastinPlayer() || rayCastinAnchor() || (startAnchor != null && startAnchor.getBracesInRange(activeAnchor.GlobalPosition).Count == 0))
                {
                    activeAnchor.destory();
                    activeAnchor = null;
                    startAnchor  = null;
                    addGoo();
                }
                else // Placing anchor into world
                {
                    if (startAnchor != null && activeAnchor != null)
                    {
                        Brace brace = newBrace(GetGlobalMousePosition());
                        startAnchor.connect(brace);
                        activeAnchor.destory();
                        activeAnchor = null;
                        startAnchor  = null;
                    }
                    else
                    {
                        activeAnchor.setActive(true);
                        activeAnchor.AddCentralForce(new Vector2(0, 0.1f));
                        anchors.Add(activeAnchor);
                        activeAnchor = null;
                    }
                }
            }
        }
        else // does not have active anchor
        {
            if (Input.IsActionJustPressed("spawn_anchor") && !rayCastinTerrain() && removeGoo())
            {
                activeAnchor = newAnchor(GetGlobalMousePosition());
                startAnchor  = getRayCastAnchor();
            }
            else if (Input.IsActionJustPressed("remove_anchor"))
            {
                Anchor anchor = getRayCastAnchor();
                if (anchor != null && hasGooSpace())
                {
                    if (anchor.removeBrace(GetGlobalMousePosition()))
                    {
                        addGoo();
                    }
                }
            }
        }
    }
コード例 #15
0
    public void setShape(Brace a, Brace b)
    {
        this.a = a; this.b = b;
        this.GlobalPosition = new Vector2((a.GlobalPosition.x + b.GlobalPosition.x) / 2, (a.GlobalPosition.y + b.GlobalPosition.y) / 2);
        LookAt(a.GlobalPosition);
        float length = (b.GlobalPosition - a.GlobalPosition).Length();

        this.Scale = new Vector2(length / 2, sprite.Scale.y);
        a.addConnectorToList(this);
        b.addConnectorToList(this);
    }
コード例 #16
0
        public void Brace()
        {
            this.Name = "Brace";
            var framingType = new StructuralFramingType(Guid.NewGuid().ToString(), this._testProfile, BuiltInMaterials.Steel);
            var line        = new Line(Vector3.Origin, new Vector3(3, 3, 3));
            var brace       = new Brace(line, framingType);

            Assert.Equal(BuiltInMaterials.Steel, brace.ElementType.Material);
            Assert.Equal(line, brace.Curve);
            this.Model.AddElement(brace);
        }
コード例 #17
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
 public bool removeClosestBrace(Vector2 pos)
 {
     bool removed = false;
     Brace brace = getClosestBrace(pos);
     if (brace != null)
     {
         brace.remove();
         removed = true;
     }
     return removed;
 }
コード例 #18
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
 public bool removeBrace(Vector2 pos)
 {
     bool removed = false;
     Brace brace = getClosestBrace(pos);
     if (brace != null && brace.GlobalPosition.DistanceTo(pos) < 3)
     {
         brace.remove();
         removed = true;
     }
     return removed;
 }
コード例 #19
0
        //Trying to reduce code duplication, beam and brace are basically the same elements in Revit
        public static Element ToNative(this Brace myBrace)
        {
            var myBeam = new Beam()
            {
                beamFamily = myBrace.braceFamily,
                beamType   = myBrace.braceType,
                baseLine   = myBrace.baseLine,
                parameters = myBrace.parameters,
                level      = myBrace.level
            };

            return(StructuralFramingToNative(myBeam, StructuralType.Brace));
        }
コード例 #20
0
 public BraceInEdit(Brace value)
 {
     Name             = value.Name;
     Open             = value.Open;
     Close            = value.Close;
     AddSpace         = value.AddSpace;
     IgnoreWhitespace = value.IgnoreWhitespace;
     Rules            = new List <Brace.Rule>(value.Rules.Length);
     foreach (var rule in value.Rules)
     {
         Rules.Add(rule.Clone());
     }
 }
コード例 #21
0
    public bool canSee(Brace brace)
    {
        bool value         = true;
        var  spaceState    = GetWorld2d().DirectSpaceState;
        var  terrainResult = spaceState.IntersectRay(this.GlobalPosition, brace.GlobalPosition, null, 1);

        if (terrainResult.Count > 0)
        {
            value = false;
        }

        return(value);
    }
コード例 #22
0
        //Trying to reduce code duplication, beam and brace are basically the same elements in Revit
        public static SpeckleObject BraceToSpeckle(Autodesk.Revit.DB.FamilyInstance myFamily)
        {
            var myBeam = BeamToSpeckle(myFamily) as Beam;

            var myBrace = new Brace()
            {
                braceFamily = myBeam.beamFamily,
                braceType   = myBeam.beamType,
                baseLine    = myBeam.baseLine,
                parameters  = myBeam.parameters,
                level       = myBeam.level
            };


            return(myBrace);
        }
コード例 #23
0
 static void Main(string[] args)
 {
     while (true)
     {
         Console.WriteLine("Please enter a string of braces");
         string input = Console.ReadLine();
         if (input != "quit")
         {
             Console.WriteLine(Brace.validBraces(input));
         }
         else
         {
             break;
         }
     }
 }
コード例 #24
0
        public FamilyInstance CreateBraceInstance(Document doc, XYZ location, XYZ endLocation, Level bottomLvl, Level topLvl, FamilySymbol colType, double rotationAngleRad, bool isStructural)
        {

            FamilyInstance Brace;
            StructuralType structuralType = isStructural ? StructuralType.Column : StructuralType.NonStructural;
            if (!colType.IsActive) colType.Activate();
            Line L1 = Line.CreateBound(location, endLocation);
            Brace = doc.Create.NewFamilyInstance(L1, colType, bottomLvl, structuralType);
            Brace.LookupParameter("Top Level").Set(topLvl.Id);
            Brace.LookupParameter("Top Offset").Set(0);
            Brace.LookupParameter("Base Offset").Set(0);
            // ElementTransformUtils.RotateElement(doc, Brace.Id, Line.CreateBound(location, endLocation), rotationAngleRad);


            return Brace;
        }
コード例 #25
0
        public FamilyInstance CreateBraceInstance(Document doc, Brace Brace, FamilySymbol colType, bool isStructural, List<double> storeys)
        {
            XYZ location = new XYZ(Util.MmToFoot(Brace.Location.X), Util.MmToFoot(Brace.Location.Y), Util.MmToFoot(Brace.Location.Z));
            XYZ endLocation = location + Util.MmToFoot(Brace.Length) * new XYZ(Brace.Axis.X, Brace.Axis.Y, Brace.Axis.Z);

            Level colBottomLevel = GetLevel(doc, MapToStorey(Brace.BottomLevel, storeys));
            double toplevel = Util.FootToMm(endLocation.Z);
            Level colTopLevel = GetLevel(doc, MapToStorey(toplevel, storeys));

            double colRotation = Brace.RefDirection.X >= 0.0 ?
                90 + Vector3D.AngleBetween(new Vector3D(Brace.RefDirection.X, Brace.RefDirection.Y, Brace.RefDirection.Z), new Vector3D(0, -1, 0)) :
                90 + Vector3D.AngleBetween(new Vector3D(Brace.RefDirection.X, Brace.RefDirection.Y, Brace.RefDirection.Z), new Vector3D(0, -1, 0));

            colRotation *= Math.PI / 180.0;

            return CreateBraceInstance(doc, location, endLocation, colBottomLevel, colTopLevel, colType, colRotation, isStructural);
        }
コード例 #26
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
    private Brace getClosestBrace(Vector2 pos)
    {
        if (braces == null || braces.Count == 0)
            return null;

        float minLength = 1000000;
        Brace closest = braces[0];
        foreach(Brace brace in braces)
        {
            float length = brace.GlobalPosition.DistanceTo(pos);
            if (length < minLength)
            {
                minLength = length;
                closest = brace;
            }
        }
        return closest;
    }
コード例 #27
0
        public FamilySymbol GetLShapeBraceFamilySymbol(Document doc, Brace Brace, string familyName, BuiltInCategory category)
        {
            FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(category)
                                                        .WhereElementIsElementType()
                                                        .Cast<FamilySymbol>()
                                                        .Where(f => f.FamilyName == familyName)
                                                        .Where(f =>
                                                        {
                                                            if (f.LookupParameter("d").AsDouble() == Util.MmToFoot(Brace.Depth) &&
                                                                f.LookupParameter("b").AsDouble() == Util.MmToFoot(Brace.Width) &&
                                                                f.LookupParameter("t").AsDouble() == Util.MmToFoot(Brace.Thickness)
                                                                ) return true;

                                                            return false;
                                                        }).FirstOrDefault();

            if (fs != null) return fs;

            Family family = default;
            try
            {
                fs = new FilteredElementCollector(doc).OfCategory(category)
                                                        .WhereElementIsElementType()
                                                        .Cast<FamilySymbol>()
                                                        .First(f => f.FamilyName == familyName);
            }
            catch (Exception)
            {
                string directory = $"C:/ProgramData/Autodesk/RVT {revitVersion}/Libraries/US Imperial/Structural Columns/Steel/";
                family = OpenFamily(doc, directory, familyName);
                fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
            }

            ElementType fs1 = fs.Duplicate(String.Format($"L-Angle Custom {0:0}x{1:0}", Brace.Width / 10, Brace.Depth / 10));
            fs1.LookupParameter("b").Set(Util.MmToFoot(Brace.Width));
            fs1.LookupParameter("d").Set(Util.MmToFoot(Brace.Depth));
            fs1.LookupParameter("t").Set(Util.MmToFoot(Brace.Thickness));
            fs1.LookupParameter("k").Set(Util.MmToFoot(Brace.Thickness));
            fs1.LookupParameter("x").Set(Util.MmToFoot(0.28 * (Brace.Thickness)));
            fs1.LookupParameter("y").Set(Util.MmToFoot(0.28 * (Brace.Thickness)));

            return fs1 as FamilySymbol;
        }
コード例 #28
0
ファイル: Anchor.cs プロジェクト: PetTurtle/LudumDare45
 public void connect(Brace brace)
 {
     brace.anchor = this;
     AddChild(brace);
     brace.GlobalPosition = GetGlobalMousePosition();
     List<Brace> range = getBracesInRange(brace.GlobalPosition);
     if (range.Count > 0)
     {
         foreach(Brace b in range)
         {
             if (b.canSee(brace))
                 b.connect(brace);
         }
         braces.Add(brace);
         CenterGravity();
     }
     else
     {
         brace.remove();
     }
 }
コード例 #29
0
        protected void getTopBraceWithIndex(out Brace topBrace, out uint index, out bool executionFault)
        {
            executionFault = true;
            topBrace       = null;
            index          = 0;

            IpElement?topIpNullable = getTopIp();

            if (!topIpNullable.HasValue)
            {
                return;
            }
            IpElement topIp = topIpNullable.Value;

            if (topIp.element.type != Element.EnumType.BRACE)
            {
                return;
            }

            executionFault = false;
            topBrace       = (Brace)topIp.element;
            index          = topIp.index;
        }
コード例 #30
0
        public List <ApplicationPlaceholderObject> BraceToNative(Brace speckleBrace)
        {
            //reuse ConversionLog.Addic in Beam class, at these are basically the same thing
            if (speckleBrace is RevitBrace rb)
            {
                var speckleBeam = new RevitBeam
                {
                    baseLine   = rb.baseLine,
                    type       = rb.type,
                    level      = rb.level,
                    family     = rb.family,
                    parameters = rb.parameters,
                };

                return(BeamToNative(speckleBeam, StructuralType.Brace));
            }
            else
            {
                var speckleBeam = new Beam();
                speckleBeam.baseLine = speckleBrace.baseLine;
                return(BeamToNative(speckleBeam, StructuralType.Brace));
            }
        }