implement method to get GeomSurface from Geom_Surface
This commit is contained in:
parent
2502526e4e
commit
fbaf3a1bbc
|
@ -3696,4 +3696,60 @@ GeomArcOfCircle *createFilletGeometry(const GeomLineSegment *lineSeg1, const Geo
|
|||
return arc;
|
||||
}
|
||||
|
||||
GeomSurface* makeFromSurface(const Handle_Geom_Surface& s)
|
||||
{
|
||||
if (s->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
|
||||
Handle_Geom_ToroidalSurface hSurf = Handle_Geom_ToroidalSurface::DownCast(s);
|
||||
return new GeomToroid(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
|
||||
Handle_Geom_BezierSurface hSurf = Handle_Geom_BezierSurface::DownCast(s);
|
||||
return new GeomBezierSurface(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
|
||||
Handle_Geom_BSplineSurface hSurf = Handle_Geom_BSplineSurface::DownCast(s);
|
||||
return new GeomBSplineSurface(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
|
||||
Handle_Geom_CylindricalSurface hSurf = Handle_Geom_CylindricalSurface::DownCast(s);
|
||||
return new GeomCylinder(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
|
||||
Handle_Geom_ConicalSurface hSurf = Handle_Geom_ConicalSurface::DownCast(s);
|
||||
return new GeomCone(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
|
||||
Handle_Geom_SphericalSurface hSurf = Handle_Geom_SphericalSurface::DownCast(s);
|
||||
return new GeomSphere(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_Plane))) {
|
||||
Handle_Geom_Plane hSurf = Handle_Geom_Plane::DownCast(s);
|
||||
return new GeomPlane(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
|
||||
Handle_Geom_OffsetSurface hSurf = Handle_Geom_OffsetSurface::DownCast(s);
|
||||
return new GeomOffsetSurface(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(GeomPlate_Surface))) {
|
||||
Handle_GeomPlate_Surface hSurf = Handle_GeomPlate_Surface::DownCast(s);
|
||||
return new GeomPlateSurface(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
|
||||
Handle_Geom_RectangularTrimmedSurface hSurf = Handle_Geom_RectangularTrimmedSurface::DownCast(s);
|
||||
return new GeomTrimmedSurface(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
|
||||
Handle_Geom_SurfaceOfRevolution hSurf = Handle_Geom_SurfaceOfRevolution::DownCast(s);
|
||||
return new GeomSurfaceOfRevolution(hSurf);
|
||||
}
|
||||
else if (s->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
|
||||
Handle_Geom_SurfaceOfLinearExtrusion hSurf = Handle_Geom_SurfaceOfLinearExtrusion::DownCast(s);
|
||||
return new GeomSurfaceOfExtrusion(hSurf);
|
||||
}
|
||||
|
||||
std::string err = "Unhandled surface type ";
|
||||
err += s->DynamicType()->Name();
|
||||
throw Base::TypeError(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -877,6 +877,8 @@ double suggestFilletRadius(const GeomLineSegment *lineSeg1, const GeomLineSegmen
|
|||
PartExport
|
||||
GeomArcOfCircle *createFilletGeometry(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2,
|
||||
const Base::Vector3d ¢er, double radius);
|
||||
PartExport
|
||||
GeomSurface *makeFromSurface(const Handle_Geom_Surface&);
|
||||
}
|
||||
|
||||
#endif // PART_GEOMETRY_H
|
||||
|
|
|
@ -72,8 +72,9 @@
|
|||
#include "TopoShapePy.h"
|
||||
#include "TopoShapeEdgePy.h"
|
||||
|
||||
// TODO: This should be somewhere globally, but where? Currently located in GeometrySurfacePyImp.cpp
|
||||
namespace Part {
|
||||
extern const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c);
|
||||
}
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include <Mod/Part/App/TopoShapeFacePy.h>
|
||||
|
||||
namespace Part {
|
||||
const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c)
|
||||
{
|
||||
if (c->IsKind(STANDARD_TYPE(Geom_Circle))) {
|
||||
|
@ -104,10 +105,13 @@ const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c)
|
|||
return Py::asObject(new BSplineCurvePy(new GeomBSplineCurve(bspline)));
|
||||
}
|
||||
|
||||
std::string err = "Unknown curve type ";
|
||||
std::string err = "Unhandled curve type ";
|
||||
err += c->DynamicType()->Name();
|
||||
throw Py::TypeError(err);
|
||||
}
|
||||
|
||||
} // Part
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
using namespace Part;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Geom_OffsetSurface.hxx>
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
#include <Base/VectorPy.h>
|
||||
|
@ -31,8 +32,8 @@
|
|||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "OffsetSurfacePy.h"
|
||||
#include "OffsetSurfacePy.cpp"
|
||||
#include <Mod/Part/App/OffsetSurfacePy.h>
|
||||
#include <Mod/Part/App/OffsetSurfacePy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -92,7 +93,14 @@ void OffsetSurfacePy::setOffsetValue(Py::Float arg)
|
|||
|
||||
Py::Object OffsetSurfacePy::getBasisSurface(void) const
|
||||
{
|
||||
throw Py::Exception(PyExc_NotImplementedError, "Not yet implemented");
|
||||
Handle_Geom_OffsetSurface surf = Handle_Geom_OffsetSurface::DownCast
|
||||
(getGeometryPtr()->handle());
|
||||
if (surf.IsNull()) {
|
||||
throw Py::TypeError("geometry is not a surface");
|
||||
}
|
||||
|
||||
std::unique_ptr<GeomSurface> geo(makeFromSurface(surf->BasisSurface()));
|
||||
return Py::asObject(geo->getPyObject());
|
||||
}
|
||||
|
||||
void OffsetSurfacePy::setBasisSurface(Py::Object arg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user