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

0030186: BRepOffsetAPI_MakePipe Generated() method produces no results for the spine edges

Add method BuildHistory providing history for sub-shapes of profile and spine to BRepFill_Pipe.
This commit is contained in:
jgv
2018-10-01 18:18:54 +03:00
committed by bugmaster
parent c3ca03eb17
commit cab49d68fc
20 changed files with 677 additions and 205 deletions

View File

@@ -62,6 +62,7 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfIntegerShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
@@ -250,7 +251,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
TopoDS_Shape aux;
TheProf = myProfile;
TheProf.Location(Loc2.Multiplied(Loc1));
// Construct First && Last Shape
Handle(GeomFill_LocationLaw) law;
@@ -307,7 +308,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
}
#endif
myShape = MakeShape(TheProf, myFirst, myLast);
myShape = MakeShape(TheProf, myProfile, myFirst, myLast);
}
@@ -382,36 +383,8 @@ void BRepFill_Pipe::Generated(const TopoDS_Shape& theShape,
{
theList.Clear();
if (theShape.IsSame(myProfile))
theList.Append(myShape);
else
{
if (theShape.ShapeType() == TopAbs_FACE ||
theShape.ShapeType() == TopAbs_WIRE)
{
if(myGenMap.IsBound(theShape))
theList = myGenMap.Find(theShape);
}
else if (theShape.ShapeType() == TopAbs_EDGE)
{
TopoDS_Iterator itw(mySpine);
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& aSpineEdge = TopoDS::Edge(itw.Value());
const TopoDS_Shape& aFace = Face(aSpineEdge, TopoDS::Edge(theShape));
theList.Append(aFace);
}
}
else if (theShape.ShapeType() == TopAbs_VERTEX)
{
TopoDS_Iterator itw(mySpine);
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& aSpineEdge = TopoDS::Edge(itw.Value());
const TopoDS_Shape& anEdge = Edge(aSpineEdge, TopoDS::Vertex(theShape));
theList.Append(anEdge);
}
}
if(myGenMap.IsBound(theShape)) {
theList = myGenMap.Find(theShape);
}
}
@@ -540,9 +513,9 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
P = Point;
P.Transform(myTrsf);
BRepLib_MakeVertex MkV(P);
TopoDS_Vertex VertexSection = BRepLib_MakeVertex(P);
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (MkV.Vertex());
new (BRepFill_ShapeLaw) (VertexSection);
// Sweeping
BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
@@ -551,6 +524,7 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
TopoDS_Shape aLocalShape = MkSw.Shape();
myErrorOnSurf = MkSw.ErrorOnSurface();
BuildHistory(MkSw, VertexSection);
return TopoDS::Wire(aLocalShape);
// return TopoDS::Wire(MkSw.Shape());
}
@@ -561,6 +535,7 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point)
//=======================================================================
TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
const TopoDS_Shape& theOriginalS,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& LastShape)
{
@@ -574,6 +549,8 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
TheLast = LastShape;
if (! myFaces.IsNull()) InitialLength = myFaces->ColLength();
TopLoc_Location BackLoc(myTrsf.Inverted());
// there are two kinds of generation
// 1. generate with S from each Filler (Vertex, Edge)
// 2. call MakeShape recursively on the subshapes of S
@@ -658,13 +635,15 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
if (!TheFirst.IsNull()) itFirst.Initialize(TheFirst);
if (!TheLast.IsNull()) itLast.Initialize(TheLast);
for (TopoDS_Iterator it(S); it.More(); it.Next()) {
TopoDS_Iterator it(S);
TopoDS_Iterator itorig(theOriginalS);
for (; it.More(); it.Next(),itorig.Next()) {
if (!TheFirst.IsNull()) first = itFirst.Value();
if (!TheLast.IsNull()) last = itLast.Value();
if (TheS.ShapeType() == TopAbs_FACE )
MakeShape(it.Value(), first, last);
MakeShape(it.Value(), itorig.Value(), first, last);
else
B.Add(result,MakeShape(it.Value(), first, last));
B.Add(result,MakeShape(it.Value(), itorig.Value(), first, last));
if (!TheFirst.IsNull()) itFirst.Next();
if (!TheLast.IsNull()) itLast.Next();
@@ -680,7 +659,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
MkSw.Build( myReversedEdges, myTapes, myRails,
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
result = MkSw.Shape();
UpdateMap(TheS.Located(myProfile.Location()), result, myGenMap);
UpdateMap(theOriginalS, result, myGenMap);
myErrorOnSurf = MkSw.ErrorOnSurface();
Handle(TopTools_HArray2OfShape) aSections = MkSw.Sections();
@@ -691,6 +670,8 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
myFirst = aSections->Value(1, 1);
myLast = aSections->Value(1, aVLast);
}
BuildHistory(MkSw, theOriginalS);
}
if (TheS.ShapeType() == TopAbs_WIRE ) {
@@ -703,7 +684,6 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
MkSw.Build( myReversedEdges, myTapes, myRails,
BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
result = MkSw.Shape();
UpdateMap(TheS.Located(myProfile.Location()), result, myGenMap);
myErrorOnSurf = MkSw.ErrorOnSurface();
// Labeling of elements
@@ -762,6 +742,8 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
myEdges = Somme;
}
BuildHistory(MkSw, theOriginalS);
}
}
@@ -808,7 +790,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
BS.Add(solid,TopoDS::Shell(aLocalShape));
// BS.Add(solid,TopoDS::Shell(result.Reversed()));
}
UpdateMap(TheS.Located(myProfile.Location()), solid, myGenMap);
UpdateMap(theOriginalS, solid, myGenMap);
return solid;
}
else {
@@ -1030,3 +1012,110 @@ void BRepFill_Pipe::RebuildTopOrBottomFace(const TopoDS_Shape& aFace,
}
}
}
//=======================================================================
//function : BuildHistory
//purpose : Builds history for edges and vertices
// of section and path
//=======================================================================
void BRepFill_Pipe::BuildHistory(const BRepFill_Sweep& theSweep,
const TopoDS_Shape& theSection)
{
//Filling of <myGenMap>
const Handle(TopTools_HArray2OfShape)& anUEdges = theSweep.InterFaces();
Standard_Integer inde;
TopoDS_Iterator itw;
if (theSection.ShapeType() == TopAbs_WIRE)
{
TopoDS_Wire aSection = TopoDS::Wire(theSection);
BRepTools_WireExplorer wexp_sec(aSection);
for (inde = 0; wexp_sec.More(); wexp_sec.Next())
{
inde++;
const TopoDS_Edge& anEdge = TopoDS::Edge(wexp_sec.Current());
if (BRep_Tool::Degenerated(anEdge))
continue;
if (myGenMap.IsBound(anEdge))
continue;
TopoDS_Vertex aVertex [2];
TopExp::Vertices(anEdge, aVertex[0], aVertex[1]);
//For an edge generated shape is a "tape" -
//a shell usually containing this edge and
//passing from beginning of path to its end
TopoDS_Shell aTape = TopoDS::Shell(theSweep.Tape(inde));
//Processing of vertices of <anEdge>
//We should choose right index in <anUEdges>
//for each vertex of edge
Standard_Integer UIndex [2];
UIndex[0] = inde;
UIndex[1] = inde+1;
if (anEdge.Orientation() == TopAbs_REVERSED)
{ Standard_Integer Tmp = UIndex[0]; UIndex[0] = UIndex[1]; UIndex[1] = Tmp; }
for (Standard_Integer kk = 0; kk < 2; kk++)
{
if (myGenMap.IsBound(aVertex[kk]))
continue;
//Assemble the list of edges ("rail" along the path)
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
Standard_Integer jj;
for (jj = 1; jj <= anUEdges->UpperCol(); jj++)
{
const TopoDS_Shape& anUedge = anUEdges->Value(UIndex[kk], jj);
if (!anUedge.IsNull())
Elist->Append(anUedge);
}
} //for (Standard_Integer kk = 0; kk < 2; kk++)
TopTools_ListOfShape* Flist = myGenMap.Bound(anEdge, TopTools_ListOfShape());
TopoDS_Iterator itsh(aTape);
for (; itsh.More(); itsh.Next())
Flist->Append(itsh.Value());
} //for (inde = 0; wexp_sec.More(); wexp_sec.Next())
} //if (theSection.ShapeType() == TopAbs_WIRE)
//For subshapes of spine
const Handle(TopTools_HArray2OfShape)& aFaces = theSweep.SubShape();
const Handle(TopTools_HArray2OfShape)& aVEdges = theSweep.Sections();
BRepTools_WireExplorer wexp(mySpine);
inde = 0;
Standard_Boolean ToExit = Standard_False;
for (;;)
{
if (!wexp.More())
ToExit = Standard_True;
inde++;
if (!ToExit)
{
const TopoDS_Edge& anEdgeOfSpine = wexp.Current();
for (Standard_Integer i = 1; i <= aFaces->UpperRow(); i++)
{
const TopoDS_Shape& aFace = aFaces->Value(i, inde);
UpdateMap(anEdgeOfSpine, aFace, myGenMap);
}
}
const TopoDS_Vertex& aVertexOfSpine = wexp.CurrentVertex();
for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++)
{
const TopoDS_Shape& aVedge = aVEdges->Value(i, inde);
UpdateMap(aVertexOfSpine, aVedge, myGenMap);
}
if (ToExit)
break;
if (wexp.More())
wexp.Next();
}
}

View File

@@ -42,6 +42,7 @@ class TopoDS_Face;
class TopoDS_Edge;
class TopoDS_Vertex;
class gp_Pnt;
class BRepFill_Sweep;
//! Create a shape by sweeping a shape (the profile)
@@ -59,9 +60,15 @@ public:
Standard_EXPORT BRepFill_Pipe();
Standard_EXPORT BRepFill_Pipe(const TopoDS_Wire& Spine, const TopoDS_Shape& Profile, const GeomFill_Trihedron aMode = GeomFill_IsCorrectedFrenet, const Standard_Boolean ForceApproxC1 = Standard_False, const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT BRepFill_Pipe(const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const GeomFill_Trihedron aMode = GeomFill_IsCorrectedFrenet,
const Standard_Boolean ForceApproxC1 = Standard_False,
const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT void Perform (const TopoDS_Wire& Spine, const TopoDS_Shape& Profile, const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT void Perform (const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const Standard_Boolean GeneratePartCase = Standard_False);
Standard_EXPORT const TopoDS_Shape& Spine() const;
@@ -113,22 +120,27 @@ private:
//! Auxiliary recursive method used to build the
//! result.
Standard_EXPORT TopoDS_Shape MakeShape (const TopoDS_Shape& S, const TopoDS_Shape& FirstShape, const TopoDS_Shape& LastShape);
Standard_EXPORT TopoDS_Shape MakeShape (const TopoDS_Shape& S,
const TopoDS_Shape& theOriginalS,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& LastShape);
//! Auxiliary recursive method used to find the edge's index
Standard_EXPORT Standard_Integer FindEdge (const TopoDS_Shape& S, const TopoDS_Edge& E, Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindEdge (const TopoDS_Shape& S,
const TopoDS_Edge& E,
Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindVertex (const TopoDS_Shape& S, const TopoDS_Vertex& V, Standard_Integer& Init) const;
Standard_EXPORT Standard_Integer FindVertex (const TopoDS_Shape& S, const
TopoDS_Vertex& V,
Standard_Integer& Init) const;
Standard_EXPORT void DefineRealSegmax();
Standard_EXPORT void RebuildTopOrBottomFace (const TopoDS_Shape& aFace, const Standard_Boolean IsTop) const;
Standard_EXPORT void RebuildTopOrBottomFace (const TopoDS_Shape& aFace,
const Standard_Boolean IsTop) const;
//! Performs sharing coincident faces in theShape. Also modifies
//! myFaces, mySections and myEdges to contain shared shapes.
//! Returns the shared shape. If theShape is not modified this
//! method returns it.
Standard_EXPORT TopoDS_Shape ShareFaces (const TopoDS_Shape& theShape, const Standard_Integer theInitialFacesLen, const Standard_Integer theInitialEdgesLen, const Standard_Integer theInitialSectionsLen);
Standard_EXPORT void BuildHistory (const BRepFill_Sweep& theSweep,
const TopoDS_Shape& theSection);
TopoDS_Wire mySpine;

View File

@@ -1203,8 +1203,8 @@ void BRepFill_PipeShell::Place(const BRepFill_Section& Sec,
//=======================================================================
//function : BuildHistory
//purpose : Builds history for edges and vertices
// of sections
//purpose : Builds history for edges and vertices of sections,
// for edges and vertices of spine
//=======================================================================
void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
{
@@ -1226,11 +1226,11 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
//for punctual sections (first or last)
//we take all the wires generated along the path
TopTools_ListOfShape Elist;
TopTools_ListOfShape* Elist = myGenMap.Bound(Section, TopTools_ListOfShape());
for (Standard_Integer i = 1; i <= anUEdges->UpperRow(); i++)
for (Standard_Integer j = 1; j <= anUEdges->UpperCol(); j++)
Elist.Append(anUEdges->Value(i,j));
myGenMap.Bind(Section, Elist);
Elist->Append(anUEdges->Value(i,j));
continue;
}
else
@@ -1319,9 +1319,11 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
continue;
if (IndWireMap.IsBound(UIndex[kk]))
{
TopTools_ListOfShape Wlist;
Wlist.Append(IndWireMap(UIndex[kk]));
myGenMap.Bind(aVertex[kk], Wlist);
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
for (itw.Initialize( IndWireMap(UIndex[kk]) ); itw.More(); itw.Next())
Elist->Append(itw.Value());
continue;
}
@@ -1393,17 +1395,21 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
}
}
}
TopTools_ListOfShape Wlist;
Wlist.Append(aWire);
myGenMap.Bind(aVertex[kk], Wlist);
TopTools_ListOfShape* Elist = myGenMap.Bound(aVertex[kk], TopTools_ListOfShape());
for (itw.Initialize(aWire); itw.More(); itw.Next())
Elist->Append(itw.Value());
//Save already built wire with its index
IndWireMap.Bind(UIndex[kk], aWire);
} //for (Standard_Integer kk = 0; kk < 2; kk++)
////////////////////////////////////
TopTools_ListOfShape ListShell;
ListShell.Append(aShell);
myGenMap.Bind(anOriginalEdge, ListShell);
TopTools_ListOfShape* Flist = myGenMap.Bound(anOriginalEdge, TopTools_ListOfShape());
TopoDS_Iterator itsh(aShell);
for (; itsh.More(); itsh.Next())
Flist->Append(itsh.Value());
////////////////////////
inde++;
@@ -1427,28 +1433,25 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
if (!ToExit)
{
const TopoDS_Edge& anEdgeOfSpine = wexp.Current();
TopoDS_Shell aShell;
BB.MakeShell(aShell);
TopTools_ListOfShape* Flist = myGenMap.Bound(anEdgeOfSpine, TopTools_ListOfShape());
for (Standard_Integer i = 1; i <= aFaces->UpperRow(); i++)
{
const TopoDS_Shape& aFace = aFaces->Value(i, inde);
if (aFace.ShapeType() == TopAbs_FACE)
BB.Add(aShell, aFace);
Flist->Append(aFace);
}
TopTools_ListOfShape ListShell;
ListShell.Append(aShell);
myGenMap.Bind(anEdgeOfSpine, ListShell);
}
const TopoDS_Vertex& aVertexOfSpine = wexp.CurrentVertex();
TopTools_ListOfShape ListVshapes;
TopTools_ListOfShape* ListVshapes = myGenMap.Bound(aVertexOfSpine, TopTools_ListOfShape());
for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++)
{
const TopoDS_Shape& aVshape = aVEdges->Value(i, inde);
if (aVshape.ShapeType() == TopAbs_EDGE ||
aVshape.ShapeType() == TopAbs_FACE)
ListVshapes.Append(aVshape);
ListVshapes->Append(aVshape);
else
{
TopoDS_Iterator itvshape(aVshape);
@@ -1457,19 +1460,17 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
const TopoDS_Shape& aSubshape = itvshape.Value();
if (aSubshape.ShapeType() == TopAbs_EDGE ||
aSubshape.ShapeType() == TopAbs_FACE)
ListVshapes.Append(aSubshape);
ListVshapes->Append(aSubshape);
else
{
//it is wire
for (itw.Initialize(aSubshape); itw.More(); itw.Next())
ListVshapes.Append(itw.Value());
ListVshapes->Append(itw.Value());
}
}
}
}
myGenMap.Bind(aVertexOfSpine, ListVshapes);
if (ToExit)
break;