Merge pull request #475 from abdullahtahiriyo/bspline_stage1b_2017_firstdeliverable

Bspline stage1b 2017 firstdeliverable
This commit is contained in:
wwmayer
2017-01-27 18:20:16 +01:00
committed by GitHub
5 changed files with 247 additions and 36 deletions

View File

@@ -290,6 +290,28 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) intArg4;
return 0;
}
else if (strstr(ConstraintType,"InternalAlignment") != NULL) { // InteralAlignment with InternalElementIndex argument
this->getConstraintPtr()->Type = InternalAlignment;
valid = true;
if(strstr(ConstraintType,"BSplineControlPoint") != NULL) {
this->getConstraintPtr()->AlignmentType=BSplineControlPoint;
}
else {
this->getConstraintPtr()->AlignmentType=Undef;
valid = false;
}
if (valid) {
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
this->getConstraintPtr()->Second = intArg3;
this->getConstraintPtr()->InternalAlignmentIndex = intArg4;
return 0;
}
}
if (valid) {
this->getConstraintPtr()->First = intArg1;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;

View File

@@ -671,6 +671,32 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed)
std::vector<int> mult = bsp->getMultiplicities();
int degree = bsp->getDegree();
bool periodic = bsp->isPeriodic();
// OCC hack
// c means there is a constraint on that weight, nc no constraint
// OCC provides normalized weights when polynomic [1 1 1] [c c c] and unnormalized weights when rational [5 1 5] [c nc c]
// then when changing from polynomic to rational, after the first solve any not-constrained pole circle gets normalized to 1.
// This only happens when changing from polynomic to rational, any subsequent change remains unnormalized [5 1 5] [c nc nc]
// This creates a visual problem that one of the poles shrinks to 1 mm when deleting an equality constraint.
int lastoneindex = -1;
int countones = 0;
double lastnotone = 1.0;
for(size_t i = 0; i < weights.size(); i++) {
if(weights[i] != 1.0) {
lastnotone = weights[i];
}
else { // is 1.0
lastoneindex = i;
countones++;
}
}
if (countones == 1)
weights[lastoneindex] = (lastnotone * 0.99);
// end hack
Base::Vector3d startPnt = bsp->getStartPoint();
Base::Vector3d endPnt = bsp->getEndPoint();