Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the given vertex has the given neighbour.
        /// </summary>
        /// <param name="vertex1"></param>
        /// <param name="vertex2"></param>
        /// <returns></returns>
        public EdgeEnumerator <CHEdgeData> GetEdges(uint vertex1, uint vertex2)
        {
            var enumerator = new EdgeEnumerator(this);

            enumerator.MoveTo(vertex1, vertex2);
            return(enumerator);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns all edges starting at the given vertex.
        /// </summary>
        /// <param name="vertex"></param>
        /// <returns></returns>
        public EdgeEnumerator GetEdgeEnumerator(uint vertex)
        {
            var enumerator = new EdgeEnumerator(this);

            enumerator.MoveTo(vertex);
            return(enumerator);
        }
Ejemplo n.º 3
0
 public static dynamic GetTSObject(EdgeEnumerator dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns all edges starting at the given vertex.
        /// </summary>
        /// <returns></returns>
        public EdgeEnumerator GetEdgeEnumerator(uint vertex)
        {
            if (vertex >= _vertices.Length)
            {
                throw new ArgumentOutOfRangeException("vertex", "vertex is not part of this graph.");
            }

            var enumerator = new EdgeEnumerator(this);

            enumerator.MoveTo(vertex);
            return(enumerator);
        }
Ejemplo n.º 5
0
    public List <LineSegment> new_get_lower_edge(Part Gpart)
    {
        List <LineSegment> lineSegmentList = new List <LineSegment>();
        Point point1 = new Point();
        Point point2 = new Point();
        Point point3 = new Point();
        Point point4 = new Point();
        Point point5 = new Point();

        Tekla.Structures.Model.Solid solid      = Gpart.GetSolid(Tekla.Structures.Model.Solid.SolidCreationTypeEnum.PLANECUTTED);
        EdgeEnumerator      edgeEnumerator      = solid.GetEdgeEnumerator();
        Point               maximumPoint        = solid.MaximumPoint;
        Point               minimumPoint        = solid.MinimumPoint;
        TransformationPlane transformationPlane = this.myModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();
        Point               point6 = transformationPlane.TransformationMatrixToGlobal.Transform(maximumPoint);
        Point               point7 = transformationPlane.TransformationMatrixToGlobal.Transform(minimumPoint);

        if (point6.Z > point7.Z)
        {
            point3 = minimumPoint;
        }
        else if (point6.Z < point7.Z)
        {
            point3 = maximumPoint;
        }
        if (solid != null)
        {
            while (edgeEnumerator.MoveNext())
            {
                Edge current = edgeEnumerator.Current as Edge;
                if (current.StartPoint.Z - current.EndPoint.Z == 0.0 && current.StartPoint.Z == point3.Z)
                {
                    LineSegment lineSegment = new LineSegment(current.StartPoint, current.EndPoint);
                    lineSegmentList.Add(lineSegment);
                }
            }
        }
        return(lineSegmentList);
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Copy mesh data.
        /// </summary>
        public void SetMesh(Mesh mesh)
        {
            // Clear unused buffers
            this.Segments = null;
            this.VoronoiPoints = null;
            this.VoronoiEdges = null;

            int n = mesh.Vertices.Count;
            int i = 0;

            this.NumberOfInputPoints = mesh.NumberOfInputPoints;

            // Linear numbering of mesh
            mesh.Renumber();

            // Copy points
            this.Points = new float[2 * n];
            foreach (var pt in mesh.Vertices)
            {
                this.Points[2 * i] = (float)pt.X;
                this.Points[2 * i + 1] = (float)pt.Y;
                i++;
            }

            // Copy segments
            n = mesh.Segments.Count;
            if (n > 0 && mesh.IsPolygon)
            {
                var segments = new List<uint>(2 * n);
                foreach (var seg in mesh.Segments)
                {
                    segments.Add((uint)seg.P0);
                    segments.Add((uint)seg.P1);
                }
                this.Segments = segments.ToArray();
            }

            // Copy edges
            var edges = new List<uint>(2 * mesh.NumberOfEdges);

            EdgeEnumerator e = new EdgeEnumerator(mesh);
            while (e.MoveNext())
            {
                edges.Add((uint)e.Current.P0);
                edges.Add((uint)e.Current.P1);
            }
            this.MeshEdges = edges.ToArray();

            if (this.NumberOfRegions > 0)
            {
                this.TrianglePartition = new int[mesh.Triangles.Count];
            }

            i = 0;

            // Copy Triangles
            var triangles = new List<uint>(3 * mesh.Triangles.Count);
            foreach (var tri in mesh.Triangles)
            {
                triangles.Add((uint)tri.P0);
                triangles.Add((uint)tri.P1);
                triangles.Add((uint)tri.P2);

                if (this.NumberOfRegions > 0)
                {
                    this.TrianglePartition[i++] = tri.Region;
                }
            }
            this.Triangles = triangles.ToArray();

            this.Bounds = new BoundingBox(
                (float)mesh.Bounds.Xmin,
                (float)mesh.Bounds.Xmax,
                (float)mesh.Bounds.Ymin,
                (float)mesh.Bounds.Ymax);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Copy mesh data.
        /// </summary>
        public void SetMesh(Mesh mesh)
        {
            // Clear unused buffers
            this.Segments      = null;
            this.VoronoiPoints = null;
            this.VoronoiEdges  = null;

            int n = mesh.Vertices.Count;
            int i = 0;

            this.NumberOfInputPoints = mesh.NumberOfInputPoints;

            // Linear numbering of mesh
            mesh.Renumber();

            // Copy points
            this.Points = new float[2 * n];
            foreach (var pt in mesh.Vertices)
            {
                this.Points[2 * i]     = (float)pt.X;
                this.Points[2 * i + 1] = (float)pt.Y;
                i++;
            }

            // Copy segments
            n = mesh.Segments.Count;
            if (n > 0 && mesh.IsPolygon)
            {
                var segments = new List <uint>(2 * n);
                foreach (var seg in mesh.Segments)
                {
                    segments.Add((uint)seg.P0);
                    segments.Add((uint)seg.P1);
                }
                this.Segments = segments.ToArray();
            }

            // Copy edges
            var edges = new List <uint>(2 * mesh.NumberOfEdges);

            EdgeEnumerator e = new EdgeEnumerator(mesh);

            while (e.MoveNext())
            {
                edges.Add((uint)e.Current.P0);
                edges.Add((uint)e.Current.P1);
            }
            this.MeshEdges = edges.ToArray();


            if (this.NumberOfRegions > 0)
            {
                this.TrianglePartition = new int[mesh.Triangles.Count];
            }

            i = 0;

            // Copy Triangles
            var triangles = new List <uint>(3 * mesh.Triangles.Count);

            foreach (var tri in mesh.Triangles)
            {
                triangles.Add((uint)tri.P0);
                triangles.Add((uint)tri.P1);
                triangles.Add((uint)tri.P2);

                if (this.NumberOfRegions > 0)
                {
                    this.TrianglePartition[i++] = tri.Region;
                }
            }
            this.Triangles = triangles.ToArray();

            this.Bounds = new BoundingBox(
                (float)mesh.Bounds.Xmin,
                (float)mesh.Bounds.Xmax,
                (float)mesh.Bounds.Ymin,
                (float)mesh.Bounds.Ymax);
        }
 internal RouterDbEdgeEnumerator(RouterDb routerDb, EdgeEnumerator edgeEnumerator)
 {
     _routerDb       = routerDb ?? throw new ArgumentNullException(nameof(routerDb));
     _edgeEnumerator = edgeEnumerator ?? throw new ArgumentNullException(nameof(edgeEnumerator));;
 }
Ejemplo n.º 9
0
    public List <LineSegment> Get_Lower_face_edge(Part GPart)
    {
        this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        Tekla.Structures.Model.Solid solid = GPart.GetSolid();
        EdgeEnumerator     edgeEnumerator  = solid.GetEdgeEnumerator();
        List <LineSegment> lineSegmentList = new List <LineSegment>();

        if (solid != null)
        {
            while (edgeEnumerator.MoveNext())
            {
                Edge        current     = edgeEnumerator.Current as Edge;
                LineSegment lineSegment = new LineSegment(current.StartPoint, current.EndPoint);
                if (Math.Abs(lineSegment.Point1.Z - lineSegment.Point2.Z) < 1.0)
                {
                    lineSegmentList.Add(lineSegment);
                }
            }
            for (int index1 = 0; index1 < lineSegmentList.Count; ++index1)
            {
                LineSegment lineSegment1 = lineSegmentList[index1];
                for (int index2 = 0; index2 < lineSegmentList.Count; ++index2)
                {
                    LineSegment lineSegment2 = lineSegmentList[index2];
                    if (Math.Abs(lineSegment1.Point1.X - lineSegment2.Point1.X) < 1.0 && Math.Abs(lineSegment1.Point1.Y - lineSegment2.Point1.Y) < 1.0 && lineSegment1.Point1.Z != lineSegment2.Point1.Z)
                    {
                        if (lineSegment2.Point1.Z > lineSegment1.Point1.Z)
                        {
                            lineSegmentList.Remove(lineSegment2);
                        }
                        else
                        {
                            lineSegmentList.Remove(lineSegment1);
                        }
                    }
                }
            }
            for (int index1 = 0; index1 < lineSegmentList.Count; ++index1)
            {
                LineSegment lineSegment1 = lineSegmentList[index1];
                for (int index2 = 0; index2 < lineSegmentList.Count; ++index2)
                {
                    LineSegment lineSegment2 = lineSegmentList[index2];
                    Point       point1       = lineSegment2.Point1;
                    LineSegment lineSegment3 = new LineSegment(lineSegment2.Point2, point1);
                    if (Math.Abs(lineSegment1.Point1.X - lineSegment3.Point1.X) < 1.0 && Math.Abs(lineSegment1.Point1.Y - lineSegment3.Point1.Y) < 1.0 && lineSegment1.Point1.Z != lineSegment3.Point1.Z)
                    {
                        if (lineSegment3.Point1.Z > lineSegment1.Point1.Z)
                        {
                            lineSegmentList.Remove(lineSegment2);
                        }
                        else
                        {
                            lineSegmentList.Remove(lineSegment1);
                        }
                    }
                }
            }
        }
        return(lineSegmentList);
    }
Ejemplo n.º 10
0
 public bool Equals(EdgeEnumerator other) => index_ == other.index_ && shape_id_ == other.shape_id_ && edge_id_ == other.edge_id_;
Ejemplo n.º 11
0
        private void button2_Click(object sender, EventArgs e)
        {
            // *기본 가정
            //  1) 슬라브를 배치할 두 빔은 평행
            //  2) 슬라브는 비스듬하게 배치되지 않음.(두빔에 항상 수직방향으로 배치됨)
            //  3) 슬라브는 z평면과 수평하게 배치됨
            TSM.Model currentModel = new TSM.Model();

            try
            {
                // 1. 슬라브 객체 생성
                ContourPlate contourPlate = new ContourPlate();

                // 2. 슬라브 생성할 두 부재 선택
                Picker          picker    = new Picker();
                TSM.ModelObject mainpart  = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "슬라브를 삽입할 첫번째 부재를 선택하세요.");
                TSM.Beam        startBeam = mainpart as TSM.Beam;
                mainpart = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "슬라브를 삽입할 두번째 부재를 선택하세요.");
                TSM.Beam endBeam = mainpart as TSM.Beam;

                // 3. 기본 방향벡터 생성
                //  1) StartBeam의 길이방향 단위벡터
                TSG.Vector startBeamLDirectionVector = new TSG.Vector(startBeam.EndPoint - startBeam.StartPoint).GetNormal();

                //  2) StartBeam의 높이방향 단위벡터-
                TSG.Vector startBeamHDirecitionVector = new TSG.Vector(0, 0, 1); //추후 기울어진 빔에도 적용가능하도록 변경

                //  EdgeEnumerator를 통해 StartBeam의 높이방향 단위벡터 구하기
                Solid solid = startBeam.GetSolid();
                if (solid != null)
                {
                    EdgeEnumerator edgeEnumerator = solid.GetEdgeEnumerator();
                    int            edgeCount      = 0;
                    while (edgeEnumerator.MoveNext())
                    {
                        var edge = edgeEnumerator.Current as Edge;
                        if (edge != null)
                        {
                            Console.WriteLine("Start : " + edge.StartPoint.ToString());
                            Console.WriteLine("End : " + edge.EndPoint.ToString());
                            Console.WriteLine("Type :" + edge.Type.ToString());

                            if (edgeCount == 8)
                            {
                                startBeamHDirecitionVector = new TSG.Vector((edge.EndPoint.X - edge.StartPoint.X) / 2, (edge.EndPoint.Y - edge.StartPoint.Y) / 2, (edge.EndPoint.Z - edge.StartPoint.Z) / 2).GetNormal();
                            }
                            edgeCount++;
                        }
                    }
                }

                //  3) StartBeam -> EndBeam 방향 단위벡터 (중점에서 중점 잇는 벡터)
                TSG.Point sbSP = startBeam.StartPoint;
                TSG.Point sbEP = startBeam.EndPoint;
                TSG.Point ebSP = endBeam.StartPoint;
                TSG.Point ebEP = endBeam.EndPoint;
                TSG.Point starBeamCenterPoint = new TSG.Point((sbSP.X + sbEP.X) / 2, (sbSP.Y + sbEP.Y) / 2, (sbSP.Z + sbEP.Z) / 2);
                TSG.Point endBeamCenterPoint  = new TSG.Point((ebSP.X + ebEP.X) / 2, (ebSP.Y + ebEP.Y) / 2, (ebSP.Z + ebEP.Z) / 2);

                TSG.Vector startBeamToEndBeamVector          = new TSG.Vector((ebSP.X + ebEP.X) / 2 - (sbSP.X + sbEP.X) / 2, (ebSP.Y + ebEP.Y) / 2 - (sbSP.Y + sbEP.Y) / 2, (ebSP.Z + ebEP.Z) / 2 - (sbSP.Z + sbEP.Z) / 2);
                TSG.Vector startBeamToEndBeamDirectionVector = new TSG.Vector((ebSP.X + ebEP.X) / 2 - (sbSP.X + sbEP.X) / 2, (ebSP.Y + ebEP.Y) / 2 - (sbSP.Y + sbEP.Y) / 2, (ebSP.Z + ebEP.Z) / 2 - (sbSP.Z + sbEP.Z) / 2).GetNormal();

                // 3. 슬라브 치수 및 기타속성 입력 ( 현재는 상수 )
                double slabWidthLeft   = 300;
                double slabWidthCenter = 300;
                double slabWidthRight  = 300;
                double slabThickness   = 100;
                double ribThickness    = 200;
                double ribDistUpper    = 50;
                double ribDistLower    = 30;
                double ribInterval     = ribDistUpper - ribDistLower;

                double startOffset = 100;
                contourPlate.Profile.ProfileString   = (startBeamToEndBeamVector.GetLength() - startOffset * 2).ToString();
                contourPlate.Material.MaterialString = "C24";

                // 4. 슬라브 시작점 설정
                //  1) 길이방향(일단은 startPoint점에서 시작하는걸로)
                String    direction      = "정방향"; //사용자가 직접 선택. 정방향 or 역방향
                TSG.Point slabStartPoint = new TSG.Point();

                if (direction == "정방향")
                {
                    slabStartPoint = startBeam.StartPoint;
                }
                else if (direction == "역방향")
                {
                    slabStartPoint            = startBeam.EndPoint;
                    startBeamLDirectionVector = startBeamLDirectionVector * -1;
                }

                //  2) 높이방향
                double heightConstant = 0.0;
                //depth type에 따른 슬라브 생성높이 변경
                if (startBeam.Position.Depth == Position.DepthEnum.FRONT)
                {
                    heightConstant = 1.0;
                }
                else if (startBeam.Position.Depth == Position.DepthEnum.MIDDLE)
                {
                    heightConstant = 0.5;
                }
                slabStartPoint += startBeamHDirecitionVector * ((Methods.GetGirderHeight(startBeam) * heightConstant + slabThickness + ribThickness));

                //  3) endBeam방향
                slabStartPoint += startBeamToEndBeamDirectionVector * (startOffset);

                // 5. 슬라브 포인트 입력
                List <TSG.Point> pointList = new List <TSG.Point>();

                pointList.Add(slabStartPoint);
                pointList.Add(pointList[0] + (startBeamHDirecitionVector * slabThickness * -1));
                pointList.Add(pointList[1] + (startBeamLDirectionVector * slabWidthLeft));
                pointList.Add(pointList[2] + (startBeamLDirectionVector * ribInterval) + (startBeamHDirecitionVector * ribThickness * -1));
                pointList.Add(pointList[3] + (startBeamLDirectionVector * ribDistLower));
                pointList.Add(pointList[4] + (startBeamLDirectionVector * ribInterval) + (startBeamHDirecitionVector * ribThickness));
                pointList.Add(pointList[5] + (startBeamLDirectionVector * slabWidthCenter));
                pointList.Add(pointList[6] + (startBeamLDirectionVector * ribInterval) + (startBeamHDirecitionVector * ribThickness * -1));
                pointList.Add(pointList[7] + (startBeamLDirectionVector * ribDistLower));
                pointList.Add(pointList[8] + (startBeamLDirectionVector * ribInterval) + (startBeamHDirecitionVector * ribThickness));
                pointList.Add(pointList[9] + (startBeamLDirectionVector * slabWidthRight));
                pointList.Add(pointList[10] + (startBeamHDirecitionVector * slabThickness));

                for (int i = 0; i <= 11; i++)
                {
                    contourPlate.AddContourPoint(new ContourPoint(pointList[i], null));
                }

                // 4. 슬라브 깊이타입 결정
                //  1) StartBeam 중앙에서 L,H Direction의 법선 벡터방향 으로 Line을 뻗어 EndBeam과 겹치는 부분이 있는지 확인
                //  2) 겹치면 깊이타입 Front , 겹치지 않으면 Back

                //  StartBeam 중앙에서 L,H Direction의 법선 벡터(외적 결과값)
                TSG.Vector crossResult = TSG.Vector.Cross(startBeamHDirecitionVector, startBeamLDirectionVector);

                //  외적벡터의 연장선
                TSG.Point       extendedPoint     = new TSG.Point(starBeamCenterPoint.X, starBeamCenterPoint.Y, starBeamCenterPoint.Z) + new TSG.Point(crossResult.X * 10000, crossResult.Y * 10000, crossResult.Z * 10000);
                TSG.LineSegment centerLineSegment = new TSG.LineSegment(starBeamCenterPoint, extendedPoint);

                //endBeam의 Plane 작성
                TSG.Vector         planeNormalVector = crossResult; //조건 중 startBeam과 endBeam이 평행하므로 평면을 구성하는 법선벡터 또한 같다.
                TSG.GeometricPlane endBeamPlane      = new TSG.GeometricPlane(endBeamCenterPoint, planeNormalVector);

                //두 line이 겹치는지 확인하는 Point (겹치면 값이 있고 안겹치면 값이 없음)
                TSG.Point isIntersect = TSG.Intersection.LineSegmentToPlane(centerLineSegment, endBeamPlane);
                if (isIntersect != null) // endBeam이 오른쪽에 있을 때
                {
                    if (direction == "정방향")
                    {
                        contourPlate.Position.Depth = Position.DepthEnum.BEHIND;
                    }
                    else if (direction == "역방향")
                    {
                        contourPlate.Position.Depth = Position.DepthEnum.FRONT;
                    }
                }
                else if (isIntersect == null) // endBeam이 오른쪽에 없을 때
                {
                    if (direction == "정방향")
                    {
                        contourPlate.Position.Depth = Position.DepthEnum.FRONT;
                    }
                    else if (direction == "역방향")
                    {
                        contourPlate.Position.Depth = Position.DepthEnum.BEHIND;
                    }
                }
                bool result = false;
                result = contourPlate.Insert();
                currentModel.CommitChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void btn_createMainRebar_Click(object sender, EventArgs e)
        {
            //기본객체 생성
            RebarGroup rebarGroup = new RebarGroup();
            Picker     picker     = new Picker();

            //부재선택
            TSM.ModelObject mainpart = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "철근을 삽입할 부재를 선택하세요.");
            TSM.Beam        Beam     = mainpart as TSM.Beam;
            rebarGroup.Father = Beam;

            //Beam 프로퍼티 확인용
            Solid solid = Beam.GetSolid();

            if (solid != null)
            {
                EdgeEnumerator edgeEnumerator = solid.GetEdgeEnumerator();
                int            edgeCount      = 0;
                while (edgeEnumerator.MoveNext())
                {
                    var edge = edgeEnumerator.Current as Edge;
                    if (edge != null)
                    {
                        Console.WriteLine("Start : " + edge.StartPoint.ToString());
                        Console.WriteLine("End : " + edge.EndPoint.ToString());
                        Console.WriteLine("Type : " + edge.Type.ToString());
                        edgeCount++;
                    }
                }

                Console.WriteLine("Edge count : " + edgeCount.ToString());
            }



            //철근 형태를 결정할 Point 선택
            ArrayList shapePoints = picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON, "철근 형태를 결정할 포인트를 선택하세요.");

            TSM.Polygon polygon = new TSM.Polygon();
            for (int i = 0; i < shapePoints.Count; i++)
            {
                polygon.Points.Add(shapePoints[i]);
            }
            rebarGroup.Polygons.Add(polygon);

            //철근 생성 위치를 결정할 Point 선택
            ArrayList locationPoints = picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON, "철근 생성 위치를 결정할 포인트를 선택하세요.");

            rebarGroup.StartPoint = (TSG.Point)locationPoints[0];
            rebarGroup.EndPoint   = (TSG.Point)locationPoints[1];

            //RebarInfo 클래스에서 불러올 값
            rebarGroup.Name  = "Rebar";
            rebarGroup.Size  = "13";
            rebarGroup.Grade = "SD400";
            rebarGroup.RadiusValues.Add(60.00);
            rebarGroup.Class = 11;

            //Form에서 설정
            rebarGroup.StartHook.Shape = RebarHookData.RebarHookShapeEnum.NO_HOOK;
            rebarGroup.EndHook.Shape   = RebarHookData.RebarHookShapeEnum.NO_HOOK;

            rebarGroup.OnPlaneOffsets.Add(25.00);
            rebarGroup.FromPlaneOffset       = 25;
            rebarGroup.StartPointOffsetValue = 25;
            rebarGroup.EndPointOffsetValue   = 25;

            rebarGroup.SpacingType = BaseRebarGroup.RebarGroupSpacingTypeEnum.SPACING_TYPE_TARGET_SPACE;
            rebarGroup.Spacings.Add(200);
            rebarGroup.ExcludeType = BaseRebarGroup.ExcludeTypeEnum.EXCLUDE_TYPE_NONE;
            rebarGroup.StirrupType = RebarGroup.RebarGroupStirrupTypeEnum.STIRRUP_TYPE_POLYGONAL;

            if (!rebarGroup.Insert())
            {
                Console.WriteLine("insert failed");
            }
            else
            {
                model.CommitChanges();
            }
        }