#include <TopOpeBRepTool_ShapeClassifier.hxx>
#include <TopOpeBRepDS_EXPORT.hxx>
+#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <DrawTrSurf.hxx>
#include <Draw_Color.hxx>
#include <DBRep.hxx>
+#include <Extrema_ExtFlag.hxx>
+#include <Extrema_ExtAlgo.hxx>
+
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
static Standard_Integer drawbnd2d(Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n < 5) return 1;
- Standard_Integer i = atoi(a[4]);
+ Standard_Integer i = Draw::Atoi(a[4]);
TopoDS_Shape W = DBRep::Get(a[2]);
TopoDS_Shape F = DBRep::Get(a[3]);
if (W.IsNull() || F.IsNull()) return 1;
static Standard_Integer pntonc(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 3) return 1;
- Standard_Real x = atof(a[1]);
+ Standard_Real x = Draw::Atof(a[1]);
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
if (C.IsNull()) {di<<"null curve"<<"\n"; return 1;}
gp_Pnt p = C->Value(x);
static Standard_Integer pntonc2d(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 4) return 1;
- Standard_Real x = atof(a[1]);
+ Standard_Real x = Draw::Atof(a[1]);
Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);
if (C2d.IsNull()) {di<<"null curve"<<"\n"; return 1;}
Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[3]);
static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n < 3) return 1;
+ if (n < 3) {
+ di << "projponf f pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]\n";
+ return 1;
+ }
+ //
TopoDS_Shape aLocalShape = DBRep::Get(a[1]);
TopoDS_Face f = TopoDS::Face(aLocalShape);
-// TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1]));
- if (f.IsNull()) {di<<"null shape"<<"\n";return 1;}
- gp_Pnt p; DrawTrSurf::GetPoint(a[2], p);
- Standard_Real dist=0.; gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_projPonF(p,f,uv,dist);
- if (!ok) {di<<"projection failed"<<"\n"; return 1;}
- gp_Pnt pproj; ok = FUN_tool_value(uv,f,pproj);
- if (!ok) {di<<"projection failed"<<"\n"; return 1;}
+ //
+ if (f.IsNull()) {
+ di<<"null shape"<<"\n";
+ return 1;
+ }
+ //
+ Standard_Real dist=0.;
+ Standard_Boolean ok;
+ gp_Pnt2d uv;
+ gp_Pnt p, pproj;
+ Extrema_ExtAlgo anExtAlgo = Extrema_ExtAlgo_Grad;
+ Extrema_ExtFlag anExtFlag = Extrema_ExtFlag_MINMAX;
+ //
+ DrawTrSurf::GetPoint(a[2], p);
+ //
+ if (n > 3) {
+ const char* key1 = a[3];
+ const char* key2 = (n > 4) ? a[4] : NULL;
+ if (key1) {
+ if (!strcasecmp(key1,"-min")) {
+ anExtFlag = Extrema_ExtFlag_MIN;
+ } else if (!strcasecmp(key1,"-max")) {
+ anExtFlag = Extrema_ExtFlag_MAX;
+ } else {
+ anExtAlgo = (!strcasecmp(key1,"-t")) ? Extrema_ExtAlgo_Tree : anExtAlgo;
+ }
+ }
+ if (key2) {
+ anExtAlgo = (!strcasecmp(key2,"-t")) ? Extrema_ExtAlgo_Tree : anExtAlgo;
+ }
+ }
+ ok = FUN_tool_projPonF(p, f, uv, dist, anExtFlag, anExtAlgo);
+ //
+ if (!ok) {
+ di<<"projection failed"<<"\n";
+ return 1;
+ }
+ //
+ ok = FUN_tool_value(uv,f,pproj);
+ if (!ok) {
+ di<<"projection failed"<<"\n";
+ return 1;
+ }
+ //
di<<"proj dist = "<<dist<<" uvproj = ("<<uv.X()<<" "<<uv.Y();
di<<"); pproj = ("<<pproj.X()<<" "<<pproj.Y()<<" "<<pproj.Z()<<")"<<"\n";
return 0;
TopoDS_Shape s = DBRep::Get(a[1]);
if (s.IsNull()) {di<<"null shape"<<"\n";return 1;}
gp_Pnt p; DrawTrSurf::GetPoint(a[2], p);
- Standard_Real tol = atof(a[3]);
+ Standard_Real tol = Draw::Atof(a[3]);
TopOpeBRepTool_SolidClassifier soclassi;
TopAbs_State sta = TopAbs_UNKNOWN;
TopoDS_Shape s = DBRep::Get(a[1]);
if (s.IsNull()) {di<<"null shape"<<"\n";return 1;}
gp_Pnt p; DrawTrSurf::GetPoint(a[2], p);
- Standard_Real tol = atof(a[3]);
+ Standard_Real tol = Draw::Atof(a[3]);
BRepClass3d_SolidClassifier soclassi(s);
TopAbs_State sta = TopAbs_UNKNOWN;
// TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1]));
if (f.IsNull()) {di<<"null shape"<<"\n";return 1;}
gp_Pnt p; DrawTrSurf::GetPoint(a[2], p);
-#ifdef DEB
- Standard_Real length = atof(a[3]);
-#endif
+
Standard_Real dist=0.; gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_projPonF(p,f,uv,dist);
if (!ok) {di<<"projection failed"<<"\n"; return 1;}
#ifdef DEB
TopoDS_Face f = TopoDS::Face(aLocalShape);
// TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1]));
if (f.IsNull()) {di<<"null shape"<<"\n";return 1;}
- Standard_Real x = atof(a[2]);
- Standard_Real y = atof(a[3]);
- Standard_Real z = atof(a[4]);
+ Standard_Real x = Draw::Atof(a[2]);
+ Standard_Real y = Draw::Atof(a[3]);
+ Standard_Real z = Draw::Atof(a[4]);
Handle(Geom_Line) line = new Geom_Line(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Dir(x,y,z)));
BRepAdaptor_Surface BS(f);
Handle(Geom_Surface) su = BRep_Tool::Surface(f);
theCommands.Add("classibnd2d","classibnd2d W1 W2 F i", __FILE__, classifBnd2d, g);
theCommands.Add("pntonc", "pntonc par C3d", __FILE__, pntonc, g);
theCommands.Add("pntonc2d", "pntonc2d par C2d S", __FILE__, pntonc2d, g);
- theCommands.Add("projponf", "projponf f pnt", __FILE__, projponf, g);
+ theCommands.Add("projponf",
+ "projponf f pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]",
+ __FILE__, projponf, g);
theCommands.Add("tolmax", "tolmax s", __FILE__, tolmax, g);
theCommands.Add("normal", "normal f p3d length", __FILE__, normal, g);
theCommands.Add("curvature", "curvature f x y z", __FILE__, curvature , g);