add two scaling modes

This commit is contained in:
Stefan Tröger 2015-06-01 06:58:40 +02:00
parent df386cc3c1
commit 68ee7f4f27
7 changed files with 192 additions and 19 deletions

View File

@ -53,6 +53,9 @@
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <Law_Function.hxx>
#include <Law_Linear.hxx>
#include <Law_S.hxx>
#endif
#include <Base/Exception.h>
@ -70,7 +73,7 @@ using namespace PartDesign;
const char* Pipe::TypeEnums[] = {"FullPath","UpToFace",NULL};
const char* Pipe::TransitionEnums[] = {"Transformed","Right corner", "Round corner",NULL};
const char* Pipe::ModeEnums[] = {"Standart", "Fixed", "Frenet", "Auxillery", "Binormal", NULL};
const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Auxillery", NULL};
const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Linear", "S-shape", "Interpolation", NULL};
PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::SketchBased)
@ -88,6 +91,7 @@ Pipe::Pipe()
ADD_PROPERTY_TYPE(Binormal,(Base::Vector3d()),"Sweep",App::Prop_None,"Binormal vector for coresponding orientation mode");
ADD_PROPERTY_TYPE(Transition,(long(0)),"Sweep",App::Prop_None,"Transition mode");
ADD_PROPERTY_TYPE(Transformation,(long(0)),"Sweep",App::Prop_None,"Section transformation mode");
ADD_PROPERTY_TYPE(ScalingData, (), "Sweep", App::Prop_None, "Data for scaling laws");
Mode.setEnums(ModeEnums);
Transition.setEnums(TransitionEnums);
Transformation.setEnums(TransformEnums);
@ -163,7 +167,10 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
std::vector<std::vector<TopoDS_Wire>> wiresections;
for(TopoDS_Wire& wire : wires)
wiresections.push_back(std::vector<TopoDS_Wire>(1, wire));
//maybe we need a sacling law
Handle(Law_Function) scalinglaw;
//see if we shall use multiple sections
if(Transformation.getValue() == 1) {
//we need to order the sections to prevent occ from crahsing, as makepieshell connects
@ -188,6 +195,25 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
}
}
//build the law functions instead
else if(Transformation.getValue() == 2) {
if(ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for liinear scaling mode");
Handle(Law_Linear) lin = new Law_Linear();
lin->Set(0,1,1,ScalingData[0].x);
scalinglaw = lin;
}
else if(Transformation.getValue() == 3) {
if(ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for liinear scaling mode");
Handle(Law_S) s = new Law_S();
s->Set(0,1,ScalingData[0].y, 1, ScalingData[0].x, ScalingData[0].z);
scalinglaw = s;
}
//build all shells
std::vector<TopoDS_Shape> shells;
@ -197,8 +223,14 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
BRepOffsetAPI_MakePipeShell mkPS(TopoDS::Wire(path));
setupAlgorithm(mkPS, auxpath);
for(TopoDS_Wire& wire : wires)
mkPS.Add(wire);
if(!scalinglaw) {
for(TopoDS_Wire& wire : wires)
mkPS.Add(wire);
}
else {
for(TopoDS_Wire& wire : wires)
mkPS.SetLaw(wire, scalinglaw);
}
if (!mkPS.IsReady())
return new App::DocumentObjectExecReturn("pipe could not be build");

View File

@ -49,6 +49,7 @@ public:
App::PropertyEnumeration Transition;
App::PropertyEnumeration Transformation;
App::PropertyLinkList Sections;
App::PropertyVectorList ScalingData;
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;

View File

@ -212,6 +212,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
@ -222,6 +225,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1">
@ -232,6 +238,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
</layout>

View File

@ -537,6 +537,14 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool newObj, QWidge
this, SLOT(onButtonRefRemove(bool)));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)),
this, SLOT(updateUI(int)));
connect(ui->linearSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onLinearSpinBox(double)));
connect(ui->sshapeSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onSshapeChanged(double)));
connect(ui->sshapeStartDeriSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onSshapeChanged(double)));
connect(ui->sshapeEndDeriSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onSshapeChanged(double)));
this->groupLayout()->addWidget(proxy);
@ -582,8 +590,13 @@ void TaskPipeScaling::onButtonRefRemove(bool checked) {
void TaskPipeScaling::onScalingChanged(int idx) {
updateUI(idx);
static_cast<PartDesign::Pipe*>(vp->getObject())->Transformation.setValue(idx);
recomputeFeature();
if(idx==2)
onLinearSpinBox(ui->linearSpinBox->value());
else if(idx==3)
onSshapeChanged(0);
}
void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) {
@ -666,6 +679,23 @@ void TaskPipeScaling::updateUI(int idx) {
ui->stackedWidget->widget(idx)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
void TaskPipeScaling::onLinearSpinBox(double val) {
static_cast<PartDesign::Pipe*>(vp->getObject())->ScalingData.setValue(Base::Vector3d(val,0,0));
recomputeFeature();
}
void TaskPipeScaling::onSshapeChanged(double val) {
double f, d0, d1;
f = ui->sshapeSpinBox->value();
d0 = ui->sshapeStartDeriSpinBox->value();
d1 = ui->sshapeEndDeriSpinBox->value();
static_cast<PartDesign::Pipe*>(vp->getObject())->ScalingData.setValue(Base::Vector3d(f, d0, d1));
recomputeFeature();
}
//**************************************************************************
//**************************************************************************

View File

@ -138,6 +138,8 @@ private Q_SLOTS:
void onButtonRefAdd(bool checked);
void onButtonRefRemove(bool checked);
void updateUI(int idx);
void onLinearSpinBox(double val);
void onSshapeChanged(double val);
protected:
enum selectionModes { none, refAdd, refRemove };

View File

@ -43,7 +43,12 @@
</item>
<item>
<property name="text">
<string>Auxillery</string>
<string>Linear</string>
</property>
</item>
<item>
<property name="text">
<string>S-Shape</string>
</property>
</item>
</widget>
@ -113,20 +118,114 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="auxillery">
<widget class="QWidget" name="linear">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>This mode is only available if the orientation is given by a secondary profile</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Final scaling factor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="linearSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="sshape">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Scaling factor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="sshapeSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-9999.000000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Derivative at start</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="sshapeStartDeriSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Derivative at end</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="sshapeEndDeriSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View File

@ -172,7 +172,7 @@ void ViewProviderPipe::highlightReferences(const bool on, bool auxillery)
TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap);
originalLineColors = svp->LineColorArray.getValues();
std::vector<App::Color> colors = originalLineColors;
colors.resize(eMap.Extent(), LineColor.getValue());
colors.resize(eMap.Extent(), svp->LineColor.getValue());
for (std::string e : edges) {
int idx = atoi(e.substr(4).c_str()) - 1;