Skip to content

Commit

Permalink
Part: expose HLR algorithm to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 21, 2021
1 parent dede24d commit 73a9867
Show file tree
Hide file tree
Showing 8 changed files with 793 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Mod/Part/App/AppPart.cpp
Expand Up @@ -142,6 +142,8 @@
#include <Mod/Part/App/GeomPlate/BuildPlateSurfacePy.h>
#include <Mod/Part/App/GeomPlate/CurveConstraintPy.h>
#include <Mod/Part/App/GeomPlate/PointConstraintPy.h>
#include <Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.h>
#include <Mod/Part/App/HLRBRep/HLRToShapePy.h>
#include <Mod/Part/App/ShapeUpgrade/UnifySameDomainPy.h>
#include "PropertyGeometryList.h"
#include "DatumFeature.h"
Expand Down Expand Up @@ -295,6 +297,11 @@ PyMOD_INIT_FUNC(Part)
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepOffsetApiModule,"MakePipeShell");
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakeFillingPy::Type,brepOffsetApiModule,"MakeFilling");

// HLRBRep package
PyObject* hlrfeatModule(module.getAttr("HLRBRep").ptr());
Base::Interpreter().addType(&Part::HLRBRep_AlgoPy::Type,hlrfeatModule,"Algo");
Base::Interpreter().addType(&Part::HLRToShapePy::Type,hlrfeatModule,"HLRToShape");

// Geom2d package
PyObject* geom2dModule(module.getAttr("Geom2d").ptr());
Base::Interpreter().addType(&Part::Geometry2dPy::Type,geom2dModule,"Geometry2d");
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/Part/App/AppPartPy.cpp
Expand Up @@ -317,6 +317,17 @@ class GeomPlateModule : public Py::ExtensionModule<GeomPlateModule>
virtual ~GeomPlateModule() {}
};

class HLRBRepModule : public Py::ExtensionModule<HLRBRepModule>
{
public:
HLRBRepModule() : Py::ExtensionModule<HLRBRepModule>("HLRBRep")
{
initialize("This is a module working with the HLRBRep framework."); // register with Python
}

virtual ~HLRBRepModule() {}
};

class ShapeUpgradeModule : public Py::ExtensionModule<ShapeUpgradeModule>
{
public:
Expand All @@ -334,6 +345,7 @@ class Module : public Py::ExtensionModule<Module>
BRepOffsetAPIModule brepOffsetApi;
Geom2dModule geom2d;
GeomPlateModule geomPlate;
HLRBRepModule HLRBRep;
ShapeUpgradeModule shapeUpgrade;
public:
Module() : Py::ExtensionModule<Module>("Part")
Expand Down Expand Up @@ -559,6 +571,7 @@ class Module : public Py::ExtensionModule<Module>
PyModule_AddObject(m_module, "BRepOffsetAPI", brepOffsetApi.module().ptr());
PyModule_AddObject(m_module, "Geom2d", geom2d.module().ptr());
PyModule_AddObject(m_module, "GeomPlate", geomPlate.module().ptr());
PyModule_AddObject(m_module, "HLRBRep", HLRBRep.module().ptr());
PyModule_AddObject(m_module, "ShapeUpgrade", shapeUpgrade.module().ptr());
}

Expand Down
17 changes: 15 additions & 2 deletions src/Mod/Part/App/CMakeLists.txt
Expand Up @@ -97,6 +97,7 @@ generate_from_xml(BRepOffsetAPI_MakeFillingPy)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/BRepFeat)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Geom2d)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/GeomPlate)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/HLRBRep)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ShapeUpgrade)

generate_from_xml(BRepFeat/MakePrismPy)
Expand All @@ -123,6 +124,9 @@ generate_from_xml(GeomPlate/BuildPlateSurfacePy)
generate_from_xml(GeomPlate/CurveConstraintPy)
generate_from_xml(GeomPlate/PointConstraintPy)

generate_from_xml(HLRBRep/HLRBRep_AlgoPy)
generate_from_xml(HLRBRep/HLRToShapePy)

generate_from_xml(ShapeUpgrade/UnifySameDomainPy)

SET(Features_SRCS
Expand Down Expand Up @@ -322,8 +326,7 @@ SET(BRepFeatPy_SRCS
BRepFeat/MakePrismPy.xml
BRepFeat/MakePrismPyImp.cpp
)

SOURCE_GROUP("ShapeUpgrade" FILES ${ShapeUpgradePy_SRCS})
SOURCE_GROUP("BRepFeat" FILES ${BRepFeatPy_SRCS})

# Geom2d wrappers
SET(Geom2dPy_SRCS
Expand Down Expand Up @@ -377,6 +380,15 @@ SET(GeomPlatePy_SRCS

SOURCE_GROUP("GeomPlate" FILES ${GeomPlatePy_SRCS})

# HLRBRep wrappers
SET(HLRBRepPy_SRCS
HLRBRep/HLRBRep_AlgoPy.xml
HLRBRep/HLRBRep_AlgoPyImp.cpp
HLRBRep/HLRToShapePy.xml
HLRBRep/HLRToShapePyImp.cpp
)
SOURCE_GROUP("HLRBRep" FILES ${HLRBRepPy_SRCS})

# ShapeUpgrade wrappers
SET(ShapeUpgradePy_SRCS
ShapeUpgrade/UnifySameDomainPy.xml
Expand All @@ -392,6 +404,7 @@ SET(Part_SRCS
${BRepFeatPy_SRCS}
${Geom2dPy_SRCS}
${GeomPlatePy_SRCS}
${HLRBRepPy_SRCS}
${ShapeUpgradePy_SRCS}
Attacher.cpp
Attacher.h
Expand Down
117 changes: 117 additions & 0 deletions src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPy.xml
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="HLRBRep_AlgoPy"
PythonName="Part.HLRBRep_Algo"
Twin="HLRBRep_Algo"
TwinPointer="HLRBRep_Algo"
Include="HLRBRep_Algo.hxx"
Namespace="Part"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="false">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
<UserDocu>Describes functions to use HLR algorithm.</UserDocu>
</Documentation>
<Methode Name="add">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="remove">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="index">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
<Methode Name="outLinedShapeNullify">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="setProjector" Keyword="true">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="nbShapes">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="showAll">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="hide">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="hideAll">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="partialHide">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="select">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="selectEdge">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="selectFace">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="initEdgeStatus">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<Methode Name="update">
<Documentation>
<UserDocu>
</UserDocu>
</Documentation>
</Methode>
<ClassDeclarations>
private:
Handle(HLRBRep_Algo) hAlgo;

public:
Handle(HLRBRep_Algo) handle() {
return hAlgo;
}
</ClassDeclarations>
</PythonExport>
</GenerateModel>

0 comments on commit 73a9867

Please sign in to comment.