Replace makeTube algorithm
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <BRepAdaptor_HCurve.hxx>
|
||||
# include <BRepAdaptor_HCompCurve.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepAlgoAPI_Common.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
@@ -1343,7 +1345,8 @@ TopoDS_Shape TopoShape::makePipeShell(const TopTools_ListOfShape& profiles,
|
||||
return mkPipeShell.Shape();
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::makeTube(double radius, double tol) const
|
||||
#if 0
|
||||
TopoDS_Shape TopoShape::makeTube() const
|
||||
{
|
||||
// http://opencascade.blogspot.com/2009/11/surface-modeling-part3.html
|
||||
if (this->_Shape.IsNull())
|
||||
@@ -1378,43 +1381,54 @@ TopoDS_Shape TopoShape::makeTube(double radius, double tol) const
|
||||
);
|
||||
return mkBuilder.Face();
|
||||
}
|
||||
|
||||
// for testing
|
||||
static Handle(Law_Function) CreateBsFunction (const Standard_Real theFirst, const Standard_Real theLast)
|
||||
#else
|
||||
static Handle(Law_Function) CreateBsFunction (const Standard_Real theFirst, const Standard_Real theLast, const Standard_Real theRadius)
|
||||
{
|
||||
//Handle_Law_BSpline aBs;
|
||||
//Handle_Law_BSpFunc aFunc = new Law_BSpFunc (aBs, theFirst, theLast);
|
||||
Handle_Law_Linear aFunc = new Law_Linear();
|
||||
aFunc->Set(theFirst, 2.0, theLast, 3.0);
|
||||
aFunc->Set(theFirst, theRadius, theLast, theRadius);
|
||||
return aFunc;
|
||||
}
|
||||
|
||||
// for testing
|
||||
TopoDS_Shape TopoShape::makeTube() const
|
||||
TopoDS_Shape TopoShape::makeTube(double radius, double tol, int cont, int maxdegree, int maxsegm) const
|
||||
{
|
||||
// http://opencascade.blogspot.com/2009/11/surface-modeling-part3.html
|
||||
Standard_Real theTol = 0.001;
|
||||
Standard_Real theTol = tol;
|
||||
Standard_Boolean theIsPolynomial = Standard_True;
|
||||
Standard_Boolean myIsElem = Standard_True;
|
||||
GeomAbs_Shape theContinuity = GeomAbs_G1;
|
||||
Standard_Integer theMaxDegree = 3;
|
||||
Standard_Integer theMaxSegment = 1000;
|
||||
GeomAbs_Shape theContinuity = GeomAbs_Shape(cont);
|
||||
Standard_Integer theMaxDegree = maxdegree;
|
||||
Standard_Integer theMaxSegment = maxsegm;
|
||||
|
||||
if (this->_Shape.IsNull())
|
||||
Standard_Failure::Raise("Cannot sweep along empty spine");
|
||||
if (this->_Shape.ShapeType() != TopAbs_EDGE)
|
||||
Standard_Failure::Raise("Spine shape is not an edge");
|
||||
|
||||
const TopoDS_Edge& path_edge = TopoDS::Edge(this->_Shape);
|
||||
BRepAdaptor_Curve path_adapt(path_edge);
|
||||
Handle(Adaptor3d_HCurve) myPath;
|
||||
if (this->_Shape.ShapeType() == TopAbs_EDGE) {
|
||||
const TopoDS_Edge& path_edge = TopoDS::Edge(this->_Shape);
|
||||
BRepAdaptor_Curve path_adapt(path_edge);
|
||||
myPath = new BRepAdaptor_HCurve(path_adapt);
|
||||
theContinuity = GeomAbs_C0;
|
||||
}
|
||||
//else if (this->_Shape.ShapeType() == TopAbs_WIRE) {
|
||||
// const TopoDS_Wire& path_wire = TopoDS::Wire(this->_Shape);
|
||||
// BRepAdaptor_CompCurve path_adapt(path_wire);
|
||||
// myPath = new BRepAdaptor_HCompCurve(path_adapt);
|
||||
//}
|
||||
//else {
|
||||
// Standard_Failure::Raise("Spine shape is neither an edge nor a wire");
|
||||
//}
|
||||
else {
|
||||
Standard_Failure::Raise("Spine shape is not an edge");
|
||||
}
|
||||
|
||||
//circular profile
|
||||
Handle(Geom_Circle) aCirc = new Geom_Circle (gp::XOY(), 1.0);
|
||||
Handle(Geom_Circle) aCirc = new Geom_Circle (gp::XOY(), radius);
|
||||
aCirc->Rotate (gp::OZ(), Standard_PI/2.);
|
||||
|
||||
//perpendicular section
|
||||
Handle(BRepAdaptor_HCurve) myPath = new BRepAdaptor_HCurve(path_adapt);
|
||||
Handle(Law_Function) myEvol = ::CreateBsFunction (myPath->FirstParameter(), myPath->LastParameter());
|
||||
Handle(Law_Function) myEvol = ::CreateBsFunction (myPath->FirstParameter(), myPath->LastParameter(), radius);
|
||||
Handle(GeomFill_SectionLaw) aSec = new GeomFill_EvolvedSection(aCirc, myEvol);
|
||||
Handle(GeomFill_LocationLaw) aLoc = new GeomFill_CurveAndTrihedron(new GeomFill_CorrectedFrenet);
|
||||
aLoc->SetCurve (myPath);
|
||||
@@ -1438,6 +1452,7 @@ TopoDS_Shape TopoShape::makeTube() const
|
||||
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
#endif
|
||||
|
||||
TopoDS_Shape TopoShape::makeSweep(const TopoDS_Shape& profile, double tol, int fillMode) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user