This commit adds getShape and setShape to TopoShape
This commit is contained in:
committed by
wmayer
parent
5a30a43862
commit
7f4a437cc2
@@ -125,7 +125,7 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
try {
|
||||
BRepBuilderAPI_MakeEdge mkEdge(curve, first, last);
|
||||
getTopoShapePtr()->_Shape = mkEdge.Edge();
|
||||
getTopoShapePtr()->setShape(mkEdge.Edge());
|
||||
return 0;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
@@ -138,8 +138,8 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) {
|
||||
TopoShape* shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
|
||||
if (shape && !shape->_Shape.IsNull() && shape->_Shape.ShapeType() == TopAbs_EDGE) {
|
||||
this->getTopoShapePtr()->_Shape = shape->_Shape;
|
||||
if (shape && !shape->getShape().IsNull() && shape->getShape().ShapeType() == TopAbs_EDGE) {
|
||||
this->getTopoShapePtr()->setShape(shape->getShape());
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
@@ -153,12 +153,12 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
&(Part::TopoShapeVertexPy::Type), &pcObj2)) {
|
||||
TopoShape* shape1 = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
|
||||
TopoShape* shape2 = static_cast<TopoShapePy*>(pcObj2)->getTopoShapePtr();
|
||||
const TopoDS_Vertex& v1 = TopoDS::Vertex(shape1->_Shape);
|
||||
const TopoDS_Vertex& v2 = TopoDS::Vertex(shape2->_Shape);
|
||||
const TopoDS_Vertex& v1 = TopoDS::Vertex(shape1->getShape());
|
||||
const TopoDS_Vertex& v2 = TopoDS::Vertex(shape2->getShape());
|
||||
|
||||
try {
|
||||
BRepBuilderAPI_MakeEdge mkEdge(v1, v2);
|
||||
getTopoShapePtr()->_Shape = mkEdge.Edge();
|
||||
getTopoShapePtr()->setShape(mkEdge.Edge());
|
||||
return 0;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
@@ -180,7 +180,7 @@ PyObject* TopoShapeEdgePy::getParameterByLength(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
// transform value of [0,Length] to [First,Last]
|
||||
@@ -207,7 +207,7 @@ PyObject* TopoShapeEdgePy::valueAt(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
// Check now the orientation of the edge to make
|
||||
@@ -226,11 +226,11 @@ PyObject* TopoShapeEdgePy::parameterAt(PyObject *args)
|
||||
return 0;
|
||||
|
||||
try {
|
||||
const TopoDS_Shape& v = static_cast<TopoShapePy*>(pnt)->getTopoShapePtr()->_Shape;
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Shape& v = static_cast<TopoShapePy*>(pnt)->getTopoShapePtr()->getShape();
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
|
||||
if (face) {
|
||||
const TopoDS_Shape& f = static_cast<TopoShapeFacePy*>(face)->getTopoShapePtr()->_Shape;
|
||||
const TopoDS_Shape& f = static_cast<TopoShapeFacePy*>(face)->getTopoShapePtr()->getShape();
|
||||
Standard_Real par = BRep_Tool::Parameter(TopoDS::Vertex(v), e, TopoDS::Face(f));
|
||||
return PyFloat_FromDouble(par);
|
||||
}
|
||||
@@ -252,7 +252,7 @@ PyObject* TopoShapeEdgePy::tangentAt(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
|
||||
@@ -273,7 +273,7 @@ PyObject* TopoShapeEdgePy::normalAt(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -295,7 +295,7 @@ PyObject* TopoShapeEdgePy::curvatureAt(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -316,7 +316,7 @@ PyObject* TopoShapeEdgePy::centerOfCurvatureAt(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -338,7 +338,7 @@ PyObject* TopoShapeEdgePy::derivative1At(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -359,7 +359,7 @@ PyObject* TopoShapeEdgePy::derivative2At(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -380,7 +380,7 @@ PyObject* TopoShapeEdgePy::derivative3At(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
|
||||
try {
|
||||
@@ -398,7 +398,7 @@ PyObject* TopoShapeEdgePy::derivative3At(PyObject *args)
|
||||
PyObject* TopoShapeEdgePy::discretize(PyObject *args, PyObject *kwds)
|
||||
{
|
||||
try {
|
||||
BRepAdaptor_Curve adapt(TopoDS::Edge(getTopoShapePtr()->_Shape));
|
||||
BRepAdaptor_Curve adapt(TopoDS::Edge(getTopoShapePtr()->getShape()));
|
||||
bool uniformAbscissaPoints = false;
|
||||
bool uniformAbscissaDistance = false;
|
||||
int numPoints = -1;
|
||||
@@ -568,7 +568,7 @@ PyObject* TopoShapeEdgePy::split(PyObject *args)
|
||||
return 0;
|
||||
|
||||
try {
|
||||
BRepAdaptor_Curve adapt(TopoDS::Edge(getTopoShapePtr()->_Shape));
|
||||
BRepAdaptor_Curve adapt(TopoDS::Edge(getTopoShapePtr()->getShape()));
|
||||
Standard_Real f = adapt.FirstParameter();
|
||||
Standard_Real l = adapt.LastParameter();
|
||||
|
||||
@@ -636,8 +636,8 @@ PyObject* TopoShapeEdgePy::isSeam(PyObject *args)
|
||||
return 0;
|
||||
|
||||
try {
|
||||
const TopoDS_Edge& e = TopoDS::Edge(this->getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Face& f = TopoDS::Face(static_cast<TopoShapeFacePy*>(face)->getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(this->getTopoShapePtr()->getShape());
|
||||
const TopoDS_Face& f = TopoDS::Face(static_cast<TopoShapeFacePy*>(face)->getTopoShapePtr()->getShape());
|
||||
|
||||
ShapeAnalysis_Edge sa;
|
||||
Standard_Boolean ok = sa.IsSeam(e, f);
|
||||
@@ -656,7 +656,7 @@ PyObject* TopoShapeEdgePy::setTolerance(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "d", &tol))
|
||||
return 0;
|
||||
BRep_Builder aBuilder;
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
aBuilder.UpdateEdge(e, tol);
|
||||
Py_Return;
|
||||
}
|
||||
@@ -665,27 +665,27 @@ PyObject* TopoShapeEdgePy::setTolerance(PyObject *args)
|
||||
|
||||
Py::Float TopoShapeEdgePy::getTolerance(void) const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
return Py::Float(BRep_Tool::Tolerance(e));
|
||||
}
|
||||
|
||||
void TopoShapeEdgePy::setTolerance(Py::Float tol)
|
||||
{
|
||||
BRep_Builder aBuilder;
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
aBuilder.UpdateEdge(e, (double)tol);
|
||||
}
|
||||
|
||||
Py::Float TopoShapeEdgePy::getLength(void) const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
return Py::Float(GCPnts_AbscissaPoint::Length(adapt));
|
||||
}
|
||||
|
||||
Py::Object TopoShapeEdgePy::getCurve() const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
switch(adapt.GetType())
|
||||
{
|
||||
@@ -753,7 +753,7 @@ Py::Object TopoShapeEdgePy::getCurve() const
|
||||
|
||||
Py::Tuple TopoShapeEdgePy::getParameterRange(void) const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
double u = adapt.FirstParameter();
|
||||
double v = adapt.LastParameter();
|
||||
@@ -766,7 +766,7 @@ Py::Tuple TopoShapeEdgePy::getParameterRange(void) const
|
||||
|
||||
Py::Float TopoShapeEdgePy::getFirstParameter(void) const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
double t = adapt.FirstParameter();
|
||||
return Py::Float(t);
|
||||
@@ -774,7 +774,7 @@ Py::Float TopoShapeEdgePy::getFirstParameter(void) const
|
||||
|
||||
Py::Float TopoShapeEdgePy::getLastParameter(void) const
|
||||
{
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
BRepAdaptor_Curve adapt(e);
|
||||
double t = adapt.LastParameter();
|
||||
return Py::Float(t);
|
||||
@@ -783,7 +783,7 @@ Py::Float TopoShapeEdgePy::getLastParameter(void) const
|
||||
Py::Object TopoShapeEdgePy::getMass(void) const
|
||||
{
|
||||
GProp_GProps props;
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props);
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->getShape(), props);
|
||||
double c = props.Mass();
|
||||
return Py::Float(c);
|
||||
}
|
||||
@@ -791,7 +791,7 @@ Py::Object TopoShapeEdgePy::getMass(void) const
|
||||
Py::Object TopoShapeEdgePy::getCenterOfMass(void) const
|
||||
{
|
||||
GProp_GProps props;
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props);
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->getShape(), props);
|
||||
gp_Pnt c = props.CentreOfMass();
|
||||
return Py::Vector(Base::Vector3d(c.X(),c.Y(),c.Z()));
|
||||
}
|
||||
@@ -799,7 +799,7 @@ Py::Object TopoShapeEdgePy::getCenterOfMass(void) const
|
||||
Py::Object TopoShapeEdgePy::getMatrixOfInertia(void) const
|
||||
{
|
||||
GProp_GProps props;
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props);
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->getShape(), props);
|
||||
gp_Mat m = props.MatrixOfInertia();
|
||||
Base::Matrix4D mat;
|
||||
for (int i=0; i<3; i++) {
|
||||
@@ -813,7 +813,7 @@ Py::Object TopoShapeEdgePy::getMatrixOfInertia(void) const
|
||||
Py::Object TopoShapeEdgePy::getStaticMoments(void) const
|
||||
{
|
||||
GProp_GProps props;
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props);
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->getShape(), props);
|
||||
Standard_Real lx,ly,lz;
|
||||
props.StaticMoments(lx,ly,lz);
|
||||
Py::Tuple tuple(3);
|
||||
@@ -826,7 +826,7 @@ Py::Object TopoShapeEdgePy::getStaticMoments(void) const
|
||||
Py::Dict TopoShapeEdgePy::getPrincipalProperties(void) const
|
||||
{
|
||||
GProp_GProps props;
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->_Shape, props);
|
||||
BRepGProp::LinearProperties(getTopoShapePtr()->getShape(), props);
|
||||
GProp_PrincipalProps pprops = props.PrincipalProperties();
|
||||
|
||||
Py::Dict dict;
|
||||
@@ -858,15 +858,15 @@ Py::Dict TopoShapeEdgePy::getPrincipalProperties(void) const
|
||||
|
||||
Py::Boolean TopoShapeEdgePy::getClosed(void) const
|
||||
{
|
||||
if (getTopoShapePtr()->_Shape.IsNull())
|
||||
if (getTopoShapePtr()->getShape().IsNull())
|
||||
throw Py::Exception("Cannot determine the 'Closed'' flag of an empty shape");
|
||||
Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->_Shape);
|
||||
Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->getShape());
|
||||
return Py::Boolean(ok ? true : false);
|
||||
}
|
||||
|
||||
Py::Boolean TopoShapeEdgePy::getDegenerated(void) const
|
||||
{
|
||||
Standard_Boolean ok = BRep_Tool::Degenerated(TopoDS::Edge(getTopoShapePtr()->_Shape));
|
||||
Standard_Boolean ok = BRep_Tool::Degenerated(TopoDS::Edge(getTopoShapePtr()->getShape()));
|
||||
return Py::Boolean(ok ? true : false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user