+ add method to get intersection of two curves

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5414 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2012-01-17 15:08:47 +00:00
parent ce9a0bc54e
commit 1bb663c897
2 changed files with 45 additions and 0 deletions

View File

@ -41,6 +41,11 @@
<UserDocu>Make a ruled surface of this and the given curves</UserDocu> <UserDocu>Make a ruled surface of this and the given curves</UserDocu>
</Documentation> </Documentation>
</Methode> </Methode>
<Methode Name="intersect2d">
<Documentation>
<UserDocu>Get intersection points with another curve lying on a plane.</UserDocu>
</Documentation>
</Methode>
<Methode Name="parameter"> <Methode Name="parameter">
<Documentation> <Documentation>
<UserDocu>Returns the parameter on the curve <UserDocu>Returns the parameter on the curve

View File

@ -26,9 +26,13 @@
# include <BRepBuilderAPI_MakeEdge.hxx> # include <BRepBuilderAPI_MakeEdge.hxx>
# include <gp_Dir.hxx> # include <gp_Dir.hxx>
# include <gp_Vec.hxx> # include <gp_Vec.hxx>
# include <gp_Pln.hxx>
# include <GCPnts_UniformAbscissa.hxx> # include <GCPnts_UniformAbscissa.hxx>
# include <Geom2dAPI_InterCurveCurve.hxx>
# include <GeomAPI.hxx>
# include <Geom_Geometry.hxx> # include <Geom_Geometry.hxx>
# include <Geom_Curve.hxx> # include <Geom_Curve.hxx>
# include <Geom_Plane.hxx>
# include <Geom_Surface.hxx> # include <Geom_Surface.hxx>
# include <GeomAdaptor_Curve.hxx> # include <GeomAdaptor_Curve.hxx>
# include <GeomFill.hxx> # include <GeomFill.hxx>
@ -48,6 +52,7 @@
#include "GeometryCurvePy.cpp" #include "GeometryCurvePy.cpp"
#include "RectangularTrimmedSurfacePy.h" #include "RectangularTrimmedSurfacePy.h"
#include "BSplineSurfacePy.h" #include "BSplineSurfacePy.h"
#include "PlanePy.h"
#include "TopoShape.h" #include "TopoShape.h"
#include "TopoShapePy.h" #include "TopoShapePy.h"
@ -261,6 +266,41 @@ PyObject* GeometryCurvePy::makeRuledSurface(PyObject *args)
return 0; return 0;
} }
PyObject* GeometryCurvePy::intersect2d(PyObject *args)
{
PyObject *c,*p;
if (!PyArg_ParseTuple(args, "O!O!", &(Part::GeometryCurvePy::Type), &c,
&(Part::PlanePy::Type), &p))
return 0;
try {
Handle_Geom_Curve self = Handle_Geom_Curve::DownCast(getGeometryPtr()->handle());
Handle_Geom_Curve curv = Handle_Geom_Curve::DownCast(static_cast<GeometryPy*>(c)->
getGeometryPtr()->handle());
Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast(static_cast<GeometryPy*>(p)->
getGeometryPtr()->handle());
Handle_Geom2d_Curve curv1 = GeomAPI::To2d(self, plane->Pln());
Handle_Geom2d_Curve curv2 = GeomAPI::To2d(curv, plane->Pln());
Geom2dAPI_InterCurveCurve intCC(curv1, curv2);
int nbPoints = intCC.NbPoints();
Py::List list;
for (int i=1; i<= nbPoints; i++) {
gp_Pnt2d pt = intCC.Point(i);
Py::Tuple tuple(2);
tuple.setItem(0, Py::Float(pt.X()));
tuple.setItem(1, Py::Float(pt.Y()));
list.append(tuple);
}
return Py::new_reference_to(list);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
}
Py::Float GeometryCurvePy::getFirstParameter(void) const Py::Float GeometryCurvePy::getFirstParameter(void) const
{ {
return Py::Float(Handle_Geom_Curve::DownCast return Py::Float(Handle_Geom_Curve::DownCast