[Surface]: Implementation of BlenCurve.

This commit is contained in:
Matteo-Grellier
2022-07-18 11:05:31 +02:00
committed by wwmayer
parent 7e69d7e38b
commit c85c8cfb33
18 changed files with 644 additions and 111 deletions

View File

@@ -24,27 +24,30 @@
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include "FeatureFilling.h"
#include "FeatureSewing.h"
#include "FeatureCut.h"
#include "FeatureGeomFillSurface.h"
#include "FeatureExtend.h"
#include "FeatureSections.h"
#include "Blending/BlendPointPy.h"
#include "Blending/BlendCurvePy.h"
#include "Blending/BlendPoint.h"
#include "Blending/BlendPointPy.h"
#include "Blending/FeatureBlendCurve.h"
#include "FeatureCut.h"
#include "FeatureExtend.h"
#include "FeatureFilling.h"
#include "FeatureGeomFillSurface.h"
#include "FeatureSections.h"
#include "FeatureSewing.h"
#include <Base/Interpreter.h>
#include <Base/Parameter.h>
namespace Surface {
class Module : public Py::ExtensionModule<Module>
namespace Surface
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("Surface")
{
initialize("This module is the Surface module."); // register with Python
initialize("This module is the Surface module.");// register with Python
}
~Module() override {}
@@ -52,38 +55,40 @@ public:
private:
};
PyObject* initModule()
PyObject *initModule()
{
return Base::Interpreter().addModule(new Module);
}
} // namespace Surface
}// namespace Surface
/* Python entry */
PyMOD_INIT_FUNC(Surface)
{
try {
Base::Interpreter().runString("import Part");
}
catch(const Base::Exception& e) {
catch (const Base::Exception &e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
PyObject* mod = Surface::initModule();
PyObject *mod = Surface::initModule();
Base::Console().Log("Loading Surface module... done\n");
Base::Interpreter().addType(&Surface::BlendPointPy::Type, mod, "BlendPoint");
Base::Interpreter().addType(&Surface::BlendCurvePy::Type, mod, "BlendCurve");
// Add types to module
Surface::Filling ::init();
Surface::Sewing ::init();
Surface::Cut ::init();
Surface::GeomFillSurface ::init();
Surface::Extend ::init();
Surface::Sections ::init();
Surface::BlendPoint ::init();
Surface::BlendCurve ::init();
Surface::Filling ::init();
Surface::Sewing ::init();
Surface::Cut ::init();
Surface::GeomFillSurface ::init();
Surface::Extend ::init();
Surface::FeatureBlendCurve ::init();
Surface::Sections ::init();
Surface::BlendPoint ::init();
Surface::BlendCurve ::init();
PyMOD_Return(mod);
}

View File

@@ -33,10 +33,10 @@
#include <math_Gauss.hxx>
#include <math_Matrix.hxx>
#endif
#include <Base/Vector3D.h>
#include <Mod/Part/App/Geometry.h>
#include "Blending/BlendCurve.h"
#include "Blending/BlendCurvePy.h"
#include <Base/Vector3D.h>
#include <Mod/Part/App/Geometry.h>
using namespace Surface;
@@ -47,7 +47,7 @@ BlendCurve::BlendCurve()
BlendCurve::BlendCurve(std::vector<BlendPoint> blendPointsList)
{
// Retrieve number of blendPoints and push them into blendPoints.
int nb_pts = blendPointsList.size();
size_t nb_pts = blendPointsList.size();
if (nb_pts > 2) {
throw Base::ValueError("Not implemented");
@@ -64,23 +64,23 @@ BlendCurve::~BlendCurve()
Handle(Geom_BezierCurve) BlendCurve::compute()
{
int nb_pts = blendPoints.size();
size_t nb_pts = blendPoints.size();
try {
// Uniform Parametrization
TColStd_Array1OfReal params(1, nb_pts);
for (int i = 0; i < nb_pts; ++i) {
params(i + 1) = (double)i / ((double)nb_pts - 1);
}
int num_poles = 0;
for (int i = 0; i < nb_pts; ++i) {
num_poles += blendPoints[i].nbVectors();
}
Handle(Geom_BezierCurve) curve;
if (num_poles > (curve->MaxDegree()+1))// use Geom_BezierCurve max degree
if (num_poles > (curve->MaxDegree() + 1))// use Geom_BezierCurve max degree
Standard_Failure::Raise("number of constraints exceeds bezier curve capacity");
TColStd_Array1OfReal knots(1, 2 * num_poles);
for (int i = 1; i <= num_poles; ++i) {
knots(i) = params(1);
@@ -127,7 +127,7 @@ Handle(Geom_BezierCurve) BlendCurve::compute()
Handle(Geom_BezierCurve) bezier = new Geom_BezierCurve(poles);
return bezier;
}
catch (Standard_Failure &e) {
PyErr_SetString(PyExc_Exception, "Failed to compute bezier curve");
}
@@ -140,7 +140,7 @@ void BlendCurve::setSize(int i, double f, bool relative)
try {
if (relative) {
double nb_poles = blendPoints.front().nbVectors() + blendPoints[1].nbVectors();
Base::Vector3d diff = blendPoints[1].vectors[0] - blendPoints[0].vectors[0];
Base::Vector3d diff = blendPoints[1].vectors[0] - blendPoints[0].vectors[0];
size = size * diff.Length() / nb_poles;
}
blendPoints[i].setSize(size);

View File

@@ -17,8 +17,7 @@
<Documentation>
<Author Licence="LGPL" Name="Mattéo Grellier" EMail="matteogrellier@gmail.com" />
<UserDocu>
Create a BlendCurve that interpolate a list of BlendPoints.
curve = BlendCurve([BlendPoint1, BlendPoint2])
Create a BlendCurve that interpolate 2 BlendPoints.
curve = BlendCurve(BlendPoint1, BlendPoint2)
</UserDocu>
</Documentation>

View File

@@ -29,9 +29,9 @@
#include "Blending/BlendPointPy.h"
// #include "Mod/Part/App/Geometry.h"
// #include <Base/GeometryPyCXX.h>
#include "Blending/BlendCurvePy.cpp"
#include <Base/VectorPy.h>
#include <Mod/Part/App/BezierCurvePy.h>
#include "Blending/BlendCurvePy.cpp"
using namespace Surface;
@@ -48,30 +48,10 @@ PyObject *BlendCurvePy::PyMake(struct _typeobject *, PyObject *, PyObject *)// P
int BlendCurvePy::PyInit(PyObject *args, PyObject * /*kwds*/)
{
PyObject *plist;
if (PyArg_ParseTuple(args, "O", &plist)) {
Py::Sequence list(plist);
if (list.size() != 2) {
PyErr_SetString(PyExc_TypeError, "Currently BlendCurve need exactly 2 BlendPoints");
return -1;
}
std::vector<BlendPoint> bpList;
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::Object obj(*it);
if (PyObject_TypeCheck(obj.ptr(), &BlendPointPy::Type)) {
BlendPoint *geom = static_cast<BlendPointPy *>(obj.ptr())->getBlendPointPtr();
bpList.emplace_back(*geom);
}
}
this->getBlendCurvePtr()->blendPoints = bpList;
return 0;
}
PyErr_Clear();
PyObject *b1;
PyObject *b2;
std::vector<BlendPoint> bpList;
if (PyArg_ParseTuple(args, "O!O!", &(Surface::BlendPointPy::Type), &b1, &(Surface::BlendPointPy::Type), &b2)) {
BlendPoint *geom1 = static_cast<BlendPointPy *>(b1)->getBlendPointPtr();
BlendPoint *geom2 = static_cast<BlendPointPy *>(b2)->getBlendPointPtr();
@@ -94,7 +74,7 @@ PyObject *BlendCurvePy::setSize(PyObject *args)
{
int i;
double size;
PyObject* relative = Py_True;
PyObject *relative = Py_True;
if (!PyArg_ParseTuple(args, "idO!", &i, &size, &PyBool_Type, &relative)) {
return nullptr;
}

View File

@@ -45,7 +45,7 @@ BlendPoint::BlendPoint(std::vector<Base::Vector3d> vectorList)
BlendPoint::BlendPoint()
{
vectors.emplace_back(Base::Vector3d(0, 0, 0));
vectors.emplace_back(Base::Vector3d(0, 0, 0));
}
BlendPoint::~BlendPoint()

View File

@@ -40,7 +40,7 @@
<Documentation>
<UserDocu>
Resizes the BlendPoint vectors,
by setting the lenght of the first derivative.
by setting the length of the first derivative.
theBlendPoint.setSize(new_size)
</UserDocu>
</Documentation>

View File

@@ -27,13 +27,14 @@
#include <TColgp_Array1OfPnt.hxx>
#include <TopoDS.hxx>
#endif
#include "Blending/BlendPoint.h"
#include "Blending/BlendPointPy.h"
#include <Base/GeometryPyCXX.h>
#include <Base/VectorPy.h>
#include <Mod/Part/App/TopoShapePy.h>
#include "Blending/BlendPoint.h"
#include "Blending/BlendPointPy.h"
#include "Blending/BlendPointPy.cpp"
using namespace Surface;
std::string BlendPointPy::representation(void) const
@@ -51,7 +52,7 @@ PyObject *BlendPointPy::PyMake(struct _typeobject *, PyObject *, PyObject *)// P
return new BlendPointPy(new BlendPoint);
}
int BlendPointPy::PyInit(PyObject* args, PyObject*)
int BlendPointPy::PyInit(PyObject *args, PyObject *)
{
PyObject *plist;
std::vector<Base::Vector3d> vecs;
@@ -89,6 +90,11 @@ int BlendPointPy::PyInit(PyObject* args, PyObject*)
TopoDS_Shape shape = static_cast<Part::TopoShapePy *>(pcObj)->getTopoShapePtr()->getShape();
const TopoDS_Edge &e = TopoDS::Edge(shape);
BRepAdaptor_Curve adapt(e);
if (param < adapt.FirstParameter() || param > adapt.LastParameter()) {
PyErr_Warn(PyExc_UserWarning, "BlendPoint: edge is not a closed curve");
Base::Console().Message("fp=%f\n", adapt.FirstParameter());
Base::Console().Message("lp=%f\n", adapt.LastParameter());
}
adapt.D0(param, Pt);
Base::Vector3d bv(Pt.X(), Pt.Y(), Pt.Z());

View File

@@ -0,0 +1,74 @@
/***************************************************************************
* Copyright (c) 2014 Matteo Grellier <matteogrellier@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef FEATURE_BLEND_CURVE_H
#define FEATURE_BLEND_CURVE_H
#include <App/PropertyLinks.h>
#include <App/PropertyStandard.h>
#include <App/PropertyUnits.h>
#include <Mod/Part/App/FeaturePartSpline.h>
#include <Mod/Surface/SurfaceGlobal.h>
#include <Mod/Surface/App/Blending/BlendPoint.h>
namespace Surface
{
class SurfaceExport FeatureBlendCurve: public Part::Spline
{
PROPERTY_HEADER_WITH_OVERRIDE(Surface::FeatureBlendCurve);
public:
FeatureBlendCurve();
App::PropertyLinkSub StartEdge;
App::PropertyFloatConstraint StartParameter;
App::PropertyIntegerConstraint StartContinuity;
App::PropertyFloat StartSize;
App::PropertyLinkSub EndEdge;
App::PropertyFloatConstraint EndParameter;
App::PropertyIntegerConstraint EndContinuity;
App::PropertyFloat EndSize;
Standard_Integer maxDegree;
App::DocumentObjectExecReturn *execute(void) override;
short mustExecute() const override;
const char *getViewProviderName(void) const override
{
return "SurfaceGui::ViewProviderBlendCurve";
}
private:
BlendPoint GetBlendPoint(App::PropertyLinkSub &link, App::PropertyFloatConstraint &param, App::PropertyIntegerConstraint &Continuity);
double RelativeToRealParameters(double, double, double);
bool lockOnChangeMutex;
protected:
virtual void onChanged(const App::Property *prop) override;
};
}//Namespace Surface
#endif

View File

@@ -1,19 +1,50 @@
if(MSVC)
add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC)
include_directories(
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/src
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
)
link_directories(${OCC_LIBRARY_DIR})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Blending)
generate_from_xml(Blending/BlendPointPy)
generate_from_xml(Blending/BlendCurvePy)
set(Surface_LIBS
FreeCADApp
Part
FreeCADApp
Part
)
# BlendPoint Wrapper
SET(BlendingPy_SRCS
Blending/BlendPointPy.xml
Blending/BlendPointPyImp.cpp
Blending/BlendCurvePy.xml
Blending/BlendCurvePyImp.cpp
)
SOURCE_GROUP("Blending" FILES ${BlendingPy_SRCS})
SET(Blending_SRCS
Blending/FeatureBlendCurve.cpp
Blending/FeatureBlendCurve.h
Blending/BlendPoint.cpp
Blending/BlendPoint.h
Blending/BlendCurve.cpp
Blending/BlendCurve.h
)
SET(BlendingPy_SRCS
@@ -34,21 +65,23 @@ SET(Blending_SRCS
)
SET(Surface_SRCS
AppSurface.cpp
PreCompiled.cpp
PreCompiled.h
FeatureExtend.cpp
FeatureExtend.h
FeatureGeomFillSurface.cpp
FeatureGeomFillSurface.h
FeatureFilling.cpp
FeatureFilling.h
FeatureSections.cpp
FeatureSections.h
FeatureSewing.cpp
FeatureSewing.h
FeatureCut.cpp
FeatureCut.h
${Blending_SRCS}
${BlendingPy_SRCS}
AppSurface.cpp
PreCompiled.cpp
PreCompiled.h
FeatureExtend.cpp
FeatureExtend.h
FeatureGeomFillSurface.cpp
FeatureGeomFillSurface.h
FeatureFilling.cpp
FeatureFilling.h
FeatureSections.cpp
FeatureSections.h
FeatureSewing.cpp
FeatureSewing.h
FeatureCut.cpp
FeatureCut.h
)
link_directories(${OCC_LIBRARY_DIR})

View File

@@ -24,15 +24,16 @@
#include "PreCompiled.h"
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Interpreter.h>
#include <Base/PyObjectBase.h>
#include <Gui/Application.h>
#include "Workbench.h"
#include "TaskGeomFillSurface.h"
#include "Blending/ViewProviderBlendCurve.h"
#include "TaskFilling.h"
#include "TaskGeomFillSurface.h"
#include "TaskSections.h"
#include "ViewProviderExtend.h"
#include "Workbench.h"
// use a different name to CreateCommand()
@@ -45,7 +46,7 @@ class Module : public Py::ExtensionModule<Module>
public:
Module() : Py::ExtensionModule<Module>("SurfaceGui")
{
initialize("This module is the SurfaceGui module."); // register with Python
initialize("This module is the SurfaceGui module.");// register with Python
}
~Module() override {}
@@ -53,12 +54,11 @@ public:
private:
};
PyObject* initModule()
{
PyObject *initModule(){
return Base::Interpreter().addModule(new Module);
}
} // namespace SurfaceGui
}// namespace SurfaceGui
/* Python entry */
PyMOD_INIT_FUNC(SurfaceGui)
@@ -76,12 +76,13 @@ PyMOD_INIT_FUNC(SurfaceGui)
SurfaceGui::Workbench::init();
SurfaceGui::ViewProviderGeomFillSurface ::init();
SurfaceGui::ViewProviderFilling ::init();
SurfaceGui::ViewProviderSections ::init();
SurfaceGui::ViewProviderExtend::init();
SurfaceGui::ViewProviderFilling ::init();
SurfaceGui::ViewProviderSections ::init();
SurfaceGui::ViewProviderExtend ::init();
SurfaceGui::ViewProviderBlendCurve ::init();
// SurfaceGui::ViewProviderCut::init();
PyObject* mod = SurfaceGui::initModule();
PyObject *mod = SurfaceGui::initModule();
Base::Console().Log("Loading GUI of Surface module... done\n");
PyMOD_Return(mod);
}

View File

@@ -0,0 +1,42 @@
/***************************************************************************
* Copyright (c) 2020 Eliud Cabrera Castillo <matteogrellier@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "../PreCompiled.h"
#include <Gui/BitmapFactory.h>
#include <Mod/Part/Gui/ViewProvider.h>
#include "ViewProviderBlendCurve.h"
using namespace SurfaceGui;
PROPERTY_SOURCE(SurfaceGui::ViewProviderBlendCurve, PartGui::ViewProviderSpline)
namespace SurfaceGui
{
QIcon ViewProviderBlendCurve::getIcon(void) const
{
return Gui::BitmapFactory().pixmap("BlendCurve");
}
}//namespace SurfaceGui

View File

@@ -0,0 +1,42 @@
/***************************************************************************
* Copyright (c) 2020 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef SURFACEGUI_VIEWPROVIDERBLENDCURVE_H
#define SURFACEGUI_VIEWPROVIDERBLENDCURVE_H
#include <Mod/Part/Gui/ViewProviderSpline.h>
#include <Mod/Surface/App/Blending/FeatureBlendCurve.h>
namespace SurfaceGui
{
class ViewProviderBlendCurve: public PartGui::ViewProviderSpline
{
PROPERTY_HEADER(SurfaceGui::ViewProviderBlendCurve);
public:
QIcon getIcon(void) const;
};
}//namespace SurfaceGui
#endif// SURFACEGUI_VIEWPROVIDEREXTEND_H

View File

@@ -36,6 +36,11 @@ SET(SurfaceGui_UIC_SRCS
TaskSections.ui
)
SET(BlendingGui_SRCS
Blending/ViewProviderBlendCurve.cpp
Blending/ViewProviderBlendCurve.h
)
if (BUILD_QT5)
qt5_wrap_ui(SurfaceGui_UIC_HDRS ${SurfaceGui_UIC_SRCS})
else()
@@ -45,6 +50,7 @@ endif()
SET(SurfaceGui_SRCS
${SurfaceGui_QRC_SRCS}
${SurfaceGui_UIC_HDRS}
${BlendingGui_SRCS}
TaskFilling.cpp
TaskFilling.h
TaskFillingEdge.cpp

View File

@@ -61,6 +61,8 @@
#include <App/PropertyUnits.h>
#include <App/PropertyLinks.h>
#include "Mod/Part/App/PartFeature.h"
#include <BRepAdaptor_Curve.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
//===========================================================================
@@ -189,6 +191,8 @@ void CmdSurfaceGeomFillSurface::activated(int iMsg)
}
DEF_STD_CMD_A(CmdSurfaceCurveOnMesh)
CmdSurfaceCurveOnMesh::CmdSurfaceCurveOnMesh()
@@ -204,6 +208,8 @@ CmdSurfaceCurveOnMesh::CmdSurfaceCurveOnMesh()
sPixmap = "Surface_CurveOnMesh";
}
void CmdSurfaceCurveOnMesh::activated(int)
{
doCommand(Doc,"import MeshPartGui, FreeCADGui\n"
@@ -224,6 +230,118 @@ bool CmdSurfaceCurveOnMesh::isActive()
return false;
}
//===========================================================================
// CmdBlendSurface THIS IS THE BLEND SURFACE COMMAND
//===========================================================================
DEF_STD_CMD_A(CmdBlendSurface)
CmdBlendSurface::CmdBlendSurface()
: Command("BlendSurface")
{
sAppModule = "Surface";
sGroup = QT_TR_NOOP("Surface");
sMenuText = QT_TR_NOOP("Blend Surface");
sToolTipText = QT_TR_NOOP("This is the blend Surface feature");
sStatusTip = sToolTipText;
sWhatsThis = "BlendSurface";
sPixmap = "BlendSurface";
}
void CmdBlendSurface::activated(int)
{
}
bool CmdBlendSurface::isActive(void)
{
return true;
}
//===========================================================================
// CmdBlendCurve THIS IS THE BLEND CURVE COMMAND
//===========================================================================
DEF_STD_CMD_A(CmdBlendCurve)
CmdBlendCurve::CmdBlendCurve()
: Command("BlendCurve")
{
sAppModule = "Surface";
sGroup = QT_TR_NOOP("Surface");
sMenuText = QT_TR_NOOP("Blend Curve");
sToolTipText = QT_TR_NOOP("Join two edges with high continuity");
sStatusTip = sToolTipText;
sWhatsThis = "BlendCurve";
sPixmap = "BlendCurve";
}
void CmdBlendCurve::activated(int)
{
// To do add pickpoints to parameters
std::string docName = App::GetApplication().getActiveDocument()->getName();
std::string objName[2];
std::string edge[2];
std::string featName = getUniqueObjectName("BlendCurve");
std::vector<Gui::SelectionObject> sel = getSelection().getSelectionEx(0, Part::Feature::getClassTypeId());
//std::vector<Base::Vector3d> pickedPoints = sel[0].getPickedPoints();
//App::DocumentObject *obj1 = sel[0].getObject();
//App::DocumentObject *obj2 = sel[1].getObject();
//std::vector<std::string> edge1SubName = sel[0].getSubNames();
//std::vector<std::string> edge2SubName = sel[1].getSubNames();
//TopoDS_Shape edge1 = static_cast<Part::Feature *>(obj1)
// ->Shape.getShape()
// .getSubShape(edge1SubName[0].c_str());
//if (edge1.IsNull() || edge1.ShapeType() != TopAbs_EDGE)
// return;
//TopoDS_Shape edge2 = static_cast<Part::Feature *>(obj2)
// ->Shape.getShape()
// .getSubShape(edge2SubName[0].c_str());
//if (edge2.IsNull() || edge2.ShapeType() != TopAbs_EDGE)
// return;
//const TopoDS_Edge &e1 = TopoDS::Edge(edge1);
//BRepAdaptor_Curve adapt1(e1);
//gp_Pnt pnt1(pickedPoints[0].x, pickedPoints[0].y, pickedPoints[0].z);
//GeomAdaptor_Curve geomCurve = adapt1.Curve();
//GeomAPI_ProjectPointOnCurve geomAPI(pnt1, geomCurve.Curve());
//double par = geomAPI.LowerDistanceParameter();
//edge2.Curve.closestParameter(vec, par)
objName[0] = sel[0].getFeatName();
edge[0] = sel[0].getSubNames()[0];
if (sel.size() == 1) {
objName[1] = sel[0].getFeatName();
edge[1] = sel[0].getSubNames()[1];
}
else {
objName[1] = sel[1].getFeatName();
edge[1] = sel[1].getSubNames()[0];
}
openCommand(QT_TRANSLATE_NOOP("Command", "Blend Curve"));
doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::FeatureBlendCurve\",\"%s\")", featName.c_str());
doCommand(Doc, "App.ActiveDocument.%s.StartEdge = (App.getDocument('%s').getObject('%s'),['%s'])", featName.c_str(), docName.c_str(), objName[0].c_str(), edge[0].c_str());
doCommand(Doc, "App.ActiveDocument.%s.EndEdge = (App.getDocument('%s').getObject('%s'),['%s'])", featName.c_str(), docName.c_str(), objName[1].c_str(), edge[1].c_str());
updateActive();
commitCommand();
}
bool CmdBlendCurve::isActive(void)
{
Gui::SelectionFilter edgeFilter("SELECT Part::Feature SUBELEMENT Edge COUNT 2");
return edgeFilter.match();
}
DEF_STD_CMD_A(CmdSurfaceExtendFace)
CmdSurfaceExtendFace::CmdSurfaceExtendFace()
@@ -306,4 +424,6 @@ void CreateSurfaceCommands()
rcCmdMgr.addCommand(new CmdSurfaceSections());
rcCmdMgr.addCommand(new CmdSurfaceExtendFace());
rcCmdMgr.addCommand(new CmdSurfaceCurveOnMesh());
rcCmdMgr.addCommand(new CmdBlendCurve());
rcCmdMgr.addCommand(new CmdBlendSurface());
}

View File

@@ -4,6 +4,7 @@
<file>icons/Surface_BSplineSurface.svg</file>
<file>icons/Surface_CurveOnMesh.svg</file>
<file>icons/Surface_Cut.svg</file>
<file>icons/BlendCurve.svg</file>
<file>icons/Surface_ExtendFace.svg</file>
<file>icons/Surface_Filling.svg</file>
<file>icons/Surface_GeomFillSurface.svg</file>
@@ -11,6 +12,7 @@
<file>icons/Surface_Sewing.svg</file>
<file>icons/Surface_Surface.svg</file>
<file>icons/Surface_Workbench.svg</file>
<file>icons/BlendSurface.svg</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
id="svg2985"
height="64px"
width="64px">
<title
id="title889">Surface_Sewing</title>
<defs
id="defs2987">
<linearGradient
id="linearGradient4387">
<stop
id="stop4389"
offset="0"
style="stop-color:#71b2f8;stop-opacity:1;" />
<stop
id="stop4391"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient6321">
<stop
id="stop6323"
offset="0"
style="stop-color:#71b2f8;stop-opacity:1;" />
<stop
id="stop6325"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<radialGradient
gradientTransform="translate(-0.23443224,0.23443198)"
gradientUnits="userSpaceOnUse"
r="19.467436"
fy="28.869568"
fx="45.883327"
cy="28.869568"
cx="45.883327"
id="radialGradient3692"
xlink:href="#linearGradient3377" />
<linearGradient
id="linearGradient3377">
<stop
style="stop-color:#faff2b;stop-opacity:1;"
offset="0"
id="stop3379" />
<stop
style="stop-color:#ffaa00;stop-opacity:1;"
offset="1"
id="stop3381" />
</linearGradient>
<linearGradient
id="linearGradient3377-3">
<stop
style="stop-color:#faff2b;stop-opacity:1;"
offset="0"
id="stop3379-8" />
<stop
style="stop-color:#ffaa00;stop-opacity:1;"
offset="1"
id="stop3381-3" />
</linearGradient>
<radialGradient
r="19.467436"
fy="28.869568"
fx="45.883327"
cy="28.869568"
cx="45.883327"
gradientTransform="matrix(0.67067175,0,0,0.64145918,-63.380792,0.83845403)"
gradientUnits="userSpaceOnUse"
id="radialGradient6412"
xlink:href="#linearGradient3377-3" />
<linearGradient
id="linearGradient3036">
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="0"
id="stop3038" />
<stop
style="stop-color:#a40000;stop-opacity:1"
offset="1"
id="stop3040" />
</linearGradient>
<linearGradient
gradientTransform="matrix(0.96812402,0,0,0.96755864,-0.72057496,-2.6783592)"
xlink:href="#linearGradient1189"
id="linearGradient2095"
x1="47"
y1="9"
x2="7"
y2="28"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient1189">
<stop
style="stop-color:#204a87;stop-opacity:1"
offset="0"
id="stop1185" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop1187" />
</linearGradient>
</defs>
<metadata
id="metadata2990">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Surface_Sewing</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[bitacovir]</dc:title>
</cc:Agent>
</dc:creator>
<dc:title>Part_Shape_from_Mesh</dc:title>
<dc:date>2020/10/03</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier />
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:contributor>
<dc:subject>
<rdf:Bag>
<rdf:li>surface</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:description />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
style="display:inline;fill:url(#linearGradient2095);fill-opacity:1;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.1519208,24.413282 17.899691,60.320494 c 14.52186,-34.832109 31.154371,7.93994 42.771854,-25.924611 L 38.972508,3.1269928 C 30.809307,30.407148 17.749067,-0.16084869 3.1519208,24.413282 Z"
id="path3820-1-9" />
<path
id="path3820-1-9-6"
d="M 5.3492197,24.626663 18.113409,55.643482 C 32.677175,26.678261 49.470489,63.641047 58.406281,34.501823 L 39.63819,7.4361573 C 30.967406,29.589343 16.774125,4.5857267 5.3492197,24.626663 Z"
style="display:inline;fill:none;fill-opacity:1;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#0b1521;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 10.982526,42.149889 C 22.049849,14.305576 38.645757,44.184548 50.089385,20.093327"
id="path1219-0" />
<path
id="path882"
d="m 27.670296,26.630997 c 10.9647,1.930433 15.10812,2.91774 20.11825,-7.524843"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="path859"
d="m 38.193663,21.887236 9.330416,13.952023"
style="fill:none;stroke:#0b1521;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 31.751036,32.387618 C 22.26124,30.47478 16.502839,32.473328 13.131071,43.29124"
id="path882-9" />
<path
style="fill:none;stroke:#0b1521;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 13.709416,25.210411 21.313357,40.45729"
id="path859-1" />
<path
style="fill:none;stroke:#0b1521;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 25.62034,22.195278 7.9739,14.506961"
id="path859-0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -44,40 +44,42 @@ Workbench::~Workbench()
{
}
Gui::MenuItem* Workbench::setupMenuBar() const
Gui::MenuItem *Workbench::setupMenuBar() const
{
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
Gui::MenuItem* item = root->findItem( "&Windows" );
Gui::MenuItem *root = StdWorkbench::setupMenuBar();
Gui::MenuItem *item = root->findItem("&Windows");
Gui::MenuItem* surface = new Gui::MenuItem;
root->insertItem( item, surface );
Gui::MenuItem *surface = new Gui::MenuItem;
root->insertItem(item, surface);
surface->setCommand("Surface");
*surface << "Surface_Filling"
<< "Surface_GeomFillSurface"
<< "Surface_Sections"
<< "Surface_ExtendFace"
<< "Surface_CurveOnMesh";
/*
<< "Surface_CurveOnMesh"
<< "BlendCurve";
/*
*surface << "Surface_Cut";
*/
*/
return root;
}
Gui::ToolBarItem* Workbench::setupToolBars() const
Gui::ToolBarItem *Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
Gui::ToolBarItem *root = StdWorkbench::setupToolBars();
Gui::ToolBarItem* surface = new Gui::ToolBarItem(root);
Gui::ToolBarItem *surface = new Gui::ToolBarItem(root);
surface->setCommand("Surface");
*surface << "Surface_Filling"
<< "Surface_GeomFillSurface"
<< "Surface_Sections"
<< "Surface_ExtendFace"
<< "Surface_CurveOnMesh";
/*
<< "Surface_CurveOnMesh"
<< "BlendCurve";
/*
*surface << "Surface_Cut";
*/
*/
return root;
}