public void ReversedFace() { var baseShape = new Box { DimensionX = 20, DimensionY = 20, DimensionZ = 20, }; var body = TestGeomGenerator.CreateBody(baseShape, new Pnt(-10, -10, 0)); var imprint = Imprint.Create(body, baseShape.GetSubshapeReference(SubshapeType.Face, 0)); var sketch = imprint.Operands[1] as Sketch; Assert.IsNotNull(sketch); sketch.Points.Add(0, new Pnt2d(0, 0)); sketch.Points.Add(1, new Pnt2d(0, 11)); sketch.Segments.Add(0, new SketchSegmentCircle(0, 1)); Assert.IsNotNull(imprint); imprint.Depth = 2.5; imprint.Mode = Imprint.ImprintMode.Raise; Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(imprint, Path.Combine(_BasePath, "ReversedFace"))); }
public void ChamferFaces(int edgeToChamfer, int faceToImprint, Imprint.ImprintMode mode) { var body = TestGeomGenerator.CreateBox().Body; var chamfer = Chamfer.Create(body, new[] { body.Shape.GetSubshapeReference(SubshapeType.Edge, edgeToChamfer) }); chamfer.Distance = 5.0; var imprint = Imprint.Create(body, body.Shape.GetSubshapeReference(SubshapeType.Face, faceToImprint)); var center = imprint.Sketch.AddPoint(new Pnt2d(0, 0)); var rim = imprint.Sketch.AddPoint(new Pnt2d(0, 2)); imprint.Sketch.AddSegment(new SketchSegmentCircle(center, rim)); imprint.Mode = mode; Assert.IsTrue(imprint.Make(Shape.MakeFlags.None)); Assert.IsTrue(ModelCompare.CompareShape(body.Shape, Path.Combine(_BasePath, $"ChamferFaces_{edgeToChamfer}_{mode}"))); }
//-------------------------------------------------------------------------------------------------- public static Imprint CreateImprint(SketchType sketchType = SketchType.Circle) { var baseShape = new Box { DimensionX = 20, DimensionY = 20, DimensionZ = 5, }; var body = CreateBody(baseShape, new Pnt(-10, -10, 0)); var imprint = Imprint.Create(body, baseShape.GetSubshapeReference(SubshapeType.Face, 5)); var sketch = imprint.Operands[1] as Sketch; Assert.IsNotNull(sketch); FillSketch(sketch, sketchType); return(imprint); }
//-------------------------------------------------------------------------------------------------- void _OnActionFinished(ToolAction toolAction) { bool finished = false; var selectAction = toolAction as SelectSubshapeAction; Debug.Assert(selectAction != null); if (selectAction.SelectedSubshapeType == SubshapeTypes.Face) { var face = TopoDS.Face(selectAction.SelectedSubshape); var brepAdaptor = new BRepAdaptor_Surface(face, true); if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane) { StatusText = "Selected face is not a plane type surface."; } else { selectAction.Stop(); Stop(); finished = true; var faceRef = _TargetShape.GetSubshapeReference(_TargetBrep, face); if (faceRef == null) { Messages.Error("A subshape reference could not be produced for this face."); return; } if (_Mode == ToolMode.CreateNew) { // Create new var sketch = new Sketch { Body = _TargetBody, }; var imprint = Imprint.Create(_TargetBody, faceRef, sketch); if (imprint != null) { imprint.Mode = _ImprintMode; InteractiveContext.Current.UndoHandler.Commit(); InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody); WorkspaceController.StartTool(new SketchEditorTool(sketch)); } } else if (_Mode == ToolMode.ReselectFace) { // Reselected face _ImprintToChange.Face = faceRef; _ImprintToChange.Invalidate(); InteractiveContext.Current.UndoHandler.Commit(); } } } if (!finished) { selectAction.Reset(); } WorkspaceController.Invalidate(); }