public override bool Run(FeatureContext context) { LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.RED); var points = new List <Vector3>(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(50, 0, 0)); points.Add(new Vector3(100, 0, 0)); points.Add(new Vector3(0, 50, 0)); points.Add(new Vector3(50, 50, 5)); points.Add(new Vector3(100, 50, -5)); points.Add(new Vector3(0, 150, 5)); points.Add(new Vector3(50, 150, -5)); points.Add(new Vector3(100, 150, 0)); TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3); context.ShowGeometry(face); GeomSurface surface = new GeomSurface(); surface.Initialize(face); double ufirst = surface.FirstUParameter(); double uLarst = surface.LastUParameter(); double vfirst = surface.FirstVParameter(); double vLast = surface.LastVParameter(); double ustep = (uLarst - ufirst) * 0.1; double vstep = (vLast - vfirst) * 0.1; for (double ii = ufirst; ii <= uLarst; ii += ustep) { for (double jj = vfirst; jj <= vLast; jj += vstep) { var data = surface.D1(ii, jj); Vector3 pos = data[0]; Vector3 dirU = data[1]; Vector3 dirV = data[2]; Vector3 dir = dirV.CrossProduct(dirU); //dir.Normalize(); { TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir * 0.01f); SceneNode node = context.ShowGeometry(line); node.SetLineStyle(lineStyle); } } } return(true); }
public override void OnButtonDownEvent(InputEvent evt) { if (evt.IsRButtonDown()) { this.Exit(1); return; } this.RemoveAllTempNodes(); Renderer rv = GetRenderer(); PickHelper pickHelper = new PickHelper(); pickHelper.Initialize(rv); if (!pickHelper.Pick(evt.GetMousePosition())) { return; } TopoShape shape = pickHelper.GetGeometry(); GeomSurface surface = new GeomSurface(); if (!surface.Initialize(shape)) { return; } IntersectionLineSurface intersector = new IntersectionLineSurface(); intersector.SetSurface(shape); if (!intersector.Perform(rv.ComputeScreenRay(evt.GetMousePosition()))) { return; } int nCount = intersector.GetPointCount(); if (nCount < 1) { return; } double u = intersector.GetParameterU(1); double v = intersector.GetParameterV(1); Vector3 pt = surface.Value(u, v); Vector3 normal = surface.GetNormal(u, v); LineNode lineNode = new LineNode(); lineNode.Set(pt, pt + normal); this.ShowTempNode(lineNode); rv.RequestDraw(1); }
public override void OnFace(TopoShape face) { ++nShapeCount; nodeStack.Peek().Nodes.Add(String.Format("{0}", nShapeCount), String.Format("Face {0}", nShapeCount)); SceneNode node = renderView.ShowGeometry(face, nShapeCount); node.SetFaceStyle(faceStyle); GeomSurface gs = new GeomSurface(); gs.Initialize(face); if (gs.IsUClosed() || gs.IsVClosed()) { //SceneNode node = renderView.ShowGeometry(face, nShapeCount); //node.SetFaceStyle(faceStyle); WireClassifier wc = new WireClassifier(); if (!wc.Initialize(face)) { return; } var holes = wc.GetInnerWires(); for (int ii = 0, len = holes.Size(); ii < len; ++ii) { var holeEdge = holes.GetAt(ii); ++nShapeCount; var holeNode = renderView.ShowGeometry(holeEdge, nShapeCount); holeNode.SetLineStyle(holeStyle); } } //var outer = wc.GetOuterWire(); //TopoExplor te = new TopoExplor(); //var edges = te.ExplorEdges(outer); //for (int ii = 0, len = edges.Size(); ii < len; ++ii) //{ // var edge = edges.GetAt(ii); // GeomCurve curve = new GeomCurve(); // curve.Initialize(edge); // if (curve.IsClosed()) // { // var holeNode = renderView.ShowGeometry(edge, ++nShapeCount); // holeNode.SetLineStyle(holeStyle); // } //} }
public override void OnButtonDownEvent(InputEvent evt) { if (evt.IsRButtonDown()) { this.Exit(1); return; } this.RemoveAllTempNodes(); Renderer rv = GetRenderer(); PickHelper pickHelper = new PickHelper(); pickHelper.Initialize(rv); if (!pickHelper.Pick(evt.GetMousePosition())) return; TopoShape shape = pickHelper.GetGeometry(); GeomSurface surface = new GeomSurface(); if (!surface.Initialize(shape)) return; IntersectionLineSurface intersector = new IntersectionLineSurface(); intersector.SetSurface(shape); if (!intersector.Perform(rv.ComputeScreenRay(evt.GetMousePosition()))) { return; } int nCount = intersector.GetPointCount(); if(nCount < 1) return; float u = intersector.GetParameterU(1); float v = intersector.GetParameterV(1); Vector3 pt = surface.Value(u, v); Vector3 normal = surface.GetNormal(u, v); LineNode lineNode = new LineNode(); lineNode.Set(pt, pt + normal); this.ShowTempNode(lineNode); rv.RequestDraw(1); }
public FaceInfo(TopoShape face, int idx, double area) { Surface = new GeomSurface(); Surface.Initialize(face); Index = idx; Area = area; Direction = Surface.GetNormal(Surface.FirstUParameter(), Surface.FirstVParameter()); TopoShapeProperty prop = new TopoShapeProperty(); var edges = GlobalInstance.TopoExplor.ExplorEdges(face); for (int jj = 0; jj < edges.Size(); ++jj) { var edge = edges.GetAt(jj); prop.SetShape(edge); var edgeInfo = new EdgeInfo(edge, jj, idx, prop.EdgeLength()); // 只加直线? Edges.Add(jj, edgeInfo); } }
public void Load(GeomSurface S, double UFirst, double ULast, double VFirst, double VLast, double TolU, double TolV) { GeomAdaptor_Surface_LoadBCD666D6(Instance, S.Instance, UFirst, ULast, VFirst, VLast, TolU, TolV); }
public BRepBuilderAPIMakeFace(GeomSurface S, double UMin, double UMax, double VMin, double VMax, double TolDegen) : base(BRepBuilderAPI_MakeFace_Ctor8F43826(S.Instance, UMin, UMax, VMin, VMax, TolDegen)) { }
public void Init(GeomSurface S, double UMin, double UMax, double VMin, double VMax, double TolDegen) { BRepBuilderAPI_MakeFace_Init8F43826(Instance, S.Instance, UMin, UMax, VMin, VMax, TolDegen); }
public BRepBuilderAPIMakeFace(GeomSurface S, TopoDSWire W, bool Inside) : base(BRepBuilderAPI_MakeFace_CtorC9D68572(S.Instance, W.Instance, Inside)) { }
public void UpdateFace(TopoDSFace F, GeomSurface S, TopLocLocation L, double Tol) { BRep_Builder_UpdateFaceBAA765A3(Instance, F.Instance, S.Instance, L.Instance, Tol); }
public void UpdateVertex(TopoDSVertex V, double P, TopoDSEdge E, GeomSurface S, TopLocLocation L, double Tol) { BRep_Builder_UpdateVertex2BB581FE(Instance, V.Instance, P, E.Instance, S.Instance, L.Instance, Tol); }
public void Init(GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, double Tolerance, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_InitC925CD84(Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, Tolerance, (int)Algo); }
public void Init(gpPnt P, GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, double Tolerance, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_InitBF455401(Instance, P.Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, Tolerance, (int)Algo); }
public void Load(GeomSurface S) { GeomAdaptor_Surface_Load9001466F(Instance, S.Instance); }
public GeomAdaptorSurface(GeomSurface S, double UFirst, double ULast, double VFirst, double VLast, double TolU, double TolV) : base(GeomAdaptor_Surface_CtorBCD666D6(S.Instance, UFirst, ULast, VFirst, VLast, TolU, TolV)) { }
private void planeAngleToolStripMenuItem_Click(object sender, EventArgs e) { // plane Vector3 planeDir = Vector3.UNIT_Z; TopoShape plane1 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, planeDir, -100, 100, -100, 100); { GeomSurface gs = new GeomSurface(); gs.Initialize(plane1); List<Vector3> rst = gs.D1(gs.FirstUParameter(), gs.FirstVParameter()); Vector3 dir2 = rst[1].CrossProduct(rst[2]); MessageBox.Show(dir2.ToString()); } Vector3 normal = new Vector3(0,1,1); normal.Normalize(); TopoShape plane2 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, normal, -100, 100, -100, 100); renderView.ShowGeometry(plane1, ++shapeId); renderView.ShowGeometry(plane2, ++shapeId); LineStyle style = new LineStyle(); style.SetColor(ColorValue.GREEN); // witness Vector3 end1 = new Vector3(0, 0, 100); LineNode line1 = new LineNode(); line1.Set(Vector3.ZERO, end1); line1.SetLineStyle(style); renderView.ShowSceneNode(line1); Vector3 end2 = normal * 100; LineNode line2 = new LineNode(); line2.Set(Vector3.ZERO, end2); line2.SetLineStyle(style); renderView.ShowSceneNode(line2); // angle float angle = normal.AngleBetween(planeDir); Vector3 dir = normal.CrossProduct(planeDir); dir.Normalize(); TopoShape arc = GlobalInstance.BrepTools.MakeArc(end2, end1, Vector3.ZERO, dir); SceneNode arcNode = renderView.ShowGeometry(arc, ++shapeId); arcNode.SetLineStyle(style); // text TextNode text = new TextNode(); text.SetText(angle.ToString()); Vector3 pos = end2 + end1; pos = pos * 0.5f; text.SetPosition(pos); renderView.ShowSceneNode(text); renderView.RequestDraw(); }
private void surfaceToolStripMenuItem_Click(object sender, EventArgs e) { Platform.LineStyle lineStyle = new Platform.LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.RED); var points = new System.Collections.Generic.List<Vector3>(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(50, 0, 0)); points.Add(new Vector3(100, 0, 0)); points.Add(new Vector3(0, 50, 0)); points.Add(new Vector3(50, 50, 5)); points.Add(new Vector3(100, 50, -5)); points.Add(new Vector3(0, 150, 5)); points.Add(new Vector3(50, 150, -5)); points.Add(new Vector3(100, 150, 0)); TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3); renderView.ShowGeometry(face, 101); GeomSurface surface = new GeomSurface(); surface.Initialize(face); float ufirst = surface.FirstUParameter(); float uLarst = surface.LastUParameter(); float vfirst = surface.FirstVParameter(); float vLast = surface.LastVParameter(); float ustep = (uLarst - ufirst) * 0.1f; float vstep = (vLast - vfirst) * 0.1f; for(float ii=ufirst; ii<=uLarst; ii+= ustep) for (float jj = vfirst; jj <= vLast; jj += vstep) { var data = surface.D1(ii, jj); Vector3 pos = data[0]; Vector3 dirU = data[1]; Vector3 dirV = data[2]; Vector3 dir = dirV.CrossProduct(dirU); dir.Normalize(); { Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir*10.0f); Platform.SceneNode node = renderView.ShowGeometry(line, 101); node.SetLineStyle(lineStyle); } } TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(face); float area = property.SurfaceArea(); TextNode text = new TextNode(); text.SetText(String.Format("Surface Area: {0}", area)); text.SetPosition(new Vector3(100, 100, 0)); renderView.SceneManager.ClearNodes2d(); renderView.SceneManager.AddNode2d(text); renderView.RequestDraw(); }
public void Init(gpPnt P, GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_InitCC109054(Instance, P.Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, (int)Algo); }
public SolverSurface(GeomSurface surface) { Surface = surface; GeometryType = GeometryType.None; }
public void Init(GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_Init702736C(Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, (int)Algo); }
public SolverSurface(GeomSurface surface, GeometryType type) { Surface = surface; GeometryType = type; }
public void Range(TopoDSEdge E, GeomSurface S, TopLocLocation L, double First, double Last) { BRep_Builder_Range367873C2(Instance, E.Instance, S.Instance, L.Instance, First, Last); }
public GeomAPIProjectPointOnSurf(gpPnt P, GeomSurface Surface, ExtremaExtAlgo Algo) : base(GeomAPI_ProjectPointOnSurf_Ctor491C84E1(P.Instance, Surface.Instance, (int)Algo)) { }
public void MakeFace(TopoDSFace F, GeomSurface S, double Tol) { BRep_Builder_MakeFace7EEC8D91(Instance, F.Instance, S.Instance, Tol); }
public GeomAPIProjectPointOnSurf(gpPnt P, GeomSurface Surface, double Tolerance, ExtremaExtAlgo Algo) : base(GeomAPI_ProjectPointOnSurf_Ctor72869244(P.Instance, Surface.Instance, Tolerance, (int)Algo)) { }
public void Continuity(TopoDSEdge E, GeomSurface S1, GeomSurface S2, TopLocLocation L1, TopLocLocation L2, GeomAbsShape C) { BRep_Builder_ContinuityBD255723(Instance, E.Instance, S1.Instance, S2.Instance, L1.Instance, L2.Instance, (int)C); }
public GeomAPIProjectPointOnSurf(gpPnt P, GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, double Tolerance, ExtremaExtAlgo Algo) : base(GeomAPI_ProjectPointOnSurf_CtorBF455401(P.Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, Tolerance, (int)Algo)) { }
public void Init(GeomSurface S, bool Bound, double TolDegen) { BRepBuilderAPI_MakeFace_Init78C1643F(Instance, S.Instance, Bound, TolDegen); }
public GeomAPIProjectPointOnSurf(gpPnt P, GeomSurface Surface, double Umin, double Usup, double Vmin, double Vsup, ExtremaExtAlgo Algo) : base(GeomAPI_ProjectPointOnSurf_CtorCC109054(P.Instance, Surface.Instance, Umin, Usup, Vmin, Vsup, (int)Algo)) { }
public BRepBuilderAPIMakeFace(GeomSurface S, double TolDegen) : base(BRepBuilderAPI_MakeFace_Ctor4C43CA45(S.Instance, TolDegen)) { }
public void Init(gpPnt P, GeomSurface Surface, double Tolerance, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_Init72869244(Instance, P.Instance, Surface.Instance, Tolerance, (int)Algo); }
private void queryToolStripMenuItem_Click(object sender, EventArgs e) { SelectedShapeQuery context = new SelectedShapeQuery(); renderView.QuerySelection(context); TopoShape subShape = context.GetSubGeometry(); SceneNode topoNode = context.GetSubNode(); if (subShape != null) { Console.WriteLine(subShape.GetShapeType()); } Matrix4 shapeTransform = topoNode.GetTransform(); //surface GeomSurface surface = new GeomSurface(); if (surface.Initialize(subShape)) { List <Vector3> ptVecList = new List <Vector3>(); List <Vector3> norVecList = new List <Vector3>(); Console.Write("surface"); //double firstU = surface.FirstUParameter(); //double lastU = surface.LastUParameter(); //double firstV = surface.FirstVParameter(); //double lastV = surface.LastVParameter(); double firstU = surface.FirstUParameter(); double lastU = surface.LastUParameter(); double firstV = surface.FirstVParameter(); double lastV = surface.LastVParameter(); double offSetU = lastU - firstU; double offSetV = lastV - firstV; double stepU = 0.10; double stepV = 10; int stepNoU = (int)(offSetU / stepU); int stepNoV = (int)(offSetV / stepV); for (int v_i = 3; v_i < stepNoV - 5; v_i++) { for (int u_i = 0; u_i < stepNoU; u_i++) { double tempV = firstV + stepV * v_i; double tempU = firstU + stepU * (v_i % 2 == 0 ? u_i : stepNoU - u_i); //double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i); Vector3 ptVec_1 = surface.Value(tempU, tempV); Vector3 ptVec = shapeTransform.Transform(ptVec_1); Vector3 normalVec_1 = surface.GetNormal(tempU, tempV); //Vector3 normalVec =shapeTransform.Transform(normalVec_1);//matrix3 3*3 Vector3 normalVec = RotateDirVector(shapeTransform, normalVec_1); ptVecList.Add(ptVec); norVecList.Add(normalVec); pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec)); ShowStatusMessage("path pts No: " + pathPqList.Count); //LineNode tempLineNode = new LineNode(); //LineStyle lineStyle = new LineStyle(); //lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine); //lineStyle.SetColor(100, 0, 100); //tempLineNode.SetLineStyle(lineStyle); //tempLineNode.Set(ptVec, ptVec + normalVec); //tempLineNode.SetVisible(true); //renderView.SceneManager.AddNode(tempLineNode); //renderView.RequestDraw(); } } //for (int u_i = 0; u_i < stepNoU; u_i++) //{ // for (int v_i = 0; v_i < stepNoV-0; v_i++) // { // double tempU = firstU + stepU * u_i; // double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i); // Vector3 ptVec =shapeTransform.Transform(surface.Value(tempU,tempV )); // Vector3 normalVec = surface.GetNormal(tempU,tempV); // ptVecList.Add(ptVec); // norVecList.Add(normalVec); // pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec)); // } //} int a = 0; } //curve GeomCurve curve = new GeomCurve(); if (curve.Initialize(subShape)) { Vector3 startPt = shapeTransform.Transform(curve.D0(curve.FirstParameter())); //Vector3 startPt_ = shapeTransform.Transform(startPt); Vector3 pt1 = curve.GetStartPoint(); Vector3 endPt = shapeTransform.Transform(curve.D0(curve.LastParameter())); Vector3 pt2 = curve.GetEndPoint(); switch ((EnumCurveType)curve.GetCurveType()) { case EnumCurveType.CurveType_OtherCurve: Console.Write("other"); break; case EnumCurveType.CurveType_BSplineCurve: break; case EnumCurveType.CurveType_BezierCurve: break; case EnumCurveType.CurveType_Parabola: break; case EnumCurveType.CurveType_Hyperbola: break; case EnumCurveType.CurveType_Ellipse: break; case EnumCurveType.CurveType_Circle: Console.Write("Circle"); break; case EnumCurveType.CurveType_Line: Console.Write("Line"); //path double[] startPt_ = new double[3] { startPt.X, startPt.Y, startPt.Z }; double[] endPt_ = new double[3] { endPt.X, endPt.Y, endPt.Z }; Path_U.Interpolation(startPt_, endPt_, 0.01, ref pathPtList); //show pick result LineNode tempLineNode = new LineNode(); LineStyle lineStyle = new LineStyle(); lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine); lineStyle.SetColor(100, 0, 100); tempLineNode.SetLineStyle(lineStyle); tempLineNode.Set(new Vector3(startPt.X + 0.1, startPt.Y + 10, startPt.Z + 0.1), endPt); tempLineNode.SetVisible(true); renderView.SceneManager.AddNode(tempLineNode); renderView.RequestDraw(); break; default: break; } ElementId id = context.GetNodeId(); MessageBox.Show(id.AsInt().ToString()); //... } }
public void Init(gpPnt P, GeomSurface Surface, ExtremaExtAlgo Algo) { GeomAPI_ProjectPointOnSurf_Init491C84E1(Instance, P.Instance, Surface.Instance, (int)Algo); }