Example #1
0
        public bool Test(RenderWindow3d context)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "STEP (*.stp;*.step)|*.stp;*.step";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            var shape = GlobalInstance.BrepTools.LoadFile(new Path(dlg.FileName));

            if (shape == null)
            {
                return(false);
            }

            // 1. Adjust position and direction by box
            var     box    = shape.GetBBox();
            var     sz     = box.Size();
            var     center = box.GetCenter();
            Matrix4 trf    = GlobalInstance.MatrixBuilder.MakeTranslate(-center);


            if (sz.X < sz.Y && sz.X < sz.Z)
            {
                trf = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_Y) * trf;
            }
            else if (sz.Y < sz.X && sz.Y < sz.Z)
            {
                trf = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_X) * trf;
            }

            shape = GlobalInstance.BrepTools.Transform(shape, trf);

            // 2. Find base face
            Solid solid = new Solid(shape);

            context.ShowGeometry(shape, 100);
            foreach (var fg in solid.SideFaceGroup)
            {
                foreach (var face in fg.Faces)
                {
                    context.ShowGeometry(face.GetShape(), 100);
                }
                break;
            }

            return(true);
        }
Example #2
0
        private void queryMultiSelectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShapeGroup group = new TopoShapeGroup();

            MultiShapeQuery query = new MultiShapeQuery();

            m_RenderView.QuerySelection(query);
            int nCount = query.GetCount();

            for (int ii = 0; ii < nCount; ++ii)
            {
                SelectedShapeQuery shapeQuery = query.GetSubContext(ii);
                TopoShape          subShape   = shapeQuery.GetSubGeometry();
                if (subShape != null)
                {
                    group.Add(subShape);
                }
            }

            // clear the scene and only keep the selected shapes
            if (group.Size() > 0)
            {
                m_RenderView.ClearScene();
                for (int ii = 0; ii < group.Size(); ++ii)
                {
                    m_RenderView.ShowGeometry(group.GetAt(ii), 100 + ii);;
                }
            }
        }
        public void Init(RenderWindow3d renderView)
        {
            // TODO: change parameters
            Bolt.UpdateShape();
            Nut.UpdateShape();

            Bolt.Node = renderView.ShowGeometry(Bolt.Shape, Bolt.Id);

            Bolt.Node.SetFaceStyle(RedStyle);


            Nut.Node = renderView.ShowGeometry(Nut.Shape, Nut.Id);
            FaceStyle faceStyle = new FaceStyle();

            faceStyle.SetTransparecy(0.5f);
            faceStyle.SetTransparent(true);
            Nut.Node.SetFaceStyle(faceStyle);
        }