1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Commit for 2d offset algorithm

This commit is contained in:
ifv
2015-02-02 15:58:21 +03:00
parent b11453f54f
commit fda01cadb2
16 changed files with 2423 additions and 1829 deletions

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -32,6 +32,7 @@
#include <BRep_PolygonOnClosedTriangulation.hxx> #include <BRep_PolygonOnClosedTriangulation.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <TopoDS_Wire.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
@@ -52,6 +53,10 @@
#include <Poly_Polygon2D.hxx> #include <Poly_Polygon2D.hxx>
#include <Poly_PolygonOnTriangulation.hxx> #include <Poly_PolygonOnTriangulation.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_IncAllocator.hxx>
#include <TopTools_ShapeMapHasher.hxx>
//modified by NIZNHY-PKV Fri Oct 17 14:13:29 2008f //modified by NIZNHY-PKV Fri Oct 17 14:13:29 2008f
static static
Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS); Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS);
@@ -314,28 +319,30 @@ Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
GP = Handle(Geom_Plane)::DownCast(S); GP = Handle(Geom_Plane)::DownCast(S);
//fin modif du 21-05-97 //fin modif du 21-05-97
if (!GP.IsNull()) { if (!GP.IsNull())
{
Handle(GeomAdaptor_HCurve) HC; Handle(GeomAdaptor_HCurve) HC;
Handle(GeomAdaptor_HSurface) HS; Handle(GeomAdaptor_HSurface) HS;
HC = new GeomAdaptor_HCurve(); HC = new GeomAdaptor_HCurve();
HS = new GeomAdaptor_HSurface(); HS = new GeomAdaptor_HSurface();
TopLoc_Location LC; TopLoc_Location aCurveLocation;
Standard_Real f, l;// for those who call with (u,u). Standard_Real f, l;// for those who call with (u,u).
Handle(Geom_Curve) C3d = Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, aCurveLocation, f, l);
BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
// we can loose scale factor of Curve transformation (eap 13 May 2002)
LC = L/*.Predivided(LC)*/; if (C3d.IsNull())
{
return nullPCurve;
}
if (C3d.IsNull()) return nullPCurve; aCurveLocation = L.Predivided(aCurveLocation);
Handle(Geom_Plane) Plane = GP; Handle(Geom_Plane) Plane = GP;
if (!LC.IsIdentity()) { if (!aCurveLocation.IsIdentity())
const gp_Trsf& T = LC.Transformation(); {
const gp_Trsf& T = aCurveLocation.Transformation();
Handle(Geom_Geometry) GPT = GP->Transformed(T); Handle(Geom_Geometry) GPT = GP->Transformed(T);
Plane = *((Handle(Geom_Plane)*)&GPT); Plane = *((Handle(Geom_Plane)*)&GPT);
} }
@@ -1139,6 +1146,12 @@ Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E)
gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V) gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V)
{ {
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
if (TV.IsNull())
{
Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
}
gp_Pnt P = TV->Pnt(); gp_Pnt P = TV->Pnt();
P.Transform(V.Location().Transformation()); P.Transform(V.Location().Transformation());
return P; return P;
@@ -1151,7 +1164,14 @@ gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V)
Standard_Real BRep_Tool::Tolerance(const TopoDS_Vertex& V) Standard_Real BRep_Tool::Tolerance(const TopoDS_Vertex& V)
{ {
Standard_Real p = (*((Handle(BRep_TVertex)*)&V.TShape()))->Tolerance(); Handle(BRep_TVertex)& aTVert = *((Handle(BRep_TVertex)*)&V.TShape());
if (aTVert.IsNull())
{
Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
}
Standard_Real p = aTVert->Tolerance();
Standard_Real pMin = Precision::Confusion(); Standard_Real pMin = Precision::Confusion();
if (p > pMin) return p; if (p > pMin) return p;
else return pMin; else return pMin;
@@ -1431,24 +1451,43 @@ gp_Pnt2d BRep_Tool::Parameters(const TopoDS_Vertex& V,
} }
//======================================================================= //=======================================================================
//function : IsClosed //function : IsClosed
//purpose : Returns <True> if S if flaged Closed, if S is a //purpose :
// Solid,Shell or Compound returns <True> is S has no free boundaries.
//======================================================================= //=======================================================================
Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Shape& S) Standard_Boolean BRep_Tool::IsClosed (const TopoDS_Shape& theShape)
{ {
if (S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_SOLID || if (theShape.ShapeType() == TopAbs_SHELL || theShape.ShapeType() == TopAbs_SOLID)
S.ShapeType() == TopAbs_COMPOUND) { {
TopTools_MapOfShape M; NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
TopExp_Explorer exp; TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next()) { Standard_Boolean hasBound = Standard_False;
// for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) { for (; exp.More(); exp.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
if (BRep_Tool::Degenerated(E)) continue; if (BRep_Tool::Degenerated(E) || E.Orientation() == TopAbs_INTERNAL || E.Orientation() == TopAbs_EXTERNAL)
if (!M.Add(E)) M.Remove(E); continue;
hasBound = Standard_True;
if (!aMap.Add(E))
aMap.Remove(E);
} }
if ( M.IsEmpty()) return 1; return hasBound && aMap.IsEmpty();
} }
return (S.Closed()); else if (theShape.ShapeType() == TopAbs_WIRE)
{
NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_VERTEX);
Standard_Boolean hasBound = Standard_False;
for (; exp.More(); exp.Next())
{
const TopoDS_Shape& V = exp.Current();
if (V.Orientation() == TopAbs_INTERNAL || V.Orientation() == TopAbs_EXTERNAL)
continue;
hasBound = Standard_True;
if (!aMap.Add(V))
aMap.Remove(V);
}
return hasBound && aMap.IsEmpty();
}
return theShape.Closed();
} }
//modified by NIZNHY-PKV Fri Oct 17 14:09:58 2008 f //modified by NIZNHY-PKV Fri Oct 17 14:09:58 2008 f
@@ -1480,3 +1519,4 @@ Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS)
// //
return bRet; return bRet;
} }

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -31,13 +31,17 @@
#include <Precision.hxx> #include <Precision.hxx>
#include <IntRes2d_IntersectionPoint.hxx> #include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx> #include <IntRes2d_IntersectionSegment.hxx>
#include <ElCLib.hxx>
#include <StdFail_NotDone.hxx> #include <StdFail_NotDone.hxx>
#ifdef DEB
//#define DRAW
#ifdef DRAW #ifdef DRAW
#include <DrawTrSurf.hxx> #include <DrawTrSurf.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
static Standard_Boolean Affich = Standard_False; static Standard_Boolean Affich = Standard_False;
static Standard_Boolean AffichInt = Standard_False;
static Standard_Integer intind = 0;
#endif
#endif #endif
@@ -47,7 +51,7 @@ static Standard_Boolean Affich = Standard_False;
//======================================================================= //=======================================================================
static void SimpleExpression (const Bisector_Bisec& B, static void SimpleExpression (const Bisector_Bisec& B,
Handle(Geom2d_Curve)& Bis) Handle(Geom2d_Curve)& Bis)
{ {
Bis = B.Value(); Bis = B.Value();
@@ -60,8 +64,8 @@ static void SimpleExpression (const Bisector_Bisec& B,
if (BT == STANDARD_TYPE(Bisector_BisecAna)) { if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve(); Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
Bis = new Geom2d_TrimmedCurve (Bis, Bis = new Geom2d_TrimmedCurve (Bis,
TrBis->FirstParameter(), TrBis->FirstParameter(),
TrBis->LastParameter()); TrBis->LastParameter());
} }
} }
} }
@@ -83,18 +87,18 @@ BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool()
//======================================================================= //=======================================================================
BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool
(const Bisector_Bisec& Bisec, (const Bisector_Bisec& Bisec,
const Handle(Geom2d_Geometry)& S1, const Handle(Geom2d_Geometry)& S1,
const Handle(Geom2d_Geometry)& S2, const Handle(Geom2d_Geometry)& S2,
const Standard_Real Offset) : const Standard_Real Offset) :
myOffset(Offset), myOffset(Offset),
myBisec(Bisec) myBisec(Bisec)
{ {
isPoint1 = (S1->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint)); isPoint1 = (S1->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
isPoint2 = (S2->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint)); isPoint2 = (S2->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
// return geometries of shapes. // return geometries of shapes.
// Standard_Real f,l; // Standard_Real f,l;
if (isPoint1) { if (isPoint1) {
myP1 = Handle(Geom2d_Point)::DownCast(S1)->Pnt2d(); myP1 = Handle(Geom2d_Point)::DownCast(S1)->Pnt2d();
} }
@@ -102,10 +106,10 @@ myBisec(Bisec)
myC1 = Handle(Geom2d_Curve)::DownCast(S1); myC1 = Handle(Geom2d_Curve)::DownCast(S1);
#ifdef DRAW #ifdef DRAW
if ( Affich) { if ( Affich) {
//POP pour NT //POP pour NT
char* myC1name = "myC1"; char* myC1name = "myC1";
DrawTrSurf::Set(myC1name,myC1); DrawTrSurf::Set(myC1name,myC1);
// DrawTrSurf::Set("myC1",myC1); // DrawTrSurf::Set("myC1",myC1);
} }
#endif #endif
} }
@@ -118,7 +122,7 @@ myBisec(Bisec)
if ( Affich) { if ( Affich) {
char* myC2name = "myC2"; char* myC2name = "myC2";
DrawTrSurf::Set(myC2name,myC2); DrawTrSurf::Set(myC2name,myC2);
// DrawTrSurf::Set("myC2",myC2); // DrawTrSurf::Set("myC2",myC2);
} }
#endif #endif
} }
@@ -128,8 +132,8 @@ myBisec(Bisec)
myBis = Geom2dAdaptor_Curve(Bis); myBis = Geom2dAdaptor_Curve(Bis);
#ifdef DRAW #ifdef DRAW
if ( Affich) { if ( Affich) {
char* myBisname = "myBis"; char* myBisname = "myBis";
DrawTrSurf::Set(myBisname,Bis); DrawTrSurf::Set(myBisname,Bis);
} }
#endif #endif
@@ -150,8 +154,8 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
gp_Pnt P1 = Seq.Value(i); gp_Pnt P1 = Seq.Value(i);
gp_Pnt P2 = Seq.Value(i+1); gp_Pnt P2 = Seq.Value(i+1);
if (P2.X()<P1.X()) { if (P2.X()<P1.X()) {
Seq.Exchange(i,i+1); Seq.Exchange(i,i+1);
Invert = Standard_True; Invert = Standard_True;
} }
} }
} }
@@ -164,12 +168,12 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
//======================================================================= //=======================================================================
static void EvalParameters(const Geom2dAdaptor_Curve& Bis, static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC, const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params) TColgp_SequenceOfPnt& Params)
{ {
Geom2dInt_GInter Intersector; Geom2dInt_GInter Intersector;
Standard_Real Tol = Precision::Confusion(); Standard_Real Tol = Precision::Confusion();
// Standard_Real TolC = 1.e-9; // Standard_Real TolC = 1.e-9;
Geom2dAdaptor_Curve CBis(Bis); Geom2dAdaptor_Curve CBis(Bis);
Geom2dAdaptor_Curve CAC (AC); Geom2dAdaptor_Curve CAC (AC);
@@ -206,20 +210,20 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
U1 = Seg.FirstPoint().ParamOnSecond(); U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond(); Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol && if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) { Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.); P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P); Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.); P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P); Params.Append(P);
} }
else { else {
U1 += Seg.LastPoint().ParamOnSecond(); U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.; U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst(); U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst(); U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.; U2 /= 2.;
P = gp_Pnt(U1,U2,0.); P = gp_Pnt(U1,U2,0.);
Params.Append(P); Params.Append(P);
} }
} }
} }
@@ -229,9 +233,9 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
} }
static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis, static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC, const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params, TColgp_SequenceOfPnt& Params,
const Standard_Real Tol) const Standard_Real Tol)
{ {
Geom2dInt_GInter Intersector; Geom2dInt_GInter Intersector;
Standard_Real TolC = Tol; Standard_Real TolC = Tol;
@@ -270,20 +274,20 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
U1 = Seg.FirstPoint().ParamOnSecond(); U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond(); Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol && if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) { Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.); P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P); Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.); P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P); Params.Append(P);
} }
else { else {
U1 += Seg.LastPoint().ParamOnSecond(); U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.; U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst(); U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst(); U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.; U2 /= 2.;
P = gp_Pnt(U1,U2,0.); P = gp_Pnt(U1,U2,0.);
Params.Append(P); Params.Append(P);
} }
} }
} }
@@ -299,8 +303,8 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
//======================================================================= //=======================================================================
void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1, void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2, const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params) TColgp_SequenceOfPnt& Params)
{ {
Params.Clear(); Params.Clear();
@@ -318,23 +322,24 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
Geom2dAdaptor_Curve AC2(C2,f,l); Geom2dAdaptor_Curve AC2(C2,f,l);
#ifdef DRAW #ifdef DRAW
if ( Affich) { if ( AffichInt) {
f = AC1.FirstParameter(); f = AC1.FirstParameter();
l = AC1.LastParameter(); l = AC1.LastParameter();
char* CURVE1name = "CURVE1"; char name[32];
DrawTrSurf::Set(CURVE1name, new Geom2d_TrimmedCurve(C1,f,l)); sprintf(name,"C1_%d", ++intind);
DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C1,f,l));
f = AC2.FirstParameter(); f = AC2.FirstParameter();
l = AC2.LastParameter(); l = AC2.LastParameter();
char* CURVE2name = "CURVE2"; sprintf(name,"C2_%d", intind);
DrawTrSurf::Set(CURVE2name, new Geom2d_TrimmedCurve(C2,f,l)); DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C2,f,l));
f = myBis.FirstParameter(); f = myBis.FirstParameter();
l = myBis.LastParameter(); l = myBis.LastParameter();
char* bisname = "BIS"; sprintf(name,"BIS%d", intind);
DrawTrSurf::Set(bisname, new Geom2d_TrimmedCurve(myBis.Curve(),f,l)); DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
char* Edge1name = "E1"; sprintf(name,"E1_%d", intind);
DBRep::Set(Edge1name, Edge1); DBRep::Set(name, Edge1);
char* Edge2name = "E2"; sprintf(name,"E2_%d", intind);
DBRep::Set(Edge2name, Edge2); DBRep::Set(name, Edge2);
} }
#endif #endif
@@ -347,36 +352,94 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
EvalParameters (myBis,AC2,Points2); EvalParameters (myBis,AC2,Points2);
Standard_Integer SeanceDeRattrapage=0; Standard_Integer SeanceDeRattrapage=0;
Standard_Real TolInit= 1.e-9; Standard_Real TolInit= 1.e-9;
Standard_Integer nn = 7; Standard_Integer nn = 7;
if((AC1.GetType() != GeomAbs_Circle && AC1.GetType() != GeomAbs_Line) || if((AC1.GetType() != GeomAbs_Circle && AC1.GetType() != GeomAbs_Line) ||
(AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) { (AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) {
TolInit = 1.e-8; TolInit = 1.e-8;
nn = 6; nn = 6;
}
if(Params.IsEmpty() && Points2.IsEmpty())
{
//Check, may be there are no intersections at all
// for case myBis == Line
if(myBis.GetType() == GeomAbs_Line)
{
Standard_Real dmax = TolInit;
Standard_Integer n = 0;
while(n < nn)
{
dmax *= 10.0;
++n;
}
dmax *= dmax;
//
gp_Lin2d anL = myBis.Line();
Standard_Boolean isFar1 = Standard_True;
Standard_Boolean isFar2 = Standard_True;
gp_Pnt2d aP;
//
Standard_Real d = RealLast();
AC1.D0(AC1.FirstParameter(), aP);
Standard_Real par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = anL.SquareDistance(aP);
}
AC1.D0(AC1.LastParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = Min(anL.SquareDistance(aP), d);
}
isFar1 = d > dmax;
//
d = RealLast();
AC2.D0(AC2.FirstParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = anL.SquareDistance(aP);
}
AC2.D0(AC2.LastParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = Min(anL.SquareDistance(aP), d);
}
isFar2 = d > dmax;
//
if(isFar1 && isFar2)
{
return;
}
}
} }
while ( SeanceDeRattrapage < nn // TolInit <= 0.01 while ( SeanceDeRattrapage < nn // TolInit <= 0.01
&& ( Points2.Length() != Params.Length() || && ( Points2.Length() != Params.Length() ||
(Points2.Length() == 0 && Params.Length() == 0) ) ) { (Points2.Length() == 0 && Params.Length() == 0) ) ) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl; cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl;
#endif #endif
Params.Clear(); Params.Clear();
Points2.Clear(); Points2.Clear();
TolInit*=10.0; TolInit*=10.0;
EvalParametersBis(myBis,AC1,Params,TolInit); EvalParametersBis(myBis,AC1,Params,TolInit);
EvalParametersBis(myBis,AC2,Points2,TolInit); EvalParametersBis(myBis,AC2,Points2,TolInit);
SeanceDeRattrapage++; SeanceDeRattrapage++;
} }
#ifdef DEB #ifdef OCCT_DEBUG
if(SeanceDeRattrapage != 0) cout << "SeanceDeRattrapage = " << SeanceDeRattrapage << endl; if(SeanceDeRattrapage != 0) cout << "SeanceDeRattrapage = " << SeanceDeRattrapage << endl;
if(SeanceDeRattrapage == nn) { if(SeanceDeRattrapage == nn) {
cout << "BRepFill_TrimEdgeTool: incoherent intersection" << endl; cout << "BRepFill_TrimEdgeTool: incoherent intersection" << endl;
@@ -387,7 +450,7 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
if(Params.Length() == 0 && Points2.Length() == 1) { if(Params.Length() == 0 && Points2.Length() == 1) {
//cout << "Params.Length() == 0 && Points2.Length() == 1" << endl; //cout << "Params.Length() == 0 && Points2.Length() == 1" << endl;
Standard_Real dmin; Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
Standard_Real tBis = Points2(1).X(); Standard_Real tBis = Points2(1).X();
gp_Pnt2d PBis = myBis.Value(tBis); gp_Pnt2d PBis = myBis.Value(tBis);
@@ -395,19 +458,26 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
gp_Pnt2d PC = AC1.Value(t); gp_Pnt2d PC = AC1.Value(t);
dmin = PC.SquareDistance(PBis); dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.); gp_Pnt P(tBis, t, 0.);
Params.Append(P); if(dmin < dmax)
{
Params.Append(P);
}
t = AC1.LastParameter(); t = AC1.LastParameter();
PC = AC1.Value(t); PC = AC1.Value(t);
if(dmin > PC.SquareDistance(PBis)) { Standard_Real dmin1 = PC.SquareDistance(PBis);
if(dmin > dmin1 && dmin1 < dmax ) {
P.SetY(t); P.SetY(t);
Params.SetValue(1,P); if(Params.IsEmpty())
Params.Append(P);
else
Params.SetValue(1,P);
} }
} }
else if(Params.Length() == 1 && Points2.Length() == 0) { else if(Params.Length() == 1 && Points2.Length() == 0) {
//cout << "Params.Length() == 1 && Points2.Length() == 0" << endl; //cout << "Params.Length() == 1 && Points2.Length() == 0" << endl;
Standard_Real dmin; Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
Standard_Real tBis = Params(1).X(); Standard_Real tBis = Params(1).X();
gp_Pnt2d PBis = myBis.Value(tBis); gp_Pnt2d PBis = myBis.Value(tBis);
@@ -415,13 +485,20 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
gp_Pnt2d PC = AC2.Value(t); gp_Pnt2d PC = AC2.Value(t);
dmin = PC.SquareDistance(PBis); dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.); gp_Pnt P(tBis, t, 0.);
Points2.Append(P); if(dmin < dmax)
{
Points2.Append(P);
}
t = AC2.LastParameter(); t = AC2.LastParameter();
PC = AC2.Value(t); PC = AC2.Value(t);
if(dmin > PC.SquareDistance(PBis)) { Standard_Real dmin1 = PC.SquareDistance(PBis);
if(dmin > dmin1 && dmin1 < dmax ) {
P.SetY(t); P.SetY(t);
Points2.SetValue(1,P); if(Points2.IsEmpty())
Points2.Append(P);
else
Points2.SetValue(1,P);
} }
} }
@@ -452,18 +529,18 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
Standard_Real P1xP2x=Abs( P1.X() - P2.X()); Standard_Real P1xP2x=Abs( P1.X() - P2.X());
if ( P1xP2x > Tol ) { if ( P1xP2x > Tol ) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: no same parameter on the bissectrice" << endl; cout << "BRepFill_TrimEdgeTool: no same parameter on the bissectrice" << endl;
#endif #endif
if(P1xP2x>TolInit) { if(P1xP2x>TolInit) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl; cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl;
#endif #endif
i++; i++;
} }
else { else {
if ( P1.X() < P2.X()) Params.Remove(i); if ( P1.X() < P2.X()) Params.Remove(i);
else Points2.Remove(i); else Points2.Remove(i);
} }
} }
else i++; else i++;
@@ -492,10 +569,10 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
//======================================================================= //=======================================================================
void BRepFill_TrimEdgeTool::AddOrConfuse(const Standard_Boolean Start, void BRepFill_TrimEdgeTool::AddOrConfuse(const Standard_Boolean Start,
const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2, const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params) TColgp_SequenceOfPnt& Params)
const const
{ {
Standard_Boolean ToProj = Standard_True; Standard_Boolean ToProj = Standard_True;
gp_Pnt2d PBis; gp_Pnt2d PBis;
@@ -523,7 +600,7 @@ const
} }
if (ToProj) { if (ToProj) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << " project extremity bissectrice on parallel."<<endl; cout << " project extremity bissectrice on parallel."<<endl;
#endif #endif
@@ -537,32 +614,32 @@ const
Geom2dAPI_ProjectPointOnCurve Projector2(PBis,C2,f2,l2); Geom2dAPI_ProjectPointOnCurve Projector2(PBis,C2,f2,l2);
if (Projector1.NbPoints() == 0) { if (Projector1.NbPoints() == 0) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl; cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif #endif
return; return;
} }
if (!Projector1.NearestPoint().IsEqual(PBis,Tol)) { if (!Projector1.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB #ifdef OCCT_DEBUG
cout <<"Incorrect solution in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl; cout <<"Incorrect solution in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif #endif
return; return;
} }
if (Projector2.NbPoints() == 0) { if (Projector2.NbPoints() == 0) {
#ifdef DEB #ifdef OCCT_DEBUG
cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl; cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif #endif
return; return;
} }
if (!Projector2.NearestPoint().IsEqual(PBis,Tol)) { if (!Projector2.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB #ifdef OCCT_DEBUG
cout <<" Mauvaisesolution dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl; cout <<" Mauvaisesolution dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif #endif
return; return;
} }
gp_Pnt PInt (0, gp_Pnt PInt (0,
Projector1.LowerDistanceParameter(), Projector1.LowerDistanceParameter(),
Projector2.LowerDistanceParameter()); Projector2.LowerDistanceParameter());
if (Start) { if (Start) {
PInt.SetX (myBis.FirstParameter()); PInt.SetX (myBis.FirstParameter());
Params.Prepend(PInt); Params.Prepend(PInt);
@@ -581,10 +658,10 @@ const
Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
{ {
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin // Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
// Standard_Real Dist; // Standard_Real Dist;
Standard_Real Dist = RealLast(); Standard_Real Dist = RealLast();
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End // Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
if (isPoint1) if (isPoint1)
Dist = P.Distance(myP1); Dist = P.Distance(myP1);
else if (isPoint2) else if (isPoint2)
@@ -594,26 +671,26 @@ Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
if (Projector.NbPoints() > 0) { if (Projector.NbPoints() > 0) {
Dist = Projector.LowerDistance(); Dist = Projector.LowerDistance();
} }
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin // Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
// else { // else {
// gp_Pnt2d PF = myC1->Value(myC1->FirstParameter()); // gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
// gp_Pnt2d PL = myC1->Value(myC1->LastParameter()); // gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
// Dist = Min (P.Distance(PF),P.Distance(PL)); // Dist = Min (P.Distance(PF),P.Distance(PL));
// } // }
// Check of distances between P and first and last point of the first curve // Check of distances between P and first and last point of the first curve
// should be performed in any case, despite of the results of projection. // should be performed in any case, despite of the results of projection.
gp_Pnt2d PF = myC1->Value(myC1->FirstParameter()); gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
gp_Pnt2d PL = myC1->Value(myC1->LastParameter()); gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
Standard_Real aDistMin = Min (P.Distance(PF),P.Distance(PL)); Standard_Real aDistMin = Min (P.Distance(PF),P.Distance(PL));
if (Dist > aDistMin) if (Dist > aDistMin)
Dist = aDistMin; Dist = aDistMin;
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End // Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
} }
// return (Dist < Abs(myOffset); // return (Dist < Abs(myOffset);
// return (Dist < Abs(myOffset) + Precision::Confusion()); // return (Dist < Abs(myOffset) + Precision::Confusion());
return (Dist < Abs(myOffset) - Precision::Confusion()); return (Dist < Abs(myOffset) - Precision::Confusion());
} }

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,9 @@
#include <Precision.hxx> #include <Precision.hxx>
#include <math_Matrix.hxx> #include <math_Matrix.hxx>
#include <math_Vector.hxx> #include <math_Vector.hxx>
#include <math_Gauss.hxx> //#include <math_Gauss.hxx>
#include <math_SVD.hxx>
#include <math_Jacobi.hxx>
#include <gp_Lin.hxx> #include <gp_Lin.hxx>
#include <gp_Circ.hxx> #include <gp_Circ.hxx>
@@ -45,6 +47,8 @@
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <BRep_Builder.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <GeomLib.hxx> #include <GeomLib.hxx>
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
@@ -58,7 +62,7 @@
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints, static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
const Handle(Geom_Plane)& thePlane) const Handle(Geom_Plane)& thePlane)
{ {
Standard_Real dfMaxDist=0.; Standard_Real dfMaxDist=0.;
Standard_Real a,b,c,d, dist; Standard_Real a,b,c,d, dist;
@@ -79,9 +83,9 @@ static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
// the first vertex of theEdge2 in parametric space of theFace // the first vertex of theEdge2 in parametric space of theFace
//======================================================================= //=======================================================================
inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1, inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
const TopoDS_Edge& theEdge2, const TopoDS_Edge& theEdge2,
const Handle(Geom_Surface)& theSurface, const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation) const TopLoc_Location& theLocation)
{ {
Standard_Real f,l; Standard_Real f,l;
//TopLoc_Location aLoc; //TopLoc_Location aLoc;
@@ -110,8 +114,8 @@ inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
//======================================================================= //=======================================================================
static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape, static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape,
const Handle(Geom_Surface)& theSurface, const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation) const TopLoc_Location& theLocation)
{ {
try try
{ {
@@ -164,9 +168,9 @@ BRepLib_FindSurface::BRepLib_FindSurface()
//purpose : //purpose :
//======================================================================= //=======================================================================
BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S, BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
const Standard_Real Tol, const Standard_Real Tol,
const Standard_Boolean OnlyPlane, const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed) const Standard_Boolean OnlyClosed)
{ {
Init(S,Tol,OnlyPlane,OnlyClosed); Init(S,Tol,OnlyPlane,OnlyClosed);
} }
@@ -175,9 +179,9 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepLib_FindSurface::Init(const TopoDS_Shape& S, void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
const Standard_Real Tol, const Standard_Real Tol,
const Standard_Boolean OnlyPlane, const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed) const Standard_Boolean OnlyClosed)
{ {
myTolerance = Tol; myTolerance = Tol;
myTolReached = 0.; myTolReached = 0.;
@@ -331,27 +335,15 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
continue; continue;
else else
{ {
const Standard_Integer aNbPolMax = 200;
Standard_Integer incr = 1;
if(iNbPol > aNbPolMax)
{
Standard_Integer nb = iNbPol;
while(nb > aNbPolMax)
{
incr++;
nb = (iNbPol-1) / incr;
}
}
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol); Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1()); GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext; gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext; Standard_Real dfDistPrev = 0., dfDistNext;
Standard_Integer iPol; for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
for (iPol = 1; iPol <= iNbPol; iPol += incr)
{ {
if (iPol <= iNbPol - incr) if (iPol<iNbPol)
{ {
aPoleNext = aPoles->Value(iPol+incr); aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext); dfDistNext = aPolePrev.Distance(aPoleNext);
} }
else else
@@ -436,50 +428,115 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
aMat(1,1)+=w*p.X()*p.X(); aMat(1,1)+=w*p.X()*p.X();
aMat(1,2)+=w*p.X()*p.Y(); aMat(1,2)+=w*p.X()*p.Y();
aMat(1,3)+=w*p.X()*p.Z(); aMat(1,3)+=w*p.X()*p.Z();
aMat(2,1)+=w*p.Y()*p.X(); //
aMat(2,2)+=w*p.Y()*p.Y(); aMat(2,2)+=w*p.Y()*p.Y();
aMat(2,3)+=w*p.Y()*p.Z(); aMat(2,3)+=w*p.Y()*p.Z();
aMat(3,1)+=w*p.Z()*p.X(); //
aMat(3,2)+=w*p.Z()*p.Y();
aMat(3,3)+=w*p.Z()*p.Z(); aMat(3,3)+=w*p.Z()*p.Z();
aVec(1) -= w*p.X(); }
aVec(2) -= w*p.Y(); aMat(2,1) = aMat(1,2);
aVec(3) -= w*p.Z(); aMat(3,1) = aMat(1,3);
aMat(3,2) = aMat(2,3);
//
math_Jacobi anEignval(aMat);
math_Vector anEVals(1,3);
Standard_Boolean isSolved = anEignval.IsDone();
Standard_Integer isol = 0;
if(isSolved)
{
anEVals = anEignval.Values();
//We need vector with eigenvalue ~ 0.
Standard_Real anEMin = RealLast();
Standard_Real anEMax = -anEMin;
for(i = 1; i <= 3; ++i)
{
Standard_Real anE = Abs(anEVals(i));
if(anEMin > anE)
{
anEMin = anE;
isol = i;
}
if(anEMax < anE)
{
anEMax = anE;
}
}
if(isol == 0)
{
isSolved = Standard_False;
}
else
{
Standard_Real eps = Epsilon(anEMax);
if(anEMin <= eps)
{
anEignval.Vector(isol, aVec);
}
else
{
//try using vector product of other axes
Standard_Integer ind[2] = {0,0};
for(i = 1; i <= 3; ++i)
{
if(i == isol)
{
continue;
}
if(ind[0] == 0)
{
ind[0] = i;
continue;
}
if(ind[1] == 0)
{
ind[1] = i;
continue;
}
}
math_Vector aVec1(1, 3, 0.), aVec2(1, 3, 0.);
anEignval.Vector(ind[0], aVec1);
anEignval.Vector(ind[1], aVec2);
gp_Vec aV1(aVec1(1), aVec1(2), aVec1(3));
gp_Vec aV2(aVec2(1), aVec2(2), aVec2(3));
gp_Vec aN = aV1^ aV2;
aVec(1) = aN.X();
aVec(2) = aN.Y();
aVec(3) = aN.Z();
}
if (aVec.Norm2() < gp::Resolution()) {
isSolved = Standard_False;
}
}
} }
// Solve the system of equations to get plane coefficients
math_Gauss aSolver(aMat);
Standard_Boolean isSolved = aSolver.IsDone();
// //
// let us be more tolerant (occ415) // let us be more tolerant (occ415)
Standard_Real dfDist = RealLast(); Standard_Real dfDist = RealLast();
Handle(Geom_Plane) aPlane; Handle(Geom_Plane) aPlane;
// //
if (isSolved) { if (isSolved) {
aSolver.Solve(aVec); //Plane normal can have two directions, direction is chosen
if (aVec.Norm2()<gp::Resolution()) { //according to direction of eigenvector
isSolved = Standard_False; gp_Vec anN(aVec(1), aVec(2), aVec(3));
} aPlane = new Geom_Plane(aBaryCenter,anN);
}
//
if (isSolved) {
aPlane = new Geom_Plane(aBaryCenter,gp_Dir(aVec(1),aVec(2),aVec(3)));
dfDist = Controle (aPoints, aPlane); dfDist = Controle (aPoints, aPlane);
} }
// //
if (!isSolved || myTolerance < dfDist) { if (!isSolved || myTolerance < dfDist) {
gp_Pnt aFirstPnt=aPoints(1); gp_Pnt aFirstPnt=aPoints(1);
for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) { for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) {
const gp_Pnt& aNextPnt = aPoints(iPoint); gp_Vec aDir(aFirstPnt,aPoints(iPoint));
gp_Vec aDir(aFirstPnt, aNextPnt);
Standard_Real dfSide=aDir.Magnitude(); Standard_Real dfSide=aDir.Magnitude();
if (dfSide<myTolerance) { if (dfSide<myTolerance) {
continue; // degeneration continue; // degeneration
} }
for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) { for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
if (aCross.Magnitude() > dfSide*myTolerance) { if (aCross.Magnitude() > dfSide*myTolerance) {
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aFirstPnt, aCross); Handle(Geom_Plane) aPlane2 = new Geom_Plane(aBaryCenter, aCross);
Standard_Real dfDist2 = Controle (aPoints, aPlane2); Standard_Real dfDist2 = Controle (aPoints, aPlane2);
if (dfDist2 < myTolerance) { if (dfDist2 < myTolerance) {
myTolReached = dfDist2; myTolReached = dfDist2;
@@ -504,6 +561,23 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
//myTolReached = dfDist; //myTolReached = dfDist;
//XXt //XXt
mySurface = aPlane; mySurface = aPlane;
//If S is wire, try to orient surface according to orientation of wire.
if(S.ShapeType() == TopAbs_WIRE && S.Closed())
{
//
TopoDS_Wire aW = TopoDS::Wire(S);
TopoDS_Face aTmpFace = BRepLib_MakeFace(mySurface, Precision::Confusion());
BRep_Builder BB;
BB.Add(aTmpFace, aW);
BRepTopAdaptor_FClass2d FClass(aTmpFace, 0.);
if ( FClass.PerformInfinitePoint() == TopAbs_IN )
{
gp_Dir aN = aPlane->Position().Direction();
aN.Reverse();
mySurface = new Geom_Plane(aPlane->Position().Location(), aN);
}
}
} }
//XXf //XXf
myTolReached = dfDist; myTolReached = dfDist;
@@ -558,4 +632,3 @@ TopLoc_Location BRepLib_FindSurface::Location() const
return myLocation; return myLocation;
} }

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -39,14 +39,27 @@
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRepLib.hxx> #include <BRepLib.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx> #include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <GCE2d_MakeArcOfCircle.hxx>
#include <GCE2d_MakeSegment.hxx>
//
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:14 2002 Begin // Modified by Sergey KHROMOV - Thu Dec 5 10:38:14 2002 Begin
static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve, static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
const TopoDS_Face &theFace, const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst, const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast); const TopoDS_Vertex &theVLast);
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:16 2002 End // Modified by Sergey KHROMOV - Thu Dec 5 10:38:16 2002 End
//
static GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d);
static void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
const Standard_Boolean isFirst);
//
//======================================================================= //=======================================================================
//function : BRepMAT2d_Explorer //function : BRepMAT2d_Explorer
//purpose : //purpose :
@@ -79,7 +92,7 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
TopoDS_Face F = TopoDS::Face(aFace); TopoDS_Face F = TopoDS::Face(aFace);
F.Orientation(TopAbs_FORWARD); F.Orientation(TopAbs_FORWARD);
TopExp_Explorer Exp (F,TopAbs_WIRE); TopExp_Explorer Exp (F,TopAbs_WIRE);
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin // Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F); Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
TopoDS_Face aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion()); TopoDS_Face aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
@@ -91,8 +104,8 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
BRepLib::BuildCurves3d(aNewF); BRepLib::BuildCurves3d(aNewF);
myModifShapes.Add(aFace, aNewF); myModifShapes.Add(aFace, aNewF);
// CheckConnection(); // CheckConnection();
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End // Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
} }
//======================================================================= //=======================================================================
@@ -101,43 +114,43 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
//======================================================================= //=======================================================================
void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
const TopoDS_Face& aFace, const TopoDS_Face& aFace,
TopoDS_Face& aNewFace) TopoDS_Face& aNewFace)
{ {
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin // Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
// This method is totally rewroted to include check // This method is totally rewroted to include check
// of connection and creation of a new spine. // of connection and creation of a new spine.
NewContour(); NewContour();
myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False; myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
// Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin // Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
// Taking into account side of bisecting loci construction. // Taking into account side of bisecting loci construction.
// TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD)); // TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
// BRepTools_WireExplorer anExp(aWFwd, aFace); // BRepTools_WireExplorer anExp(aWFwd, aFace);
BRepTools_WireExplorer anExp(Spine, aFace); BRepTools_WireExplorer anExp(Spine, aFace);
// Modified by skv - Wed Jun 23 12:23:02 2004 Integration End // Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
TopTools_IndexedDataMapOfShapeShape anOldNewE; TopTools_IndexedDataMapOfShapeShape anOldNewE;
if (!anExp.More()) if (!anExp.More())
return; return;
TopoDS_Edge aFirstEdge = anExp.Current(); TopoDS_Edge aFirstEdge = anExp.Current();
TopoDS_Edge aPrevEdge = aFirstEdge;
Standard_Real UFirst,ULast, aD; Standard_Real UFirst,ULast, aD;
Handle(Geom2d_BSplineCurve) BCurve;
Handle(Geom2d_Curve) C2d; Handle(Geom2d_Curve) C2d;
Handle(Geom2d_TrimmedCurve) CT2d; Handle(Geom2d_TrimmedCurve) CT2d;
Handle(Geom2d_TrimmedCurve) aFirstCurve; Handle(Geom2d_TrimmedCurve) aFirstCurve;
gp_Pnt2d aPFirst; gp_Pnt2d aPFirst;
gp_Pnt2d aPLast; gp_Pnt2d aPLast;
gp_Pnt2d aPCurFirst; gp_Pnt2d aPCurFirst;
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin // Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
// Set the confusion tolerance in accordance with the further algo // Set the confusion tolerance in accordance with the further algo
// Standard_Real aTolConf = Precision::Confusion(); // Standard_Real aTolConf = Precision::Confusion();
Standard_Real aTolConf = 1.e-8; Standard_Real aTolConf = 1.e-8;
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration End // Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
Standard_Boolean isModif = Standard_False; Standard_Boolean isModif = Standard_False;
// Treatment of the first edge of a wire. // Treatment of the first edge of a wire.
anOldNewE.Add(aFirstEdge, aFirstEdge); anOldNewE.Add(aFirstEdge, aFirstEdge);
C2d = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast); C2d = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast);
CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast); CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
@@ -152,7 +165,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
aFirstCurve = CT2d; aFirstCurve = CT2d;
anExp.Next(); anExp.Next();
// Treatment of the next edges: // Treatment of the next edges:
for (; anExp.More(); anExp.Next()) { for (; anExp.More(); anExp.Next()) {
TopoDS_Edge anEdge = anExp.Current(); TopoDS_Edge anEdge = anExp.Current();
@@ -175,64 +188,111 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
// code should be rewritten. // code should be rewritten.
isModif = Standard_True; isModif = Standard_True;
// //
//modified by NIZNHY-PKV Tue Aug 7 09:14:03 2007f Standard_Integer aNbC = theCurves.Value(currentContour).Length();
//BCurve = Geom2dConvert::CurveToBSplineCurve(CT2d); Handle(Geom2d_BoundedCurve) CPrev =
BCurve=Geom2dConvert::CurveToBSplineCurve(CT2d, Convert_QuasiAngular); Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
//modified by NIZNHY-PKV Tue Aug 7 09:14:07 2007t //
GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
GeomAbs_CurveType TCCurr = GetCurveType(CT2d);
//
if(TCCurr <= TCPrev)
{
AdjustCurveEnd(CT2d, aPLast, Standard_True);
// Creation of new edge.
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
BCurve->SetPole(1, aPLast); if (anEdge.Orientation() == TopAbs_FORWARD)
CT2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(), aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
BCurve->LastParameter()); else
aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
// Creation of new edge. aNewEdge.Orientation(anEdge.Orientation());
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
if (anEdge.Orientation() == TopAbs_FORWARD) anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl); }
else else
aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl); {
gp_Pnt2d aP = CT2d->Value(CT2d->FirstParameter());
AdjustCurveEnd(CPrev, aP, Standard_False);
theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
//Change previous edge
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
aNewEdge.Orientation(anEdge.Orientation()); if (aPrevEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aPrevEdge.Orientation());
anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
}
anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
} }
aPLast = CT2d->Value(CT2d->LastParameter()); aPLast = CT2d->Value(CT2d->LastParameter());
Add(CT2d); Add(CT2d);
aPrevEdge = anEdge;
} }
// Check of the distance between the first and the last point of wire // Check of the distance between the first and the last point of wire
// if the wire is closed. // if the wire is closed.
if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) { if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
isModif = Standard_True; isModif = Standard_True;
//
//modified by NIZNHY-PKV Tue Aug 7 09:20:08 2007f Standard_Integer aNbC = theCurves.Value(currentContour).Length();
//Handle(Geom2d_BSplineCurve) Handle(Geom2d_BoundedCurve) CPrev =
//BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve); Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve, Convert_QuasiAngular); //
//modified by NIZNHY-PKV Tue Aug 7 09:20:11 2007t GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
GeomAbs_CurveType TCCurr = GetCurveType(aFirstCurve);
BCurve->SetPole(1, aPLast); //
aFirstCurve = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(), if(TCCurr <= TCPrev)
BCurve->LastParameter()); {
AdjustCurveEnd(aFirstCurve, aPLast, Standard_True);
theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve; theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve;
// Creation of new edge.
// Creation of new first edge.
TopoDS_Edge aNewEdge; TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge); TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge); TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge);
if (aFirstEdge.Orientation() == TopAbs_FORWARD) if (aFirstEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl); aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
else else
aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl); aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aFirstEdge.Orientation()); aNewEdge.Orientation(aFirstEdge.Orientation());
anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge; anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge;
} }
else
{
gp_Pnt2d aP = aFirstCurve->Value(aFirstCurve->FirstParameter());
AdjustCurveEnd(CPrev, aP, Standard_False);
theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
//Change previous edge
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
if (aPrevEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aPrevEdge.Orientation());
anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
}
}
TopoDS_Wire aNewWire; TopoDS_Wire aNewWire;
BRep_Builder aBuilder; BRep_Builder aBuilder;
@@ -263,7 +323,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
aNewWire = Spine; aNewWire = Spine;
aBuilder.Add(aNewFace, aNewWire); aBuilder.Add(aNewFace, aNewWire);
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End // Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
} }
//======================================================================= //=======================================================================
@@ -302,10 +362,10 @@ void BRepMAT2d_Explorer::Clear()
{ {
theCurves.Clear() ; theCurves.Clear() ;
currentContour = 0; currentContour = 0;
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin // Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin
myIsClosed.Clear(); myIsClosed.Clear();
myModifShapes.Clear(); myModifShapes.Clear();
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End // Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End
} }
@@ -318,9 +378,9 @@ void BRepMAT2d_Explorer::NewContour()
{ {
TColGeom2d_SequenceOfCurve Contour; TColGeom2d_SequenceOfCurve Contour;
theCurves.Append(Contour); theCurves.Append(Contour);
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin // Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin
myIsClosed.Append(Standard_False); myIsClosed.Append(Standard_False);
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End // Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End
currentContour ++ ; currentContour ++ ;
} }
@@ -353,7 +413,7 @@ Standard_Integer BRepMAT2d_Explorer::NumberOfContours() const
Standard_Integer BRepMAT2d_Explorer::NumberOfCurves Standard_Integer BRepMAT2d_Explorer::NumberOfCurves
(const Standard_Integer IndexContour) (const Standard_Integer IndexContour)
const const
{ {
return theCurves.Value(IndexContour).Length(); return theCurves.Value(IndexContour).Length();
} }
@@ -421,7 +481,7 @@ TopoDS_Shape BRepMAT2d_Explorer::Shape() const
const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour
(const Standard_Integer IC) (const Standard_Integer IC)
const const
{ {
return theCurves.Value(IC); return theCurves.Value(IC);
} }
@@ -434,7 +494,7 @@ const
//======================================================================= //=======================================================================
Standard_Boolean BRepMAT2d_Explorer::IsModified Standard_Boolean BRepMAT2d_Explorer::IsModified
(const TopoDS_Shape &aShape) const (const TopoDS_Shape &aShape) const
{ {
if (myModifShapes.Contains(aShape)) { if (myModifShapes.Contains(aShape)) {
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape); const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -452,7 +512,7 @@ Standard_Boolean BRepMAT2d_Explorer::IsModified
//======================================================================= //=======================================================================
TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape
(const TopoDS_Shape &aShape) const (const TopoDS_Shape &aShape) const
{ {
if (myModifShapes.Contains(aShape)) { if (myModifShapes.Contains(aShape)) {
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape); const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -479,9 +539,9 @@ const TColStd_SequenceOfBoolean &BRepMAT2d_Explorer::GetIsClosed() const
//======================================================================= //=======================================================================
TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve, TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
const TopoDS_Face &theFace, const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst, const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast) const TopoDS_Vertex &theVLast)
{ {
TopoDS_Edge aNewEdge; TopoDS_Edge aNewEdge;
BRep_Builder aBuilder; BRep_Builder aBuilder;
@@ -498,3 +558,85 @@ TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
return aNewEdge; return aNewEdge;
} }
// Modified by Sergey KHROMOV - Wed Mar 6 17:40:14 2002 End // Modified by Sergey KHROMOV - Wed Mar 6 17:40:14 2002 End
//
//=======================================================================
//function : GetCurveType
//purpose : Get curve type.
//=======================================================================
GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d)
{
GeomAbs_CurveType aTypeCurve = GeomAbs_OtherCurve;
Handle(Standard_Type) TheType = theC2d->DynamicType();
if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
TheType = (*((Handle(Geom2d_TrimmedCurve)*)&theC2d))->BasisCurve()->DynamicType();
}
if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
aTypeCurve = GeomAbs_Circle;
}
else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
aTypeCurve = GeomAbs_Line;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
aTypeCurve = GeomAbs_Ellipse;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
aTypeCurve = GeomAbs_Parabola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
aTypeCurve = GeomAbs_Hyperbola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
aTypeCurve = GeomAbs_BezierCurve;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
aTypeCurve = GeomAbs_BSplineCurve;
}
else {
aTypeCurve = GeomAbs_OtherCurve;
}
return aTypeCurve;
}
//=======================================================================
//function : AdjustCurveEnd
//purpose :
//=======================================================================
void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
const Standard_Boolean isFirst)
{
GeomAbs_CurveType aType = GetCurveType(theC2d);
if(aType == GeomAbs_Line)
{
//create new line
if(isFirst)
{
gp_Pnt2d aP = theC2d->Value(theC2d->LastParameter());
theC2d = GCE2d_MakeSegment(theP, aP);
}
else
{
gp_Pnt2d aP = theC2d->Value(theC2d->FirstParameter());
theC2d = GCE2d_MakeSegment(aP, theP);
}
}
else
{
//Convert to BSpline and adjust first pole
Handle(Geom2d_BSplineCurve) BCurve =
Geom2dConvert::CurveToBSplineCurve(theC2d, Convert_QuasiAngular);
if(isFirst)
{
BCurve->SetPole(1, theP);
theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
}
else
{
BCurve->SetPole(BCurve->NbPoles(), theP);
theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
}
}
}

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -21,6 +21,7 @@
#include <Geom2d_Point.hxx> #include <Geom2d_Point.hxx>
#include <Geom2d_CartesianPoint.hxx> #include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <gp.hxx> #include <gp.hxx>
#include <gp_Pnt2d.hxx> #include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx> #include <gp_Vec2d.hxx>
@@ -31,21 +32,27 @@
#include <Bisector_BisecAna.hxx> #include <Bisector_BisecAna.hxx>
#include <Bisector_BisecPC.hxx> #include <Bisector_BisecPC.hxx>
#include <Bisector_BisecCC.hxx> #include <Bisector_BisecCC.hxx>
#include <GCE2d_MakeSegment.hxx>
/* #ifdef DEB
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx> #include <DrawTrSurf.hxx>
static char tname[100]; #pragma comment(lib, "TKDraw.lib")
static Standard_CString name = tname ; static char name[100];
static Standard_Integer nbb = 0; static Standard_Integer nbb = 0;
*/ static Standard_Boolean Affich = Standard_False;
#endif
#endif
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C, static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U, Standard_Real U,
Standard_Real& R); Standard_Real& R);
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis, static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst, Standard_Real& UFirst,
Standard_Real& ULast); Standard_Real& ULast);
//============================================================================= //=============================================================================
//function : Empty Constructor //function : Empty Constructor
//============================================================================= //=============================================================================
@@ -66,48 +73,115 @@ Bisector_Bisec::Bisector_Bisec()
//=========================================================================== //===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve , void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Curve)& asecondcurve , const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint , const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector , const gp_Vec2d& asecondvector ,
const Standard_Real adirection , const Standard_Real adirection ,
const Standard_Real tolerance , const Standard_Real tolerance ,
const Standard_Boolean oncurve ) const Standard_Boolean oncurve )
{ {
Handle(Standard_Type) Type1 = afirstcurve ->DynamicType(); Handle(Standard_Type) Type1 = afirstcurve ->DynamicType();
Handle(Standard_Type) Type2 = asecondcurve->DynamicType(); Handle(Standard_Type) Type2 = asecondcurve->DynamicType();
Handle(Bisector_Curve) Bis; Handle(Bisector_Curve) Bis;
Standard_Real UFirst,ULast; Standard_Real UFirst,ULast;
//gp_XY ref1( -65.9325, -200.28055 );
//gp_XY ref2(50.00154, -201.54198 );
//gp_XY p1 = afirstcurve->Value(afirstcurve->FirstParameter()).XY();
//gp_XY p2 = afirstcurve->Value(afirstcurve->LastParameter()).XY();
//if(p1.IsEqual(ref1, 1.e-5) && p2.IsEqual(ref2,1.e-5))
//{
// cout << "111" << endl;
//}
//p1 = asecondcurve->Value(asecondcurve->FirstParameter()).XY();
//p2 = asecondcurve->Value(asecondcurve->LastParameter()).XY();
//if(p1.IsEqual(ref1, 1.e-5) && p2.IsEqual(ref2,1.e-5))
//{
// cout << "222" << endl;
//}
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) { if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve) Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType(); ->BasisCurve()->DynamicType();
} }
if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) { if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve) Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType(); ->BasisCurve()->DynamicType();
}
Handle(Geom2d_Curve) afirstcurve1 = afirstcurve;
Handle(Geom2d_Curve) asecondcurve1 = asecondcurve;
if(Type1 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(afirstcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(afirstcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
afirstcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type1 = STANDARD_TYPE(Geom2d_Line);
}
}
}
if(Type2 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(asecondcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(asecondcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
asecondcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type2 = STANDARD_TYPE(Geom2d_Line);
}
}
} }
if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) && if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) &&
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) ) { (Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) )
{
//------------------------------------------------------------------ //------------------------------------------------------------------
// Analytic Bissectrice. // Analytic Bissectrice.
//------------------------------------------------------------------ //------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna(); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve , BisAna->Perform(afirstcurve1 ,
asecondcurve , asecondcurve1 ,
apoint , apoint ,
afirstvector , afirstvector ,
asecondvector , asecondvector ,
adirection , adirection ,
tolerance , tolerance ,
oncurve ); oncurve );
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} }
else { else {
Standard_Boolean IsLine = Standard_False; Standard_Boolean IsLine = Standard_False;
if (oncurve) { if (oncurve) {
gp_Dir2d Fd(afirstvector); gp_Dir2d Fd(afirstvector);
@@ -115,7 +189,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//if (Fd.Dot(Sd) < Precision::Angular() - 1.) { //if (Fd.Dot(Sd) < Precision::Angular() - 1.) {
//if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch //if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch
if (Fd.Dot(Sd) < Sqrt(2.*Precision::Angular()) - 1.) if (Fd.Dot(Sd) < Sqrt(2.*Precision::Angular()) - 1.)
IsLine = Standard_True; IsLine = Standard_True;
} }
if (IsLine) { if (IsLine) {
//------------------------------------------------------------------ //------------------------------------------------------------------
@@ -125,7 +199,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint); Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite()); BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
@@ -137,58 +211,78 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
// Bissectrice algo // Bissectrice algo
//------------------------------------------------------------------- //-------------------------------------------------------------------
Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC(); Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC();
BisCC -> Perform(asecondcurve, BisCC -> Perform(asecondcurve1,
afirstcurve , afirstcurve1 ,
adirection , adirection ,
adirection , adirection ,
apoint); apoint);
if (BisCC -> IsEmpty()) { if (BisCC -> IsEmpty()) {
// bissectrice is empty. a point is projected at the end of the guide curve. // bissectrice is empty. a point is projected at the end of the guide curve.
// Construction of a false bissectrice. // Construction of a false bissectrice.
// modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___ // modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
gp_Dir2d dir1(afirstvector), dir2(asecondvector); gp_Pnt2d aP1 = afirstcurve1->Value(afirstcurve1->LastParameter());
Standard_Real gp_Pnt2d aP2 = asecondcurve1->Value(asecondcurve1->FirstParameter());
Nx = - dir1.X() - dir2.X(), gp_Pnt2d aPm(.5*(aP1.XY()+aP2.XY()));
Ny = - dir1.Y() - dir2.Y(); Standard_Real Nx, Ny;
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) { if(aPm.Distance(apoint) > 10.*Precision::Confusion())
Nx = - afirstvector.Y(); {
Ny = afirstvector.X(); Nx = apoint.X() - aPm.X();
} Ny = apoint.Y() - aPm.Y();
//gp_Dir2d N ( - adirection*afirstvector.Y(), adirection*afirstvector.X()); if(adirection < 0)
gp_Dir2d N ( adirection*Nx, adirection*Ny); {
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___ Nx = -Nx;
Ny = -Ny;
}
}
else
{
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = -afirstvector.Y();
Ny = afirstvector.X();
}
}
gp_Dir2d N ( adirection*Nx, adirection*Ny);
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint); Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite()); BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} }
else { else {
UFirst = BisCC->FirstParameter(); UFirst = BisCC->FirstParameter();
ULast = BisCC->LastParameter (); ULast = BisCC->LastParameter ();
Bis = BisCC; Bis = BisCC;
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast); ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
} }
} }
} }
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast); thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
}
#endif
/*
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
} }
//=========================================================================== //===========================================================================
@@ -204,13 +298,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//=========================================================================== //===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve , void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Point)& asecondpoint , const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint , const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector, const gp_Vec2d& asecondvector,
const Standard_Real adirection , const Standard_Real adirection ,
const Standard_Real tolerance , const Standard_Real tolerance ,
const Standard_Boolean oncurve ) const Standard_Boolean oncurve )
{ {
//gp_Pnt2d SecondPnt = asecondpoint->Pnt2d(); //gp_Pnt2d SecondPnt = asecondpoint->Pnt2d();
@@ -220,7 +314,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) { if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve) Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType(); ->BasisCurve()->DynamicType();
} }
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) { if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
@@ -229,13 +323,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//------------------------------------------------------------------ //------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna(); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstcurve , BisAna -> Perform (afirstcurve ,
asecondpoint , asecondpoint ,
apoint , apoint ,
afirstvector , afirstvector ,
asecondvector , asecondvector ,
adirection , adirection ,
tolerance , tolerance ,
oncurve ); oncurve );
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
@@ -246,8 +340,8 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
if (oncurve) { if (oncurve) {
if (Bisector::IsConvex(afirstcurve,adirection) || if (Bisector::IsConvex(afirstcurve,adirection) ||
IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) { IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) {
IsLine = Standard_True; IsLine = Standard_True;
} }
} }
if (IsLine) { if (IsLine) {
@@ -271,64 +365,71 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
Handle(Geom2d_Curve) afirstcurvereverse = afirstcurve->Reversed(); Handle(Geom2d_Curve) afirstcurvereverse = afirstcurve->Reversed();
BisPC -> Perform(afirstcurvereverse , BisPC -> Perform(afirstcurvereverse ,
asecondpoint->Pnt2d(), asecondpoint->Pnt2d(),
- adirection ); - adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin // Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) { if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector); gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real Standard_Real
Nx = - dir1.X() - dir2.X(), Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y(); Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) { if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y(); Nx = - afirstvector.Y();
Ny = afirstvector.X(); Ny = afirstvector.X();
} }
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X()); // gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny); gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC); Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} else { } else {
// Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End // Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End
UFirst = BisPC->Parameter(apoint); UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter(); ULast = BisPC->LastParameter();
if(UFirst >= ULast) if(UFirst >= ULast)
{ {
//Standard_Real t = .9; //Standard_Real t = .9;
//UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast; //UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
//Extrapolate by line //Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X()); //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) ); gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V ); gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC); Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} }
else else
Bis = BisPC; Bis = BisPC;
} }
} }
} }
if(UFirst < Bis->FirstParameter())
UFirst = Bis->FirstParameter();
if(ULast > Bis->LastParameter())
ULast = Bis->LastParameter();
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast); thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/* #ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb ); sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve ); DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb ); sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, SecondPnt ); DrawTrSurf::Set( name, asecondpoint->Pnt2d() );
sprintf( name, "p%d", nbb ); sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint ); DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb ); sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector ); DrawTrSurf::Set( name, thebisector );
*/ }
#endif
} }
//=========================================================================== //===========================================================================
@@ -344,13 +445,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//=========================================================================== //===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint , void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Curve)& asecondcurve , const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint , const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector, const gp_Vec2d& asecondvector,
const Standard_Real adirection , const Standard_Real adirection ,
const Standard_Real tolerance , const Standard_Real tolerance ,
const Standard_Boolean oncurve ) const Standard_Boolean oncurve )
{ {
//gp_Pnt2d FirstPnt = afirstpoint->Pnt2d(); //gp_Pnt2d FirstPnt = afirstpoint->Pnt2d();
@@ -361,7 +462,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) { if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve) Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType(); ->BasisCurve()->DynamicType();
} }
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) { if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
@@ -370,26 +471,26 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//------------------------------------------------------------------ //------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna(); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstpoint , BisAna -> Perform (afirstpoint ,
asecondcurve , asecondcurve ,
apoint , apoint ,
afirstvector , afirstvector ,
asecondvector , asecondvector ,
adirection , adirection ,
tolerance , tolerance ,
oncurve ); oncurve );
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} }
else { else {
// Standard_Real UPoint = 0.; // Standard_Real UPoint = 0.;
Standard_Boolean IsLine = Standard_False; Standard_Boolean IsLine = Standard_False;
Standard_Real RC = Precision::Infinite(); Standard_Real RC = Precision::Infinite();
if (oncurve) { if (oncurve) {
if (Bisector::IsConvex(asecondcurve, adirection) || if (Bisector::IsConvex(asecondcurve, adirection) ||
IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) { IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
IsLine = Standard_True; IsLine = Standard_True;
} }
} }
if (IsLine) { if (IsLine) {
@@ -411,62 +512,69 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//------------------------------------------------------------------- //-------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC(); Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
BisPC -> Perform(asecondcurve , BisPC -> Perform(asecondcurve ,
afirstpoint->Pnt2d(), afirstpoint->Pnt2d(),
adirection ); adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin // Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) { if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector); gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real Standard_Real
Nx = - dir1.X() - dir2.X(), Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y(); Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) { if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y(); Nx = - afirstvector.Y();
Ny = afirstvector.X(); Ny = afirstvector.X();
} }
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X()); // gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny); gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC); Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} else { } else {
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End // Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
UFirst = BisPC->Parameter(apoint); UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter(); ULast = BisPC->LastParameter();
if(UFirst >= ULast) if(UFirst >= ULast)
{ {
//Extrapolate by line //Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X()); //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) ); gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V ); gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N); Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC); Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna (); Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL); BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint(); UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint(); ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna; Bis = BisAna;
} }
else else
Bis = BisPC; Bis = BisPC;
} }
} }
} }
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast); thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/* #ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb ); sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, FirstPnt ); DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb ); sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve ); DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb ); sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint ); DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb ); sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector ); DrawTrSurf::Set( name, thebisector );
*/ }
#endif
} }
//=========================================================================== //===========================================================================
@@ -481,29 +589,31 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//=========================================================================== //===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint , void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Point)& asecondpoint , const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint , const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector , const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector, const gp_Vec2d& asecondvector,
const Standard_Real adirection , const Standard_Real adirection ,
const Standard_Real tolerance , const Standard_Real tolerance ,
const Standard_Boolean oncurve ) const Standard_Boolean oncurve )
{ {
Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna(); Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna();
Bis -> Perform (afirstpoint , Bis -> Perform (afirstpoint ,
asecondpoint , asecondpoint ,
apoint , apoint ,
afirstvector , afirstvector ,
asecondvector , asecondvector ,
adirection , adirection ,
tolerance , tolerance ,
oncurve ); oncurve );
thebisector = new Geom2d_TrimmedCurve(Bis, thebisector = new Geom2d_TrimmedCurve(Bis,
Bis->ParameterOfStartPoint(), Bis->ParameterOfStartPoint(),
Bis->ParameterOfEndPoint()); Bis->ParameterOfEndPoint());
/* #ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb ); sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstpoint->Pnt2d() ); DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb ); sprintf( name, "c2_%d", nbb );
@@ -512,7 +622,8 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
DrawTrSurf::Set( name, apoint ); DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb ); sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector ); DrawTrSurf::Set( name, thebisector );
*/ }
#endif
} }
//============================================================================= //=============================================================================
@@ -539,8 +650,8 @@ const Handle(Geom2d_TrimmedCurve)& Bisector_Bisec::ChangeValue()
// replaced by a half-straight. // replaced by a half-straight.
//============================================================================= //=============================================================================
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis, static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst, Standard_Real& UFirst,
Standard_Real& ULast ) Standard_Real& ULast )
{ {
if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch
@@ -568,8 +679,8 @@ static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
//purpose : //purpose :
//============================================================================= //=============================================================================
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C, static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U, Standard_Real U,
Standard_Real& R) Standard_Real& R)
{ {
Standard_Real KF,KL; Standard_Real KF,KL;
Standard_Real US = C->FirstParameter(); Standard_Real US = C->FirstParameter();

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -46,24 +46,24 @@
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P, static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C, const Handle(Geom2d_Curve)& C,
Standard_Real& theParam); Standard_Real& theParam);
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C, static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U, Standard_Real U,
Standard_Real Tol) ; Standard_Real Tol) ;
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1, static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2, const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End); const Standard_Integer Start_End);
static Standard_Boolean DiscretPar(const Standard_Real DU, static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin, const Standard_Real EpsMin,
const Standard_Real EpsMax, const Standard_Real EpsMax,
const Standard_Integer NbMin, const Standard_Integer NbMin,
const Standard_Integer NbMax, const Standard_Integer NbMax,
Standard_Real& Eps, Standard_Real& Eps,
Standard_Integer& Nb); Standard_Integer& Nb);
//============================================================================= //=============================================================================
//function : //function :
@@ -80,11 +80,11 @@ Bisector_BisecCC::Bisector_BisecCC()
//purpose : //purpose :
//============================================================================= //=============================================================================
Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1, Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2, const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1, const Standard_Real Side1,
const Standard_Real Side2, const Standard_Real Side2,
const gp_Pnt2d& Origin, const gp_Pnt2d& Origin,
const Standard_Real DistMax) const Standard_Real DistMax)
{ {
Perform (Cu1,Cu2,Side1,Side2,Origin,DistMax); Perform (Cu1,Cu2,Side1,Side2,Origin,DistMax);
} }
@@ -94,11 +94,11 @@ Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
//purpose : //purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1, void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2, const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1, const Standard_Real Side1,
const Standard_Real Side2, const Standard_Real Side2,
const gp_Pnt2d& Origin, const gp_Pnt2d& Origin,
const Standard_Real DistMax) const Standard_Real DistMax)
{ {
isEmpty = Standard_False; isEmpty = Standard_False;
distMax = DistMax; distMax = DistMax;
@@ -122,7 +122,6 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
// Calculate first point of the polygon. // Calculate first point of the polygon.
//--------------------------------------------- //---------------------------------------------
Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U); Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U);
P = ValueByInt (U,UC1,UC2,Dist);
if(!isProjDone) if(!isProjDone)
{ {
@@ -130,6 +129,20 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
return; return;
} }
P = ValueByInt (U,UC1,UC2,Dist);
if(Dist < Precision::Confusion())
{
gp_Pnt2d aP1 = curve1->Value(UC1);
gp_Pnt2d aP2 = curve2->Value(UC2);
Standard_Real dp = (aP1.Distance(P)+aP2.Distance(P));
Standard_Real dorig = (aP1.Distance(Origin)+aP2.Distance(Origin));
if(dp < dorig)
{
isEmpty = Standard_True;
return;
}
}
if (Dist < Precision::Infinite()) { if (Dist < Precision::Infinite()) {
//---------------------------------------------------- //----------------------------------------------------
// the parameter of the origin point gives a point // the parameter of the origin point gives a point
@@ -164,7 +177,7 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
} }
} }
if ( !myPolygon.Length() == 0) { if ( myPolygon.Length() != 0 ) {
SupLastParameter(); SupLastParameter();
//---------------------------------------------- //----------------------------------------------
// Construction of the polygon of the bissectrice. // Construction of the polygon of the bissectrice.
@@ -380,8 +393,8 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = myPolygon.Length(); i >=1; i--) { for (Standard_Integer i = myPolygon.Length(); i >=1; i--) {
Bisector_PointOnBis P = myPolygon.Value(i); Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(), Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (), P.ParamOnC2(), P.Distance (),
P.Point()); P.Point());
Poly.Append (NewP); Poly.Append (NewP);
} }
} }
@@ -389,8 +402,8 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = 1; i <= myPolygon.Length(); i ++) { for (Standard_Integer i = 1; i <= myPolygon.Length(); i ++) {
Bisector_PointOnBis P = myPolygon.Value(i); Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(), Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (), P.ParamOnC2(), P.Distance (),
P.Point()); P.Point());
Poly.Append (NewP); Poly.Append (NewP);
} }
} }
@@ -429,7 +442,7 @@ Standard_Boolean Bisector_BisecCC::IsCN (const Standard_Integer N) const
//============================================================================= //=============================================================================
Standard_Real Bisector_BisecCC::FirstParameter() const Standard_Real Bisector_BisecCC::FirstParameter() const
{ {
return startIntervals.First(); return startIntervals.First();
} }
//============================================================================= //=============================================================================
@@ -438,7 +451,7 @@ Standard_Real Bisector_BisecCC::FirstParameter() const
//============================================================================= //=============================================================================
Standard_Real Bisector_BisecCC::LastParameter() const Standard_Real Bisector_BisecCC::LastParameter() const
{ {
return endIntervals.Last(); return endIntervals.Last();
} }
//============================================================================= //=============================================================================
@@ -510,7 +523,7 @@ Standard_Boolean Bisector_BisecCC::IsClosed() const
{ {
if (curve1->IsClosed()) { if (curve1->IsClosed()) {
if (startIntervals.First() == curve1->FirstParameter() && if (startIntervals.First() == curve1->FirstParameter() &&
endIntervals .Last () == curve1->LastParameter () ) endIntervals .Last () == curve1->LastParameter () )
return Standard_True; return Standard_True;
} }
return Standard_False; return Standard_False;
@@ -531,8 +544,8 @@ Standard_Boolean Bisector_BisecCC::IsPeriodic() const
//purpose : //purpose :
//============================================================================= //=============================================================================
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C, static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U, Standard_Real U,
Standard_Real Tol) Standard_Real Tol)
{ {
Standard_Real K1; Standard_Real K1;
gp_Vec2d D1,D2; gp_Vec2d D1,D2;
@@ -569,9 +582,9 @@ static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
// //
//============================================================================= //=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U, gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& U2, Standard_Real& U2,
Standard_Real& Dist) const Standard_Real& Dist) const
{ {
gp_Vec2d T; gp_Vec2d T;
@@ -619,8 +632,8 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
//--------------------------------------------------------------- //---------------------------------------------------------------
gp_Pnt2d P1; gp_Pnt2d P1;
gp_Vec2d T1; gp_Vec2d T1;
Standard_Real EpsH = 1.E-8; Standard_Real EpsH = 1.E-9;
Standard_Real EpsH100 = 1.E-6; Standard_Real EpsH100 = 1.E-7;
curve1->D1 (U1,P1,T1); curve1->D1 (U1,P1,T1);
gp_Vec2d N1(T1.Y(), - T1.X()); gp_Vec2d N1(T1.Y(), - T1.X());
@@ -637,14 +650,14 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
else { else {
math_BissecNewton SolNew (H,VMin - EpsH100,VMax + EpsH100,EpsH,10); math_BissecNewton SolNew (H,VMin - EpsH100,VMax + EpsH100,EpsH,10);
if (SolNew.IsDone()) { if (SolNew.IsDone()) {
U2 = SolNew.Root(); U2 = SolNew.Root();
} }
else { else {
math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100); math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
if (SolRoot.IsDone()) { if (SolRoot.IsDone()) {
U2 = SolRoot.Root(); U2 = SolRoot.Root();
} }
else { Valid = Standard_False;} else { Valid = Standard_False;}
} }
} }
} }
@@ -667,8 +680,8 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Valid = Standard_False; Valid = Standard_False;
} }
else { else {
PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1); PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
Dist = P1.SquareDistance(PBis); Dist = P1.SquareDistance(PBis);
} }
} }
@@ -691,20 +704,20 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Geom2dAdaptor_Curve ANorLi(NorLi); Geom2dAdaptor_Curve ANorLi(NorLi);
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi, Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion()); Precision::Confusion(),Precision::Confusion());
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) { if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) { for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) { if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
P = Intersect.Point(i).Value(); P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) { if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1); DMin = P.SquareDistance(P1);
PBis = P; PBis = P;
U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst()); U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
Dist = DMin; Dist = DMin;
} }
} }
} }
} }
} }
@@ -725,9 +738,9 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
// normal at this point. // normal at this point.
//============================================================================= //=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U, gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& U2, Standard_Real& U2,
Standard_Real& Dist) const Standard_Real& Dist) const
{ {
//------------------------------------------------------------------ //------------------------------------------------------------------
// Return point, tangent, normal on C1 at parameter U. // Return point, tangent, normal on C1 at parameter U.
@@ -792,10 +805,10 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Bisector_FunctionH H (curve2,P1,sign1*sign2*Tan1); Bisector_FunctionH H (curve2,P1,sign1*sign2*Tan1);
math_FunctionRoots SolRoot (H, math_FunctionRoots SolRoot (H,
UFirstOnC2, UFirstOnC2,
ULastOnC2 , ULastOnC2 ,
NbSamples, NbSamples,
EpsX,EpsH,EpsH); EpsX,EpsH,EpsH);
if (SolRoot.IsDone()) { if (SolRoot.IsDone()) {
for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) { for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
USol = SolRoot.Value(j); USol = SolRoot.Value(j);
@@ -806,60 +819,60 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
// Test if the solution is at the proper side of the curves. // Test if the solution is at the proper side of the curves.
if (N1P2P1*sign1 > 0 ) { if (N1P2P1*sign1 > 0 ) {
P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1); P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
DistPP1 = P1.SquareDistance(P); DistPP1 = P1.SquareDistance(P);
if (DistPP1 < DMin) { if (DistPP1 < DMin) {
DMin = DistPP1; DMin = DistPP1;
PSol = P; PSol = P;
U2 = USol; U2 = USol;
YaSol = Standard_True; YaSol = Standard_True;
} }
} }
} }
} }
/* /*
if (!YaSol) { if (!YaSol) {
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Construction de la bisectrice point courbe et de la droite passant // Construction de la bisectrice point courbe et de la droite passant
// par P1 et portee par la normale. // par P1 et portee par la normale.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC Handle(Bisector_BisecPC) BisPC
= new Bisector_BisecPC(curve2,P1,sign2,2*distMax); = new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
//------------------------------- //-------------------------------
// Test si la bissectrice existe. // Test si la bissectrice existe.
//------------------------------- //-------------------------------
if (BisPC->IsEmpty()) { if (BisPC->IsEmpty()) {
Dist = Precision::Infinite(); Dist = Precision::Infinite();
PSol = P1; PSol = P1;
return PSol; return PSol;
}
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
} }
*/
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
}
*/
if (YaSol) { if (YaSol) {
Dist = DMin; Dist = DMin;
@@ -878,18 +891,18 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
} }
else { else {
if ( !isConvex1 ) { if ( !isConvex1 ) {
Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion()); Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
if (K1 != 0.) { if (K1 != 0.) {
if (Dist > 1/(K1*K1)) YaSol = Standard_False; if (Dist > 1/(K1*K1)) YaSol = Standard_False;
} }
} }
if (YaSol) { if (YaSol) {
if ( !isConvex2 ) { if ( !isConvex2 ) {
Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion()); Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
if (K2 != 0.) { if (K2 != 0.) {
if (Dist > 1/(K2*K2)) YaSol = Standard_False; if (Dist > 1/(K2*K2)) YaSol = Standard_False;
} }
} }
} }
} }
} }
@@ -905,7 +918,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
//purpose : //purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::D0(const Standard_Real U, void Bisector_BisecCC::D0(const Standard_Real U,
gp_Pnt2d& P) const gp_Pnt2d& P) const
{ {
Standard_Real U1,U2,Dist; Standard_Real U1,U2,Dist;
@@ -917,8 +930,8 @@ void Bisector_BisecCC::D0(const Standard_Real U,
//purpose : //purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::D1(const Standard_Real U, void Bisector_BisecCC::D1(const Standard_Real U,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V ) const gp_Vec2d& V ) const
{ {
V.SetCoord(0.,0.); V.SetCoord(0.,0.);
gp_Vec2d V2,V3; gp_Vec2d V2,V3;
@@ -930,9 +943,9 @@ void Bisector_BisecCC::D1(const Standard_Real U,
//purpose : //purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::D2(const Standard_Real U, void Bisector_BisecCC::D2(const Standard_Real U,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V1, gp_Vec2d& V1,
gp_Vec2d& V2) const gp_Vec2d& V2) const
{ {
V1.SetCoord(0.,0.); V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.); V2.SetCoord(0.,0.);
@@ -945,10 +958,10 @@ void Bisector_BisecCC::D2(const Standard_Real U,
//purpose : //purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::D3(const Standard_Real U, void Bisector_BisecCC::D3(const Standard_Real U,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V1, gp_Vec2d& V1,
gp_Vec2d& V2, gp_Vec2d& V2,
gp_Vec2d& V3) const gp_Vec2d& V3) const
{ {
V1.SetCoord(0.,0.); V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.); V2.SetCoord(0.,0.);
@@ -961,7 +974,7 @@ void Bisector_BisecCC::D3(const Standard_Real U,
//purpose : //purpose :
//============================================================================= //=============================================================================
gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U, gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
const Standard_Integer N) const const Standard_Integer N) const
{ {
gp_Pnt2d P; gp_Pnt2d P;
gp_Vec2d V1(0.,0.); gp_Vec2d V1(0.,0.);
@@ -969,12 +982,12 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
gp_Vec2d V3(0.,0.); gp_Vec2d V3(0.,0.);
Values (U,N,P,V1,V2,V3); Values (U,N,P,V1,V2,V3);
switch (N) { switch (N) {
case 1 : return V1; case 1 : return V1;
case 2 : return V2; case 2 : return V2;
case 3 : return V3; case 3 : return V3;
default: { default: {
Standard_NotImplemented::Raise(); Standard_NotImplemented::Raise();
} }
} }
return V1; return V1;
} }
@@ -1000,11 +1013,11 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
// //
//============================================================================= //=============================================================================
void Bisector_BisecCC::Values (const Standard_Real U, void Bisector_BisecCC::Values (const Standard_Real U,
const Standard_Integer N, const Standard_Integer N,
gp_Pnt2d& P, gp_Pnt2d& P,
gp_Vec2d& V1, gp_Vec2d& V1,
gp_Vec2d& V2, gp_Vec2d& V2,
gp_Vec2d& V3) const gp_Vec2d& V3) const
{ {
V1 = gp_Vec2d(0.,0.); V1 = gp_Vec2d(0.,0.);
V2 = gp_Vec2d(0.,0.); V2 = gp_Vec2d(0.,0.);
@@ -1066,9 +1079,9 @@ void Bisector_BisecCC::Values (const Standard_Real U,
TvvPuPv = Tvv.Dot(PuPv) ; TvTvv = Tv.Dot(Tvv) ; TvvPuPv = Tvv.Dot(PuPv) ; TvTvv = Tv.Dot(Tvv) ;
Standard_Real dHdu = 2*(TuPuPv*(TuuPuPv - TuTu)*TvTv + Standard_Real dHdu = 2*(TuPuPv*(TuuPuPv - TuTu)*TvTv +
TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv); TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv);
Standard_Real dHdv = 2*(TuPuPv*TuTv*TvTv + TvTvv*TuPuPv*TuPuPv - Standard_Real dHdv = 2*(TuPuPv*TuTv*TvTv + TvTvv*TuPuPv*TuPuPv -
TvPuPv*(TvvPuPv + TvTv)*TuTu); TvPuPv*(TvvPuPv + TvTv)*TuTu);
//----------------------------- //-----------------------------
// Calculate dF/du and dF/dv. // Calculate dF/du and dF/dv.
@@ -1115,10 +1128,10 @@ void Bisector_BisecCC::Values (const Standard_Real U,
// by tangence of the curve. // by tangence of the curve.
//============================================================================ //============================================================================
gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U, gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& U2, Standard_Real& U2,
Standard_Real& Dist, Standard_Real& Dist,
gp_Vec2d& T ) const gp_Vec2d& T ) const
{ {
Bisector_PointOnBis PRef; Bisector_PointOnBis PRef;
gp_Pnt2d P,P1,P2,PBis; gp_Pnt2d P,P1,P2,PBis;
@@ -1201,12 +1214,12 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
// purpose : // purpose :
//============================================================================= //=============================================================================
static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA, static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
const Handle(Geom2d_Curve)& CB, const Handle(Geom2d_Curve)& CB,
const Standard_Real SignA, const Standard_Real SignA,
const Standard_Real SignB, const Standard_Real SignB,
const Standard_Real UOnA, const Standard_Real UOnA,
Standard_Real& UOnB, Standard_Real& UOnB,
Standard_Real& Dist) Standard_Real& Dist)
{ {
//------------------------------------------------------------------ //------------------------------------------------------------------
// Return point,tangent, normal on CA with parameter UOnA. // Return point,tangent, normal on CA with parameter UOnA.
@@ -1250,7 +1263,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Standard_Real DMin = Precision::Infinite(); Standard_Real DMin = Precision::Infinite();
Standard_Real UPC; Standard_Real UPC;
Standard_Boolean YaSol = Standard_False; Standard_Boolean YaSol = Standard_False;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Construction of the bisectrice point curve and of the straight line passing // Construction of the bisectrice point curve and of the straight line passing
// through P1 and carried by the normal. // through P1 and carried by the normal.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@@ -1271,21 +1284,21 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Geom2dAdaptor_Curve ANorLi(NorLi); Geom2dAdaptor_Curve ANorLi(NorLi);
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi, Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion()); Precision::Confusion(),Precision::Confusion());
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) { if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) { for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*SignA < Precision::PConfusion()) { if (Intersect.Point(i).ParamOnSecond()*SignA < Precision::PConfusion()) {
P = Intersect.Point(i).Value(); P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) { if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1); DMin = P.SquareDistance(P1);
PSol = P; PSol = P;
UPC = Intersect.Point(i).ParamOnFirst(); UPC = Intersect.Point(i).ParamOnFirst();
UOnB = BisPC->LinkBisCurve(UPC); UOnB = BisPC->LinkBisCurve(UPC);
Dist = DMin; Dist = DMin;
YaSol = Standard_True; YaSol = Standard_True;
} }
} }
} }
} }
@@ -1294,6 +1307,17 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
// Point found => Test distance curvature + Angular test // Point found => Test distance curvature + Angular test
//--------------------------------------------------------------- //---------------------------------------------------------------
P2 = CB->Value(UOnB); P2 = CB->Value(UOnB);
if(P1.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
if(P2.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
gp_Dir2d PP1Unit(P1.X() - PSol.X(),P1.Y() - PSol.Y()); gp_Dir2d PP1Unit(P1.X() - PSol.X(),P1.Y() - PSol.Y());
gp_Dir2d PP2Unit(P2.X() - PSol.X(),P2.Y() - PSol.Y()); gp_Dir2d PP2Unit(P2.X() - PSol.X(),P2.Y() - PSol.Y());
@@ -1303,18 +1327,18 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
else { else {
Dist = sqrt(Dist); Dist = sqrt(Dist);
if ( !IsConvexA ) { if ( !IsConvexA ) {
Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion()); Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
if (K1 != 0.) { if (K1 != 0.) {
if (Dist > Abs(1/K1)) YaSol = Standard_False; if (Dist > Abs(1/K1)) YaSol = Standard_False;
} }
} }
if (YaSol) { if (YaSol) {
if ( !IsConvexB ) { if ( !IsConvexB ) {
Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion()); Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
if (K2 != 0.) { if (K2 != 0.) {
if (Dist > Abs(1/K2)) YaSol = Standard_False; if (Dist > Abs(1/K2)) YaSol = Standard_False;
} }
} }
} }
} }
} }
@@ -1426,20 +1450,20 @@ Standard_Real Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const
//============================================================================= //=============================================================================
//void Bisector_BisecCC::Dump(const Standard_Integer Deep, //void Bisector_BisecCC::Dump(const Standard_Integer Deep,
void Bisector_BisecCC::Dump(const Standard_Integer , void Bisector_BisecCC::Dump(const Standard_Integer ,
const Standard_Integer Offset) const const Standard_Integer Offset) const
{ {
Indent (Offset); Indent (Offset);
cout <<"Bisector_BisecCC :"<<endl; cout <<"Bisector_BisecCC :"<<endl;
Indent (Offset); Indent (Offset);
// cout <<"Curve1 :"<<curve1<<endl; // cout <<"Curve1 :"<<curve1<<endl;
// cout <<"Curve2 :"<<curve2<<endl; // cout <<"Curve2 :"<<curve2<<endl;
cout <<"Sign1 :"<<sign1<<endl; cout <<"Sign1 :"<<sign1<<endl;
cout <<"Sign2 :"<<sign2<<endl; cout <<"Sign2 :"<<sign2<<endl;
cout <<"Number Of Intervals :"<<startIntervals.Length()<<endl; cout <<"Number Of Intervals :"<<startIntervals.Length()<<endl;
for (Standard_Integer i = 1; i <= startIntervals.Length(); i++) { for (Standard_Integer i = 1; i <= startIntervals.Length(); i++) {
cout <<"Interval number :"<<i<<"Start :"<<startIntervals.Value(i) cout <<"Interval number :"<<i<<"Start :"<<startIntervals.Value(i)
<<" end :"<< endIntervals.Value(i)<<endl ; <<" end :"<< endIntervals.Value(i)<<endl ;
} }
cout <<"Index Current Interval :"<<currentInterval<<endl; cout <<"Index Current Interval :"<<currentInterval<<endl;
} }
@@ -1449,7 +1473,7 @@ void Bisector_BisecCC::Dump(const Standard_Integer ,
// purpose : // purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::Curve(const Standard_Integer I, void Bisector_BisecCC::Curve(const Standard_Integer I,
const Handle(Geom2d_Curve)& C) const Handle(Geom2d_Curve)& C)
{ {
if (I == 1) curve1 = C; if (I == 1) curve1 = C;
else if (I == 2) curve2 = C; else if (I == 2) curve2 = C;
@@ -1461,7 +1485,7 @@ void Bisector_BisecCC::Curve(const Standard_Integer I,
// purpose : // purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::Sign(const Standard_Integer I, void Bisector_BisecCC::Sign(const Standard_Integer I,
const Standard_Real S) const Standard_Real S)
{ {
if (I == 1) sign1 = S; if (I == 1) sign1 = S;
else if (I == 2) sign2 = S; else if (I == 2) sign2 = S;
@@ -1491,7 +1515,7 @@ void Bisector_BisecCC::DistMax(const Standard_Real D)
// purpose : // purpose :
//============================================================================= //=============================================================================
void Bisector_BisecCC::IsConvex(const Standard_Integer I, void Bisector_BisecCC::IsConvex(const Standard_Integer I,
const Standard_Boolean IsConvex) const Standard_Boolean IsConvex)
{ {
if (I == 1) isConvex1 = IsConvex; if (I == 1) isConvex1 = IsConvex;
else if (I == 2) isConvex2 = IsConvex; else if (I == 2) isConvex2 = IsConvex;
@@ -1586,7 +1610,7 @@ void Bisector_BisecCC::LastParameter (const Standard_Real U)
// purpose : // purpose :
//============================================================================= //=============================================================================
Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1, Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
const Standard_Real U2) const const Standard_Real U2) const
{ {
Standard_Real UMid,Dist1,Dist2,DistMid,U11,U22; Standard_Real UMid,Dist1,Dist2,DistMid,U11,U22;
Standard_Real UC1,UC2; Standard_Real UC1,UC2;
@@ -1598,20 +1622,20 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
PBis = ValueByInt(U22,UC1,UC2,Dist2); PBis = ValueByInt(U22,UC1,UC2,Dist2);
while ((U22 - U11) > TolPar || while ((U22 - U11) > TolPar ||
((Dist1 < Precision::Infinite() && ((Dist1 < Precision::Infinite() &&
Dist2 < Precision::Infinite() && Dist2 < Precision::Infinite() &&
!PBis.IsEqual(PBisPrec,TolPnt)))) { !PBis.IsEqual(PBisPrec,TolPnt)))) {
PBisPrec = PBis; PBisPrec = PBis;
UMid = 0.5*( U22 + U11); UMid = 0.5*( U22 + U11);
PBis = ValueByInt(UMid,UC1,UC2,DistMid); PBis = ValueByInt(UMid,UC1,UC2,DistMid);
if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) { if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
U11 = UMid; U11 = UMid;
Dist1 = DistMid; Dist1 = DistMid;
} }
else { else {
U22 = UMid; U22 = UMid;
Dist2 = DistMid; Dist2 = DistMid;
} }
} }
PBis = ValueByInt(U11,UC1,UC2,Dist1); PBis = ValueByInt(U11,UC1,UC2,Dist1);
if (Dist1 < Precision::Infinite()) { if (Dist1 < Precision::Infinite()) {
@@ -1628,8 +1652,8 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
// purpose : // purpose :
//============================================================================= //=============================================================================
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P, static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C, const Handle(Geom2d_Curve)& C,
Standard_Real& theParam) Standard_Real& theParam)
{ {
//Standard_Real UOnCurve =0.; //Standard_Real UOnCurve =0.;
theParam = 0.0; theParam = 0.0;
@@ -1667,8 +1691,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
return Standard_True; return Standard_True;
} }
Geom2dAPI_ProjectPointOnCurve Proj(P,C, Geom2dAPI_ProjectPointOnCurve Proj(P,C,
C->FirstParameter(), C->FirstParameter(),
C->LastParameter()); C->LastParameter());
if (Proj.NbPoints() > 0) { if (Proj.NbPoints() > 0) {
theParam = Proj.LowerDistanceParameter(); theParam = Proj.LowerDistanceParameter();
} }
@@ -1684,8 +1708,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
// purpose : // purpose :
//============================================================================= //=============================================================================
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1, static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2, const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End) const Standard_Integer Start_End)
{ {
gp_Pnt2d P1,P2; gp_Pnt2d P1,P2;
gp_Vec2d T1,T2; gp_Vec2d T1,T2;
@@ -1708,7 +1732,7 @@ static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
if (P1.IsEqual(P2,Precision::Confusion())) { if (P1.IsEqual(P2,Precision::Confusion())) {
T2.Normalize(); T2.Normalize();
if (T1.Dot(T2) > 1.0 - Precision::Confusion()) { if (T1.Dot(T2) > 1.0 - Precision::Confusion()) {
Test = Standard_True; Test = Standard_True;
} }
} }
} }
@@ -1753,12 +1777,12 @@ void Bisector_BisecCC::ComputePointEnd ()
// purpose : // purpose :
//============================================================================= //=============================================================================
static Standard_Boolean DiscretPar(const Standard_Real DU, static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin, const Standard_Real EpsMin,
const Standard_Real EpsMax, const Standard_Real EpsMax,
const Standard_Integer NbMin, const Standard_Integer NbMin,
const Standard_Integer NbMax, const Standard_Integer NbMax,
Standard_Real& Eps, Standard_Real& Eps,
Standard_Integer& Nb) Standard_Integer& Nb)
{ {
if (DU <= NbMin*EpsMin) { if (DU <= NbMin*EpsMin) {
Eps = DU/(NbMin + 1) ; Eps = DU/(NbMin + 1) ;

View File

@@ -5,8 +5,8 @@
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
// This library is free software; you can redistribute it and / or modify it // This library is free software; you can redistribute it and/or modify it under
// under the terms of the GNU Lesser General Public version 2.1 as published // the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file // by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty. // distribution for complete text of the license and disclaimer of any warranty.
@@ -33,14 +33,14 @@
#include <Precision.hxx> #include <Precision.hxx>
#include <math_BissecNewton.hxx> #include <math_BissecNewton.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
#ifdef DRAW
#include <Draw_Appli.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <Draw_Marker2D.hxx>
#endif
#ifdef DEB #ifdef DEB
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
static char name[100];
static Standard_Boolean Affich = Standard_False; static Standard_Boolean Affich = Standard_False;
static Standard_Integer nbint = 0;
#endif
#endif #endif
//=================================================================================== //===================================================================================
@@ -174,14 +174,14 @@ void Bisector_Inter::Perform(const Bisector_Bisec& C1,
PMax,UMax,D2.LastTolerance()); PMax,UMax,D2.LastTolerance());
if ((IB2 == 1 && Bis2->IsExtendAtStart()) || if ((IB2 == 1 && Bis2->IsExtendAtStart()) ||
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){ (IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
//-------------------------------------------------------- //--------------------------------------------------------
// Part corresponding to an extension is a segment. // Part corresponding to an extension is a segment.
//-------------------------------------------------------- //--------------------------------------------------------
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax); SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
} }
else { else {
SBis2 [IB2] = Bis2; SBis2 [IB2] = Bis2;
} }
NB2++; NB2++;
} }
@@ -271,11 +271,11 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) { if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis1), TestBound(Handle(Geom2d_Line)::DownCast(Bis1),
D1,Bis2,D2,TolConf,Standard_False); D1,Bis2,D2,TolConf,Standard_False);
} }
else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) { else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis2), TestBound(Handle(Geom2d_Line)::DownCast(Bis2),
D2,Bis1,D1,TolConf,Standard_True); D2,Bis1,D1,TolConf,Standard_True);
} }
Geom2dInt_GInter Intersect; Geom2dInt_GInter Intersect;
Geom2dAdaptor_Curve ABis1(Bis1); Geom2dAdaptor_Curve ABis1(Bis1);
@@ -287,21 +287,17 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
#ifdef DRAW #ifdef DRAW
if (Affich) { if (Affich) {
Handle(DrawTrSurf_Curve2d) dr; sprintf( name, "i1_%d", ++nbint);
Draw_Color Couleur = Draw_bleu; DrawTrSurf::Set(name, Bis1);
sprintf( name, "i2_%d", nbint);
dr = new DrawTrSurf_Curve2d(Bis1,Couleur,100); DrawTrSurf::Set(name, Bis2);
dout << dr; if (IsDone() && !IsEmpty()) {
dr = new DrawTrSurf_Curve2d(Bis2,Couleur,100);
dout << dr;
if (IsDone() && !IsEmpty()) {
for (Standard_Integer k = 1; k <= NbPoints(); k++) { for (Standard_Integer k = 1; k <= NbPoints(); k++) {
gp_Pnt2d P = Point(k).Value(); gp_Pnt2d P = Point(k).Value();
Handle(Draw_Marker2D) drp = new Draw_Marker2D(P,Draw_Plus,Draw_vert); sprintf( name, "ip_%d_%d", nbint, k);
dout << drp; DrawTrSurf::Set(name, P);
} }
} }
dout.Flush();
} }
#endif #endif
} }
@@ -334,7 +330,7 @@ void Bisector_Inter::NeighbourPerform(const Handle(Bisector_BisecCC)& Bis1,
// Change guiedline on Bis2. // Change guiedline on Bis2.
BisTemp = Bis2->ChangeGuide(); BisTemp = Bis2->ChangeGuide();
Guide = Bis2->Curve(2); Guide = Bis2->Curve(2);
#ifdef DEB #ifdef OCCT_DEBUG
gp_Pnt2d P2S = Bis2->ValueAndDist(D2.FirstParameter(),U1,UMax,Dist); gp_Pnt2d P2S = Bis2->ValueAndDist(D2.FirstParameter(),U1,UMax,Dist);
gp_Pnt2d P2E = Bis2->ValueAndDist(D2.LastParameter() ,U1,UMin,Dist); gp_Pnt2d P2E = Bis2->ValueAndDist(D2.LastParameter() ,U1,UMin,Dist);
#else #else

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,3 @@
puts "TODO DEBUG_OCC24121 Debian60-64 Windows: \\*\\* Exception \\*\\*.*"
puts "TODO DEBUG_OCC24121 Debian60-64 Windows: An exception was caught"
puts "TODO DEBUG_OCC24121 Debian60-64 Windows: TEST INCOMPLETE"
puts "============" puts "============"
puts "OCC22831" puts "OCC22831"
puts "============" puts "============"

View File

@@ -11,7 +11,7 @@ CHECKSHAPE : Wires = 12 ( 18 ) Faces = 16 ( 16 ) Shells = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) Summary = 68418 ( 68418 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) Summary = 68418 ( 68418 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) FreeWire = 10 ( 10 ) FreeEdge = 283 ( 283 ) SharedEdge = 29071 ( 29075 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 5163 ( 5163 ) FreeWire = 10 ( 10 ) FreeEdge = 283 ( 283 ) SharedEdge = 29071 ( 29075 )
TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.0111430941 ( 0.01115568387 ) TOLERANCE : MaxTol = 0.9874083984 ( 0.9875071265 ) AvgTol = 0.0111430941 ( 0.01115568387 )
LABELS : N0Labels = 5392 ( 5458 ) N1Labels = 18 ( 4437 ) N2Labels = 0 ( 0 ) TotalLabels = 5410 ( 9895 ) NameLabels = 5392 ( 5458 ) ColorLabels = 5391 ( 9829 ) LayerLabels = 5391 ( 9829 ) LABELS : N0Labels = 5392 ( 5458 ) N1Labels = 18 ( 4443 ) N2Labels = 0 ( 0 ) TotalLabels = 5410 ( 9901 ) NameLabels = 5392 ( 5458 ) ColorLabels = 5391 ( 9835 ) LayerLabels = 5391 ( 9835 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 4 ( 4 ) NCOLORS : NColors = 4 ( 4 )
COLORS : Colors = BLACK BLUE1 CYAN1 GREEN ( BLACK BLUE1 CYAN1 GREEN ) COLORS : Colors = BLACK BLUE1 CYAN1 GREEN ( BLACK BLUE1 CYAN1 GREEN )

View File

@@ -14,7 +14,7 @@ CHECKSHAPE : Wires = 12 ( 17 ) Faces = 12 ( 11 ) Shells = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) Summary = 63154 ( 63144 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) Summary = 63154 ( 63144 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) FreeWire = 18 ( 18 ) FreeEdge = 452 ( 452 ) SharedEdge = 26794 ( 26793 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 4729 ( 4729 ) FreeWire = 18 ( 18 ) FreeEdge = 452 ( 452 ) SharedEdge = 26794 ( 26793 )
TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01153089029 ( 0.01154870945 ) TOLERANCE : MaxTol = 0.9804479161 ( 0.9805459497 ) AvgTol = 0.01153089029 ( 0.01154870945 )
LABELS : N0Labels = 5089 ( 5165 ) N1Labels = 26 ( 3844 ) N2Labels = 0 ( 0 ) TotalLabels = 5115 ( 9009 ) NameLabels = 5089 ( 5165 ) ColorLabels = 5086 ( 8933 ) LayerLabels = 5086 ( 8933 ) LABELS : N0Labels = 5089 ( 5165 ) N1Labels = 26 ( 3846 ) N2Labels = 0 ( 0 ) TotalLabels = 5115 ( 9011 ) NameLabels = 5089 ( 5165 ) ColorLabels = 5086 ( 8935 ) LayerLabels = 5086 ( 8935 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 3 ( 3 ) NCOLORS : NColors = 3 ( 3 )
COLORS : Colors = BLUE1 CYAN1 GREEN ( BLUE1 CYAN1 GREEN ) COLORS : Colors = BLUE1 CYAN1 GREEN ( BLUE1 CYAN1 GREEN )

View File

@@ -14,8 +14,8 @@ TPSTAT : Faulties = 0 ( 0 ) Warnings = 6 ( 523 ) Summary = 6 ( 523 )
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1177 ( 1177 ) Summary = 18232 ( 18230 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1177 ( 1177 ) Summary = 18232 ( 18230 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1177 ( 1177 ) FreeWire = 5 ( 5 ) FreeEdge = 714 ( 714 ) SharedEdge = 7614 ( 7614 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1177 ( 1177 ) FreeWire = 5 ( 5 ) FreeEdge = 714 ( 714 ) SharedEdge = 7614 ( 7614 )
TOLERANCE : MaxTol = 0.9436610236 ( 0.8261873283 ) AvgTol = 0.01104814106 ( 0.01076280021 ) TOLERANCE : MaxTol = 0.9436610236 ( 0.8261873283 ) AvgTol = 0.01104814109 ( 0.0107628002 )
LABELS : N0Labels = 1884 ( 1885 ) N1Labels = 0 ( 1020 ) N2Labels = 0 ( 0 ) TotalLabels = 1884 ( 2905 ) NameLabels = 1884 ( 1885 ) ColorLabels = 1873 ( 2904 ) LayerLabels = 1873 ( 2904 ) LABELS : N0Labels = 1884 ( 1885 ) N1Labels = 0 ( 1019 ) N2Labels = 0 ( 0 ) TotalLabels = 1884 ( 2904 ) NameLabels = 1884 ( 1885 ) ColorLabels = 1873 ( 2903 ) LayerLabels = 1873 ( 2903 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 7 ( 7 ) NCOLORS : NColors = 7 ( 7 )
COLORS : Colors = BLACK BLUE1 CYAN1 GREEN RED WHITE YELLOW ( BLACK BLUE1 CYAN1 GREEN RED WHITE YELLOW ) COLORS : Colors = BLACK BLUE1 CYAN1 GREEN RED WHITE YELLOW ( BLACK BLUE1 CYAN1 GREEN RED WHITE YELLOW )

View File

@@ -1,6 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script # !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR23096 ALL: TPSTAT : Faulty" puts "TODO CR23096 ALL: TPSTAT : Faulty"
puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty"
puts "TODO CR23096 Mandriva2010: Error : 2 differences with reference data found :" puts "TODO CR23096 Mandriva2010: Error : 2 differences with reference data found :"
puts "TODO CR23096 Mandriva2010: STATSHAPE : Faulty" puts "TODO CR23096 Mandriva2010: STATSHAPE : Faulty"

View File

@@ -1,3 +1,3 @@
set TheFileName shading_082.brep set TheFileName shading_082.brep
set bug_cross "OCC22687" set bug_cross "OCC22687"
set nbcross(All) 16 set nbcross(All) 0

View File

@@ -1,16 +1,6 @@
set os "ALL" puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_4"
if {[array get env os_type] != ""} { puts "TODO OCC23068 ALL: Error : The length of the resulting shape is"
set os $env(os_type) puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG because it must contain"
}
if {
[string compare $os "Debian40"] == 0
|| [string compare $os "Mandriva2008"] == 0
} {
puts "TODO OCC23068 $os: Faulty shapes in variables faulty_1 to faulty_4"
puts "TODO OCC23068 $os: Error : The length of result shape is"
puts "TODO OCC23068 $os: Error : Result shape is WRONG"
}
restore [locate_data_file offset_wire_038.brep] s restore [locate_data_file offset_wire_038.brep] s