#include <GCPnts_QuasiUniformDeflection.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <GCPnts_TangentialDeflection.hxx>
+#include <GCPnts_DistFunction.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <gce_MakeLin.hxx>
#include <TColStd_Array1OfBoolean.hxx>
//epa test
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <AIS_Shape.hxx>
+#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepAdaptor_HCompCurve.hxx>
#include <GeomLProp_CLProps.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GCPnts_UniformAbscissa.hxx>
#include <DBRep.hxx>
-#ifdef WNT
+#ifdef _WIN32
Standard_IMPORT Draw_Viewer dout;
#endif
ONE = 2;
}
else {
- di << "gproject wait 2 or 3 arguments" << "\n";
+ di << "gproject wait 2 or 3 arguments\n";
return 1;
}
Standard_Integer k;
Standard_Real Udeb, Ufin, UIso, VIso;
- Standard_Integer Only2d, Only3d;
+ Standard_Boolean Only2d, Only3d;
gp_Pnt2d P2d, Pdeb, Pfin;
gp_Pnt P;
Handle(Adaptor2d_HCurve2d) HPCur;
Sprintf(newname,"%s_%d",name,k);
Sprintf(newname1,"%s2d_%d",name,k);
if(Projector.IsSinglePnt(k, P2d)){
-// cout<<"Part "<<k<<" of the projection is punctual"<<endl;
+// std::cout<<"Part "<<k<<" of the projection is punctual"<<std::endl;
Projector.GetSurface()->D0(P2d.X(), P2d.Y(), P);
DrawTrSurf::Set(temp, P);
DrawTrSurf::Set(temp1, P2d);
- di<<temp<<" is 3d projected curve"<<"\n";
- di<<temp1<<" is pcurve"<<"\n";
+ di<<temp<<" is 3d projected curve\n";
+ di<<temp1<<" is pcurve\n";
}
else {
Only2d = Only3d = Standard_False;
gp_Dir2d Dir; // Only for isoparametric projection
if (Projector.IsUIso(k, UIso)) {
-// cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<endl;
+// std::cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<std::endl;
Projector.D0(Udeb, Pdeb);
Projector.D0(Ufin, Pfin);
Udeb = Pdeb.Y();
Only3d = Standard_True;
}
else if(Projector.IsVIso(k, VIso)) {
-// cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<endl;
+// std::cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<std::endl;
Projector.D0(Udeb, Pdeb);
Projector.D0(Ufin, Pfin);
Udeb = Pdeb.X();
Handle(Geom_Curve) OutCur = new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()), Ufin, Udeb);
DrawTrSurf::Set(temp, OutCur);
DrawTrSurf::Set(temp1, PCur2d);
- di<<temp<<" is 3d projected curve"<<"\n";
- di<<temp1<<" is pcurve"<<"\n";
+ di<<temp<<" is 3d projected curve\n";
+ di<<temp1<<" is pcurve\n";
return 0;
}
else {
- Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
- myContinuity, myMaxDegree, myMaxSeg,
- Only3d, Only2d);
+ Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
+ appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
if(!Only3d) {
PCur2d = appr.Curve2d();
di << " Error in 2d is " << appr.MaxError2dU()
DrawTrSurf::Set(temp, appr.Curve3d());
}
DrawTrSurf::Set(temp1, PCur2d);
- di<<temp<<" is 3d projected curve"<<"\n";
- di<<temp1<<" is pcurve"<<"\n";
+ di<<temp<<" is 3d projected curve\n";
+ di<<temp1<<" is pcurve\n";
}
}
}
{
if ( n == 1) {
- di << "project result2d c3d surf [-e p] [-v n] [-t tol]" << "\n";
- di << " -e p : extent the surface of <p>%" << "\n";
- di << " -v n : verify the projection at <n> points." << "\n";
- di << " -t tol : set the tolerance for approximation" << "\n";
+ di << "project result2d c3d surf [-e p] [-v n] [-t tol]\n";
+ di << " -e p : extent the surface of <p>%\n";
+ di << " -v n : verify the projection at <n> points.\n";
+ di << " -t tol : set the tolerance for approximation\n";
return 0;
}
GeomProjLib::Curve2d(GC, GS, U1, U2, V1, V2, tolerance);
if ( G2d.IsNull() ) {
- di << "\n" << "Projection Failed" << "\n";
+ di << "\nProjection Failed\n";
return 1;
}
else {
}
if ( Verif) { // verify the projection on n points
if ( NbPoints <= 0) {
- di << " n must be positive" << "\n";
+ di << " n must be positive\n";
return 0;
}
gp_Pnt P1,P2;
Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(S);
if ( Pl.IsNull()) {
- di << " The surface must be a plane" << "\n";
+ di << " The surface must be a plane\n";
return 1;
}
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
else {
- di << " args must be line/circle/point line/circle/point" << "\n";
+ di << " args must be line/circle/point line/circle/point\n";
return 1;
}
}
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
solution(Bis.ThisSolution(),a[1],0);
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
}
else {
- di << " the second arg must be line/circle/point " << "\n";
+ di << " the second arg must be line/circle/point \n";
}
}
else if ( ip1) {
}
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
solution(Bis.ThisSolution(),a[1],0);
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
DrawTrSurf::Set(a[1],new Geom2d_Line(Bis.ThisSolution()));
}
else {
- di << " Bisec has failed !!" << "\n";
+ di << " Bisec has failed !!\n";
return 1;
}
}
else {
- di << " the second arg must be line/circle/point " << "\n";
+ di << " the second arg must be line/circle/point \n";
return 1;
}
}
else {
- di << " args must be line/circle/point line/circle/point" << "\n";
+ di << " args must be line/circle/point line/circle/point\n";
return 1;
}
if ( NbSol >= 2) {
- di << "There are " << NbSol << " Solutions." << "\n";
+ di << "There are " << NbSol << " Solutions.\n";
}
else {
- di << "There is " << NbSol << " Solution." << "\n";
+ di << "There is " << NbSol << " Solution.\n";
}
return 0;
static Standard_Integer movelaw (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
Standard_Integer
- ii,
- condition=0,
- error_status ;
+ ii,
+ condition=0,
+ error_status ;
Standard_Real u,
- x,
- tolerance,
- tx ;
+ x,
+ tolerance,
+ tx ;
u = Draw::Atof(a[2]);
x = Draw::Atof(a[3]);
tolerance = 1.0e-5 ;
if (n < 5) {
- return 1 ;
+ return 1 ;
}
Handle(Geom2d_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve2d(a[1]);
if (!G2.IsNull()) {
- tx = Draw::Atof(a[4]) ;
- if (n == 6) {
- condition = Max(Draw::Atoi(a[5]), -1) ;
- condition = Min(condition, G2->Degree()-1) ;
- }
- TColgp_Array1OfPnt2d curve_poles(1,G2->NbPoles()) ;
- TColStd_Array1OfReal law_poles(1,G2->NbPoles()) ;
- TColStd_Array1OfReal law_knots(1,G2->NbKnots()) ;
- TColStd_Array1OfInteger law_mults(1,G2->NbKnots()) ;
-
- G2->Knots(law_knots) ;
- G2->Multiplicities(law_mults) ;
- G2->Poles(curve_poles) ;
- for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
- law_poles(ii) = curve_poles(ii).Coord(2) ;
- }
+ tx = Draw::Atof(a[4]) ;
+ if (n == 6) {
+ condition = Max(Draw::Atoi(a[5]), -1) ;
+ condition = Min(condition, G2->Degree()-1) ;
+ }
+ TColgp_Array1OfPnt2d curve_poles(1,G2->NbPoles()) ;
+ TColStd_Array1OfReal law_poles(1,G2->NbPoles()) ;
+ TColStd_Array1OfReal law_knots(1,G2->NbKnots()) ;
+ TColStd_Array1OfInteger law_mults(1,G2->NbKnots()) ;
+
+ G2->Knots(law_knots) ;
+ G2->Multiplicities(law_mults) ;
+ G2->Poles(curve_poles) ;
+ for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
+ law_poles(ii) = curve_poles(ii).Coord(2) ;
+ }
- Law_BSpline a_law(law_poles,
- law_knots,
- law_mults,
- G2->Degree(),
- Standard_False) ;
-
- a_law.MovePointAndTangent(u,
- x,
- tx,
- tolerance,
- condition,
- condition,
- error_status) ;
-
- for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
- curve_poles(ii).SetCoord(2,a_law.Pole(ii)) ;
- G2->SetPole(ii,curve_poles(ii)) ;
- }
+ Law_BSpline a_law(law_poles,
+ law_knots,
+ law_mults,
+ G2->Degree(),
+ Standard_False) ;
+
+ a_law.MovePointAndTangent(u,
+ x,
+ tx,
+ tolerance,
+ condition,
+ condition,
+ error_status) ;
+
+ for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
+ curve_poles(ii).SetCoord(2,a_law.Pole(ii)) ;
+ G2->SetPole(ii,curve_poles(ii)) ;
+ }
-
- if (! error_status) {
- Draw::Repaint();
- }
- else {
- di << "Not enought degree of freedom increase degree please" << "\n";
- }
-
-
+
+ if (! error_status) {
+ Draw::Repaint();
}
+ else {
+ di << "Not enought degree of freedom increase degree please\n";
+ }
+
+
+ }
return 0;
}
//Static method computing deviation of curve and polyline
+#include <math_PSO.hxx>
+#include <math_PSOParticlesPool.hxx>
+#include <math_MultipleVarFunction.hxx>
+#include <math_BrentMinimum.hxx>
+
+static Standard_Real CompLocalDev(const Adaptor3d_Curve& theCurve,
+ const Standard_Real u1, const Standard_Real u2);
-static void ComputeDeviation(const Handle(Geom_Curve)& theCurve,
+static void ComputeDeviation(const Adaptor3d_Curve& theCurve,
const Handle(Geom_BSplineCurve)& thePnts,
Standard_Real& theDmax,
Standard_Real& theUfMax,
thePnts->Knots(aKnots);
Standard_Integer i;
- for(i = 1; i < nbp; ++i) {
- Standard_Real uf = aKnots(i);
- Standard_Real ul = aKnots(i+1);
-
- GeomAPI_ExtremaCurveCurve ECC(theCurve, thePnts, uf, ul, uf, ul);
-
- Standard_Integer nbe = ECC.NbExtrema();
- if(nbe > 0) {
- Standard_Integer k;
- Standard_Real d = 0.;
- for(k = 1; k <= nbe; k++) {
- if(ECC.Distance(k) > d) d = ECC.Distance(k);
- }
-
- if(d > theDmax) {
- theDmax = d;
- theUfMax = uf;
- theUlMax = ul;
- theImax = i;
- }
+ for(i = 1; i < nbp; ++i)
+ {
+ Standard_Real u1 = aKnots(i), u2 = aKnots(i+1);
+ Standard_Real d = CompLocalDev(theCurve, u1, u2);
+ if(d > theDmax)
+ {
+ theDmax = d;
+ theImax = i;
+ theUfMax = u1;
+ theUlMax = u2;
}
}
}
+Standard_Real CompLocalDev(const Adaptor3d_Curve& theCurve,
+ const Standard_Real u1, const Standard_Real u2)
+{
+ math_Vector aLowBorder(1,1);
+ math_Vector aUppBorder(1,1);
+ math_Vector aSteps(1,1);
+ //
+ aLowBorder(1) = u1;
+ aUppBorder(1) = u2;
+ aSteps(1) =(aUppBorder(1) - aLowBorder(1)) * 0.01; // Run PSO on even distribution with 100 points.
+ //
+ GCPnts_DistFunction aFunc1(theCurve, u1, u2);
+ //
+ Standard_Real aValue;
+ math_Vector aT(1,1);
+ GCPnts_DistFunctionMV aFunc(aFunc1);
+
+ math_PSO aFinder(&aFunc, aLowBorder, aUppBorder, aSteps); // Choose 32 best points from 100 above.
+ aFinder.Perform(aSteps, aValue, aT);
+ Standard_Real d = 0.;
+
+ Standard_Real d1, d2;
+ Standard_Real x1 = Max(u1, aT(1) - aSteps(1));
+ Standard_Boolean Ok = aFunc1.Value(x1, d1);
+ if(!Ok)
+ {
+ return Sqrt(-aValue);
+ }
+ Standard_Real x2 = Min(u2, aT(1) + aSteps(1));
+ Ok = aFunc1.Value(x2, d2);
+ if(!Ok)
+ {
+ return Sqrt(-aValue);
+ }
+ if(!(d1 > aValue && d2 > aValue))
+ {
+ Standard_Real dmin = Min(d1, Min(aValue, d2));
+ return Sqrt(-dmin);
+ }
+
+ math_BrentMinimum anOptLoc(Precision::PConfusion());
+ anOptLoc.Perform(aFunc1, x1, aT(1), x2);
+
+ if (anOptLoc.IsDone())
+ {
+ d = -anOptLoc.Minimum();
+ }
+ else
+ {
+ d = -aValue;
+ }
+ return Sqrt(d);
+}
//=======================================================================
//function : crvpoints
Standard_Integer i, nbp;
Standard_Real defl;
+ Handle(Adaptor3d_HCurve) aHCurve;
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
+ if (C.IsNull())
+ {
+ // try getting a wire
+ TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
+ if (aWire.IsNull())
+ {
+ std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
+ return 1;
+ }
+ BRepAdaptor_CompCurve aCompCurve(aWire);
+ aHCurve = new BRepAdaptor_HCompCurve(aCompCurve);
+ }
+ else
+ {
+ aHCurve = new GeomAdaptor_HCurve(C);
+ }
+
defl = Draw::Atof(a[3]);
- GeomAdaptor_Curve GAC(C);
- GCPnts_QuasiUniformDeflection PntGen(GAC, defl);
+ GCPnts_QuasiUniformDeflection PntGen(aHCurve->Curve(), defl);
if(!PntGen.IsDone()) {
- di << "Points generation failed" << "\n";
+ di << "Points generation failed\n";
return 1;
}
Standard_Integer imax = 0;
//check deviation
- ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
- di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << i << "\n";
+ ComputeDeviation(aHCurve->Curve(), aPnts, dmax, ufmax, ulmax, imax);
+ di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
return 0;
}
static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- Standard_Integer i, nbp;
+ Standard_Integer i, nbp, aMinPntsNb = 2;
Standard_Real defl, angle = Precision::Angular();
+ Handle(Adaptor3d_HCurve) aHCurve;
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
+ if (C.IsNull())
+ {
+ // try getting a wire
+ TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
+ if (aWire.IsNull())
+ {
+ std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
+ return 1;
+ }
+ BRepAdaptor_CompCurve aCompCurve(aWire);
+ aHCurve = new BRepAdaptor_HCompCurve(aCompCurve);
+ }
+ else
+ {
+ aHCurve = new GeomAdaptor_HCurve(C);
+ }
defl = Draw::Atof(a[3]);
- if(n > 3)
+ if(n > 4)
angle = Draw::Atof(a[4]);
- GeomAdaptor_Curve GAC(C);
- GCPnts_TangentialDeflection PntGen(GAC, angle, defl, 2);
+ if(n > 5)
+ aMinPntsNb = Draw::Atoi (a[5]);
+
+ GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, aMinPntsNb);
nbp = PntGen.NbPoints();
di << "Nb points : " << nbp << "\n";
Standard_Integer imax = 0;
//check deviation
- ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
- di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << i << "\n";
+ ComputeDeviation(aHCurve->Curve(), aPnts, dmax, ufmax, ulmax, imax);
+ //
+ di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
return 0;
}
ellip = DrawTrSurf::GetBSplineCurve(a[1]);
if (ellip.IsNull())
{
- di << " BSpline is NULL "<<"\n";
+ di << " BSpline is NULL \n";
return 1;
}*/
ellip = DrawTrSurf::GetCurve(a[1]);
if (ellip.IsNull())
{
- di << " Curve is NULL "<<"\n";
+ di << " Curve is NULL \n";
return 1;
}
}
}
- catch (Standard_Failure )
+ catch (Standard_Failure const&)
{
- di << " Standard Failure " <<"\n";
+ di << " Standard Failure \n";
}
return 0;
}
return 1;
//test nbPoints for Geom_Ellipse
- Handle_Geom_Ellipse ellip;
+ Handle(Geom_Ellipse) ellip;
try
DBRep::Set("Ellipse",edge_curve);
}
- catch(Standard_Failure)
+ catch(Standard_Failure const&)
{
- di << " Standard Failure "<<"\n";
+ di << " Standard Failure \n";
}
try
}
}
- catch (Standard_Failure )
+ catch (Standard_Failure const&)
{
- di << " Standard Failure " <<"\n";
+ di << " Standard Failure \n";
}
return 0;
}
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
defl = Draw::Atof(a[3]);
- const Handle(Geom_BSplineCurve)& aBS = Handle(Geom_BSplineCurve)::DownCast(C);
+ Handle(Geom_BSplineCurve) aBS (Handle(Geom_BSplineCurve)::DownCast(C));
if(aBS.IsNull()) return 1;
Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
Standard_Integer imax = 0;
- ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
+ ComputeDeviation(GeomAdaptor_Curve(C),aPnts,dmax,ufmax,ulmax,imax);
di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
return 0;
//function : intersect
//purpose :
//=======================================================================
-static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n, const char** a)
- {
+static Standard_Integer intersection (Draw_Interpretor& di,
+ Standard_Integer n, const char** a)
+{
if (n < 4)
return 1;
-
+
//
Handle(Geom_Curve) GC1;
Handle(Geom_Surface) GS1 = DrawTrSurf::GetSurface(a[2]);
if (GS1.IsNull())
- {
+ {
GC1 = DrawTrSurf::GetCurve(a[2]);
if (GC1.IsNull())
return 1;
- }
+ }
//
Handle(Geom_Surface) GS2 = DrawTrSurf::GetSurface(a[3]);
//
Handle(Geom_Curve) Result;
gp_Pnt Point;
-
+
//
if (GC1.IsNull())
- {
+ {
GeomInt_IntSS Inters;
//
// Surface Surface
if (n <= 5)
- {
+ {
// General case
Inters.Perform(GS1,GS2,tol,Standard_True);
- }
+ }
else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
- {
+ {
Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
Standard_Real UVsta[4];
Handle(GeomAdaptor_HSurface) AS1,AS2;
-
+
//
if (n <= 9) // user starting point
- {
+ {
useBnd = Standard_False;
ista1 = 4;
ista2 = 7;
- }
+ }
else if (n <= 13) // user bounding
- {
+ {
useStart = Standard_False;
ibnd1 = 4; ibnd2 = 11;
- }
+ }
else // both user starting point and bounding
- {
+ {
ista1 = 4; ista2 = 7;
ibnd1 = 8; ibnd2 = 15;
- }
+ }
if (useStart)
- {
+ {
for (Standard_Integer i=ista1; i <= ista2; i++)
- {
+ {
UVsta[i-ista1] = Draw::Atof(a[i]);
- }
}
+ }
if (useBnd)
- {
+ {
Standard_Real UVbnd[8];
for (Standard_Integer i=ibnd1; i <= ibnd2; i++)
UVbnd[i-ibnd1] = Draw::Atof(a[i]);
AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
- }
+ }
//
if (useStart && !useBnd)
- {
+ {
Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
- }
+ }
else if (!useStart && useBnd)
- {
+ {
Inters.Perform(AS1,AS2,tol);
- }
+ }
else
- {
+ {
Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
- }
- }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
+ }
+ }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
else
- {
- di<<"incorrect number of arguments"<<"\n";
+ {
+ di<<"incorrect number of arguments\n";
return 1;
- }
+ }
//
if (!Inters.IsDone())
- {
- di<<"No intersections found!"<<"\n";
+ {
+ di<<"No intersections found!\n";
return 1;
- }
-
+ }
+
//
char buf[1024];
Standard_Integer i, aNbLines, aNbPoints;
-
+
//
aNbLines = Inters.NbLines();
if (aNbLines >= 2)
- {
+ {
for (i=1; i<=aNbLines; ++i)
- {
+ {
Sprintf(buf, "%s_%d",a[1],i);
di << buf << " ";
Result = Inters.Line(i);
const char* temp = buf;
DrawTrSurf::Set(temp,Result);
- }
}
+ }
else if (aNbLines == 1)
- {
+ {
Result = Inters.Line(1);
Sprintf(buf,"%s",a[1]);
di << buf << " ";
//
aNbPoints=Inters.NbPoints();
for (i=1; i<=aNbPoints; ++i)
- {
+ {
Point=Inters.Point(i);
Sprintf(buf,"%s_p_%d",a[1],i);
di << buf << " ";
const char* temp = buf;
DrawTrSurf::Set(temp, Point);
- }
- }// if (GC1.IsNull())
+ }
+ }// if (GC1.IsNull())
else
- {
+ {
// Curve Surface
GeomAPI_IntCS Inters(GC1,GS2);
-
+
//
if (!Inters.IsDone())
- {
- di<<"No intersections found!"<<"\n";
+ {
+ di<<"No intersections found!\n";
return 1;
- }
+ }
Standard_Integer nblines = Inters.NbSegments();
Standard_Integer nbpoints = Inters.NbPoints();
char newname[1024];
if ( (nblines+nbpoints) >= 2)
- {
+ {
Standard_Integer i;
Standard_Integer Compt = 1;
if(nblines >= 1)
- cout << " Lines: " << endl;
+ std::cout << " Lines: " << std::endl;
for (i = 1; i <= nblines; i++, Compt++)
- {
+ {
Sprintf(newname,"%s_%d",a[1],Compt);
di << newname << " ";
Result = Inters.Segment(i);
const char* temp = newname; // pour portage WNT
DrawTrSurf::Set(temp,Result);
- }
+ }
if(nbpoints >= 1)
- cout << " Points: " << endl;
+ std::cout << " Points: " << std::endl;
const Standard_Integer imax = nblines+nbpoints;
for (/*i = 1*/; i <= imax; i++, Compt++)
- {
+ {
Sprintf(newname,"%s_%d",a[1],i);
di << newname << " ";
Point = Inters.Point(i);
const char* temp = newname; // pour portage WNT
DrawTrSurf::Set(temp,Point);
- }
}
+ }
else if (nblines == 1)
- {
+ {
Result = Inters.Segment(1);
Sprintf(newname,"%s",a[1]);
di << newname << " ";
DrawTrSurf::Set(a[1],Result);
- }
+ }
else if (nbpoints == 1)
- {
+ {
Point = Inters.Point(1);
Sprintf(newname,"%s",a[1]);
di << newname << " ";
DrawTrSurf::Set(a[1],Point);
- }
}
+ }
dout.Flush();
return 0;
+}
+
+//=======================================================================
+//function : GetCurveContinuity
+//purpose : Returns the continuity of the given curve
+//=======================================================================
+static Standard_Integer GetCurveContinuity( Draw_Interpretor& theDI,
+ Standard_Integer theNArg,
+ const char** theArgv)
+{
+ if(theNArg != 2)
+ {
+ theDI << "Use: getcurvcontinuity {curve or 2dcurve} \n";
+ return 1;
+ }
+
+ char aContName[7][3] = {"C0", //0
+ "G1", //1
+ "C1", //2
+ "G2", //3
+ "C2", //4
+ "C3", //5
+ "CN"}; //6
+
+ Handle(Geom2d_Curve) GC2d;
+ Handle(Geom_Curve) GC3d = DrawTrSurf::GetCurve(theArgv[1]);
+ if(GC3d.IsNull())
+ {
+ GC2d = DrawTrSurf::GetCurve2d(theArgv[1]);
+ if(GC2d.IsNull())
+ {
+ theDI << "Argument is not a 2D or 3D curve!\n";
+ return 1;
+ }
+ else
+ {
+ theDI << theArgv[1] << " has " << aContName[GC2d->Continuity()] << " continuity.\n";
+ }
+ }
+ else
+ {
+ theDI << theArgv[1] << " has " << aContName[GC3d->Continuity()] << " continuity.\n";
}
+ return 0;
+}
+
//=======================================================================
//function : CurveCommands
//purpose :
intersection,g);
theCommands.Add("crvpoints",
- "crvpoints result curv deflection",
+ "crvpoints result <curve or wire> deflection",
__FILE__,
crvpoints,g);
theCommands.Add("crvtpoints",
- "crvtpoints result curv deflection angular deflection - tangential deflection points",
+ "crvtpoints result <curve or wire> deflection angular deflection - tangential deflection points",
__FILE__,
crvtpoints,g);
__FILE__,
surfpoints,g);
+ theCommands.Add("getcurvcontinuity",
+ "getcurvcontinuity {curve or 2dcurve}: \n\tReturns the continuity of the given curve",
+ __FILE__,
+ GetCurveContinuity,g);
+
+
}