#include <BRepLib_FindSurface.hxx>
#include <BRepLib_MakeWire.hxx>
#include <BRepLib_MakeEdge.hxx>
+#include <BRepCheck_Wire.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
}
if (Abs(I2-I1)==1) {
- // numeros consecutifs
+ // consecutive numbers
if (I2==I1+1) {
E1 = e1;
E2 = e2;
}
}
else {
- // numeros non consecutifs sur un wire ferme
+ // non consecutive numbers on a closed wire
if (I1==1&&I2==NE) {
E1 = e2;
E2 = e1;
BRepGProp::LinearProperties(W,GP);
gp_Pnt Bary = GP.CentreOfMass();
-// blindage pour les cas particuliers : 1 seule edge cercle ou ellipse
-// sur un wire ferme !
+// shielding for particular cases : only one edge circle or ellipse
+// on a closed wire !
Standard_Integer nbEdges = 0;
BRepTools_WireExplorer anExp;
anExp.Init(W);
Standard_Boolean wClosed = W.Closed();
if (!wClosed) {
- // on regarde quand meme si les vertex sont les memes.
+ // it is checked if the vertices are the same.
TopoDS_Vertex V1, V2;
TopExp::Vertices(W,V1,V2);
if ( V1.IsSame(V2)) wClosed = Standard_True;
P.SetLocation(Bary);
}
else {
- // wire non plan !
+ // wire not plane !
GProp_PrincipalProps Pp = GP.PrincipalProperties();
gp_Vec Vec;
Standard_Real R1, R2, R3,Tol = Precision::Confusion();
Vbid.Nullify();
if (SeqOrder) {
- // de first vers last
+ // from first to last
m0 = first;
V0 = Vf;
for (j=1; j<=ndec; j++) {
- // morceau d'edge
+ // piece of edge
m1 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
TopoDS_Edge CutE = BRepLib_MakeEdge(C,V0,Vbid,m0,m1);
CutE.Orientation(CurrentOrient);
m0 = m1;
V0 = TopExp::LastVertex(CutE);
if (j==ndec) {
- // dernier morceau
+ // last piece
TopoDS_Edge LastE = BRepLib_MakeEdge(C,V0,Vl,m0,last);
LastE.Orientation(CurrentOrient);
S.Append(LastE);
}
}
else {
- // de last vers first
+ // from last to first
m1 = last;
V1 = Vl;
for (j=ndec; j>=1; j--) {
- // morceau d'edge
+ // piece of edge
m0 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
TopoDS_Edge CutE = BRepLib_MakeEdge(C,Vbid,V1,m0,m1);
CutE.Orientation(CurrentOrient);
m1 = m0;
V1 = TopExp::FirstVertex(CutE);
if (j==1) {
- // dernier morceau
+ // last piece
TopoDS_Edge LastE = BRepLib_MakeEdge(C,Vf,V1,first,m1);
LastE.Orientation(CurrentOrient);
S.Append(LastE);
BRepTools_WireExplorer anExp;
- // construction de l'edge d'intersection
+ // construction of the edge of intersection
Standard_Boolean NewVertex = Standard_False;
gp_Lin droite(P1,gp_Dir(gp_Vec(P1,P2)));
- // ATTENTION : en toute rigueur, il faudrait construire une demi-droite
- // mais il y a un bug dans BRepExtrema_DistShapeShape
- // on se contente de 100 * la distance entre P1 et P2
- // en esperant que ce soit suffisant jusqu'a ce que le bug
- // soit corrige
+ // ATTENTION : it is required to construct a half-straight
+ // but there is a bug in BRepExtrema_DistShapeShape
+ // it is enough to take 100 * distance between P1 and P2
+ // hoping that it is enough until the bug is corrected
// Standard_Real dernierparam = Precision::Infinite();
- // ATTENTION : le retour !!
- // 100 c'est mieux que 10 mais quelquefois c'est trop !
- // finalement, rien ne vaut une bonne boite d'encombrement
+ // ATTENTION : return !!
+ // 100 is better than 10 but it is too much !
+ // finally, nothing is better than a blocking box
// Standard_Real dernierparam = 100 * P1.Distance(P2);
Bnd_Box B;
BRepBndLib::Add(W,B);
BRepLib_MakeEdge ME(droite,0.,dernierparam);
TopoDS_Edge ECur = BRepLib_MakeEdge(droite,0.,P1.Distance(P2));
- // calcul de l'intersection par BRepExtrema (point de distance mini)
+ // calculate the intersection by BRepExtrema (point of min distance)
BRepExtrema_DistShapeShape DSS(ME.Edge(),W);
if (DSS.IsDone()) {
- // on choisit la solution la plus proche de P2
+ // choose the solution closest to P2
Standard_Integer isol = 1;
Standard_Real dss = P2.Distance(DSS.PointOnShape2(isol));
for (Standard_Integer iss=2; iss<=DSS.NbSolution(); iss++) {
gp_Pnt Psol =
#endif
DSS.PointOnShape2(isol);
- // la solution est-elle un nouveau vertex ?
+ // is the solution a new vertex ?
NewVertex = (DSS.SupportTypeShape2(isol) != BRepExtrema_IsVertex);
if (NewVertex) {
TopoDS_Shape aLocalShape = DSS.SupportOnShape2(isol);
NewVertex = Standard_False;
Vsol = TopExp::LastVertex(E);
}
- // verif
+ // check
if (!NewVertex) {
TopoDS_Vertex VRoot;
if (SearchRoot(Vsol,Map,VRoot)) NewVertex = Standard_True;
// Vsol = TopoDS::Vertex(DSS.SupportOnShape2(isol));
}
- // il faut decouper l'edge
+ // it is required to cut the edge
if (NewVertex) {
TopoDS_Shape aLocalShape = DSS.SupportOnShape2(isol);
TopoDS_Edge E = TopoDS::Edge(aLocalShape);
// TopoDS_Edge E = TopoDS::Edge(DSS.SupportOnShape2(isol));
-#ifdef DEB
- Standard_Real tol =
-#endif
- Precision::PConfusion();
Standard_Real first,last,param;
DSS.ParOnEdgeS2(isol,param);
BRep_Tool::Range(E,first,last);
gp_Ax1 Norm(Pos2,norm2);
Standard_Real ang = axe1.AngleWithRef(axe2,norm2);
if (!WithRotation) {
- if (ang>PI/2) ang = ang - PI;
- if (ang<-PI/2) ang = ang + PI;
+ if (ang>M_PI/2) ang = ang - M_PI;
+ if (ang<-M_PI/2) ang = ang + M_PI;
}
ang *= sign;
Pnew = Pnew.Rotated (Norm,ang);
// compute origin and orientation on wires to avoid twisted results
// and update wires to have same number of edges
- // determination de report:
- // si le nombre d'elements est identique et si les wires ont des discontinuites
- // en tangence, on n'effectue pas le report par abscisse curviligne, ni
+ // determination of report:
+ // if the number of elements is the same and if the wires have discontinuities
+ // by tangency, the report is not carried out by curvilinear abscissa
Standard_Integer nbSects = myWork.Length(), i;
BRepTools_WireExplorer anExp;
Standard_Integer nbmax=0, nbmin=0;
if (nbmax<nbEdges(i)) nbmax = nbEdges(i);
if (nbmin>nbEdges(i)) nbmin = nbEdges(i);
}
- // si on n'a pas le meme nombre d'elements ou si tous les wires sont au moins
- // C1, on effectue le report par abscisse curviligne des decoupes sinon, on se
- // fait un report vertex / Vertex
+ // if the number of elements is not the same or if all wires are at least
+ // C1, the report is carried out by curvilinear abscissa of cuts, otherwise
+ // a report vertex / Vertex is done
report = (nbmax != nbmin || contS >= GeomAbs_C1 );
- // initialisation de la map
+ // initialization of the map
Standard_Integer nbE = 0;
TopTools_ListOfShape Empty;
for (i=1; i<=nbSects; i++) {
}
}
- // sections ouvertes / sections fermees
- // initialisation de myDegen1, myDegen2
+ // open/closed sections
+ // initialisation of myDegen1, myDegen2
Standard_Integer ideb=1, ifin=myWork.Length();
- // on regarde si le premier wire est ponctuel
+ // check if the first wire is punctual
myDegen1 = Standard_True;
for(anExp.Init(TopoDS::Wire(myWork(ideb))); anExp.More(); anExp.Next()) {
myDegen1 = myDegen1 && (BRep_Tool::Degenerated(anExp.Current()));
}
if (myDegen1) ideb++;
- // on regarde si le dernier wire est ponctuel
+ // check if the last wire is punctual
myDegen2 = Standard_True;
for(anExp.Init(TopoDS::Wire(myWork(ifin))); anExp.More(); anExp.Next()) {
myDegen2 = myDegen2 && (BRep_Tool::Degenerated(anExp.Current()));
for (i=ideb; i<=ifin; i++) {
wClosed = myWork(i).Closed();
if (!wClosed) {
- // on regarde quand meme si les vertex sont les memes.
+ // check if the vertices are the same.
TopoDS_Vertex V1, V2;
TopExp::Vertices(TopoDS::Wire(myWork(i)),V1,V2);
if ( V1.IsSame(V2)) wClosed = Standard_True;
}
if (allClosed) {
- // Toutes les sections sont fermees
+ // All sections are closed
if (report) {
// same number of elements
SameNumberByPolarMethod(WithRotation);
}
else {
- // origine
+ // origin
ComputeOrigin(Standard_False);
}
myIsDone = Standard_True;
}
else if (allOpen) {
- // Toutes les sections sont ouvertes
- // origine
+ // All sections are open
+ // origin
SearchOrigin();
// same number of elements
if (report) {
myIsDone = Standard_True;
}
else {
- // Il y a des sections ouvertes et des sections fermees :
- // on ne traite pas
+ // There are open and closed sections :
+ // not processed
Standard_DomainError::Raise("Sections must be all closed or all open");
}
Standard_Boolean allClosed = Standard_True;
Standard_Integer i,ii,ideb=1,ifin=NbSects;
for (i=1; i<=NbSects; i++) {
- allClosed = (allClosed && myWork(i).Closed());
+ Handle(BRepCheck_Wire) Checker = new BRepCheck_Wire(TopoDS::Wire(myWork(i)));
+ allClosed = (allClosed && (Checker->Closed() == BRepCheck_NoError));
+ //allClosed = (allClosed && myWork(i).Closed());
}
if (!allClosed)
Standard_NoSuchObject::Raise("BRepFill_CompatibleWires::SameNumberByPolarMethod : the wires must be closed");
+ // sections ponctuelles, sections bouclantes ?
+ if (myDegen1) ideb++;
+ if (myDegen2) ifin--;
+ Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
+ && (myWork(ideb).IsSame(myWork(ifin)));
+
+ //Removing degenerated edges
+ for (i = ideb; i <= ifin; i++)
+ {
+ Standard_Boolean hasDegEdge = Standard_False;
+ TopoDS_Iterator anItw(myWork(i));
+ for (; anItw.More(); anItw.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(anItw.Value());
+ if (BRep_Tool::Degenerated(anEdge))
+ {
+ hasDegEdge = Standard_True;
+ break;
+ }
+ }
+ if (hasDegEdge)
+ {
+ TopoDS_Wire aNewWire;
+ BRep_Builder aBBuilder;
+ aBBuilder.MakeWire(aNewWire);
+ for (anItw.Initialize(myWork(i)); anItw.More(); anItw.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(anItw.Value());
+ if (!BRep_Tool::Degenerated(anEdge))
+ aBBuilder.Add(aNewWire, anEdge);
+ }
+ myWork(i) = aNewWire;
+ }
+ }
+
// Nombre max de decoupes possibles
Standard_Integer NbMaxV = 0;
for (i=1; i<=NbSects; i++) {
}
}
- // sections ponctuelles, sections bouclantes ?
- if (myDegen1) ideb++;
- if (myDegen2) ifin--;
- Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
- && (myWork(ideb).IsSame(myWork(ifin)));
-
- // construction des tableaux de plans des wires
+ // construction of tables of planes of wires
gp_Pln P;
Handle(TColgp_HArray1OfPnt) Pos
= new (TColgp_HArray1OfPnt) (1,NbSects);
Axe->SetValue(NbSects,Axe->Value(ifin));
}
- // construction de RMap, map des reports du wire i vers le wire i-1
+ // construction of RMap, map of reports of wire i to wire i-1
TopTools_DataMapOfShapeListOfShape RMap;
RMap.Clear();
- // boucle sur i
+ // loop on i
for (i=ifin; i>ideb; i--) {
const TopoDS_Wire& wire1 = TopoDS::Wire(myWork(i));
- // sequence des vertex du premier wire
+ // sequence of vertices of the first wire
SeqOfVertices(wire1,SeqV);
if (SeqV.Length()>NbMaxV)
Standard_NoSuchObject::Raise("BRepFill::SameNumberByPolarMethod failed");
- // extremite du premier wire
+ // extremity of the first wire
V1 = TopoDS::Vertex(SeqV.Value(1));
- // wire precedent
+ // previous wire
#ifdef DEB
const TopoDS_Wire& wire2 =
#endif
TopoDS::Wire(myWork(i-1));
- // boucle sur les vertex de wire1
+ // loop on vertices of wire1
for (ii=1;ii<=SeqV.Length();ii++) {
TopoDS_Vertex Vi = TopoDS::Vertex(SeqV.Value(ii));
- // init de RMap pour Vi
+ // init of RMap for Vi
TopTools_ListOfShape Init;
Init.Clear();
RMap.Bind(Vi,Init);
- // il faut chercher l'intersection Vi - wire2
+ // it is required to find intersection Vi - wire2
gp_Pnt Pi = BRep_Tool::Pnt(Vi);
- // on ramene Pi dans le plan courant
+ // return Pi in the current plane
gp_Pnt Pnew;
Transform(WithRotation,Pi,
Pos->Value(i),Axe->Value(i),
Pos->Value(i-1),Axe->Value(i-1),Pnew);
- // calcul de l'intersection
+ // calculate the intersection
TopoDS_Shape Support;
Standard_Boolean NewVertex;
TopoDS_Vertex Vsol;
RMap(Vi).Append(Vsol);
}
- } // boucle sur ii
- } // boucle sur i
+ } // loop on ii
+ } // loop on i
- // initialisation de MapVLV, map des correspondances vertex - liste de vertex
+ // initialisation of MapVLV, map of correspondences vertex - list of vertices
TopTools_DataMapOfShapeListOfShape MapVLV;
SeqOfVertices(TopoDS::Wire(myWork(ideb)),SeqV);
Standard_Integer SizeMap = SeqV.Length();
while (tantque) {
MapVLV(Vi).Append(V1);
NbV++;
- // test sur NbV necessaire pour les sections bouclantes
+ // test on NbV required for looping sections
if (V1.IsSame(Vi) || NbV >= myWork.Length()) {
tantque = Standard_False;
}
}
}
- // boucle sur i
+ // loop on i
for (i=ideb; i<ifin; i++) {
const TopoDS_Wire& wire1 = TopoDS::Wire(myWork(i));
- // sequence des vertex du premier wire
+ // sequence of vertices of the first wire
SeqOfVertices(wire1,SeqV);
if ( SeqV.Length()>NbMaxV || SeqV.Length()>SizeMap )
Standard_NoSuchObject::Raise("BRepFill::SameNumberByPolarMethod failed");
- // extremite du premier wire
+ // extremity of the first wire
V1 = TopoDS::Vertex(SeqV.Value(1));
- // wire suivant
+ // next wire
const TopoDS_Wire& wire2 = TopoDS::Wire(myWork(i+1));
- // boucle sur les vertex de wire1
+ // loop on vertices of wire1
for (ii=1;ii<=SeqV.Length();ii++) {
TopoDS_Vertex Vi = TopoDS::Vertex(SeqV.Value(ii));
}
if (intersect) {
- // il faut chercher l'intersection Vi - wire2
+ // it is necessary to find intersection Vi - wire2
gp_Pnt Pi = BRep_Tool::Pnt(Vi);
- // on ramene Pi dans le plan courant
+ // return Pi in the current plane
gp_Pnt Pnew;
Transform(WithRotation,Pi,
Pos->Value(i),Axe->Value(i),
Pos->Value(i+1),Axe->Value(i+1),Pnew);
- // calcul de l'intersection
+ // calculate the intersection
TopoDS_Shape Support;
Standard_Boolean NewVertex;
TopoDS_Vertex Vsol;
}
}
- } // boucle sur ii
- } // boucle sur i
+ } // loop on ii
+ } // loop on i
- // mise en ordre des wires en suivant MapVLV
+ // regularize wires following MapVLV
TopoDS_Wire wire = TopoDS::Wire(myWork(ideb));
- // sauf le dernier si les sections sont bouclantes
+ // except for the last if the sections loop
Standard_Integer ibout = ifin;
if (vClosed) ibout--;
TopoDS_Vertex VVF,VVL;
TopExp::Vertices(E,VVF,VVL,Standard_True);
- // tri des edges candidates
+ // parse candidate edges
Standard_Real scal1,scal2;
if ( (V1.IsSame(VVF)&&V2.IsSame(VVL)) || (V2.IsSame(VVF)&&V1.IsSame(VVL)) ) {
Standard_Real U1 = BRep_Tool::Parameter(VVF,E);
TopoDS_Vertex VVF,VVL;
TopExp::Vertices(E,VVF,VVL,Standard_True);
- // tri des edges candidates
+ // parse candidate edges
Standard_Real scal1,scal2;
U1 = BRep_Tool::Parameter(VVF,E);
U2 = BRep_Tool::Parameter(VVL,E);
myWork(i) = MW.Wire();
}
- // sections bouclantes ?
+ // blocking sections?
if (vClosed) myWork(myWork.Length()) = myWork(1);
- // verification du nombre d'edges pour debug
+ // check the number of edges for debug
Standard_Integer nbmax=0, nbmin=0;
for ( i=ideb; i<=ifin; i++) {
Standard_Integer nbEdges=0;
Standard_Integer ideb=1, ifin=myWork.Length();
BRepTools_WireExplorer anExp;
- // sections ponctuelles, sections bouclantes ?
+ // point sections, blocking sections?
if (myDegen1) ideb++;
if (myDegen2) ifin--;
Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
}
if (nbmax>1) {
- // plusieurs edges
+ // several edges
if (report || nbmin<nbmax) {
- // insertion des decoupes
+ // insertion of cuts
Standard_Integer nbdec=(nbmax-1)*nbSects+1;
Standard_Real tol = 0.01;
TColStd_Array1OfReal dec(1,nbdec);
dec.Init(0);
dec(2)=1;
- // calcul du tableau des decoupes
+ // calculate the table of cuts
Standard_Integer j,k,l;
for (i=1; i<=nbSects; i++) {
- // wire courant
+ // current wire
const TopoDS_Wire& wire1 = TopoDS::Wire(myWork(i));
Standard_Integer nbE = 0;
for(anExp.Init(wire1); anExp.More(); anExp.Next()) {
nbE++;
}
- // longueur et ACR du wire
+ // length and ACR of the wire
TColStd_Array1OfReal ACR(0,nbE);
ACR.Init(0);
BRepFill::ComputeACR(wire1, ACR);
- // insertion des ACR du wire dans le tableau des decoupes
+ // insertion of ACR of the wire in the table of cuts
for (j=1; j<ACR.Length()-1; j++) {
k=1;
while (dec(k)<ACR(j)) {
}
}
- // tableau effectif des decoupes
+ // table of cuts
k=1;
while (dec(k)<1) {
k++;
dec2(k) = dec(k);
}
- // insertion des decoupes dans chaque wire
+ // insertion of cuts in each wire
for (i=1; i<=nbSects; i++) {
const TopoDS_Wire& oldwire = TopoDS::Wire(myWork(i));
TopoDS_Wire newwire = BRepFill::InsertACR(oldwire, dec2, tol);
}
}
- // sections bouclantes ?
+ // blocking sections ?
if (vClosed) myWork(myWork.Length()) = myWork(1);
- // verification du nombre d'edges pour debug
+ // check the number of edges for debug
nbmax = 0;
for (i=ideb; i<=ifin; i++) {
nbEdges(i) = 0;
Standard_Integer NbSects = myWork.Length();
Standard_Integer i, ideb=1,ifin=NbSects;
- // sections ponctuelles, sections bouclantes
+ // point sections, blocking sections
if (myDegen1) ideb++;
if (myDegen2) ifin--;
Standard_Boolean vClosed = (!myDegen1) && (!myDegen2)
for (i=ideb; i<=ifin; i++) {
wClosed = myWork(i).Closed();
if (!wClosed) {
- // on regarde quand meme si les vertex sont les memes.
+ // check if the vertices are the same.
TopoDS_Vertex V1, V2;
TopExp::Vertices(TopoDS::Wire(myWork(i)),V1,V2);
if ( V1.IsSame(V2)) wClosed = Standard_True;
Standard_NoSuchObject::Raise("BRepFill_CompatibleWires::ComputeOrigin : the wires must be closed");
/*
- // Nombre max de decoupes possibles
+ // Max number of possible cuts
Standard_Integer NbMaxV = 0;
for (i=1; i<=NbSects; i++) {
for(anExp.Init(TopoDS::Wire(myWork(i))); anExp.More(); anExp.Next()) {
}
}
- // construction des tableaux de plans des wires
+ // construction of tables of planes of wires
gp_Pln P;
Handle(TColgp_HArray1OfPnt) Pos
= new (TColgp_HArray1OfPnt) (1,NbSects);
//Consider that all wires have same number of edges (polar==Standard_False)
TopTools_SequenceOfShape PrevSeq;
+ TopTools_SequenceOfShape PrevEseq;
Standard_Integer theLength = 0;
const TopoDS_Wire& wire = TopoDS::Wire( myWork(ideb) );
for (anExp.Init(wire); anExp.More(); anExp.Next())
{
PrevSeq.Append(anExp.CurrentVertex());
+ PrevEseq.Append(anExp.Current());
theLength++;
}
+ Standard_Integer nbs, NbSamples = 0;
+ if (theLength <= 2)
+ NbSamples = 4;
for (i = ideb+1; i <= ifin; i++)
{
const TopoDS_Wire& wire = TopoDS::Wire(myWork(i));
Standard_Boolean forward;
if (i == myWork.Length() && myDegen2)
{
- // derniere section ponctuelle
+ // last point section
jmin = 1;
forward = Standard_True;
}
const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
gp_Pnt P = BRep_Tool::Pnt(V);
SumDist += Pprev.Distance(P);
+ if (NbSamples > 0)
+ {
+ const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+ const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k));
+ BRepAdaptor_Curve PrevEcurve(PrevEdge);
+ BRepAdaptor_Curve Ecurve(CurEdge);
+ Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+ Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+ for (nbs = 1; nbs <= NbSamples-1; nbs++)
+ {
+ Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+ (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+ (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+ Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+ (Ecurve.FirstParameter() + nbs*SampleOnCur) :
+ (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur);
+ gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+ gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+ SumDist += PonPrev.Distance(PonCur);
+ }
+ }
}
for (k = 1; k < j; k++, n++)
{
const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
gp_Pnt P = BRep_Tool::Pnt(V);
SumDist += Pprev.Distance(P);
+ if (NbSamples > 0)
+ {
+ const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+ const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k));
+ BRepAdaptor_Curve PrevEcurve(PrevEdge);
+ BRepAdaptor_Curve Ecurve(CurEdge);
+ Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+ Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+ for (nbs = 1; nbs <= NbSamples-1; nbs++)
+ {
+ Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+ (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+ (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+ Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+ (Ecurve.FirstParameter() + nbs*SampleOnCur) :
+ (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur);
+ gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+ gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+ SumDist += PonPrev.Distance(PonCur);
+ }
+ }
}
if (SumDist < MinSumDist)
{
const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
gp_Pnt P = BRep_Tool::Pnt(V);
SumDist += Pprev.Distance(P);
+ if (NbSamples > 0)
+ {
+ Standard_Integer k_cur = k-1;
+ if (k_cur == 0)
+ k_cur = theLength;
+ const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+ const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k_cur));
+ BRepAdaptor_Curve PrevEcurve(PrevEdge);
+ BRepAdaptor_Curve Ecurve(CurEdge);
+ Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+ Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+ for (nbs = 1; nbs <= NbSamples-1; nbs++)
+ {
+ Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+ (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+ (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+ Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+ (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur) :
+ (Ecurve.FirstParameter() + nbs*SampleOnCur);
+ gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+ gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+ SumDist += PonPrev.Distance(PonCur);
+ }
+ }
}
for (k = theLength; k > j; k--, n++)
{
const TopoDS_Vertex& V = TopoDS::Vertex( SeqVertices(k) );
gp_Pnt P = BRep_Tool::Pnt(V);
SumDist += Pprev.Distance(P);
+ if (NbSamples > 0)
+ {
+ const TopoDS_Edge& PrevEdge = TopoDS::Edge(PrevEseq(n));
+ const TopoDS_Edge& CurEdge = TopoDS::Edge(SeqEdges(k-1));
+ BRepAdaptor_Curve PrevEcurve(PrevEdge);
+ BRepAdaptor_Curve Ecurve(CurEdge);
+ Standard_Real SampleOnPrev = (PrevEcurve.LastParameter()-PrevEcurve.FirstParameter())/NbSamples;
+ Standard_Real SampleOnCur = (Ecurve.LastParameter()-Ecurve.FirstParameter())/NbSamples;
+ for (nbs = 1; nbs <= NbSamples-1; nbs++)
+ {
+ Standard_Real ParOnPrev = (PrevEdge.Orientation() == TopAbs_FORWARD)?
+ (PrevEcurve.FirstParameter() + nbs*SampleOnPrev) :
+ (PrevEcurve.FirstParameter() + (NbSamples-nbs)*SampleOnPrev);
+ Standard_Real ParOnCur = (CurEdge.Orientation() == TopAbs_FORWARD)?
+ (Ecurve.FirstParameter() + (NbSamples-nbs)*SampleOnCur) :
+ (Ecurve.FirstParameter() + nbs*SampleOnCur);
+ gp_Pnt PonPrev = PrevEcurve.Value(ParOnPrev);
+ gp_Pnt PonCur = Ecurve.Value(ParOnCur);
+ SumDist += PonPrev.Distance(PonCur);
+ }
+ }
}
if (SumDist < MinSumDist)
{
}
PrevSeq.Clear();
+ PrevEseq.Clear();
if (forward)
{
for (j = jmin; j <= theLength; j++)
{
BB.Add( newwire, TopoDS::Edge(SeqEdges(j)) );
PrevSeq.Append( SeqVertices(j) );
+ PrevEseq.Append( SeqEdges(j) );
}
for (j = 1; j < jmin; j++)
{
BB.Add( newwire, TopoDS::Edge(SeqEdges(j)) );
PrevSeq.Append( SeqVertices(j) );
+ PrevEseq.Append( SeqEdges(j) );
}
}
else
TopoDS_Shape aLocalShape = SeqEdges(j).Reversed();
BB.Add( newwire, TopoDS::Edge(aLocalShape) );
//PrevSeq.Append( SeqVertices(j) );
+ PrevEseq.Append( SeqEdges(j).Reversed() );
}
for (j = theLength; j >= jmin; j--)
{
TopoDS_Shape aLocalShape = SeqEdges(j).Reversed();
BB.Add( newwire, TopoDS::Edge(aLocalShape) );
//PrevSeq.Append( SeqVertices(j) );
+ PrevEseq.Append( SeqEdges(j).Reversed() );
}
for (j = jmin; j >= 1; j--)
PrevSeq.Append( SeqVertices(j) );
// recherche du vertex correspondant a la projection conique
Standard_Real angmin, angV, eta = Precision::Angular();
TopoDS_Vertex Vopti;
- angmin = PI/2;
+ angmin = M_PI/2;
distmini = Precision::Infinite();
gp_Dir dir0(gp_Vec(Pnew,P.Location()));
for (Standard_Integer ii=1;ii<=SeqV.Length();ii++) {
gp_Dir dir1(gp_Vec(Pnew,P1));
angV = dir1.Angle(dir0);
}
- if (angV>PI/2) angV = PI - angV;
+ if (angV>M_PI/2) angV = M_PI - angV;
if (angmin>angV+eta) {
distmini = dist;
angmin = angV;
}
*/
- // sections bouclantes ?
+ // blocking sections ?
if (vClosed) myWork(myWork.Length()) = myWork(1);
}
if (isline0 || isline) {
- // cas particulier des segments de droite
+ // particular case of straight segments
gp_Pnt P1 = BRep_Tool::Pnt(Vdeb),
P2 = BRep_Tool::Pnt(Vfin);
Standard_Real dist1, dist2;
//OCC86
gp_Pnt P1 = BRep_Tool::Pnt(Vdeb), P1o = Pdeb,
P2 = BRep_Tool::Pnt(Vfin), P2o = Pfin;
-/* // on ramene Pdeb dans le plan courant
+/* // return Pdeb in the current plane
gp_Pnt Pnew = Pdeb.Translated (P0.Location(),P.Location());
gp_Ax1 A0 = P0.Axis();
gp_Ax1 A1 = P.Axis();
norm = vec1 ^ vec2;
gp_Ax1 Norm(P.Location(),norm);
Standard_Real ang = vec1.AngleWithRef(vec2,norm);
- if (ang > PI/2.0)
- ang = PI - ang;
- if (ang < -PI/2.0)
- ang = -PI - ang;
- if (Abs(ang-PI/2.0)<Precision::Angular()) {
+ if (ang > M_PI/2.0)
+ ang = M_PI - ang;
+ if (ang < -M_PI/2.0)
+ ang = -M_PI - ang;
+ if (Abs(ang-M_PI/2.0)<Precision::Angular()) {
// cas d'ambiguite
gp_Vec Vtrans(P0.Location(),P.Location()),Vsign;
Standard_Real alpha,beta,sign=1;
};
gp_Vec VDebFin0(P1o,P2o), VDebFin(P1,P2);
Standard_Real AStraight = VDebFin0.Angle(VDebFin);
- parcours = (AStraight < PI/2.0? Standard_True: Standard_False);
+ parcours = (AStraight < M_PI/2.0? Standard_True: Standard_False);
}
- // reconstruction du wire
+ // reconstruction of the wire
Standard_Integer rang;
if (parcours) {
for (rang=1;rang<=nbEdges;rang++) {
}
}
- // orientation du wire
+ // orientation of the wire
newwire.Oriented(TopAbs_FORWARD);
myWork(i) = newwire;
- // on passe au wire suivant
+ // passe to the next wire
if (parcours) {
Pdeb = BRep_Tool::Pnt(Vdeb);
Pfin = BRep_Tool::Pnt(Vfin);
E0 = E;
}
- // sections bouclantes ?
+ // blocking sections ?
if (vClosed) myWork(myWork.Length()) = myWork(1);
}
-
-
-
-
-
-
-
-