Parameter transformation
This commit is contained in:
@@ -166,23 +166,31 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
// ====== Methods ======================================================================
|
||||
|
||||
double TopoShapeEdgePy::getNormalizedParameter(double u) const
|
||||
PyObject* TopoShapeEdgePy::getParameterByLength(PyObject *args)
|
||||
{
|
||||
#if 0
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
// normalizing parameter space to length
|
||||
// transform value of [0,Length] to [First,Last]
|
||||
double first = BRepLProp_CurveTool::FirstParameter(adapt);
|
||||
double last = BRepLProp_CurveTool::LastParameter(adapt);
|
||||
if (!Precision::IsInfinite(first) && !Precision::IsInfinite(last)) {
|
||||
double length = GCPnts_AbscissaPoint::Length(adapt);
|
||||
|
||||
if (u < 0 || u > length) {
|
||||
PyErr_SetString(PyExc_ValueError, "value out of range");
|
||||
return 0;
|
||||
}
|
||||
|
||||
double stretch = (last - first) / length;
|
||||
u = first + u*stretch;
|
||||
}
|
||||
#endif
|
||||
|
||||
return u;
|
||||
return PyFloat_FromDouble(u);
|
||||
}
|
||||
|
||||
PyObject* TopoShapeEdgePy::valueAt(PyObject *args)
|
||||
@@ -194,8 +202,6 @@ PyObject* TopoShapeEdgePy::valueAt(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
// Check now the orientation of the edge to make
|
||||
// sure that we get the right wanted point!
|
||||
BRepLProp_CLProps prop(adapt,u,0,Precision::Confusion());
|
||||
@@ -241,8 +247,6 @@ PyObject* TopoShapeEdgePy::tangentAt(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
if (prop.IsTangentDefined()) {
|
||||
gp_Dir dir;
|
||||
@@ -264,8 +268,6 @@ PyObject* TopoShapeEdgePy::normalAt(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
gp_Dir V ;
|
||||
@@ -288,8 +290,6 @@ PyObject* TopoShapeEdgePy::curvatureAt(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
double C = prop.Curvature();
|
||||
@@ -311,8 +311,6 @@ PyObject* TopoShapeEdgePy::centerOfCurvatureAt(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
gp_Pnt V ;
|
||||
@@ -335,8 +333,6 @@ PyObject* TopoShapeEdgePy::derivative1At(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,1,Precision::Confusion());
|
||||
const gp_Vec& V = prop.D1();
|
||||
@@ -358,8 +354,6 @@ PyObject* TopoShapeEdgePy::derivative2At(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
const gp_Vec& V = prop.D2();
|
||||
@@ -381,8 +375,6 @@ PyObject* TopoShapeEdgePy::derivative3At(PyObject *args)
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
u = getNormalizedParameter(u);
|
||||
|
||||
try {
|
||||
BRepLProp_CLProps prop(adapt,u,3,Precision::Confusion());
|
||||
const gp_Vec& V = prop.D3();
|
||||
|
||||
Reference in New Issue
Block a user