Open CASCADE学习|刚体( TopoDS_Shape)按某种轨迹运动,停在指定位置上

今天实现如下功能:刚体做做螺旋运动,轨迹已知,求刚体在每个位置上的所占据的空间,就是把刚体从初始位置变换到该位置。

这里的刚体是一个砂轮截面,螺旋运动轨迹由B样条曲线拟合,通过Frenet标架确定运动轨迹上的局部坐标系,据此计算变换矩阵,将砂轮截面变换到指定位置。

目前可以实现平面刚体的运动,还无法实现三维刚体的运动。

1、起始位置空间的确定

#include <Geom_CylindricalSurface.hxx>
#include <gp_Ax3.hxx>
#include <GeomAPI_Interpolate.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GCE2d_MakeSegment.hxx>#include <GeomAPI_PointsToBSpline.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <GC_MakeCircle.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <BRepAlgoAPI_Fuse.hxx>#include <gp_GTrsf.hxx>
#include <BRepBuilderAPI_Transform.hxx>#include"Viewer.h"#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <GC_MakeSegment.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <GeomFill_TrihedronLaw.hxx>
#include <GeomFill_Frenet.hxx>
#include <GeomFill_CurveAndTrihedron.hxx>
#include <BRepFill_Edge3DLaw.hxx>
#include <BRepFill_SectionPlacement.hxx>
#include <ShapeUpgrade_RemoveLocations.hxx>TopoDS_Edge createHelix(const Standard_Real HelixRadius, const Standard_Real HelixAngle, const Standard_Real HelixLength)
{Standard_Real u0 = 0.0;Standard_Real u1 = 2 * M_PI;Standard_Real v0 = 0.0;Standard_Real v1 = HelixLength;double uInter = (u1 - u0) / 1000;double vInter = (v1 - v0) / 1000;TColgp_HArray1OfPnt Points(1, 1001);Handle(Geom_CylindricalSurface) aCylinder = new Geom_CylindricalSurface(gp::XOY(), HelixRadius);double u;double v;//生成点for (int i = 0; i < 1001; i++) {u = i * vInter * tan(HelixAngle) / HelixRadius;v = i * vInter;Points[i + 1] = aCylinder->Value(u, v);}GeomAPI_PointsToBSpline Approx(Points);Handle_Geom_BSplineCurve K = Approx.Curve();TopoDS_Edge aHelixEdge = BRepBuilderAPI_MakeEdge(K);return aHelixEdge;}
TopoDS_Shape createGrindingwheel()
{Standard_Real Line1_angle = 280 * M_PI / 180;Standard_Real Line1_length = 0.5031;Standard_Real Line2_angle = 236 * M_PI / 180;Standard_Real Line2_length = 0.5925;Standard_Real Arc1_r = 0.112;Standard_Real Arc1_angle = (180 + 10 + 50) * M_PI / 180;gp_Pnt Line1_p1(-0.6822 / 2, 0, 0);gp_Pnt Line2_p1(0.6822 / 2, 0, 0);gp_Lin Line1(Line1_p1, gp_Dir(cos(Line1_angle), sin(Line1_angle), 0.));gp_Lin Line2(Line2_p1, gp_Dir(cos(Line2_angle), sin(Line2_angle), 0.));Handle(Geom_TrimmedCurve) L1 = GC_MakeSegment(Line1, 0., Line1_length);TopoDS_Edge L1e = BRepBuilderAPI_MakeEdge(L1);Handle(Geom_TrimmedCurve) L2 = GC_MakeSegment(Line2, 0., Line2_length);TopoDS_Edge L2e = BRepBuilderAPI_MakeEdge(L2);gp_Pnt l1end = L1->EndPoint();gp_Pnt l2end = L2->EndPoint();gp_Lin Line1v(l1end, gp_Dir(cos(Line1_angle + M_PI_2), sin(Line1_angle + M_PI_2), 0.));gp_Lin2d Line2v(gp_Pnt2d(l2end.X(), l2end.Y()), gp_Dir2d(cos(Line2_angle - M_PI_2), sin(Line2_angle - M_PI_2)));gp_Lin Line2v3d(l2end, gp_Dir(cos(Line2_angle - M_PI_2), sin(Line2_angle - M_PI_2), 0.));Handle(Geom_TrimmedCurve) L1v = GC_MakeSegment(Line1v, 0., Arc1_r);gp_Pnt l1vend = L1v->EndPoint();gp_Circ c1(gp_Ax2(l1vend, gp_Dir(0, 0, 1)), Arc1_r);Handle(Geom_TrimmedCurve) c1c = GC_MakeArcOfCircle(c1, l1end, Arc1_angle, 1);gp_Pnt c1end = c1c->EndPoint();gp_Lin2d Line3(gp_Pnt2d(c1end.X(), c1end.Y()), gp_Dir2d(l2end.X() - c1end.X(), l2end.Y() - c1end.Y()));gp_Lin2d Line3v = Line3.Normal(gp_Pnt2d((l2end.X() + c1end.X()) / 2, (l2end.Y() + c1end.Y()) / 2));IntAna2d_AnaIntersection aIntAna;aIntAna.Perform(Line2v, Line3v);IntAna2d_IntPoint aIntPoint = aIntAna.Point(1);gp_Pnt o2(aIntPoint.Value().X(), aIntPoint.Value().Y(), 0.);Handle(Geom_TrimmedCurve) L2v = GC_MakeSegment(Line2v3d, l2end, o2);Standard_Real r2 = L2v->LastParameter();gp_Circ c2(gp_Ax2(o2, gp_Dir(0, 0, 1)), r2);Handle(Geom_TrimmedCurve) c2c = GC_MakeArcOfCircle(c2, c1end, l2end, 0);gp_Pnt c2low = c2c->Value(M_PI_2);TopoDS_Edge c1ce = BRepBuilderAPI_MakeEdge(c1c);TopoDS_Edge L1ev = BRepBuilderAPI_MakeEdge(L1v);TopoDS_Edge c2ce = BRepBuilderAPI_MakeEdge(c2c);TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(Line1_p1, Line2_p1);TopTools_ListOfShape listEdge;listEdge.Append(anEdge);listEdge.Append(L1e);listEdge.Append(c1ce);listEdge.Append(c2ce);listEdge.Append(L2e);BRepBuilderAPI_MakeWire mw;mw.Add(listEdge);mw.Build();TopoDS_Face out = BRepBuilderAPI_MakeFace(mw);gp_Circ  cutcircle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 0.406 / 2);TopoDS_Edge cute = BRepBuilderAPI_MakeEdge(cutcircle);TopoDS_Wire cutw = BRepBuilderAPI_MakeWire(cute);TopoDS_Face cutf = BRepBuilderAPI_MakeFace(cutw);//平移:gp_Trsf theTransformation1;gp_Vec theVectorOfTranslation1(-c2low.X(), -c2low.Y(), 0.);theTransformation1.SetTranslation(theVectorOfTranslation1);BRepBuilderAPI_Transform myBRepTransformation1(out, theTransformation1);TopoDS_Shape outzero = myBRepTransformation1.Shape();TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(outzero, cutf);gp_Trsf theTransformation2;gp_Vec theVectorOfTranslation2(0., 0.125 / 2, 0.);theTransformation2.SetTranslation(theVectorOfTranslation2);//绕一个轴旋转:gp_Trsf theTransformation3;gp_Ax1 axez = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0., 0., 1.));theTransformation3.SetRotation(axez, -90 * M_PI / 180);gp_Trsf theTransformation4;gp_Ax1 axex = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1., 0., 0.));theTransformation4.SetRotation(axex, -50 * M_PI / 180);BRepBuilderAPI_Transform myBRepTransformation(theCommonSurface, theTransformation4 * theTransformation3 * theTransformation2);TopoDS_Shape TransformedShape = myBRepTransformation.Shape();return TransformedShape;
}
int main(int argc, char* argv[])
{gp_Dir  Z(0.0, 0.0, 1.0);gp_Pnt center(0, 0, 0.0);gp_Pnt xr(0.5, 0, 0.0);gp_Pnt yr(0.0, 1.0, 0.0);gp_Pnt zr(0.0, 0.0, 7.0);gp_Ax2  wb(center, Z);gp_Circ  wbcircle(wb, 0.125 / 2);TopoDS_Edge wbe = BRepBuilderAPI_MakeEdge(wbcircle);TopoDS_Edge xline = BRepBuilderAPI_MakeEdge(center, xr);TopoDS_Edge yline = BRepBuilderAPI_MakeEdge(center, yr);TopoDS_Edge zline = BRepBuilderAPI_MakeEdge(center, zr);//creat a profile of gringing wheelTopoDS_Shape gw = createGrindingwheel();//creat a cylinder surfaceHandle(Geom_CylindricalSurface) aCylinder = new Geom_CylindricalSurface(gp::XOY(), 0.306 / 2);TopoDS_Shape cF = BRepBuilderAPI_MakeFace(aCylinder->Cylinder(), 0, 2 * M_PI, 0, 3.);TopoDS_Solid cys = BRepPrimAPI_MakeCylinder(gp::XOY(), 0.306 / 2, 7);TopoDS_Edge aE = createHelix(0.306 / 2, M_PI / 4, 6.);TopoDS_Wire spine = BRepBuilderAPI_MakeWire(aE);//crate a sweep surfaceTopoDS_Shape pipe = BRepOffsetAPI_MakePipe(spine, gw, GeomFill_IsFrenet, 1);TopoDS_Wire mySpine;TopoDS_Shape myProfile;TopoDS_Shape myShape;gp_Trsf myTrsf;Handle(BRepFill_LocationLaw) myLoc;Handle(TopTools_HArray2OfShape) mySections;Handle(TopTools_HArray2OfShape) myFaces;Handle(TopTools_HArray2OfShape) myEdges;TopTools_MapOfShape myReversedEdges;BRepFill_DataMapOfShapeHArray2OfShape myTapes;BRepFill_DataMapOfShapeHArray2OfShape myRails;Standard_Integer myCurIndexOfSectionEdge;TopoDS_Shape myFirst;TopoDS_Shape myLast;TopTools_DataMapOfShapeListOfShape myGenMap;Standard_Integer myDegmax;Standard_Integer mySegmax;GeomAbs_Shape myContinuity;GeomFill_Trihedron myMode;Standard_Boolean myForceApproxC1;Standard_Real myErrorOnSurf;mySections.Nullify();myFaces.Nullify();myEdges.Nullify();mySpine = spine;myProfile = gw;TopoDS_Shape TheProf;Handle(GeomFill_TrihedronLaw) TLaw;TLaw = new GeomFill_Frenet();Handle(GeomFill_CurveAndTrihedron) Loc = new (GeomFill_CurveAndTrihedron) (TLaw);myLoc = new (BRepFill_Edge3DLaw) (mySpine, Loc);if (myLoc->NbLaw() == 0) {return 0; // Degenerated case}myLoc->TransformInG0Law(); // Set into continuityBRepFill_SectionPlacement Place(myLoc, gw);myTrsf = Place.Transformation();TopLoc_Location Loc2(myTrsf), Loc1;Loc1 = gw.Location();TopoDS_Shape aux;TheProf = myProfile;TheProf.Location(Loc2.Multiplied(Loc1));// Construct First && Last ShapeHandle(GeomFill_LocationLaw) law;gp_Mat M;gp_Vec V;gp_Trsf fila;Standard_Real first,last;myLoc->Law(1)->GetDomain(first, last);std::cout << "first=" <<first<< std::endl;std::cout << "last=" << last << std::endl;myLoc->Law(1)->D0(first, M, V);fila.SetValues(M(1, 1), M(1, 2), M(1, 3), V.X(),M(2, 1), M(2, 2), M(2, 3), V.Y(),M(3, 1), M(3, 2), M(3, 3), V.Z());fila.Multiply(myTrsf);TopLoc_Location LocFirst(fila);myFirst = myProfile;if (!LocFirst.IsIdentity()) {//myFirst.Location( LocFirst.Multiplied(myProfile.Location()) );myFirst = BRepBuilderAPI_Transform(myProfile, fila, Standard_True); //copy}ShapeUpgrade_RemoveLocations RemLoc;RemLoc.SetRemoveLevel(TopAbs_COMPOUND);RemLoc.Remove(myFirst);myFirst = RemLoc.GetResult();myLoc->Law(myLoc->NbLaw())->GetDomain(first, last);myLoc->Law(myLoc->NbLaw())->D0(last, M, V);//    try { // Not good, but there are no other means to test SetValuesfila.SetValues(M(1, 1), M(1, 2), M(1, 3), V.X(),M(2, 1), M(2, 2), M(2, 3), V.Y(),M(3, 1), M(3, 2), M(3, 3), V.Z());fila.Multiply(myTrsf);TopLoc_Location LocLast(fila);if (!myLoc->IsClosed() || LocFirst != LocLast) {myLast = myProfile;if (!LocLast.IsIdentity()) {//myLast.Location(LocLast.Multiplied(myProfile.Location()) );myLast = BRepBuilderAPI_Transform(myProfile, fila, Standard_True); //copy}}else {myLast = myFirst;}RemLoc.Remove(myLast);myLast = RemLoc.GetResult();Viewer vout(50, 50, 500, 500);vout << wbe;vout << xline;vout << yline;vout << zline;vout << myProfile;vout << myLast;vout << spine;vout.StartMessageLoop();return 0;
}

2、中间任一位置空间的确定

#include <Geom_CylindricalSurface.hxx>
#include <gp_Ax3.hxx>
#include <GeomAPI_Interpolate.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GCE2d_MakeSegment.hxx>#include <GeomAPI_PointsToBSpline.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <GC_MakeCircle.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <BRepAlgoAPI_Fuse.hxx>#include <gp_GTrsf.hxx>
#include <BRepBuilderAPI_Transform.hxx>#include"Viewer.h"#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <GC_MakeSegment.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <GeomFill_TrihedronLaw.hxx>
#include <GeomFill_Frenet.hxx>
#include <GeomFill_CurveAndTrihedron.hxx>
#include <BRepFill_Edge3DLaw.hxx>
#include <BRepFill_SectionPlacement.hxx>
#include <ShapeUpgrade_RemoveLocations.hxx>TopoDS_Edge createHelix(const Standard_Real HelixRadius, const Standard_Real HelixAngle, const Standard_Real HelixLength)
{Standard_Real u0 = 0.0;Standard_Real u1 = 2 * M_PI;Standard_Real v0 = 0.0;Standard_Real v1 = HelixLength;double uInter = (u1 - u0) / 1000;double vInter = (v1 - v0) / 1000;TColgp_HArray1OfPnt Points(1, 1001);Handle(Geom_CylindricalSurface) aCylinder = new Geom_CylindricalSurface(gp::XOY(), HelixRadius);double u;double v;//生成点for (int i = 0; i < 1001; i++) {u = i * vInter * tan(HelixAngle) / HelixRadius;v = i * vInter;Points[i + 1] = aCylinder->Value(u, v);}GeomAPI_PointsToBSpline Approx(Points);Handle_Geom_BSplineCurve K = Approx.Curve();TopoDS_Edge aHelixEdge = BRepBuilderAPI_MakeEdge(K);return aHelixEdge;}
TopoDS_Shape createGrindingwheel()
{Standard_Real Line1_angle = 280 * M_PI / 180;Standard_Real Line1_length = 0.5031;Standard_Real Line2_angle = 236 * M_PI / 180;Standard_Real Line2_length = 0.5925;Standard_Real Arc1_r = 0.112;Standard_Real Arc1_angle = (180 + 10 + 50) * M_PI / 180;gp_Pnt Line1_p1(-0.6822 / 2, 0, 0);gp_Pnt Line2_p1(0.6822 / 2, 0, 0);gp_Lin Line1(Line1_p1, gp_Dir(cos(Line1_angle), sin(Line1_angle), 0.));gp_Lin Line2(Line2_p1, gp_Dir(cos(Line2_angle), sin(Line2_angle), 0.));Handle(Geom_TrimmedCurve) L1 = GC_MakeSegment(Line1, 0., Line1_length);TopoDS_Edge L1e = BRepBuilderAPI_MakeEdge(L1);Handle(Geom_TrimmedCurve) L2 = GC_MakeSegment(Line2, 0., Line2_length);TopoDS_Edge L2e = BRepBuilderAPI_MakeEdge(L2);gp_Pnt l1end = L1->EndPoint();gp_Pnt l2end = L2->EndPoint();gp_Lin Line1v(l1end, gp_Dir(cos(Line1_angle + M_PI_2), sin(Line1_angle + M_PI_2), 0.));gp_Lin2d Line2v(gp_Pnt2d(l2end.X(), l2end.Y()), gp_Dir2d(cos(Line2_angle - M_PI_2), sin(Line2_angle - M_PI_2)));gp_Lin Line2v3d(l2end, gp_Dir(cos(Line2_angle - M_PI_2), sin(Line2_angle - M_PI_2), 0.));Handle(Geom_TrimmedCurve) L1v = GC_MakeSegment(Line1v, 0., Arc1_r);gp_Pnt l1vend = L1v->EndPoint();gp_Circ c1(gp_Ax2(l1vend, gp_Dir(0, 0, 1)), Arc1_r);Handle(Geom_TrimmedCurve) c1c = GC_MakeArcOfCircle(c1, l1end, Arc1_angle, 1);gp_Pnt c1end = c1c->EndPoint();gp_Lin2d Line3(gp_Pnt2d(c1end.X(), c1end.Y()), gp_Dir2d(l2end.X() - c1end.X(), l2end.Y() - c1end.Y()));gp_Lin2d Line3v = Line3.Normal(gp_Pnt2d((l2end.X() + c1end.X()) / 2, (l2end.Y() + c1end.Y()) / 2));IntAna2d_AnaIntersection aIntAna;aIntAna.Perform(Line2v, Line3v);IntAna2d_IntPoint aIntPoint = aIntAna.Point(1);gp_Pnt o2(aIntPoint.Value().X(), aIntPoint.Value().Y(), 0.);Handle(Geom_TrimmedCurve) L2v = GC_MakeSegment(Line2v3d, l2end, o2);Standard_Real r2 = L2v->LastParameter();gp_Circ c2(gp_Ax2(o2, gp_Dir(0, 0, 1)), r2);Handle(Geom_TrimmedCurve) c2c = GC_MakeArcOfCircle(c2, c1end, l2end, 0);gp_Pnt c2low = c2c->Value(M_PI_2);TopoDS_Edge c1ce = BRepBuilderAPI_MakeEdge(c1c);TopoDS_Edge L1ev = BRepBuilderAPI_MakeEdge(L1v);TopoDS_Edge c2ce = BRepBuilderAPI_MakeEdge(c2c);TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(Line1_p1, Line2_p1);TopTools_ListOfShape listEdge;listEdge.Append(anEdge);listEdge.Append(L1e);listEdge.Append(c1ce);listEdge.Append(c2ce);listEdge.Append(L2e);BRepBuilderAPI_MakeWire mw;mw.Add(listEdge);mw.Build();TopoDS_Face out = BRepBuilderAPI_MakeFace(mw);gp_Circ  cutcircle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 0.406 / 2);TopoDS_Edge cute = BRepBuilderAPI_MakeEdge(cutcircle);TopoDS_Wire cutw = BRepBuilderAPI_MakeWire(cute);TopoDS_Face cutf = BRepBuilderAPI_MakeFace(cutw);//平移:gp_Trsf theTransformation1;gp_Vec theVectorOfTranslation1(-c2low.X(), -c2low.Y(), 0.);theTransformation1.SetTranslation(theVectorOfTranslation1);BRepBuilderAPI_Transform myBRepTransformation1(out, theTransformation1);TopoDS_Shape outzero = myBRepTransformation1.Shape();TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(outzero, cutf);gp_Trsf theTransformation2;gp_Vec theVectorOfTranslation2(0., 0.125 / 2, 0.);theTransformation2.SetTranslation(theVectorOfTranslation2);//绕一个轴旋转:gp_Trsf theTransformation3;gp_Ax1 axez = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0., 0., 1.));theTransformation3.SetRotation(axez, -90 * M_PI / 180);gp_Trsf theTransformation4;gp_Ax1 axex = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1., 0., 0.));theTransformation4.SetRotation(axex, -50 * M_PI / 180);BRepBuilderAPI_Transform myBRepTransformation(theCommonSurface, theTransformation4 * theTransformation3 * theTransformation2);TopoDS_Shape TransformedShape = myBRepTransformation.Shape();return TransformedShape;
}
TopoDS_Shape getShapeOnPosition(TopoDS_Shape myProfile,Handle(BRepFill_LocationLaw) myLoc,Standard_Real pos, Standard_Real a, Standard_Real b, gp_Trsf myTrsf)
{TopoDS_Shape myPos;Handle(GeomFill_LocationLaw) law;gp_Mat M;gp_Vec V;gp_Trsf fila;Standard_Real first, last;myLoc->Law(1)->GetDomain(first, last);Standard_Real px = (pos - a) / (b - a);myLoc->Law(1)->D0(px, M, V);fila.SetValues(M(1, 1), M(1, 2), M(1, 3), V.X(),M(2, 1), M(2, 2), M(2, 3), V.Y(),M(3, 1), M(3, 2), M(3, 3), V.Z());fila.Multiply(myTrsf);myPos = myProfile;TopLoc_Location LocPos(fila);if (!LocPos.IsIdentity()) {//myFirst.Location( LocFirst.Multiplied(myProfile.Location()) );myPos = BRepBuilderAPI_Transform(myProfile, fila, Standard_True); //copy}ShapeUpgrade_RemoveLocations RemLoc;RemLoc.SetRemoveLevel(TopAbs_COMPOUND);RemLoc.Remove(myPos);myPos = RemLoc.GetResult();return myPos;
}
int main(int argc, char* argv[])
{gp_Dir  Z(0.0, 0.0, 1.0);gp_Pnt center(0, 0, 0.0);gp_Pnt xr(0.5, 0, 0.0);gp_Pnt yr(0.0, 1.0, 0.0);gp_Pnt zr(0.0, 0.0, 7.0);gp_Ax2  wb(center, Z);gp_Circ  wbcircle(wb, 0.125 / 2);TopoDS_Edge wbe = BRepBuilderAPI_MakeEdge(wbcircle);TopoDS_Edge xline = BRepBuilderAPI_MakeEdge(center, xr);TopoDS_Edge yline = BRepBuilderAPI_MakeEdge(center, yr);TopoDS_Edge zline = BRepBuilderAPI_MakeEdge(center, zr);//creat a profile of gringing wheelTopoDS_Shape gw = createGrindingwheel();//creat a cylinder surfaceHandle(Geom_CylindricalSurface) aCylinder = new Geom_CylindricalSurface(gp::XOY(), 0.306 / 2);TopoDS_Shape cF = BRepBuilderAPI_MakeFace(aCylinder->Cylinder(), 0, 2 * M_PI, 0, 3.);TopoDS_Solid cys = BRepPrimAPI_MakeCylinder(gp::XOY(), 0.306 / 2, 7);TopoDS_Edge aE = createHelix(0.306 / 2, M_PI / 4, 6.);TopoDS_Wire spine = BRepBuilderAPI_MakeWire(aE);//crate a sweep surfaceTopoDS_Shape pipe = BRepOffsetAPI_MakePipe(spine, gw, GeomFill_IsFrenet, 1);TopoDS_Wire mySpine;TopoDS_Shape myProfile;TopoDS_Shape myShape;gp_Trsf myTrsf;Handle(BRepFill_LocationLaw) myLoc;Handle(TopTools_HArray2OfShape) mySections;Handle(TopTools_HArray2OfShape) myFaces;Handle(TopTools_HArray2OfShape) myEdges;TopTools_MapOfShape myReversedEdges;BRepFill_DataMapOfShapeHArray2OfShape myTapes;BRepFill_DataMapOfShapeHArray2OfShape myRails;Standard_Integer myCurIndexOfSectionEdge;TopoDS_Shape myFirst;TopoDS_Shape myLast;TopTools_DataMapOfShapeListOfShape myGenMap;Standard_Integer myDegmax;Standard_Integer mySegmax;GeomAbs_Shape myContinuity;GeomFill_Trihedron myMode;Standard_Boolean myForceApproxC1;Standard_Real myErrorOnSurf;mySections.Nullify();myFaces.Nullify();myEdges.Nullify();mySpine = spine;myProfile = gw;TopoDS_Shape TheProf;Handle(GeomFill_TrihedronLaw) TLaw;TLaw = new GeomFill_Frenet();Handle(GeomFill_CurveAndTrihedron) Loc = new (GeomFill_CurveAndTrihedron) (TLaw);myLoc = new (BRepFill_Edge3DLaw) (mySpine, Loc);if (myLoc->NbLaw() == 0) {return 0; // Degenerated case}myLoc->TransformInG0Law(); // Set into continuityBRepFill_SectionPlacement Place(myLoc, gw);myTrsf = Place.Transformation();TopLoc_Location Loc2(myTrsf), Loc1;Loc1 = gw.Location();TopoDS_Shape aux;TheProf = myProfile;TheProf.Location(Loc2.Multiplied(Loc1));// Construct First && Last ShapeHandle(GeomFill_LocationLaw) law;gp_Mat M;gp_Vec V;gp_Trsf fila;Standard_Real first,last;myLoc->Law(1)->GetDomain(first, last);std::cout << "first=" <<first<< std::endl;std::cout << "last=" << last << std::endl;std::cout << "myLoc->NbLaw()=" << myLoc->NbLaw() << std::endl;myLoc->Law(1)->D0(first, M, V);fila.SetValues(M(1, 1), M(1, 2), M(1, 3), V.X(),M(2, 1), M(2, 2), M(2, 3), V.Y(),M(3, 1), M(3, 2), M(3, 3), V.Z());fila.Multiply(myTrsf);TopLoc_Location LocFirst(fila);myFirst = myProfile;if (!LocFirst.IsIdentity()) {//myFirst.Location( LocFirst.Multiplied(myProfile.Location()) );myFirst = BRepBuilderAPI_Transform(myProfile, fila, Standard_True); //copy}ShapeUpgrade_RemoveLocations RemLoc;RemLoc.SetRemoveLevel(TopAbs_COMPOUND);RemLoc.Remove(myFirst);myFirst = RemLoc.GetResult();myLoc->Law(myLoc->NbLaw())->GetDomain(first, last);myLoc->Law(myLoc->NbLaw())->D0(last, M, V);//    try { // Not good, but there are no other means to test SetValuesfila.SetValues(M(1, 1), M(1, 2), M(1, 3), V.X(),M(2, 1), M(2, 2), M(2, 3), V.Y(),M(3, 1), M(3, 2), M(3, 3), V.Z());fila.Multiply(myTrsf);TopLoc_Location LocLast(fila);if (!myLoc->IsClosed() || LocFirst != LocLast) {myLast = myProfile;if (!LocLast.IsIdentity()) {//myLast.Location(LocLast.Multiplied(myProfile.Location()) );myLast = BRepBuilderAPI_Transform(myProfile, fila, Standard_True); //copy}}else {myLast = myFirst;}RemLoc.Remove(myLast);myLast = RemLoc.GetResult();TopoDS_Shape md1 = getShapeOnPosition(myProfile, myLoc, 0.2, 0., 6., myTrsf);TopoDS_Shape md2 = getShapeOnPosition(myProfile, myLoc, 0.4, 0., 6., myTrsf);TopoDS_Shape md3 = getShapeOnPosition(myProfile, myLoc, 0.6, 0., 6., myTrsf);TopoDS_Shape md4 = getShapeOnPosition(myProfile, myLoc, 0.8, 0., 6., myTrsf);TopoDS_Shape md5 = getShapeOnPosition(myProfile, myLoc, 1.0, 0., 6., myTrsf);Viewer vout(50, 50, 500, 500);vout << wbe;vout << xline;vout << yline;vout << zline;vout << myProfile;vout << myLast;vout << spine;vout << md1;vout << md2;vout << md3;vout << md4;vout << md5;vout.StartMessageLoop();return 0;
}

3、使用的dll

TKernel.lib

TKMath.lib

TKTopAlgo.lib

TKBRep.lib

TKPrim.lib

TKOpenGl.lib

TKService.lib

TKV3d.lib

kernel32.lib

user32.lib

gdi32.lib

TKBinXCAF.lib

TKSTEP.lib

TKSTEP209.lib

TKSTEPAttr.lib

TKSTEPBase.lib

TKXSBase.lib

TKGeomBase.lib

TKG3d.lib

TKG2d.lib

TKShHealing.lib

TKGeomAlgo.lib

TKOffset.lib

TKBO.lib

TKFeat.lib

TKFillet.lib

TKBool.lib

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/791592.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

iOS使用CoreML运用小型深度神经网络架构对图像进行解析

查找一个图片选择器 我用的是ImagePicker 项目有点老了&#xff0c;需要做一些改造&#xff0c;下面是新的仓库 platform :ios, 16.0use_frameworks!target learnings dosource https://github.com/CocoaPods/Specs.gitpod ImagePicker, :git > https://github.com/KevinS…

Python之Opencv进阶教程(1):图片模糊

1、Opencv提供了多种模糊图片的方法 加载原始未经模糊处理的图片 import cv2 as cvimg cv.imread(../Resources/Photos/girl.jpg) cv.imshow(girl, img)1.1 平均值 关键代码 # Averaging 平均值 average cv.blur(img, (3, 3)) cv.imshow(Average Blur, average)实现效果 1.2…

STM32F407 FSMC并口读取AD7606

先贴一下最终效果图.这个是AD7606并口读取数据一个周期后的数据结果. 原始波形用示波器看是很平滑的. AD7606不知为何就会出现干扰, 我猜测可能是数字信号干扰导致的. 因为干扰的波形很有规律. 这种现象基本上可以排除是程序问题. 应该是干扰或者数字信号干扰,或者是数字和模拟…

基于Spring Boot的餐厅点餐系统

基于Spring Boot的餐厅点餐系统 开发语言&#xff1a;Java框架&#xff1a;springbootJDK版本&#xff1a;JDK1.8数据库工具&#xff1a;Navicat11开发软件&#xff1a;eclipse/myeclipse/ideaMaven包&#xff1a;Maven3.3.9 部分系统展示 管理员登录界面 用户注册登录界面 …

​如何使用ArcGIS Pro进行洪水淹没分析

洪水淹没分析是一种常见的水文地理信息系统应用&#xff0c;用于模拟和预测洪水事件中可能受到淹没影响的地区&#xff0c;这里为大家介绍一下ArcGIS Pro进行洪水淹没分析的方法&#xff0c;希望能对你有所帮助。 数据来源 教程所使用的数据是从水经微图中下载的DEM数据&…

Python学习笔记-Flask接收post请求数据并存储数据库

1.引包 from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy 2.配置连接,替换为自己的MySQL 数据库的实际用户名、密码和数据库名 app Flask(__name__) #创建应用实列 app.config[SQLALCHEMY_DATABASE_URI] mysqlpymysql://ro…

鸿蒙OS开发实例:【应用事件打点】

简介 传统的日志系统里汇聚了整个设备上所有程序运行的过程流水日志&#xff0c;难以识别其中的关键信息。因此&#xff0c;应用开发者需要一种数据打点机制&#xff0c;用来评估如访问数、日活、用户操作习惯以及影响用户使用的关键因素等关键信息。 HiAppEvent是在系统层面…

适用于 Linux 的 Windows 子系统安装初体验

1、简述 Windows Subsystem for Linux (WSL) 是 Windows 的一项功能&#xff0c;允许您在 Windows 计算机上运行 Linux 环境&#xff0c;而无需单独的虚拟机或双重启动。 WSL 旨在为想要同时使用 Windows 和 Linux 的开发人员提供无缝且高效的体验。 使用 WSL 安装和运行各种 L…

【javaScript】DOM编程入门

一、什么是DOM编程 概念&#xff1a;DOM(Document Object Model)编程就是使用document对象的API完成对网页HTML文档进行动态修改&#xff0c;以实现网页数据和样式动态变化的编程 为什么要由DOM编程来动态修改呢&#xff1f;我们就得先理解网页的运行原理&#xff1a; 如上图&a…

IO流:字节流、字符流、缓冲流、转换流、数据流、序列化流 --Java学习笔记

目录 IO流 IO流的分类 IO流的体系 字节流&#xff1a; 1、Filelnputstream(文件字节输入流) 2、FileOutputStream(文件字节输出流) 字节流非常适合做一切文件的复制操作 复制案例&#xff1a; try-catch-finally 和 try-with-resource 字符流 1、FileReader(文件字符…

ALPHA开发板上的PHY芯片驱动:LAN8720驱动

一. 简介 前面文章了解到&#xff0c;Linux内核是有提供 PHY通用驱动的。 本文来简单了解一下ALPHA开发板上的 PHY网络芯片LAN8720的驱动。是 LAN8720芯片的公司提供的 PHY驱动。 二. ALPHA开发板上的PHY芯片驱动&#xff1a;LAN8720驱动 我 们 来 看 一 下 LAN8720A 的 …

输入url到页面显示过程的优化

浏览器架构 线程&#xff1a;操作系统能够进行运算调度的最小单位。 进程&#xff1a;操作系统最核心的就是进程&#xff0c;他是操作系统进行资源分配和调度的基本单位。 一个进程就是一个程序的运行实例。启动一个程序的时候&#xff0c;操作系统会为该程序创建一块内存&a…

HDLbits 刷题 --Always nolatches

学习: Your circuit has one 16-bit input, and four outputs. Build this circuit that recognizes these four scancodes and asserts the correct output. To avoid creating latches, all outputs must be assigned a value in all possible conditions (See also always…

【HTML】简单制作一个3D动画效果重叠圆环

目录 前言 开始 HTML部分 CSS部分 效果图 总结 前言 无需多言&#xff0c;本文将详细介绍一段代码&#xff0c;具体内容如下&#xff1a; 开始 首先新建文件夹&#xff0c;创建两个文本文档&#xff0c;其中HTML的文件名改为[index.html]&#xff0c;CSS的…

搞学术研究好用免费的学术版ChatGPT网站-学术AI

学术版ChatGPThttps://chat.uaskgpt.com/mobile/?user_sn88&channelcsdn&scenelogin 推荐一个非常适合中国本科硕士博士等学生老师使用的学术版ChatGPT&#xff0c; 对接了超大型学术模型&#xff0c;利用AI技术实现学术润色、中英文翻译&#xff0c;学术纠错&#…

centOS如何升级python

centOS下升级python版本的详细步骤 1、可利用linux自带下载工具wget下载&#xff0c;如下所示&#xff1a; 笔者安装的是最小centos系统&#xff0c;所以使用编译命令前&#xff0c;必须安装wget服务&#xff0c;读者如果安装的是界面centos系统&#xff0c;或者使用过编译工具…

在 Amazon Timestream 上通过时序数据机器学习进行预测分析

由于不断变化的需求和现代化基础设施的动态性质&#xff0c;为大型应用程序规划容量可能会非常困难。例如&#xff0c;传统的反应式方法依赖于某些 DevOps 指标&#xff08;如 CPU 和内存&#xff09;的静态阈值&#xff0c;而这些指标在这样的环境中并不足以解决问题。在这篇文…

Stable Diffusion 本地化部署

一、前言 最近在家背八股文背诵得快吐了&#xff0c;烦闷的时候&#xff0c;看到使用 AI 进行作图&#xff0c;可以使用本地话部署。刚好自己家里的电脑&#xff0c;之前买来玩暗黑4&#xff0c;配置相对来说来可以&#xff0c;就拿来试试。 此篇是按照 Github 上的 stable-d…

Android JNI基础

目录 一、JNI简介1.1 什么是JNI1.2 用途1.3 优点 二、初探JNI2.1 新建cpp\cmake2.2 build.gradle配置2.3 java层配置2.4 cmake和c 三、API详解3.1 JNI API3.1.1 数据类型3.1.2 方法 3.2 CMake脚本 四、再探JNI 一、JNI简介 1.1 什么是JNI JNI&#xff08;Java Native Interfa…

适配器: stack与queue

模板的使用 容器的复用 传容器: 控制底层是那个控制传仿函数: 控制大小堆的建立 stack 特点: 后进先出底层: 容器的封装(vector, list, dequeue)场景: 模拟递归, 函数压栈等接口:empty(), size(), top(), push(), pop()代码: stack queue 特点: 先进先出底层: 容器的封装…