Пример #1
0
        public static void ShowFaceDirection(TopoDSFace face, Document Document)
        {
            var p1 = new gpPnt();
            var v1 = new gpVec();
            var v2 = new gpVec();

            var sf = new BRepAdaptorSurface(face, true);
            var u  = sf.FirstUParameter;
            var x  = sf.LastUParameter;

            if (Precision.IsInfinite(u))
            {
                u = (Precision.IsInfinite(x)) ? 0.0 : x;
            }
            else if (!Precision.IsInfinite(x))
            {
                u = (u + x) / 2.0;
            }

            var v = sf.FirstVParameter;

            x = sf.LastVParameter;
            if (Precision.IsInfinite(v))
            {
                v = (Precision.IsInfinite(x)) ? 0.0 : x;
            }
            else if (!Precision.IsInfinite(x))
            {
                v = (v + x) / 2.0;
            }

            sf.D1(u, v, p1, v1, v2);
            var vector = v1.Crossed(v2);

            x = vector.Magnitude;

            // The direction vector length
            const double length = 70.0;

            if (x > 0.0000001)
            {
                vector.Multiply(length / x);
            }
            else
            {
                vector.SetCoord(length / 2.0, 0, 0);
            }

            var p2 = new gpPnt(p1.X, p1.Y, p1.Z);

            p2.Translate(vector);

            if (p1.IsEqual(p2, Precision.Confusion))
            {
                return;
            }

            DrawArrow(Document, p1, p2, face.Orientation());
        }
Пример #2
0
        private List <Point3D> ExecuteTrim(SceneSelectedEntity wireToTrim, List <SceneSelectedEntity> trimmingWires, gpPnt clickPoint)
        {
            var profileLocation          = wireToTrim.TargetShape().Location();
            var profileTranslation       = new gpTrsf();
            var profileTranslationVector = profileLocation.Transformation.TranslationPart.Reversed;

            profileTranslation.TranslationPart = (profileTranslationVector);
            var newProfileLocation = new TopLocLocation(profileTranslation);

            foreach (var wire in trimmingWires)
            {
                if (wire.Node.Get <TopoDsShapeInterpreter>().Shape != null)
                {
                    wire.Node.Get <TopoDsShapeInterpreter>().Shape.Move(newProfileLocation);
                }
            }
            wireToTrim.Node.Get <TopoDsShapeInterpreter>().Shape.Move(newProfileLocation);
            clickPoint.Translate(profileTranslationVector);

            var trimmingEdges = new List <TopoDSEdge>();

            foreach (var trimming in trimmingWires)
            {
                var trimmingE = GeomUtils.ExtractEdges(trimming.TargetShape());
                if (trimmingE.Count > 0)
                {
                    trimmingEdges.AddRange(trimmingE);
                }
            }
            if (trimmingEdges.Count <= 0)
            {
                return(null);
            }

            var resultPoints = GeomUtils.TrimKnownShape(trimmingEdges, wireToTrim, new Point3D(clickPoint));

            return(resultPoints);
        }