Example #1
0
        public void CreateBox(DbElement owner, IfcObjectGeometryData primitive)
        {
            DbElement dbElement = owner.Create(0, (DbElementType)DbElementTypeInstance.BOX);

            try
            {
                AABB     aabb   = new AABB(primitive.StartPointTS, primitive.EndPointTS);
                Point    point  = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z);
                Position pos    = Position.Create(point.X, point.Y, point.Z);
                Vector   xdirTs = primitive.XDirTS;
                xdirTs.Normalize();
                Vector ydirTs = primitive.YDirTS;
                ydirTs.Normalize();
                Orientation orientation = Tools.CreateOrientation(xdirTs, ydirTs);
                Tools.CreatePosOri(dbElement, pos, orientation);
                double num1 = Math.Round(primitive.XDimension, 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.XLEN, num1);
                double num2 = Math.Round(primitive.YDimension, 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.YLEN, num2);
                double num3 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.ZLEN, num3);
            }
            catch
            {
                dbElement.Delete();
            }
        }
Example #2
0
        public void CreateCylinder(DbElement owner, IfcObjectGeometryData primitive)
        {
            DbElement element = owner.Create(0, (DbElementType)DbElementTypeInstance.CYLINDER);

            try
            {
                Position    position1        = Tools.GetPosition("POS WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner);
                Orientation orientation1     = Tools.GetOrientation("ORI WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner);
                Direction   direction1       = orientation1.XDir();
                Direction   direction2       = orientation1.YDir();
                Matrix      coordinateSystem = MatrixFactory.ToCoordinateSystem(new CoordinateSystem(new Point(position1.get_X(), position1.get_Y(), position1.get_Z()), new Vector(direction1.get_East(), direction1.get_North(), direction1.get_Up()), new Vector(direction2.get_East(), direction2.get_North(), direction2.get_Up())));
                double      num1             = Math.Max(primitive.XDimension, primitive.YDimension);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.DIAM, num1);
                Point startPointTs = primitive.StartPointTS;
                Point endPointTs   = primitive.EndPointTS;
                new Vector(endPointTs - startPointTs).Normalize();
                AABB        aabb         = new AABB(startPointTs, endPointTs);
                Point       p            = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z);
                Point       point1       = coordinateSystem.Transform(startPointTs);
                Point       point2       = coordinateSystem.Transform(endPointTs);
                Point       point3       = coordinateSystem.Transform(p);
                Orientation orientation2 = Orientation.Create("Z  IS " + ((object)Direction.Create(Position.Create(point1.X, point1.Y, point1.Z), Position.Create(point2.X, point2.Y, point2.Z))).ToString());
                Position    position2    = Position.Create(
                    .X, point3.Y, point3.Z);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, position2);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.ORI, orientation2);
                double num2 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.HEIG, num2);
            }
            catch
            {
                element.Delete();
            }
        }
Example #3
0
        public void CreateExtrusion(DbElement owner, IfcObjectGeometryData primitive, bool chamfers)
        {
            DbElement dbElement1 = owner.Create(0, (DbElementType)DbElementTypeInstance.EXTRUSION);

            try
            {
                Vector xdirTs = primitive.XDirTS;
                xdirTs.Normalize();
                Vector ydirTs = primitive.YDirTS;
                ydirTs.Normalize();
                CoordinateSystem CoordSys    = new CoordinateSystem(primitive.PolygonPointsTS[0], xdirTs, ydirTs);
                Matrix           matrix      = MatrixFactory.ToCoordinateSystem(CoordSys);
                Orientation      orientation = Tools.CreateOrientation(xdirTs, ydirTs);
                Position         pos         = Position.Create(CoordSys.Origin.X, CoordSys.Origin.Y, CoordSys.Origin.Z);
                Tools.CreatePosOri(dbElement1, pos, orientation);
                double num1 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(dbElement1, (DbAttribute)DbAttributeInstance.HEIG, num1);
                DbElement     dbElement2 = dbElement1.Create(0, (DbElementType)DbElementTypeInstance.LOOP);
                int           index      = 0;
                List <Point>  points;
                List <double> chamfers1;
                new PolygonCreator().GetPolygonPointsArcMiddelePoint(primitive, out points, out chamfers1);
                List <Point> list = points.Select <Point, Point>((Func <Point, Point>)(p => matrix.Transform(p))).ToList <Point>();
                Tools.CleanPolygonImport(ref chamfers1, ref list);
                foreach (Point point in list)
                {
                    DbElement element = dbElement2.Create(0, (DbElementType)DbElementTypeInstance.VERTEX);
                    Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, Position.Create(point.X, point.Y, point.Z));
                    double num2 = chamfers ? Math.Floor(chamfers1[index]) : 0.0;
                    Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.FRAD, num2);
                    ++index;
                }
            }
            catch
            {
                dbElement1.Delete();
            }
        }