mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Next version.
This commit is contained in:
@@ -81,6 +81,7 @@
|
||||
#include <TopOpeBRepDS_PointIterator.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <BOPCol_MapOfOrientedShape.hxx>
|
||||
|
||||
#ifdef OCCT_DEBUG
|
||||
#include <OSD_Chronometer.hxx>
|
||||
@@ -108,6 +109,185 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
|
||||
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
|
||||
@@ -421,13 +601,8 @@ void ChFi3d_Builder::Compute()
|
||||
//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);
|
||||
@@ -441,13 +616,16 @@ void ChFi3d_Builder::Compute()
|
||||
}
|
||||
//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))
|
||||
@@ -456,8 +634,12 @@ void ChFi3d_Builder::Compute()
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -816,6 +816,7 @@ Standard_Boolean ChFi3d_Builder::StoreData(Handle(ChFiDS_SurfData)& Data,
|
||||
myFaceNewEdges.Add(IndF1, aList);
|
||||
}
|
||||
Standard_Integer IndE1 = myNewEdges.FindIndex(Boundary1);
|
||||
Data->ChangeIndexOfE1(IndE1);
|
||||
TopAbs_Orientation Et = (Reversed)? TopAbs_REVERSED : TopAbs_FORWARD;
|
||||
QualifiedEdge aQE1(IndE1, Et, BRepOffset_Convex);
|
||||
myFaceNewEdges.ChangeFromKey(IndF1).Append(aQE1);
|
||||
@@ -891,6 +892,7 @@ Standard_Boolean ChFi3d_Builder::StoreData(Handle(ChFiDS_SurfData)& Data,
|
||||
myFaceNewEdges.Add(IndF2, aList);
|
||||
}
|
||||
Standard_Integer IndE2 = myNewEdges.FindIndex(Boundary2);
|
||||
Data->ChangeIndexOfE2(IndE2);
|
||||
QualifiedEdge aQE2(IndE2, TopAbs::Reverse(Et), BRepOffset_Convex);
|
||||
myFaceNewEdges.ChangeFromKey(IndF2).Append(aQE2);
|
||||
/////
|
||||
|
@@ -756,6 +756,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
|
||||
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);
|
||||
@@ -771,6 +772,26 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
|
||||
|
||||
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);
|
||||
@@ -861,7 +882,9 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
|
||||
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.);
|
||||
@@ -1299,8 +1322,10 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
|
||||
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;
|
||||
|
@@ -24,9 +24,11 @@
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
@@ -38,6 +40,8 @@ void ChFiDS_SurfData::Copy(const Handle(ChFiDS_SurfData)& Other)
|
||||
{
|
||||
indexOfS1 = Other->indexOfS1;
|
||||
indexOfS2 = Other->indexOfS2;
|
||||
indexOfE1 = Other->indexOfE1;
|
||||
indexOfE2 = Other->indexOfE2;
|
||||
indexOfConge = Other->indexOfConge;
|
||||
orientation = Other->orientation;
|
||||
intf1 = Other->intf1;
|
||||
@@ -75,6 +79,19 @@ Standard_Integer ChFiDS_SurfData::Index(const Standard_Integer OfS) const
|
||||
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 :
|
||||
@@ -87,9 +104,8 @@ const ChFiDS_FaceInterference& ChFiDS_SurfData::Interference
|
||||
else return intf2;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Interference
|
||||
//function : ChangeInterference
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
@@ -81,6 +81,10 @@ public:
|
||||
|
||||
void ChangeIndexOfS2 (const Standard_Integer Index);
|
||||
|
||||
void ChangeIndexOfE1 (const Standard_Integer Index);
|
||||
|
||||
void ChangeIndexOfE2 (const Standard_Integer Index);
|
||||
|
||||
void ChangeSurf (const Standard_Integer Index);
|
||||
|
||||
void SetIndexOfC1 (const Standard_Integer Index);
|
||||
@@ -107,6 +111,8 @@ public:
|
||||
|
||||
Standard_EXPORT Standard_Integer Index (const Standard_Integer OfS) const;
|
||||
|
||||
Standard_EXPORT Standard_Integer IndexOfEdge(const Standard_Integer OfS) const;
|
||||
|
||||
//! returns one of the four vertices wether First is true
|
||||
//! or wrong and OnS equals 1 or 2.
|
||||
Standard_EXPORT const ChFiDS_CommonPoint& Vertex (const Standard_Boolean First, const Standard_Integer OnS) const;
|
||||
@@ -183,11 +189,15 @@ private:
|
||||
Standard_Real myfirstextend;
|
||||
Standard_Real mylastextend;
|
||||
Handle(MMgt_TShared) simul;
|
||||
|
||||
Standard_Integer indexOfS1;
|
||||
Standard_Integer indexOfC1;
|
||||
Standard_Integer indexOfS2;
|
||||
Standard_Integer indexOfC2;
|
||||
Standard_Integer indexOfE1;
|
||||
Standard_Integer indexOfE2;
|
||||
Standard_Integer indexOfConge;
|
||||
|
||||
Standard_Boolean isoncurv1;
|
||||
Standard_Boolean isoncurv2;
|
||||
Standard_Boolean twistons1;
|
||||
|
@@ -201,6 +201,26 @@ inline void ChFiDS_SurfData::ChangeIndexOfS2(const Standard_Integer Index)
|
||||
indexOfS2 = Index;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeIndexOfE1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ChFiDS_SurfData::ChangeIndexOfE1(const Standard_Integer Index)
|
||||
{
|
||||
indexOfE1 = Index;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeIndexOfE2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ChFiDS_SurfData::ChangeIndexOfE2(const Standard_Integer Index)
|
||||
{
|
||||
indexOfE2 = Index;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeSurf
|
||||
//purpose :
|
||||
|
Reference in New Issue
Block a user