Skip to content

Commit

Permalink
+ add Python binding to Plate surface
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 19, 2015
1 parent fe522bc commit 13e2b24
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Mod/Part/App/AppPart.cpp
Expand Up @@ -80,6 +80,7 @@
#include "ConePy.h"
#include "CylinderPy.h"
#include "OffsetSurfacePy.h"
#include "PlateSurfacePy.h"
#include "PlanePy.h"
#include "RectangularTrimmedSurfacePy.h"
#include "SpherePy.h"
Expand Down Expand Up @@ -201,6 +202,7 @@ void PartExport initPart()
Base::Interpreter().addType(&Part::BezierSurfacePy ::Type,partModule,"BezierSurface");
Base::Interpreter().addType(&Part::BSplineSurfacePy ::Type,partModule,"BSplineSurface");
Base::Interpreter().addType(&Part::OffsetSurfacePy ::Type,partModule,"OffsetSurface");
Base::Interpreter().addType(&Part::PlateSurfacePy ::Type,partModule,"PlateSurface");
Base::Interpreter().addType(&Part::SurfaceOfExtrusionPy ::Type,partModule,"SurfaceOfExtrusion");
Base::Interpreter().addType(&Part::SurfaceOfRevolutionPy::Type,partModule,"SurfaceOfRevolution");
Base::Interpreter().addType(&Part::RectangularTrimmedSurfacePy
Expand Down Expand Up @@ -298,6 +300,7 @@ void PartExport initPart()
Part::GeomToroid ::init();
Part::GeomPlane ::init();
Part::GeomOffsetSurface ::init();
Part::GeomPlateSurface ::init();
Part::GeomTrimmedSurface ::init();
Part::GeomSurfaceOfRevolution ::init();
Part::GeomSurfaceOfExtrusion ::init();
Expand Down
5 changes: 3 additions & 2 deletions src/Mod/Part/App/CMakeLists.txt
Expand Up @@ -62,13 +62,12 @@ generate_from_xml(ToroidPy)
generate_from_xml(BezierSurfacePy)
generate_from_xml(BSplineSurfacePy)
generate_from_xml(OffsetSurfacePy)
generate_from_xml(PlateSurfacePy)
generate_from_xml(RectangularTrimmedSurfacePy)
generate_from_xml(SurfaceOfExtrusionPy)
generate_from_xml(SurfaceOfRevolutionPy)
generate_from_xml(PartFeaturePy)
generate_from_xml(Part2DObjectPy)
generate_from_xml(OffsetSurfacePy)
generate_from_xml(OffsetSurfacePy)
generate_from_xml(TopoShapePy)
generate_from_xml(TopoShapeCompoundPy)
generate_from_xml(TopoShapeCompSolidPy)
Expand Down Expand Up @@ -197,6 +196,8 @@ SET(Python_SRCS
BSplineSurfacePyImp.cpp
OffsetSurfacePy.xml
OffsetSurfacePyImp.cpp
PlateSurfacePy.xml
PlateSurfacePyImp.cpp
RectangularTrimmedSurfacePy.xml
RectangularTrimmedSurfacePyImp.cpp
SurfaceOfExtrusionPy.xml
Expand Down
75 changes: 72 additions & 3 deletions src/Mod/Part/App/Geometry.cpp
Expand Up @@ -46,6 +46,7 @@
# include <Geom_SphericalSurface.hxx>
# include <Geom_ToroidalSurface.hxx>
# include <Geom_OffsetSurface.hxx>
# include <GeomPlate_Surface.hxx>
# include <Geom_RectangularTrimmedSurface.hxx>
# include <Geom_SurfaceOfRevolution.hxx>
# include <Geom_SurfaceOfLinearExtrusion.hxx>
Expand Down Expand Up @@ -184,13 +185,13 @@ unsigned int Geometry::getMemSize (void) const
return 1;
}

void Geometry::Save (Base::Writer &writer) const
void Geometry::Save(Base::Writer &writer) const
{
const char c = Construction?'1':'0';
writer.Stream() << writer.ind() << "<Construction value=\"" << c << "\"/>" << endl;
}

void Geometry::Restore (Base::XMLReader &reader)
void Geometry::Restore(Base::XMLReader &reader)
{
// read my Element
reader.readElement("Construction");
Expand Down Expand Up @@ -249,7 +250,7 @@ void GeomPoint::setPoint(const Base::Vector3d& p)
}

// Persistence implementer
unsigned int GeomPoint::getMemSize (void) const
unsigned int GeomPoint::getMemSize (void) const
{
return sizeof(Geom_CartesianPoint);
}
Expand Down Expand Up @@ -3214,6 +3215,7 @@ PyObject *GeomPlane::getPyObject(void)
{
return new PlanePy((GeomPlane*)this->clone());
}

// -------------------------------------------------

TYPESYSTEM_SOURCE(Part::GeomOffsetSurface,Part::GeomSurface);
Expand Down Expand Up @@ -3265,6 +3267,73 @@ PyObject *GeomOffsetSurface::getPyObject(void)

// -------------------------------------------------

TYPESYSTEM_SOURCE(Part::GeomPlateSurface,Part::GeomSurface);

GeomPlateSurface::GeomPlateSurface()
{
}

GeomPlateSurface::GeomPlateSurface(const Handle_Geom_Surface& s, const Plate_Plate& plate)
{
this->mySurface = new GeomPlate_Surface(s, plate);
}

GeomPlateSurface::GeomPlateSurface(const GeomPlate_BuildPlateSurface& buildPlate)
{
Handle_GeomPlate_Surface s = buildPlate.Surface();
this->mySurface = Handle_GeomPlate_Surface::DownCast(s->Copy());
}

GeomPlateSurface::GeomPlateSurface(const Handle_GeomPlate_Surface& s)
{
this->mySurface = Handle_GeomPlate_Surface::DownCast(s->Copy());
}

GeomPlateSurface::~GeomPlateSurface()
{
}

void GeomPlateSurface::setHandle(const Handle_GeomPlate_Surface& s)
{
mySurface = Handle_GeomPlate_Surface::DownCast(s->Copy());
}

const Handle_Geom_Geometry& GeomPlateSurface::handle() const
{
return mySurface;
}

Geometry *GeomPlateSurface::clone(void) const
{
GeomPlateSurface *newSurf = new GeomPlateSurface(mySurface);
newSurf->Construction = this->Construction;
return newSurf;
}

// Persistence implementer
unsigned int GeomPlateSurface::getMemSize (void) const
{
throw Base::NotImplementedError("GeomPlateSurface::getMemSize");
}

void GeomPlateSurface::Save(Base::Writer &/*writer*/) const
{
throw Base::NotImplementedError("GeomPlateSurface::Save");
}

void GeomPlateSurface::Restore(Base::XMLReader &/*reader*/)
{
throw Base::NotImplementedError("GeomPlateSurface::Restore");
}

PyObject *GeomPlateSurface::getPyObject(void)
{
throw Base::NotImplementedError("GeomPlateSurface::getPyObject");
// return new PlateSurfacePy(static_cast<GeomPlateSurface*>(this->clone()));
}

// -------------------------------------------------

TYPESYSTEM_SOURCE(Part::GeomTrimmedSurface,Part::GeomSurface);

GeomTrimmedSurface::GeomTrimmedSurface()
Expand Down
28 changes: 28 additions & 0 deletions src/Mod/Part/App/Geometry.h
Expand Up @@ -43,9 +43,12 @@
#include <Handle_Geom_ToroidalSurface.hxx>
#include <Handle_Geom_Plane.hxx>
#include <Handle_Geom_OffsetSurface.hxx>
#include <Handle_GeomPlate_Surface.hxx>
#include <Handle_Geom_RectangularTrimmedSurface.hxx>
#include <Handle_Geom_SurfaceOfRevolution.hxx>
#include <Handle_Geom_SurfaceOfLinearExtrusion.hxx>
#include <GeomPlate_BuildPlateSurface.hxx>
#include <Plate_Plate.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
Expand Down Expand Up @@ -746,6 +749,31 @@ class PartExport GeomOffsetSurface : public GeomSurface
Handle_Geom_OffsetSurface mySurface;
};

class PartExport GeomPlateSurface : public GeomSurface
{
TYPESYSTEM_HEADER();
public:
GeomPlateSurface();
GeomPlateSurface(const Handle_Geom_Surface&, const Plate_Plate&);
GeomPlateSurface(const GeomPlate_BuildPlateSurface&);
GeomPlateSurface(const Handle_GeomPlate_Surface&);
virtual ~GeomPlateSurface();
virtual Geometry *clone(void) const;

// Persistence implementer ---------------------
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
// Base implementer ----------------------------
virtual PyObject *getPyObject(void);

void setHandle(const Handle_GeomPlate_Surface& s);
const Handle_Geom_Geometry& handle() const;

private:
Handle_GeomPlate_Surface mySurface;
};

class PartExport GeomTrimmedSurface : public GeomSurface
{
TYPESYSTEM_HEADER();
Expand Down
33 changes: 33 additions & 0 deletions src/Mod/Part/App/PlateSurfacePy.xml
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="GeometrySurfacePy"
Name="PlateSurfacePy"
Twin="GeomPlateSurface"
TwinPointer="GeomPlateSurface"
Include="Mod/Part/App/Geometry.h"
Namespace="Part"
FatherInclude="Mod/Part/App/GeometrySurfacePy.h"
FatherNamespace="Part"
Constructor="true">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
<UserDocu></UserDocu>
</Documentation>
<Methode Name="uIso">
<Documentation>
<UserDocu>Builds the U isoparametric line of this surface</UserDocu>
</Documentation>
</Methode>
<Methode Name="vIso">
<Documentation>
<UserDocu>Builds the V isoparametric line of this surface</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeApprox" Keyword="true">
<Documentation>
<UserDocu>Approximate the plate surface to a B-Spline surface</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

0 comments on commit 13e2b24

Please sign in to comment.