remove trailing spaces

This commit is contained in:
wmayer
2018-11-05 10:53:01 +01:00
parent 0e9334aec2
commit a67ee5648c
5 changed files with 35 additions and 42 deletions

View File

@@ -104,9 +104,11 @@ public:
inline double getValue() const {
return Value;
}
inline bool isDimensional() const { return Type == Distance || Type == DistanceX || Type == DistanceY ||
Type == Radius || Type == Diameter || Type == Angle || Type == SnellsLaw;}
inline bool isDimensional() const {
return Type == Distance || Type == DistanceX || Type == DistanceY ||
Type == Radius || Type == Diameter || Type == Angle || Type == SnellsLaw;
}
friend class PropertyConstraintList;

View File

@@ -385,7 +385,7 @@ int SketchObject::toggleDriving(int ConstrId)
if (extorconstructionpoint1 && extorconstructionpoint2 && extorconstructionpoint3 && vals[ConstrId]->isDriving==false)
return -4;
// copy the list
std::vector<Constraint *> newVals(vals);
// clone the changed Constraint
@@ -409,14 +409,13 @@ int SketchObject::testDrivingChange(int ConstrId, bool isdriving)
if (ConstrId < 0 || ConstrId >= int(vals.size()))
return -1;
if (!vals[ConstrId]->isDimensional())
return -2;
if (!(vals[ConstrId]->First>=0 || vals[ConstrId]->Second>=0 || vals[ConstrId]->Third>=0) && isdriving==true)
return -3; // a constraint that does not have at least one element as not-external-geometry can never be driving.
return 0;
}
@@ -424,36 +423,31 @@ int SketchObject::testDrivingChange(int ConstrId, bool isdriving)
/// Make all dimensionals Driving/non-Driving
int SketchObject::setDatumsDriving(bool isdriving)
{
const std::vector<Constraint *> &vals = this->Constraints.getValues();
std::vector<Constraint *> newVals(vals);
std::vector< Constraint * > tbd; // list of dynamically allocated memory that need to be deleted;
for(size_t i=0; i<newVals.size(); i++) {
if(!testDrivingChange(i, isdriving)) {
const std::vector<Constraint *> &vals = this->Constraints.getValues();
std::vector<Constraint *> newVals(vals);
std::vector< Constraint * > tbd; // list of dynamically allocated memory that need to be deleted;
for (size_t i=0; i<newVals.size(); i++) {
if (!testDrivingChange(i, isdriving)) {
Constraint *constNew = newVals[i]->clone();
constNew->isDriving = isdriving;
newVals[i] = constNew;
tbd.push_back(constNew);
}
}
}
this->Constraints.setValues(newVals);
for(size_t i = 0; i < newVals.size(); i++) {
for (size_t i = 0; i < newVals.size(); i++) {
if (!isdriving && newVals[i]->isDimensional())
setExpression(Constraints.createPath(i), boost::shared_ptr<App::Expression>());
}
for(auto &t : tbd)
delete t;
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
for (auto &t : tbd)
delete t;
if (noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();
return 0;
@@ -462,33 +456,31 @@ int SketchObject::setDatumsDriving(bool isdriving)
int SketchObject::moveDatumsToEnd(void)
{
const std::vector<Constraint *> &vals = this->Constraints.getValues();
std::vector<Constraint *> copy(vals);
std::vector<Constraint *> newVals(vals.size());
int addindex= copy.size()-1;
// add the dimensionals at the end
for(int i= copy.size()-1 ; i >= 0; i--) {
for (int i= copy.size()-1 ; i >= 0; i--) {
if(copy[i]->isDimensional()) {
newVals[addindex] = copy[i];
addindex--;
}
}
// add the non-dimensionals
for(int i = copy.size()-1; i >= 0; i--) {
for (int i = copy.size()-1; i >= 0; i--) {
if(!copy[i]->isDimensional()) {
newVals[addindex] = copy[i];
addindex--;
}
}
this->Constraints.setValues(newVals);
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
if (noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();
return 0;

View File

@@ -112,7 +112,7 @@ public:
/// Copy the constraints instead of cloning them and copying the expressions if any
int addCopyOfConstraints(const SketchObject &orig);
/// add constraint
int addConstraint(const Constraint *constraint);
int addConstraint(const Constraint *constraint);
/// delete constraint
int delConstraint(int ConstrId);
int delConstraints(std::vector<int> ConstrIds, bool updategeometry=true);
@@ -178,7 +178,7 @@ public:
int getDriving(int ConstrId, bool &isdriving);
/// toggle the driving status of this constraint
int toggleDriving(int ConstrId);
/// Make all dimensionals Driving/non-Driving
int setDatumsDriving(bool isdriving);
/// Move Dimensional constraints at the end of the properties array
@@ -413,8 +413,8 @@ protected:
\retval list - the supported geometry list
*/
std::vector<Part::Geometry *> supportedGeometry(const std::vector<Part::Geometry *> &geoList) const;
// refactoring functions
// check whether constraint may be changed driving status
int testDrivingChange(int ConstrId, bool isdriving);

View File

@@ -730,7 +730,7 @@ PyObject* SketchObjectPy::setDriving(PyObject *args)
PyObject* SketchObjectPy::setDatumsDriving(PyObject *args)
{
PyObject* driving;
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &driving))
return 0;
@@ -746,7 +746,6 @@ PyObject* SketchObjectPy::setDatumsDriving(PyObject *args)
PyObject* SketchObjectPy::moveDatumsToEnd(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;

View File

@@ -317,10 +317,10 @@ public:
}
return false;
}
bool isDimensional() const {
assert(ConstraintNbr >= 0 && ConstraintNbr < sketch->Constraints.getSize());
return (sketch->Constraints[ConstraintNbr])->isDimensional();
}