+ improve the plane fit from REEN module
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
# include <BRepFill.hxx>
|
||||
# include <BRepLib.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Ax3.hxx>
|
||||
# include <gp_Pnt.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
# include <GCE2d_MakeSegment.hxx>
|
||||
@@ -576,10 +577,11 @@ static PyObject * makeSolid(PyObject *self, PyObject *args)
|
||||
static PyObject * makePlane(PyObject *self, PyObject *args)
|
||||
{
|
||||
double length, width;
|
||||
PyObject *pPnt=0, *pDir=0;
|
||||
if (!PyArg_ParseTuple(args, "dd|O!O!", &length, &width,
|
||||
&(Base::VectorPy::Type), &pPnt,
|
||||
&(Base::VectorPy::Type), &pDir))
|
||||
PyObject *pPnt=0, *pDirZ=0, *pDirX=0;
|
||||
if (!PyArg_ParseTuple(args, "dd|O!O!O!", &length, &width,
|
||||
&(Base::VectorPy::Type), &pPnt,
|
||||
&(Base::VectorPy::Type), &pDirZ,
|
||||
&(Base::VectorPy::Type), &pDirX))
|
||||
return NULL;
|
||||
|
||||
if (length < Precision::Confusion()) {
|
||||
@@ -598,11 +600,21 @@ static PyObject * makePlane(PyObject *self, PyObject *args)
|
||||
Base::Vector3d pnt = static_cast<Base::VectorPy*>(pPnt)->value();
|
||||
p.SetCoord(pnt.x, pnt.y, pnt.z);
|
||||
}
|
||||
if (pDir) {
|
||||
Base::Vector3d vec = static_cast<Base::VectorPy*>(pDir)->value();
|
||||
if (pDirZ) {
|
||||
Base::Vector3d vec = static_cast<Base::VectorPy*>(pDirZ)->value();
|
||||
d.SetCoord(vec.x, vec.y, vec.z);
|
||||
}
|
||||
Handle_Geom_Plane aPlane = new Geom_Plane(p, d);
|
||||
Handle_Geom_Plane aPlane;
|
||||
if (pDirX) {
|
||||
Base::Vector3d vec = static_cast<Base::VectorPy*>(pDirX)->value();
|
||||
gp_Dir dx;
|
||||
dx.SetCoord(vec.x, vec.y, vec.z);
|
||||
aPlane = new Geom_Plane(gp_Ax3(p, d, dx));
|
||||
}
|
||||
else {
|
||||
aPlane = new Geom_Plane(p, d);
|
||||
}
|
||||
|
||||
BRepBuilderAPI_MakeFace Face(aPlane, 0.0, length, 0.0, width
|
||||
#if OCC_VERSION_HEX >= 0x060502
|
||||
, Precision::Confusion()
|
||||
@@ -614,6 +626,10 @@ static PyObject * makePlane(PyObject *self, PyObject *args)
|
||||
PyErr_SetString(PyExc_Exception, "creation of plane failed");
|
||||
return NULL;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
PyErr_SetString(PyExc_Exception, "creation of plane failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject * makeBox(PyObject *self, PyObject *args)
|
||||
@@ -1688,8 +1704,8 @@ struct PyMethodDef Part_methods[] = {
|
||||
"makeSolid(shape) -- Create a solid out of the shells inside a shape."},
|
||||
|
||||
{"makePlane" ,makePlane ,METH_VARARGS,
|
||||
"makePlane(length,width,[pnt,dir]) -- Make a plane\n"
|
||||
"By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)"},
|
||||
"makePlane(length,width,[pnt,dirZ,dirX]) -- Make a plane\n"
|
||||
"By default pnt=Vector(0,0,0) and dirZ=Vector(0,0,1), dirX is ignored in this case"},
|
||||
|
||||
{"makeBox" ,makeBox ,METH_VARARGS,
|
||||
"makeBox(length,width,height,[pnt,dir]) -- Make a box located\n"
|
||||
|
||||
Reference in New Issue
Block a user