private AISInteractiveObject UpdateShapeInteractive(Node node, TopoDSShape topoDsShape) { AISInteractiveObject interactiveShape; var haveInteractiveShape = ShapeList.TryGetValue(node.Index, out interactiveShape); if (haveInteractiveShape) { AISShape shape = interactiveShape.Convert <AISShape>(); if (shape != null) { shape.Set(topoDsShape); interactiveShape.Redisplay(false); } } else { interactiveShape = new AISShape(topoDsShape); ShapeList[node.Index] = interactiveShape; if (ShapeUtils.IsPlanarFace(topoDsShape)) { var drawer = interactiveShape.Attributes; var shadingAspect = drawer.ShadingAspect; var shadingAspectAspect = shadingAspect.Aspect; shadingAspectAspect.EdgeColor = (ShapeUtils.GetOccColor(Color.Black)); //shadingAspectAspect.SetEdgeWidth(1); shadingAspectAspect.SetEdgeOn(); } } return(interactiveShape); }
private AISShape AddToContext(NodeBuilder builder, TopoDSShape sourceShape, gpTrsf mirrorTransform) { var shape = new BRepBuilderAPITransform(sourceShape, mirrorTransform, true).Shape; var aisShape = new AISShape(shape); _context.Display(aisShape, false); _context.SetTransparency(aisShape, 0.8, false); ApplyColor(builder, aisShape); return(aisShape); }
public static BndBox ExtractBndBox(TopoDSShape topoDsShape) { var shape = new AISShape(topoDsShape); try { var bndBox = shape.BoundingBox; return(bndBox); } catch { return(null); } }
public override bool Execute() { var firstPoint = Dependency[0].TransformedPoint3D; var secondPoint = Dependency[1].TransformedPoint3D; var colorOrientation = Dependency[2].Integer; var color = QuantityNameOfColor.Quantity_NOC_RED; var aEdge = new BRepBuilderAPIMakeEdge(firstPoint.GpPnt, secondPoint.GpPnt).Edge; var wire = new BRepBuilderAPIMakeWire(aEdge).Wire; var temporaryShape = new AISShape(wire); var drawer = temporaryShape.Attributes; //need fixed the coloring // drawer.WireAspect = (new Prs3dLineAspect(color, AspectTypeOfLine.Aspect_TOL_DOT,3)); Interactive = temporaryShape; return(true); }
private void ViewMouseMove(object sender, MouseEventArgs e) { var pnt = new gpPnt(e.X + 10, e.Y + 20, 1); if (shape != null) { context3d.Remove(shape, false); } var box = new BRepPrimAPIMakeBox(pnt, 50, 50, 50); shape = new AISShape(box.Shape); context3d.Display(shape, true); //context3d.OpenLocalContext(true, true, false, false); //context3d.ActivateStandardMode(OCTopAbs_ShapeEnum.TopAbs_SOLID); context3d.MoveTo(e.X, e.Y, view3d); //context3d.CloseAllContexts(false); }
/// <summary> /// Initializes the OpenCascade views and assigns them View handles. /// </summary> private void InitializeOpenCascade() { // Initialize the Devices device3d = new Graphic3dWNTGraphicDevice(); // Create the V3d Viewer try { viewer3d = new V3dViewer(device3d, "Hello", "", 100, V3dTypeOfOrientation.V3d_XnegYpos, QuantityNameOfColor.Quantity_NOC_ALICEBLUE, V3dTypeOfVisualization.V3d_ZBUFFER, V3dTypeOfShadingModel.V3d_GOURAUD, V3dTypeOfUpdate.V3d_WAIT, true, true, V3dTypeOfSurfaceDetail.V3d_TEX_ALL); // manual default Debug.Assert(viewer3d != null); if (CreateLights()) { viewer3d.SetLightOn(); } } catch (Exception ex) { Debug.Assert(false, ex.Message); throw; //re-throw exception } // Create the 3D Interactive Context try { context3d = new AISInteractiveContext(this.viewer3d); Debug.Assert(context3d != null); if (context3d != null) { //context3d.HilightColor = NameOfColor.Quantity_NOC_DARKSLATEGRAY; //context3d.SelectionColor = NameOfColor.Quantity_NOC_WHITE; } } catch (Exception ex) { Debug.Assert(false, ex.Message); throw; // re-throw exception } // create the 2D interactive context //try //{ // context2d = new AIS2D_InteractiveContext(this.viewer2d); // Debug.Assert(context2d != null); // if (context2d != null) // { // //context.HilightColor = NameOfColor.Quantity_NOC_DARKSLATEGRAY; // //context.SelectionColor = NameOfColor.Quantity_NOC_WHITE; // } //} //catch (Exception ex) //{ // Debug.Assert(false, ex.Message); // throw; // re-throw exception //} // Create an OpenCascade view for each visible Custom controls CreateView3D(); //CreateView2D(); //SetVisualMode(); //bool executeTemporaryCode = true; //if (executeTemporaryCode) //{ // temporary code ------------------- // Draw a box for (int i = 0; i < 500; i += 10) { var pnt = new gpPnt(i, i, i); //OCBRepPrimAPI_MakeBox box = new BRepPrimAPI_MakeBox(pnt, 100, 100, 100); var box = new BRepPrimAPIMakeBox(pnt, 50, 50, 50); var shape = new AISShape(box.Shape); context3d.Display(shape, false); // manual default } view3d.FitAll(0.01, false, true); // manual default // ----------------------------------- //} // Build an XYZ axis trihedron and add it to Ocaf var coords = gp.ZOX; coords.Location = new gpPnt(0, 0, 0); var axis = new GeomAxis2Placement(coords); var trihedron = new AISTrihedron(axis) { Size = 200 }; context3d.Display(trihedron, false); }