Toponaming: Bring in Chamfer, Fillet code and add tests (#14035)
* Toponaming: bring in missing code fragments in Sketcher * Toponaming: Fix infinite recursion, remove debug cruft, rough in fillet test * Bring in missing code; fix chamfers * Toponaming: Add code for fillets and test
This commit is contained in:
@@ -65,6 +65,67 @@ short Fillet::mustExecute() const
|
||||
|
||||
App::DocumentObjectExecReturn *Fillet::execute()
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
Part::TopoShape baseShape;
|
||||
try {
|
||||
baseShape = getBaseTopoShape();
|
||||
}
|
||||
catch (Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
baseShape.setTransform(Base::Matrix4D());
|
||||
|
||||
auto edges = UseAllEdges.getValue() ? baseShape.getSubTopoShapes(TopAbs_EDGE)
|
||||
: getContinuousEdges(baseShape);
|
||||
if (edges.empty()) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "Fillet not possible on selected shapes"));
|
||||
}
|
||||
|
||||
double radius = Radius.getValue();
|
||||
|
||||
if (radius <= 0) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "Fillet radius must be greater than zero"));
|
||||
}
|
||||
|
||||
this->positionByBaseFeature();
|
||||
|
||||
try {
|
||||
TopoShape shape(0); //,getDocument()->getStringHasher());
|
||||
shape.makeElementFillet(baseShape, edges, Radius.getValue(), Radius.getValue());
|
||||
if (shape.isNull()) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "Resulting shape is null"));
|
||||
}
|
||||
|
||||
TopTools_ListOfShape aLarg;
|
||||
aLarg.Append(baseShape.getShape());
|
||||
bool failed = false;
|
||||
if (!BRepAlgo::IsValid(aLarg, shape.getShape(), Standard_False, Standard_False)) {
|
||||
ShapeFix_ShapeTolerance aSFT;
|
||||
aSFT.LimitTolerance(shape.getShape(),
|
||||
Precision::Confusion(),
|
||||
Precision::Confusion(),
|
||||
TopAbs_SHAPE);
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
shape = refineShapeIfActive(shape);
|
||||
shape = getSolid(shape);
|
||||
}
|
||||
this->Shape.setValue(shape);
|
||||
|
||||
if (failed) {
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
|
||||
}
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
|
||||
#else
|
||||
Part::TopoShape TopShape;
|
||||
try {
|
||||
TopShape = getBaseTopoShape();
|
||||
@@ -144,6 +205,7 @@ App::DocumentObjectExecReturn *Fillet::execute()
|
||||
catch (Standard_Failure& e) {
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fillet::Restore(Base::XMLReader &reader)
|
||||
|
||||
Reference in New Issue
Block a user