Inheritance: IfcCartesianPointList
Exemplo n.º 1
0
		protected IfcTessellatedFaceSet(DatabaseIfc m, IfcCartesianPointList3D pl, IEnumerable<Tuple<double, double, double>> normals, bool closed)
			: base(m)
		{
			mCoordinates = pl.mIndex;
			if (normals != null)
				mNormals = normals.ToArray();
			mClosed = closed;
		}
Exemplo n.º 2
0
		public IfcTriangulatedFaceSet(DatabaseIfc m, IfcCartesianPointList3D pl, List<Tuple<double, double, double>> normals, bool closed, IEnumerable<Tuple<int, int, int>> coords, IEnumerable<Tuple<int, int, int>> normalIndices)
			: base(m, pl, normals, closed) { mCoordIndex = coords.ToArray(); if (normals != null) mNormalIndex = normalIndices.ToArray(); }
Exemplo n.º 3
0
		internal static IfcCartesianPointList3D Parse(string strDef)
		{
			IfcCartesianPointList3D l = new IfcCartesianPointList3D();
			l.mCoordList = ParserSTEP.SplitListDoubleTriple(strDef);
			return l;
		}
Exemplo n.º 4
0
		internal IfcCartesianPointList3D(IfcCartesianPointList3D o) : base(o) { mCoordList = o.mCoordList; }
Exemplo n.º 5
0
 internal static IfcIndexedPolyCurve Convert(DatabaseIfc db, PolyCurve polycurve, bool twoD)
 {
     double tol = db.Tolerance;
     Curve[] segments = polycurve.Explode();
     PolyCurve pc = new PolyCurve();
     foreach (Curve s in segments)
     {
         if (s.IsLinear(tol))
             pc.Append(new Line(s.PointAtStart, s.PointAtEnd));
         else
         {
             Arc a = Arc.Unset;
             if (s.TryGetArc(out a, tol))
                 pc.Append(a);
             else
                 return null;
         }
     }
     List<IfcSegmentIndexSelect> segs = new List<IfcSegmentIndexSelect>();
     IfcCartesianPointList cpl = null;
     bool closed = pc.PointAtStart.DistanceTo(pc.PointAtEnd) < tol;
     if (twoD)
     {
         Point2d pt = new Point2d(pc.PointAtStart.X, pc.PointAtStart.Y);
         int pcounter = 1;
         List<Point2d> pts = new List<Point2d>();
         pts.Add(pt);
         IfcLineIndex li = null;
         for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
         {
             Curve c = pc.SegmentCurve(icounter);
             if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                 continue;
             if (c.IsLinear(tol))
             {
                 if (closed && icounter + 1 == segments.Length)
                 {
                     if (li != null)
                         li.mIndices.Add(1);
                     else
                         li = new IfcLineIndex(pcounter, 1);
                 }
                 else
                 {
                     pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                     if (li != null)
                         li.mIndices.Add(++pcounter);
                     else
                         li = new IfcLineIndex(pcounter++, pcounter);
                 }
             }
             else
             {
                 if (li != null)
                 {
                     segs.Add(li);
                     li = null;
                 }
                 Point3d tp = c.PointAt(c.Domain.Mid);
                 pts.Add(new Point2d(tp.X, tp.Y));
                 if (closed && icounter + 1 == segments.Length)
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, 1));
                 else
                 {
                     pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                 }
             }
         }
         if (li != null)
             segs.Add(li);
         cpl = new IfcCartesianPointList2D(db, pts.ToArray());
     }
     else
     {
         Point3d pt = pc.PointAtStart;
         int pcounter = 1;
         List<Point3d> pts = new List<Point3d>();
         pts.Add(pt);
         List<IfcSegmentIndexSelect> sis = new List<IfcSegmentIndexSelect>(segments.Length);
         IfcLineIndex li = null;
         for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
         {
             Curve c = pc.SegmentCurve(icounter);
             if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                 continue;
             if (c.IsLinear(tol))
             {
                 if (closed && icounter + 1 == segments.Length)
                 {
                     if (li != null)
                         li.mIndices.Add(0);
                     else
                         li = new IfcLineIndex(pcounter, 0);
                 }
                 else
                 {
                     pts.Add(c.PointAtEnd);
                     if (li != null)
                         li.mIndices.Add(++pcounter);
                     else
                         li = new IfcLineIndex(pcounter++, pcounter);
                 }
             }
             else
             {
                 if (li != null)
                 {
                     segs.Add(li);
                     li = null;
                 }
                 pts.Add(c.PointAt(c.Domain.Mid));
                 if (closed && icounter + 1 == segments.Length)
                     segs.Add(new IfcArcIndex(pcounter++, pcounter, 0));
                 else
                 {
                     pts.Add(c.PointAtEnd);
                     segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                 }
             }
         }
         if (li != null)
             segs.Add(li);
         cpl = new IfcCartesianPointList3D(db, pts.ToArray());
     }
     return new IfcIndexedPolyCurve(cpl, segs) { };
 }
        internal static IfcIndexedPolyCurve Convert(DatabaseIfc db, PolyCurve polycurve, bool twoD)
        {
            double tol = db.Tolerance;

            Curve[]   segments = polycurve.Explode();
            PolyCurve pc       = new PolyCurve();

            foreach (Curve s in segments)
            {
                if (s.IsLinear(tol))
                {
                    pc.Append(new Line(s.PointAtStart, s.PointAtEnd));
                }
                else
                {
                    Arc a = Arc.Unset;
                    if (s.TryGetArc(out a, tol))
                    {
                        pc.Append(a);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            List <IfcSegmentIndexSelect> segs = new List <IfcSegmentIndexSelect>();
            IfcCartesianPointList        cpl  = null;
            bool closed = pc.PointAtStart.DistanceTo(pc.PointAtEnd) < tol;

            if (twoD)
            {
                Point2d        pt       = new Point2d(pc.PointAtStart.X, pc.PointAtStart.Y);
                int            pcounter = 1;
                List <Point2d> pts      = new List <Point2d>();
                pts.Add(pt);
                IfcLineIndex li = null;
                for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
                {
                    Curve c = pc.SegmentCurve(icounter);
                    if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                    {
                        continue;
                    }
                    if (c.IsLinear(tol))
                    {
                        if (closed && icounter + 1 == segments.Length)
                        {
                            if (li != null)
                            {
                                li.mIndices.Add(1);
                            }
                            else
                            {
                                li = new IfcLineIndex(pcounter, 1);
                            }
                        }
                        else
                        {
                            pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                            if (li != null)
                            {
                                li.mIndices.Add(++pcounter);
                            }
                            else
                            {
                                li = new IfcLineIndex(pcounter++, pcounter);
                            }
                        }
                    }
                    else
                    {
                        if (li != null)
                        {
                            segs.Add(li);
                            li = null;
                        }
                        Point3d tp = c.PointAt(c.Domain.Mid);
                        pts.Add(new Point2d(tp.X, tp.Y));
                        if (closed && icounter + 1 == segments.Length)
                        {
                            segs.Add(new IfcArcIndex(pcounter++, pcounter++, 1));
                        }
                        else
                        {
                            pts.Add(new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                            segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                        }
                    }
                }
                if (li != null)
                {
                    segs.Add(li);
                }
                cpl = new IfcCartesianPointList2D(db, pts.ToArray());
            }
            else
            {
                Point3d        pt       = pc.PointAtStart;
                int            pcounter = 1;
                List <Point3d> pts      = new List <Point3d>();
                pts.Add(pt);
                List <IfcSegmentIndexSelect> sis = new List <IfcSegmentIndexSelect>(segments.Length);
                IfcLineIndex li = null;
                for (int icounter = 0; icounter < pc.SegmentCount; icounter++)
                {
                    Curve c = pc.SegmentCurve(icounter);
                    if (c.IsLinear(tol) && c.PointAtStart.DistanceTo(c.PointAtEnd) < tol)
                    {
                        continue;
                    }
                    if (c.IsLinear(tol))
                    {
                        if (closed && icounter + 1 == segments.Length)
                        {
                            if (li != null)
                            {
                                li.mIndices.Add(0);
                            }
                            else
                            {
                                li = new IfcLineIndex(pcounter, 0);
                            }
                        }
                        else
                        {
                            pts.Add(c.PointAtEnd);
                            if (li != null)
                            {
                                li.mIndices.Add(++pcounter);
                            }
                            else
                            {
                                li = new IfcLineIndex(pcounter++, pcounter);
                            }
                        }
                    }
                    else
                    {
                        if (li != null)
                        {
                            segs.Add(li);
                            li = null;
                        }
                        pts.Add(c.PointAt(c.Domain.Mid));
                        if (closed && icounter + 1 == segments.Length)
                        {
                            segs.Add(new IfcArcIndex(pcounter++, pcounter, 0));
                        }
                        else
                        {
                            pts.Add(c.PointAtEnd);
                            segs.Add(new IfcArcIndex(pcounter++, pcounter++, pcounter));
                        }
                    }
                }
                if (li != null)
                {
                    segs.Add(li);
                }
                cpl = new IfcCartesianPointList3D(db, pts.ToArray());
            }
            return(new IfcIndexedPolyCurve(cpl, segs)
            {
            });
        }