Exemple #1
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Vector3d vec  = basePoint.GetVectorTo(secondPoint);
                Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.secondPoint));
                //geo.PushModelTransform(disp);
                for (int i = 0; i < blockPosition.Count; i++)
                {
                    Point3d tempPoint = blockPosition[i] + vec;
                    brefs[i].Position = tempPoint;
                    geo.Draw(brefs[i]);
                }

                for (int i = 0; i < linesPosition.Count; i++)
                {
                    Point3d tempStartPoint = linesPosition[i].Item1 + vec;
                    Point3d tempEndPoint   = linesPosition[i].Item2 + vec;

                    lines[i].StartPoint = tempStartPoint;
                    lines[i].EndPoint   = tempEndPoint;
                    geo.Draw(lines[i]);
                }
                //geo.PopModelTransform();
                return(true);
            }
            return(false);
        }
Exemple #2
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                if (jigUpdate)
                {
                    stair = MyFunctions.CreateStair3D(steps, riser, tread, landing, width, slope);
                }
                switch (jigStatus)
                {
                case 0:
                    geo.PushModelTransform(matDisplacement);
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;

                case 1:
                    geo.PushModelTransform(matDisplacement.PreMultiplyBy(matRotation));
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;;

                default: return(false);
                }
            }
            return(true);
        }
Exemple #3
0
        static void TestWGEO()
        {
            WorldGeometry wgeo = new WorldGeometry("room.wgeo");

            Directory.CreateDirectory("kek");

            for (int i = 0; i < 128; i++)
            {
                for (int j = 0; j < 128; j++)
                {
                    BucketGridBucket bucket = wgeo.BucketGrid.Buckets[i, j];

                    List <uint> indices = wgeo.BucketGrid.Indices
                                          .GetRange((int)bucket.StartIndex, (bucket.InsideFaceCount + bucket.StickingOutFaceCount) * 3)
                                          .Select(x => (uint)x)
                                          .ToList();

                    if (indices.Count != 0)
                    {
                        int            startVertex = (int)indices.Min();
                        int            vertexCount = (int)indices.Max() - startVertex;
                        List <Vector3> vertices    = wgeo.BucketGrid.Vertices.GetRange(startVertex + (int)bucket.BaseVertex, vertexCount);

                        new OBJFile(vertices, indices).Write(string.Format("kek/bucket{0}_{1}.obj", i, j));
                    }
                }
            }
        }
Exemple #4
0
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            WorldGeometry wGeo = draw.Geometry;

            if (wGeo != null)
            {
                wGeo.PushModelTransform(UCS);
                wGeo.Polygon(corners);
                wGeo.PopModelTransform();
            }
            return(true);
        }
Exemple #5
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                table.Position = insertionPoint;
                geo.Draw(table);
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// Converts the models of <paramref name="wgeo"/> into the <see cref="OBJFile"/> format
 /// </summary>
 /// <param name="wgeo">The <see cref="WorldGeometry"/> to convert models from</param>
 /// <returns>Converted <see cref="WorldGeometryModel"/> models in the <see cref="OBJFile"/> format</returns>
 public static IEnumerable <OBJFile> ConvertWGEOModels(WorldGeometry wgeo)
 {
     foreach (WorldGeometryModel model in wgeo.Models)
     {
         List <Vector3> vertices = new List <Vector3>();
         List <Vector2> uvs      = new List <Vector2>();
         foreach (WorldGeometryVertex vertex in model.Vertices)
         {
             vertices.Add(vertex.Position);
             uvs.Add(vertex.UV);
         }
         yield return(new OBJFile(vertices, model.Indices, uvs));
     }
 }
Exemple #7
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Vector3d vec  = basePoint.GetVectorTo(secondPoint);
                Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.secondPoint));
                //geo.PushModelTransform(disp);
                for (int i = 0; i < blockPosition.Count; i++)
                {
                    Point3d tempPoint = blockPosition[i] + vec;
                    brefs[i].Position = tempPoint;
                    geo.Draw(brefs[i]);
                }

                for (int i = 0; i < linesPosition.Count; i++)
                {
                    Point3d tempStartPoint = linesPosition[i].Item1 + vec;
                    Point3d tempEndPoint   = linesPosition[i].Item2 + vec;

                    lines[i].StartPoint = tempStartPoint;
                    lines[i].EndPoint   = tempEndPoint;
                    geo.Draw(lines[i]);
                }

                if (plinesPosition.Count != 0)
                {
                    for (int i = 0; i < plinesPosition.Count; i++)
                    {
                        List <Point3d> tempVertext = new List <Point3d>();
                        for (int j = 0; j < plinesPosition[j].Count; j++)
                        {
                            Point3d newVert    = plinesPosition[i][j] + vec;
                            double  bulge      = plines[i].GetBulgeAt(j);
                            double  startWidth = plines[i].GetStartWidthAt(j);
                            double  endWidth   = plines[i].GetEndWidthAt(j);
                            plines[i].RemoveVertexAt(j);
                            plines[i].AddVertexAt(j, new Point2d(newVert.X, newVert.Y), bulge, startWidth, endWidth);
                        }
                        geo.Draw(plines[i]);
                    }
                }


                //geo.PopModelTransform();
                return(true);
            }
            return(false);
        }
Exemple #8
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                // Отрисовка линий.
                _lines = getLines();
                foreach (var line in _lines)
                {
                    geo.Draw(line);
                }
            }
            return(true);
        }
Exemple #9
0
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            mleader.EndPoint = mdragPT;
            Vector3d UserXaxis = db.Ucsxdir;
            Vector3d WXaxis    = new Vector3d(1, 0, 0);
            Vector3d Zaxis     = new Vector3d(0, 0, 1);
            double   Rangle    = UserXaxis.GetAngleTo(WXaxis);

            if (UserXaxis.Y < 0)
            {
                Zaxis = Zaxis.Negate();                                           //1.03版修改,修正角度旋转正负问题
            }
            Matrix3d Rmat = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);            //旋转矩阵

            if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X)
            {
                Matrix3d      mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT)).PreMultiplyBy(Rmat); //旋转矩阵左乘位移矩阵
                WorldGeometry geo = draw.Geometry;
                if (geo != null)
                {
                    geo.Draw(mleader);
                    geo.PushModelTransform(mat);
                    foreach (Entity ent in mEntities)
                    {
                        geo.Draw(ent);
                    }
                    geo.PopModelTransform();
                }
            }
            else
            {
                Line          L   = (Line)mEntitiesL[0];
                Vector3d      Vt  = new Vector3d(L.Length, 0, 0);
                Matrix3d      mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) - Vt).PreMultiplyBy(Rmat);//旋转矩阵左乘位移矩阵
                WorldGeometry geo = draw.Geometry;
                if (geo != null)
                {
                    geo.Draw(mleader);
                    geo.PushModelTransform(mat);
                    foreach (Entity ent in mEntitiesL)
                    {
                        geo.Draw(ent);
                    }
                    geo.PopModelTransform();
                }
            }
            return(true);
        }
Exemple #10
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Vector3d vec  = basePoint.GetVectorTo(secondPoint);
                Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.secondPoint));
                //geo.PushModelTransform(disp);

                Point3d tempPoint = brefPosition + vec;
                bref.Position = tempPoint;
                geo.Draw(bref);
            }
            return(true);
        }
Exemple #11
0
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            Matrix3d      mat3d = Matrix3d.Displacement(pnt3dRes - pnt3dBase);
            WorldGeometry wGeo  = draw.Geometry;

            if (wGeo != null)
            {
                wGeo.PushModelTransform(mat3d);
                foreach (Entity ent in entities)
                {
                    wGeo.Draw(ent);
                }
                wGeo.PopModelTransform();
            }
            return(true);
        }
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            Matrix3d mat = Matrix3d.Displacement(this.startPoint.GetVectorTo(this.insertPoint));

            mat = currentUCS.PreMultiplyBy(mat);

            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                geo.PushModelTransform(mat);
                foreach (var ent in this.entities)
                {
                    geo.Draw(ent);
                }

                geo.PopModelTransform();
            }

            return(true);
        }
Exemple #13
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry  geo    = draw.Geometry;
            List <Point3d> points = new List <Point3d>();

            points.Add(firstPoint);
            points.Add(secondPoint);
            primaryBoundary = createRectangleForXclip(points);

            if (primaryBoundary == null || primaryBoundary.Count != 4)
            {
                return(false);
            }

            geo.WorldLine(primaryBoundary[0], primaryBoundary[1]);
            geo.WorldLine(primaryBoundary[1], primaryBoundary[2]);
            geo.WorldLine(primaryBoundary[2], primaryBoundary[3]);
            geo.WorldLine(primaryBoundary[3], primaryBoundary[0]);

            return(true);
        }
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Point3dCollection tempPts = new Point3dCollection();
                foreach (Point3d pt in mAllVertexes)
                {
                    tempPts.Add(pt);
                }

                tempPts.Add(mLastVertex);
                if (tempPts.Count > 0)
                {
                    try
                    {
                        Database db = HostApplicationServices.WorkingDatabase;
                        Autodesk.AutoCAD.DatabaseServices.Polyline line = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                        for (int i = 0; i < tempPts.Count; i++)
                        {
                            Point3d pt3d = tempPts[i];
                            Point2d pt2d = new Point2d(pt3d.X, pt3d.Y);
                            line.AddVertexAt(i, pt2d, 0, db.Plinewid, db.Plinewid);
                        }
                        Point2d final = new Point2d(tempPts[0].X, tempPts[0].Y);
                        line.AddVertexAt(tempPts.Count, final, 0, db.Plinewid, db.Plinewid);
                        line.ConstantWidth = HeatSourceLayoutApp.globalProperty.BuildingOutlineWidth;
                        line.Color         = Color.FromRgb(255, 0, 0);
                        draw.Geometry.Draw(line);
                    }
                    catch (System.Exception e)
                    {
                        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message);
                    }
                }
            }
            return(true);
        }
Exemple #15
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            try
            {
                WorldGeometry geometry = draw.Geometry;
                if (geometry != null)
                {
                    geometry.PushModelTransform(transforms);
                    foreach (Entity entity in entityList)
                    {
                        geometry.Draw(entity);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                ProxyCAD.Editor.WriteMessage(ex.Message);
                return(false);
            }
        }
Exemple #16
0
    protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
    {
        Vector3d UserXaxis = db.Ucsxdir;
        Vector3d WXaxis    = new Vector3d(1, 0, 0);
        Vector3d Zaxis     = new Vector3d(0, 0, 1);
        double   Rangle    = UserXaxis.GetAngleTo(WXaxis);
        Matrix3d Rmat      = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);
        Vector3d VT        = new Vector3d(1, 1, 1);                                 //插入点转换向量

        if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y >= mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(0, 0, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X < mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y >= mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(-mtableob.Width, 0, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X < mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y < mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(-mtableob.Width, -mtableob.Height, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y < mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(0, -mtableob.Height, 0);
        }
        Matrix3d      mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) + VT);
        WorldGeometry geo = draw.Geometry;

        if (geo != null)
        {
            geo.Draw(mleader);
            geo.PushModelTransform(mat.PreMultiplyBy(Rmat));
            geo.Draw(mtableob);
            geo.PopModelTransform();
        }
        return(true);
    }
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return(base.WorldDraw(drawable, wd));
            }

            RebarPos pos = drawable as RebarPos;

            if (pos == null)
            {
                return(base.WorldDraw(drawable, wd));
            }

            PosShape  shape    = PosShape.GetPosShape(pos.Shape);
            Extents3d?shapeExt = shape.Bounds;

            if (!shapeExt.HasValue)
            {
                return(base.WorldDraw(drawable, wd));
            }
            Extents3d ext = shapeExt.Value;

            WorldGeometry   g     = wd.Geometry;
            SubEntityTraits s     = wd.SubEntityTraits;
            TextStyle       style = new TextStyle();

            // Get geometry
            Point3d  pt   = pos.BasePoint;
            Vector3d dir  = pos.DirectionVector;
            Vector3d up   = pos.UpVector;
            Vector3d norm = pos.NormalVector;

            double w = pos.Width / dir.Length;
            double h = pos.Height / dir.Length;

            // Draw bound dimension lines
            foreach (RebarPos.BoundDimension dim in pos.GetBoundDimensions())
            {
                Line line = new Line(dim.TextPosition, pos.BasePoint);
                g.Draw(line);
            }

            // Draw shape
            double xmin = ext.MinPoint.X, ymin = ext.MinPoint.Y, xmax = ext.MaxPoint.X, ymax = ext.MaxPoint.Y;

            // Scale
            double scale = 0.025;
            // Client offsets
            double xoff = (w - scale * (xmax - xmin)) / 2.0;
            double yoff = 2.0 * h;//(h - scale * (ymax - ymin)) / 2.0;

            // Transform
            Matrix3d trans = Matrix3d.AlignCoordinateSystem(new Point3d(xmin, ymin, 0), Vector3d.XAxis / scale, Vector3d.YAxis / scale, Vector3d.ZAxis / scale, pt + dir * xoff + up * yoff, dir, up, norm);

            g.PushModelTransform(trans);

            // Draw shapes
            shape.SetShapeTexts(pos.A, pos.B, pos.C, pos.D, pos.E, pos.F);
            g.Draw(shape);
            shape.ClearShapeTexts();

            // Reset transform
            g.PopModelTransform();

            return(base.WorldDraw(drawable, wd));
        }