1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0026473: Offset API fails to create offset shape

Tolerance of map building changed.
Added possibility to work 0.0 offset value.

Added test cases bugs/modalg_6/bug26473_1 bug26473_2
This commit is contained in:
aml 2015-07-29 15:33:30 +03:00 committed by bugmaster
parent c5d8782cfd
commit 03383c97c3
4 changed files with 70 additions and 14 deletions

View File

@ -171,7 +171,7 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S,
myShape = S; myShape = S;
angle = Angle; angle = Angle;
Standard_Real SinTol = sin(Angle); Standard_Real SinTol = Sin(Angle);
// Build ancestors. // Build ancestors.
BuildAncestors (S,ancestors); BuildAncestors (S,ancestors);

View File

@ -666,7 +666,7 @@ static void EvalMax(const TopoDS_Shape& S, Standard_Real& Tol)
void BRepOffset_MakeOffset::MakeOffsetShape() void BRepOffset_MakeOffset::MakeOffsetShape()
{ {
myDone = Standard_False; myDone = Standard_False;
//------------------------------------------ //------------------------------------------
// Construction of myShape without caps. // Construction of myShape without caps.
//------------------------------------------ //------------------------------------------
@ -678,16 +678,36 @@ void BRepOffset_MakeOffset::MakeOffsetShape()
if (! IsConnectedShell(myShape)) if (! IsConnectedShell(myShape))
Standard_ConstructionError::Raise("BRepOffset_MakeOffset : Incorrect set of faces to remove, the remaining shell is not connected"); Standard_ConstructionError::Raise("BRepOffset_MakeOffset : Incorrect set of faces to remove, the remaining shell is not connected");
if (Abs(myOffset) < myTol) return; if (Abs(myOffset) <= myTol)
{
// Check for face with non-null offset value.
Standard_Boolean isFound = Standard_False;
TopTools_DataMapIteratorOfDataMapOfShapeReal anIter(myFaceOffset);
for( ; anIter.More(); anIter.Next())
{
if (Abs(anIter.Value()) > myTol)
{
isFound = Standard_True;
break;
}
}
if (!isFound)
{
// No face with non-null offset found.
return;
}
}
TopAbs_State Side = TopAbs_IN; TopAbs_State Side = TopAbs_IN;
if (myOffset < 0.) Side = TopAbs_OUT; if (myOffset < 0.) Side = TopAbs_OUT;
// ------------ // ------------
// Preanalyse. // Preanalyse.
// ------------ // ------------
EvalMax(myShape,myTol); EvalMax(myShape,myTol);
// There are possible second variant: analytical continuation of arcsin. // There are possible second variant: analytical continuation of arcsin.
Standard_Real TolAngleCoeff = Min(myTol/Abs(myOffset*0.5), 1.0); Standard_Real TolAngleCoeff = Min(myTol / (Abs(myOffset * 0.5) + Precision::Confusion()), 1.0);
Standard_Real TolAngle = 4*ASin(TolAngleCoeff); Standard_Real TolAngle = 4*ASin(TolAngleCoeff);
myAnalyse.Perform(myShape,TolAngle); myAnalyse.Perform(myShape,TolAngle);
//--------------------------------------------------- //---------------------------------------------------
@ -1033,12 +1053,12 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
// Extension of neighbor edges of new edges and intersection between neighbors. // Extension of neighbor edges of new edges and intersection between neighbors.
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
Handle(BRepAlgo_AsDes) AsDes2d = new BRepAlgo_AsDes(); Handle(BRepAlgo_AsDes) AsDes2d = new BRepAlgo_AsDes();
for (Exp.Init(myShape,TopAbs_FACE) ; Exp.More(); Exp.Next()) { for (Exp.Init(myShape,TopAbs_FACE) ; Exp.More(); Exp.Next())
{
const TopoDS_Face& FI = TopoDS::Face(Exp.Current()); const TopoDS_Face& FI = TopoDS::Face(Exp.Current());
// Modified by skv - Mon Jan 12 11:50:02 2004 OCC4455 Begin Standard_Real aCurrFaceTol = BRep_Tool::Tolerance(FI);
// BRepOffset_Inter2d::ConnexIntByInt (FI,MapSF(FI),MES,Build,AsDes2d,myTol); BRepOffset_Inter2d::ConnexIntByInt (FI, MapSF(FI), MES, Build,
BRepOffset_Inter2d::ConnexIntByInt (FI,MapSF(FI),MES,Build,AsDes2d,myOffset, myTol); AsDes2d, myOffset, aCurrFaceTol);
// Modified by skv - Mon Jan 12 11:50:03 2004 OCC4455 End
} }
//----------------------------------------------------------- //-----------------------------------------------------------
// Great restriction of new edges and update of AsDes. // Great restriction of new edges and update of AsDes.
@ -1114,17 +1134,21 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
} }
TopTools_ListIteratorOfListOfShape itLFE(LFE); TopTools_ListIteratorOfListOfShape itLFE(LFE);
for (; itLFE.More(); itLFE.Next()) { for (; itLFE.More(); itLFE.Next())
{
const TopoDS_Face& NEF = TopoDS::Face(itLFE.Value()); const TopoDS_Face& NEF = TopoDS::Face(itLFE.Value());
BRepOffset_Inter2d::Compute(AsDes,NEF,NewEdges,myTol); Standard_Real aCurrFaceTol = BRep_Tool::Tolerance(NEF);
BRepOffset_Inter2d::Compute(AsDes, NEF, NewEdges, aCurrFaceTol);
} }
//---------------------------------------------- //----------------------------------------------
// Intersections 2d on caps. // Intersections 2d on caps.
//---------------------------------------------- //----------------------------------------------
Standard_Integer i; Standard_Integer i;
for (i = 1; i <= myFaces.Extent(); i++) { for (i = 1; i <= myFaces.Extent(); i++)
{
const TopoDS_Face& Cork = TopoDS::Face(myFaces(i)); const TopoDS_Face& Cork = TopoDS::Face(myFaces(i));
BRepOffset_Inter2d::Compute(AsDes,Cork,NewEdges,myTol); Standard_Real aCurrFaceTol = BRep_Tool::Tolerance(Cork);
BRepOffset_Inter2d::Compute(AsDes, Cork, NewEdges, aCurrFaceTol);
} }
//------------------------------- //-------------------------------

View File

@ -0,0 +1,15 @@
puts "=========="
puts "OCC26473"
puts "=========="
puts ""
################################################
# Offset API fails to create offset shape
################################################
restore [locate_data_file bug26473_offset_shape.input.brep] i
offsetparameter 1e-7 c i
offsetload i 1
offsetperform result
set square 605144
set 2dviewer 1

View File

@ -0,0 +1,17 @@
puts "=========="
puts "OCC26473"
puts "=========="
puts ""
################################################
# Offset API fails to create offset shape
################################################
box b1 0.0 0.0 0.0 1.0 1.0 1.0
explode b1 F
offsetparameter 1e-7 c i
offsetload b1 0.0
offsetonface b1_1 1.0
offsetperform result
set square 10
set 2dviewer 1