Esempio n. 1
0
		public IfcBoundingBox(IfcCartesianPoint pt, double xdim, double ydim, double zdim) : base(pt.mDatabase)
		{
			mCorner = pt;
			mXDim = xdim;
			mYDim = ydim;
			mZDim = zdim;
		}
Esempio n. 2
0
        internal override void parseJObject(JObject obj)
        {
            base.parseJObject(obj);
            IfcCartesianPoint cp = Location;

            if (cp != null)
            {
                cp.Coordinates = cp.Coordinates;                 // Force 3d
            }
            IfcDirection dir = mDatabase.parseJObject <IfcDirection>(obj.GetValue("Axis", StringComparison.InvariantCultureIgnoreCase) as JObject);

            if (dir != null)
            {
                mAxis = dir.mIndex;
                dir.DirectionRatioY = dir.DirectionRatioY;
                dir.DirectionRatioZ = dir.DirectionRatioZ;
            }
            dir = mDatabase.parseJObject <IfcDirection>(obj.GetValue("RefDirection", StringComparison.InvariantCultureIgnoreCase) as JObject);
            if (dir != null)
            {
                mRefDirection       = dir.mIndex;
                dir.DirectionRatioY = dir.DirectionRatioY;
                dir.DirectionRatioZ = dir.DirectionRatioZ;
            }
        }
        public Transform Transform()
        {
            IfcCartesianPoint cp = LocalOrigin;
            Point3d           p  = (cp == null ? Point3d.Origin : cp.Location);

            return(Rhino.Geometry.Transform.Translation(p.X, p.Y, p.Z) * vecsTransform() * getScaleTransform(p));
        }
Esempio n. 4
0
 internal IfcAxis2Placement2D(DatabaseIfc db, Point2d position, Vector2d dir) : base(db)
 {
     Location = new IfcCartesianPoint(db, position);
     if (dir.Length > 0 && new Vector3d(dir.X, dir.Y, 0).IsParallelTo(Vector3d.XAxis, Math.PI / 1800) != 1)
     {
         RefDirection = new IfcDirection(db, dir);
     }
 }
 internal IfcClothoidalArcSegment2D(IfcCartesianPoint start, double startDirection, double length, double radius, bool isCCW, bool isEntry, double clothoidConstant)
     : base(start, startDirection, length)
 {
     mStartRadius      = radius;
     mIsCCW            = isCCW;
     mIsEntry          = isEntry;
     mClothoidConstant = clothoidConstant;
 }
 public IfcTrimmedCurve(IfcCartesianPoint s, IfcCartesianPoint e) : base(s.mDatabase)
 {
     BasisCurve            = new IfcLine(s, new IfcVector(s.mDatabase, e.Location - s.Location));
     mTrim1                = new IfcTrimmingSelect(s);
     mTrim2                = new IfcTrimmingSelect(e);
     mMasterRepresentation = IfcTrimmingPreference.CARTESIAN;
     mSenseAgreement       = true;
 }
Esempio n. 7
0
 public IfcBoundingBox(IfcCartesianPoint pt, double xdim, double ydim, double zdim) : base(pt.mDatabase)
 {
     //if (mModel.mModelView != ModelView.NotAssigned && mModel.mModelView != ModelView.IFC2x3Coordination)
     //	throw new Exception("Invalid Model View for IfcBoundingBox : " + m.ModelView.ToString());
     mCorner = pt.mIndex;
     mXDim   = xdim;
     mYDim   = ydim;
     mZDim   = zdim;
 }
Esempio n. 8
0
        internal IfcCompositeCurve(DatabaseIfc db, PolyCurve plc, bool twoD) : base(db)
        {
            mSegments = new List <int>(plc.SegmentCount);
            IfcCartesianPoint curr = null;

            for (int icounter = 0; icounter < plc.SegmentCount; icounter++)
            {
                mSegments.Add(new IfcCompositeCurveSegment(db, plc.SegmentCurve(icounter), true, IfcTransitionCode.CONTINUOUS, twoD, curr, out curr).mIndex);
            }
        }
Esempio n. 9
0
        public Transform Transform()
        {
            IfcCartesianPoint cp          = LocalOrigin;
            Point3d           p           = (cp == null ? Point3d.Origin : cp.Location);
            Transform         translation = Rhino.Geometry.Transform.Translation(p.X, p.Y, p.Z);
            Transform         changeBasis = vecsTransform();
            Transform         scale       = getScaleTransform();

            return(translation * changeBasis * scale);
        }
Esempio n. 10
0
        internal void initGeom()
        {
            IfcCartesianPoint point     = Origin;
            IfcDirection      direction = XAxis;

            direction = YAxis;
            direction = ZAxis;
            IfcAxis2Placement   pl        = this.WorldCoordinatePlacement;
            IfcAxis2Placement2D placement = Origin2dPlace;
        }
Esempio n. 11
0
 public IfcTrimmedCurve(IfcCartesianPoint s, IfcCartesianPoint e)
     : base(s.mDatabase)
 {
     IfcLine il = new IfcLine(s, new IfcVector(s.mDatabase,e.Location- s.Location));
     mBasisCurve = il.mIndex;
     mTrim1 = new IfcTrimmingSelect(s);
     mTrim2 = new IfcTrimmingSelect(e);
     mMasterRepresentation = IfcTrimmingPreference.CARTESIAN;
     mSenseAgreement = true;
 }
Esempio n. 12
0
 internal IfcFillAreaStyleHatching(DatabaseIfc db, IfcFillAreaStyleHatching h) : base(db, h)
 {
     mHatchLineAppearance  = db.Factory.Duplicate(h.HatchLineAppearance).mIndex;
     mStartOfNextHatchLine = h.mStartOfNextHatchLine;
     if (h.mPointOfReferenceHatchLine > 0)
     {
         mPointOfReferenceHatchLine = db.Factory.Duplicate(h.mDatabase[h.mPointOfReferenceHatchLine]).mIndex;
     }
     if (h.mPatternStart > 0)
     {
         PatternStart = db.Factory.Duplicate(h.PatternStart) as IfcCartesianPoint;
     }
     mHatchLineAngle = h.mHatchLineAngle;
 }
Esempio n. 13
0
        public IfcAxis2Placement3D(DatabaseIfc db, Plane plane) : base(db)
        {
            Location = new IfcCartesianPoint(db, plane.Origin);
            double angTol = Math.PI / 1800;

            if (plane.ZAxis.IsParallelTo(Vector3d.ZAxis, angTol) != 1)
            {
                Axis         = IfcDirection.convert(db, plane.ZAxis);
                RefDirection = IfcDirection.convert(db, plane.XAxis);
            }
            else if (plane.XAxis.IsParallelTo(Vector3d.XAxis, angTol) != 1)
            {
                RefDirection = IfcDirection.convert(db, plane.XAxis);
                Axis         = db.Factory.ZAxis;
            }
        }
 internal IfcPolyline(DatabaseIfc db, Polyline pl) : base(db)
 {
     if (pl.IsClosed)
     {
         int ilast            = pl.Count - 1;
         IfcCartesianPoint cp = new IfcCartesianPoint(db, pl[0]);
         Points.Add(cp);
         for (int icounter = 1; icounter < ilast; icounter++)
         {
             Points.Add(new IfcCartesianPoint(db, pl[icounter]));
         }
         Points.Add(cp);
     }
     else
     {
         Points = new STEP.LIST <IfcCartesianPoint>(pl.ConvertAll(x => new IfcCartesianPoint(db, x)));
     }
 }
Esempio n. 15
0
 internal override void ParseXml(XmlElement xml)
 {
     base.ParseXml(xml);
     foreach (XmlNode child in xml.ChildNodes)
     {
         string name = child.Name;
         if (string.Compare(name, "Polygon") == 0)
         {
             foreach (XmlNode cn in child.ChildNodes)
             {
                 IfcCartesianPoint p = mDatabase.ParseXml <IfcCartesianPoint>(cn as XmlElement);
                 if (p != null)
                 {
                     mPolygon.Add(p);
                 }
             }
         }
     }
 }
        internal IfcTrimmedCurve(DatabaseIfc db, Arc a, bool twoD, IfcCartesianPoint optStrt, out IfcCartesianPoint end) : base(db)
        {
            Point3d  o = a.Plane.Origin, s = a.StartPoint, e = a.EndPoint;
            Vector3d x = s - o;

            mSenseAgreement = true;
            if (optStrt == null)
            {
                optStrt = twoD ? new IfcCartesianPoint(db, new Point2d(s.X, s.Y)) : new IfcCartesianPoint(db, s);
            }
            end = twoD ? new IfcCartesianPoint(db, new Point2d(e.X, e.Y)) : new IfcCartesianPoint(db, e);
            double angleFactor = mDatabase.mContext.UnitsInContext.getScaleSI(IfcUnitEnum.PLANEANGLEUNIT);

            if (twoD)
            {
                if (a.Plane.ZAxis.Z < 0)
                {
                    mSenseAgreement = false;
                    x = e - o;
                    IfcAxis2Placement2D ap = new IfcAxis2Placement2D(db, new Point2d(o.X, o.Y), new Vector2d(x.X, x.Y));
                    BasisCurve = new IfcCircle(ap, a.Radius);
                    mTrim1     = new IfcTrimmingSelect(a.Angle / angleFactor, optStrt);
                    mTrim2     = new IfcTrimmingSelect(0, end);
                }
                else
                {
                    IfcAxis2Placement2D ap = new IfcAxis2Placement2D(db, new Point2d(o.X, o.Y), new Vector2d(x.X, x.Y));
                    BasisCurve = new IfcCircle(ap, a.Radius);
                    mTrim1     = new IfcTrimmingSelect(0, optStrt);
                    mTrim2     = new IfcTrimmingSelect(a.Angle / angleFactor, end);
                }
            }
            else
            {
                Vector3d            y  = Vector3d.CrossProduct(a.Plane.ZAxis, x);
                Plane               pl = new Plane(o, x, y);
                IfcAxis2Placement3D ap = new IfcAxis2Placement3D(db, pl);
                BasisCurve = new IfcCircle(ap, a.Radius);
                mTrim1     = new IfcTrimmingSelect(0, optStrt);
                mTrim2     = new IfcTrimmingSelect(a.Angle / angleFactor, end);
            }
            mMasterRepresentation = IfcTrimmingPreference.PARAMETER;
        }
Esempio n. 17
0
 internal IfcPolyline(DatabaseIfc db, Polyline pl) : base(db)
 {
     if (pl.IsClosed)
     {
         int ilast            = pl.Count - 1;
         IfcCartesianPoint cp = new IfcCartesianPoint(db, pl[0]);
         addPoint(cp);
         for (int icounter = 1; icounter < ilast; icounter++)
         {
             addPoint(new IfcCartesianPoint(db, pl[icounter]));
         }
         addPoint(cp);
     }
     else
     {
         for (int icounter = 0; icounter < pl.Count; icounter++)
         {
             addPoint(new IfcCartesianPoint(db, pl[icounter]));
         }
     }
 }
Esempio n. 18
0
 internal override void ParseXml(XmlElement xml)
 {
     base.ParseXml(xml);
     foreach (XmlNode child in xml.ChildNodes)
     {
         string name = child.Name;
         if (string.Compare(name, "Points") == 0)
         {
             List <IfcCartesianPoint> points = new List <IfcCartesianPoint>(child.ChildNodes.Count);
             foreach (XmlNode cn in child.ChildNodes)
             {
                 IfcCartesianPoint p = mDatabase.ParseXml <IfcCartesianPoint>(cn as XmlElement);
                 if (p != null)
                 {
                     points.Add(p);
                 }
             }
             Points = points;
         }
     }
 }
Esempio n. 19
0
 internal IfcTrimmedCurve(DatabaseIfc db, Arc a, bool twoD, IfcCartesianPoint optStrt, out IfcCartesianPoint end)
     : base(db)
 {
     Point3d o = a.Plane.Origin, s = a.StartPoint, e = a.EndPoint;
     Vector3d x = s - o;
     mSenseAgreement = true;
     if (optStrt == null)
         optStrt = twoD ? new IfcCartesianPoint(db, new Point2d(s.X, s.Y)) : new IfcCartesianPoint(db, s);
     end = twoD ? new IfcCartesianPoint(db, new Point2d(e.X, e.Y)) : new IfcCartesianPoint(db,e);
     double angleFactor = mDatabase.mContext.UnitsInContext.getScaleSI(IfcUnitEnum.PLANEANGLEUNIT);
     if (twoD)
     {
         if (a.Plane.ZAxis.Z < 0)
         {
             mSenseAgreement = false;
             x = e - o;
             IfcAxis2Placement2D ap = new IfcAxis2Placement2D(db, new Point2d(o.X, o.Y), new Vector2d(x.X, x.Y));
             BasisCurve = new IfcCircle(ap, a.Radius);
             mTrim1 = new IfcTrimmingSelect(a.Angle / angleFactor, optStrt);
             mTrim2 = new IfcTrimmingSelect(0, end);
         }
         else
         {
             IfcAxis2Placement2D ap = new IfcAxis2Placement2D(db, new Point2d(o.X, o.Y), new Vector2d(x.X, x.Y));
             BasisCurve = new IfcCircle(ap, a.Radius);
             mTrim1 = new IfcTrimmingSelect(0, optStrt);
             mTrim2 = new IfcTrimmingSelect(a.Angle / angleFactor, end);
         }
     }
     else
     {
         Vector3d y = Vector3d.CrossProduct(a.Plane.ZAxis, x);
         Plane pl = new Plane(o, x, y);
         IfcAxis2Placement3D ap = new IfcAxis2Placement3D(db, pl);
         BasisCurve = new IfcCircle(ap, a.Radius);
         mTrim1 = new IfcTrimmingSelect(0, optStrt);
         mTrim2 = new IfcTrimmingSelect(a.Angle / angleFactor, end);
     }
     mMasterRepresentation = IfcTrimmingPreference.PARAMETER;
 }
Esempio n. 20
0
        internal static IfcTrimmingSelect Parse(XmlElement xml, DatabaseIfc db)
        {
            IfcTrimmingSelect result = new IfcTrimmingSelect();

            foreach (XmlNode child in xml.ChildNodes)
            {
                string name = child.Name;
                if (string.Compare(name, "IfcParameterValue-wrapper") == 0)
                {
                    result.mIfcParameterValue = double.Parse(child.InnerText);
                }
                else if (string.Compare(name, "IfcCartesianPoint") == 0)
                {
                    IfcCartesianPoint p = db.ParseXml <IfcCartesianPoint>(child as XmlElement);
                    if (p != null)
                    {
                        result.mIfcCartesianPoint = p.mIndex;
                    }
                }
            }
            return(result);
        }
Esempio n. 21
0
		internal IfcTrimmingSelect(IfcCartesianPoint cp)
		{
			mIfcParameterValue = double.NaN;
			mIfcCartesianPoint = 0;
			if (cp != null)
				mIfcCartesianPoint = cp.mIndex;
		}
Esempio n. 22
0
 internal IfcGradientCurve(DatabaseIfc db, IfcGradientCurve c, DuplicateOptions options) : base(db, c, options)
 {
     mBaseCurve = db.Factory.Duplicate(c.mBaseCurve) as IfcBoundedCurve;
     Segments.AddRange(c.Segments.ConvertAll(x => db.Factory.Duplicate(x) as IfcCurveSegment));
     mEndPoint = db.Factory.Duplicate(c.mEndPoint) as IfcCartesianPoint;
 }
Esempio n. 23
0
 internal IfcCircularArcSegment2D(IfcCartesianPoint start, double startDirection, double length, double radius, bool isCCW)
     : base(start, startDirection, length)
 {
     mRadius = radius;
     mIsCCW  = isCCW;
 }
Esempio n. 24
0
 internal IfcLineSegment2D(IfcCartesianPoint start, double startDirection, double length)
     : base(start, startDirection, length)
 {
 }
Esempio n. 25
0
 internal IfcClothoidalArcSegment2D(IfcCartesianPoint start, double startDirection, double length, double radius, bool isCCW, bool isEntry, double clothoidConstant)
     : base(start, startDirection, length)
 {
     mStartRadius = radius;
     mIsCCW = isCCW;
     mIsEntry = isEntry;
     mClothoidConstant = clothoidConstant;
 }
Esempio n. 26
0
 protected IfcPlacement(DatabaseIfc db, Point2D position) : base(db)
 {
     Location = new IfcCartesianPoint(db, position);
 }
Esempio n. 27
0
 internal IfcCompositeCurveSegment(DatabaseIfc db, Curve c, bool sense, IfcTransitionCode tc, bool twoD, IfcCartesianPoint optStrt, out IfcCartesianPoint end)
     : this(tc, sense, IfcBoundedCurve.convCurve(db, c, optStrt, twoD, out end))
 {
 }
Esempio n. 28
0
		public IfcAxis2Placement2D(IfcCartesianPoint location) : base(location) { }
Esempio n. 29
0
		public IfcAxis2Placement3D(IfcCartesianPoint p, IfcDirection axis, IfcDirection refDirection) : base(p) { mAxis = (axis == null ? 0 : axis.mIndex); mRefDirection = (refDirection == null ? 0 : refDirection.mIndex); }
Esempio n. 30
0
 protected IfcPlacement(DatabaseIfc db, Point3d position)
     : base(db)
 {
     Location = new IfcCartesianPoint(db, position);
 }
Esempio n. 31
0
		public IfcAxis2Placement3D(IfcCartesianPoint p) : base(p) { }
Esempio n. 32
0
		public IfcAxis2Placement2D(IfcCartesianPoint point) : base(point) { }
Esempio n. 33
0
		protected IfcElement(IfcProduct host, IfcMaterialProfileSetUsage profile, IfcAxis2Placement3D placement, double length) : base(host,new IfcLocalPlacement(host.Placement,placement), null)
		{
			List<IfcShapeModel> reps = new List<IfcShapeModel>();
			IfcCartesianPoint cp = new IfcCartesianPoint(mDatabase, 0, 0, length);
			IfcPolyline ipl = new IfcPolyline(mDatabase.Factory.Origin, cp);
			reps.Add(IfcShapeRepresentation.GetAxisRep(ipl));
			
			profile.Associates.addAssociation(this);

			IfcMaterialProfileSet ps = profile.ForProfileSet;
			IfcMaterialProfileSetUsageTapering psut = profile as IfcMaterialProfileSetUsageTapering;
			if (psut != null)
				throw new Exception("Tapering Elements not implemented yet!");
			IfcProfileDef pd = null;
			if (ps.mCompositeProfile > 0)
				pd = ps.CompositeProfile;
			else
			{
				if (ps.mMaterialProfiles.Count > 0)
					pd = ps.MaterialProfiles[0].Profile;
				else
					throw new Exception("Profile not provided");
			}
			if (pd != null)
				reps.Add(new IfcShapeRepresentation( new IfcExtrudedAreaSolid(pd, pd.CalculateTransform(profile.CardinalPoint), length))); 
			
			Representation = new IfcProductDefinitionShape(reps);
		
		}
Esempio n. 34
0
		public IfcPolyline(IfcCartesianPoint start, IfcCartesianPoint end) : base(start.mDatabase) { mPoints.Add(start.mIndex); mPoints.Add(end.mIndex); }
Esempio n. 35
0
        internal int mPnt; // : IfcCartesianPoint;

        #endregion Fields

        #region Constructors

        public IfcLine(IfcCartesianPoint point, IfcVector dir)
            : base(point.mDatabase)
        {
            Pnt = point; Dir = dir;
        }
Esempio n. 36
0
		internal static void parseFields(IfcCartesianPoint p, List<string> arrFields, ref int ipos)
		{
			IfcPoint.parseFields(p, arrFields, ref ipos);
			string s = arrFields[ipos++];
			if (s != "$")
			{
				List<string> arrCoords = ParserSTEP.SplitLineFields(s.Substring(1, s.Length - 2));
				int count = arrCoords.Count;
				if (count > 0)
				{
					p.mCoordinateX = ParserSTEP.ParseDouble(arrCoords[0]);
					if (count > 1)
					{
						p.mCoordinateY = ParserSTEP.ParseDouble(arrCoords[1]);
						p.mCoordinateZ = (count > 2 ? ParserSTEP.ParseDouble(arrCoords[2]) : double.NaN);
					}
				}
			}
		}
Esempio n. 37
0
 internal IfcCompositeCurveSegment(DatabaseIfc db, Curve c, bool sense, IfcTransitionCode tc, bool twoD, IfcCartesianPoint optStrt, out IfcCartesianPoint end)
     : this(tc, sense, IfcBoundedCurve.convCurve(db, c, optStrt, twoD, out end))
 {
 }
Esempio n. 38
0
		public IfcAxis1Placement(IfcCartesianPoint location, IfcDirection axis) : base(location) { Axis = axis; }
Esempio n. 39
0
		internal static IfcCartesianPoint Parse(string str)
		{
			IfcCartesianPoint p = new IfcCartesianPoint();
			if (str[0] == '(')
			{
				int pos = 1;
				string val = ParserSTEP.StripField(str, ref pos);

				if (!string.IsNullOrEmpty(val))
					p.mCoordinateX = ParserSTEP.ParseDouble(val);
				val = ParserSTEP.StripField(str, ref pos);
				if (!string.IsNullOrEmpty(val))
					p.mCoordinateY = ParserSTEP.ParseDouble(val);
				if (pos >= str.Length)
					p.mCoordinateZ = double.NaN;
				else
				{
					val = str.Substring(pos, str.Length - pos - 1);// ParserSTEP.StripField(str.Substring(ref pos);
					p.mCoordinateZ = (string.IsNullOrEmpty(val) ? double.NaN : ParserSTEP.ParseDouble(val));
				}
			}
			return p;
		}
Esempio n. 40
0
		internal IfcBoundingBox(IfcCartesianPoint pt, double xdim, double ydim, double zdim) : base(pt.mDatabase)
		{
			//if (mModel.mModelView != ModelView.NotAssigned && mModel.mModelView != ModelView.IFC2x3Coordination)
			//	throw new Exception("Invalid Model View for IfcBoundingBox : " + m.ModelView.ToString());
			mCorner = pt.mIndex;
			mXDim = xdim;
			mYDim = ydim;
			mZDim = zdim;
		}
Esempio n. 41
0
		protected IfcCartesianTransformationOperator(DatabaseIfc db, IfcDirection ax1, IfcDirection ax2, IfcCartesianPoint o, double scale)
			: base(db) { if (ax1 != null) mAxis1 = ax1.mIndex; if (ax2 != null) mAxis2 = ax2.mIndex; mLocalOrigin = o.mIndex; mScale = scale; }
Esempio n. 42
0
 internal IfcCircularArcSegment2D(IfcCartesianPoint start, double startDirection, double length, double radius, bool isCCW)
     : base(start, startDirection, length)
 {
     mRadius = radius;
     mIsCCW = isCCW;
 }
        public T ParseJObject <T>(JObject obj) where T : IBaseClassIfc
        {
            if (obj == null)
            {
                return(default(T));
            }

            BaseClassIfc result = null;
            JToken       token  = obj.GetValue("href", StringComparison.InvariantCultureIgnoreCase);

            if (token != null)
            {
                if (token.Type == JTokenType.Integer)
                {
                    int index = token.Value <int>();
                    result = this[index];
                }
                else if (token.Type == JTokenType.String)
                {
                    mDictionary.TryGetValue(token.Value <string>(), out result);
                }
                if (result != null && obj.Count == 1)
                {
                    return((T)(IBaseClassIfc)result);
                }
            }
            if (result == null)
            {
                Type type = null;
                token = obj.GetValue("type", StringComparison.InvariantCultureIgnoreCase);
                if (token != null)
                {
                    string keyword = token.Value <string>();
                    type = Type.GetType("GeometryGym.Ifc." + keyword, false, true);
                }
                if (token == null)
                {
                    type = typeof(T);
                }
                if (type != null && !type.IsAbstract)
                {
                    ConstructorInfo constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                                                                      null, Type.EmptyTypes, null);
                    if (constructor != null)
                    {
                        result = constructor.Invoke(new object[] { }) as BaseClassIfc;
                        if (result != null)
                        {
                            result.mDatabase = this;
                            token            = obj.GetValue("id", StringComparison.InvariantCultureIgnoreCase);
                            int index = 0;                            // (int) (this.mIfcObjects.Count * 1.2);
                            if (token != null)
                            {
                                if (token.Type == JTokenType.Integer)
                                {
                                    try
                                    {
                                        int i = token.Value <int>();
                                        if (this[i] == null)
                                        {
                                            index = i;
                                        }
                                    }
                                    catch (Exception) { }
                                    // TODO merge if existing equivalent
                                }
                                else if (token.Type == JTokenType.String)
                                {
                                    result.mGlobalId = token.Value <string>();
                                    mDictionary.TryAdd(result.mGlobalId, result);
                                }
                            }
                            IfcCartesianPoint   point     = result as IfcCartesianPoint;
                            IfcDirection        direction = result as IfcDirection;
                            IfcAxis2Placement3D placement = result as IfcAxis2Placement3D;
                            if (index == 0)
                            {
                                if (point != null)
                                {
                                    point.parseJObject(obj);
                                    if (point.isOrigin)
                                    {
                                        if (point.is2D)
                                        {
                                            return((T)(IBaseClassIfc)Factory.Origin2d);
                                        }
                                        return((T)(IBaseClassIfc)Factory.Origin);
                                    }
                                }
                                else
                                {
                                    if (direction != null)
                                    {
                                        direction.parseJObject(obj);
                                        if (!direction.is2D)
                                        {
                                            if (direction.isXAxis)
                                            {
                                                return((T)(IBaseClassIfc)Factory.XAxis);
                                            }
                                            if (direction.isYAxis)
                                            {
                                                return((T)(IBaseClassIfc)Factory.YAxis);
                                            }
                                            if (direction.isZAxis)
                                            {
                                                return((T)(IBaseClassIfc)Factory.ZAxis);
                                            }
                                            if (direction.isXAxisNegative)
                                            {
                                                return((T)(IBaseClassIfc)Factory.XAxisNegative);
                                            }
                                            if (direction.isYAxisNegative)
                                            {
                                                return((T)(IBaseClassIfc)Factory.YAxisNegative);
                                            }
                                            if (direction.isZAxisNegative)
                                            {
                                                return((T)(IBaseClassIfc)Factory.ZAxisNegative);
                                            }
                                        }
                                    }
                                    if (placement != null)
                                    {
                                        placement.parseJObject(obj);
                                        if (placement.IsXYPlane)
                                        {
                                            return((T)(IBaseClassIfc)Factory.XYPlanePlacement);
                                        }
                                    }
                                }

                                index       = NextBlank();
                                this[index] = result;

                                if (point != null || direction != null || placement != null)
                                {
                                    return((T)(IBaseClassIfc)result);
                                }
                            }
                            else
                            {
                                this[index] = result;
                            }
                        }
                    }
                }
            }
            if (result == null)
            {
                return(default(T));
            }
            result.parseJObject(obj);
            parseBespoke(result, obj);
            return((T)(IBaseClassIfc)result);
        }
Esempio n. 44
0
 protected IfcCurveSegment2D(IfcCartesianPoint start, double startDirection, double length)
     : base(start.mDatabase)
 {
     mStartDirection = startDirection;
     mSegmentLength = length;
 }
Esempio n. 45
0
 protected IfcCurveSegment2D(DatabaseIfc db, IfcCurveSegment2D p) : base(db, p)
 {
     StartPoint = db.Factory.Duplicate(p.StartPoint) as IfcCartesianPoint; mStartDirection = p.mStartDirection; mSegmentLength = p.mSegmentLength;
 }
Esempio n. 46
0
        public T ParseJObject <T>(JObject obj) where T : IBaseClassIfc
        {
            if (obj == null)
            {
                return(default(T));
            }

            BaseClassIfc result = null;
            JToken       token  = obj.GetValue("href", StringComparison.InvariantCultureIgnoreCase);

            if (token != null)
            {
                mDictionary.TryGetValue(token.Value <string>(), out result);
                if (result != null && obj.Count == 1)
                {
                    return((T)(IBaseClassIfc)result);
                }
            }
            if (result == null)
            {
                Type type = null;
                token = obj.GetValue("type", StringComparison.InvariantCultureIgnoreCase);
                if (token != null)
                {
                    string keyword = token.Value <string>();
                    type = Type.GetType("GeometryGym.Ifc." + keyword, false, true);
                }
                if (token == null)
                {
                    type = typeof(T);
                }
                if (type != null)
                {
                    if (type.IsAbstract)
                    {
                        JProperty jtoken    = (JProperty)obj.First;
                        Type      valueType = Type.GetType("GeometryGym.Ifc." + jtoken.Name, false, true);
                        if (valueType != null && valueType.IsSubclassOf(typeof(IfcValue)))
                        {
                            return((T)(IBaseClassIfc)ParserIfc.extractValue(jtoken.Name, jtoken.Value.ToString()));
                        }
                    }
                    else
                    {
                        ConstructorInfo constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                                                                          null, Type.EmptyTypes, null);
                        if (constructor != null)
                        {
                            bool common = false;
                            result = constructor.Invoke(new object[] { }) as BaseClassIfc;
                            if (result != null)
                            {
                                result.mDatabase = this;

                                IfcCartesianPoint point = result as IfcCartesianPoint;
                                if (point != null)
                                {
                                    point.parseJObject(obj);
                                    if (point.isOrigin)
                                    {
                                        if (point.is2D)
                                        {
                                            result = Factory.Origin2d;
                                        }
                                        else
                                        {
                                            result = Factory.Origin;
                                        }
                                        common = true;
                                    }
                                }
                                else
                                {
                                    IfcDirection direction = result as IfcDirection;
                                    if (direction != null)
                                    {
                                        direction.parseJObject(obj);
                                        if (!direction.is2D)
                                        {
                                            common = true;
                                            if (direction.isXAxis)
                                            {
                                                result = Factory.XAxis;
                                            }
                                            else if (direction.isYAxis)
                                            {
                                                result = Factory.YAxis;
                                            }
                                            else if (direction.isZAxis)
                                            {
                                                result = Factory.ZAxis;
                                            }
                                            else if (direction.isXAxisNegative)
                                            {
                                                result = Factory.XAxisNegative;
                                            }
                                            else if (direction.isYAxisNegative)
                                            {
                                                result = Factory.YAxisNegative;
                                            }
                                            else if (direction.isZAxisNegative)
                                            {
                                                result = Factory.ZAxisNegative;
                                            }
                                            else
                                            {
                                                common = false;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        IfcAxis2Placement3D placement = result as IfcAxis2Placement3D;
                                        if (placement != null)
                                        {
                                            placement.parseJObject(obj);
                                            if (placement.IsXYPlane)
                                            {
                                                result = Factory.XYPlanePlacement;
                                                common = true;
                                            }
                                        }
                                    }
                                }
                                token = obj.GetValue("id", StringComparison.InvariantCultureIgnoreCase);
                                if (token != null)
                                {
                                    string id = token.Value <string>();
                                    if (!(result is IfcRoot))
                                    {
                                        result.mGlobalId = id;
                                    }
                                    mDictionary.TryAdd(id, result);
                                }

                                if (common)
                                {
                                    return((T)(IBaseClassIfc)result);
                                }

                                int index = NextBlank();
                                this[index] = result;
                            }
                        }
                    }
                }
            }
            if (result == null)
            {
                return(default(T));
            }
            result.parseJObject(obj);
            parseBespoke(result, obj);
            IfcRoot root = result as IfcRoot;

            if (root != null)
            {
                mDictionary[root.GlobalId] = root;
            }
            return((T)(IBaseClassIfc)result);
        }
Esempio n. 47
0
 internal IfcLineSegment2D(IfcCartesianPoint start, double startDirection, double length)
     : base(start, startDirection, length)
 {
 }
Esempio n. 48
0
 private static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, bool twoD)
 {
     IfcCartesianPoint e = null; return(convCurve(db, crv, null, twoD, out e));
 }
Esempio n. 49
0
		public IfcPolyloop(IfcCartesianPoint cp1, IfcCartesianPoint cp2, IfcCartesianPoint cp3) : base(cp1.mDatabase) { mPolygon = new List<int>() { cp1.mIndex, cp2.mIndex, cp3.mIndex }; }
Esempio n. 50
0
 protected IfcCurveSegment2D(IfcCartesianPoint start, double startDirection, double length)
     : base(start.mDatabase)
 {
     mStartDirection = startDirection;
     mSegmentLength  = length;
 }
Esempio n. 51
0
        internal static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, IfcCartesianPoint optStrt, bool twoD, out IfcCartesianPoint end)
        {
            double tol = db.Tolerance;

            end = null;
            Curve c = crv.DuplicateCurve();

            if (c.IsLinear(tol))
            {
                if (twoD)
                {
                    end = new IfcCartesianPoint(db, new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                }
                else
                {
                    end = new IfcCartesianPoint(db, c.PointAtEnd);
                }
                if (optStrt == null)
                {
                    if (twoD)
                    {
                        optStrt = new IfcCartesianPoint(db, new Point2d(c.PointAtStart.X, c.PointAtStart.Y));
                    }
                    else
                    {
                        optStrt = new IfcCartesianPoint(db, c.PointAtStart);
                    }
                }
                return(new IfcPolyline(optStrt, end));
            }
            ArcCurve ac = c as ArcCurve;

            if (ac != null)
            {
                return(new IfcTrimmedCurve(db, ac.Arc, twoD, optStrt, out end));
            }
            Arc arc = Arc.Unset;

            if (c.TryGetArc(out arc, tol))
            {
                return(new IfcTrimmedCurve(db, arc, twoD, optStrt, out end));
            }

            Polyline pl = new Polyline();

            if (c.TryGetPolyline(out pl))
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    if (twoD)
                    {
                        return(new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, pl.ConvertAll(x => new Point2d(x.X, x.Y)))));
                    }
                    else
                    {
                        return(new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, pl)));
                    }
                }
                List <IfcCartesianPoint> cps = new List <IfcCartesianPoint>();
                if (twoD)
                {
                    Point2d p = new Point2d(pl[0].X, pl[0].Y), n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count - 1; icounter++)
                    {
                        n = new Point2d(pl[icounter].X, pl[icounter].Y);
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                    n = new Point2d(pl[pl.Count - 1].X, pl[pl.Count - 1].Y);
                    if (n.DistanceTo(p) > tol)
                    {
                        if (pl.IsClosed)
                        {
                            cps.Add(cps[0]);
                        }
                        else
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                        }
                    }
                }
                else
                {
                    Point3d p = pl[0], n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count; icounter++)
                    {
                        n = pl[icounter];
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                }
                return(new IfcPolyline(cps));
            }
            PolyCurve plc = c as PolyCurve;

            if (plc != null)
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    IfcIndexedPolyCurve ipc = IfcIndexedPolyCurve.Convert(db, plc, twoD);
                    if (ipc != null)
                    {
                        return(ipc);
                    }
                }
                return(new IfcCompositeCurve(db, plc, twoD));
            }
            if (db.mRelease != ReleaseVersion.IFC2x3)
            {
                NurbsCurve nc = c as NurbsCurve;
                if (nc != null)
                {
                    if (nc.IsRational)
                    {
                        return(new IfcRationalBSplineCurveWithKnots(db, nc, twoD));
                    }
                    return(new IfcBSplineCurveWithKnots(db, nc, twoD));
                }
            }

            return(null);
        }
Esempio n. 52
0
 public IfcLine(IfcCartesianPoint point, IfcVector dir) : base(point.mDatabase)
 {
     Pnt = point; Dir = dir;
 }
Esempio n. 53
0
        internal static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, IfcCartesianPoint optStrt, bool twoD, out IfcCartesianPoint end)
        {
            double tol = db.Tolerance;
            end = null;
            Curve c = crv.DuplicateCurve();
            if (c.IsLinear(tol))
            {
                if (twoD)
                    end = new IfcCartesianPoint(db, new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                else
                    end = new IfcCartesianPoint(db, c.PointAtEnd);
                if (optStrt == null)
                {
                    if (twoD)
                        optStrt = new IfcCartesianPoint(db, new Point2d(c.PointAtStart.X, c.PointAtStart.Y));
                    else
                        optStrt = new IfcCartesianPoint(db, c.PointAtStart);
                }
                return new IfcPolyline(optStrt, end);
            }
            ArcCurve ac = c as ArcCurve;
            if (ac != null)
                return new IfcTrimmedCurve(db, ac.Arc, twoD, optStrt, out end);
            Arc arc = Arc.Unset;
            if (c.TryGetArc(out arc, tol))
                return new IfcTrimmedCurve(db, arc, twoD, optStrt, out end);

            Polyline pl = new Polyline();
            if (c.TryGetPolyline(out pl))
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    if (twoD)
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, pl.ConvertAll(x => new Point2d(x.X, x.Y))));
                    else
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, pl));
                }
                List<IfcCartesianPoint> cps = new List<IfcCartesianPoint>();
                if (twoD)
                {
                    Point2d p = new Point2d(pl[0].X, pl[0].Y), n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count - 1; icounter++)
                    {
                        n = new Point2d(pl[icounter].X, pl[icounter].Y);
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                    n = new Point2d(pl[pl.Count - 1].X, pl[pl.Count - 1].Y);
                    if (n.DistanceTo(p) > tol)
                    {
                        if (pl.IsClosed)
                            cps.Add(cps[0]);
                        else
                            cps.Add(new IfcCartesianPoint(db, n));
                    }
                }
                else
                {
                    Point3d p = pl[0], n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count; icounter++)
                    {
                        n = pl[icounter];
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                }
                return new IfcPolyline(cps);
            }
            PolyCurve plc = c as PolyCurve;
            if (plc != null)
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    IfcIndexedPolyCurve ipc = IfcIndexedPolyCurve.Convert(db, plc, twoD);
                    if (ipc != null)
                        return ipc;
                }
                return new IfcCompositeCurve(db, plc, twoD);
            }
            if (db.mRelease != ReleaseVersion.IFC2x3)
            {
                NurbsCurve nc = c as NurbsCurve;
                if (nc != null)
                {
                    if (nc.IsRational)
                        return new IfcRationalBSplineCurveWithKnots(db, nc, twoD);
                    return new IfcBSplineCurveWithKnots(db, nc, twoD);
                }
            }

            return null;
        }
Esempio n. 54
0
		internal IfcCartesianPoint(IfcCartesianPoint p) : base()
		{
			mCoordinateX = p.mCoordinateX;
			mCoordinateY = p.mCoordinateY;
			mCoordinateZ = p.mCoordinateZ;
		}
Esempio n. 55
0
		protected IfcPlacement(IfcCartesianPoint p) : base(p.mDatabase) { mLocation = p.mIndex; }