Пример #1
0
        public List <AcadDB.Region> GetSubRegions()
        {
            List <AcadDB.Region> regions = new List <AcadDB.Region>();

            AcadGeo.Vector3d tmp_vec = up_vector.CrossProduct(normal_vector);

            AcadDB.DBObjectCollection objs = new AcadDB.DBObjectCollection();

            AcadGeo.Vector3d hf = up_vector * height * 0.5;
            AcadGeo.Vector3d wf = tmp_vec * (width * 0.5 - thickness);
            AcadGeo.Vector3d tf = up_vector * thickness;
            objs.Add(new AcadDB.Line(base_point + hf + wf, base_point + hf - wf));
            objs.Add(new AcadDB.Line(base_point + hf - wf, base_point - hf - wf + tf));
            objs.Add(new AcadDB.Line(base_point - hf - wf + tf, base_point - hf + wf + tf));
            objs.Add(new AcadDB.Line(base_point - hf + wf + tf, base_point + hf + wf));

            {
                AcadDB.DBObjectCollection regs = AcadDB.Region.CreateFromCurves(objs);

                foreach (var reg in regs)
                {
                    if (reg is AcadDB.Region)
                    {
                        regions.Add(reg as AcadDB.Region);
                    }
                }
            }

            return(regions);
        }
Пример #2
0
        public void Rotate(AcadGeo.Vector3d vec)
        {
            AcadGeo.Vector3d axe = vec.CrossProduct(normal_vector);
            axe = axe.GetNormal();
            if (axe.IsEqualTo(new AcadGeo.Vector3d(0.0, 0.0, 0.0)))
            {
                return;
            }

            double angle = normal_vector.GetAngleTo(vec, axe);

            if (angle > AcadFuncs.kPI)
            {
                angle -= AcadFuncs.kPI;
            }
            if (angle > AcadFuncs.kPI * 0.5)
            {
                angle -= AcadFuncs.kPI;
            }
            AcadGeo.Tolerance tol = new AcadGeo.Tolerance(0.01, 0.01);
            if (!up_vector.IsParallelTo(axe, tol))
            {
                up_vector = up_vector.RotateBy(angle, axe);
            }
            if (!normal_vector.IsParallelTo(axe, tol))
            {
                normal_vector = normal_vector.RotateBy(angle, axe);
            }
        }
Пример #3
0
        protected override List <PathInfo> GetSweptPath()
        {
            AcadGeo.Point3d       center  = CalculateCenter();
            AcadGeo.Vector3d      ref_vec = AcadFuncs.GetVec(CalculateBranchPos(position, branch_positions[0], radius, angle), center);
            AcadGeo.CircularArc3d arc     = new AcadGeo.CircularArc3d(
                center, NormalVec(), ref_vec, radius,
                GetStartAngle(position, center, ref_vec, NormalVec()), GetEndAngle(position, center, ref_vec, NormalVec()));

            AcadFuncs.AddNewEnt(AcadDB.Arc.CreateFromGeCurve(arc));

            List <PathInfo> ents = new List <PathInfo>();

            AcadGeo.Point3d bp = CalculateBranchPos(position,
                                                    profile.NormalVector.GetNormal().IsParallelTo(AcadFuncs.GetVec(position, branch_positions[1])) ? branch_positions[1] : branch_positions[0],
                                                    radius, angle);

            profile.BasePoint = bp;
            ents.Add(new PathInfo(profile.GetRegions().First(), profile.GetSubRegions().First(), AcadDB.Arc.CreateFromGeCurve(arc), bp));

            //{
            //	var regs = profile.GetRegions();
            //	AcadFuncs.AddNewEnt(regs[0]);
            //}

            return(ents);
        }
Пример #4
0
        internal static Movement4 getMoveVector(Triangle tri, Triangle adjacentTri, Edge commonEdge)
        {
            Movement4 r      = new Movement4();
            Point     center = tri.Center;
            Edge      e      = center.PerpendicularOn(commonEdge.ToLine());

            if (adjacentTri == null)
            {
                return(r);
            }
            Edge e2 = adjacentTri.Center.PerpendicularOn(commonEdge.ToLine());

            Autodesk.AutoCAD.Geometry.Vector3d v      = MyConvert.toVector(e);
            Autodesk.AutoCAD.Geometry.Vector3d v2     = MyConvert.toVector(e2);
            Autodesk.AutoCAD.Geometry.Vector3d crossv = v.CrossProduct(v2);
            Autodesk.AutoCAD.Geometry.Vector3d movev  = crossv.CrossProduct(v);
            double angle = v.GetAngleTo(v2);

            if (angle < 0)
            {
                throw new System.Exception("angle<0");
            }
            if (angle > Math.PI)
            {
                angle = Math.PI * 2 - angle;
            }
            double length = e.Length;

            Autodesk.AutoCAD.Geometry.Vector3d unitV = movev.GetNormal();

            r.move = -unitV * (Math.PI - angle) * 1 / 16;
            r.dis  = length;
            return(r);
        }
Пример #5
0
        public static List <InterpolatedPoint> interp(Point3d p, Point3d p1, Point3d p2, Point3d p3)
        {
            List <InterpolatedPoint> ps = new List <InterpolatedPoint>();

            p1 = new Point3d(p.X + (p1.X - p.X) / 4, p.Y + (p1.Y - p.Y) / 4, p.Z + (p1.Z - p.Z) / 4);

            p2 = new Point3d(p.X + (p2.X - p.X) / 4, p.Y + (p2.Y - p.Y) / 4, p.Z + (p2.Z - p.Z) / 4);

            p3 = new Point3d(p.X + (p3.X - p.X) / 4, p.Y + (p3.Y - p.Y) / 4, p.Z + (p3.Z - p.Z) / 4);

            //pl.Sort(new My.Point3dComparer());
            //Point3d p1 = pl[0], p2 = pl[1], p3 = pl[2];
            Autodesk.AutoCAD.Geometry.Plane    plane1  = new Autodesk.AutoCAD.Geometry.Plane(p1, p2, p3);
            Autodesk.AutoCAD.Geometry.Matrix3d prjMat1 = Autodesk.AutoCAD.Geometry.Matrix3d.Projection(plane1, plane1.Normal);

            Point3d prjP = p.TransformBy(prjMat1);

            Autodesk.AutoCAD.Geometry.Vector3d direction = new Autodesk.AutoCAD.Geometry.Vector3d(p.X - prjP.X, p.Y - prjP.Y, p.Z - prjP.Z);

            Point3d tp = p1.TransformBy(Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(direction * 1 / 3));

            ps.Add(new InterpolatedPoint(direction.Length, new Point(tp.X, tp.Y, tp.Z)));
            tp = p2.TransformBy(Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(direction * 1 / 3));
            ps.Add(new InterpolatedPoint(direction.Length, new Point(tp.X, tp.Y, tp.Z)));
            tp = p3.TransformBy(Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(direction * 1 / 3));
            ps.Add(new InterpolatedPoint(direction.Length, new Point(tp.X, tp.Y, tp.Z)));

            return(ps);
        }
Пример #6
0
        private AcadGeo.Vector3d NormalVec()
        {
            AcadGeo.Vector3d v1 = AcadFuncs.GetVec(position, main_branch_position);

            AcadGeo.Vector3d v2 = AcadFuncs.GetVec(branch_position, position);

            return(v1.CrossProduct(v2).GetNormal());
        }
Пример #7
0
 public Point(double x, double y, int N)
 {
     X          = x;
     Y          = y;
     Number     = N;
     vNormalise = new Gem.Vector3d(0, 0, 0);
     isPrinted  = false;
 }
Пример #8
0
        protected override List <PathInfo> GetSweptPath()
        {
            AcadGeo.Point3d       center  = CalculateCenter();
            AcadGeo.Vector3d      ref_vec = AcadFuncs.GetVec(CalculateBranchPos(position, main_branch_position, radius), center);
            AcadGeo.CircularArc3d arc     = new AcadGeo.CircularArc3d(
                center, NormalVec(), ref_vec, radius,
                GetStartAngle(position, center, ref_vec, NormalVec()), GetEndAngle(position, center, ref_vec, NormalVec()));

            //AcadFuncs.AddNewEnt(AcadDB.Arc.CreateFromGeCurve(arc));

            List <PathInfo> ents = new List <PathInfo>();

            AcadGeo.Point3d bp = CalculateBranchPos(position,
                                                    profile.NormalVector.GetNormal().IsParallelTo(ref_vec) ? branch_position : main_branch_position,
                                                    radius);

            profile.BasePoint = new AcadGeo.Point3d(bp.X, bp.Y, bp.Z);
            ents.Add(new PathInfo(profile.GetRegions().First(), profile.GetSubRegions().First(), AcadDB.Arc.CreateFromGeCurve(arc), bp));

            {
                AcadGeo.Plane         plane   = new AcadGeo.Plane(position, AcadFuncs.GetVec(position, branch_position));
                AcadGeo.CircularArc3d tmp_arc = new AcadGeo.CircularArc3d(
                    arc.Center, arc.Normal, arc.ReferenceVector, arc.Radius, arc.StartAngle, arc.EndAngle);
                tmp_arc.Mirror(plane);

                AcadGeo.Point3d tmp_bp = new AcadGeo.Point3d(bp.X, bp.Y, bp.Z);
                if (tmp_bp.IsEqualTo(CalculateBranchPos(position, branch_position, radius)))
                {
                    tmp_bp           += AcadFuncs.GetVec(position, branch_position) * radius * 2.0;
                    profile.BasePoint = tmp_bp;
                }
                //AcadFuncs.AddNewEnt(AcadDB.Arc.CreateFromGeCurve(tmp_arc));

                ents.Add(new PathInfo(profile.GetRegions().First(), profile.GetSubRegions().First(), AcadDB.Arc.CreateFromGeCurve(tmp_arc), tmp_bp));
            }

            {
                AcadGeo.Point3d tmp_pos     = CalculateBranchPos(position, branch_position, radius);
                AcadGeo.Point3d tmp_end_pos = tmp_pos + AcadFuncs.GetVec(position, branch_position) * radius * 2.0;

                AcadGeo.Point3d tmp_bp = new AcadGeo.Point3d(bp.X, bp.Y, bp.Z);
                if (tmp_bp.IsEqualTo(CalculateBranchPos(position, branch_position, radius)))
                {
                    profile.BasePoint = CalculateBranchPos(position, branch_position, radius);
                }
                else
                {
                    profile.BasePoint = new AcadGeo.Point3d(position.X, position.Y, position.Z);
                    profile.Rotate(AcadFuncs.GetVec(position, branch_position));
                    profile.BasePoint = CalculateBranchPos(position, branch_position, radius);
                }

                ents.Add(new PathInfo(profile.GetRegions().First(), profile.GetSubRegions().First(), new AcadDB.Line(tmp_pos, tmp_end_pos), tmp_bp));
            }


            return(ents);
        }
Пример #9
0
 public Profile(Profile p)
 {
     base_point    = p.base_point;
     width         = p.width;
     height        = p.height;
     thickness     = p.thickness;
     up_vector     = p.up_vector;
     normal_vector = p.normal_vector;
 }
Пример #10
0
 public Profile()
 {
     base_point    = new AcadGeo.Point3d();
     width         = 0.0;
     height        = 0.0;
     thickness     = 0.0;
     up_vector     = new AcadGeo.Vector3d();
     normal_vector = new AcadGeo.Vector3d();
 }
Пример #11
0
        private AcadGeo.Point3d CalculateCenter()
        {
            AcadGeo.Vector3d vec = AcadFuncs.GetVec(
                CalculateBranchPos(position, main_branch_position, radius),
                CalculateBranchPos(position, branch_position, radius));
            AcadGeo.Point3d pos   = position + AcadFuncs.GetVec(main_branch_position, position) * radius;
            AcadGeo.Plane   plane = new AcadGeo.Plane(pos, NormalVec().CrossProduct(vec));

            return(position.Mirror(plane));
        }
Пример #12
0
        public void CalculateAngle()
        {
            AcadGeo.Vector3d vec1 = AcadFuncs.GetVec(branch_positions[0], position);
            AcadGeo.Vector3d vec2 = AcadFuncs.GetVec(branch_positions[1], position);

            if (vec1.IsParallelTo(vec2))
            {
                throw new Exception("Failed parse elbow");
            }
            angle = vec1.GetAngleTo(vec2);
        }
Пример #13
0
 private void AutoDetectParams(ref AcadGeo.Point3d bp, ref AcadGeo.Vector3d up_vec, ref AcadGeo.Vector3d norm)
 {
     foreach (var conn in routers.Edges)
     {
         if (ConnVec(conn).DotProduct(AcadGeo.Vector3d.ZAxis) < 0.0001)
         {
             bp     = conn.Source.Position;
             up_vec = AcadGeo.Vector3d.ZAxis;
             norm   = ConnVec(conn);
         }
     }
 }
Пример #14
0
        public static Point3dCollection GetOffsetTriangles(TinSurfaceTriangle tri, double offset)
        {
            var points = new Point3dCollection();

            try
            {
                Acad.Vector3d cenpointp3d = new Acad.Vector3d();
                Acad.Vector3d centerv1    = new Acad.Vector3d();
                Acad.Vector3d centerv2    = new Acad.Vector3d();
                Acad.Vector3d centerv3    = new Acad.Vector3d();

                var v1 = tri.Vertex1.Location;
                var v2 = tri.Vertex2.Location;
                var v3 = tri.Vertex3.Location;


                var vec1 = v1.GetVectorTo(v2);
                var vec2 = v1.GetVectorTo(v3);

                var norm = vec1.CrossProduct(vec2);
                var e1   = UnitVector3D(vec1);
                var e2   = UnitVector3D(vec2);


                var M = new Acad.Vector3d(norm.X, norm.Y, norm.Z + offset);

                cenpointp3d = FindTriangleCenter(v1, v2, v3, vec1.CrossProduct(vec2));

                centerv1 = new Acad.Vector3d(cenpointp3d.X + v1.X, cenpointp3d.Y + v1.Y, cenpointp3d.Z + v1.Z) / 2.0;
                centerv2 = new Acad.Vector3d(cenpointp3d.X + v2.X, cenpointp3d.Y + v2.Y, cenpointp3d.Z + v2.Z) / 2.0;
                centerv3 = new Acad.Vector3d(cenpointp3d.X + v3.X, cenpointp3d.Y + v3.Y, cenpointp3d.Z + v3.Z) / 2.0;

                var offsetcenterv1 = (centerv1.Add(M));
                var offsetcenterv2 = (centerv2.Add(M));
                var offsetcenterv3 = (centerv3.Add(M));

                var p1 = new Acad.Point3d(offsetcenterv1.X, offsetcenterv1.Y, offsetcenterv1.Z);
                var p2 = new Acad.Point3d(offsetcenterv2.X, offsetcenterv2.Y, offsetcenterv2.Z);
                var p3 = new Acad.Point3d(offsetcenterv3.X, offsetcenterv3.Y, offsetcenterv3.Z);


                points.Add(p1);
                points.Add(p2);
                points.Add(p3);
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message);
            }

            return(points);
        }
Пример #15
0
        public void BuildProfile()
        {
            //double width = 0.0;
            if (!AcadFuncs.GetDouble(ref width, "Nhập chiều rộng:"))
            {
                throw new Exception("Cancel process");
            }

            //double height = 0.0;
            if (!AcadFuncs.GetDouble(ref height, "Nhập chiều cao:"))
            {
                throw new Exception("Cancel process");
            }

            if (!AcadFuncs.GetDouble(ref thickness, "Nhập độ dày:"))
            {
                throw new Exception("Cancel process");
            }

            //AcadGeo.Point3d bp = new AcadGeo.Point3d();
            //while (true)
            //{
            //	if (!AcadFuncs.GetPoint(ref bp, "Chọn điểm bắt đầu:"))
            //		throw new Exception("Cancel process");

            //	if (null != FindNode(bp))
            //		break;
            //}

            //AcadGeo.Point3d vp = new AcadGeo.Point3d();
            //if (!AcadFuncs.GetPoint(ref vp, "Chọn hướng:", bp))
            //	throw new Exception("Cancel process");

            //AcadGeo.Point3d up = new AcadGeo.Point3d();
            //if (!AcadFuncs.GetPoint(ref up, "Chọn up:", bp))
            //	throw new Exception("Cancel process");

            AcadGeo.Point3d  bp     = new AcadGeo.Point3d();
            AcadGeo.Vector3d up_vec = new AcadGeo.Vector3d();
            AcadGeo.Vector3d norm   = new AcadGeo.Vector3d();
            AutoDetectParams(ref bp, ref up_vec, ref norm);

            profile.Width        = width;
            profile.Height       = height;
            profile.Thickness    = thickness;
            profile.BasePoint    = bp;
            profile.NormalVector = norm;
            profile.UpVector     = up_vec;
        }
Пример #16
0
        public static Point3d?GetNormalPointEx(this Polyline sourceLine, Point3d point, Polyline distanceLine)
        {
            Autodesk.AutoCAD.Geometry.Vector3d normal = sourceLine.GetFirstDerivative(point);
            normal = normal.GetPerpendicularVector();

            Autodesk.AutoCAD.Geometry.Point3dCollection intersects = new Autodesk.AutoCAD.Geometry.Point3dCollection();
            distanceLine.IntersectWith(new Line(point, new Autodesk.AutoCAD.Geometry.Point3d(point.X + normal.X, point.Y + normal.Y, 0d)), Intersect.ExtendBoth, new Autodesk.AutoCAD.Geometry.Plane(), intersects, new IntPtr(1), new IntPtr(0));
            if (intersects.Count == 0)
            {
                return(null);
            }
            else
            {
                return(intersects[0]);
            }
        }
Пример #17
0
        private double AngleElbow(Node n)
        {
            if (ELBOW_CONNS != n.Connections.Count)
            {
                return(AcadFuncs.kPI * 0.5);
            }

            AcadGeo.Vector3d vec1 = n.Position.IsEqualTo(n.Connections[0].Source.Position) ?
                                    AcadFuncs.GetVec(n.Connections[0].Source.Position, n.Connections[0].Target.Position) :
                                    AcadFuncs.GetVec(n.Connections[0].Target.Position, n.Connections[0].Source.Position);
            AcadGeo.Vector3d vec2 = n.Position.IsEqualTo(n.Connections[1].Target.Position) ?
                                    AcadFuncs.GetVec(n.Connections[1].Target.Position, n.Connections[1].Source.Position) :
                                    AcadFuncs.GetVec(n.Connections[1].Source.Position, n.Connections[1].Target.Position);

            return(Math.Abs(vec1.GetAngleTo(vec2)));
        }
Пример #18
0
        private AcadGeo.Point3d GetMainTeePos(AcadGeo.Point3d pos, AcadGeo.Point3d pos1, AcadGeo.Point3d pos2, AcadGeo.Point3d pos3)
        {
            AcadGeo.Vector3d vec1 = AcadFuncs.GetVec(pos, pos1);
            AcadGeo.Vector3d vec2 = AcadFuncs.GetVec(pos, pos2);
            AcadGeo.Vector3d vec3 = AcadFuncs.GetVec(pos, pos3);

            if (vec1.IsParallelTo(vec2))
            {
                return(pos3);
            }
            if (vec1.IsParallelTo(vec3))
            {
                return(pos2);
            }
            return(pos1);
        }
Пример #19
0
        private AcadGeo.Point3d CalculateCenter()
        {
            //AcadGeo.Vector3d vec = AcadFuncs.GetVec(
            //	CalculateBranchPos(position, branch_positions[0], radius, angle),
            //	CalculateBranchPos(position, branch_positions[1], radius, angle));
            //AcadGeo.Point3d pos = position + AcadFuncs.GetVec(branch_positions[0], position) * (radius / Math.Sin(angle * 0.5));
            //AcadGeo.Plane plane = new AcadGeo.Plane(pos, NormalVec().CrossProduct(vec));

            //return position.Mirror(plane);
            AcadGeo.Vector3d vec1    = AcadFuncs.GetVec(branch_positions[0], position);
            AcadGeo.Vector3d vec2    = AcadFuncs.GetVec(branch_positions[1], position);
            AcadGeo.Vector3d tmp_vec = new AcadGeo.Vector3d(
                vec1.X + vec2.X, vec1.Y + vec2.Y, vec1.Z + vec2.Z);
            tmp_vec = tmp_vec.GetNormal();
            return(position + tmp_vec * (radius / Math.Sin(angle * 0.5)));
        }
Пример #20
0
        public static CoordinateSystem GetCeometricUcs()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            Autodesk.AutoCAD.Geometry.Matrix3d currentUserCoordinateSystem = editor.CurrentUserCoordinateSystem;
            Point3d origin = currentUserCoordinateSystem.CoordinateSystem3d.Origin;

            Autodesk.AutoCAD.Geometry.Vector3d xaxis       = currentUserCoordinateSystem.CoordinateSystem3d.Xaxis;
            Autodesk.AutoCAD.Geometry.Vector3d yaxis       = currentUserCoordinateSystem.CoordinateSystem3d.Yaxis;
            Autodesk.AutoCAD.Geometry.Vector3d zaxis       = currentUserCoordinateSystem.CoordinateSystem3d.Zaxis;
            ngeometry.VectorGeometry.Point     originPoint = new ngeometry.VectorGeometry.Point(origin.X, origin.Y, origin.Z);
            ngeometry.VectorGeometry.Vector3d  e           = new ngeometry.VectorGeometry.Vector3d(xaxis.X, xaxis.Y, xaxis.Z);
            ngeometry.VectorGeometry.Vector3d  e2          = new ngeometry.VectorGeometry.Vector3d(yaxis.X, yaxis.Y, yaxis.Z);
            ngeometry.VectorGeometry.Vector3d  e3          = new ngeometry.VectorGeometry.Vector3d(zaxis.X, zaxis.Y, zaxis.Z);
            return(new ngeometry.VectorGeometry.CoordinateSystem(originPoint, e, e2, e3));
        }
Пример #21
0
        public PolylineJig(Matrix3d ucs, double width)
            : base(new Polyline())
        {
            m_pts = new Point3dCollection();
            var origin = new Point3d(0, 0, 0);
            var normal = new Vector3d(0, 0, 1);

            normal  = normal.TransformBy(ucs);
            m_plane = new Plane(origin, normal);
            var pline = Entity as Polyline;

            pline.SetDatabaseDefaults();
            pline.Normal = normal;
            pline.AddVertexAt(0, new Point2d(0, 0), 0, width, width);

            lineWidth = width;
        }
Пример #22
0
        public static double FinalZCoordAcad(Autodesk.AutoCAD.Geometry.Vector3d normal, Autodesk.AutoCAD.Geometry.Point3d point, Autodesk.AutoCAD.Geometry.Vector3d testpoint)
        {
            var a = normal.X;
            var b = normal.Y;
            var c = normal.Z;

            var x0 = point.X;
            var y0 = point.Y;
            var z0 = point.Z;

            var x = testpoint.X;
            var y = testpoint.Y;

            var z = -(a * x - a * x0 + b * y - b * y0 - c * z0) / c;

            return(z);
        }
Пример #23
0
        private static void AddMLeader(Gem.Point2d pnt, Gem.Vector3d otstup,
                                       double scale, string layer,
                                       string mleaderStyleName, string str)
        {
            SettingsParser settings = SettingsParser.getInstance();

            App.Document acDoc   = App.Application.DocumentManager.MdiActiveDocument;
            Db.Database  acCurDb = acDoc.Database;
            using (Db.Transaction acTrans = acCurDb.TransactionManager.StartOpenCloseTransaction())
            {
                Db.BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                           Db.OpenMode.ForRead) as Db.BlockTable;
                Db.BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[Db.BlockTableRecord.ModelSpace],
                                                                    Db.OpenMode.ForWrite) as Db.BlockTableRecord;
                Db.MLeader acML = new Db.MLeader();
                acML.SetDatabaseDefaults();
                acML.Layer        = layer;
                acML.MLeaderStyle = CheckLocalRepository.GetIDbyName <Db.MLeaderStyle>(acCurDb, mleaderStyleName);
                acML.ContentType  = Db.ContentType.MTextContent;
                Db.MText mText = new Db.MText();
                mText.SetDatabaseDefaults();
                mText.Contents           = str;
                mText.TextHeight         = scale;
                mText.BackgroundFill     = settings.MTextMask;
                mText.UseBackgroundColor = settings.MTextMask;


                if (settings.MTextMask)
                {
                    mText.BackgroundScaleFactor = settings.MTextMaskKoefficient;
                }

                mText.Location = (new Gem.Point3d(pnt.X, pnt.Y, 0) + otstup);
                acML.MText     = mText;
                int idx = acML.AddLeaderLine(new Gem.Point3d(pnt.X, pnt.Y, 0));

                acML.Scale = 1;


                acBlkTblRec.AppendEntity(acML);
                acTrans.AddNewlyCreatedDBObject(acML, true);
                acTrans.Commit();
            }
        }
Пример #24
0
        public static PointSet __interp(Point3d p, List <LineSegment3d> ll)
        {
            if (ll.Count < 3)
            {
                return(null);
            }
            PointSet       ps = new PointSet();
            List <Point3d> pl = new List <Point3d>();
            Point3d        ortherP;

            for (int i = 0; i < ll.Count; i++)
            {
                if (p == ll[0].EndPoint)
                {
                    ortherP = ll[0].StartPoint;
                }
                else
                {
                    ortherP = ll[i].EndPoint;
                }
                Point3d tp = new Point3d(p.X + (ortherP.X - p.X) / 3, p.Y + (ortherP.Y - p.Y) / 3, p.Z + (ortherP.Z - p.Z) / 3);
                pl.Add(tp);
            }
            Point3d p1 = pl[0], p2 = pl[1], p3 = pl[2];

            Autodesk.AutoCAD.Geometry.Plane    plane1  = new Autodesk.AutoCAD.Geometry.Plane(p1, p2, p3);
            Autodesk.AutoCAD.Geometry.Matrix3d prjMat1 = Autodesk.AutoCAD.Geometry.Matrix3d.Projection(plane1, plane1.Normal);


            Point3d prjP = p.TransformBy(prjMat1);

            Autodesk.AutoCAD.Geometry.Vector3d direction = new Autodesk.AutoCAD.Geometry.Vector3d(p.X - prjP.X, p.Y - prjP.Y, p.Z - prjP.Z);
            for (int i = 0; i < pl.Count; i++)
            {
                //double d = p.DistanceTo(prjP);
                ;
                Point3d tp = pl[i].TransformBy(Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(direction * 2 / 3));
                ps.Add(new Point(tp.X, tp.Y, tp.Z));
            }

            return(ps);
        }
Пример #25
0
        public static SummationsAcad IterateAdjacentTrianglesAcad(TinSurfaceTriangleCollection connectedTriangles, Acad.Point3d centernode)
        {
            var top = new Acad.Vector3d(0, 0, 0);
            var bot = new Acad.Vector3d(0, 0, 0);

            foreach (var triangle in connectedTriangles)
            {
                //3-Vertices's for Triangle

                var v1 = triangle;
                var v2 = triangle;
                var v3 = triangle;

                //Formatting

                var p1 = triangle.Vertex1.Location;
                var p2 = triangle.Vertex2.Location;
                var p3 = triangle.Vertex3.Location;

                //Get Vectors

                var vec12 = p1.GetVectorTo(p2);
                var vec13 = p1.GetVectorTo(p3);
                var norm  = vec13.CrossProduct(vec12);

                var centerOfPlane = FindTriangleCenter(p1, p2, p3, norm);


                var e1 = UnitVector3D(vec12);
                var e2 = UnitVector3D(vec13);

                var angleradian = Math.Acos(e1.DotProduct(e2));
                var unitnormal  = e1.CrossProduct(e2);


                top += unitnormal.MultiplyBy(angleradian);
                bot += unitnormal.MultiplyBy(angleradian);
            }

            return(new SummationsAcad(top, bot));
        }
Пример #26
0
        internal static ProjectClass getMovement(Point3d p, Point3d p1, Point3d p2, Point3d p3)
        {
            List <InterpolatedPoint> ps = new List <InterpolatedPoint>();

            //p1 = new Point3d(p.X + (p1.X - p.X) / 4, p.Y + (p1.Y - p.Y) / 4, p.Z + (p1.Z - p.Z) / 4);

            //p2 = new Point3d(p.X + (p2.X - p.X) / 4, p.Y + (p2.Y - p.Y) / 4, p.Z + (p2.Z - p.Z) / 4);

            //p3= new Point3d(p.X + (p3.X - p.X) /4, p.Y + (p3.Y - p.Y) / 4, p.Z + (p3.Z - p.Z) / 4);

            //pl.Sort(new My.Point3dComparer());
            //Point3d p1 = pl[0], p2 = pl[1], p3 = pl[2];
            Autodesk.AutoCAD.Geometry.Plane    plane1  = new Autodesk.AutoCAD.Geometry.Plane(p1, p2, p3);
            Autodesk.AutoCAD.Geometry.Matrix3d prjMat1 = Autodesk.AutoCAD.Geometry.Matrix3d.Projection(plane1, plane1.Normal);

            Point3d prjP = p.TransformBy(prjMat1);

            Autodesk.AutoCAD.Geometry.Vector3d direction = new Autodesk.AutoCAD.Geometry.Vector3d(p.X - prjP.X, p.Y - prjP.Y, p.Z - prjP.Z);
            List <Point3d> pl = new List <Point3d>();

            pl.Add(p1); pl.Add(p2); pl.Add(p3);
            return(new ProjectClass(plane1, prjMat1, direction, pl));
        }
Пример #27
0
        public static List <InterpolatedPoint> interp2(TEDictionary ted, Triangle tri)
        {
            List <InterpolatedPoint> r = new List <InterpolatedPoint>();

            Autodesk.AutoCAD.Geometry.Vector3d totalMoveV = new Autodesk.AutoCAD.Geometry.Vector3d();
            List <Movement4> moveList = new List <Movement4>();
            Point            center   = tri.Center;

            for (int i = 0; i < 3; i++)
            {
                Edge     commonEdge  = tri.Edges[i];
                Triangle adjacentTri = getAdjacentTri(ted, tri, commonEdge);
                if (adjacentTri == null)
                {
                    continue;
                }
                Movement4 moveV = getMoveVector(tri, adjacentTri, commonEdge);
                moveList.Add(moveV);
            }
            double totalLength = 0;

            for (int i = 0; i < moveList.Count; i++)
            {
                totalLength += moveList[i].dis;
            }

            for (int i = 0; i < moveList.Count; i++)
            {
                totalMoveV += moveList[i].move * totalLength;
            }

            Point movedP = center.Move(new ngeometry.VectorGeometry.Vector3d(totalMoveV.X, totalMoveV.Y, totalMoveV.Z));

            r.Add(new InterpolatedPoint(totalMoveV.Length, movedP));
            return(r);
        }
Пример #28
0
 public static Acad.Vector3d UnitVector3D(Acad.Vector3d vector)
 {
     return(vector.DivideBy(Magnitude(vector)));
 }
Пример #29
0
        private static Acad.Vector3d FindTriangleCenter(Autodesk.AutoCAD.Geometry.Point3d p1, Autodesk.AutoCAD.Geometry.Point3d p2, Autodesk.AutoCAD.Geometry.Point3d p3, Autodesk.AutoCAD.Geometry.Vector3d norm)
        {
            var centerX = (p1.X + p2.X + p3.X) / 3;
            var centerY = (p1.Y + p2.Y + p3.Y) / 3;
            var centerZ = FinalZCoordAcad(norm, p1, new Autodesk.AutoCAD.Geometry.Vector3d(centerX, centerY, 0));

            return(new Acad.Vector3d(centerX, centerY, centerZ));
        }
Пример #30
0
 private static double Magnitude(Acad.Vector3d vec)
 {
     return(Math.Sqrt(Math.Pow(vec.X, 2) + Math.Pow(vec.Y, 2) + Math.Pow(vec.Z, 2)));
 }