Parameter transformation
This commit is contained in:
parent
b3738a2fce
commit
babcf2f027
|
@ -14,14 +14,19 @@
|
|||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="Juergen.Riegel@web.de" />
|
||||
<UserDocu>TopoShapeEdge is the OpenCasCade topological edge wrapper</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="tangentAt">
|
||||
<Methode Name="getParameterByLength">
|
||||
<Documentation>
|
||||
<UserDocu>float = getParameterByLength(float) - Return parameter [First,Last]. Input value must be of [0|Length]</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="tangentAt">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = tangentAt(pos) - Get the tangent at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = tangentAt(pos) - Get the tangent at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="valueAt">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = valueAt(pos) - Get the point at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = valueAt(pos) - Get the point at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="parameterAt">
|
||||
|
@ -31,32 +36,32 @@
|
|||
</Methode>
|
||||
<Methode Name="normalAt">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = normalAt(pos) - Get the normal vector at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = normalAt(pos) - Get the normal vector at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="derivative1At">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = d1At(pos) - Get the first derivative at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = d1At(pos) - Get the first derivative at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="derivative2At">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = d2At(pos) - Get the second derivative at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = d2At(pos) - Get the second derivative at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="derivative3At">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = d3At(pos) - Get the third derivative at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = d3At(pos) - Get the third derivative at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="curvatureAt">
|
||||
<Documentation>
|
||||
<UserDocu>Float = curvatureAt(pos) - Get the curvature at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Float = curvatureAt(pos) - Get the curvature at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="centerOfCurvatureAt">
|
||||
<Documentation>
|
||||
<UserDocu>Vector = centerOfCurvatureAt(float pos) - Get the center of curvature at the given parameter [0|Length] if defined</UserDocu>
|
||||
<UserDocu>Vector = centerOfCurvatureAt(float pos) - Get the center of curvature at the given parameter [First|Last] if defined</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setTolerance">
|
||||
|
@ -132,8 +137,6 @@ absolute Cartesian coordinate system.</UserDocu>
|
|||
<Parameter Name="Degenerated" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<ClassDeclarations>
|
||||
private:
|
||||
double getNormalizedParameter(double) const;
|
||||
</ClassDeclarations>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user