public JtPlacement2dInt(FamilyInstance fi) { LocationPoint lp = fi.Location as LocationPoint; Debug.Assert(null != lp, "expected valid family instanace location point"); Translation = new Point2dInt(lp.Point); Rotation = Util.ConvertRadiansToDegrees(lp.Rotation); SymbolId = fi.Symbol.UniqueId; }
/// <summary> /// Expand bounding box to contain /// the given new point. /// </summary> public void ExpandToContain(Point2dInt p) { if (p.X < xmin) { xmin = p.X; } if (p.Y < ymin) { ymin = p.Y; } if (p.X > xmax) { xmax = p.X; } if (p.Y > ymax) { ymax = p.Y; } }
/// <summary> /// Create a dummy placement for a non-instance /// part, i.e. a nomral BIM element with a given /// unique id, just for GeoSnoop graphical /// debugging purposes. /// </summary> public JtPlacement2dInt(string uidPart) { Translation = new Point2dInt(0, 0); Rotation = 0; SymbolId = uidPart; }
/// <summary> /// Display room and the furniture contained in it /// in a bitmap generated on the fly. /// </summary> /// <param name="roomLoops">Room boundary loops</param> /// <param name="geometryLoops">Family symbol geometry</param> /// <param name="familyInstances">Family instances</param> public static Bitmap DisplayRoom( JtLoops roomLoops, Dictionary <string, JtLoop> geometryLoops, List <JtPlacement2dInt> familyInstances) { JtBoundingBox2dInt bbFrom = roomLoops.BoundingBox; // Adjust target rectangle height to the // displayee loop height. int width = _form_width; int height = (int)(width * bbFrom.AspectRatio + 0.5); //SizeF fsize = new SizeF( width, height ); //SizeF scaling = new SizeF( 1, 1 ); //PointF translation = new PointF( 0, 0 ); //GetTransform( fsize, bbFrom, // ref scaling, ref translation, true ); //Matrix transform1 = new Matrix( // new Rectangle(0,0,width,height), // bbFrom.GetParallelogramPoints()); //transform1.Invert(); // the bounding box fills the rectangle // perfectly and completely, inverted and // non-uniformly distorted: //Point2dInt pmin = bbFrom.Min; //Rectangle rect = new Rectangle( // pmin.X, pmin.Y, bbFrom.Width, bbFrom.Height ); //Point[] parallelogramPoints = new Point [] { // new Point( 0, 0 ), // upper left // new Point( width, 0 ), // upper right // new Point( 0, height ) // lower left //}; // the bounding box fills the rectangle // perfectly and completely, inverted and // non-uniformly distorted: // Specify transformation target rectangle // including a margin. int bottom = height - (_margin + _margin); Point[] parallelogramPoints = new Point[] { new Point(_margin, bottom), // upper left new Point(width - _margin, bottom), // upper right new Point(_margin, _margin) // lower left }; // Transform from native loop coordinate system // to target display coordinates. Matrix transform = new Matrix( bbFrom.Rectangle, parallelogramPoints); Bitmap bmp = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(bmp); graphics.Clear(System.Drawing.Color.White); DrawLoopsOnGraphics(graphics, roomLoops.GetGraphicsPathLines(), transform); if (null != familyInstances) { List <Point[]> loops = new List <Point[]>(1); loops.Add(new Point[] { }); foreach (JtPlacement2dInt i in familyInstances) { Point2dInt v = i.Translation; Matrix placement = new Matrix(); placement.Rotate(i.Rotation); placement.Translate(v.X, v.Y, MatrixOrder.Append); placement.Multiply(transform, MatrixOrder.Append); loops[0] = geometryLoops[i.SymbolId] .GetGraphicsPathLines(); DrawLoopsOnGraphics(graphics, loops, placement); } } return(bmp); }