Sketcher: Reformat to current clang-format standard
This commit is contained in:
committed by
Chris Hennes
parent
41a1a7a8e6
commit
791fe02934
@@ -66,12 +66,15 @@ struct SketchAnalysis::Vertex_Less
|
||||
{}
|
||||
bool operator()(const VertexIds& x, const VertexIds& y) const
|
||||
{
|
||||
if (fabs(x.v.x - y.v.x) > tolerance)
|
||||
if (fabs(x.v.x - y.v.x) > tolerance) {
|
||||
return x.v.x < y.v.x;
|
||||
if (fabs(x.v.y - y.v.y) > tolerance)
|
||||
}
|
||||
if (fabs(x.v.y - y.v.y) > tolerance) {
|
||||
return x.v.y < y.v.y;
|
||||
if (fabs(x.v.z - y.v.z) > tolerance)
|
||||
}
|
||||
if (fabs(x.v.z - y.v.z) > tolerance) {
|
||||
return x.v.z < y.v.z;
|
||||
}
|
||||
return false;// points are considered to be equal
|
||||
}
|
||||
|
||||
@@ -121,8 +124,9 @@ struct SketchAnalysis::Edge_Less
|
||||
{}
|
||||
bool operator()(const EdgeIds& x, const EdgeIds& y) const
|
||||
{
|
||||
if (fabs(x.l - y.l) > tolerance)
|
||||
if (fabs(x.l - y.l) > tolerance) {
|
||||
return x.l < y.l;
|
||||
}
|
||||
return false;// points are considered to be equal
|
||||
}
|
||||
|
||||
@@ -157,8 +161,9 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision,
|
||||
for (std::size_t i = 0; i < geom.size(); i++) {
|
||||
auto gf = GeometryFacade::getFacade(geom[i]);
|
||||
|
||||
if (gf->getConstruction() && !includeconstruction)
|
||||
if (gf->getConstruction() && !includeconstruction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gf->getGeometry()->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
|
||||
const Part::GeomLineSegment* segm =
|
||||
@@ -321,16 +326,19 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision,
|
||||
for (std::set<VertexIds, VertexID_Less>& grp : coincVertexGrps) {
|
||||
if ((grp.find(v1) != grp.end()) || (grp.find(v2) != grp.end())) {
|
||||
// If yes add them to the existing group
|
||||
if (!nv1.empty())
|
||||
if (!nv1.empty()) {
|
||||
grp.insert(nv1.value());
|
||||
if (!nv2.empty())
|
||||
}
|
||||
if (!nv2.empty()) {
|
||||
grp.insert(nv2.value());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (nv1.empty() || nv2.empty())
|
||||
if (nv1.empty() || nv2.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If no, create a new group of coincident vertices
|
||||
std::set<VertexIds, VertexID_Less> newGrp;
|
||||
@@ -479,8 +487,9 @@ void SketchAnalysis::makeMissingPointOnPointCoincident(bool onebyone)
|
||||
}
|
||||
}
|
||||
|
||||
if (!onebyone)
|
||||
if (!onebyone) {
|
||||
sketch->addConstraints(constr);
|
||||
}
|
||||
|
||||
vertexConstraints.clear();
|
||||
|
||||
@@ -566,8 +575,9 @@ void SketchAnalysis::makeMissingVerticalHorizontal(bool onebyone)
|
||||
}
|
||||
}
|
||||
|
||||
if (!onebyone)
|
||||
if (!onebyone) {
|
||||
sketch->addConstraints(constr);
|
||||
}
|
||||
|
||||
verthorizConstraints.clear();
|
||||
|
||||
@@ -735,8 +745,9 @@ void SketchAnalysis::makeMissingEquality(bool onebyone)
|
||||
std::vector<Sketcher::Constraint*> constr;
|
||||
|
||||
std::vector<Sketcher::ConstraintIds> equalities(lineequalityConstraints);
|
||||
equalities.insert(
|
||||
equalities.end(), radiusequalityConstraints.begin(), radiusequalityConstraints.end());
|
||||
equalities.insert(equalities.end(),
|
||||
radiusequalityConstraints.begin(),
|
||||
radiusequalityConstraints.end());
|
||||
|
||||
for (std::vector<Sketcher::ConstraintIds>::iterator it = equalities.begin();
|
||||
it != equalities.end();
|
||||
@@ -773,8 +784,9 @@ void SketchAnalysis::makeMissingEquality(bool onebyone)
|
||||
}
|
||||
}
|
||||
|
||||
if (!onebyone)
|
||||
if (!onebyone) {
|
||||
sketch->addConstraints(constr);
|
||||
}
|
||||
|
||||
lineequalityConstraints.clear();
|
||||
radiusequalityConstraints.clear();
|
||||
@@ -789,10 +801,12 @@ void SketchAnalysis::solvesketch(int& status, int& dofs, bool updategeo)
|
||||
{
|
||||
status = sketch->solve(updategeo);
|
||||
|
||||
if (updategeo)
|
||||
if (updategeo) {
|
||||
dofs = sketch->setUpSketch();
|
||||
else
|
||||
}
|
||||
else {
|
||||
dofs = sketch->getLastDoF();
|
||||
}
|
||||
|
||||
if (sketch->getLastHasRedundancies()) {// redundant constraints
|
||||
status = -2;
|
||||
@@ -806,7 +820,8 @@ void SketchAnalysis::solvesketch(int& status, int& dofs, bool updategeo)
|
||||
}
|
||||
}
|
||||
|
||||
int SketchAnalysis::autoconstraint(double precision, double angleprecision,
|
||||
int SketchAnalysis::autoconstraint(double precision,
|
||||
double angleprecision,
|
||||
bool includeconstruction)
|
||||
{
|
||||
App::Document* doc = sketch->getDocument();
|
||||
@@ -835,9 +850,10 @@ int SketchAnalysis::autoconstraint(double precision, double angleprecision,
|
||||
// as the solver may move the geometry in the meantime and prevent correct detection
|
||||
int nc = detectMissingPointOnPointConstraints(precision, includeconstruction);
|
||||
|
||||
if (nc
|
||||
> 0)// STAGE 2a: Classify point-on-point into coincidents, endpoint perp, endpoint tangency
|
||||
if (nc > 0) {// STAGE 2a: Classify point-on-point into coincidents, endpoint perp, endpoint
|
||||
// tangency
|
||||
analyseMissingPointOnPointCoincident(angleprecision);
|
||||
}
|
||||
|
||||
// STAGE 3: Equality constraint detection
|
||||
int ne = detectMissingEqualityConstraints(precision);
|
||||
@@ -968,14 +984,16 @@ int SketchAnalysis::detectDegeneratedGeometries(double tolerance)
|
||||
for (std::size_t i = 0; i < geom.size(); i++) {
|
||||
auto gf = GeometryFacade::getFacade(geom[i]);
|
||||
|
||||
if (gf->getConstruction())
|
||||
if (gf->getConstruction()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) {
|
||||
Part::GeomCurve* curve = static_cast<Part::GeomCurve*>(gf->getGeometry());
|
||||
double len = curve->length(curve->getFirstParameter(), curve->getLastParameter());
|
||||
if (len < tolerance)
|
||||
if (len < tolerance) {
|
||||
countDegenerated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,14 +1007,16 @@ int SketchAnalysis::removeDegeneratedGeometries(double tolerance)
|
||||
for (std::size_t i = 0; i < geom.size(); i++) {
|
||||
auto gf = GeometryFacade::getFacade(geom[i]);
|
||||
|
||||
if (gf->getConstruction())
|
||||
if (gf->getConstruction()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) {
|
||||
Part::GeomCurve* curve = static_cast<Part::GeomCurve*>(gf->getGeometry());
|
||||
double len = curve->length(curve->getFirstParameter(), curve->getLastParameter());
|
||||
if (len < tolerance)
|
||||
if (len < tolerance) {
|
||||
delInternalGeometries.insert(static_cast<int>(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user