#include <TopOpeBRepDS_PointIterator.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
+#include <BOPCol_MapOfOrientedShape.hxx>
#ifdef OCCT_DEBUG
#include <OSD_Chronometer.hxx>
extern Standard_Boolean ChFi3d_GettraceCHRON();
#endif
+//=======================================================================
+//function : BuildNewWire
+//purpose :
+//=======================================================================
+
+TopoDS_Wire BuildNewWire(const TopoDS_Wire& theWire,
+ const TopTools_IndexedDataMapOfShapeListOfShape& theVEmap,
+ const TopoDS_Compound& theNewEdges,
+ const TopoDS_Face& theFace)
+{
+ TopTools_IndexedMapOfShape OldVertices, NewEdges;
+ TopExp::MapShapes(theWire, TopAbs_VERTEX, OldVertices);
+ TopExp::MapShapes(theNewEdges, TopAbs_EDGE, NewEdges);
+
+ //Find <StartEdge>, <StartVertex> and calculate minimum distance
+ //between extremities of edge in 2d
+ TopoDS_Vertex StartVertex;
+ TopoDS_Edge StartEdge, SecondEdge;
+ Standard_Real MinDist = RealLast();
+ TopTools_ListIteratorOfListOfShape itl;
+ BOPCol_MapOfOrientedShape Emap;
+ for (Standard_Integer i = 1; i <= OldVertices.Extent(); i++)
+ {
+ TopoDS_Vertex aVertex = TopoDS::Vertex(OldVertices(i));
+ const TopTools_ListOfShape& Elist = theVEmap.FindFromKey(aVertex);
+ for (itl.Initialize(Elist); itl.More(); itl.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value());
+ if (!Emap.Add(anEdge))
+ continue;
+ if (StartEdge.IsNull() &&
+ NewEdges.Contains(anEdge))
+ {
+ //StartEdge = anEdge;
+ Standard_Integer anIndex = NewEdges.FindIndex(anEdge);
+ StartEdge = TopoDS::Edge(NewEdges(anIndex));
+ StartVertex = aVertex;
+ }
+ BRepAdaptor_Curve2d BAcurve(anEdge, theFace);
+ gp_Pnt2d aFirstPoint = BAcurve.Value(BAcurve.FirstParameter());
+ gp_Pnt2d aLastPoint = BAcurve.Value(BAcurve.LastParameter());
+ Standard_Real aDist = aFirstPoint.SquareDistance(aLastPoint);
+ if (aDist < MinDist)
+ MinDist = aDist;
+ }
+ }
+
+ if (StartEdge.IsNull())
+ return theWire;
+
+ TopoDS_Wire NewWire;
+ BRep_Builder BB;
+ BB.MakeWire(NewWire);
+
+ BB.Add(NewWire, StartEdge);
+
+ //Define the direction of loop: forward or reversed
+ TopAbs_Orientation Direction;
+ Standard_Integer IndOr;
+ //Here and further orientation of edge is taken into account
+ TopoDS_Vertex V1 = TopExp::FirstVertex(StartEdge, Standard_True);
+ if (V1.IsSame(StartVertex))
+ {
+ Direction = TopAbs_FORWARD;
+ IndOr = 0;
+ }
+ else
+ {
+ Direction = TopAbs_REVERSED;
+ IndOr = 1;
+ }
+
+ BRepAdaptor_Curve2d StartBAcurve(StartEdge, theFace);
+ Standard_Real StartParam = BRep_Tool::Parameter(StartVertex, StartEdge);
+ gp_Pnt2d StartPoint = StartBAcurve.Value(StartParam);
+
+ //Find second edge;
+ TopTools_SequenceOfShape Candidates;
+ TopoDS_Vertex VV [2];
+
+ //Main loop
+ TopoDS_Edge CurEdge = StartEdge, NextEdge;
+ TopoDS_Vertex CurVertex = (Direction == TopAbs_FORWARD)?
+ TopExp::LastVertex(CurEdge, Standard_True) :
+ TopExp::FirstVertex(CurEdge, Standard_True);
+ BRepAdaptor_Curve2d CurCurve(CurEdge, theFace);
+ Standard_Real CurParam = BRep_Tool::Parameter(CurVertex, CurEdge);
+ gp_Pnt2d CurPoint = CurCurve.Value(CurParam);
+ for (;;)
+ {
+ const TopTools_ListOfShape& Elist = theVEmap.FindFromKey(CurVertex);
+ Candidates.Clear();
+ //Standard_Boolean IsPrevEdgeCorrect = Standard_True;
+
+ //Candidates are the edges close to <CurPoint> in 2d
+ for (itl.Initialize(Elist); itl.More(); itl.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(itl.Value());
+ if (anEdge.IsSame(CurEdge))
+ continue;
+ BRepAdaptor_Curve2d BAcurve(anEdge, theFace);
+ gp_Pnt2d aPoint = BAcurve.Value(BAcurve.FirstParameter());
+ Standard_Real aDist = CurPoint.SquareDistance(aPoint);
+ if (aDist < MinDist)
+ Candidates.Append(anEdge);
+ else
+ {
+ aPoint = BAcurve.Value(BAcurve.LastParameter());
+ aDist = CurPoint.SquareDistance(aPoint);
+ if (aDist < MinDist)
+ Candidates.Append(anEdge);
+ }
+ }
+
+ if (Candidates.IsEmpty()) //hanging new edge
+ {
+ //need to build additional edges
+ }
+
+ TopoDS_Edge NextEdge, aCandidate;
+ for (Standard_Integer i = 1; i <= Candidates.Length(); i++)
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(Candidates(i));
+ if (NewEdges.Contains(anEdge))
+ {
+ TopExp::Vertices(anEdge, VV[0], VV[1], Standard_True);
+ if (VV[IndOr].IsSame(CurVertex))
+ {
+ BRepAdaptor_Curve2d BAcurve(anEdge, theFace);
+ Standard_Real aParam = BRep_Tool::Parameter(CurVertex, anEdge);
+ gp_Pnt2d aPoint = BAcurve.Value(aParam);
+ Standard_Real aDist = CurPoint.SquareDistance(aPoint);
+ if (aDist < MinDist)
+ {
+ NextEdge = anEdge;
+ break;
+ }
+ }
+ else //previous edge is incorrect
+ {
+ //remove previous edge from wire
+ //build additional edges
+ //NextEdge = anEdge;
+ }
+ }
+ else if (aCandidate.IsNull())
+ {
+ TopExp::Vertices(anEdge, VV[0], VV[1], Standard_True);
+ if (VV[IndOr].IsSame(CurVertex))
+ {
+ BRepAdaptor_Curve2d BAcurve(anEdge, theFace);
+ Standard_Real aParam = BRep_Tool::Parameter(VV[IndOr], anEdge);
+ gp_Pnt2d aPoint = BAcurve.Value(aParam);
+ Standard_Real aDist = CurPoint.SquareDistance(aPoint);
+ if (aDist < MinDist)
+ aCandidate = anEdge;
+ }
+ }
+ }
+ if (NextEdge.IsNull())
+ NextEdge = aCandidate;
+
+ CurEdge = NextEdge;
+ CurVertex = (Direction == TopAbs_FORWARD)?
+ TopExp::LastVertex(CurEdge, Standard_True) :
+ TopExp::FirstVertex(CurEdge, Standard_True);
+ CurCurve.Initialize(CurEdge, theFace);
+ CurParam = BRep_Tool::Parameter(CurVertex, CurEdge);
+ CurPoint = CurCurve.Value(CurParam);
+
+ BB.Add(NewWire, CurEdge);
+
+ if (CurVertex.IsSame(StartVertex) &&
+ CurPoint.SquareDistance(StartPoint) < MinDist)
+ break;
+ }
+
+ return NewWire;
+}
//=======================================================================
//function : CompleteDS
//assembling of resulting shape from modified and unmodified faces.
for (Standard_Integer i = 1; i <= myNewFaces.Extent(); i++)
{
- TopoDS_Shape aFace = myNewFaces(i);
+ TopoDS_Face aFace = TopoDS::Face(myNewFaces(i));
aFace.Orientation(TopAbs_FORWARD);
- TopoDS_Compound aWires;
- BB.MakeCompound(aWires);
- TopoDS_Iterator itw(aFace);
- for (; itw.More(); itw.Next())
- BB.Add(aWires, itw.Value());
TopoDS_Compound aNewEdges;
BB.MakeCompound(aNewEdges);
}
//BRepAlgoAPI_Fuse aFuse(aWires, aNewEdges);
BOPAlgo_Builder GenFuse;
- GenFuse.AddArgument(aWires);
+ GenFuse.AddArgument(aFace);
GenFuse.AddArgument(aNewEdges);
GenFuse.Perform();
TopoDS_Shape aNewFace = aFace.EmptyCopied();
const TopoDS_Shape& aResFuse = GenFuse.Shape();
const BOPCol_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images();
- for (itw.Initialize(aWires); itw.More(); itw.Next())
+ TopTools_IndexedDataMapOfShapeListOfShape VEmapOfNewFace;
+ TopExp::MapShapesAndAncestors(aResFuse, TopAbs_VERTEX, TopAbs_EDGE, VEmapOfNewFace);
+ TopoDS_Iterator itw(aFace);
+ for (; itw.More(); itw.Next())
{
const TopoDS_Shape& aWire = itw.Value();
if (!ModifiedShapes.IsBound(aWire))
TopTools_ListIteratorOfListOfShape itwm(aListOfModified);
for (; itwm.More(); itwm.Next())
{
- const TopoDS_Shape& aModifiedWire = itwm.Value();
+ const TopoDS_Wire& aModifiedWire = TopoDS::Wire(itwm.Value());
cout<<"a Modified Wire ..."<<endl;
+ TopoDS_Wire aNewWire = BuildNewWire(aModifiedWire, VEmapOfNewFace, aNewEdges, aFace);
+ cout<<"a New Wire ..."<<endl;
+ BB.Add(aNewFace, aNewWire);
+ cout<<"a New Face ..."<<endl;
}
}
}
ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
+ TopoDS_Vertex VerFopFad [3];
//the parameter of the vertex in the air is initialiced with the value of
//its opposite (point on arc).
Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
inters = IntersUpdateOnSame (HGs,HBs,c3df,Fop,Fv,Arcprol,Vtx,isfirst,10*tolesp, // in
FiopArc,CPopArc,p2dbout,wop); // out
+ //jgv
+ for (Standard_Integer is = 1; is <= 2; is++)
+ {
+ ChFiDS_FaceInterference& Interf = Fd->ChangeInterference(is);
+ Standard_Integer IndEsurf = Fd->IndexOfEdge(is);
+ TopoDS_Edge EdgeSurf = TopoDS::Edge(myNewEdges(IndEsurf));
+ Standard_Real fpar, lpar;
+ Handle(Geom_Curve) CurveEdgeSurf = BRep_Tool::Curve(EdgeSurf, fpar, lpar);
+ //BRep_Tool::Range(EdgeSurf, fpar, lpar);
+ if (isfirst)
+ fpar = Interf.FirstParameter();
+ else
+ lpar = Interf.LastParameter();
+ BB.Range(EdgeSurf, fpar, lpar);
+ VerFopFad[is] = (isfirst)? TopExp::FirstVertex(EdgeSurf)
+ : TopExp::LastVertex(EdgeSurf);
+ gp_Pnt aPnt = CurveEdgeSurf->Value((isfirst)? fpar : lpar);
+ BB.UpdateVertex(VerFopFad[is], aPnt, 0.);
+ }
+ /////
Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
throw Standard_Failure("OneCorner : echec calcul intersection");
//jgv
- aNewEdge = BRepLib_MakeEdge(Cc);
+ aNewEdge = BRepLib_MakeEdge(Cc,
+ VerFopFad[IFopArc], VerFopFad[IFadArc],
+ Cc->FirstParameter(), Cc->LastParameter());
BB.UpdateEdge(aNewEdge, tolreached);
TopLoc_Location aLoc;
BB.UpdateEdge(aNewEdge, Ps, DStr.Surface(Fd->Surf()).Surface(), aLoc, 0.);
throw Standard_Failure("OneCorner : echec calcul intersection");
//jgv
- TopoDS_Vertex CommonVertexForNewEdgeAndZobEdge = TopExp::FirstVertex(aNewEdge);
- TopoDS_Edge aZobEdge = BRepLib_MakeEdge(zob3d, Vtx, CommonVertexForNewEdgeAndZobEdge);
+ //TopoDS_Vertex CommonVertexForNewEdgeAndZobEdge = TopExp::FirstVertex(aNewEdge);
+ TopoDS_Edge aZobEdge = BRepLib_MakeEdge(zob3d,
+ Vtx, VerFopFad[IFopArc],
+ zob3d->FirstParameter(), zob3d->LastParameter());
BB.UpdateEdge(aZobEdge, tolreached);
/*
Handle(Geom2d_Curve) AdjustedZob2dop;
IMPLEMENT_STANDARD_RTTIEXT(ChFiDS_SurfData,MMgt_TShared)
-ChFiDS_SurfData::ChFiDS_SurfData () :
-indexOfS1(0),indexOfS2(0),indexOfConge(0),
-isoncurv1(0),isoncurv2(0),twistons1(0),twistons2(0)
+ChFiDS_SurfData::ChFiDS_SurfData ()
+: indexOfS1(0),indexOfS2(0),
+ indexOfE1(0),indexOfE2(0),
+ indexOfConge(0),
+ isoncurv1(0),isoncurv2(0),twistons1(0),twistons2(0)
{}
//=======================================================================
{
indexOfS1 = Other->indexOfS1;
indexOfS2 = Other->indexOfS2;
+indexOfE1 = Other->indexOfE1;
+indexOfE2 = Other->indexOfE2;
indexOfConge = Other->indexOfConge;
orientation = Other->orientation;
intf1 = Other->intf1;
else return indexOfS2;
}
+//=======================================================================
+//function : IndexOfEdge
+//purpose :
+//=======================================================================
+
+inline Standard_Integer ChFiDS_SurfData::IndexOfEdge(const Standard_Integer OnS) const
+{
+ if (OnS == 1)
+ return indexOfE1;
+ else
+ return indexOfE2;
+}
+
//=======================================================================
//function : Interference
//purpose :
else return intf2;
}
-
//=======================================================================
-//function : Interference
+//function : ChangeInterference
//purpose :
//=======================================================================