System.Collections.Generic.List.Add(seg3d)

Here are the examples of the csharp api System.Collections.Generic.List.Add(seg3d) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void segs_Remove(List<seg3d> segs, seg3d p)
        {
            List<seg3d> rm = new List<seg3d>();
            List<seg3d> add = new List<seg3d>();
            foreach (seg3d q in segs)
            {
                //List<seg3d> onlyp = new List<seg3d>();
                List<seg3d> onlyq = new List<seg3d>();
                //List<seg3d> common = new List<seg3d>();
                SegmentsOverlap3d so = ut.CalcSegmentsOverlap3d(p, q, null, onlyq, null);
                Debug.replacedert(
                    (so == SegmentsOverlap3d.SameSegment)
                    || (so == SegmentsOverlap3d.None)
                    || (so == SegmentsOverlap3d.OppositeDirection)
                    || (so == SegmentsOverlap3d.P_On_Q)
                    || (so == SegmentsOverlap3d.Q_On_P)
                    || (so == SegmentsOverlap3d.Overlap)
                    );
                switch (so)
                {
                    case SegmentsOverlap3d.SameSegment:
                        {
                            rm.Add(q);
                            break;
                        }
                    case SegmentsOverlap3d.None:
                        {
                            break;
                        }
                    case SegmentsOverlap3d.OppositeDirection:
                        {
                            break;
                        }
                    case SegmentsOverlap3d.P_On_Q:
                    case SegmentsOverlap3d.Q_On_P:
                    case SegmentsOverlap3d.Overlap:
                        {
                            rm.Add(q);
                            foreach (seg3d ns in onlyq)
                            {
                                segs_Add(add, ns);
                            }
                            break;
                        }
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
            foreach (seg3d s in add)
            {
                segs.Add(s);
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_RemoveByDirection(List<seg3d> segs, Face f1, Solid s2, bool reverse)
        {
            List<seg3d> rm = new List<seg3d>();
            foreach (seg3d s in segs)
            {
                foreach (Face f2 in s2.Faces)
                {
                    xyz n = f2.myPlane.n;
                    xyz p0 = f2.myPlane.pts[0];

                    double dist_a = xyz.dotsub(n, s.a, p0);
                    double dist_b = xyz.dotsub(n, s.b, p0);

                    int sign_a = fp.getsign_dot_distancetoplane(dist_a);
                    int sign_b = fp.getsign_dot_distancetoplane(dist_b);

                    if (
                        (sign_b == 0)
                        && (sign_a != 0)
                        && (PointFaceIntersection.Inside == f2.CalcPFI(s.b))
                        )
                    {
                        // this segment is moving into a face.  find out which way the face is pointing
                        if (xyz.dotsub(f2.UnitNormal(), s.b, s.a) < 0)
                        {
                            // the segment is outside s2
                            if (reverse)
                            {
                                rm.Add(s);
                            }
                        }
                        else
                        {
                            // the segment is inside s2
                            if (!reverse)
                            {
                                rm.Add(s);
                            }
                        }
                        break;
                    }
                    else if (
                        (sign_b != 0)
                        && (sign_a == 0)
                        && (PointFaceIntersection.Inside == f2.CalcPFI(s.a))
                        )
                    {
                        // this segment is moving away from a face.  find out which way the face is pointing
                        if (xyz.dotsub(f2.UnitNormal(), s.a, s.b) < 0)
                        {
                            // the segment is outside s2
                            if (reverse)
                            {
                                rm.Add(s);
                            }
                        }
                        else
                        {
                            // the segment is inside s2
                            if (!reverse)
                            {
                                rm.Add(s);
                            }
                        }
                        break;
                    }
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_RemoveObvious(List<seg3d> segs, Face f1, Solid s2, bsp3d bsp2, bool reverse)
        {
            List<seg3d> rm = new List<seg3d>();
            foreach (seg3d s in segs)
            {
                PointInPoly pip_a = bsp2.PointInPolyhedron(s.a);
                if (pip_a == PointInPoly.Coincident)
                {
                    break;
                }
                PointInPoly pip_b = bsp2.PointInPolyhedron(s.b);
                if (pip_b == PointInPoly.Coincident)
                {
                    break;
                }

                if (pip_a != pip_b)
                {
                    break;
                }

#if false // coverage says this never gets hit
                bool bNone = true;
                foreach (Face f2 in s2.Faces)
				{
					if (f2.SegmentTouches(s))
					{
                        // coverage says this line is never hit
                        // which may mean this entire check is
                        // unneeded.
                        bNone = false;
                        break;
					}
				}
				if (bNone)
#endif
                {
                    bool bKeep = false;
                    if (s2.PointInside(bsp2, s.b))
                    {
                        bKeep = false;
                    }
                    else
                    {
                        bKeep = true;
                    }
                    if (reverse)
                    {
                        bKeep = !bKeep;
                    }
                    if (!bKeep)
                    {
                        rm.Add(s);
                    }
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_SplitEdges(List<seg3d> segs, Solid s2, BoundingBox3d bb2, bool reverse)
        {
            List<seg3d> rm = new List<seg3d>();
            List<seg3d> news = new List<seg3d>();

            for (int i = 0; i < segs.Count; i++)
            {
                seg3d s = segs[i];
                if (bb2.SegmentCannotIntersect(s.a, s.b))
                {
                    continue;
                }

                for (int j = 0; j < s2.Faces.Count; j++)
                {
                    Face f2 = s2.Faces[j];

                    xyz hit = f2.CalcSegmentFaceIntersection_HitOnly(s);
                    if (hit != null)
                    {
                        rm.Add(s);

                        seg3d to_the_face = new seg3d(s.a, hit, s.origin);
                        seg3d away_from_the_face = new seg3d(hit, s.b, s.origin);

                        news.Add(to_the_face);
                        news.Add(away_from_the_face);

                        break;
                    }
                }
            }

            if (news.Count > 0)
            {
                ParreplacedionFace_SplitEdges(news, s2, bb2, reverse);

                foreach (seg3d s in rm)
                {
                    segs.Remove(s);
                }
                foreach (seg3d s in news)
                {
                    segs.Add(s);
                }
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_HandleCoplanarStuff(List<seg3d> segs, Face f1, Solid s2, bool reverse)
        {
            List<seg3d> rm = new List<seg3d>();
#if false // I think we *should* need this, but coverage says it never gets hit, so I am removing it for now.
            foreach (seg3d s in segs)
            {
                PointFaceIntersection pfi_a = f1.CalcPFI(s.a);
                PointFaceIntersection pfi_b = f1.CalcPFI(s.b);

                if (
                    (
                    (pfi_a == PointFaceIntersection.None)
                    && (pfi_b == PointFaceIntersection.OnEdge)
                    )
                    ||
                    (
                    (pfi_a == PointFaceIntersection.OnEdge)
                    && (pfi_b == PointFaceIntersection.None)
                    )
                    )
                {
                    rm.Add(s);
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
#endif

            if (segs.Count > 0)
            {
                rm.Clear();
                xyz n1 = f1.UnitNormal();
                for (int ndx_f2 = 0; ndx_f2 < s2.Faces.Count; ndx_f2++)
                {
                    Face f2 = s2.Faces[ndx_f2];
                    if (
                        fp.eq_unitvec(f2.UnitNormal(), n1)
                        && f1.IsCoPlanarWith(f2)
                        )
                    {
                        foreach (seg3d s in segs)
                        {
                            PointFaceIntersection pfi_a = f2.CalcPFI(s.a);
                            PointFaceIntersection pfi_b = f2.CalcPFI(s.b);

                            if (
                                (
                                (pfi_a == PointFaceIntersection.Inside)
                                && (pfi_b == PointFaceIntersection.OnEdge)
                                )
                                ||
                                (
                                (pfi_a == PointFaceIntersection.OnEdge)
                                && (pfi_b == PointFaceIntersection.Inside)
                                )
                                )
                            {
                                rm.Add(s);
                            }
                        }
                    }
                }
                foreach (seg3d s in rm)
                {
                    segs.Remove(s);
                }
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_HandleEdges(List<seg3d> segs, Face f1, Solid s2, bsp3d bsp2, bool reverse)
        {
            List<seg3d> rm = new List<seg3d>();
            segs.ForEach(delegate (seg3d s)
            {
                HalfEdge he1a;
                if (f1.IsAnEdge(s, out he1a))
                {
                    HalfEdge he1b = he1a.Opposite();
                    for (int ndx_f2 = 0; ndx_f2 < s2.Faces.Count; ndx_f2++)
                    {
                        Face f2 = s2.Faces[ndx_f2];
                        HalfEdge he2a = null;
                        if (f2.IsAnEdge(s, out he2a))
                        {
                            HalfEdge he2b = he2a.Opposite();

                            bool bkeep;

                            xyz n1 = he1a.GetInwardNormal();
                            xyz n2a = he2a.GetInwardNormal();
                            xyz n2b = he2b.GetInwardNormal();

                            bkeep = bool3d.SplitsVEP(n1, n2a, n2b, he2a.face.UnitNormal(), he2b.face.UnitNormal());

                            if (reverse)
                            {
                            }
                            else
                            {
                                bkeep = !bkeep;
                            }

                            if (!bkeep)
                            {
                                rm.Add(s);
                            }
                            break;
                        }

                        PointFaceIntersection pfi_a;
                        PointFaceIntersection pfi_b;
                        if (f2.CalcSegmentFaceIntersection_SamePlane(s, out pfi_a, out pfi_b))
                        {
                            bool bProceed = false;

                            if (
                                (
                                (pfi_a == PointFaceIntersection.Inside)
                                && (pfi_b == PointFaceIntersection.Inside)
                                )
                                ||
                                (
                                (pfi_a == PointFaceIntersection.Inside)
                                && (pfi_b == PointFaceIntersection.OnEdge)
                                )
                                ||
                                (
                                (pfi_a == PointFaceIntersection.OnEdge)
                                && (pfi_b == PointFaceIntersection.Inside)
                                )
                                )
                            {
                                bProceed = true;
                            }
                            else if (
                                (
                                (pfi_a == PointFaceIntersection.OnEdge)
                                && (pfi_b == PointFaceIntersection.OnEdge)
                                )
                                )
                            {
                                if (f2.solid.SegmentOnSurface(bsp2, s.a, s.b))
                                {
                                    bProceed = true;
                                }
                            }

                            if (bProceed)
                            {
                                bool bkeep;

                                double dot = xyz.dot(he1a.GetInwardNormal(), f2.UnitNormal());

                                if (fp.eq_dot_unit(dot, 0))
                                {
                                    // this occurs on the outside of f2
                                    bkeep = true;
                                }
                                else if (dot < 0)
                                {
                                    // this intersect occurs on the inside of f2
                                    bkeep = false;
                                }
                                else
                                {
                                    // this occurs on the outside of f2
                                    bkeep = true;
                                }

                                if (reverse)
                                {
                                    bkeep = !bkeep;
                                }

                                if (!bkeep)
                                {
                                    rm.Add(s);
                                    if (rm.Count == segs.Count)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
#if false // so far, it looks like we don't need this code.  It was written when CreateTenonInFaceWithHoleBool3dBug turned up.  I rewrote tenon to use the 4-cut method again and the bug "went away".  :-)
                    foreach (Face f2 in s2.Faces)
                    {
                        HalfEdge he2a = null;
                        if (f2.IsAnEdge(s, out he2a))
                        {
                            HalfEdge he2b = he2a.Opposite();

                            bool bkeep;

                            xyz n1 = xyz.cross((s.b - s.a).normalize_in_place(), f1.UnitNormal()).normalize_in_place();

                            xyz n2a = he2a.GetInwardNormal();
                            xyz n2b = he2b.GetInwardNormal();

                            if (bool3d.SplitsVEP(n1, n2a, n2b, he2a.face.UnitNormal(), he2b.face.UnitNormal()))
                            {
                                bkeep = true;
                            }
                            else if (bool3d.SplitsVEP(-n1, n2a, n2b, he2a.face.UnitNormal(), he2b.face.UnitNormal()))
                            {
                                bkeep = true;
                            }
                            else
                            {
                                bkeep = false;
                            }

                            if (reverse)
                            {
                            }
                            else
                            {
                                bkeep = !bkeep;
                            }

                            if (!bkeep)
                            {
                                rm.Add(s);
                            }
                            break;
                        }
                    }
#endif
                }
            }
            );
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void ParreplacedionFace_Edges_StuffInOtherSolid(List<seg3d> segs, Solid s2, bsp3d bsp2, bool reverse)
        {
            // TODO this function feels like such a hack.

            List<seg3d> rm = new List<seg3d>();
            foreach (seg3d s in segs)
            {
                bool bkeep;

                if (reverse)
                {
                    bkeep = false;
                    if (s2.SegmentInside(bsp2, s.a, s.b))
                    {
                        bkeep = true;
                    }
                    else if (s2.SegmentOnSurface(bsp2, s.a, s.b))
                    {
                        bkeep = true;
                    }
                }
                else
                {
                    bkeep = true;
                    if (
                        s2.SegmentInside(bsp2, s.a, s.b)
                        && !(s2.SegmentOnSurface(bsp2, s.a, s.b))
                        )
                    {
                        bkeep = false;
                    }
                }

                if (!bkeep)
                {
                    rm.Add(s);
                }
            }
            foreach (seg3d s in rm)
            {
                segs.Remove(s);
            }
        }

19 View Source File : bool3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static void segs_Add(List<seg3d> segs, seg3d p, int level)
        {
            List<seg3d> add = new List<seg3d>();

            // start with the whole seg.  we'll remove pieces of it wherever overlaps occur
            add.Add(p);
            foreach (seg3d q in segs)
            {
                //List<seg3d> onlyp = new List<seg3d>();
                //List<seg3d> onlyq = new List<seg3d>();
                List<seg3d> common = new List<seg3d>();
                SegmentsOverlap3d so = ut.CalcSegmentsOverlap3d(p, q, null, null, common);
                Debug.replacedert(
                    (so == SegmentsOverlap3d.SameSegment)
                    || (so == SegmentsOverlap3d.None)
                    || (so == SegmentsOverlap3d.OppositeDirection)
                    || (so == SegmentsOverlap3d.P_On_Q)
                    || (so == SegmentsOverlap3d.Q_On_P)
                    || (so == SegmentsOverlap3d.Overlap)
                    );
                switch (so)
                {
                    case SegmentsOverlap3d.SameSegment:
                        {
                            segs_Remove(add, p);
                            break;
                        }
                    case SegmentsOverlap3d.None:
                        {
                            break;
                        }
                    case SegmentsOverlap3d.OppositeDirection:
                        {
                            break;
                        }
                    case SegmentsOverlap3d.P_On_Q:
                    case SegmentsOverlap3d.Q_On_P:
                    case SegmentsOverlap3d.Overlap:
                        {
                            foreach (seg3d ns in common)
                            {
                                segs_Remove(add, ns);
                            }
                            break;
                        }
                }

                if (add.Count == 0)
                {
                    // nothing left.  we must be done.
                    return;
                }
            }

            foreach (seg3d s in add)
            {
                segs.Add(s);
            }
        }

19 View Source File : ppi3d.cs
License : Apache License 2.0
Project Creator : ericsink

public static List<seg3d> CalcIntersection_NotCoplanar(Face f1, Face f2)
        {
            List<seg3d> segs_from_f1 = f1.IntersectWithPlaneOfOtherFace(f2);
            List<seg3d> segs_from_f2 = f2.IntersectWithPlaneOfOtherFace(f1);

            if (
                (segs_from_f1 == null)
                || (segs_from_f2 == null)
                || (segs_from_f1.Count == 0)
                || (segs_from_f2.Count == 0)
                )
            {
                return null;
            }

            List<seg3d> result = new List<seg3d>();
            // TODO these segments are sorted, so we should not need to run through the f2 list for every seg in the f1 list
            foreach (seg3d s1 in segs_from_f1)
            {
                int count = 0;
                foreach (seg3d s2 in segs_from_f2)
                {
                    seg3d s3 = ut.CalcUndirectedSegmentsOverlap3d(s1, s2);
                    if (s3 != null)
                    {
                        result.Add(s3);
                    }
                    else
                    {
                        if (count > 0)
                        {
                            break;
                        }
                    }
                }
            }
            return result;
        }