Esempio n. 1
0
        public void Project3DModel()
        {
            OCTopoDS_Shape topoShape = WorkItem.Services.Get <ILocalContextService>().CurrentSelectedShape;

            if (topoShape == null)
            {
                return;
            }

            // Project the selected 3d object in the 2D plane

            // Make the projector
            bool     isPerspective   = WorkItem.Services.Get <ILocalContextService>().IsPerspective;
            OCgp_Pnt viewPoint       = WorkItem.Services.Get <ILocalContextService>().ViewPointPosition;
            OCgp_Vec highPointVector = WorkItem.Services.Get <ILocalContextService>().HighPointVector;

            OCgp_Ax2 ax2 = GeomUtils.ExtractAxis(topoShape);

            OCgp_Dir direction;

            if (ax2 != null)
            {
                direction = ax2.Direction();
            }
            else
            {
                direction = new OCgp_Dir(0, 1, 0);
            }
            // Use as projection vector the direction of the plane of the selected shape
            OCPrs3d_Projector aPrs3dProjector = new OCPrs3d_Projector(isPerspective, 1, direction.X(), direction.Y(), direction.Z(),
                                                                      viewPoint.X(), viewPoint.Y(), viewPoint.Z(), highPointVector.X(), highPointVector.Y(), highPointVector.Z());

            // Display the 2D projection shape
            OCAIS2D_ProjShape projShape = new OCAIS2D_ProjShape(aPrs3dProjector.Projector(), 3, false, true);

            projShape.Add(topoShape);
            context2d.Display(projShape, true);
        }
        public override void Show(OCAIS_InteractiveContext context, double x, double y, double z, OCgp_Dir direction)
        {
            if (_handleShape != null)
            {
                context.Remove(_handleShape, false);
            }

            _context = context;

            _handleTopoShape.Location(GeomUtils.BuildTranslation(new Point3D(0, 0, 0), new Point3D(x, x, z)));
            _handleShape = new OCAIS_Shape(_handleTopoShape);
            OCAIS_Shape shape = null;

            _handleShape.DownCast(ref shape);
            if (shape != null)
            {
                shape.Set(_handleTopoShape);
                _handleShape.Redisplay(false);
            }
            //var drawer = _helperLine.Attributes();
            //drawer.SetLineAspect(new OCPrs3d_LineAspect(OCQuantity_NameOfColor.Quantity_NOC_GRAY70,
            //                                            OCAspect_TypeOfLine.Aspect_TOL_DOT, 0.5));
            //_helperLine.SetTransparency(0.8);
        }