+ Special view provider to display splines
This commit is contained in:
parent
f061b6f7ea
commit
25b6645e09
|
@ -38,6 +38,7 @@
|
||||||
#include "FeaturePartCurveNet.h"
|
#include "FeaturePartCurveNet.h"
|
||||||
#include "FeaturePartCircle.h"
|
#include "FeaturePartCircle.h"
|
||||||
#include "FeaturePartPolygon.h"
|
#include "FeaturePartPolygon.h"
|
||||||
|
#include "FeaturePartSpline.h"
|
||||||
#include "FeatureGeometrySet.h"
|
#include "FeatureGeometrySet.h"
|
||||||
#include "FeatureChamfer.h"
|
#include "FeatureChamfer.h"
|
||||||
#include "FeatureCompound.h"
|
#include "FeatureCompound.h"
|
||||||
|
@ -164,6 +165,7 @@ void PartExport initPart()
|
||||||
Part::CustomFeaturePython ::init();
|
Part::CustomFeaturePython ::init();
|
||||||
Part::Primitive ::init();
|
Part::Primitive ::init();
|
||||||
Part::Box ::init();
|
Part::Box ::init();
|
||||||
|
Part::Spline ::init();
|
||||||
Part::Boolean ::init();
|
Part::Boolean ::init();
|
||||||
Part::Common ::init();
|
Part::Common ::init();
|
||||||
Part::MultiCommon ::init();
|
Part::MultiCommon ::init();
|
||||||
|
|
|
@ -101,6 +101,8 @@ SET(Features_SRCS
|
||||||
FeaturePartPolygon.h
|
FeaturePartPolygon.h
|
||||||
FeaturePartSection.cpp
|
FeaturePartSection.cpp
|
||||||
FeaturePartSection.h
|
FeaturePartSection.h
|
||||||
|
FeaturePartSpline.cpp
|
||||||
|
FeaturePartSpline.h
|
||||||
FeatureChamfer.cpp
|
FeatureChamfer.cpp
|
||||||
FeatureChamfer.h
|
FeatureChamfer.h
|
||||||
FeatureCompound.cpp
|
FeatureCompound.cpp
|
||||||
|
|
42
src/Mod/Part/App/FeaturePartSpline.cpp
Normal file
42
src/Mod/Part/App/FeaturePartSpline.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||||
|
* *
|
||||||
|
* 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"
|
||||||
|
#ifndef _PreComp_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "FeaturePartSpline.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Part;
|
||||||
|
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(Part::Spline, Part::Feature)
|
||||||
|
|
||||||
|
|
||||||
|
Spline::Spline()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
49
src/Mod/Part/App/FeaturePartSpline.h
Normal file
49
src/Mod/Part/App/FeaturePartSpline.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||||
|
* *
|
||||||
|
* 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 PART_FEATUREPARTSPLINE_H
|
||||||
|
#define PART_FEATUREPARTSPLINE_H
|
||||||
|
|
||||||
|
#include "PartFeature.h"
|
||||||
|
|
||||||
|
namespace Part
|
||||||
|
{
|
||||||
|
|
||||||
|
class PartExport Spline :public Part::Feature
|
||||||
|
{
|
||||||
|
PROPERTY_HEADER(Part::Spline);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Spline();
|
||||||
|
/// returns the type name of the ViewProvider
|
||||||
|
const char* getViewProviderName(void) const {
|
||||||
|
return "PartGui::ViewProviderSpline";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace Part
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PART_FEATUREPARTSPLINE_H
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "ViewProviderTorusParametric.h"
|
#include "ViewProviderTorusParametric.h"
|
||||||
#include "ViewProviderRuledSurface.h"
|
#include "ViewProviderRuledSurface.h"
|
||||||
#include "ViewProviderPrism.h"
|
#include "ViewProviderPrism.h"
|
||||||
|
#include "ViewProviderSpline.h"
|
||||||
|
|
||||||
#include "DlgSettingsGeneral.h"
|
#include "DlgSettingsGeneral.h"
|
||||||
#include "DlgSettingsObjectColor.h"
|
#include "DlgSettingsObjectColor.h"
|
||||||
|
@ -139,6 +140,7 @@ void PartGuiExport initPartGui()
|
||||||
PartGui::ViewProviderConeParametric ::init();
|
PartGui::ViewProviderConeParametric ::init();
|
||||||
PartGui::ViewProviderTorusParametric ::init();
|
PartGui::ViewProviderTorusParametric ::init();
|
||||||
PartGui::ViewProviderRuledSurface ::init();
|
PartGui::ViewProviderRuledSurface ::init();
|
||||||
|
PartGui::ViewProviderSpline ::init();
|
||||||
|
|
||||||
PartGui::Workbench ::init();
|
PartGui::Workbench ::init();
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,8 @@ SET(PartGui_SRCS
|
||||||
ViewProviderTorusParametric.h
|
ViewProviderTorusParametric.h
|
||||||
ViewProviderCurveNet.cpp
|
ViewProviderCurveNet.cpp
|
||||||
ViewProviderCurveNet.h
|
ViewProviderCurveNet.h
|
||||||
|
ViewProviderSpline.cpp
|
||||||
|
ViewProviderSpline.h
|
||||||
ViewProviderImport.cpp
|
ViewProviderImport.cpp
|
||||||
ViewProviderImport.h
|
ViewProviderImport.h
|
||||||
ViewProviderExtrusion.cpp
|
ViewProviderExtrusion.cpp
|
||||||
|
|
|
@ -149,7 +149,6 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||||
ADD_PROPERTY(PointSize,(lwidth));
|
ADD_PROPERTY(PointSize,(lwidth));
|
||||||
ADD_PROPERTY(Deviation,(0.5f));
|
ADD_PROPERTY(Deviation,(0.5f));
|
||||||
Deviation.setConstraints(&tessRange);
|
Deviation.setConstraints(&tessRange);
|
||||||
ADD_PROPERTY(ControlPoints,(false));
|
|
||||||
ADD_PROPERTY(Lighting,(1));
|
ADD_PROPERTY(Lighting,(1));
|
||||||
Lighting.setEnums(LightingEnums);
|
Lighting.setEnums(LightingEnums);
|
||||||
ADD_PROPERTY(DrawStyle,((long int)0));
|
ADD_PROPERTY(DrawStyle,((long int)0));
|
||||||
|
|
|
@ -75,7 +75,6 @@ public:
|
||||||
App::PropertyColor PointColor;
|
App::PropertyColor PointColor;
|
||||||
App::PropertyMaterial LineMaterial;
|
App::PropertyMaterial LineMaterial;
|
||||||
App::PropertyMaterial PointMaterial;
|
App::PropertyMaterial PointMaterial;
|
||||||
App::PropertyBool ControlPoints;
|
|
||||||
App::PropertyEnumeration Lighting;
|
App::PropertyEnumeration Lighting;
|
||||||
App::PropertyEnumeration DrawStyle;
|
App::PropertyEnumeration DrawStyle;
|
||||||
|
|
||||||
|
@ -126,7 +125,6 @@ protected:
|
||||||
SoMaterial * pcPointMaterial;
|
SoMaterial * pcPointMaterial;
|
||||||
SoDrawStyle * pcLineStyle;
|
SoDrawStyle * pcLineStyle;
|
||||||
SoDrawStyle * pcPointStyle;
|
SoDrawStyle * pcPointStyle;
|
||||||
//SoSwitch * pcControlPoints;
|
|
||||||
SoShapeHints * pShapeHints;
|
SoShapeHints * pShapeHints;
|
||||||
|
|
||||||
SoCoordinate3 * coords;
|
SoCoordinate3 * coords;
|
||||||
|
|
301
src/Mod/Part/Gui/ViewProviderSpline.cpp
Normal file
301
src/Mod/Part/Gui/ViewProviderSpline.cpp
Normal file
|
@ -0,0 +1,301 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||||
|
* *
|
||||||
|
* 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"
|
||||||
|
#ifndef _PreComp_
|
||||||
|
# include <BRepAdaptor_Curve.hxx>
|
||||||
|
# include <BRepAdaptor_Surface.hxx>
|
||||||
|
# include <GeomAbs_CurveType.hxx>
|
||||||
|
# include <GeomAbs_SurfaceType.hxx>
|
||||||
|
# include <Geom_BezierCurve.hxx>
|
||||||
|
# include <Geom_BSplineCurve.hxx>
|
||||||
|
# include <Geom_BezierSurface.hxx>
|
||||||
|
# include <Geom_BSplineSurface.hxx>
|
||||||
|
# include <gp_Pnt.hxx>
|
||||||
|
# include <TopoDS.hxx>
|
||||||
|
# include <TopoDS_Edge.hxx>
|
||||||
|
# include <TopoDS_Wire.hxx>
|
||||||
|
# include <TopoDS_Face.hxx>
|
||||||
|
# include <TopoDS_Shape.hxx>
|
||||||
|
# include <TopoDS_Iterator.hxx>
|
||||||
|
# include <TopExp_Explorer.hxx>
|
||||||
|
# include <Inventor/nodes/SoCoordinate3.h>
|
||||||
|
# include <Inventor/nodes/SoSeparator.h>
|
||||||
|
# include <Inventor/nodes/SoSwitch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <App/PropertyStandard.h>
|
||||||
|
#include <Mod/Part/App/PartFeature.h>
|
||||||
|
#include "SoFCShapeObject.h"
|
||||||
|
#include "ViewProviderSpline.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace PartGui;
|
||||||
|
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(PartGui::ViewProviderSpline, PartGui::ViewProviderPartExt)
|
||||||
|
|
||||||
|
ViewProviderSpline::ViewProviderSpline()
|
||||||
|
: pcControlPoints(0)
|
||||||
|
{
|
||||||
|
ADD_PROPERTY(ControlPoints,(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewProviderSpline::~ViewProviderSpline()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderSpline::onChanged(const App::Property* prop)
|
||||||
|
{
|
||||||
|
if (prop == &ControlPoints) {
|
||||||
|
App::DocumentObject* obj = this->pcObject;
|
||||||
|
App::Property* shape = obj->getPropertyByName("Shape");
|
||||||
|
showControlPoints(ControlPoints.getValue(), shape);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ViewProviderPartExt::onChanged(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderSpline::showControlPoints(bool show, const App::Property* prop)
|
||||||
|
{
|
||||||
|
if (!pcControlPoints && show) {
|
||||||
|
pcControlPoints = new SoSwitch();
|
||||||
|
pcRoot->addChild(pcControlPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcControlPoints) {
|
||||||
|
pcControlPoints->whichChild = (show ? SO_SWITCH_ALL : SO_SWITCH_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!show || !pcControlPoints || pcControlPoints->getNumChildren() > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ask for the property we are interested in
|
||||||
|
if (prop && prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) {
|
||||||
|
const TopoDS_Shape& shape = static_cast<const Part::PropertyPartShape*>(prop)->getValue();
|
||||||
|
if (shape.IsNull())
|
||||||
|
return; // empty shape
|
||||||
|
switch (shape.ShapeType())
|
||||||
|
{
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
{
|
||||||
|
const TopoDS_Edge& edge = TopoDS::Edge(shape);
|
||||||
|
showControlPointsOfEdge(edge);
|
||||||
|
} break;
|
||||||
|
case TopAbs_WIRE:
|
||||||
|
{
|
||||||
|
const TopoDS_Wire& wire = TopoDS::Wire(shape);
|
||||||
|
showControlPointsOfWire(wire);
|
||||||
|
} break;
|
||||||
|
case TopAbs_FACE:
|
||||||
|
{
|
||||||
|
const TopoDS_Face& face = TopoDS::Face(shape);
|
||||||
|
showControlPointsOfFace(face);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderSpline::showControlPointsOfEdge(const TopoDS_Edge& edge)
|
||||||
|
{
|
||||||
|
std::list<gp_Pnt> poles, knots;
|
||||||
|
Standard_Integer nCt=0;
|
||||||
|
BRepAdaptor_Curve curve(edge);
|
||||||
|
switch (curve.GetType())
|
||||||
|
{
|
||||||
|
case GeomAbs_BezierCurve:
|
||||||
|
{
|
||||||
|
Handle(Geom_BezierCurve) hBezier = curve.Bezier();
|
||||||
|
nCt = hBezier->NbPoles();
|
||||||
|
for (Standard_Integer i = 1; i <= nCt; i++)
|
||||||
|
poles.push_back(hBezier->Pole(i));
|
||||||
|
if (hBezier->IsClosed()) {
|
||||||
|
nCt++;
|
||||||
|
poles.push_back(hBezier->Pole(1));
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case GeomAbs_BSplineCurve:
|
||||||
|
{
|
||||||
|
Handle(Geom_BSplineCurve) hBSpline = curve.BSpline();
|
||||||
|
nCt = hBSpline->NbPoles();
|
||||||
|
for (Standard_Integer i = 1; i <= nCt; i++)
|
||||||
|
poles.push_back(hBSpline->Pole(i));
|
||||||
|
if (hBSpline->IsClosed()) {
|
||||||
|
nCt++;
|
||||||
|
poles.push_back(hBSpline->Pole(1));
|
||||||
|
}
|
||||||
|
for (Standard_Integer i = hBSpline->FirstUKnotIndex()+1; i <= hBSpline->LastUKnotIndex()-1; i++)
|
||||||
|
knots.push_back(hBSpline->Value(hBSpline->Knot(i)));
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (poles.empty())
|
||||||
|
return; // nothing to do
|
||||||
|
|
||||||
|
SoCoordinate3 * coords = new SoCoordinate3;
|
||||||
|
coords->point.setNum(nCt + knots.size());
|
||||||
|
|
||||||
|
int index=0;
|
||||||
|
SbVec3f* verts = coords->point.startEditing();
|
||||||
|
for (std::list<gp_Pnt>::iterator p = poles.begin(); p != poles.end(); ++p) {
|
||||||
|
verts[index++].setValue((float)p->X(), (float)p->Y(), (float)p->Z());
|
||||||
|
}
|
||||||
|
for (std::list<gp_Pnt>::iterator k = knots.begin(); k != knots.end(); ++k) {
|
||||||
|
verts[index++].setValue((float)k->X(), (float)k->Y(), (float)k->Z());
|
||||||
|
}
|
||||||
|
coords->point.finishEditing();
|
||||||
|
|
||||||
|
|
||||||
|
SoFCControlPoints* control = new SoFCControlPoints();
|
||||||
|
control->numPolesU = nCt;
|
||||||
|
control->numPolesV = 1;
|
||||||
|
|
||||||
|
SoSeparator* nodes = new SoSeparator();
|
||||||
|
nodes->addChild(coords);
|
||||||
|
nodes->addChild(control);
|
||||||
|
|
||||||
|
pcControlPoints->addChild(nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderSpline::showControlPointsOfWire(const TopoDS_Wire& wire)
|
||||||
|
{
|
||||||
|
TopoDS_Iterator it;
|
||||||
|
for (it.Initialize(wire); it.More(); it.Next()) {
|
||||||
|
if (it.Value().ShapeType() == TopAbs_EDGE) {
|
||||||
|
const TopoDS_Edge& edge = TopoDS::Edge(it.Value());
|
||||||
|
BRepAdaptor_Curve curve(edge);
|
||||||
|
|
||||||
|
std::list<gp_Pnt> poles, knots;
|
||||||
|
gp_Pnt start, end;
|
||||||
|
switch (curve.GetType())
|
||||||
|
{
|
||||||
|
case GeomAbs_BezierCurve:
|
||||||
|
{
|
||||||
|
Handle(Geom_BezierCurve) hBezier = curve.Bezier();
|
||||||
|
for (Standard_Integer i = 1; i <= hBezier->NbPoles(); i++)
|
||||||
|
poles.push_back(hBezier->Pole(i));
|
||||||
|
start = hBezier->StartPoint();
|
||||||
|
end = hBezier->EndPoint();
|
||||||
|
} break;
|
||||||
|
case GeomAbs_BSplineCurve:
|
||||||
|
{
|
||||||
|
Handle(Geom_BSplineCurve) hBSpline = curve.BSpline();
|
||||||
|
for (Standard_Integer i = 1; i <= hBSpline->NbPoles(); i++)
|
||||||
|
poles.push_back(hBSpline->Pole(i));
|
||||||
|
start = hBSpline->StartPoint();
|
||||||
|
end = hBSpline->EndPoint();
|
||||||
|
for (Standard_Integer i = hBSpline->FirstUKnotIndex()+1; i <= hBSpline->LastUKnotIndex()-1; i++)
|
||||||
|
knots.push_back(hBSpline->Value(hBSpline->Knot(i)));
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderSpline::showControlPointsOfFace(const TopoDS_Face& face)
|
||||||
|
{
|
||||||
|
std::list<gp_Pnt> knots;
|
||||||
|
std::vector<std::vector<gp_Pnt> > poles;
|
||||||
|
Standard_Integer nCtU=0, nCtV=0;
|
||||||
|
BRepAdaptor_Surface surface(face);
|
||||||
|
|
||||||
|
BRepAdaptor_Surface clSurface(face);
|
||||||
|
switch (clSurface.GetType())
|
||||||
|
{
|
||||||
|
case GeomAbs_BezierSurface:
|
||||||
|
{
|
||||||
|
Handle(Geom_BezierSurface) hBezier = surface.Bezier();
|
||||||
|
nCtU = hBezier->NbUPoles();
|
||||||
|
nCtV = hBezier->NbVPoles();
|
||||||
|
poles.resize(nCtU);
|
||||||
|
for (Standard_Integer u = 1; u <= nCtU; u++) {
|
||||||
|
poles[u-1].resize(nCtV);
|
||||||
|
for (Standard_Integer v = 1; v <= nCtV; v++)
|
||||||
|
poles[u-1][v-1] = hBezier->Pole(u, v);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case GeomAbs_BSplineSurface:
|
||||||
|
{
|
||||||
|
Handle(Geom_BSplineSurface) hBSpline = surface.BSpline();
|
||||||
|
nCtU = hBSpline->NbUPoles();
|
||||||
|
nCtV = hBSpline->NbVPoles();
|
||||||
|
poles.resize(nCtU);
|
||||||
|
for (Standard_Integer u = 1; u <= nCtU; u++) {
|
||||||
|
poles[u-1].resize(nCtV);
|
||||||
|
for (Standard_Integer v = 1; v <= nCtV; v++)
|
||||||
|
poles[u-1][v-1] = hBSpline->Pole(u, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Standard_Integer nKnU = hBSpline->NbUKnots();
|
||||||
|
//Standard_Integer nKnV = hBSpline->NbVKnots();
|
||||||
|
for (Standard_Integer u = 1; u <= hBSpline->NbUKnots(); u++) {
|
||||||
|
for (Standard_Integer v = 1; v <= hBSpline->NbVKnots(); v++)
|
||||||
|
knots.push_back(hBSpline->Value(hBSpline->UKnot(u), hBSpline->VKnot(v)));
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (poles.empty())
|
||||||
|
return; // nothing to do
|
||||||
|
|
||||||
|
SoCoordinate3 * coords = new SoCoordinate3;
|
||||||
|
coords->point.setNum(nCtU * nCtV + knots.size());
|
||||||
|
|
||||||
|
int index=0;
|
||||||
|
SbVec3f* verts = coords->point.startEditing();
|
||||||
|
for (std::vector<std::vector<gp_Pnt> >::iterator u = poles.begin(); u != poles.end(); ++u) {
|
||||||
|
for (std::vector<gp_Pnt>::iterator v = u->begin(); v != u->end(); ++v) {
|
||||||
|
verts[index++].setValue((float)v->X(), (float)v->Y(), (float)v->Z());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (std::list<gp_Pnt>::iterator k = knots.begin(); k != knots.end(); ++k) {
|
||||||
|
verts[index++].setValue((float)k->X(), (float)k->Y(), (float)k->Z());
|
||||||
|
}
|
||||||
|
coords->point.finishEditing();
|
||||||
|
|
||||||
|
|
||||||
|
SoFCControlPoints* control = new SoFCControlPoints();
|
||||||
|
control->numPolesU = nCtU;
|
||||||
|
control->numPolesV = nCtV;
|
||||||
|
|
||||||
|
//if (knots.size() > 0) {
|
||||||
|
// control->numKnotsU = nKnU;
|
||||||
|
// control->numKnotsV = nKnV;
|
||||||
|
//}
|
||||||
|
|
||||||
|
SoSeparator* nodes = new SoSeparator();
|
||||||
|
nodes->addChild(coords);
|
||||||
|
nodes->addChild(control);
|
||||||
|
|
||||||
|
pcControlPoints->addChild(nodes);
|
||||||
|
}
|
60
src/Mod/Part/Gui/ViewProviderSpline.h
Normal file
60
src/Mod/Part/Gui/ViewProviderSpline.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||||
|
* *
|
||||||
|
* 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 PARTGUI_VIEWPROVIDERPARTSPLINE_H
|
||||||
|
#define PARTGUI_VIEWPROVIDERPARTSPLINE_H
|
||||||
|
|
||||||
|
#include "ViewProviderExt.h"
|
||||||
|
|
||||||
|
namespace PartGui
|
||||||
|
{
|
||||||
|
|
||||||
|
class PartGuiExport ViewProviderSpline : public ViewProviderPartExt
|
||||||
|
{
|
||||||
|
PROPERTY_HEADER(PartGui::ViewProviderSpline);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// constructor
|
||||||
|
ViewProviderSpline();
|
||||||
|
/// destructor
|
||||||
|
virtual ~ViewProviderSpline();
|
||||||
|
|
||||||
|
// Display properties
|
||||||
|
App::PropertyBool ControlPoints;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onChanged(const App::Property* prop);
|
||||||
|
void showControlPoints(bool, const App::Property* prop);
|
||||||
|
void showControlPointsOfEdge(const TopoDS_Edge&);
|
||||||
|
void showControlPointsOfWire(const TopoDS_Wire&);
|
||||||
|
void showControlPointsOfFace(const TopoDS_Face&);
|
||||||
|
|
||||||
|
SoSwitch *pcControlPoints;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace PartGui
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PARTGUI_VIEWPROVIDERPARTSPLINE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user