1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

20 Commits

Author SHA1 Message Date
bugmaster
fecb042498 Update version up to 7.5.3 2021-08-04 10:41:47 +03:00
jgv
c194e1bc39 0032291: Modeling Algorithms - General Fuse produces wrong number of solids
Modify method IntWalk_IWalking::ComputeCloseLine: add new flag "isOnDegeneratedBorder" to reach the border successfully.
2021-08-04 10:14:00 +03:00
emv
96815dec17 0032307: Modeling Algorithms - Empty result of offset operation in mode "Complete" Joint type "Intersection"
Make sure the vertices created by pairwise intersection of edges connected in the same vertex are unified correctly.
2021-07-29 14:17:24 +03:00
emv
03e79361dc 0032088: Modeling Algorithms - Empty result of offset operation in mode "Complete" join type "Intersection"
Mark inverted edges located inside loops of invalid edges as invalid as well.
2021-07-29 12:55:24 +03:00
akaftasev
3a8f6b11e8 0031147: Modeling Algorithms - BRepOffsetAPI_MakePipeShell null access
Added to Draw command 'setsweep ' posibility to change degmax and segmax parameter manually by '-SM' and '-DM' options
Added test
Added new condition to prevent crash
2021-07-29 12:48:56 +03:00
akaftasev
45ec28cf68 0029645: Hang on making pipe shell using BRepOffsetAPI_MakePipeShell
Added new boolean parameter to GeomLib::FuseIntervals() to select method of defining an element with close values
2021-07-29 12:48:22 +03:00
aavtamon
7aaaf5eb13 0028572: Modeling Algorithms - Wrong result of the mkface command
- Added note to BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,
										const TopoDS_Wire& W,
										const Standard_Boolean Inside = Standard_True)
in BRepBuilderAPI_MakeFace.hxx;
- Modified subsubsection occt_modalg_3_5_2 in dox/user_guides/modeling_algos/modeling_algos.md
2021-07-29 12:46:44 +03:00
bugmaster
0dc2c377fc Update version up to 7.5.2 2021-04-20 10:07:58 +03:00
ifv
1078e94941 0032225: Modeling Data - Wrong result of extrema curve-surface
Extrema_GenExtCS.cxx: subdivision on intervals for periodic c curves is added

Extrema_FuncExtCS.hxx: access to fields mySqDist, myPoint1, myPoint2 is added

bug32225: new test case is added
2021-04-20 09:49:15 +03:00
emv
6b26c6d26d 0032199: Modeling Algorithms - BOP Cut produces invalid shape
Use section tolerance for checking the valid range.
2021-04-16 16:13:06 +03:00
jgv
dd56857183 0031984: Modeling Algorithms - Sweep crashes if Bi-normal is given
Small modification in BRepFill_Sweep: to avoid exception, return status NotDone if construction of pipe surface fails.
2021-04-16 15:54:26 +03:00
jgv
2c8eacb996 0032213: Modeling Algorithms - Invalid result of UnifySameDomain
Modify unification of faces: add splitting new wire into several ones.
2021-04-16 15:52:26 +03:00
gka
3b05b748de 0032264: Data Exchange - STEP exporter generates bad geometry [REGRESSION since 7.4.0]
Location of edge is applied to geom curve before analysis of vertices projections
2021-04-16 15:49:03 +03:00
jgv
91e51cb0f2 0032140: Modeling Algorithms - unify same domain calls crossed for opposite vectors
1. Correct unification of circular edges: avoid trying to make an axis with null magnitude.
2. New method UnionPCurves: unify existing pcurves of chain instead of projecting the curve of unified edge onto surfaces
2021-04-16 15:24:04 +03:00
emv
bb00fe2713 0032136: Modeling Algorithms - Boolean fuse fails and corrupts the argument-shape
Avoid increasing tolerance of the vertex before the check on valid range is passed.
2021-04-16 15:21:08 +03:00
bugmaster
94c00556ea Update version up to 7.5.1 2021-02-02 11:51:56 +03:00
emv
bf67bbf8fe 0031912: Modeling Algorithms - Boolean Cut can't build resulting shape
Problem is fixed by #0032058. Integrating test case only.
2021-02-02 11:49:33 +03:00
ifv
edf111202c 0032058: Modeling Data - Extrema curve-surface gives wrong result for planar surface of revolunion and circle
Extrema_GenExtCS.cxx : added solution refinement, if solution seems to be "bad" according to special criteria.
Extrema_FuncExtCS.cxx : "cosmetic" modifications
BOPAlgo_PaveFiller_3.cxx : adding control of shape index to prevent exception in ShapeInfo
bugs/moddata_3/bug32058 : new test
2021-02-02 11:30:40 +03:00
jgv
bbdcdcdd80 0031845: Modeling Algorithms - BRepOffsetAPI_MakeThickSolid fails
Multiple changes in BRepOffset_MakeOffset algorithm:
- correct fusing vertices;
- correct building intersection edges;
- correct intersecting new edges in 2D;
- correct building wire on a new face;
- correct building history.
2021-01-29 13:47:21 +03:00
bugmaster
2ecd3a06a6 Update version up to 7.5.1.dev 2020-11-11 20:08:01 +03:00
90 changed files with 2509 additions and 424 deletions

View File

@@ -1356,9 +1356,7 @@ MF.Add(W);
TopoDS_Face F = MF;
~~~~~
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked). The edges on a Face must have a parametric curve description.
If there is no parametric curve for an edge of the wire on the Face it is computed by projection.
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked).
For one wire, a simple syntax is provided to construct the face from the surface and the wire. The above lines could be written:
@@ -1366,6 +1364,8 @@ For one wire, a simple syntax is provided to construct the face from the surfac
TopoDS_Face F = BRepBuilderAPI_MakeFace(C,W);
~~~~~
The edges on a face must have a parametric curve description. If there is no parametric curve for an edge of the wire on the face it is computed by projection, moreover, the calculation is possible only for the planar face.
A planar face can be created from only a wire, provided this wire defines a plane. For example, to create a planar face from a set of points you can use *BRepBuilderAPI_MakePolygon* and *BRepBuilderAPI_MakeFace*.
~~~~~

View File

@@ -655,6 +655,12 @@ void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
// Vertices
Standard_Integer nV1, nV2;
thePB->Indices(nV1, nV2);
if (nV1 < 0 || nV2 < 0)
{
return;
}
const TopoDS_Vertex& aV1=(*(TopoDS_Vertex *)(&myDS->Shape(nV1)));
const TopoDS_Vertex& aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
// Get the edge

View File

@@ -648,8 +648,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// check if the pave block has a valid range
Standard_Real aFirst, aLast;
if (!BRepLib::FindValidRange(GeomAdaptor_Curve(aIC.Curve()), aTolR3D,
aT1, BRep_Tool::Pnt(aV1), BRep_Tool::Tolerance(aV1),
aT2, BRep_Tool::Pnt(aV2), BRep_Tool::Tolerance(aV2),
aT1, BRep_Tool::Pnt(aV1), Max (aTolR3D, BRep_Tool::Tolerance(aV1)),
aT2, BRep_Tool::Pnt(aV2), Max (aTolR3D, BRep_Tool::Tolerance(aV2)),
aFirst, aLast))
{
// If the pave block does not have valid range, i.e. it is completely
@@ -3035,9 +3035,21 @@ void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
return;
}
if (aDistVP > aTolV)
// Check if there will be valid range on the curve
Standard_Real aFirst, aLast;
Standard_Real aNewTolV = Max(aTolV, aDistVP + BOPTools_AlgoTools::DTolerance());
if (!BRepLib::FindValidRange(GeomAdaptor_Curve(aIC.Curve()), aIC.Tolerance(),
aT[0], aP[0], aNewTolV,
aT[1], aP[1], aNewTolV,
aFirst, aLast))
{
Standard_Integer nVn = UpdateVertex(nV, aDistVP + BOPTools_AlgoTools::DTolerance());
// No valid range
return;
}
if (aNewTolV > aTolV)
{
Standard_Integer nVn = UpdateVertex(nV, aNewTolV);
if (nVn != nV)
{
aPave.SetIndex(nVn);
@@ -3046,17 +3058,6 @@ void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
aTolV = BRep_Tool::Tolerance(TopoDS::Vertex(myDS->Shape(nV)));
}
// Check if there will be valid range on the curve
Standard_Real aFirst, aLast;
if (!BRepLib::FindValidRange(GeomAdaptor_Curve(aIC.Curve()), aIC.Tolerance(),
aT[0], aP[0], aTolV,
aT[1], aP[1], aTolV,
aFirst, aLast))
{
// No valid range
return;
}
// Add closing pave to the curve
BOPDS_Pave aNewPave;
aNewPave.SetIndex(nV);

View File

@@ -23,8 +23,10 @@
#include <BRepAlgo_Loop.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomLib.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Ax2.hxx>
#include <Precision.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
@@ -160,6 +162,15 @@ void BRepAlgo_Loop::AddConstEdges(const TopTools_ListOfShape& LE)
}
}
//=======================================================================
//function : SetImageVV
//purpose :
//=======================================================================
void BRepAlgo_Loop::SetImageVV (const BRepAlgo_Image& theImageVV)
{
myImageVV = theImageVV;
}
//=======================================================================
//function : UpdateClosedEdge
@@ -606,6 +617,8 @@ void BRepAlgo_Loop::Perform()
TopoDS_Wire NW;
Standard_Boolean End;
UpdateVEmap (MVE);
TopTools_MapOfShape UsedEdges;
while (MVE.Extent() > 0) {
@@ -924,6 +937,7 @@ void BRepAlgo_Loop::GetVerticesForSubstitute( TopTools_DataMapOfShapeShape& Ver
{
VerVerMap = myVerticesForSubstitute;
}
//=======================================================================
//function : VerticesForSubstitute
//purpose :
@@ -933,3 +947,123 @@ void BRepAlgo_Loop::VerticesForSubstitute( TopTools_DataMapOfShapeShape& VerVer
{
myVerticesForSubstitute = VerVerMap;
}
//=======================================================================
//function : UpdateVEmap
//purpose :
//=======================================================================
void BRepAlgo_Loop::UpdateVEmap (TopTools_IndexedDataMapOfShapeListOfShape& theVEmap)
{
TopTools_IndexedDataMapOfShapeListOfShape VerLver;
for (Standard_Integer ii = 1; ii <= theVEmap.Extent(); ii++)
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (theVEmap.FindKey(ii));
const TopTools_ListOfShape& aElist = theVEmap(ii);
if (aElist.Extent() == 1 && myImageVV.IsImage(aVertex))
{
const TopoDS_Vertex& aProVertex = TopoDS::Vertex (myImageVV.ImageFrom(aVertex));
if (VerLver.Contains(aProVertex))
{
TopTools_ListOfShape& aVlist = VerLver.ChangeFromKey(aProVertex);
aVlist.Append (aVertex.Oriented(TopAbs_FORWARD));
}
else
{
TopTools_ListOfShape aVlist;
aVlist.Append (aVertex.Oriented(TopAbs_FORWARD));
VerLver.Add (aProVertex, aVlist);
}
}
}
if (VerLver.IsEmpty())
return;
BRep_Builder aBB;
for (Standard_Integer ii = 1; ii <= VerLver.Extent(); ii++)
{
const TopTools_ListOfShape& aVlist = VerLver(ii);
if (aVlist.Extent() == 1)
continue;
Standard_Real aMaxTol = 0.;
TColgp_Array1OfPnt Points (1, aVlist.Extent());
TopTools_ListIteratorOfListOfShape itl (aVlist);
Standard_Integer jj = 0;
for (; itl.More(); itl.Next())
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (itl.Value());
Standard_Real aTol = BRep_Tool::Tolerance(aVertex);
aMaxTol = Max (aMaxTol, aTol);
gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
Points(++jj) = aPnt;
}
gp_Ax2 anAxis;
Standard_Boolean IsSingular;
GeomLib::AxeOfInertia (Points, anAxis, IsSingular);
gp_Pnt aCentre = anAxis.Location();
Standard_Real aMaxDist = 0.;
for (jj = 1; jj <= Points.Upper(); jj++)
{
Standard_Real aSqDist = aCentre.SquareDistance (Points(jj));
aMaxDist = Max (aMaxDist, aSqDist);
}
aMaxDist = Sqrt(aMaxDist);
aMaxTol = Max (aMaxTol, aMaxDist);
//Find constant vertex
TopoDS_Vertex aConstVertex;
for (itl.Initialize(aVlist); itl.More(); itl.Next())
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (itl.Value());
const TopTools_ListOfShape& aElist = theVEmap.FindFromKey(aVertex);
const TopoDS_Shape& anEdge = aElist.First();
TopTools_ListIteratorOfListOfShape itcedges (myConstEdges);
for (; itcedges.More(); itcedges.Next())
if (anEdge.IsSame (itcedges.Value()))
{
aConstVertex = aVertex;
break;
}
if (!aConstVertex.IsNull())
break;
}
if (aConstVertex.IsNull())
aConstVertex = TopoDS::Vertex(aVlist.First());
aBB.UpdateVertex (aConstVertex, aCentre, aMaxTol);
for (itl.Initialize(aVlist); itl.More(); itl.Next())
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (itl.Value());
if (aVertex.IsSame(aConstVertex))
continue;
const TopTools_ListOfShape& aElist = theVEmap.FindFromKey (aVertex);
TopoDS_Edge anEdge = TopoDS::Edge (aElist.First());
anEdge.Orientation(TopAbs_FORWARD);
TopoDS_Vertex aV1, aV2;
TopExp::Vertices (anEdge, aV1, aV2);
TopoDS_Vertex aVertexToRemove = (aV1.IsSame(aVertex))? aV1 : aV2;
anEdge.Free(Standard_True);
aBB.Remove (anEdge, aVertexToRemove);
aBB.Add (anEdge, aConstVertex.Oriented (aVertexToRemove.Orientation()));
}
}
TopTools_IndexedMapOfShape Emap;
for (Standard_Integer ii = 1; ii <= theVEmap.Extent(); ii++)
{
const TopTools_ListOfShape& aElist = theVEmap(ii);
TopTools_ListIteratorOfListOfShape itl (aElist);
for (; itl.More(); itl.Next())
Emap.Add (itl.Value());
}
theVEmap.Clear();
for (Standard_Integer ii = 1; ii <= Emap.Extent(); ii++)
TopExp::MapShapesAndAncestors (Emap(ii), TopAbs_VERTEX, TopAbs_EDGE, theVEmap);
}

View File

@@ -25,6 +25,8 @@
#include <TopTools_ListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <BRepAlgo_Image.hxx>
class TopoDS_Face;
class TopoDS_Edge;
@@ -53,9 +55,15 @@ public:
//! Add <LE> as a set of const edges.
Standard_EXPORT void AddConstEdges (const TopTools_ListOfShape& LE);
//! Sets the Image Vertex - Vertex
Standard_EXPORT void SetImageVV (const BRepAlgo_Image& theImageVV);
//! Make loops.
Standard_EXPORT void Perform();
//! Update VE map according to Image Vertex - Vertex
Standard_EXPORT void UpdateVEmap (TopTools_IndexedDataMapOfShapeListOfShape& theVEmap);
//! Cut the edge <E> in several edges <NE> on the
//! vertices<VonE>.
Standard_EXPORT void CutEdge (const TopoDS_Edge& E, const TopTools_ListOfShape& VonE, TopTools_ListOfShape& NE) const;
@@ -102,6 +110,7 @@ private:
TopTools_ListOfShape myNewFaces;
TopTools_DataMapOfShapeListOfShape myCutEdges;
TopTools_DataMapOfShapeShape myVerticesForSubstitute;
BRepAlgo_Image myImageVV;
};

View File

@@ -135,6 +135,9 @@ public:
Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
//! Make a face from a Surface and a wire.
//! If the surface S is not plane,
//! it must contain pcurves for all edges in W,
//! otherwise the wrong shape will be created.
Standard_EXPORT BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
//! Adds the wire <W> in the face <F>

View File

@@ -1450,6 +1450,10 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++)
{
const TopoDS_Shape& aVshape = aVEdges->Value(i, inde);
if (aVshape.IsNull())
{
continue;
}
if (aVshape.ShapeType() == TopAbs_EDGE ||
aVshape.ShapeType() == TopAbs_FACE)
ListVshapes->Append(aVshape);

View File

@@ -2969,11 +2969,23 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges,
// Construction of the shell
TopoDS_Shell shell;
B.MakeShell(shell);
Standard_Integer aNbFaces = 0;
for (ipath=1; ipath<=NbPath; ipath++)
for (isec=1; isec <=NbLaw; isec++) {
for (isec=1; isec <=NbLaw; isec++)
{
const TopoDS_Shape& face = myFaces->Value(isec, ipath);
if (!face.IsNull() &&
(face.ShapeType() == TopAbs_FACE) ) B.Add(shell, face);
(face.ShapeType() == TopAbs_FACE) )
{
B.Add(shell, face);
aNbFaces++;
}
}
if (aNbFaces == 0)
{
isDone = Standard_False;
return;
}
TopTools_ListIteratorOfListOfShape It(myAuxShape);

View File

@@ -32,6 +32,7 @@
#include <BRepAdaptor_Curve2d.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAlgo_AsDes.hxx>
#include <BRepAlgo_Image.hxx>
#include <BRepLib.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <BRepOffset_Analyse.hxx>
@@ -63,6 +64,7 @@
#include <gp_Pnt.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntTools_Tools.hxx>
#include <Precision.hxx>
#include <TColGeom2d_SequenceOfCurve.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
@@ -78,6 +80,7 @@
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <stdio.h>
#ifdef DRAW
@@ -113,27 +116,153 @@ static TopoDS_Vertex CommonVertex(TopoDS_Edge& E1,
return V;
}
static Standard_Boolean IsOrientationChanged(TopTools_IndexedMapOfShape& theMap,
const TopoDS_Edge& theEdge)
static Standard_Integer DefineClosedness(const TopoDS_Face& theFace)
{
Standard_Boolean IsOrChanged = Standard_False;
if (!theMap.Contains(theEdge))
theMap.Add(theEdge);
TopExp_Explorer anExplo (theFace, TopAbs_EDGE);
for (; anExplo.More(); anExplo.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
if (BRepTools::IsReallyClosed(anEdge, theFace))
{
Standard_Real fpar, lpar;
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
gp_Vec2d aTangent = aPCurve->DN(fpar, 1);
Standard_Real aCrossProd1 = aTangent ^ gp::DX2d();
Standard_Real aCrossProd2 = aTangent ^ gp::DY2d();
if (Abs(aCrossProd2) < Abs(aCrossProd1)) //pcurve is parallel to OY
return 1;
else
{
Standard_Integer anInd = theMap.FindIndex(theEdge);
const TopoDS_Shape& anEdge = theMap(anInd);
if (theEdge.Orientation() != anEdge.Orientation())
{
theMap.Substitute( anInd, theEdge );
IsOrChanged = Standard_True;
return 2;
}
}
return IsOrChanged;
return 0;
}
static void GetEdgesOrientedInFace(const TopoDS_Shape& theShape,
const TopoDS_Face& theFace,
const Handle(BRepAlgo_AsDes)& theAsDes,
TopTools_SequenceOfShape& theSeqEdges)
{
const TopTools_ListOfShape& aEdges = theAsDes->Descendant (theFace);
TopExp_Explorer anExplo (theShape, TopAbs_EDGE);
for (; anExplo.More(); anExplo.Next())
{
const TopoDS_Shape& anEdge = anExplo.Current();
TopTools_ListIteratorOfListOfShape itl (aEdges);
for (; itl.More(); itl.Next())
{
const TopoDS_Shape& anEdgeInFace = itl.Value();
if (anEdgeInFace.IsSame(anEdge))
{
theSeqEdges.Append (anEdgeInFace);
break;
}
}
}
if (theSeqEdges.Length() == 1)
return;
TopTools_IndexedDataMapOfShapeListOfShape aVEmap;
for (Standard_Integer ii = 1; ii <= theSeqEdges.Length(); ii++)
TopExp::MapShapesAndAncestors (theSeqEdges(ii), TopAbs_VERTEX, TopAbs_EDGE, aVEmap);
TopoDS_Vertex aFirstVertex;
TopoDS_Edge aFirstEdge;
for (Standard_Integer ii = 1; ii <= aVEmap.Extent(); ii++)
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (aVEmap.FindKey(ii));
const TopTools_ListOfShape& aElist = aVEmap(ii);
if (aElist.Extent() == 1)
{
const TopoDS_Edge& anEdge = TopoDS::Edge(aElist.First());
TopoDS_Vertex aV1, aV2;
TopExp::Vertices(anEdge, aV1, aV2, Standard_True); //with orientation
if (aV1.IsSame(aVertex))
{
aFirstVertex = aVertex;
aFirstEdge = anEdge;
break;
}
}
}
if (aFirstEdge.IsNull()) //closed set of edges
{
//Standard_Real aPeriod = 0.;
Standard_Integer IndCoord = DefineClosedness (theFace);
/*
BRepAdaptor_Surface aBAsurf (theFace, Standard_False);
if (IndCoord == 1)
aPeriod = aBAsurf.LastUParameter() - aBAsurf.FirstUParameter();
else if (IndCoord == 2)
aPeriod = aBAsurf.LastVParameter() - aBAsurf.FirstVParameter();
*/
if (IndCoord != 0)
{
Standard_Real aMaxDelta = 0.;
for (Standard_Integer ii = 1; ii <= aVEmap.Extent(); ii++)
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex (aVEmap.FindKey(ii));
const TopTools_ListOfShape& aElist = aVEmap(ii);
const TopoDS_Edge& anEdge1 = TopoDS::Edge(aElist.First());
const TopoDS_Edge& anEdge2 = TopoDS::Edge(aElist.Last());
Standard_Real aParam1 = BRep_Tool::Parameter(aVertex, anEdge1);
Standard_Real aParam2 = BRep_Tool::Parameter(aVertex, anEdge2);
BRepAdaptor_Curve2d aBAcurve1 (anEdge1, theFace);
BRepAdaptor_Curve2d aBAcurve2 (anEdge2, theFace);
gp_Pnt2d aPnt1 = aBAcurve1.Value(aParam1);
gp_Pnt2d aPnt2 = aBAcurve2.Value(aParam2);
Standard_Real aDelta = Abs(aPnt1.Coord(IndCoord) - aPnt2.Coord(IndCoord));
if (aDelta > aMaxDelta)
{
aMaxDelta = aDelta;
aFirstVertex = aVertex;
}
}
const TopTools_ListOfShape& aElist = aVEmap.FindFromKey(aFirstVertex);
TopTools_ListIteratorOfListOfShape itl (aElist);
for (; itl.More(); itl.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value());
TopoDS_Vertex aV1, aV2;
TopExp::Vertices(anEdge, aV1, aV2, Standard_True); //with orientation
if (aV1.IsSame(aFirstVertex))
{
aFirstEdge = anEdge;
break;
}
}
}
}
Standard_Integer aNbEdges = theSeqEdges.Length();
theSeqEdges.Clear();
theSeqEdges.Append (aFirstEdge);
TopoDS_Edge anEdge = aFirstEdge;
for (;;)
{
TopoDS_Vertex aLastVertex = TopExp::LastVertex (anEdge, Standard_True); //with orientation
if (aLastVertex.IsSame(aFirstVertex))
break;
const TopTools_ListOfShape& aElist = aVEmap.FindFromKey(aLastVertex);
if (aElist.Extent() == 1)
break;
if (aElist.First().IsSame(anEdge))
anEdge = TopoDS::Edge(aElist.Last());
else
anEdge = TopoDS::Edge(aElist.First());
theSeqEdges.Append (anEdge);
if (theSeqEdges.Length() == aNbEdges)
break;
}
}
//=======================================================================
//function : Store
@@ -150,6 +279,14 @@ static void Store(const TopoDS_Edge& theEdge,
Handle(BRepAlgo_AsDes) theAsDes2d,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
// Update vertices
TopTools_ListIteratorOfListOfShape aIt(theLV);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Vertex& aV = TopoDS::Vertex(aIt.Value());
BRep_Builder().UpdateVertex(aV, theTol);
}
// Get vertices already added to the edge and check the distances to the new ones
const TopTools_ListOfShape& aLVEx = theAsDes2d->Descendant(theEdge);
if (!IsToUpdate && aLVEx.IsEmpty()) {
if (theLV.Extent()) theAsDes2d->Add(theEdge, theLV);
@@ -157,21 +294,23 @@ static void Store(const TopoDS_Edge& theEdge,
}
//
GeomAPI_ProjectPointOnCurve aProjPC;
Standard_Real aTolE = 0.0;
if (IsToUpdate) {
Standard_Real aT1, aT2;
const Handle(Geom_Curve)& aC = BRep_Tool::Curve(theEdge, aT1, aT2);
aProjPC.Init(aC, aT1, aT2);
aTolE = BRep_Tool::Tolerance(theEdge);
}
//
TopTools_MapOfShape aMV;
TopTools_ListIteratorOfListOfShape aIt(theLV);
for (; aIt.More(); aIt.Next()) {
for (aIt.Init(theLV); aIt.More(); aIt.Next()) {
const TopoDS_Vertex& aV = TopoDS::Vertex(aIt.Value());
if (!aMV.Add(aV)) {
continue;
}
//
const gp_Pnt& aP = BRep_Tool::Pnt(aV);
const Standard_Real aTol = BRep_Tool::Tolerance(aV);
//
TopTools_ListOfShape aLVC;
TopTools_ListIteratorOfListOfShape aItEx(aLVEx);
@@ -181,7 +320,8 @@ static void Store(const TopoDS_Edge& theEdge,
break;
}
const gp_Pnt& aPEx = BRep_Tool::Pnt(aVEx);
if (aP.IsEqual(aPEx, theTol)) {
const Standard_Real aTolVEx = BRep_Tool::Tolerance(aVEx);
if (aP.IsEqual(aPEx, aTol + aTolVEx)) {
aLVC.Append(aVEx);
}
}
@@ -197,16 +337,13 @@ static void Store(const TopoDS_Edge& theEdge,
continue;
}
//
if (aProjPC.LowerDistance() > theTol) {
if (aProjPC.LowerDistance() > aTol + aTolE) {
continue;
}
//
Standard_Real aT = aProjPC.LowerDistanceParameter();
TopoDS_Shape aLocalShape = aV.Oriented(TopAbs_INTERNAL);
BRep_Builder().UpdateVertex(TopoDS::Vertex(aLocalShape), aT, theEdge, theTol);
}
else {
BRep_Builder().UpdateVertex(aV, theTol);
BRep_Builder().UpdateVertex(TopoDS::Vertex(aLocalShape), aT, theEdge, aTol);
}
//
if (aLVC.Extent()) {
@@ -505,7 +642,7 @@ static void EdgeInter(const TopoDS_Face& F,
// Vertex storage in DS.
//---------------------------------
Standard_Real TolStore = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
TolStore = Max(TolStore, 10.*Tol);
TolStore = Max (TolStore, Tol);
Store (E1,E2,LV1,LV2,TolStore,AsDes, aDMVV);
}
}
@@ -518,10 +655,13 @@ static void RefEdgeInter(const TopoDS_Face& F,
const BRepAdaptor_Surface& BAsurf,
const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const TopAbs_Orientation theOr1,
const TopAbs_Orientation theOr2,
const Handle(BRepAlgo_AsDes)& AsDes,
Standard_Real Tol,
Standard_Boolean WithOri,
gp_Pnt& Pref,
const TopoDS_Vertex& theVref,
BRepAlgo_Image& theImageVV,
TopTools_IndexedDataMapOfShapeListOfShape& aDMVV,
Standard_Boolean& theCoincide)
{
@@ -541,7 +681,7 @@ static void RefEdgeInter(const TopoDS_Face& F,
return;
Standard_Real f[3],l[3];
Standard_Real TolDub = 1.e-7;
Standard_Real TolDub = 1.e-7, TolLL = 0.0;
Standard_Integer i;
//BRep_Tool::Range(E1, f[1], l[1]);
@@ -558,9 +698,6 @@ static void RefEdgeInter(const TopoDS_Face& F,
BRepLib::BuildCurve3d(E1);
BRepLib::BuildCurve3d(E2);
Standard_Real TolSum = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
TolSum = Max( TolSum, 1.e-5 );
TColgp_SequenceOfPnt ResPoints;
TColStd_SequenceOfReal ResParamsOnE1, ResParamsOnE2;
gp_Pnt DegPoint;
@@ -590,11 +727,19 @@ static void RefEdgeInter(const TopoDS_Face& F,
(GAC2.GetType() == GeomAbs_Line))
{
// Just quickly check if lines coincide
if (GAC1.Line().Direction().IsParallel (GAC2.Line().Direction(), 1.e-8))
Standard_Real anAngle = Abs(GAC1.Line().Direction().Angle(GAC2.Line().Direction()));
if (anAngle <= 1.e-8 || M_PI - anAngle <= 1.e-8)
{
theCoincide = Standard_True;
return;
}
else
{
// Take into account the intersection range of line-line intersection
// (the smaller angle between curves, the bigger range)
TolLL = IntTools_Tools::ComputeIntRange(TolDub, TolDub, anAngle);
TolLL = Min (TolLL, 1.e-5);
}
}
Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
@@ -694,6 +839,12 @@ static void RefEdgeInter(const TopoDS_Face& F,
if (CrossProd > 0.)
OO2 = TopAbs_FORWARD;
}
if (theOr1 != TopAbs_EXTERNAL)
OO1 = theOr1;
if (theOr2 != TopAbs_EXTERNAL)
OO2 = theOr2;
LV1.Append( aNewVertex.Oriented(OO1) );
LV2.Append( aNewVertex.Oriented(OO2) );
}
@@ -755,7 +906,7 @@ static void RefEdgeInter(const TopoDS_Face& F,
while (j < i) {
P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1LV1.Value()));
P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2LV1.Value()));
if (P1.IsEqual(P2,10*Tol)) {
if (P1.IsEqual(P2, Tol)) {
LV1.Remove(it1LV1);
LV2.Remove(it1LV2);
if (AffichPurge) std::cout <<"Doubles removed in EdgeInter."<<std::endl;
@@ -775,6 +926,7 @@ static void RefEdgeInter(const TopoDS_Face& F,
////-----------------------------------------------------
if(LV1.Extent() > 1) {
//std::cout << "IFV - RefEdgeInter: remove vertex" << std::endl;
gp_Pnt Pref = BRep_Tool::Pnt(theVref);
Standard_Real dmin = RealLast();
TopoDS_Vertex Vmin;
for (it1LV1.Initialize(LV1); it1LV1.More(); it1LV1.Next()) {
@@ -795,9 +947,22 @@ static void RefEdgeInter(const TopoDS_Face& F,
}
}
TopTools_ListIteratorOfListOfShape itl (LV1);
for (; itl.More(); itl.Next())
{
TopoDS_Shape aNewVertex = itl.Value();
aNewVertex.Orientation(TopAbs_FORWARD);
if (theImageVV.HasImage (theVref))
theImageVV.Add (theVref.Oriented(TopAbs_FORWARD), aNewVertex);
else
theImageVV.Bind (theVref.Oriented(TopAbs_FORWARD), aNewVertex);
}
////-----------------------------------------------------
Standard_Real TolStore = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
TolStore = Max(TolStore, 10.*Tol);
TolStore = Max (TolStore, Tol);
// Compare to Line-Line tolerance
TolStore = Max (TolStore, TolLL);
Store (E1,E2,LV1,LV2,TolStore,AsDes, aDMVV);
}
}
@@ -1406,6 +1571,7 @@ void BRepOffset_Inter2d::Compute (const Handle(BRepAlgo_AsDes)& AsDes,
const TopoDS_Face& F,
const TopTools_IndexedMapOfShape& NewEdges,
const Standard_Real Tol,
const TopTools_DataMapOfShapeListOfShape& theEdgeIntEdges,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
#ifdef DRAW
@@ -1441,12 +1607,41 @@ void BRepOffset_Inter2d::Compute (const Handle(BRepAlgo_AsDes)& AsDes,
while (j < i && it2LE.More()) {
const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value());
Standard_Boolean ToIntersect = Standard_True;
if (theEdgeIntEdges.IsBound(E1))
{
const TopTools_ListOfShape& aElist = theEdgeIntEdges(E1);
TopTools_ListIteratorOfListOfShape itedges (aElist);
for (; itedges.More(); itedges.Next())
if (E2.IsSame (itedges.Value()))
ToIntersect = Standard_False;
if (ToIntersect)
{
for (itedges.Initialize(aElist); itedges.More(); itedges.Next())
{
const TopoDS_Shape& anEdge = itedges.Value();
if (theEdgeIntEdges.IsBound(anEdge))
{
const TopTools_ListOfShape& aElist2 = theEdgeIntEdges(anEdge);
TopTools_ListIteratorOfListOfShape itedges2 (aElist2);
for (; itedges2.More(); itedges2.Next())
if (E2.IsSame (itedges2.Value()))
ToIntersect = Standard_False;
}
}
}
}
//--------------------------------------------------------------
// Intersections of New edges obtained by intersection
// between them and with edges of restrictions
//------------------------------------------------------
if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) &&
if (ToIntersect &&
(!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) &&
(NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) {
TopoDS_Shape aLocalShape = F.Oriented(TopAbs_FORWARD);
EdgeInter(TopoDS::Face(aLocalShape),BAsurf,E1,E2,AsDes,Tol,Standard_True, theDMVV);
// EdgeInter(TopoDS::Face(F.Oriented(TopAbs_FORWARD)),E1,E2,AsDes,Tol,Standard_True);
@@ -1467,11 +1662,14 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
BRepOffset_Offset& OFI,
TopTools_DataMapOfShapeShape& MES,
const TopTools_DataMapOfShapeShape& Build,
const Handle(BRepAlgo_AsDes)& theAsDes,
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Offset,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedMapOfShape& FacesWithVerts,
BRepAlgo_Image& theImageVV,
TopTools_DataMapOfShapeListOfShape& theEdgeIntEdges,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
@@ -1529,8 +1727,7 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
continue; // Protection from case when explorer does not contain edges.
CurE = FirstE = wexp.Current();
TopTools_IndexedMapOfShape Edges;
Standard_Boolean ToReverse1, ToReverse2;
ToReverse1 = IsOrientationChanged(Edges, CurE);
while (!end) {
wexp.Next();
if (wexp.More()) {
@@ -1541,10 +1738,7 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
}
if (CurE.IsSame(NextE)) continue;
ToReverse2 = IsOrientationChanged(Edges, NextE);
TopoDS_Vertex Vref = CommonVertex(CurE, NextE);
gp_Pnt Pref = BRep_Tool::Pnt(Vref);
CurE = Analyse.EdgeReplacement (FI, CurE);
NextE = Analyse.EdgeReplacement (FI, NextE);
@@ -1559,21 +1753,38 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
TopTools_ListOfShape LV1,LV2;
Standard_Boolean DoInter = 1;
TopoDS_Shape NE1,NE2;
TopTools_SequenceOfShape NE1seq, NE2seq;
TopAbs_Orientation anOr1 = TopAbs_EXTERNAL, anOr2 = TopAbs_EXTERNAL;
Standard_Integer aChoice = 0;
if (Build.IsBound(CurE) && Build.IsBound(NextE)) {
aChoice = 1;
NE1 = Build(CurE );
NE2 = Build(NextE);
GetEdgesOrientedInFace (NE1, FIO, theAsDes, NE1seq);
GetEdgesOrientedInFace (NE2, FIO, theAsDes, NE2seq);
anOr1 = TopAbs_REVERSED;
anOr2 = TopAbs_FORWARD;
}
else if (Build.IsBound(CurE) && MES.IsBound(NEO)) {
aChoice = 2;
NE1 = Build(CurE);
NE2 = MES (NEO);
NE2.Orientation (NextE.Orientation());
GetEdgesOrientedInFace (NE1, FIO, theAsDes, NE1seq);
NE2seq.Append (NE2);
anOr1 = TopAbs_REVERSED;
anOr2 = TopAbs_FORWARD;
}
else if (Build.IsBound(NextE) && MES.IsBound(CEO)) {
aChoice = 3;
NE1 = Build(NextE);
NE2 = MES(CEO);
Standard_Boolean Tmp = ToReverse1;
ToReverse1 = ToReverse2;
ToReverse2 = Tmp;
NE2.Orientation (CurE.Orientation());
GetEdgesOrientedInFace (NE1, FIO, theAsDes, NE1seq);
NE2seq.Append (NE2);
anOr1 = TopAbs_FORWARD;
anOr2 = TopAbs_REVERSED;
}
else {
DoInter = 0;
@@ -1583,23 +1794,43 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
// NE1,NE2 can be a compound of Edges.
//------------------------------------
Standard_Boolean bCoincide;
TopExp_Explorer Exp1, Exp2;
for (Exp1.Init(NE1, TopAbs_EDGE); Exp1.More(); Exp1.Next()) {
TopoDS_Edge aE1 = TopoDS::Edge(Exp1.Current());
for (Exp2.Init(NE2, TopAbs_EDGE); Exp2.More(); Exp2.Next()) {
TopoDS_Edge aE2 = TopoDS::Edge(Exp2.Current());
//Correct orientation of edges
if (ToReverse1)
aE1.Reverse();
if (ToReverse2)
aE2.Reverse();
//////////////////////////////
RefEdgeInter(FIO, BAsurf, aE1, aE2, AsDes2d,
Tol, Standard_True, Pref, theDMVV, bCoincide);
TopoDS_Edge aE1, aE2;
if (aChoice == 1 || aChoice == 2)
{
aE1 = TopoDS::Edge (NE1seq.Last());
aE2 = TopoDS::Edge (NE2seq.First());
}
else // aChoice == 3
{
aE1 = TopoDS::Edge (NE1seq.First());
aE2 = TopoDS::Edge (NE2seq.Last());
}
if (aE1.Orientation() == TopAbs_REVERSED)
anOr1 = TopAbs::Reverse(anOr1);
if (aE2.Orientation() == TopAbs_REVERSED)
anOr2 = TopAbs::Reverse(anOr2);
RefEdgeInter(FIO, BAsurf, aE1, aE2, anOr1, anOr2, AsDes2d,
Tol, Standard_True, Vref, theImageVV, theDMVV, bCoincide);
if (theEdgeIntEdges.IsBound(aE1))
theEdgeIntEdges(aE1).Append(aE2);
else
{
TopTools_ListOfShape aElist;
aElist.Append(aE2);
theEdgeIntEdges.Bind (aE1, aElist);
}
if (theEdgeIntEdges.IsBound(aE2))
theEdgeIntEdges(aE2).Append(aE1);
else
{
TopTools_ListOfShape aElist;
aElist.Append(aE1);
theEdgeIntEdges.Bind (aE2, aElist);
}
//
// check if some of the offset edges have been
// generated out of the common vertex
@@ -1622,7 +1853,6 @@ Standard_Boolean BRepOffset_Inter2d::ConnexIntByInt
}
}
CurE = wexp.Current();
ToReverse1 = ToReverse2;
}
}
return Standard_True;
@@ -1682,7 +1912,6 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
if (CurE.IsSame(NextE)) continue;
//
TopoDS_Vertex Vref = CommonVertex(CurE, NextE);
gp_Pnt Pref = BRep_Tool::Pnt(Vref);
if (!Build.IsBound(Vref)) {
CurE = NextE;
continue;
@@ -1697,6 +1926,7 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
TopoDS_Edge NEO = TopoDS::Edge(aLocalShape);
//
TopoDS_Shape NE1,NE2;
TopAbs_Orientation anOr1 = TopAbs_EXTERNAL, anOr2 = TopAbs_EXTERNAL;
if (Build.IsBound(CurE) && Build.IsBound(NextE)) {
NE1 = Build(CurE );
@@ -1729,8 +1959,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
// intersection with first edge
for (Exp1.Init(NE1, TopAbs_EDGE); Exp1.More(); Exp1.Next()) {
const TopoDS_Edge& aE1 = TopoDS::Edge(Exp1.Current());
RefEdgeInter(FIO, BAsurf, aE1, aE3, AsDes2d,
Tol, Standard_True, Pref, theDMVV, bCoincide);
BRepAlgo_Image anEmptyImage;
RefEdgeInter(FIO, BAsurf, aE1, aE3, anOr1, anOr2, AsDes2d,
Tol, Standard_True, Vref, anEmptyImage, theDMVV, bCoincide);
if (bCoincide) {
// in case of coincidence trim the edge E3 the same way as E1
Store(aE3, AsDes2d->Descendant(aE1), Tol, Standard_True, AsDes2d, theDMVV);
@@ -1740,8 +1971,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
// intersection with second edge
for (Exp1.Init(NE2, TopAbs_EDGE); Exp1.More(); Exp1.Next()) {
const TopoDS_Edge& aE2 = TopoDS::Edge(Exp1.Current());
RefEdgeInter(FIO, BAsurf, aE2, aE3, AsDes2d,
Tol, Standard_True, Pref, theDMVV, bCoincide);
BRepAlgo_Image anEmptyImage;
RefEdgeInter(FIO, BAsurf, aE2, aE3, anOr1, anOr2, AsDes2d,
Tol, Standard_True, Vref, anEmptyImage, theDMVV, bCoincide);
if (bCoincide) {
// in case of coincidence trim the edge E3 the same way as E2
Store(aE3, AsDes2d->Descendant(aE2), Tol, Standard_True, AsDes2d, theDMVV);
@@ -1759,8 +1991,9 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
for (Exp1.Next(); Exp1.More(); Exp1.Next()) {
const TopoDS_Edge& aE3Next = TopoDS::Edge(Exp1.Current());
if (aME.Contains(aE3Next)) {
RefEdgeInter(FIO, BAsurf, aE3Next, aE3, AsDes2d,
Tol, Standard_True, Pref, theDMVV, bCoincide);
BRepAlgo_Image anEmptyImage;
RefEdgeInter(FIO, BAsurf, aE3Next, aE3, anOr1, anOr2, AsDes2d,
Tol, Standard_True, Vref, anEmptyImage, theDMVV, bCoincide);
}
}
}
@@ -1795,7 +2028,8 @@ static void MakeChain(const TopoDS_Shape& theV,
//purpose :
//=======================================================================
Standard_Boolean BRepOffset_Inter2d::FuseVertices (const TopTools_IndexedDataMapOfShapeListOfShape& theDMVV,
const Handle(BRepAlgo_AsDes)& theAsDes)
const Handle(BRepAlgo_AsDes)& theAsDes,
BRepAlgo_Image& theImageVV)
{
BRep_Builder aBB;
TopTools_MapOfShape aMVDone;
@@ -1837,6 +2071,11 @@ Standard_Boolean BRepOffset_Inter2d::FuseVertices (const TopTools_IndexedDataMap
}
// and replace the vertex
theAsDes->Replace(aVOld, aVNew);
if (theImageVV.IsImage(aVOld))
{
const TopoDS_Vertex& aProVertex = TopoDS::Vertex (theImageVV.ImageFrom(aVOld));
theImageVV.Add (aProVertex, aVNew.Oriented(TopAbs_FORWARD));
}
}
}
return Standard_True;

View File

@@ -24,14 +24,17 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_Real.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
class BRepAlgo_AsDes;
class TopoDS_Face;
class BRepAlgo_Image;
class BRepOffset_Analyse;
class BRepOffset_Offset;
class TopoDS_Edge;
class TopoDS_Face;
//! Computes the intersections betwwen edges on a face
//! Computes the intersections between edges on a face
//! stores result is SD as AsDes from BRepOffset.
class BRepOffset_Inter2d
{
@@ -50,6 +53,7 @@ public:
const TopoDS_Face& F,
const TopTools_IndexedMapOfShape& NewEdges,
const Standard_Real Tol,
const TopTools_DataMapOfShapeListOfShape& theEdgeIntEdges,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV);
//! Computes the intersection between the offset edges of the <FI>.
@@ -61,11 +65,14 @@ public:
BRepOffset_Offset& OFI,
TopTools_DataMapOfShapeShape& MES,
const TopTools_DataMapOfShapeShape& Build,
const Handle(BRepAlgo_AsDes)& theAsDes,
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Offset,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedMapOfShape& FacesWithVerts,
BRepAlgo_Image& theImageVV,
TopTools_DataMapOfShapeListOfShape& theEdgeIntEdges,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV);
//! Computes the intersection between the offset edges generated
@@ -88,7 +95,9 @@ public:
//! and updates AsDes by replacing the old vertices
//! with the new ones.
Standard_EXPORT static Standard_Boolean FuseVertices (const TopTools_IndexedDataMapOfShapeListOfShape& theDMVV,
const Handle(BRepAlgo_AsDes)& theAsDes);
const Handle(BRepAlgo_AsDes)& theAsDes,
BRepAlgo_Image& theImageVV);
//! extents the edge
Standard_EXPORT static Standard_Boolean ExtentEdge (const TopoDS_Edge& E,
TopoDS_Edge& NE,

View File

@@ -169,6 +169,7 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
{
TopTools_ListOfShape LInt1, LInt2;
TopoDS_Edge NullEdge;
TopoDS_Face NullFace;
if (F1.IsSame(F2)) return;
if (IsDone(F1,F2)) return;
@@ -221,11 +222,11 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
if (BRepOffset_Tool::FindCommonShapes(TopoDS::Face(InitF1),
TopoDS::Face(InitF2),LE,LV)) {
if (!LE.IsEmpty()) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
}
}
else {
BRepOffset_Tool::Inter3D(F1,F2,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D(F1,F2,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
}
}
}
@@ -236,7 +237,7 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
BRepOffset_Tool::PipeInter(F1,F2,LInt1,LInt2,mySide);
}
else {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
}
}
Store (F1,F2,LInt1,LInt2);
@@ -259,6 +260,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
TopTools_ListOfShape LInt1,LInt2;
TopoDS_Face F1,F2;
TopoDS_Edge NullEdge;
TopoDS_Face NullFace;
//---------------------------------------------------------------------
// etape 1 : Intersection of faces // corresponding to the initial faces
@@ -273,10 +275,13 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
//-----------------------------------------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(E);
if (Anc.Extent() == 2) {
F1 = TopoDS::Face(InitOffsetFace.Image(Anc.First()).First());
F2 = TopoDS::Face(InitOffsetFace.Image(Anc.Last ()).First());
const TopoDS_Face& InitF1 = TopoDS::Face(Anc.First());
const TopoDS_Face& InitF2 = TopoDS::Face(Anc.Last());
F1 = TopoDS::Face(InitOffsetFace.Image(InitF1).First());
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,E,Standard_True);
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,E,InitF1,InitF2);
Store (F1,F2,LInt1,LInt2);
}
}
@@ -361,7 +366,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
Store (F1,F2,LInt1,LInt2);
}
}
@@ -371,7 +376,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
Store (F1,F2,LInt1,LInt2);
}
}
@@ -635,7 +640,7 @@ void BRepOffset_Inter3d::ConnexIntByInt
//
if (!IsDone(NF1,NF2)) {
TopTools_ListOfShape LInt1,LInt2;
BRepOffset_Tool::Inter3D (NF1,NF2,LInt1,LInt2,CurSide,E,bEdge);
BRepOffset_Tool::Inter3D (NF1,NF2,LInt1,LInt2,CurSide,E,F1,F2);
SetDone(NF1,NF2);
if (!LInt1.IsEmpty()) {
Store (NF1,NF2,LInt1,LInt2);
@@ -1034,7 +1039,7 @@ void BRepOffset_Inter3d::ContextIntByInt
TopTools_ListOfShape LInt1,LInt2;
TopTools_ListOfShape LOE;
LOE.Append(OE);
BRepOffset_Tool::Inter3D (WCF,NF,LInt1,LInt2,Side,E,bEdge);
BRepOffset_Tool::Inter3D (WCF,NF,LInt1,LInt2,Side,E,CF,F);
SetDone(NF,CF);
if (!LInt1.IsEmpty()) {
Store (CF,NF,LInt1,LInt2);
@@ -1086,6 +1091,7 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
TopoDS_Edge OE;
BRep_Builder B;
TopoDS_Edge NullEdge;
TopoDS_Face NullFace;
Standard_Integer j;
for (j = 1; j <= ContextFaces.Extent(); j++) {
@@ -1255,7 +1261,7 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
// If no trace try intersection.
//-------------------------------------------------------
if (LInt1.IsEmpty()) {
BRepOffset_Tool::Inter3D (CF,OF1,LInt1,LInt2,mySide,NullEdge);
BRepOffset_Tool::Inter3D (CF,OF1,LInt1,LInt2,mySide,NullEdge,NullFace,NullFace);
}
Store (CF,OF1,LInt1,LInt2);
}

View File

@@ -51,12 +51,14 @@ BRepOffset_MakeLoops::BRepOffset_MakeLoops()
void BRepOffset_MakeLoops::Build(const TopTools_ListOfShape& LF,
const Handle(BRepAlgo_AsDes)& AsDes,
BRepAlgo_Image& Image)
BRepAlgo_Image& Image,
BRepAlgo_Image& theImageVV)
{
TopTools_ListIteratorOfListOfShape it(LF);
TopTools_ListIteratorOfListOfShape itl,itLCE;
BRepAlgo_Loop Loops;
Loops.VerticesForSubstitute( myVerVerMap );
Loops.SetImageVV (theImageVV);
for (; it.More(); it.Next()) {
const TopoDS_Face& F = TopoDS::Face(it.Value());

View File

@@ -39,11 +39,20 @@ public:
Standard_EXPORT BRepOffset_MakeLoops();
Standard_EXPORT void Build (const TopTools_ListOfShape& LF, const Handle(BRepAlgo_AsDes)& AsDes, BRepAlgo_Image& Image);
Standard_EXPORT void Build (const TopTools_ListOfShape& LF,
const Handle(BRepAlgo_AsDes)& AsDes,
BRepAlgo_Image& Image,
BRepAlgo_Image& theImageVV);
Standard_EXPORT void BuildOnContext (const TopTools_ListOfShape& LContext, const BRepOffset_Analyse& Analyse, const Handle(BRepAlgo_AsDes)& AsDes, BRepAlgo_Image& Image, const Standard_Boolean InSide);
Standard_EXPORT void BuildOnContext (const TopTools_ListOfShape& LContext,
const BRepOffset_Analyse& Analyse,
const Handle(BRepAlgo_AsDes)& AsDes,
BRepAlgo_Image& Image,
const Standard_Boolean InSide);
Standard_EXPORT void BuildFaces (const TopTools_ListOfShape& LF, const Handle(BRepAlgo_AsDes)& AsDes, BRepAlgo_Image& Image);
Standard_EXPORT void BuildFaces (const TopTools_ListOfShape& LF,
const Handle(BRepAlgo_AsDes)& AsDes,
BRepAlgo_Image& Image);

View File

@@ -591,6 +591,7 @@ BRepOffset_MakeOffset::BRepOffset_MakeOffset(const TopoDS_Shape& S,
:
myOffset (Offset),
myTol (Tol),
myInitialShape (S),
myShape (S),
myMode (Mode),
myInter (Inter),
@@ -623,6 +624,7 @@ void BRepOffset_MakeOffset::Initialize(const TopoDS_Shape& S,
const Standard_Boolean RemoveIntEdges)
{
myOffset = Offset;
myInitialShape = S;
myShape = S;
myTol = Tol;
myMode = Mode;
@@ -650,9 +652,11 @@ void BRepOffset_MakeOffset::Clear()
myInitOffsetFace .Clear();
myInitOffsetEdge .Clear();
myImageOffset .Clear();
myImageVV .Clear();
myFaces .Clear();
myOriginalFaces .Clear();
myFaceOffset .Clear();
myEdgeIntEdges .Clear();
myAsDes ->Clear();
myDone = Standard_False;
myGenerated.Clear();
@@ -1256,7 +1260,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
{
const TopoDS_Face& NEF = TopoDS::Face(itLFE.Value());
Standard_Real aCurrFaceTol = BRep_Tool::Tolerance(NEF);
BRepOffset_Inter2d::Compute(AsDes, NEF, NewEdges, aCurrFaceTol, aDMVV);
BRepOffset_Inter2d::Compute(AsDes, NEF, NewEdges, aCurrFaceTol, myEdgeIntEdges, aDMVV);
}
//----------------------------------------------
// Intersections 2d on caps.
@@ -1266,10 +1270,10 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
{
const TopoDS_Face& Cork = TopoDS::Face(myFaces(i));
Standard_Real aCurrFaceTol = BRep_Tool::Tolerance(Cork);
BRepOffset_Inter2d::Compute(AsDes, Cork, NewEdges, aCurrFaceTol, aDMVV);
BRepOffset_Inter2d::Compute(AsDes, Cork, NewEdges, aCurrFaceTol, myEdgeIntEdges, aDMVV);
}
//
BRepOffset_Inter2d::FuseVertices(aDMVV, AsDes);
BRepOffset_Inter2d::FuseVertices(aDMVV, AsDes, myImageVV);
//-------------------------------
// Unwinding of extended Faces.
//-------------------------------
@@ -1286,7 +1290,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
}
}
else {
myMakeLoops.Build(LFE, AsDes, IMOE);
myMakeLoops.Build(LFE, AsDes, IMOE, myImageVV);
}
//
#ifdef OCCT_DEBUG
@@ -2526,10 +2530,10 @@ void BRepOffset_MakeOffset::Intersection2D(const TopTools_IndexedMapOfShape& Mod
Standard_Integer i;
for (i = 1; i <= Modif.Extent(); i++) {
const TopoDS_Face& F = TopoDS::Face(Modif(i));
BRepOffset_Inter2d::Compute(myAsDes,F,NewEdges,myTol, aDMVV);
BRepOffset_Inter2d::Compute(myAsDes, F, NewEdges, myTol, myEdgeIntEdges, aDMVV);
}
//
BRepOffset_Inter2d::FuseVertices(aDMVV, myAsDes);
BRepOffset_Inter2d::FuseVertices(aDMVV, myAsDes, myImageVV);
//
#ifdef OCCT_DEBUG
if (AffichInt2d) {
@@ -2569,7 +2573,7 @@ void BRepOffset_MakeOffset::MakeLoops(TopTools_IndexedMapOfShape& Modif)
BuildSplitsOfTrimmedFaces(LF, myAsDes, myImageOffset);
}
else {
myMakeLoops.Build(LF,myAsDes,myImageOffset);
myMakeLoops.Build(LF,myAsDes,myImageOffset,myImageVV);
}
//-----------------------------------------
@@ -3345,7 +3349,7 @@ const BRepAlgo_Image& BRepOffset_MakeOffset::OffsetEdgesFromShapes() const
const TopTools_IndexedMapOfShape& BRepOffset_MakeOffset::ClosingFaces () const
{
return myFaces;
return myOriginalFaces;
}
@@ -3998,8 +4002,8 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopTools_ListOfShape& theFaces,
{
const TopoDS_Face& aF = TopoDS::Face (it.Value());
aTolF = BRep_Tool::Tolerance (aF);
if (!BRepOffset_Inter2d::ConnexIntByInt(aF, theMapSF(aF), theMES, theBuild, theAsDes2d,
myOffset, aTolF, myAnalyse, aMFV, aDMVV))
if (!BRepOffset_Inter2d::ConnexIntByInt(aF, theMapSF(aF), theMES, theBuild, theAsDes, theAsDes2d,
myOffset, aTolF, myAnalyse, aMFV, myImageVV, myEdgeIntEdges, aDMVV))
{
myError = BRepOffset_CannotExtentEdge;
return;
@@ -4015,7 +4019,7 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopTools_ListOfShape& theFaces,
}
//
// fuse vertices on edges
if (!BRepOffset_Inter2d::FuseVertices(aDMVV, theAsDes2d))
if (!BRepOffset_Inter2d::FuseVertices(aDMVV, theAsDes2d, myImageVV))
{
myError = BRepOffset_CannotFuseVertices;
return;
@@ -4490,9 +4494,24 @@ const TopTools_ListOfShape& BRepOffset_MakeOffset::Generated (const TopoDS_Shape
Standard_FALLTHROUGH
case TopAbs_FACE:
{
if (myInitOffsetFace.HasImage (theS))
TopoDS_Shape aS = theS;
const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aS);
if (aPlanface)
aS = TopoDS::Face(*aPlanface);
if (!myFaces.Contains (aS) &&
myInitOffsetFace.HasImage (aS))
{
myInitOffsetFace.LastImage (theS, myGenerated);
myInitOffsetFace.LastImage (aS, myGenerated);
if (!myFaces.IsEmpty())
{
// Reverse generated shapes in case of small solids.
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
it.Value().Reverse();
}
}
break;
}
@@ -4524,9 +4543,33 @@ const TopTools_ListOfShape& BRepOffset_MakeOffset::Generated (const TopoDS_Shape
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepOffset_MakeOffset::Modified (const TopoDS_Shape&)
const TopTools_ListOfShape& BRepOffset_MakeOffset::Modified (const TopoDS_Shape& theShape)
{
myGenerated.Clear();
if (theShape.ShapeType() == TopAbs_FACE)
{
TopoDS_Shape aS = theShape;
const TopoDS_Shape* aPlanface = myFacePlanfaceMap.Seek(aS);
if (aPlanface)
aS = TopoDS::Face(*aPlanface);
if (myFaces.Contains (aS) &&
myInitOffsetFace.HasImage (aS))
{
myInitOffsetFace.LastImage (aS, myGenerated);
if (!myFaces.IsEmpty())
{
// Reverse generated shapes in case of small solids.
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
it.Value().Reverse();
}
}
}
return myGenerated;
}

View File

@@ -97,7 +97,7 @@ public:
const TopoDS_Shape& InitShape() const
{
return myShape;
return myInitialShape;
}
//! returns information about offset state.
@@ -231,6 +231,7 @@ private:
Standard_Real myOffset;
Standard_Real myTol;
TopoDS_Shape myInitialShape;
TopoDS_Shape myShape;
TopoDS_Compound myFaceComp;
BRepOffset_Mode myMode;
@@ -248,8 +249,10 @@ private:
BRepAlgo_Image myInitOffsetFace;
BRepAlgo_Image myInitOffsetEdge;
BRepAlgo_Image myImageOffset;
BRepAlgo_Image myImageVV;
TopTools_ListOfShape myWalls;
Handle(BRepAlgo_AsDes) myAsDes;
TopTools_DataMapOfShapeListOfShape myEdgeIntEdges;
Standard_Boolean myDone;
BRepOffset_Error myError;
BRepOffset_MakeLoops myMakeLoops;

View File

@@ -195,6 +195,12 @@ static
BRepOffset_DataMapOfShapeMapOfShape& theLocValidEdges,
BRepOffset_DataMapOfShapeMapOfShape& theNeutralEdges);
static
void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset,
const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_IndexedMapOfShape& theInvEdges);
static
void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
const TopTools_IndexedMapOfShape& theInvEdges,
@@ -1030,6 +1036,10 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
FindInvalidEdges (aLFDone, theFImages, theFacesOrigins, theAnalyse,
theInvEdges, theValidEdges, aDMFMIE, aDMFMVE, aDMFMNE);
// Additional step to mark inverted edges located inside loops
// of invalid edges as invalid as well
MakeInvertedEdgesInvalid(aLFDone, theFImages, theInvertedEdges, theInvEdges);
#ifdef OFFSET_DEBUG
// show invalid edges
TopoDS_Compound aCEInv1;
@@ -2180,6 +2190,82 @@ void FindInvalidEdges (const TopTools_ListOfShape& theLFOffset,
}
}
//=======================================================================
//function : MakeInvertedEdgesInvalid
//purpose : Makes inverted edges located inside loop of invalid edges, invalid as well
//=======================================================================
void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset,
const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_IndexedMapOfShape& theInvEdges)
{
if (theInvEdges.IsEmpty() || theInvertedEdges.IsEmpty())
return;
// Map all invalid edges
TopoDS_Compound aCBEInv;
BRep_Builder().MakeCompound(aCBEInv);
for (Standard_Integer i = 1; i <= theInvEdges.Extent(); ++i)
{
BRep_Builder().Add(aCBEInv, theInvEdges(i));
}
// Make loops of invalid edges
TopTools_ListOfShape aLCB;
BOPTools_AlgoTools::MakeConnexityBlocks(aCBEInv, TopAbs_VERTEX, TopAbs_EDGE, aLCB);
// Analyze each loop on closeness and use only closed ones
TopTools_DataMapOfShapeShape aDMVCB;
for (TopTools_ListOfShape::Iterator itLCB(aLCB); itLCB.More(); itLCB.Next())
{
const TopoDS_Shape& aCB = itLCB.Value();
TopTools_IndexedDataMapOfShapeListOfShape aDMVE;
TopExp::MapShapesAndAncestors(aCB, TopAbs_VERTEX, TopAbs_EDGE, aDMVE);
Standard_Boolean isClosed = Standard_True;
for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV)
{
if (aDMVE(iV).Extent() != 2)
{
isClosed = Standard_False;
break;
}
}
if (!isClosed)
continue;
// Bind loop to each vertex of the loop
for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV)
{
aDMVCB.Bind(aDMVE.FindKey(iV), aCB);
}
}
// Check if any inverted edges of offset faces are locked inside the loops of invalid edges.
// Make such edges invalid as well.
for (TopTools_ListOfShape::Iterator itLF(theLFOffset); itLF.More(); itLF.Next())
{
const TopTools_ListOfShape& aLFIm = theFImages.FindFromKey(itLF.Value());
for (TopTools_ListOfShape::Iterator itLFIm(aLFIm); itLFIm.More(); itLFIm.Next())
{
for (TopExp_Explorer expE(itLFIm.Value(), TopAbs_EDGE); expE.More(); expE.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge(expE.Current());
if (!theInvEdges.Contains(aE) && theInvertedEdges.Contains(aE))
{
const TopoDS_Shape* pCB1 = aDMVCB.Seek (TopExp::FirstVertex(aE));
const TopoDS_Shape* pCB2 = aDMVCB.Seek (TopExp::LastVertex(aE));
if (pCB1 && pCB2 && pCB1->IsSame(*pCB2))
{
theInvEdges.Add(aE);
}
}
}
}
}
}
//=======================================================================
//function : FindInvalidFaces
//purpose : Looking for the invalid faces by analyzing their invalid edges
@@ -5678,7 +5764,9 @@ void IntersectFaces(const TopoDS_Shape& theFInv,
TopAbs_State aSide = TopAbs_OUT;
TopTools_ListOfShape aLInt1, aLInt2;
TopoDS_Edge aNullEdge;
BRepOffset_Tool::Inter3D(TopoDS::Face(theFi), TopoDS::Face(theFj), aLInt1, aLInt2, aSide, aNullEdge);
TopoDS_Face aNullFace;
BRepOffset_Tool::Inter3D(TopoDS::Face(theFi), TopoDS::Face(theFj), aLInt1, aLInt2, aSide,
aNullEdge, aNullFace, aNullFace);
//
if (aLInt1.IsEmpty()) {
return;

View File

@@ -1402,7 +1402,8 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
TopTools_ListOfShape& L2,
const TopAbs_State Side,
const TopoDS_Edge& RefEdge,
const Standard_Boolean IsRefEdgeDefined)
const TopoDS_Face& theRefFace1,
const TopoDS_Face& theRefFace2)
{
#ifdef DRAW
if (AffichInter) {
@@ -1445,7 +1446,7 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
aPF.Perform();
TopTools_IndexedMapOfShape TrueEdges;
if (IsRefEdgeDefined)
if (!RefEdge.IsNull())
CheckIntersFF( aPF.PDS(), RefEdge, TrueEdges );
Standard_Boolean addPCurve1 = 1;
@@ -1563,6 +1564,84 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
else if (aSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface)))
isEl2 = Standard_True;
if (L1.Extent() > 1 && (!isEl1 || !isEl2) && !theRefFace1.IsNull())
{
//remove excess edges that are out of range
TopoDS_Vertex aV1, aV2;
TopExp::Vertices (RefEdge, aV1, aV2);
if (!aV1.IsSame(aV2)) //only if RefEdge is open
{
Handle(Geom_Surface) aRefSurf1 = BRep_Tool::Surface (theRefFace1);
Handle(Geom_Surface) aRefSurf2 = BRep_Tool::Surface (theRefFace2);
if (aRefSurf1->IsUClosed() || aRefSurf1->IsVClosed() ||
aRefSurf2->IsUClosed() || aRefSurf2->IsVClosed())
{
TopoDS_Edge MinAngleEdge;
Standard_Real MinAngle = Precision::Infinite();
BRepAdaptor_Curve aRefBAcurve (RefEdge);
gp_Pnt aRefPnt = aRefBAcurve.Value ((aRefBAcurve.FirstParameter() + aRefBAcurve.LastParameter())/2);
TopTools_ListIteratorOfListOfShape itl (L1);
for (; itl.More(); itl.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (itl.Value());
BRepAdaptor_Curve aBAcurve (anEdge);
gp_Pnt aMidPntOnEdge = aBAcurve.Value ((aBAcurve.FirstParameter() + aBAcurve.LastParameter())/2);
gp_Vec RefToMid (aRefPnt, aMidPntOnEdge);
Extrema_ExtPC aProjector (aRefPnt, aBAcurve);
if (aProjector.IsDone())
{
Standard_Integer imin = 0;
Standard_Real MinSqDist = Precision::Infinite();
for (Standard_Integer ind = 1; ind <= aProjector.NbExt(); ind++)
{
Standard_Real aSqDist = aProjector.SquareDistance(ind);
if (aSqDist < MinSqDist)
{
MinSqDist = aSqDist;
imin = ind;
}
}
if (imin != 0)
{
gp_Pnt aProjectionOnEdge = aProjector.Point(imin).Value();
gp_Vec RefToProj (aRefPnt, aProjectionOnEdge);
Standard_Real anAngle = RefToProj.Angle(RefToMid);
if (anAngle < MinAngle)
{
MinAngle = anAngle;
MinAngleEdge = anEdge;
}
}
}
}
if (!MinAngleEdge.IsNull())
{
TopTools_ListIteratorOfListOfShape itlist1 (L1);
TopTools_ListIteratorOfListOfShape itlist2 (L2);
while (itlist1.More())
{
const TopoDS_Shape& anEdge = itlist1.Value();
if (anEdge.IsSame(MinAngleEdge))
{
itlist1.Next();
itlist2.Next();
}
else
{
L1.Remove(itlist1);
L2.Remove(itlist2);
}
}
}
} //if closed
} //if (!aV1.IsSame(aV2))
} //if (L1.Extent() > 1 && (!isEl1 || !isEl2) && !theRefFace1.IsNull())
if (L1.Extent() > 1 && (!isEl1 || !isEl2)) {
TopTools_SequenceOfShape eseq;
TopTools_SequenceOfShape EdgesForConcat;
@@ -1724,7 +1803,7 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1,
eseq.Append( aLocalEdgesForConcat(j) );
else
eseq.Append( AssembledEdge );
}
} //for (i = 1; i <= wseq.Length(); i++)
} //end of else (when TrueEdges is empty)
if (eseq.Length() < L1.Extent())
@@ -3468,7 +3547,8 @@ void BRepOffset_Tool::ExtentFace (const TopoDS_Face& F,
if (ConstShapes.IsBound(E)) ToBuild.UnBind(E);
if (ToBuild.IsBound(E)) {
EnLargeFace(TopoDS::Face(ToBuild(E)),StopFace,Standard_False);
BRepOffset_Tool::Inter3D (EF,StopFace,LInt1,LInt2,Side,E,Standard_True);
TopoDS_Face NullFace;
BRepOffset_Tool::Inter3D (EF,StopFace,LInt1,LInt2,Side,E,NullFace,NullFace);
// No intersection, it may happen for example for a chosen (non-offseted) planar face and
// its neighbour offseted cylindrical face, if the offset is directed so that
// the radius of the cylinder becomes smaller.

View File

@@ -89,7 +89,8 @@ public:
TopTools_ListOfShape& LInt2,
const TopAbs_State Side,
const TopoDS_Edge& RefEdge,
const Standard_Boolean IsRefEdgeDefined = Standard_False);
const TopoDS_Face& RefFace1,
const TopoDS_Face& RefFace2);
//! Find if the edges <Edges> of the face <F2> are on
//! the face <F1>.

View File

@@ -560,6 +560,10 @@ static Standard_Integer setsweep(Draw_Interpretor& di,
di << " -CN dx dy dz : BiNormal is given by dx dy dz\n";
di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n";
di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n";
di << " -SM : Set the maximum degree of approximation\n";
di << " paramvalue more then 0 (100 by default)\n";
di << " -DM : Set the maximum number of span of approximation\n";
di << " paramvalue [1; 14] (11 by default)\n";
return 0;
}
@@ -630,6 +634,42 @@ static Standard_Integer setsweep(Draw_Interpretor& di,
(BRepFill_TypeOfContact)KeepContact);
}
}
else if (!strcmp(a[1], "-DM"))
{
if (n != 3)
{
di << "bad arguments !\n";
return 1;
}
if (Draw::Atoi(a[2]) > 0 && Draw::Atoi(a[2]) < 15)
{
Sweep->SetMaxDegree(Draw::Atoi(a[2]));
}
else
{
di << " -DM paramvalue must be [1; 14]\n";
return 1;
}
}
else if (!strcmp(a[1], "-SM"))
{
if (n != 3)
{
di << "bad arguments !\n";
return 1;
}
if (Draw::Atoi(a[2]) > 0)
{
Sweep->SetMaxSegments(Draw::Atoi(a[2]));
}
else
{
di << " -SM paramvalue must be more then 0\n";
return 1;
}
}
else {
di << "The option " << a[1] << " is unknown !\n";
@@ -638,7 +678,6 @@ static Standard_Integer setsweep(Draw_Interpretor& di,
return 0;
}
//=======================================================================
// addsweep
//=======================================================================
@@ -985,9 +1024,9 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep",
__FILE__, errorsweep, g);
theCommands.Add("simulsweep", "simulsweep r [n] [option]"
theCommands.Add("simulsweep", "simulsweep r [n] [option]",
__FILE__, simulsweep, g);
theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]",
__FILE__, geompipe, g);
theCommands.Add("middlepath", "middlepath res shape startshape endshape",

View File

@@ -1780,10 +1780,12 @@ void BiTgte_Blend::ComputeCenters()
}
}
}
TopTools_DataMapOfShapeListOfShape anEmptyMap;
BRepOffset_Inter2d::Compute(myAsDes,
CurOF,
myEdges,
myTol,
anEmptyMap,
aDMVV);
}
}
@@ -1813,20 +1815,23 @@ void BiTgte_Blend::ComputeCenters()
myAsDes->Add(CurOF,CurOE);
}
TopTools_DataMapOfShapeListOfShape anEmptyMap;
BRepOffset_Inter2d::Compute(myAsDes,
CurOF,
myEdges,
myTol,
anEmptyMap,
aDMVV);
}
//
// fuse vertices on edges stored in AsDes
BRepOffset_Inter2d::FuseVertices(aDMVV, myAsDes);
BRepAlgo_Image anEmptyImage;
BRepOffset_Inter2d::FuseVertices(aDMVV, myAsDes, anEmptyImage);
// ------------
// unwinding
// ------------
BRepOffset_MakeLoops MakeLoops;
MakeLoops.Build( LOF, myAsDes, myImageOffset );
MakeLoops.Build (LOF, myAsDes, myImageOffset, anEmptyImage);
// ------------------------------------------------------------
// It is possible to unwind edges at least one ancestor which of

View File

@@ -208,12 +208,13 @@ Standard_Integer Extrema_FuncExtCS::GetStateNumber()
std::cout <<"F(1)= "<<Sol(1)<<" F(2)= "<<Sol(2)<<" F(3)= "<<Sol(3)<<std::endl;
#endif
//comparison of solution with previous solutions
Standard_Real tol2d = Precision::PConfusion() * Precision::PConfusion();
Standard_Real tol2d = Precision::SquarePConfusion();
Standard_Integer i = 1, nbSol = mySqDist.Length();
for( ; i <= nbSol; i++)
{
Standard_Real aT = myPoint1(i).Parameter();
if( (myt - aT) * (myt - aT) <= tol2d )
aT -= myt; aT *= aT;
if( aT <= tol2d )
break;
}
if (i <= nbSol)

View File

@@ -84,14 +84,21 @@ public:
//! Return the Nth extremum on S.
Standard_EXPORT const Extrema_POnSurf& PointOnSurface (const Standard_Integer N) const;
protected:
//! Change Sequence of SquareDistance
TColStd_SequenceOfReal& SquareDistances()
{
return mySqDist;
}
//! Change Sequence of PointOnCurv
Extrema_SequenceOfPOnCurv& PointsOnCurve()
{
return myPoint1;
}
//! Change Sequence of PointOnSurf
Extrema_SequenceOfPOnSurf& PointsOnSurf()
{
return myPoint2;
}
private:

View File

@@ -38,6 +38,8 @@
#include <TColgp_Array1OfPnt.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <ElCLib.hxx>
#include <Extrema_GenLocateExtPS.hxx>
const Standard_Real MaxParamVal = 1.0e+10;
const Standard_Real aBorderDivisor = 1.0e+4;
@@ -304,17 +306,31 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
Tol(2) = mytol2;
Tol(3) = mytol2;
//
TUVinf(1) = mytmin;
// Number of particles used in PSO algorithm (particle swarm optimization).
const Standard_Integer aNbParticles = 48;
Standard_Integer aNbIntC = 1;
if (C.IsClosed() || C.IsPeriodic())
{
Standard_Real aPeriod = C.Period();
if (C.LastParameter() - C.FirstParameter() > 2. * aPeriod / 3.)
{
aNbIntC = 2;
}
}
Standard_Integer anInt;
Standard_Real dT = (mytsup - mytmin) / aNbIntC;
for (anInt = 1; anInt <= aNbIntC; anInt++)
{
TUVinf(1) = mytmin + (anInt - 1) * dT;
TUVinf(2) = trimumin;
TUVinf(3) = trimvmin;
//
TUVsup(1) = mytsup;
TUVsup(1) = TUVinf(1) + dT; // mytsup;
TUVsup(2) = trimusup;
TUVsup(3) = trimvsup;
//
// Number of particles used in PSO algorithm (particle swarm optimization).
const Standard_Integer aNbParticles = 48;
//
if (aNbVar == 3)
{
GlobMinGenCS(C, aNbParticles, TUVinf, TUVsup, TUV);
@@ -331,8 +347,44 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
// Find min approximation
math_FunctionSetRoot anA(myF, Tol);
anA.Perform(myF, TUV, TUVinf, TUVsup);
}
if (aNbIntC > 1 && myF.NbExt() > 1)
{
//Try to remove "false" extrema caused by dividing curve interval
TColStd_SequenceOfReal& aSqDists = myF.SquareDistances();
Extrema_SequenceOfPOnCurv& aPntsOnCrv = myF.PointsOnCurve();
Extrema_SequenceOfPOnSurf& aPntsOnSurf = myF.PointsOnSurf();
TColStd_SequenceOfReal aSqDists1(aSqDists);
Extrema_SequenceOfPOnCurv aPntsOnCrv1(aPntsOnCrv);
Extrema_SequenceOfPOnSurf aPntsOnSurf1(aPntsOnSurf);
Standard_Real aMinDist = aSqDists(1);
Standard_Integer i;
for (i = 2; i <= aSqDists.Length(); ++i)
{
Standard_Real aDist = aSqDists(i);
if (aDist < aMinDist)
{
aMinDist = aDist;
}
}
aSqDists.Clear();
aPntsOnCrv.Clear();
aPntsOnSurf.Clear();
Standard_Real aTol = Precision::SquareConfusion();
for (i = 1; i <= aSqDists1.Length(); ++i)
{
Standard_Real aDist = aSqDists1(i);
if (Abs(aDist - aMinDist) <= aTol)
{
aSqDists.Append(aDist);
aPntsOnCrv.Append(aPntsOnCrv1(i));
aPntsOnSurf.Append(aPntsOnSurf1(i));
}
}
}
myDone = Standard_True;
}
//=======================================================================
//function : GlobMinGenCS
@@ -447,6 +499,7 @@ void Extrema_GenExtCS::GlobMinConicS(const Adaptor3d_Curve& theC,
anUVsup(i) = theTUVsup(i + 1);
}
//
//
math_PSOParticlesPool aParticles(theNbParticles, aNbVar);
math_Vector aMinUV(1, aNbVar);
@@ -517,10 +570,103 @@ void Extrema_GenExtCS::GlobMinConicS(const Adaptor3d_Curve& theC,
aCT = ElCLib::InPeriod(aCT, theTUVinf(1), theTUVinf(1) + 2. * M_PI);
}
}
theTUV(1) = aCT;
theTUV(2) = anUV(1);
theTUV(3) = anUV(2);
Standard_Boolean isBadSol = Standard_False;
gp_Vec aDU, aDV, aDT;
gp_Pnt aPOnS, aPOnC;
myS->D1(anUV(1), anUV(2), aPOnS, aDU, aDV);
theC.D1(aCT, aPOnC, aDT);
Standard_Real aSqDist = aPOnC.SquareDistance(aPOnS);
if (aSqDist <= Precision::SquareConfusion())
return;
gp_Vec aN = aDU.Crossed(aDV);
if (aN.SquareMagnitude() < Precision::SquareConfusion())
return;
gp_Vec PcPs(aPOnC, aPOnS);
Standard_Real anAngMin = M_PI_2 - M_PI_2 / 10.;
Standard_Real anAngMax = M_PI_2 + M_PI_2 / 10.;
Standard_Real anAngN = PcPs.Angle(aN);
if (anAngN >= anAngMin && anAngN <= anAngMax)
{
// PcPs is perpendicular to surface normal, it means that
// aPOnC can be on surface, but far from aPOnS
isBadSol = Standard_True;
Standard_Integer iu, iv;
for (iu = -1; iu <= 1; ++iu)
{
Standard_Real u = anUV(1) + iu * aStepSU;
u = Max(anUVinf(1), u);
u = Min(anUVsup(1), u);
for (iv = -1; iv <= 1; ++iv)
{
Standard_Real v = anUV(2) + iv * aStepSV;
v = Max(anUVinf(2), v);
v = Min(anUVsup(2), v);
myS->D1(u, v, aPOnS, aDU, aDV);
if (aPOnC.SquareDistance(aPOnS) < Precision::SquareConfusion())
{
isBadSol = Standard_False;
break;
}
aN = aDU.Crossed(aDV);
if (aN.SquareMagnitude() < Precision::SquareConfusion())
{
isBadSol = Standard_False;
break;
}
PcPs.SetXYZ(aPOnS.XYZ() - aPOnC.XYZ());
anAngN = PcPs.Angle(aN);
if (anAngN < anAngMin || anAngN > anAngMax)
{
isBadSol = Standard_False;
break;
}
}
if (!isBadSol)
{
break;
}
}
}
if (isBadSol)
{
//Try to precise solution with help of Extrema PS
math_Vector aF(1, 3);
aF(1) = PcPs.Dot(aDT);
aF(2) = PcPs.Dot(aDU);
aF(3) = PcPs.Dot(aDV);
Standard_Real aFF = aF.Norm2();
Extrema_GenLocateExtPS anExtPS(*myS, mytol2, mytol2);
anExtPS.Perform(aPOnC, anUV(1), anUV(2), Standard_False);
if (anExtPS.IsDone())
{
const Extrema_POnSurf& aPmin = anExtPS.Point();
aPmin.Parameter(anUV(1), anUV(2));
math_Vector aTUV = theTUV;
aTUV(2) = anUV(1);
aTUV(3) = anUV(2);
myF.Value(aTUV, aF);
Standard_Real aFF1 = aF.Norm2();
if (anExtPS.SquareDistance() < aSqDist && aFF1 <= 1.1 * aFF)
{
theTUV(2) = aTUV(2);
theTUV(3) = aTUV(3);
}
}
}
}
//=======================================================================
//function : GlobMinCQuadric

View File

@@ -882,7 +882,7 @@ Standard_Real GeomFill_CorrectedFrenet::GetAngleAT(const Standard_Real Param) co
frenet->Intervals(FrenetInt, S);
EvolAroundT->Intervals(LawInt, S);
GeomLib::FuseIntervals(FrenetInt, LawInt, Fusion);
GeomLib::FuseIntervals(FrenetInt, LawInt, Fusion, Precision::PConfusion(), Standard_True);
return Fusion.Length()-1;
}
@@ -913,7 +913,7 @@ Standard_Real GeomFill_CorrectedFrenet::GetAngleAT(const Standard_Real Param) co
frenet->Intervals(FrenetInt, S);
EvolAroundT->Intervals(LawInt, S);
GeomLib::FuseIntervals(FrenetInt, LawInt, Fusion);
GeomLib::FuseIntervals(FrenetInt, LawInt, Fusion, Precision::PConfusion(), Standard_True);
for(Standard_Integer i = 1; i <= Fusion.Length(); i++)
T.ChangeValue(i) = Fusion.Value(i);

View File

@@ -692,7 +692,7 @@ Standard_Boolean
myCurve->Intervals(TrimInt, tmpS);
TColStd_SequenceOfReal Fusion;
GeomLib::FuseIntervals(TrimInt, mySngl->Array1(), Fusion);
GeomLib::FuseIntervals(TrimInt, mySngl->Array1(), Fusion, Precision::PConfusion(), Standard_True);
return Fusion.Length() - 1;
}
@@ -726,7 +726,7 @@ Standard_Boolean
myCurve->Intervals(TrimInt, tmpS);
TColStd_SequenceOfReal Fusion;
GeomLib::FuseIntervals(TrimInt, mySngl->Array1(), Fusion);
GeomLib::FuseIntervals(TrimInt, mySngl->Array1(), Fusion, Precision::PConfusion(), Standard_True);
for (Standard_Integer i = 1; i <= Fusion.Length(); i++)
T.ChangeValue(i) = Fusion.Value(i);

View File

@@ -415,7 +415,8 @@ void GeomLib::DensifyArray1OfReal(const Standard_Integer MinNumPoints,
void GeomLib::FuseIntervals(const TColStd_Array1OfReal& I1,
const TColStd_Array1OfReal& I2,
TColStd_SequenceOfReal& Seq,
const Standard_Real Epspar)
const Standard_Real Epspar,
const Standard_Boolean IsAdjustToFirstInterval)
{
Standard_Integer ind1=1, ind2=1;
Standard_Real v1, v2;
@@ -432,7 +433,14 @@ void GeomLib::FuseIntervals(const TColStd_Array1OfReal& I1,
v2 = I2(ind2);
if (Abs(v1-v2)<= Epspar) {
// Ici les elements de I1 et I2 conviennent .
Seq.Append((v1+v2)/2);
if (IsAdjustToFirstInterval)
{
Seq.Append(v1);
}
else
{
Seq.Append((v1 + v2) / 2);
}
ind1++;
ind2++;
}

View File

@@ -170,7 +170,19 @@ public:
//! non decreasing
Standard_EXPORT static void DensifyArray1OfReal (const Standard_Integer MinNumPoints, const TColStd_Array1OfReal& InParameters, Handle(TColStd_HArray1OfReal)& OutParameters);
Standard_EXPORT static void FuseIntervals (const TColStd_Array1OfReal& Interval1, const TColStd_Array1OfReal& Interval2, TColStd_SequenceOfReal& Fusion, const Standard_Real Confusion = 1.0e-9);
//! This method fuse intervals Interval1 and Interval2 with specified Confusion
//! @param Interval1 [in] first interval to fuse
//! @param Interval2 [in] second interval to fuse
//! @param Confision [in] tolerance to compare intervals
//! @param IsAdjustToFirstInterval [in] flag to set method of fusion, if intervals are close
//! if false, intervals are fusing by half-division methdod
//! if true, intervals are fusing by selecting value from Interval1
//! @param Fusion [out] output interval
Standard_EXPORT static void FuseIntervals (const TColStd_Array1OfReal& Interval1,
const TColStd_Array1OfReal& Interval2,
TColStd_SequenceOfReal& Fusion,
const Standard_Real Confusion = 1.0e-9,
const Standard_Boolean IsAdjustToFirstInterval = Standard_False);
//! this will compute the maximum distance at the
//! parameters given in the Parameters array by

View File

@@ -178,6 +178,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
#ifdef CHRONO
Chronrsnld.Stop();
#endif
Standard_Boolean isOnDegeneratedBorder = Standard_False;
if (Cadre) { // update of limits.
BornInf(1) = Um;BornSup(1) = UM;BornInf(2) = Vm;BornSup(2) = VM;
@@ -262,6 +263,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
/ (uv[aCoordIdx - 1] - uvprev[aCoordIdx - 1]) );
Standard_Integer aFixIdx = aCoordIdx == 1? 2 : 1; // Fixing index;
Uvap(aFixIdx) = uv[aFixIdx - 1] + (uv[aFixIdx - 1] - uvprev[aFixIdx - 1]) * aScaleCoeff;
isOnDegeneratedBorder = Standard_True;
}
}
}
@@ -307,6 +309,8 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
if (N <= 0) { // jag 941017
MakeWalkingPoint(2,Uvap(1),Uvap(2),Func,Psol);
Tgtend = Func.IsTangent(); // jag 940616
if (isOnDegeneratedBorder)
Tgtend = Standard_True;
N = -N;
}
Arrive = (wd2[I].etat == 12); // the line is open
@@ -315,6 +319,9 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
aStatus = TestDeflection(Func, Arrive,Uvap,StatusPrecedent,
NbDivision,PasC,StepSign);
if (isOnDegeneratedBorder && Tgtend)
aStatus = IntWalk_ArretSurPoint;
StatusPrecedent = aStatus;
if (aStatus == IntWalk_PasTropGrand) {// division of the step
Arrive = Standard_False;

View File

@@ -29,6 +29,9 @@
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ElementarySurface.hxx>
#include <Geom_Line.hxx>
@@ -67,6 +70,7 @@
#include <TColGeom_SequenceOfSurface.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_SequenceOfBoolean.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
@@ -96,11 +100,10 @@
IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_UnifySameDomain,Standard_Transient)
struct SubSequenceOfEdges
{
TopTools_SequenceOfShape SeqsEdges;
TopoDS_Edge UnionEdges;
};
static void SplitWire (const TopoDS_Wire& theWire,
const TopoDS_Face& theFace,
const TopTools_IndexedMapOfShape& theVmap,
TopTools_SequenceOfShape& theWireSeq);
static Standard_Real TrueValueOfOffset(const Standard_Real theValue,
const Standard_Real thePeriod)
@@ -135,6 +138,40 @@ static void UpdateBoundaries(const Handle(Geom2d_Curve)& thePCurve,
}
}
static Standard_Boolean TryMakeLine(const Handle(Geom2d_Curve)& thePCurve,
const Standard_Real theFirst,
const Standard_Real theLast,
Handle(Geom2d_Line)& theLine)
{
gp_Pnt2d aFirstPnt = thePCurve->Value (theFirst);
gp_Pnt2d aLastPnt = thePCurve->Value (theLast);
gp_Vec2d aVec (aFirstPnt, aLastPnt);
Standard_Real aSqLen = aVec.SquareMagnitude();
Standard_Real aSqParamLen = (theLast - theFirst)*(theLast - theFirst);
if (Abs(aSqLen - aSqParamLen) > Precision::Confusion())
return Standard_False;
gp_Dir2d aDir = aVec;
gp_Vec2d anOffset = -aDir;
anOffset *= theFirst;
gp_Pnt2d anOrigin = aFirstPnt.Translated(anOffset);
gp_Lin2d aLin (anOrigin, aDir);
const Standard_Integer NbSamples = 10;
Standard_Real aDelta = (theLast - theFirst)/NbSamples;
for (Standard_Integer i = 1; i < NbSamples; i++)
{
Standard_Real aParam = theFirst + i*aDelta;
gp_Pnt2d aPnt = thePCurve->Value(aParam);
Standard_Real aDist = aLin.Distance (aPnt);
if (aDist > Precision::Confusion())
return Standard_False;
}
theLine = new Geom2d_Line (aLin);
return Standard_True;
}
static void RemoveEdgeFromMap(const TopoDS_Edge& theEdge,
TopTools_IndexedDataMapOfShapeListOfShape& theVEmap)
{
@@ -1444,18 +1481,330 @@ static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain,
return ResEdge;
}
//=======================================================================
//function : UnionPCurves
//purpose :
//=======================================================================
void ShapeUpgrade_UnifySameDomain::UnionPCurves(const TopTools_SequenceOfShape& theChain,
TopoDS_Edge& theEdge)
{
TopTools_SequenceOfShape aFaceSeq;
const TopoDS_Edge& aFirstEdge = TopoDS::Edge(theChain.Value(1));
const TopTools_ListOfShape& aFaceList = myEFmap.FindFromKey (aFirstEdge);
TopTools_ListIteratorOfListOfShape anItl (aFaceList);
for (; anItl.More(); anItl.Next())
{
TopoDS_Face aFace = TopoDS::Face (anItl.Value());
if (myFacePlaneMap.IsBound(aFace))
continue;
if (myFaceNewFace.IsBound(aFace))
aFace = TopoDS::Face (myFaceNewFace(aFace));
BRepAdaptor_Surface aBAsurf (aFace, Standard_False);
if (aBAsurf.GetType() == GeomAbs_Plane)
continue;
TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace, aLoc);
Standard_Boolean isFound = Standard_False;
for (Standard_Integer ii = 1; ii <= aFaceSeq.Length(); ii++)
{
TopLoc_Location aPrevLoc;
Handle(Geom_Surface) aPrevSurf = BRep_Tool::Surface (TopoDS::Face(aFaceSeq(ii)), aPrevLoc);
if (aPrevSurf == aSurf && aPrevLoc == aLoc)
{
isFound = Standard_True;
break;
}
}
if (isFound)
continue;
Standard_Real aFirst, aLast;
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, aFirst, aLast);
aFaceSeq.Append (aFace);
}
TColGeom2d_SequenceOfCurve ResPCurves;
TColStd_SequenceOfReal ResFirsts;
TColStd_SequenceOfReal ResLasts;
TColStd_SequenceOfReal aTolVerSeq;
TopoDS_Edge aPrevEdge;
for (Standard_Integer j = 1; j <= aFaceSeq.Length(); j++)
{
TColGeom2d_SequenceOfCurve aPCurveSeq;
TColStd_SequenceOfReal aFirstsSeq;
TColStd_SequenceOfReal aLastsSeq;
TColStd_SequenceOfBoolean aForwardsSeq;
GeomAbs_CurveType aCurrentType = GeomAbs_OtherCurve;
Standard_Real aFirst, aLast;
for (Standard_Integer i = 1; i <= theChain.Length(); i++)
{
TopoDS_Edge anEdge = TopoDS::Edge(theChain.Value(i));
Standard_Boolean isForward = (anEdge.Orientation() != TopAbs_REVERSED);
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, TopoDS::Face(aFaceSeq(j)),
aFirst, aLast);
if (aPCurve.IsNull())
continue;
Geom2dAdaptor_Curve anAdaptor(aPCurve);
GeomAbs_CurveType aType = anAdaptor.GetType();
Handle(Geom2d_Line) aLine;
if (aType == GeomAbs_BSplineCurve ||
aType == GeomAbs_BezierCurve)
TryMakeLine (aPCurve, aFirst, aLast, aLine);
if (!aLine.IsNull())
{
aPCurve = aLine;
anAdaptor.Load (aPCurve);
aType = GeomAbs_Line;
}
if (aPCurveSeq.IsEmpty()) {
Handle(Geom2d_Curve) aCopyPCurve = Handle(Geom2d_Curve)::DownCast(aPCurve->Copy());
aPCurveSeq.Append(aCopyPCurve);
aFirstsSeq.Append(aFirst);
aLastsSeq.Append(aLast);
aForwardsSeq.Append(isForward);
aCurrentType = aType;
aPrevEdge = anEdge;
continue;
}
Standard_Boolean isSameCurve = Standard_False;
Standard_Real aNewF = aFirst;
Standard_Real aNewL = aLast;
if (aPCurve == aPCurveSeq.Last())
{
isSameCurve = Standard_True;
}
else if (aType == aCurrentType)
{
Geom2dAdaptor_Curve aPrevAdaptor(aPCurveSeq.Last());
switch (aType) {
case GeomAbs_Line: {
gp_Lin2d aPrevLin = aPrevAdaptor.Line();
gp_Pnt2d aFirstP2d = aPCurve->Value (aFirst);
gp_Pnt2d aLastP2d = aPCurve->Value (aLast);
if (aPrevLin.Contains (aFirstP2d, Precision::Confusion()) &&
aPrevLin.Contains (aLastP2d, Precision::Confusion()))
{
isSameCurve = Standard_True;
gp_Pnt2d p1 = anAdaptor.Value(aFirst);
gp_Pnt2d p2 = anAdaptor.Value(aLast);
aNewF = ElCLib::Parameter(aPrevLin, p1);
aNewL = ElCLib::Parameter(aPrevLin, p2);
if (aNewF > aNewL)
{
Standard_Real aTmp = aNewF;
aNewF = aNewL;
aNewL = aTmp;
}
}
break;
}
case GeomAbs_Circle: {
gp_Circ2d aCirc = anAdaptor.Circle();
gp_Circ2d aPrevCirc = aPrevAdaptor.Circle();
if (aCirc.Location().Distance(aPrevCirc.Location()) <= Precision::Confusion() &&
Abs(aCirc.Radius() - aPrevCirc.Radius()) <= Precision::Confusion())
{
isSameCurve = Standard_True;
gp_Pnt2d p1 = anAdaptor.Value(aFirst);
gp_Pnt2d p2 = anAdaptor.Value(aLast);
aNewF = ElCLib::Parameter(aPrevCirc, p1);
aNewL = ElCLib::Parameter(aPrevCirc, p2);
if (aNewF > aNewL)
{
Standard_Real aTmp = aNewF;
aNewF = aNewL;
aNewL = aTmp;
}
}
break;
}
default:
break;
}
}
if (isSameCurve) {
if (aForwardsSeq.Last() == Standard_True)
aLastsSeq.ChangeLast() = aNewL;
else
aFirstsSeq.ChangeLast() = aNewF;
}
else
{
Handle(Geom2d_Curve) aCopyPCurve = Handle(Geom2d_Curve)::DownCast(aPCurve->Copy());
aPCurveSeq.Append(aCopyPCurve);
aFirstsSeq.Append(aFirst);
aLastsSeq.Append(aLast);
aForwardsSeq.Append(isForward);
aCurrentType = aType;
TopoDS_Vertex aV;
TopExp::CommonVertex(aPrevEdge, anEdge, aV);
Standard_Real aTol = BRep_Tool::Tolerance(aV);
aTolVerSeq.Append (aTol);
}
aPrevEdge = anEdge;
}
Handle(Geom2d_Curve) aResPCurve;
Standard_Real aResFirst, aResLast;
if (aPCurveSeq.Length() == 1) {
aResPCurve = aPCurveSeq.Last();
aResFirst = aFirstsSeq.Last();
aResLast = aLastsSeq.Last();
if (aForwardsSeq.Last() == Standard_False)
{
Standard_Real aNewLast = aResPCurve->ReversedParameter (aResFirst);
Standard_Real aNewFirst = aResPCurve->ReversedParameter (aResLast);
aResPCurve->Reverse();
aResFirst = aNewFirst;
aResLast = aNewLast;
}
}
else {
//C1 concatenation for PCurveSeq
TColGeom2d_Array1OfBSplineCurve tab_c2d(0, aPCurveSeq.Length() - 1);
for (Standard_Integer i = 1; i <= aPCurveSeq.Length(); i++) {
Handle(Geom2d_TrimmedCurve) aTrPCurve = new Geom2d_TrimmedCurve(aPCurveSeq(i), aFirstsSeq(i), aLastsSeq(i));
if (aForwardsSeq(i) == Standard_False)
{
aTrPCurve->Reverse();
}
tab_c2d(i - 1) = Geom2dConvert::CurveToBSplineCurve(aTrPCurve);
Geom2dConvert::C0BSplineToC1BSplineCurve(tab_c2d(i - 1), Precision::Confusion());
}
TColStd_Array1OfReal tabtolvertex(0, aTolVerSeq.Length() - 1);
Standard_Real aMaxTol = 0.0;
for (Standard_Integer i = 1; i <= aTolVerSeq.Length(); i++)
{
Standard_Real aTol = aTolVerSeq(i);
tabtolvertex(i - 1) = aTol;
if (aTol > aMaxTol)
aMaxTol = aTol;
}
Handle(TColGeom2d_HArray1OfBSplineCurve) concatc2d; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfInd2d; //array of the remining Vertex
Standard_Boolean aClosedFlag = Standard_False;
Geom2dConvert::ConcatC1(tab_c2d,
tabtolvertex,
ArrayOfInd2d,
concatc2d,
aClosedFlag,
Precision::Confusion()); //C1 concatenation
if (concatc2d->Length() > 1)
{
Geom2dConvert_CompCurveToBSplineCurve Concat2d(concatc2d->Value(concatc2d->Lower()));
for (Standard_Integer i = concatc2d->Lower() + 1; i <= concatc2d->Upper(); i++)
Concat2d.Add(concatc2d->Value(i), aMaxTol, Standard_True);
concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve());
}
Handle(Geom2d_BSplineCurve) aBSplineCurve = concatc2d->Value(concatc2d->Lower());
aResPCurve = aBSplineCurve;
aResFirst = aBSplineCurve->FirstParameter();
aResLast = aBSplineCurve->LastParameter();
}
ResPCurves.Append(aResPCurve);
ResFirsts.Append(aResFirst);
ResLasts.Append(aResLast);
}
BRep_Builder aBuilder;
Standard_Real aTol = BRep_Tool::Tolerance(theEdge);
//Reparametrize pcurves if needed
for (Standard_Integer ii = 2; ii <= ResPCurves.Length(); ii++)
{
if (Abs (ResFirsts(1) - ResFirsts(ii)) > Precision::Confusion() ||
Abs (ResLasts(1) - ResLasts(ii)) > Precision::Confusion())
{
Handle(Geom2d_TrimmedCurve) aTrPCurve =
new Geom2d_TrimmedCurve (ResPCurves(ii), ResFirsts(ii), ResLasts(ii));
Handle(Geom2d_BSplineCurve) aBSplinePCurve = Geom2dConvert::CurveToBSplineCurve(aTrPCurve);
TColStd_Array1OfReal aKnots (1, aBSplinePCurve->NbKnots());
aBSplinePCurve->Knots (aKnots);
BSplCLib::Reparametrize (ResFirsts(1), ResLasts(1), aKnots);
aBSplinePCurve->SetKnots (aKnots);
ResPCurves(ii) = aBSplinePCurve;
}
}
//Reparametrize 3d curve if needed
if (!ResPCurves.IsEmpty())
{
Standard_Real aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve (theEdge, aFirst, aLast);
if (Abs (aFirst - ResFirsts(1)) > Precision::Confusion() ||
Abs (aLast - ResLasts(1)) > Precision::Confusion())
{
GeomAdaptor_Curve aGAcurve (aCurve);
GeomAbs_CurveType aType = aGAcurve.GetType();
if (aType == GeomAbs_Line)
{
gp_Lin aLin = aGAcurve.Line();
gp_Dir aDir = aLin.Direction();
gp_Pnt aPnt = aGAcurve.Value (aFirst);
gp_Vec anOffset = -aDir;
anOffset *= ResFirsts(1);
aPnt.Translate (anOffset);
Handle(Geom_Line) aLine = new Geom_Line (aPnt, aDir);
aBuilder.UpdateEdge (theEdge, aLine, aTol);
}
else if (aType == GeomAbs_Circle)
{
gp_Circ aCirc = aGAcurve.Circle();
Standard_Real aRadius = aCirc.Radius();
gp_Ax2 aPosition = aCirc.Position();
gp_Ax1 anAxis = aPosition.Axis();
Standard_Real anOffset = aFirst - ResFirsts(1);
aPosition.Rotate (anAxis, anOffset);
Handle(Geom_Circle) aCircle = new Geom_Circle (aPosition, aRadius);
aBuilder.UpdateEdge (theEdge, aCircle, aTol);
}
else //general case
{
Handle(Geom_TrimmedCurve) aTrCurve =
new Geom_TrimmedCurve (aCurve, aFirst, aLast);
Handle(Geom_BSplineCurve) aBSplineCurve = GeomConvert::CurveToBSplineCurve(aTrCurve);
TColStd_Array1OfReal aKnots (1, aBSplineCurve->NbKnots());
aBSplineCurve->Knots (aKnots);
BSplCLib::Reparametrize (ResFirsts(1), ResLasts(1), aKnots);
aBSplineCurve->SetKnots (aKnots);
aBuilder.UpdateEdge (theEdge, aBSplineCurve, aTol);
}
}
aBuilder.Range(theEdge, ResFirsts(1), ResLasts(1));
}
for (Standard_Integer j = 1; j <= ResPCurves.Length(); j++)
{
aBuilder.UpdateEdge(theEdge, ResPCurves(j), TopoDS::Face(aFaceSeq(j)), aTol);
}
}
//=======================================================================
//function : MergeSubSeq
//purpose : Merges a sequence of edges into one edge if possible
//=======================================================================
static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
Standard_Boolean ShapeUpgrade_UnifySameDomain::MergeSubSeq(const TopTools_SequenceOfShape& theChain,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
TopoDS_Edge& OutEdge,
double theAngTol,
Standard_Boolean ConcatBSplines,
Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext)
TopoDS_Edge& OutEdge)
{
ShapeAnalysis_Edge sae;
BRep_Builder B;
@@ -1521,12 +1870,12 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
if(c3d1.IsNull() || c3d2.IsNull())
return Standard_False;
while(c3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
if (c3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tc =
Handle(Geom_TrimmedCurve)::DownCast(c3d1);
c3d1 = tc->BasisCurve();
}
while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
if (c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tc =
Handle(Geom_TrimmedCurve)::DownCast(c3d2);
c3d2 = tc->BasisCurve();
@@ -1536,7 +1885,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2);
gp_Dir Dir1 = L1->Position().Direction();
gp_Dir Dir2 = L2->Position().Direction();
if(!Dir1.IsParallel(Dir2,theAngTol))
if (!Dir1.IsParallel (Dir2, myAngTol))
IsUnionOfLinesPossible = Standard_False;
}
else
@@ -1564,15 +1913,15 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
V[1] = sae.LastVertex(TopoDS::Edge(theChain.Last()));
gp_Pnt PV2 = BRep_Tool::Pnt(V[1]);
gp_Vec Vec(PV1, PV2);
if (isSafeInputMode) {
if (mySafeInputMode) {
for (int k = 0; k < 2; k++) {
if (!theContext->IsRecorded(V[k])) {
if (!myContext->IsRecorded(V[k])) {
TopoDS_Vertex Vcopy = TopoDS::Vertex(V[k].EmptyCopied());
theContext->Replace(V[k], Vcopy);
myContext->Replace(V[k], Vcopy);
V[k] = Vcopy;
}
else
V[k] = TopoDS::Vertex(theContext->Apply(V[k]));
V[k] = TopoDS::Vertex (myContext->Apply(V[k]));
}
}
Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec));
@@ -1583,6 +1932,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
B.Add (E,V[0]); B.Add (E,V[1]);
B.UpdateVertex(V[0], 0., E, 0.);
B.UpdateVertex(V[1], dist, E, 0.);
UnionPCurves(theChain, E);
OutEdge = E;
return Standard_True;
}
@@ -1593,7 +1943,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
TopoDS_Edge FE = TopoDS::Edge(theChain.First());
Handle(Geom_Curve) c3d = BRep_Tool::Curve(FE,f,l);
while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
if (c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tc =
Handle(Geom_TrimmedCurve)::DownCast(c3d);
c3d = tc->BasisCurve();
@@ -1638,55 +1988,53 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
B.Add(E,V[1]);
}
}
else {
if (isSafeInputMode) {
else //open chain
{
Standard_Real ParamFirst = BRep_Tool::Parameter(V[0], FE);
TopoDS_Vertex VertexLastOnFE = sae.LastVertex(FE);
Standard_Real ParamLast = BRep_Tool::Parameter(VertexLastOnFE, FE);
if (mySafeInputMode) {
for (int k = 0; k < 2; k++) {
if (!theContext->IsRecorded(V[k])) {
if (!myContext->IsRecorded(V[k])) {
TopoDS_Vertex Vcopy = TopoDS::Vertex(V[k].EmptyCopied());
theContext->Replace(V[k], Vcopy);
myContext->Replace(V[k], Vcopy);
V[k] = Vcopy;
}
else
V[k] = TopoDS::Vertex(theContext->Apply(V[k]));
V[k] = TopoDS::Vertex (myContext->Apply(V[k]));
}
}
gp_Pnt PV1 = BRep_Tool::Pnt(V[0]);
gp_Pnt PV2 = BRep_Tool::Pnt(V[1]);
TopoDS_Vertex VM = sae.LastVertex(FE);
gp_Pnt PVM = BRep_Tool::Pnt(VM);
GC_MakeCircle MC (PV1,PVM,PV2);
Handle(Geom_Circle) C = MC.Value();
gp_Pnt P0 = C->Location();
gp_Dir D1(gp_Vec(P0,PV1));
gp_Dir D2(gp_Vec(P0,PV2));
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
if(fabs(fpar)>Precision::Confusion()) {
// check orientation
gp_Dir ND = C->XAxis().Direction().Crossed(D1);
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
fpar = -fpar;
}
}
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
if(fabs(lpar)>Precision::Confusion()) {
// check orientation
gp_Dir ND = C->XAxis().Direction().Crossed(D2);
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
lpar = -lpar;
}
}
if (lpar < fpar) lpar += 2*M_PI;
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
gp_Pnt PointFirst = BRep_Tool::Pnt(V[0]);
while (Abs(ParamLast - ParamFirst) > 7*M_PI/8)
ParamLast = (ParamFirst + ParamLast)/2;
BRepAdaptor_Curve BAcurveFE(FE);
gp_Pnt PointLast = BAcurveFE.Value(ParamLast);
gp_Pnt Origin = Cir->Circ().Location();
gp_Dir Dir1 = gp_Vec(Origin, PointFirst);
gp_Dir Dir2 = gp_Vec(Origin, PointLast);
gp_Dir Vdir = Dir1 ^ Dir2;
gp_Ax2 anAx2(Origin, Vdir, Dir1);
Handle(Geom_Circle) aNewCircle = new Geom_Circle(anAx2, Cir->Radius());
gp_Pnt PointLastInChain = BRep_Tool::Pnt(V[1]);
gp_Dir DirLastInChain = gp_Vec(Origin, PointLastInChain);
Standard_Real lpar = Dir1.AngleWithRef(DirLastInChain, Vdir);
if (lpar < 0.)
lpar += 2*M_PI;
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(aNewCircle,0.,lpar);
B.MakeEdge (E,tc,Precision::Confusion());
B.Add(E,V[0]);
B.Add(E,V[1]);
B.UpdateVertex(V[0], fpar, E, 0.);
B.UpdateVertex(V[0], 0., E, 0.);
B.UpdateVertex(V[1], lpar, E, 0.);
}
UnionPCurves(theChain, E);
OutEdge = E;
return Standard_True;
}
if (theChain.Length() > 1 && ConcatBSplines) {
if (theChain.Length() > 1 && myConcatBSplines) {
// second step: union edges with various curves
// skl for bug 0020052 from Mantis: perform such unions
// only if curves are bspline or bezier
@@ -1699,7 +2047,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
TopLoc_Location Loc;
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1);
if(c3d.IsNull()) continue;
while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
if (c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tc =
Handle(Geom_TrimmedCurve)::DownCast(c3d);
c3d = tc->BasisCurve();
@@ -1912,13 +2260,8 @@ static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq,
//function : MergeEdges
//purpose : auxilary
//=======================================================================
static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
Standard_Boolean ShapeUpgrade_UnifySameDomain::MergeEdges(TopTools_SequenceOfShape& SeqEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
const Standard_Real theAngTol,
const Standard_Real theLinTol,
const Standard_Boolean ConcatBSplines,
const Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext,
NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges,
const TopTools_MapOfShape& NonMergVrt)
{
@@ -2001,7 +2344,7 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
// split chain by vertices at which merging is not possible
NCollection_Sequence<SubSequenceOfEdges> aOneSeq;
GenerateSubSeq(aChain, aOneSeq, IsClosed, theAngTol, theLinTol, VerticesToAvoid, theVFmap);
GenerateSubSeq(aChain, aOneSeq, IsClosed, myAngTol, myLinTol, VerticesToAvoid, theVFmap);
// put sub-chains in the result
SeqOfSubSeqOfEdges.Append(aOneSeq);
@@ -2012,9 +2355,7 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
TopoDS_Edge UE;
if (SeqOfSubSeqOfEdges(i).SeqsEdges.Length() < 2)
continue;
if (MergeSubSeq(SeqOfSubSeqOfEdges(i).SeqsEdges, theVFmap,
UE, theAngTol,
ConcatBSplines, isSafeInputMode, theContext))
if (MergeSubSeq(SeqOfSubSeqOfEdges(i).SeqsEdges, theVFmap, UE))
SeqOfSubSeqOfEdges(i).UnionEdges = UE;
}
return Standard_True;
@@ -2025,25 +2366,19 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
//purpose : Tries to unify the sequence of edges with the set of
// another edges which lies on the same geometry
//=======================================================================
static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges,
Standard_Boolean ShapeUpgrade_UnifySameDomain::MergeSeq (TopTools_SequenceOfShape& SeqEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
const Standard_Real theAngTol,
const Standard_Real theLinTol,
const Standard_Boolean ConcatBSplines,
const Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext,
const TopTools_MapOfShape& nonMergVert)
{
NCollection_Sequence<SubSequenceOfEdges> SeqOfSubsSeqOfEdges;
if (MergeEdges(SeqEdges, theVFmap, theAngTol, theLinTol, ConcatBSplines, isSafeInputMode,
theContext, SeqOfSubsSeqOfEdges, nonMergVert))
if (MergeEdges(SeqEdges, theVFmap, SeqOfSubsSeqOfEdges, nonMergVert))
{
for (Standard_Integer i = 1; i <= SeqOfSubsSeqOfEdges.Length(); i++ )
{
if (SeqOfSubsSeqOfEdges(i).UnionEdges.IsNull())
continue;
theContext->Merge(SeqOfSubsSeqOfEdges(i).SeqsEdges,
myContext->Merge(SeqOfSubsSeqOfEdges(i).SeqsEdges,
SeqOfSubsSeqOfEdges(i).UnionEdges);
}
return Standard_True;
@@ -2143,6 +2478,8 @@ void ShapeUpgrade_UnifySameDomain::Initialize(const TopoDS_Shape& aShape,
myContext->Clear();
myKeepShapes.Clear();
myFacePlaneMap.Clear();
myEFmap.Clear();
myFaceNewFace.Clear();
myHistory->Clear();
}
@@ -2680,6 +3017,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
BB.MakeWire(aNewWire);
BB.Add(aNewWire, StartEdge);
RemoveEdgeFromMap(StartEdge, VEmap);
TopTools_IndexedMapOfShape SplittingVertices;
Standard_Real fpar, lpar;
Handle(Geom2d_Curve) StartPCurve = BRep_Tool::CurveOnSurface(StartEdge, F_RefFace, fpar, lpar);
@@ -2761,6 +3099,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
else
{
//we must choose the closest direction - the biggest angle
SplittingVertices.Add (CurVertex);
Standard_Real MaxAngle = RealFirst();
TopoDS_Edge TrueEdge;
Handle(Geom2d_Curve) CurPCurve = BRep_Tool::CurveOnSurface(CurEdge, F_RefFace, fpar, lpar);
@@ -2910,6 +3249,10 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
}
else //may be this wire is a hole
{
//split this wire if needed
if (!SplittingVertices.IsEmpty())
SplitWire (aNewWire, F_RefFace, SplittingVertices, NewWires);
else
NewWires.Append(aNewWire);
}
} //while (!edges.IsEmpty())
@@ -2974,6 +3317,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
BB.Add(aResult, InternalWires(ii));
aResult.Orientation(RefFaceOrientation);
myContext->Merge(faces, aResult);
//Update the map Face-NewFace
for (Standard_Integer jj = 1; jj <= faces.Length(); jj++)
myFaceNewFace.Bind (faces(jj), aResult);
}
else if (NewFaces.Length() == 1)
{
@@ -2983,6 +3329,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
for (Standard_Integer ii = 1; ii <= InternalWires.Length(); ii++)
BB.Add(aNewFace, InternalWires(ii));
myContext->Merge(faces, NewFaces(1));
//Update the map Face-NewFace
for (Standard_Integer jj = 1; jj <= faces.Length(); jj++)
myFaceNewFace.Bind (faces(jj), NewFaces(1));
}
else
{
@@ -3016,6 +3365,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
facesForThisFace.Append(faces(jj));
}
myContext->Merge(facesForThisFace, NewFaces(ii));
//Update the map Face-NewFace
for (Standard_Integer jj = 1; jj <= facesForThisFace.Length(); jj++)
myFaceNewFace.Bind (facesForThisFace(jj), NewFaces(ii));
}
}
} //if (faces.Length() > 1)
@@ -3052,8 +3404,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
TopTools_MapOfShape aSharedVert;
CheckSharedVertices(aSeqEdges, aMapEdgesVertex, myKeepShapes, aSharedVert);
// Merge the edges avoiding removal of the shared vertices
Standard_Boolean isMerged = MergeSeq(aSeqEdges, aVFmap, myAngTol, myLinTol, myConcatBSplines,
mySafeInputMode, myContext, aSharedVert);
Standard_Boolean isMerged = MergeSeq(aSeqEdges, aVFmap, aSharedVert);
// Collect faces to rebuild
TopTools_IndexedMapOfShape aChangedFaces;
if (isMerged)
@@ -3140,6 +3491,8 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
//=======================================================================
void ShapeUpgrade_UnifySameDomain::Build()
{
TopExp::MapShapesAndAncestors(myInitShape, TopAbs_EDGE, TopAbs_FACE, myEFmap);
if (myUnifyFaces)
UnifyFaces();
if (myUnifyEdges)
@@ -3233,3 +3586,112 @@ void ShapeUpgrade_UnifySameDomain::FillHistory()
// Merge the history of the operation into global history
myHistory->Merge(aUSDHistory);
}
void SplitWire (const TopoDS_Wire& theWire,
const TopoDS_Face& theFace,
const TopTools_IndexedMapOfShape& theVmap,
TopTools_SequenceOfShape& theWireSeq)
{
TopTools_DataMapOfShapeListOfShape aVEmap;
TopTools_MapOfShape aEmap;
TopoDS_Iterator itw (theWire);
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (itw.Value());
if (!aEmap.Add (anEdge))
continue;
if (anEdge.Orientation() != TopAbs_FORWARD &&
anEdge.Orientation() != TopAbs_REVERSED)
continue;
const TopoDS_Vertex& aVertex = TopExp::FirstVertex (anEdge, Standard_True); //with orientation
if (aVEmap.IsBound (aVertex))
aVEmap(aVertex).Append (anEdge);
else
{
TopTools_ListOfShape aElist;
aElist.Append (anEdge);
aVEmap.Bind (aVertex, aElist);
}
}
BRep_Builder aBB;
for (Standard_Integer ii = 1; ii <= theVmap.Extent(); ii++)
{
const TopoDS_Vertex& anOrigin = TopoDS::Vertex (theVmap(ii));
TopTools_ListOfShape& aBranches = aVEmap (anOrigin);
TopTools_ListIteratorOfListOfShape anItl (aBranches);
while (anItl.More())
{
TopoDS_Edge CurEdge = TopoDS::Edge (anItl.Value());
aBranches.Remove (anItl);
TopoDS_Wire aNewWire;
aBB.MakeWire (aNewWire);
for (;;)
{
aBB.Add (aNewWire, CurEdge);
const TopoDS_Vertex& aVertex = TopExp::LastVertex (CurEdge, Standard_True); //with orientation
if (aVertex.IsSame(anOrigin))
break;
if (!aVEmap.IsBound (aVertex))
break;
TopTools_ListOfShape& aElist = aVEmap (aVertex);
if (aElist.Extent() == 0)
break;
if (aElist.Extent() == 1)
{
CurEdge = TopoDS::Edge (aElist.First());
aElist.Clear();
}
else
{
Standard_Real fpar, lpar;
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(CurEdge, theFace, fpar, lpar);
Standard_Real aParam = (CurEdge.Orientation() == TopAbs_FORWARD)? lpar : fpar;
gp_Pnt2d aPoint;
gp_Vec2d CurDir;
aPCurve->D1(aParam, aPoint, CurDir);
CurDir.Normalize();
if (CurEdge.Orientation() == TopAbs_REVERSED)
CurDir.Reverse();
//choose the rightest direction - the smallest angle
Standard_Real MinAngle = RealLast();
TopoDS_Edge NextEdge;
TopTools_ListIteratorOfListOfShape aLocalIter (aElist);
for (; aLocalIter.More(); aLocalIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(aLocalIter.Value());
aPCurve = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
aParam = (anEdge.Orientation() == TopAbs_FORWARD)? fpar : lpar;
gp_Vec2d aDir;
aPCurve->D1(aParam, aPoint, aDir);
aDir.Normalize();
if (anEdge.Orientation() == TopAbs_REVERSED)
aDir.Reverse();
Standard_Real anAngle = CurDir.Angle(aDir);
if (anAngle < MinAngle)
{
MinAngle = anAngle;
NextEdge = anEdge;
}
}
CurEdge = NextEdge;
//Remove <CurEdge> from list
for (aLocalIter.Initialize(aElist); aLocalIter.More(); aLocalIter.Next())
if (CurEdge.IsSame (aLocalIter.Value()))
{
aElist.Remove (aLocalIter);
break;
}
} //else (more than one edge)
} //for (;;)
theWireSeq.Append (aNewWire);
} //while (anItl.More())
}
}

View File

@@ -27,6 +27,7 @@
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <Geom_Plane.hxx>
#include <Precision.hxx>
class ShapeBuild_ReShape;
@@ -64,6 +65,13 @@ DEFINE_STANDARD_HANDLE(ShapeUpgrade_UnifySameDomain, Standard_Transient)
//! The algorithm provides a place holder for the history and collects the
//! history by default.
//! To avoid collecting of the history the place holder should be set to null handle.
struct SubSequenceOfEdges
{
TopTools_SequenceOfShape SeqsEdges;
TopoDS_Edge UnionEdges;
};
class ShapeUpgrade_UnifySameDomain : public Standard_Transient
{
@@ -166,6 +174,27 @@ protected:
void IntUnifyFaces(const TopoDS_Shape& theInpShape,
TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces);
//! Splits the sequence of edges into the sequence of chains
Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges,
const TopTools_MapOfShape& NonMergVrt);
//! Tries to unify the sequence of edges with the set of
//! another edges which lies on the same geometry
Standard_Boolean MergeSeq(TopTools_SequenceOfShape& SeqEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
const TopTools_MapOfShape& nonMergVert);
//! Merges a sequence of edges into one edge if possible
Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& theChain,
const TopTools_IndexedDataMapOfShapeListOfShape& theVFmap,
TopoDS_Edge& OutEdge);
//! Unifies the pcurve of the chain into one pcurve of the edge
void UnionPCurves(const TopTools_SequenceOfShape& theChain,
TopoDS_Edge& theEdge);
//! Fills the history of the modifications during the operation.
Standard_EXPORT void FillHistory();
@@ -183,6 +212,8 @@ private:
Handle(ShapeBuild_ReShape) myContext;
TopTools_MapOfShape myKeepShapes;
DataMapOfFacePlane myFacePlaneMap;
TopTools_IndexedDataMapOfShapeListOfShape myEFmap;
TopTools_DataMapOfShapeShape myFaceNewFace;
Handle(BRepTools_History) myHistory; //!< The history.
};

View File

@@ -35,19 +35,19 @@
// Primary definitions
#define OCC_VERSION_MAJOR 7
#define OCC_VERSION_MINOR 5
#define OCC_VERSION_MAINTENANCE 0
#define OCC_VERSION_MAINTENANCE 3
//! This macro must be commented in official release, and set to non-empty
//! string in other situations, to identify specifics of the version, e.g.:
//! - "dev" for development version between releases
//! - "beta..." or "rc..." for beta releases or release candidates
//! - "project..." for version containing project-specific fixes
//#define OCC_VERSION_DEVELOPMENT "beta"
//#define OCC_VERSION_DEVELOPMENT "dev"
// Derived (manually): version as real and string (major.minor)
#define OCC_VERSION 7.5
#define OCC_VERSION_STRING "7.5"
#define OCC_VERSION_COMPLETE "7.5.0"
#define OCC_VERSION_COMPLETE "7.5.3"
//! Derived: extended version as string ("major.minor.maintenance.dev")
#ifdef OCC_VERSION_DEVELOPMENT

View File

@@ -186,9 +186,11 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& aEdge,
Handle(StepGeom_Curve) Gpms;
Handle(Geom_Curve) C = CA.Curve().Curve();
if (!C.IsNull()) {
C = Handle(Geom_Curve)::DownCast(C->Copy());
gp_Trsf Tr1 = CA.Trsf();
C->Transform(Tr1);
// Special treatment is needed for very short edges based on periodic curves.
// Since edge in STEP does not store its parametric range, parameters are computed
// on import by projecting vertices on a curve, and for periodic curve this may
@@ -246,8 +248,7 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& aEdge,
}
}
gp_Trsf Tr1 = CA.Trsf();
C->Transform(Tr1);
GeomToStep_MakeCurve MkCurve(C);
Gpms = MkCurve.Value();
}

View File

@@ -32,7 +32,7 @@ CheckIsFeatureRemoved feature3 {v e f}
removefeatures res5 s feature4
checkshape res5
checkprops res5 -s 2387.67 -v 1060.67 -deps 1.e-7
checkprops res5 -s 2387.67 -v 1060.68 -deps 1.e-7
checknbshapes res5 -vertex 67 -edge 100 -wire 35 -face 35 -shell 1 -solid 1 -t
CheckIsFeatureRemoved feature4 {v e f}

View File

@@ -10,6 +10,6 @@ compound s_2 s_25 s_1 s_4 feature
removefeatures result s feature
checkshape result
checkprops result -s 2392.41 -v 1063.75 -deps 1.e-7
checkprops result -s 2392.42 -v 1063.76 -deps 1.e-7
checknbshapes result -vertex 61 -edge 91 -wire 34 -face 33 -shell 1 -solid 1
CheckIsFeatureRemoved feature {e f}

12
tests/bugs/heal/bug31524 Normal file
View File

@@ -0,0 +1,12 @@
puts "TODO OCC31524 ALL: Faulty shapes in variables faulty_1"
puts "==============================================================================================="
puts "0031524: Modeling Algorithms - Unify same domain corrupts shape representing a cylindrical tube"
puts "==============================================================================================="
puts ""
restore [locate_data_file bug31524.brep] shape
unifysamedom res shape
checkshape shape

28
tests/bugs/heal/bug31778 Normal file
View File

@@ -0,0 +1,28 @@
puts "============================================="
puts "OCC31778: UnifySameDomain fails in Debug mode"
puts "============================================="
puts ""
brestore [locate_data_file bug31778.brep] s
explode s
bclearobjects
bcleartools
baddobjects s_1
baddtools s_2 s_3
bfillds
bbop q 1
explode q
unifysamedom result q_1
checkshape result
checknbshapes result -solid 1 -shell 1 -face 19 -wire 21 -edge 51 -vertex 34
set tolres [checkmaxtol result]
if { ${tolres} > 5.e-5} {
puts "Error: bad tolerance of result"
}
checkprops result -v 15173.9

18
tests/bugs/heal/bug32140 Normal file
View File

@@ -0,0 +1,18 @@
puts "=============================================================="
puts "OCC32140: unify same domain calls crossed for opposite vectors"
puts "=============================================================="
puts ""
restore [locate_data_file bug32140.brep] a
unifysamedom result a
checkshape result
checknbshapes result -solid 1 -shell 1 -face 26 -wire 32 -edge 69 -vertex 41
set tolres [checkmaxtol result]
if { ${tolres} > 6.e-6} {
puts "Error: bad tolerance of result"
}

20
tests/bugs/heal/bug32213 Normal file
View File

@@ -0,0 +1,20 @@
puts "==========================================="
puts "OCC32213: Invalid result of UnifySameDomain"
puts "==========================================="
puts ""
restore [locate_data_file bug32213.brep] a
unifysamedom result a
checkshape result
checknbshapes result -solid 1 -shell 1 -face 21 -wire 22 -edge 58 -vertex 38
set tolres [checkmaxtol result]
if { ${tolres} > 6.e-6} {
puts "Error: bad tolerance of result"
}
checkprops result -s 81.9221

View File

@@ -1,4 +1,8 @@
puts "TODO OCC25925 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC25925 ALL: ERROR. offsetperform operation not done."
puts "TODO OCC25925 ALL: Error: The command cannot be built"
puts "TODO OCC25925 ALL: Faulty OCC5805 : result is not Closed shape"
puts "TODO OCC25925 ALL: TEST INCOMPLETE"
puts "TODO OCC25925 ALL: Tcl Exception: Error : command \\\"nbshapes result\\\" gives an empty result"
puts "============"
puts "OCC5805"
@@ -32,7 +36,7 @@ if [catch { thrusections s ${issolid} ${isruled} UpCover BottomCover } catch_res
set distance -0.001
catch { OFFSETSHAPE $distance {s_2} $calcul $type }
# Bad result
# Null result
checkprops result -s 358.795
@@ -48,6 +52,6 @@ if {$index == -1} {
}
checkshape result
checknbshapes result -t -wire 5 -face 5 -shell 2 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,6 +1,6 @@
puts "TODO OCC23068 ALL: Error : is WRONG because number of"
puts "TODO OCC23068 ALL: Error : The area of result shape is"
puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC25925 ALL: Error: The command cannot be built"
puts "TODO OCC25925 ALL: TEST INCOMPLETE"
puts "TODO OCC25925 ALL: Tcl Exception: Error : command \\\"nbshapes result\\\" gives an empty result"
puts "============"
puts "OCC5805"
@@ -36,9 +36,7 @@ set distance -0.001
catch { OFFSETSHAPE $distance {} $calcul $type }
# Null result
checkprops result -s 495.635
checkshape result
checknbshapes result -vertex 2 -edge 3 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 13
@@ -54,5 +52,4 @@ if {$index == -1} {
}
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,4 +1,6 @@
puts "TODO OCC25925 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC25925 ALL: Faulty OCC5805 : result is not Closed shape"
puts "TODO OCC25925 ALL: ERROR. offsetperform operation not done."
puts "TODO OCC25925 ALL: Error: The command cannot be built"
puts "============"
puts "OCC5805"
@@ -32,11 +34,10 @@ if [catch { thrusections s ${issolid} ${isruled} UpCover BottomCover } catch_res
set distance -0.001
catch { OFFSETSHAPE $distance {s_2} $calcul $type }
# Bad result
# Null result
checkprops result -s 495.635
checkshape result
set index [lsearch [whatis s] Closed]
if {$index == -1} {
@@ -50,5 +51,4 @@ if {$index == -1} {
}
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -19,16 +19,18 @@ checkprops result -s 8206.54
set nbshapes_expected "
Number of shapes in shape
VERTEX : 5
EDGE : 9
EDGE : 8
WIRE : 4
FACE : 4
SHELL : 1
SOLID : 1
COMPSOLID : 0
COMPOUND : 1
SHAPE : 25
SHAPE : 24
"
checknbshapes result -ref ${nbshapes_expected} -t -m "Boolean operations common"
set tolres [checkmaxtol result]
checkview -display result -3d -path ${imagedir}/${test_image}-3d.png
checkview -display result -2d -path ${imagedir}/${test_image}-2d.png

View File

@@ -19,16 +19,18 @@ checkprops result -s 34566
set nbshapes_expected "
Number of shapes in shape
VERTEX : 13
EDGE : 21
EDGE : 20
WIRE : 8
FACE : 8
SHELL : 1
SOLID : 1
COMPSOLID : 0
COMPOUND : 1
SHAPE : 53
SHAPE : 52
"
checknbshapes result -ref ${nbshapes_expected} -t -m "Boolean operations cut"
set tolres [checkmaxtol result]
checkview -display result -3d -path ${imagedir}/${test_image}-3d.png
checkview -display result -2d -path ${imagedir}/${test_image}-2d.png

View File

@@ -0,0 +1,43 @@
puts "======================================================================"
puts "OCC31735: BRepOffset_MakeOffset works slowly and produces wrong result"
puts "======================================================================"
puts ""
setfillhistory 1
restore [locate_data_file bug31735_1.brep] a
offsetparameter 1e-7 c i
offsetload a 0.02
offsetperform result
checkshape result
checknbshapes result -t -wire 28 -face 28 -shell 1 -solid 1
set tolres [checkmaxtol result]
if { ${tolres} > 0.001001} {
puts "Error: bad tolerance of result"
}
savehistory hh
explode a f
generated gf hh a_2
checkprops gf -s 0.582567
explode a_2 e
generated ge hh a_2_3
checkprops ge -l 0.440027
explode a_2_3
generated gv hh a_2_3_1
axo
donly a_2 a_2_3 a_2_3_1 result gf ge gv
fit
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
puts "TEST COMPLETED"

View File

@@ -0,0 +1,41 @@
puts "======================================================================"
puts "OCC31735: BRepOffset_MakeOffset works slowly and produces wrong result"
puts "======================================================================"
puts ""
setfillhistory 1
restore [locate_data_file bug31735_1.brep] a
explode a f
offsetparameter 1e-7 c i
offsetload a -0.02 a_1 a_2 a_3 a_4 a_10 a_11 a_12 a_15
offsetperform result
checknbshapes result -t -wire 49 -face 49 -shell 1 -solid 1
set tolres [checkmaxtol result]
if { ${tolres} > 0.001001} {
puts "Error: bad tolerance of result"
}
savehistory hh
generated gf6 hh a_6
checkprops gf6 -s 0.255127
modified mf2 hh a_2
checkprops mf2 -s 0.0270215
if {[regexp "Not deleted" [isdeleted hh a_1]]} {
puts "Error: History information is wrong"
}
axo
donly result gf6 mf2
fit
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
puts "TEST COMPLETED"

View File

@@ -0,0 +1,15 @@
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_1.brep] a
offsetparameter 1e-7 c i
offsetload a 0.2
offsetperform result
checkshape result
checkprops result -s 271.847
checknbshapes result -t -edge 12 -wire 6 -face 6 -shell 1 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,15 @@
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_1.brep] a
offsetparameter 1e-7 c i
offsetload a -0.2
offsetperform result
checkshape result
checkprops result -s 210.825
checknbshapes result -t -edge 12 -wire 6 -face 6 -shell 1 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,16 @@
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_1.brep] a
explode a f
offsetparameter 1e-7 p i
offsetload a 0.2 a_5 a_6
offsetperform result
checkshape result
checkprops result -s 423.33
checknbshapes result -t -edge 24 -wire 12 -face 10 -shell 1 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_1.brep] a
explode a f
offsetparameter 1e-7 p i
offsetload a -0.2 a_5 a_6
offsetperform result
checkshape result
checkprops result -s 388.879
checknbshapes result -t -edge 24 -wire 12 -face 10 -shell 1 -solid 1
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,14 @@
puts "TODO OCC31845 All: ERROR. offsetperform operation not done."
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_f.brep] a
explode a f
offsetparameter 1e-7 p i
offsetload a 0.001 a_4 a_5
offsetperform result

View File

@@ -0,0 +1,16 @@
puts "TODO OCC31845 All: ERROR: null result"
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_h.brep] a
offsetparameter 1e-7 p i
offsetload a -0.01
offsetperform result
if {[llength [whatis result]] < 4} {
puts "ERROR: null result"
}

View File

@@ -0,0 +1,13 @@
puts "TODO OCC31845 All: ERROR. offsetperform operation not done."
puts "============================================"
puts "OCC31845: BRepOffsetAPI_MakeThickSolid fails"
puts "============================================"
puts ""
restore [locate_data_file bug31845_h.brep] a
explode a f
offsetparameter 1e-7 p i
offsetload a 0.001 a_3 a_4
offsetperform result

View File

@@ -0,0 +1,46 @@
puts "======================================================="
puts "0031912: Modeling Algorithms - Boolean Cut can't build resulting shape"
puts "======================================================="
puts ""
pload DATAEXCHANGE
stepread [locate_data_file bug31912_s.stp] s *
stepread [locate_data_file bug31912_b.stp] b *
bclearobjects
bcleartools
baddobjects s_1
baddtools b_1
bfillds
bbop r0 0
bbop r1 1
bbop r2 2
bbop r3 3
bbop r4 4
bbuild rgf
foreach r {r0 r1 r2 r3 r4 rgf} {
checkshape $r
}
checknbshapes r0 -wire 6 -face 6 -shell 1 -solid 1 -t
checkprops r0 -s 279207 -v 5.32814e+06
checknbshapes r1 -wire 12 -face 12 -shell 1 -solid 1 -t
checkprops r1 -s 4.93771e+06 -v 1.56185e+08
checknbshapes r2 -wire 8 -face 8 -shell 1 -solid 1 -t
checkprops r2 -s 4.37427e+06 -v 1.34873e+08
checknbshapes r3 -wire 6 -face 6 -shell 1 -solid 1 -t
checkprops r3 -s 571214 -v 1.59844e+07
checkprops r4 -l 3810.09
checksection r4 -r 4
checknbshapes rgf -wire 16 -face 16 -shell 3 -solid 3 -t
checkprops rgf -s 5.22469e+06 -v 1.56185e+08
checkview -display rgf -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,12 @@
puts "=============================================="
puts " 0031984: Sweep crashes if Bi-normal is given"
puts "=============================================="
puts ""
restore [locate_data_file bug31984.brep] a
explode a
mksweep a_1
addsweep a_2
setsweep -CN 0 0 1
buildsweep result

View File

@@ -0,0 +1,54 @@
puts "============================================================================================="
puts "0032136: Modeling Algorithms - Boolean fuse fails and corrupts the argument-shape"
puts "============================================================================================="
puts ""
restore [locate_data_file bug32136_obj.brep] s
restore [locate_data_file bug32136_tools.brep] t
bclearobjects
bcleartools
baddobjects s
eval baddtools [explode t]
bfillds
bbop result 1
checkshape result
checknbshapes result -face 731 -shell 1 -solid 1 -t
checkprops result -s 0.051066 -v 8.9084e-06
foreach sh {result s} {
if {![regexp "This shape seems to be OK" [bopcheck $sh]]} {
puts "Error: the $sh shape is self-interfered"
}
checkmaxtol $sh -ref 5.e-6
}
foreach sh [explode t] {
if {![regexp "This shape seems to be OK" [bopcheck $sh]]} {
puts "Error: the $sh shape is self-interfered"
}
checkmaxtol $sh -ref 5.e-6
}
checkview -display result -2d -path ${imagedir}/${test_image}_fuse.png
# subsequent cut operation
box box 0.06335 0.06335 0.05
bclearobjects
bcleartools
baddobjects box
baddtools result
bfillds
bbop result_cut 2
checkshape result_cut
checknbshapes result_cut -face 756 -shell 1 -solid 1 -t
checkprops result_cut -s 0.0545148 -v 0.000191753
if {![regexp "This shape seems to be OK" [bopcheck result_cut]]} {
puts "Error: the result_cut shape is self-interfered"
}
checkmaxtol result_cut -ref 5.e-6
checkview -display result_cut -2d -path ${imagedir}/${test_image}_cut.png

View File

@@ -0,0 +1,15 @@
puts "============================="
puts " 0032189: BOP Cut regression"
puts "============================="
puts ""
restore [locate_data_file bug32189_a.brep] a
restore [locate_data_file bug32189_b.brep] b
bcut result a b
checkshape result
checknbshapes result -vertex 5 -edge 6 -wire 3 -face 3 -shell 1 -solid 1
checkprops result -s 0.000687454 -v 8.86946e-07
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,29 @@
puts "======================================================="
puts " 0032291: General Fuse produces wrong number of solids"
puts "======================================================="
puts ""
restore [locate_data_file bug32291.brep] s
explode s
baddobjects s_1
baddtools s_2 s_3 s_4 s_5 s_6 s_7 s_8
bfillds
bbuild result
checkshape result
checknbshapes result -vertex 79 -edge 176 -wire 112 -face 112 -shell 18 -solid 18
set tolres [checkmaxtol result]
if { ${tolres} > 7.e-5} {
puts "Error: bad tolerance of result"
}
axo
clear
explode result So
fit
checkview -screenshot -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,15 @@
puts "========="
puts "0032058: Modeling Data - Extrema curve-surface gives wrong result for planar surface of revolunion and circle"
puts "========="
puts ""
restore [locate_data_file bug32058_c] c
restore [locate_data_file bug32058_s] s
extrema c s
checklength ext_1 -l 2.3437142008433856e-13
smallview
fit
checkview -screenshot -2d -path ${imagedir}/${test_image}.png

8
tests/bugs/step/bug32264 Normal file
View File

@@ -0,0 +1,8 @@
restore [locate_data_file bug32264.brep] s
set aTmpFile "$imagedir/${casename}.brep"
testwritestep "$aTmpFile" s
testreadstep "$aTmpFile" s1
file delete "$aTmpFile"
checkshape s1 f
checkmaxtol s1 -ref 1.e-7
checkprops s1 -v 16.1759 -deps 0.01

View File

@@ -18,7 +18,7 @@ if {[regexp "Faulties" [bopargcheck result]]} {
puts "Error: bopargcheck has found some faulties in res2"
}
checkmaxtol result -ref 0.031968491076118669
checkmaxtol result -ref 5.e-6
smallview
don result sw tw

View File

@@ -0,0 +1,28 @@
puts "========"
puts "OCC32225: Modeling Data - Wrong result of extrema curve-surface"
puts "========"
puts ""
restore [locate_data_file bug32225_curve.draw] c
restore [locate_data_file bug32225_surf.draw] s
extrema c s
if {[isdraw ext_1]} {
set ext_dist [lindex [length ext_1] end]
checkreal "Ext_1 min distance" $ext_dist 0. 1.e-10 1.e-10
} else {
puts "Error: invalid result"
}
if {[isdraw ext_2]} {
set ext_dist [lindex [length ext_2] end]
checkreal "Ext_2 min distance" $ext_dist 0. 1.e-10 1.e-10
} else {
puts "Error: invalid result"
}
smallview
donly c ext_1 ext_2
fit
disp s
checkview -screenshot -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,3 +1,5 @@
puts "TODO OCC26030 ALL: Error : The offset cannot be built"
puts "========"
puts "OCC26288"
puts "========"

View File

View File

@@ -1,7 +1,6 @@
puts "TODO OCC24156 MacOS: An exception was caught"
puts "TODO OCC24156 MacOS: TEST INCOMPLETE"
puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_"
puts "TODO OCC23068 ALL: Error : The area of face result_3 of the resulting shape is negative."
puts "TODO OCC23068 ALL: Error: bsection of the result and s is not equal to zero."
ellipse w1 0 0 0 15 10
mkedge w1 w1 0 pi/2

View File

@@ -1,5 +1,4 @@
puts "TODO CR27414 ALL: Error : is WRONG because number of FACE entities in shape"
puts "TODO OCC27414 ALL: the resulting shape is negative"
restore [locate_data_file bug26917_dom-8092.new_with_faces.brep] c

View File

@@ -1,5 +1,4 @@
puts "TODO CR27414 ALL: Error : is WRONG because number of FACE entities in shape"
puts "TODO OCC27414 ALL: the resulting shape is negative"
restore [locate_data_file bug26917_dom-8092.new_trim2_with_faces.brep] c

View File

@@ -1,5 +1,4 @@
puts "TODO CR27414 ALL: Error : is WRONG because number of FACE entities in shape"
puts "TODO OCC27414 ALL: the resulting shape is negative"
restore [locate_data_file bug26917_dom-8092.new_trim4_with_faces.brep] c

View File

@@ -1,6 +1,6 @@
puts "TODO OCC27414 ALL: Error : The area of result shape is"
puts "TODO OCC27414 ALL: Error : The volume of result shape is"
puts "TODO OCC27414 ALL: Error : is WRONG because number of"
puts "TODO OCC27414 ALL: Error: The command cannot be built"
puts "TODO OCC27414 ALL: gives an empty result"
puts "TODO OCC27414 ALL: TEST INCOMPLETE"
puts "========"
puts "0031307: Modeling Algorithms - Offset algorithm produces incorrect result in mode Complete join type Intersection"
@@ -15,9 +15,8 @@ offsetonface s_9 7
offsetperform result
checkprops result -s 222993 -v 1.87721e+06
checknbshapes result -shell 1 -solid 1
unifysamedom result_unif result
checknbshapes result_unif -vertex 26 -edge 39 -wire 15 -face 15 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png
#unifysamedom result_unif result
#checknbshapes result_unif -vertex 26 -edge 39 -wire 15 -face 15 -shell 1 -solid 1
#checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,34 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_trimmed.brep] s
set ref_values { { 23829.6 171246 13 13 } \
{ 25781.5 196049 14 14 } \
{ 27762.8 222816 14 14 } \
{ 29808.5 251596 12 12 } \
{ 31919.5 282455 12 12 } \
{ 34088.4 315454 12 12 } \
{ 36315.3 350651 12 12 } \
{ 38600 388104 12 12 } \
{ 40942.8 427870 12 12 } \
{ 43343.5 470009 12 12 } \
{ 45802.1 514577 12 12 } \
{ 48318.6 561632 12 12 } \
{ 50893.1 611233 12 12 } \
{ 53525.6 663438 12 12 } \
{ 56215.9 718304 12 12 } \
{ 58964.3 775889 12 12 } \
{ 61770.5 836251 12 12 } \
{ 64634.7 899449 12 12 } \
{ 67556.9 965540 12 12 } \
{ 70537 1.03458e+06 12 12 } }
perform_offset_increasing s 1 20 1 $ref_values
copy r5 result
copy r5_unif result_unif
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 5
offsetperform result
checkprops result -s 3.47344e+06 -v 4.06389e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 962 -face 962 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 8
offsetperform result
checkprops result -s 3.35577e+06 -v 5.12413e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 755 -face 755 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,22 @@
puts "TODO CR32333 ALL: Error : The area of result shape is"
puts "TODO CR32333 ALL: Error : The command is not valid."
puts "TODO CR32333 ALL: Error : The volume of result shape is"
puts "TODO CR32333 ALL: Error : is WRONG because number of"
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 10
offsetperform result
checkprops result -s 3.1312e+06 -v 5.77267e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 492 -face 492 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,22 @@
puts "TODO OCC32333 ALL: Error: The command cannot be built"
puts "TODO OCC32333 ALL: gives an empty result"
puts "TODO OCC32333 ALL: TEST INCOMPLETE"
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 11
offsetperform result
checkprops result -s 2.75287e+06 -v 6.08747e+07
checknbshapes result -shell 1 -solid 1
#unifysamedom result_unif result
#checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1
#checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 13
offsetperform result
checkprops result -s 2.84681e+06 -v 6.64723e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 15
offsetperform result
checkprops result -s 2.7281e+06 -v 7.20465e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 104 -face 104 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032307: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" Joint type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32307.brep] s
offsetparameter 1e-7 c i r
offsetload s 20
offsetperform result
checkprops result -s 1.29992e+07 -v 8.09132e+08
# number of shapes should not change
checknbshapes result -ref [nbshapes s]
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,24 @@
puts "============================================================================================="
puts "0032307: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" Joint type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32307.brep] s
offsetparameter 1e-7 c i r
offsetload s 0
foreach f [explode s f] {
mksurface surf $f
regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump surf] full x y z
if {abs($z) > 1.e-7 || (abs($y) < 1.e-7 && abs($x) > 1.e-7)} {
offsetonface $f 20
}
}
offsetperform result
checkprops result -s 1.20298e+07 -v 7.1394e+08
# number of shapes should not change
checknbshapes result -ref [nbshapes s]
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,4 +1,7 @@
puts "TODO CR27414 ALL: Error : The volume of result shape is"
#puts "TODO CR27414 ALL: Error : The volume of result shape is"
puts "TODO OCC27414 ALL: Error: The command cannot be built"
puts "TODO OCC27414 ALL: gives an empty result"
puts "TODO OCC27414 ALL: TEST INCOMPLETE"
restore [locate_data_file bug26917_M2_trim16.brep] s

15
tests/pipe/bugs/bug29645 Normal file
View File

@@ -0,0 +1,15 @@
puts "========"
puts "0029645: Hang on making pipe shell using BRepOffsetAPI_MakePipeShell"
puts "========"
puts ""
restore [locate_data_file bug29645_spine.brep] spine
restore [locate_data_file bug29645_profile.brep] profile
mksweep spine
addsweep profile
buildsweep result -S -C
puts "TEST COMPLETED"

35
tests/pipe/bugs/bug31147 Normal file
View File

@@ -0,0 +1,35 @@
puts "============"
puts "0031147: Modeling Algorithms - BRepOffsetAPI_MakePipeShell null access"
puts "============"
puts ""
pload VISUALIZATION
restore [locate_data_file bug31147.brep] s
explode s e
wire spine s_1
wire profile s_2
mksweep spine
addsweep profile
setsweep -SM 1000
setsweep -DM 14
buildsweep result -S -C
set info1 [errorsweep]
set check [regexp {Tolerance on surfaces = ([0-9\-+Ee.]+)} $info1 str error]
if { $error > 1.e-4 } {
puts "Error: bad tolerance of result"
}
vinit
vdisplay result
vsetdispmode 1
vfit
checkshape result
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
puts "TEST COMPLETED"