0022627: Change OCCT memory management defaults
[occt.git] / src / GeometryTest / GeometryTest_TestProjCommands.cxx
CommitLineData
38f33510
J
1// File: GeometryTest_TestProjCommands.cxx
2// Created: 30.06.11 17:21:02
3// Author: jgv@ROLEX
4// Copyright: Open CASCADE 2011
5
6#include <GeometryTest.hxx>
7#include <Geom_Curve.hxx>
8#include <Geom_Surface.hxx>
9#include <GeomAPI_ProjectPointOnSurf.hxx>
10
11#include <DBRep.hxx>
12#include <DBRep_DrawableShape.hxx>
13#include <Draw_Interpretor.hxx>
14#include <Draw_Appli.hxx>
15#include <DrawTrSurf.hxx>
16#include <Draw_Marker3D.hxx>
17
18#include <stdio.h>
19#ifdef WNT
20Standard_IMPORT Draw_Viewer dout;
21#endif
22
23//=======================================================================
24//function : xdistcs
25//purpose :
26//=======================================================================
27static Standard_Integer xdistcs(Draw_Interpretor& , Standard_Integer n, const char** a)
28{
29 if (n<5) {
30 cout<<" Use xdistcs c s t1 t2 nbp"<<endl;
31 return 0;
32 }
33 //
34 Standard_Boolean bRet;
35 Standard_Integer i, aNbP, iSize;
36 Standard_Real aTol, aD, aT, aT1, aT2, dT;
37 gp_Pnt aP;
38 Handle(Geom_Curve) aC;
39 Handle(Geom_Surface) aS;
40 GeomAPI_ProjectPointOnSurf aPPS;
41 Handle(Draw_Marker3D) aMr;
42 Draw_Color aColor(Draw_rouge);
43 //
44 aTol=1.e-7;
45 //
46 aC=DrawTrSurf::GetCurve(a[1]);
47 if (aC.IsNull()) {
48 cout<<a[1]<<" is null curve"<<endl;
49 return 0;
50 }
51 //
52 aS=DrawTrSurf::GetSurface(a[2]);
53 if (aS.IsNull()) {
54 cout<<a[2]<<" is null"<<endl;
55 return 0;
56 }
57 //
58 aT1=atof(a[3]);
59 aT2=atof(a[4]);
60 //
61 aNbP=10;
62 if (n>5) {
63 aNbP=atoi(a[5]);
64 }
65 //
66 iSize=3;
67 //
68 dT=(aT2-aT1)/(aNbP-1);
69 for (i=0; i<aNbP; ++i) {
70 aT=aT1+i*dT;
71 if (i==aNbP-1) {
72 aT=aT2;
73 }
74 //
75 aC->D0(aT, aP);
76 aPPS.Init(aP, aS, aTol);
77 bRet=aPPS.IsDone();
78 if (!bRet) {
79 cout<<" GeomAPI_ProjectPointOnSurf failed"<<endl;
80 return 0;
81 }
82 //
83 aD=aPPS.LowerDistance();
84 printf(" T=%lg\tD=%lg\n", aT, aD);
85 //
86 aMr=new Draw_Marker3D(aP, Draw_Plus, aColor, iSize);
87 dout << aMr;
88 }
89 //
90 return 0;
91}
92
93//=======================================================================
94//function : TestProjCommands
95//purpose :
96//=======================================================================
97
98void GeometryTest::TestProjCommands(Draw_Interpretor& theCommands)
99{
100
101 static Standard_Boolean loaded = Standard_False;
102 if (loaded) return;
103 loaded = Standard_True;
104
105 DrawTrSurf::BasicCommands(theCommands);
106
107 const char* g;
108
109 g = "Testing of projection (geometric objects)";
110
111 theCommands.Add("xdistcs", "xdistcs c s t1 t2 nbp", __FILE__, xdistcs, g);
112}