FEM: Add cylinder filter function
This commit is contained in:
@@ -187,6 +187,7 @@ PyMOD_INIT_FUNC(Fem)
|
||||
|
||||
Fem::FemPostFunction ::init();
|
||||
Fem::FemPostFunctionProvider ::init();
|
||||
Fem::FemPostCylinderFunction ::init();
|
||||
Fem::FemPostPlaneFunction ::init();
|
||||
Fem::FemPostSphereFunction ::init();
|
||||
|
||||
|
||||
@@ -59,6 +59,44 @@ DocumentObjectExecReturn* FemPostFunction::execute() {
|
||||
return DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// cylinder function
|
||||
PROPERTY_SOURCE(Fem::FemPostCylinderFunction, Fem::FemPostFunction)
|
||||
|
||||
FemPostCylinderFunction::FemPostCylinderFunction() : FemPostFunction()
|
||||
{
|
||||
ADD_PROPERTY(Center, (Base::Vector3d(0.0, 0.0, 0.0)));
|
||||
ADD_PROPERTY(Axis, (Base::Vector3d(0.0, 0.0, 1.0)));
|
||||
ADD_PROPERTY(Radius, (5.));
|
||||
|
||||
m_cylinder = vtkSmartPointer<vtkCylinder>::New();
|
||||
m_implicit = m_cylinder;
|
||||
|
||||
m_cylinder->SetAxis(0., 0., 1.);
|
||||
m_cylinder->SetCenter(0., 0., 0.);
|
||||
m_cylinder->SetRadius(5.);
|
||||
}
|
||||
|
||||
FemPostCylinderFunction::~FemPostCylinderFunction()
|
||||
{
|
||||
}
|
||||
|
||||
void FemPostCylinderFunction::onChanged(const Property* prop)
|
||||
{
|
||||
if (prop == &Axis) {
|
||||
const Base::Vector3d& vec = Axis.getValue();
|
||||
m_cylinder->SetAxis(vec[0], vec[1], vec[2]);
|
||||
}
|
||||
else if (prop == &Center) {
|
||||
const Base::Vector3d& vec = Center.getValue();
|
||||
m_cylinder->SetCenter(vec[0], vec[1], vec[2]);
|
||||
}
|
||||
else if (prop == &Radius) {
|
||||
m_cylinder->SetRadius(Radius.getValue());
|
||||
}
|
||||
|
||||
Fem::FemPostFunction::onChanged(prop);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// plane function
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define Fem_FemPostFunction_H
|
||||
|
||||
#include <vtkBoundingBox.h>
|
||||
#include <vtkCylinder.h>
|
||||
#include <vtkImplicitFunction.h>
|
||||
#include <vtkPlane.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
@@ -81,6 +82,32 @@ protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class FemExport FemPostCylinderFunction : public FemPostFunction
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostCylinderFunction);
|
||||
|
||||
public:
|
||||
|
||||
FemPostCylinderFunction();
|
||||
~FemPostCylinderFunction() override;
|
||||
|
||||
App::PropertyVector Axis;
|
||||
App::PropertyVectorDistance Center;
|
||||
App::PropertyDistance Radius;
|
||||
|
||||
const char* getViewProviderName() const override {
|
||||
return "FemGui::ViewProviderFemPostCylinderFunction";
|
||||
}
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
/// get called after a document has been fully restored
|
||||
// void onDocumentRestored() override;
|
||||
|
||||
vtkSmartPointer<vtkCylinder> m_cylinder;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user