is virtual;
---Purpose: Returns true if the shape S has been deleted.
+ EnsureToleranceRule (myclass; theS : Shape from TopoDS);
+ ---Purpose: Fixes all tolerances of shape theS and it's subshapes by the tolerance
+ -- rule: vertex tolerance >= edge tolerance >= face tolerance.
+ -- Edge or vertex tolerance which does not satisfy the tolerance rule will
+ -- be increased.
fields
#include <BRepBuilderAPI_MakeShape.ixx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
+#include <BRep_TVertex.hxx>
+#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
+//=======================================================================
+//function : EnsureToleranceRule
+//purpose :
+//=======================================================================
+
+void BRepBuilderAPI_MakeShape::EnsureToleranceRule(const TopoDS_Shape & theS)
+{
+ if (theS.IsNull())
+ {
+ return;
+ }
+ //
+ for (TopExp_Explorer aFE(theS, TopAbs_FACE); aFE.More(); aFE.Next())
+ {
+ TopoDS_Face aF = TopoDS::Face(aFE.Current());
+ Standard_Real aFT = (*((Handle_BRep_TFace *)&aF.TShape()))->Tolerance();
+ //
+ for (TopExp_Explorer anEE(aF, TopAbs_EDGE); anEE.More(); anEE.Next())
+ {
+ TopoDS_Edge anES = TopoDS::Edge(anEE.Current());
+ Handle_BRep_TEdge & anEG = *(Handle_BRep_TEdge *)&anES.TShape();
+ Standard_Real anET = anEG->Tolerance();
+ if (anET < aFT)
+ {
+ anET = aFT;
+ anEG->Tolerance(anET);
+ }
+ for (TopExp_Explorer aVE(anES, TopAbs_VERTEX); aVE.More(); aVE.Next())
+ {
+ TopoDS_Vertex aVS = TopoDS::Vertex(aVE.Current());
+ Handle_BRep_TVertex & aVG = *(Handle_BRep_TVertex *)&aVS.TShape();
+ aVG->UpdateTolerance(anET);
+ }
+ }
+ //
+ for (TopExp_Explorer aVE(aF, TopAbs_VERTEX, TopAbs_EDGE);
+ aVE.More(); aVE.Next())
+ {
+ TopoDS_Vertex aVS = TopoDS::Vertex(aVE.Current());
+ Handle_BRep_TVertex & aVG = *(Handle_BRep_TVertex *)&aVS.TShape();
+ aVG->UpdateTolerance(aFT);
+ }
+ }
+ //
+ for (TopExp_Explorer anEE(theS, TopAbs_EDGE, TopAbs_FACE);
+ anEE.More(); anEE.Next())
+ {
+ TopoDS_Edge anES = TopoDS::Edge(anEE.Current());
+ Handle_BRep_TEdge & anEG = *(Handle_BRep_TEdge *)&anES.TShape();
+ Standard_Real anET = anEG->Tolerance();
+ for (TopExp_Explorer aVE(anES, TopAbs_VERTEX); aVE.More(); aVE.Next())
+ {
+ TopoDS_Vertex aVS = TopoDS::Vertex(aVE.Current());
+ Handle_BRep_TVertex & aVG = *(Handle_BRep_TVertex *)&aVS.TShape();
+ aVG->UpdateTolerance(anET);
+ }
+ }
+}
+
#include <BRepBuilderAPI_VertexInspector.hxx>
#include <BRepBuilderAPI_CellFilter.hxx>
#include <BRepBuilderAPI_BndBoxTreeSelector.hxx>
+#include <BRepBuilderAPI_MakeShape.hxx>
#include <NCollection_UBTreeFiller.hxx>
static void SortBox (const Handle(Bnd_HArray1OfBox) hSetBoxes,
mySewedShape.Nullify();
return;
}
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(mySewedShape);
}
#if DEB
chr_total.Stop();
if (myBuilder.IsDone()){
Done();
myShape = myBuilder.Shape();
+ EnsureToleranceRule(myShape);
//creation of the Map.
TopExp_Explorer ex;
if(myBuilder.IsDone()) {
Done();
myShape = myBuilder.Shape();
+ EnsureToleranceRule(myShape);
// creation of the Map.
TopExp_Explorer ex;
void BRepOffsetAPI_MakePipe::Build()
{
myShape = myPipe.Shape();
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(myShape);
Done();
}
{
myNormalProjector.Build();
myShape = myNormalProjector.Projection();
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(myShape);
Done();
}
return 0;
}
+static Standard_Integer EnsureTolRule(
+ Draw_Interpretor & theDI, Standard_Integer theC, const char ** theAs)
+{
+ if (theC != 3)
+ {
+ return 1;
+ }
+ //
+ TopoDS_Shape aS = DBRep::Get(theAs[2]);
+ if (aS.IsNull())
+ {
+ return 1;
+ }
+ //
+ TopoDS_Shape aRes = BRepBuilderAPI_Copy(aS);
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(aRes);
+ //
+ DBRep::Set(theAs[1], aRes);
+ return 0;
+}
+
void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
"scalexyz res shape factor_x factor_y factor_z",
__FILE__,
scalexyz, g);
+
+ theCommands.Add("EnsureTolRule", "res shape", __FILE__, EnsureTolRule, g);
}
Init (me: mutable; shape: Shape from TopoDS);
---Purpose: Initislises by shape.
- Perform (me : mutable;
+ Perform (me : mutable;
theProgress : ProgressIndicator from Message = 0) returns Boolean;
---Purpose: Iterates on sub- shape and performs fixes
+ PerformR (me : mutable;
+ theProgress : ProgressIndicator from Message ) returns Boolean is private;
+ ---Purpose: Internal method. Called by Perform.
+
SameParameter (me : mutable;
shape : Shape from TopoDS;
enforce : Boolean;
#include <TopAbs_ShapeEnum.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeShape.hxx>
#include <ShapeFix.hxx>
#include <ShapeBuild_ReShape.hxx>
//purpose :
//=======================================================================
-Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)& theProgress)
+Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)& theProgress)
+{
+ Standard_Boolean aR = PerformR(theProgress);
+ if (aR)
+ {
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(myResult);
+ }
+ return aR;
+}
+
+//=======================================================================
+//function : PerformR
+//purpose :
+//=======================================================================
+
+Standard_Boolean ShapeFix_Shape::PerformR(const Handle(Message_ProgressIndicator)& theProgress)
{
Standard_Integer savFixSmallAreaWireMode = 0;
#include <ShapeUpgrade_WireDivide.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
+#include <BRepBuilderAPI_MakeShape.hxx>
//=======================================================================
//function : ShapeUpgrade_ShapeDivide
if ( Status ( ShapeExtend_DONE ) ) {
myResult = myContext->Apply ( C, TopAbs_SHAPE );
myContext->Replace ( myShape, myResult );
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(myResult);
return Standard_True;
}
myResult = myShape;
}
}
myResult = myContext->Apply ( myShape, TopAbs_SHAPE );
+ BRepBuilderAPI_MakeShape::EnsureToleranceRule(myResult);
return ! myResult.IsSame ( myShape );
}