Part: [skip ci] add methods to determine continuity

This commit is contained in:
wmayer
2020-05-17 21:57:25 +02:00
parent a5ab09aa09
commit ff0e556b59
7 changed files with 160 additions and 1 deletions

View File

@@ -90,6 +90,11 @@ parameterAtDistance([abscissa, startingParameter]) -> Float the</UserDocu>
<UserDocu>Get intersection points with another curve lying on a plane.</UserDocu>
</Documentation>
</Methode>
<Methode Name="continuityWith" Const="true">
<Documentation>
<UserDocu>Computes the continuity of two curves</UserDocu>
</Documentation>
</Methode>
<Methode Name="parameter" Const="true">
<Documentation>
<UserDocu>Returns the parameter on the curve

View File

@@ -43,6 +43,7 @@
# include <Geom_Surface.hxx>
# include <GeomAdaptor_Curve.hxx>
# include <GeomFill.hxx>
# include <GeomLProp.hxx>
# include <GeomLProp_CLProps.hxx>
# include <Geom_RectangularTrimmedSurface.hxx>
# include <Geom_BSplineSurface.hxx>
@@ -708,6 +709,84 @@ PyObject* GeometryCurvePy::approximateBSpline(PyObject *args)
}
}
PyObject* GeometryCurvePy::continuityWith(PyObject *args)
{
double u1 = -1.0, u2 = -1.0;
double tl = -1.0, ta = -1.0;
PyObject* curve;
PyObject* rev1 = Py_False;
PyObject* rev2 = Py_False;
if (!PyArg_ParseTuple(args, "O!|ddO!O!dd",
&GeometryCurvePy::Type, &curve,
&u1, &u2,
&PyBool_Type, &rev1,
&PyBool_Type, &rev2,
&tl, &ta))
return nullptr;
Handle(Geom_Geometry) g1 = getGeometryPtr()->handle();
Handle(Geom_Curve) c1 = Handle(Geom_Curve)::DownCast(g1);
Handle(Geom_Geometry) g2 = static_cast<GeometryCurvePy*>(curve)->getGeomCurvePtr()->handle();
Handle(Geom_Curve) c2 = Handle(Geom_Curve)::DownCast(g2);
// if no parameter value is given then by default use the end of the parameter range
if (u1 < 0.0)
u1 = c1->LastParameter();
// if no parameter value is given then by default use the start of the parameter range
if (u2 < 0.0)
u2 = c2->FirstParameter();
Standard_Boolean r1 = PyObject_IsTrue(rev1) ? Standard_True : Standard_False;
Standard_Boolean r2 = PyObject_IsTrue(rev2) ? Standard_True : Standard_False;
try {
if (!c1.IsNull() && !c2.IsNull()) {
GeomAbs_Shape c;
if (tl >= 0.0 && ta >= 0.0)
c = GeomLProp::Continuity(c1, c2, u1, u2, r1, r2, tl, ta);
else
c = GeomLProp::Continuity(c1, c2, u1, u2, r1, r2);
std::string str;
switch (c) {
case GeomAbs_C0:
str = "C0";
break;
case GeomAbs_G1:
str = "G1";
break;
case GeomAbs_C1:
str = "C1";
break;
case GeomAbs_G2:
str = "G2";
break;
case GeomAbs_C2:
str = "C2";
break;
case GeomAbs_C3:
str = "C3";
break;
case GeomAbs_CN:
str = "CN";
break;
default:
str = "Unknown";
break;
}
return Py_BuildValue("s", str.c_str());
}
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
Py::String GeometryCurvePy::getContinuity(void) const
{
GeomAbs_Shape c = Handle(Geom_Curve)::DownCast

View File

@@ -389,6 +389,7 @@
#include <GeomFill_SectionGenerator.hxx>
#include <GeomLib.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <GeomLProp.hxx>
#include <GeomLProp_SLProps.hxx>
#include <GeomLProp_CLProps.hxx>
#include <GeomPlate_MakeApprox.hxx>

View File

@@ -522,7 +522,13 @@ coordinate system.</UserDocu>
</Documentation>
<Parameter Name="PrincipalProperties" Type="Dict"/>
</Attribute>
<ClassDeclarations>
<Attribute Name="Continuity" ReadOnly="true">
<Documentation>
<UserDocu>Returns the continuity</UserDocu>
</Documentation>
<Parameter Name="Continuity" Type="String"/>
</Attribute>
<ClassDeclarations>
</ClassDeclarations>
</PythonExport>
</GenerateModel>

View File

@@ -747,6 +747,37 @@ PyObject* TopoShapeEdgePy::lastVertex(PyObject *args)
// ====== Attributes ======================================================================
Py::String TopoShapeEdgePy::getContinuity() const
{
BRepAdaptor_Curve adapt(TopoDS::Edge(getTopoShapePtr()->getShape()));
std::string cont;
switch (adapt.Continuity()) {
case GeomAbs_C0:
cont = "C0";
break;
case GeomAbs_G1:
cont = "G1";
break;
case GeomAbs_C1:
cont = "C1";
break;
case GeomAbs_G2:
cont = "G2";
break;
case GeomAbs_C2:
cont = "C2";
break;
case GeomAbs_C3:
cont = "C3";
break;
case GeomAbs_CN:
cont = "CN";
break;
}
return Py::String(cont);
}
Py::Float TopoShapeEdgePy::getTolerance(void) const
{
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());

View File

@@ -158,6 +158,12 @@ coordinate system.</UserDocu>
</Documentation>
<Parameter Name="OrderedEdges" Type="List"/>
</Attribute>
<Attribute Name="Continuity" ReadOnly="true">
<Documentation>
<UserDocu>Returns the continuity</UserDocu>
</Documentation>
<Parameter Name="Continuity" Type="String"/>
</Attribute>
<Attribute Name="OrderedVertexes" ReadOnly="true">
<Documentation>
<UserDocu>List of ordered vertexes in this shape.</UserDocu>

View File

@@ -528,6 +528,37 @@ PyObject* TopoShapeWirePy::discretize(PyObject *args, PyObject *kwds)
return 0;
}
Py::String TopoShapeWirePy::getContinuity() const
{
BRepAdaptor_CompCurve adapt(TopoDS::Wire(getTopoShapePtr()->getShape()));
std::string cont;
switch (adapt.Continuity()) {
case GeomAbs_C0:
cont = "C0";
break;
case GeomAbs_G1:
cont = "G1";
break;
case GeomAbs_C1:
cont = "C1";
break;
case GeomAbs_G2:
cont = "G2";
break;
case GeomAbs_C2:
cont = "C2";
break;
case GeomAbs_C3:
cont = "C3";
break;
case GeomAbs_CN:
cont = "CN";
break;
}
return Py::String(cont);
}
Py::Object TopoShapeWirePy::getMass(void) const
{
GProp_GProps props;