示例#1
0
        //InterSectionTest 2
        private void button1_Click_1(object sender, EventArgs e)
        {
            //부재 선택
            Picker picker = new Picker();

            TSM.ModelObject  part         = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ModelObject;
            TSM.ContourPlate contourPlate = part as TSM.ContourPlate;
            Solid            solid        = contourPlate.GetSolid();

            //철근 정보 받기
            //철근 선택 및 그룹철근 분할
            ModelObjectEnumerator  reinforcement = contourPlate.GetReinforcements();
            List <TSM.SingleRebar> singleRebars  = new List <TSM.SingleRebar>();
            List <TSM.SingleRebar> group         = new List <TSM.SingleRebar>(); //수정안된 철근

            while (reinforcement.MoveNext())
            {
                if (reinforcement.Current.GetType().Name == "SingleRebar")
                {
                    TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar;
                    singleRebars.Add(singleRebar);
                }
                else
                {
                    TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup;

                    TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup);
                    while (rebarEnumerator.MoveNext())
                    {
                        TSM.ModelObject rebar       = rebarEnumerator.Current;
                        TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar;
                        singleRebars.Add(singleRebar);
                    }
                }
            }

            //Intersect (마구리와 철근 겹치는 부분을 철근의 새 포인트로 지정한다.)
            TSG.LineSegment rebarLineSegment     = null;
            ArrayList       intersectLinesegment = new ArrayList();

            for (int j = 0; j < singleRebars.Count; j++) //철근 선택 반복문
            {
                TSG.Point       point1         = singleRebars[j].Polygon.Points[0] as TSG.Point;
                TSG.Point       point2         = singleRebars[j].Polygon.Points[1] as TSG.Point;
                TSM.SingleRebar newSingleRebar = singleRebars[j];

                if (singleRebars[j].Polygon.Points.Count == 2) //직선철근일때
                {
                    rebarLineSegment = new TSG.LineSegment(point1, point2);
                }

                intersectLinesegment             = solid.Intersect(rebarLineSegment);
                newSingleRebar.Polygon.Points[0] = intersectLinesegment[0] as TSG.Point;
                newSingleRebar.Polygon.Points[1] = intersectLinesegment[1] as TSG.Point;

                singleRebars[j].Delete();

                newSingleRebar.Insert();

                if (newSingleRebar.Polygon.Points[0] as TSG.Point == point1 && newSingleRebar.Polygon.Points[1] as TSG.Point == point2)
                {
                    group.Add(newSingleRebar);
                }
            }
            TSM.RebarGroup nonmodifiedGroup = TSM.Operations.Operation.Group(group);
        }
示例#2
0
        //InterSectionTest 3
        private void button4_Click(object sender, EventArgs e)
        {
            //부재 선택
            Picker picker = new Picker();

            TSM.Part part             = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "철근형태를 수정할 부재를 선택하세요.") as TSM.Part;
            TSM.Part intersectingpart = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "간섭하는 부재를 선택하세요.") as TSM.Part;

            //Intersection 처리
            double partFrontLength    = 0.0;
            double intersectionLength = 0.0; //할당해야함

            TSG.OBB    iPartOBB    = CreateOrientedBoundingBox(intersectingpart);
            TSG.Vector partLVector = new TSG.Vector();

            if (part.GetType().Name == "Beam")
            {
                TSM.Beam        beam        = part as TSM.Beam;
                TSG.LineSegment lineSegment = new TSG.LineSegment(beam.StartPoint, beam.EndPoint);
                TSG.Point       firstPoint  = TSG.Intersection.LineSegmentToObb(lineSegment, iPartOBB).Point1;
                TSG.Point       secondPoint = TSG.Intersection.LineSegmentToObb(lineSegment, iPartOBB).Point2;

                partFrontLength    = TSG.Distance.PointToPoint(beam.StartPoint, firstPoint);
                intersectionLength = TSG.Distance.PointToPoint(firstPoint, secondPoint);
                partLVector        = new TSG.Vector(beam.EndPoint - beam.StartPoint).GetNormal();
            }
            else if (part.GetType().Name == "ContourPlate") //ContourPlate인 경우 추후 작성
            {
                TSM.ContourPlate contourPlate = part as TSM.ContourPlate;
            }

            //철근 그룹화 해제 후 singleRebar 저장
            ModelObjectEnumerator  reinforcement = part.GetReinforcements();
            List <TSM.SingleRebar> singleRebars  = new List <TSM.SingleRebar>();
            List <TSM.SingleRebar> group         = new List <TSM.SingleRebar>(); //그룹화를 위한 List

            int       rebarCount    = 0;                                         //총 단일철근 수량
            ArrayList rebarInterval = new ArrayList();                           //철근 간격 (싱글 타입일 때는 철근 간격을 어떻게 구하지? > 일단 PASS)

            while (reinforcement.MoveNext())
            {
                if (reinforcement.Current.GetType().Name == "SingleRebar") //부재에 속한 철근이 SingleRebar타입일 때
                {
                    TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar;
                    singleRebars.Add(singleRebar);

                    MessageBox.Show("SingleRebar 타입은 현재 지원 불가");
                }
                else //부재에 속한 철근이 RebarGroup타입일 때
                {
                    TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup;
                    rebarInterval = rebarGroup.Spacings; //철근 간격 저장

                    TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup);
                    while (rebarEnumerator.MoveNext())
                    {
                        TSM.ModelObject rebar       = rebarEnumerator.Current;
                        TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar;
                        singleRebars.Add(singleRebar);
                    }
                }
                rebarCount = singleRebars.Count; // 총 단일수량 저장
            }

            //철근 재배치
            for (int i = 0; i < singleRebars.Count - (intersectionLength / (double)rebarInterval[0]); i++) // 딱 안떨어지는 경우 고려해줘야함
            {
                double frontLength = (i * (double)rebarInterval[0]);

                if (frontLength >= partFrontLength)
                {
                    if (i == singleRebars.Count)
                    {
                        break;
                    }
                    else
                    {
                        for (int j = 0; j < singleRebars[i].Polygon.Points.Count; j++)
                        {
                            TSM.SingleRebar newSingleRebar = singleRebars[i];

                            TSG.Point intersectionLengthPoint = new TSG.Point(intersectionLength * partLVector.X, intersectionLength * partLVector.Y, intersectionLength * partLVector.Z);
                            newSingleRebar.Polygon.Points[j] = newSingleRebar.Polygon.Points[j] as TSG.Point + intersectionLengthPoint;
                            singleRebars[i].Delete();
                            newSingleRebar.Insert();

                            group.Add(newSingleRebar);
                        }
                    }
                }
                else
                {
                    group.Add(singleRebars[i]);
                }
            }

            for (int i = singleRebars.Count - (int)(intersectionLength / (double)rebarInterval[0]); i < singleRebars.Count; i++)
            {
                singleRebars[i].Delete();
            }

            TSM.RebarGroup newRebarGroup = TSM.Operations.Operation.Group(group);
        }
示例#3
0
        //InterSectionTest 1
        private void button3_Click(object sender, EventArgs e)
        {
            //기본 객체 생성
            TSM.Part                girder       = null;
            TSM.Component           component    = new TSM.Component();
            TSM.Part                endPiece     = null;
            List <TSM.ContourPlate> endPieceList = new List <TSM.ContourPlate>();

            //1. 부재를 Input 으로 받는다.
            Picker picker = new Picker();

            TSM.ModelObject part = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ModelObject;


            if (part.GetType().Name == "Beam") //선택한 거더가 단일객체일 경우
            {
                girder   = part as TSM.Beam;
                endPiece = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ContourPlate; //연장할 마구리를 직접 선택

                //마구리 객체 OBB 생성 (추후 수정 - Girder 단일부재일 때도 마구리 1개이상 가능하므로)
                TSG.OBB         obb = CreateOrientedBoundingBox(endPiece); //마구리 OBB 객체 생성
                TSG.LineSegment rebarLineSegment = null;

                //철근 선택 및 그룹철근 분할
                ModelObjectEnumerator  reinforcement = girder.GetReinforcements();
                List <TSM.SingleRebar> singleRebars  = new List <TSM.SingleRebar>();
                List <TSM.SingleRebar> group1        = new List <TSM.SingleRebar>(); //수정된 철근
                List <TSM.SingleRebar> group2        = new List <TSM.SingleRebar>(); //수정안된 철근

                while (reinforcement.MoveNext())
                {
                    if (reinforcement.Current.GetType().Name == "SingleRebar") //부재 내 철근이 SingleRebar타입일때
                    {
                        TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar;
                        singleRebars.Add(singleRebar);
                    }
                    else //부재 내 철근이 rebarGroup타입일때
                    {
                        TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup;

                        TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup);
                        while (rebarEnumerator.MoveNext())
                        {
                            TSM.ModelObject rebar       = rebarEnumerator.Current;
                            TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar;
                            singleRebars.Add(singleRebar);
                        }
                    }
                }

                for (int j = 0; j < singleRebars.Count; j++) //철근 선택 반복문
                {
                    TSG.Point       rebarStartPoint = singleRebars[j].Polygon.Points[0] as TSG.Point;
                    TSG.Point       rebarEndPoint   = singleRebars[j].Polygon.Points[1] as TSG.Point;
                    TSM.SingleRebar newSingleRebar  = singleRebars[j]; //기존 철근을 삭제하고 형태가 변형된 새 철근 삽입

                    if (singleRebars[j].Polygon.Points.Count == 2)     //직선철근일때
                    {
                        rebarLineSegment = new TSG.LineSegment(rebarStartPoint, rebarEndPoint);
                    }

                    TSG.LineSegment intersectLine = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb); //만나는 점이 하나일 때 output 형태 > 두 점이 같은지점으로 찍힘

                    if (intersectLine != null)                                                                // 철근과 마구리가 만날때 / 한 점만 만날때는 Linesegment의 point1 과 point2 가 같은 값임
                    {
                        //철근 선을 연장
                        rebarLineSegment = new TSG.LineSegment(rebarStartPoint, rebarEndPoint + new TSG.Point(0, 100000, 0)); //추후 수정( y방향이 아니라 철근의 진행방향으로)
                        intersectLine    = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb);

                        //마구리 가까운쪽이 철근 Point1 인경우
                        if (intersectLine.Point1.Equals(intersectLine.Point2))
                        {
                            rebarLineSegment = new TSG.LineSegment(rebarStartPoint + new TSG.Point(0, 100000, 0), rebarEndPoint);
                            intersectLine    = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb);

                            newSingleRebar.Polygon.Points[0] = intersectLine.Point2;
                        }
                        else //마구리 가까운쪽이 철근 Point2 인경우
                        {
                            newSingleRebar.Polygon.Points[1] = intersectLine.Point2;
                        }
                        singleRebars[j].Delete();
                        newSingleRebar.Insert();
                        group1.Add(newSingleRebar);
                    }
                    else
                    {
                        group2.Add(singleRebars[j]); //수정안된 철근들 그룹에 넣기
                    }

                    TSM.RebarGroup modifiedGroup    = TSM.Operations.Operation.Group(group1);
                    TSM.RebarGroup nonmodifiedGroup = TSM.Operations.Operation.Group(group2);
                }
            }
            else if (part.ToString() == "Tekla.Structures.Model.Component") //선택한 거더가 컴포넌트일 경우
            {
                component = part as TSM.Component;

                //반환된 Girder의 타입 결정
                TSM.Assembly assembly = component.GetAssembly();
                if (assembly.GetMainPart().GetType().Name == "Beam")
                {
                    girder = assembly.GetMainPart() as TSM.Beam;
                }
                else if (assembly.GetMainPart().GetType().Name == "ContourPlate")
                {
                    girder = assembly.GetMainPart() as TSM.ContourPlate;
                }

                // Input으로 받은 부재에 연결되어있는 마구리와 철근정보를 받아온다.
                //반환된 Secondaries의 타입 결정

                endPieceList = new List <TSM.ContourPlate>();

                for (int i = 0; i < assembly.GetSecondaries().Count; i++)
                {
                    TSM.Part secondary = assembly.GetSecondaries()[i] as TSM.Part;

                    if (secondary.Name == "EndPiece")
                    {
                        endPieceList.Add(secondary as TSM.ContourPlate);
                    }
                }
            }
        }