0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / SWDRAW / SWDRAW_ShapeAnalysis.cxx
CommitLineData
b311480e 1// Created on: 1999-03-09
2// Created by: data exchange team
3// Copyright (c) 1999-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// sln 19.11.2001. Bug 2: Correction of output of 'statshape' draw function.
18
42cf5bc1 19#include <BRep_Builder.hxx>
20#include <BRep_Tool.hxx>
21#include <BRepBuilderAPI.hxx>
22#include <BRepBuilderAPI_MakeFace.hxx>
23#include <BRepGProp.hxx>
24#include <BRepTopAdaptor_FClass2d.hxx>
7fd59977 25#include <DBRep.hxx>
42cf5bc1 26#include <Draw.hxx>
7fd59977 27#include <DrawTrSurf.hxx>
42cf5bc1 28#include <Geom2d_Curve.hxx>
7fd59977 29#include <Geom_Curve.hxx>
30#include <Geom_Surface.hxx>
31#include <GeomAPI_ProjectPointOnSurf.hxx>
7fd59977 32#include <gp_Pnt.hxx>
33#include <gp_Pnt2d.hxx>
7fd59977 34#include <GProp_GProps.hxx>
42cf5bc1 35#include <Precision.hxx>
36#include <ShapeAnalysis.hxx>
37#include <ShapeAnalysis_Curve.hxx>
38#include <ShapeAnalysis_Edge.hxx>
39#include <ShapeAnalysis_FreeBoundData.hxx>
7fd59977 40#include <ShapeAnalysis_FreeBounds.hxx>
41#include <ShapeAnalysis_FreeBoundsProperties.hxx>
42cf5bc1 42#include <ShapeAnalysis_ShapeContents.hxx>
43#include <ShapeAnalysis_ShapeTolerance.hxx>
44#include <ShapeAnalysis_Surface.hxx>
ef57920a 45#include <ShapeAnalysis_Wire.hxx>
42cf5bc1 46#include <ShapeExtend_WireData.hxx>
47#include <ShapeFix_FreeBounds.hxx>
48#include <SWDRAW.hxx>
49#include <SWDRAW_ShapeAnalysis.hxx>
50#include <TCollection_AsciiString.hxx>
51#include <TColStd_MapOfInteger.hxx>
52#include <TopExp.hxx>
53#include <TopExp_Explorer.hxx>
54#include <TopoDS.hxx>
55#include <TopoDS_Compound.hxx>
56#include <TopoDS_Edge.hxx>
57#include <TopoDS_Face.hxx>
58#include <TopoDS_Iterator.hxx>
59#include <TopoDS_Shape.hxx>
60#include <TopoDS_Vertex.hxx>
61#include <TopoDS_Wire.hxx>
62#include <TopTools_HSequenceOfShape.hxx>
7fd59977 63
42cf5bc1 64#include <stdio.h>
7fd59977 65static Standard_Integer tolerance
66 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
67{
68 if (argc < 2) { di<<"myshape : analyses a shape\n"
69 << "myshape [mode] valmin : sub-shapes over valmin\n"
70 <<"myshape [mode] valmin valmax : between valmin and valmax\n"
71 <<"myshape [mode] 0 valmax : below valmax\n"
586db386 72 <<" more : all shapes(D) v vertices e edges f faces c combined(faces)\n";
7fd59977 73 return (argc < 2 ? 0 : 1 /* Error */); }
74 Standard_CString arg1 = argv[1];
75 TopoDS_Shape Shape = DBRep::Get(arg1);
76 if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
77
78 ShapeAnalysis_ShapeTolerance sat;
79 if (argc == 2) {
80 sat.InitTolerance();
81 sat.AddTolerance (Shape);
82 di<<"Tolerance MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
83 sat.InitTolerance();
84 sat.AddTolerance (Shape,TopAbs_FACE);
85 di<<"FACE : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
86 sat.InitTolerance();
87 sat.AddTolerance (Shape,TopAbs_EDGE);
88 di<<"EDGE : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
89 sat.InitTolerance();
90 sat.AddTolerance (Shape,TopAbs_VERTEX);
91 di<<"VERTEX : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
92 } else {
93// Analyse plus fouillee
94 Standard_Integer nextarg = 2;
95 char opt = argv[2][0];
96 TopAbs_ShapeEnum type = TopAbs_SHAPE;
97 if (opt == 'a') nextarg = 3;
98 else if (opt == 'c') { nextarg = 3; type = TopAbs_SHELL; }
99 else if (opt == 'e') { nextarg = 3; type = TopAbs_EDGE; }
100 else if (opt == 'f') { nextarg = 3; type = TopAbs_FACE; }
101 else if (opt == 'v') { nextarg = 3; type = TopAbs_VERTEX; }
102 if (nextarg < 3) opt = 'a';
103
104 Standard_Real tol1= 0., tol2= 0.;
91322f44 105 if (nextarg < argc) tol1 = Draw::Atof (argv[nextarg]);
106 if (nextarg < argc-1) tol2 = Draw::Atof (argv[nextarg+1]);
107// Standard_Real tol = Draw::Atof (argv[2]);
7fd59977 108 Handle(TopTools_HSequenceOfShape) list = sat.InTolerance (Shape,tol1,tol2,type);
109 Standard_Integer i, nb = list->Length();
110 switch (type) {
111 case TopAbs_VERTEX : di<<"Analysing Vertices gives "; break;
112 case TopAbs_EDGE : di<<"Analysing Edges gives "; break;
113 case TopAbs_FACE : di<<"Analysing Faces gives "; break;
114 case TopAbs_SHELL : di<<"Analysing Shells,Faces+content gives "; break;
115 default : di<<"Analysing all sub-shapes gives ";
116 }
117 if (tol1 == 0) di<<nb<<" Shapes below tol="<<tol2;
118 else if (tol2 == 0) di<<nb<<" Shapes over tol="<<tol1;
119 else di<<nb<<" Shapes between tol1="<<tol1<<" and tol2="<<tol2;
120 if (nb == 1) di<<" , named tol_1";
121 if (nb > 1) di<<" , named tol_1 to tol_"<<nb;
122 di<<"\n";
123 char nomsh[30];
124 for (i = 1; i <= nb; i ++) {
91322f44 125 Sprintf (nomsh,"tol_%d",i);
7fd59977 126 DBRep::Set (nomsh,list->Value(i));
127 }
128 }
129 return 0;
130}
131
132static Standard_Integer projface
133 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
134{
586db386 135 if (argc < 4) { di<<"Give FACE name and X Y [Z]\n"; return 1 /* Error */; }
7fd59977 136 Standard_CString arg1 = argv[1];
137 TopoDS_Shape Shape = DBRep::Get(arg1);
138 if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
586db386 139 if (Shape.ShapeType() != TopAbs_FACE) { di<<"Not a face\n"; return 1 /* Error */; }
7fd59977 140 TopoDS_Face F = TopoDS::Face (Shape);
141 Handle(Geom_Surface) thesurf = BRep_Tool::Surface (F); // pas locface
142// On y va
143 Standard_Real X,Y,Z,U,V;
91322f44 144 X = U = Draw::Atof (argv[2]);
145 Y = V = Draw::Atof (argv[3]);
7fd59977 146 if (argc > 4) {
91322f44 147 Z = Draw::Atof (argv[4]);
7fd59977 148 gp_Pnt P3D (X,Y,Z);
149 di<<" Point 3D X = "<<X<<" Y = "<<Y<<" Z = "<<Z<<"\n";
150 Standard_Real uf, ul, vf, vl;
151 thesurf->Bounds(uf, ul, vf, vl);
152
153 if (Precision::IsInfinite(uf)) uf = -1000;
154 if (Precision::IsInfinite(ul)) ul = 1000;
155 if (Precision::IsInfinite(vf)) vf = -1000;
156 if (Precision::IsInfinite(vl)) vl = 1000;
157 Standard_Real du = Abs(ul-uf)/10; Standard_Real dv = Abs(vl-vf)/10;
158
159 GeomAPI_ProjectPointOnSurf proj(P3D, thesurf, uf-du, ul+du, vf-dv, vl+dv);
160 Standard_Integer sol, nPSurf = proj.NbPoints();
586db386 161 di<<" Found "<<nPSurf<<" Points\n";
7fd59977 162 for (sol = 1; sol <= nPSurf; sol ++) {
163 di<<"n0 "<<sol<<" Distance "<<proj.Distance(sol);
164 proj.Parameters(sol, U,V);
165 di<<" U = "<<U<<" V = "<<V<<"\n";
166// reprojection
167 P3D = thesurf->Value (U,V);
168 di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
169 }
170// Que donne ShapeTool ?
171 P3D.SetCoord (X,Y,Z);
172 Handle(ShapeAnalysis_Surface) su = new ShapeAnalysis_Surface(thesurf);
173 gp_Pnt2d suval = su->ValueOfUV (P3D,BRep_Tool::Tolerance(F));
174 suval.Coord(U,V);
175 di<<"** ShapeAnalysis_Surface gives U = "<<U<<" V = "<<V<<"\n";
176 P3D = thesurf->Value(U,V);
177 di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
178
179 } else {
180 di<<" Point UV U = "<<U<<" V = "<<V<<"\n";
181 gp_Pnt P3D = thesurf->Value(U,V);
182 di<<" => proj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
183 }
184 return 0;
185}
186
187static Standard_Integer projcurve
188 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
189{
190// admet une EDGE ou une CURVE
586db386 191 if (argc < 5) { di<<"Give : EDGE X Y Z or CURVE3D X Y Z or CURVE3D first last X Y Z\n"; return 1 /* Error */; }
7fd59977 192 const char * arg1 = argv[1];
193 Standard_Integer i0 = 0;
194 TopoDS_Shape Shape = DBRep::Get(arg1);
195
196 Handle(Geom_Curve) C; Standard_Real cf,cl;
197 if (!Shape.IsNull()) {
198 if (Shape.ShapeType() == TopAbs_EDGE) {
199 TopoDS_Edge E = TopoDS::Edge(Shape);
200 C = BRep_Tool::Curve (E,cf,cl);
201 di<<"Edge "<<arg1<<" Params from "<<cf<<" to "<<cl<<"\n";
202 } else {
586db386 203 di<<"SHAPE "<<arg1<<" Not an EDGE\n"; return 1 /* Error */;
7fd59977 204 }
205 } else {
206 const char* a1 = arg1;
207 C = DrawTrSurf::GetCurve (a1);
208 if (C.IsNull())
586db386 209 { di<<arg1<<" neither EDGE nor CURVE 3D\n"; return 1 /* Error */; }
7fd59977 210 cf = C->FirstParameter(); cl = C->LastParameter();
91322f44 211 if (argc >= 7) { cf = Draw::Atof (argv[2]); cl = Draw::Atof (argv[3]); i0 = 2; }
7fd59977 212 di<<"Curve 3D "<<arg1<<" Params from "<<cf<<" to "<<cl<<"\n";
213 }
214
215 Standard_Real X,Y,Z;
91322f44 216 X = Draw::Atof (argv[2+i0]);
217 Y = Draw::Atof (argv[3+i0]);
218 Z = Draw::Atof (argv[4+i0]);
7fd59977 219 di<<"Precision (BRepBuilderAPI) : "<<BRepBuilderAPI::Precision()
220 <<" Projection : "<<X<<" "<<Y<<" "<<Z<<"\n";
221
222 gp_Pnt P3D (X,Y,Z);
223 gp_Pnt res; Standard_Real param,dist;
224
225 dist = ShapeAnalysis_Curve().Project (C,P3D,BRepBuilderAPI::Precision(),res,param, cf,cl);
226 res.Coord(X,Y,Z);
586db386 227 di<<"Result : "<<X<<" "<<Y<<" "<<Z<<"\nParam = "<<param<<" Gap = "<<dist<<"\n";
7fd59977 228 return 0;
229}
230
231static Standard_Integer anaface
232 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
233{
586db386 234 if (argc < 2) { di<<"donner un nom de face\n"; return 1 /* Error */; }
7fd59977 235 Standard_CString arg1 = argv[1];
236 TopoDS_Shape Shape = DBRep::Get(arg1);
586db386 237 if (Shape.IsNull()) { di<<arg1<<" inconnu\n"; return 1 /* Error */; }
238// if (Shape.ShapeType() != TopAbs_FACE) { di<<"Pas une FACE\n"; return 1 /* Error */; }
7fd59977 239
240// On regarde les wires, sont-ils bien fermes
241 Standard_Integer nbw = 0, nbe = 0;
242 Handle(Geom_Surface) surface;
243 TopoDS_Face Face;
244 if (Shape.ShapeType() == TopAbs_FACE) {
245 Face = TopoDS::Face(Shape);
246 surface = BRep_Tool::Surface (Face); // pas locface
247// TopLoc_Location locface;
248 di<<"Face, surface type = "<<surface->DynamicType()->Name()<<" Tol="<<BRep_Tool::Tolerance(Face);
249 if (Face.Orientation() == TopAbs_REVERSED) {
250 di<<" (REV)";
251// Face.Orientation(TopAbs_FORWARD);
252 }
253 di<<"\n";
254 }
586db386 255 else { di<<"Analyse Wires, Ignore Faces\n"; }
7fd59977 256 Standard_Boolean iasurf = !surface.IsNull();
257//:sw if (!Face.IsNull()) STW.SetFace (Face);
258//:sw else STW.SetPrecision (BRepBuilderAPI::Precision());
259
260 for (TopExp_Explorer exp(Shape,TopAbs_WIRE); exp.More(); exp.Next()) {
261 TopoDS_Wire Wire = TopoDS::Wire (exp.Current()); nbw ++; nbe = 0;
262 di<<"WIRE "<<nbw;
586db386 263 if (Wire.Orientation() == TopAbs_FORWARD) di<<" (FWD)\n";
264 else di<<" (REV)\n";
7fd59977 265 gp_Pnt fin,debut;
266 gp_Pnt2d finuv,debuv; gp_XY baseuv;
267 TopoDS_Vertex fv,lv;
268 Standard_Real maxp3d = 0., maxuv = 0., maxvtx = 0.;
269 Standard_Real df3d= 0.,dl3d= 0.,dvtx= 0.,duv= 0.;
270 Standard_Boolean iaw2d = iasurf;
271 Standard_Real u1= 0.,u2= 0.,v1= 0.,v2= 0.,umin= 0.,umax= 0.,vmin= 0.,vmax= 0., totcross= 0.;
272
273//:sw STW.ClearWire(); STW.Load (Wire);
586db386 274// if (STW.Reorder()) di<<"Wire reordered to explore\n";
7fd59977 275// for (TopExp_Explorer exe(Wire.Oriented(TopAbs_FORWARD),TopAbs_EDGE); exe.More(); exe.Next()) {
276// TopoDS_Edge Edge = TopoDS::Edge (exe.Current()); nbe ++;
277//:sw for (nbe = 1; nbe <= STW.NbEdges(); nbe ++) {
278//:sw TopoDS_Edge Edge = STW.Edge(nbe);
279 TopoDS_Iterator it (Wire); //:sw: ShapeTool_Wire -> TopoDS_Iterator (it is the same)
280 for (; it.More(); it.Next()) {
281 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
282
283 di<<"Wire "<<nbw<<", Edge "<<nbe;
284 if (Edge.Orientation() == TopAbs_FORWARD) di<<" (FWD";
285 else di<<" (REV";
586db386 286 di<<" , Tol= "<<BRep_Tool::Tolerance (Edge)<<" )\n";
7fd59977 287 Standard_Real f3d,l3d,f2d,l2d;
288 Handle(Geom_Curve) curve3d = BRep_Tool::Curve (Edge,f3d,l3d);
289 Handle(Geom2d_Curve) curve2d;
290 if (iasurf) curve2d = BRep_Tool::CurveOnSurface(Edge,Face,f2d,l2d);
291 Standard_Boolean ia2d = !curve2d.IsNull(); iaw2d |= ia2d;
586db386 292 if (!ia2d) di<<"-- No PCurve\n";
293 if (curve3d.IsNull()) di<<"-- no Curve 3d\n";
7fd59977 294
295// On va tacher de calculer les positions et les comparer
296 gp_Pnt2d fuv,luv;
297 if (Edge.Orientation() == TopAbs_FORWARD)
298 { TopExp::Vertices (Edge,fv,lv);
299 if (ia2d) BRep_Tool::UVPoints (Edge,Face,fuv,luv); }
300 else
301 { TopExp::Vertices (Edge,lv,fv);
302 if (ia2d) BRep_Tool::UVPoints (Edge,Face,luv,fuv); }
303 gp_Pnt fp = BRep_Tool::Pnt (fv);
304 gp_Pnt lp = BRep_Tool::Pnt (lv);
305 gp_Pnt fxyz, lxyz;
306 if (ia2d) {
307 surface->D0 (fuv.X(),fuv.Y(),fxyz);
308 surface->D0 (luv.X(),luv.Y(),lxyz);
309 df3d = fp.Distance (fxyz); maxp3d = Max (maxp3d,df3d);
310 dl3d = lp.Distance (lxyz); maxp3d = Max (maxp3d,dl3d);
311 if (nbe > 1) duv = finuv.Distance (fuv); maxuv = Max (maxuv, duv);
312// et les min-max
313 u1 = Min (fuv.X(),luv.X()); u2 = Max (fuv.X(),luv.X());
314 v1 = Min (fuv.Y(),luv.Y()); v2 = Max (fuv.Y(),luv.Y());
315 if (nbe == 1) { umin = u1; umax = u2; vmin = v1; vmax = v2; }
316 else { umin = Min(umin,u1); umax = Max(umax,u2); vmin = Min(vmin,v1); vmax = Max(vmax,v2); }
317// et la classification directe
318 if (nbe == 1) { baseuv = fuv.XY(); totcross = 0; }
319 else {
320 gp_XY buv1 = fuv.XY() - baseuv;
321 gp_XY buv2 = luv.XY() - baseuv;
322 totcross += buv2.Crossed(buv1);
323 }
324 }
325
326// Resultats ...
327 if (nbe == 1) { debut = fxyz; debuv = fuv; }
328 else {
329 duv = finuv.Distance (fuv); maxuv = Max (maxuv, duv);
330 dvtx = fin.Distance (fxyz); maxvtx = Max (maxvtx,dvtx);
331 di<<" Fin("<<nbe-1<<")-Debut("<<nbe<<"): DISTANCE="<<dvtx;
332 if (ia2d) di<<" DeltaUV="<<duv;
333 di<<" Tol(Fin)="<<BRep_Tool::Tolerance(lv)<<"\n";
334 }
335 fin = lxyz; finuv = luv;
336
337 di<<"-- Deb : VTX="<<fp.X()<<" , "<<fp.Y()<<" , "<<fp.Z()
338 <<"\n XYZ="<<fxyz.X()<<" , "<<fxyz.Y()<<" , "<<fxyz.Z()
339 <<"\n UV="<<fuv.X()<<" , "<<fuv.Y()<<" -- D.UV/3D="<<df3d<<"\n";
340 di<<"-- Fin : VTX="<<lp.X()<<" , "<<lp.Y()<<" , "<<lp.Z()
341 <<"\n XYZ="<<lxyz.X()<<" , "<<lxyz.Y()<<" , "<<lxyz.Z()
342 <<"\n UV="<<luv.X()<<" , "<<luv.Y()<<" -- D.UV/3D="<<dl3d<<"\n";
343 }
344 dvtx = fin.Distance (debut); maxvtx = Max (maxvtx,dvtx);
345 if (iaw2d) { duv = finuv.Distance (debuv); maxuv = Max (maxuv, duv); }
346 di<<" Fin("<<nbe<<")-Debut(1): DISTANCE="<<dvtx;
347 if (iaw2d) di <<" DeltaUV="<<duv;
348 di<<" Tol(Fin)="<<BRep_Tool::Tolerance(lv)<<"\n";
349
350 di<<" Wire "<<nbw<<" Max : Dist.Vertex="<<maxvtx;
351 if (iaw2d) di<<" Ecart UV/3D="<<maxp3d<<" DeltaUV="<<maxuv;
352 di<<"\n";
353// Min Max
354 if (iaw2d) {
355 di<<"TotCross="<<totcross;
356 di<<" UMin-Max:"<<umin<<" , "<<umax<<" VMin-Max:"<<vmin<<" , "<<vmax<<"\n";
357 Standard_Real difu = umax - umin, difv = vmax - vmin;
358 GProp_GProps G;
359 BRepGProp::SurfaceProperties(Face,G);
586db386 360 if (G.Mass() > 0) di<<"GProps:Mass Out\n";
361 else di<<"GProps:Mass In\n";
7fd59977 362/// return (G.Mass() > 0);
363 BRepTopAdaptor_FClass2d fcl (Face,BRep_Tool::Tolerance(Face));
586db386 364 if (fcl.PerformInfinitePoint () == TopAbs_OUT) di<<"Classifier Infinite : Out\n";
365 else di<<"Classifier Infinite : In\n";
7fd59977 366 gp_Pnt2d pcl;
367 pcl.SetCoord(umin-difu,vmin-difv);
586db386 368 if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMin-VMin : Out\n";
7fd59977 369 pcl.SetCoord(umin-difu,vmax+difv);
586db386 370 if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMin-VMax : Out\n";
7fd59977 371 pcl.SetCoord(umax+difu,vmin-difv);
586db386 372 if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMax-VMin : Out\n";
7fd59977 373 pcl.SetCoord(umax+difu,vmax+difv);
586db386 374 if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMax-VMax : Out\n";
7fd59977 375 }
376 }
586db386 377 if (ShapeAnalysis::IsOuterBound (Face)) di<<"ShapeAnalysis: Outer Bound\n";
378 else di<<"ShapeAnalysis: Not Outer Bound\n";
379 di<<" Total "<<nbw<<" Wire(s)\n";
7fd59977 380 return 0;
381}
382
383static Standard_Integer XSHAPE_statshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
384{
586db386 385 if (argc < 2) { di<<"ShapeName; + options : prefix for particular cases : what to get\n"; return 1 /* Error */; }
7fd59977 386 Standard_CString arg1 = argv[1];
387 Standard_CString arg2 = NULL;
388 Standard_CString arg3 = NULL;
389 if (argc > 2) arg2 = argv[2];
390 if (argc > 3) arg3 = argv[3];
391 TopoDS_Shape Shape = DBRep::Get(arg1);
392 if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
393 char nompart[100];
394 Standard_Integer nb;
395
396 ShapeAnalysis_ShapeContents analyzer;
397 if(argc > 3) {
398 analyzer.ModifyBigSplineMode()=(strstr("bigspl",arg3)!=NULL);
399 analyzer.ModifyIndirectMode()=(strstr("indsur",arg3)!=NULL);
400 analyzer.ModifyOffestSurfaceMode()=(strstr("ofsur",arg3)!=NULL);
401 analyzer.ModifyTrimmed3dMode()=(strstr("trc3d",arg3)!=NULL);
402 analyzer.ModifyOffsetCurveMode()=(strstr("ofcur",arg3)!=NULL);
403 analyzer.ModifyTrimmed2dMode()=(strstr("trc2d",arg3)!=NULL);
404 }
405 analyzer.Perform(Shape);
406
586db386 407 di<<"Count Item\n----- ----\n";
7fd59977 408 nb = analyzer.NbEdges();
586db386 409 if(nb>0) di<<nb<<" EDGE (Oriented)\n";
7fd59977 410 nb = analyzer.NbSharedEdges();
586db386 411 if(nb>0) di<<nb<<" EDGE (Shared)\n";
7fd59977 412 nb = analyzer.NbFreeEdges();
586db386 413 if(nb>0) di<<nb<<" EDGE (Free)\n";
7fd59977 414 nb = analyzer.NbFaces();
586db386 415 if(nb>0) di<<nb<<" FACE\n";
7fd59977 416 nb = analyzer.NbFreeFaces();
586db386 417 if(nb>0) di<<nb<<" FACE (Free)\n";
7fd59977 418 nb = analyzer.NbFreeWires();
586db386 419 if(nb>0) di<<nb<<" WIRE (Free)\n";
7fd59977 420 nb = analyzer.NbShells();
586db386 421 if(nb>0) di<<nb<<" SHELL\n";
7fd59977 422 nb = analyzer.NbSolids();
586db386 423 if(nb>0) di<<nb<<" SOLID\n";
7fd59977 424 nb = analyzer.NbVertices();
586db386 425 if(nb>0) di<<nb<<" VERTEX (Oriented)\n";
7fd59977 426 nb = analyzer.NbSharedVertices();
586db386 427 if(nb>0) di<<nb<<" VERTEX (Shared)\n";
7fd59977 428 nb = analyzer.NbWires();
586db386 429 if(nb>0) di<<nb<<" WIRE\n";
7fd59977 430 nb = analyzer.NbFaceWithSevWires();
586db386 431 if(nb>0) di<<nb<<" Face with more than one wire\n";
7fd59977 432 nb = analyzer.NbNoPCurve();
586db386 433 if(nb>0) di<<nb<<" No pcurve\n";
7fd59977 434 nb = analyzer.NbSolidsWithVoids();
586db386 435 if(nb>0) di<<nb<<" SOLID with voids\n";
7fd59977 436 nb = analyzer.NbWireWitnSeam();
586db386 437 if(nb>0) di<<nb<<" Wire(s) with one seam edge\n";
7fd59977 438 nb = analyzer.NbWireWithSevSeams();
586db386 439 if(nb>0) di<<nb<<" Wire(s) with several seam edges\n";
7fd59977 440 nb = analyzer.NbBigSplines();
586db386 441 if(nb>0) di<<nb<<" bigspl : BSpline > 8192 poles\n";
7fd59977 442 nb = analyzer.NbBezierSurf();
586db386 443 if(nb>0) di<<nb<<" bezsur : BezierSurface\n";
7fd59977 444 nb = analyzer.NbBSplibeSurf();
586db386 445 if(nb>0) di<<nb<<" bspsur : BSplineSurface\n";
7fd59977 446 nb = analyzer.NbC0Curves();
586db386 447 if(nb>0) di<<nb<<" c0curv : Curve Only C0\n";
7fd59977 448 nb = analyzer.NbC0Surfaces();
586db386 449 if(nb>0) di<<nb<<" c0surf : Surface Only C0\n";
7fd59977 450 nb = analyzer.NbIndirectSurf();
586db386 451 if(nb>0) di<<nb<<" indsur : Indirect Surface\n";
7fd59977 452 nb = analyzer.NbOffsetCurves();
586db386 453 if(nb>0) di<<nb<<" ofcur : Offset Curve(s)\n";
7fd59977 454 nb = analyzer.NbOffsetSurf();
586db386 455 if(nb>0) di<<nb<<" ofsur : Offset Surface\n";
7fd59977 456 nb = analyzer.NbTrimmedCurve2d();
586db386 457 if(nb>0) di<<nb<<" trc2d : Trimmed Curve2d\n";
7fd59977 458 nb = analyzer.NbTrimmedCurve3d();
586db386 459 if(nb>0) di<<nb<<" trc3d : Trimmed Curve3d\n";
7fd59977 460 nb = analyzer.NbTrimSurf();
586db386 461 if(nb>0) di<<nb<<" trimsu : RectangularTrimmedSurface\n";
7fd59977 462
463 if(arg3 ==NULL) return 0;
464
465 Handle(TopTools_HSequenceOfShape) sec;
466 if(analyzer.ModifyBigSplineMode()) {
467 sec = analyzer.BigSplineSec();
468 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 469 Sprintf(nompart,"%s_bigspl_%d",arg2,i);
7fd59977 470 DBRep::Set (nompart,sec->Value(i));
471 }
472 }
473 if(analyzer.ModifyIndirectMode()) {
474 sec = analyzer.IndirectSec();
475 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 476 Sprintf(nompart,"%s_indsur_%d",arg2,i);
7fd59977 477 DBRep::Set (nompart,sec->Value(i));
478 }
479 }
480 if(analyzer.ModifyOffestSurfaceMode()) {
481 sec = analyzer.OffsetSurfaceSec();
482 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 483 Sprintf(nompart,"%s_ofsur_%d",arg2,i);
7fd59977 484 DBRep::Set (nompart,sec->Value(i));
485 }
486 }
487 if(analyzer.ModifyTrimmed3dMode()) {
488 sec = analyzer.Trimmed3dSec();
489 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 490 Sprintf(nompart,"%s_trc3d_%d",arg2,i);
7fd59977 491 DBRep::Set (nompart,sec->Value(i));
492 }
493 }
494 if(analyzer.ModifyOffsetCurveMode()) {
495 sec = analyzer.OffsetCurveSec();
496 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 497 Sprintf(nompart,"%s_ofcur_%d",arg2,i);
7fd59977 498 DBRep::Set (nompart,sec->Value(i));
499 }
500 }
501 if(analyzer.ModifyTrimmed2dMode()) {
502 sec = analyzer.Trimmed2dSec();
503 for(Standard_Integer i = 1; i <= sec->Length(); i++) {
91322f44 504 Sprintf(nompart,"%s_trc2d_%d",arg2,i);
7fd59977 505 DBRep::Set (nompart,sec->Value(i));
506 }
507 }
508 return 0;
509}
510
511static Standard_Integer XSHAPE_comptoledge
512 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
513{
514 if ( argc <2 ) {
515 di << "Use:\n"
516 "> comptol shape [nbpoints=371] [prefix]\n\n"
517 "Computes real tolerance of edges in the shape \n"
518 "as maximal deviation of 3d curve and pcurves.\n"
519 "Deviation is computed by nbpoints sample points (default is 371).\n"
520 "Gives the max, min and average value on all edges in the shape\n"
521 "If prefix is defined, edges with maximal real tolerance and\n"
586db386 522 "relation (and corresponding faces) will be saved with such names\n\n";
7fd59977 523 return 0;
524 }
525
526 TopoDS_Shape shape = DBRep::Get(argv[1]);
586db386 527 if (shape.IsNull()) { di << "Shape name \"" << argv[1] << "\" is invalid\n"; return 1; }
7fd59977 528 Standard_Integer nbpnts = 371;
529 Standard_CString prefix = 0;
530 if ( argc >2 ) {
531 if ( IsDigit(argv[2][0]) ) {
91322f44 532 nbpnts = Draw::Atoi(argv[2]);
7fd59977 533 if ( nbpnts <2 ) nbpnts = 2;
534 if ( argc >3 ) prefix = argv[3];
535 }
536 else prefix = argv[2];
537 }
538
539 Standard_Integer num = 0;
540 Standard_Real max=0, min=0, ave=0.;
541 Standard_Real relmax=0, relmin=0, relave=0.;
542 ShapeAnalysis_Edge sae;
543 TopoDS_Edge edmax, edmaxrel;
544 for ( TopExp_Explorer exp(shape,TopAbs_EDGE); exp.More(); exp.Next() ) {
545 Standard_Real tol;
546 TopoDS_Edge edge = TopoDS::Edge(exp.Current());
547 sae.CheckSameParameter ( edge, tol, nbpnts );
548 Standard_Real t = BRep_Tool::Tolerance(edge);
549 Standard_Real rel = tol / ( t > Precision::Confusion() ? t : Precision::Confusion() );
550 ave += tol;
551 relave += rel;
552 if ( ! num ) { max = min = tol; relmax = relmin = rel; edmax = edmaxrel = edge; }
553 else {
554 if ( max < tol ) { max = tol; edmax = edge; }
555 if ( min > tol ) min = tol;
556 if ( relmax < rel ) { relmax = rel; edmaxrel = edge; }
557 if ( relmin > rel ) relmin = rel;
558 }
559 num++;
560 }
586db386 561 if ( ! num ) { di << "No edges found in the shape\n"; return 1; }
7fd59977 562
563 di << "Edges tolerance computed by " << nbpnts << " points: \n"
564 "MAX=" << max << " AVG=" << ave/num << " MIN=" << min << "\n";
565 di << "Relation real tolerance / tolerance set in edge\n"
566 "MAX=" << relmax << " AVG=" << relave/num << " MIN=" << relmin << "\n";
567 if ( prefix && prefix[0] ) {
568 char name[21];
91322f44 569 Sprintf ( name, "%.10s_edge_tol", prefix );
7fd59977 570 DBRep::Set (name,edmax);
571 di << "Edge with max tolerance saved to " << name;
572 if ( edmax.IsSame ( edmaxrel ) ) di << "\n";
573 else {
91322f44 574 Sprintf ( name, "%.10s_edge_rel", prefix );
7fd59977 575 DBRep::Set (name,edmaxrel);
576 di << "; edge with max relation saved to " << name << "\n";
577 }
578 Standard_Integer num1=0;
579 for ( TopExp_Explorer fac(shape,TopAbs_FACE); fac.More(); fac.Next() ) {
580 TopoDS_Face face = TopoDS::Face ( fac.Current() );
581 for ( TopExp_Explorer ed(face,TopAbs_EDGE); ed.More(); ed.Next() ) {
582 TopoDS_Edge edge = TopoDS::Edge ( ed.Current() );
583 if ( edge.IsSame ( edmax ) || edge.IsSame ( edmaxrel ) ) {
584 if ( ! num1 ) di << "Concerned faces saved to shapes ";
91322f44 585 Sprintf ( name, "%.10s_%d", prefix, num1+1 );
7fd59977 586 DBRep::Set (name,face);
587 //cout << ( num1 ? ", " : "" ) << name;
588 if (num1 == 0) {
589 di << "" << name;
590 } else {
591 di << ", " << name;
592 }
593 num1++;
594 break;
595 }
596 }
597 }
598 if ( num1 >0 ) di << "\n";
599 }
600 return 0;
601}
602
603
604//=======================================================================
605//function : freebounds
606//purpose :
607//=======================================================================
608static Standard_Integer freebounds (Draw_Interpretor& di,
609 Standard_Integer n, const char** a)
610{
611 if ((n < 3) || (n > 5)) return 1;
612 TopoDS_Shape shape = DBRep::Get(a[1]);
613 if (shape.IsNull()) return 1;
91322f44 614 Standard_Real toler = Draw::Atof (a[2]);
7fd59977 615 Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
dde68833 616 if ( n > 3) splitclosed = Draw::Atoi (a[3]) != 0;
617 if ( n > 4) splitopen = Draw::Atoi (a[4]) != 0;
7fd59977 618
619 ShapeAnalysis_FreeBounds F;
620 if (toler <= 0)
621 F = ShapeAnalysis_FreeBounds (shape, splitclosed, splitopen);
622 else
623 F = ShapeAnalysis_FreeBounds (shape, toler, splitclosed, splitopen);
624
625 char name[100];
626 TopoDS_Shape wires = F.GetClosedWires();
91322f44 627 Sprintf (name, "%s_c", a[1]);
7fd59977 628 DBRep::Set (name, wires);
586db386 629 di << name << " - closed wires\n";
7fd59977 630 wires = F.GetOpenWires();
91322f44 631 Sprintf (name, "%s_o", a[1]);
7fd59977 632 DBRep::Set (name, wires);
586db386 633 di << name << " - open wires\n";
7fd59977 634
635 return 0;
636}
637
638
639//=======================================================================
640//function : PrintProps
641//purpose : auxilary for FreeBoundsProps
642//=======================================================================
643static void PrintProps(Standard_Integer i,
644 const Handle(ShapeAnalysis_FreeBoundData)& fbd,
645 Draw_Interpretor& di)
646{
647 char str[100];
648
649 Standard_Real area = fbd->Area();
650 Standard_Real perimeter = fbd->Perimeter();
651 Standard_Real ratio = fbd->Ratio();
652 Standard_Real width = fbd->Width();
653 Standard_Integer notch = fbd->NbNotches();
91322f44 654 Sprintf(str," %d\t%12.5f\t%12.5f\t%12.5f\t%12.5f\t%d", i, area, perimeter, ratio, width, notch);
7fd59977 655 di<<str<<"\n";
656}
657
658
659//=======================================================================
660//function : FreeBoundsProps
661//purpose :
662//=======================================================================
663static Standard_Integer FreeBoundsProps(Draw_Interpretor& di,
664 Standard_Integer n, const char** a)
665{
666 if ( (n < 2)||(n > 5) ) {
586db386 667 di<<"Usage : freeprops shapename [tolerance [splitclosed [splitopen]]]\n";
7fd59977 668 return 1;
669 }
670
671 TopoDS_Shape source = DBRep::Get(a[1]);
672 if (source.IsNull()) {
673 di<<"Error : unknown shape "<<a[1]<<"\n";
674 return 1;
675 }
676
677 Standard_Real toler = 0.;
678 Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
91322f44 679 if (n > 2) toler = Draw::Atof(a[2]);
dde68833 680 if (n > 3) splitclosed = Draw::Atoi(a[3]) != 0;
681 if (n > 4) splitopen = Draw::Atoi(a[4]) != 0;
7fd59977 682 ShapeAnalysis_FreeBoundsProperties analyzer;
683 if (toler > 0)
684 analyzer.Init(source, toler, splitclosed, splitopen);
685 else
686 analyzer.Init(source, splitclosed, splitopen);
687 analyzer.Perform();
688 TopoDS_Compound closed, open;
689 BRep_Builder B;
690
691 Standard_Integer nb = analyzer.NbClosedFreeBounds();
692 di<<"\n";
586db386 693 di<<" \tArea mm2\tLength mm\tRatio L/W\tWidth mm\tNb noth\n";
7fd59977 694 B.MakeCompound(closed);
695 if (nb) {
586db386 696 di<<"Closed bounds properties\n";
7fd59977 697 for (Standard_Integer i=1; i <= nb; i++) {
698 Handle(ShapeAnalysis_FreeBoundData) fbd = analyzer.ClosedFreeBound(i);
699 PrintProps(i, fbd, di);
700 B.Add(closed,fbd->FreeBound());
701 }
702 }
703
704 nb = analyzer.NbOpenFreeBounds();
705 B.MakeCompound(open);
706 if (nb) {
586db386 707 di<<"Open bounds properties\n";
7fd59977 708 for (Standard_Integer i=1; i <= nb; i++) {
709 Handle(ShapeAnalysis_FreeBoundData) fbd = analyzer.OpenFreeBound(i);
710 PrintProps(i, fbd, di);
711 B.Add(open,fbd->FreeBound());
712 }
713 }
714
715 char name[100];
91322f44 716 Sprintf (name, "%s_c",a[1]);
7fd59977 717 di << name << " - closed wires, ";
718 DBRep::Set(name, closed);
91322f44 719 Sprintf (name, "%s_o",a[1]);
586db386 720 di << name << " - closed wires \n";
7fd59977 721 DBRep::Set(name, open);
722 return 0;
723}
724
725
726//=======================================================================
727//function : closefreebounds
728//purpose :
729//=======================================================================
730static Standard_Integer closefreebounds (Draw_Interpretor& di,
731 Standard_Integer n, const char** a)
732{
733 if ((n < 4) || (n > 6)) return 1;
734 TopoDS_Shape shape = DBRep::Get(a[1]);
735 if (shape.IsNull()) return 1;
91322f44 736 Standard_Real sewtoler = Draw::Atof (a[2]), closetoler = Draw::Atof (a[3]);
7fd59977 737 Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
dde68833 738 if ( n > 4) splitclosed = Draw::Atoi (a[3]) != 0;
739 if ( n > 5) splitopen = Draw::Atoi (a[4]) != 0;
7fd59977 740
741 ShapeFix_FreeBounds F;
742 if (sewtoler <= 0)
743 F = ShapeFix_FreeBounds (shape, closetoler, splitclosed, splitopen);
744 else
745 F = ShapeFix_FreeBounds (shape, sewtoler, closetoler, splitclosed, splitopen);
746
747 char name[100];
748 TopoDS_Shape wires = F.GetClosedWires();
91322f44 749 Sprintf (name, "%s_c", a[1]);
7fd59977 750 DBRep::Set (name, wires);
586db386 751 di << name << " - closed wires\n";
7fd59977 752 wires = F.GetOpenWires();
91322f44 753 Sprintf (name, "%s_o", a[1]);
7fd59977 754 DBRep::Set (name, wires);
586db386 755 di << name << " - open wires\n";
7fd59977 756
757 return 0;
758}
759
760
761//=======================================================================
762//function : MyVISEDG
763//purpose :
764//=======================================================================
765static Standard_Integer MyVISEDG (Draw_Interpretor& /*di*/,
766 Standard_Integer n, const char** a)
767{
768 if (n >4) return 1;
769 TopoDS_Shape MaListe = DBRep::Get(a[1]);
770 if (MaListe.IsNull()) return 1;
771 TopoDS_Compound TheList = TopoDS::Compound(MaListe);
772 if (TheList.IsNull()) return 1;
773 Standard_Real toler = 0.001;
774 int create = 0;
91322f44 775 if ( n >= 3) toler = Draw::Atof(a[2]);
7fd59977 776 if (n == 4 && !strcmp(a[3],"C")) create = 1;
777 ShapeAnalysis_FreeBounds F(TheList,toler);
778 //
779 //
780 //
781 char name[100];
782 char num[5];
783 if (!create)
784 {
785 TopoDS_Compound Wires = F.GetClosedWires();
786 TopoDS_Iterator S(Wires);
787 Standard_Integer iwire = 0;
788 while (S.More())
789 {
91322f44 790 Sprintf (num,"%d",iwire);
7fd59977 791 name[0] = 'w';
792 name[1] = '\0';
793 strncat(name,num,strlen(num));
794 name[strlen(name)] = '\0';
795 DBRep::Set(name,S.Value());
796 S.Next();
797 iwire++;
798 }
799 iwire = 0;
800 TopoDS_Compound Edges = F.GetOpenWires();
801 S.Initialize(Edges);
802 iwire = 0;
803 while (S.More())
804 {
91322f44 805 Sprintf (num,"%d",iwire);
7fd59977 806 name[0] = 'E';
807 name[1] = '\0';
808 strncat(name,num,strlen(num));
809 name[strlen(name)] = '\0';
810 DBRep::Set(name,S.Value());
811 S.Next();
812 iwire++;
813 }
814 }
815 else
816 {
817 }
818 return 0;
819}
820
821static Standard_Integer getareacontour (Draw_Interpretor& di,
822 Standard_Integer n, const char** a)
823{
824 if (n < 2) return 1;
825 TopoDS_Shape shape = DBRep::Get(a[1]);
826 if (shape.IsNull()) {
586db386 827 di<<"Shape is not defined\n";
7fd59977 828 return 1;
829 }
830 if(shape.ShapeType() != TopAbs_WIRE) {
586db386 831 di<<"invalid type of argument\n";
7fd59977 832 return 1;
833 }
834 //Handle(ShapeExtend_WireData) asewd = new ShapeExtend_WireData(TopoDS::Wire(shape));
835 Standard_Real anArea = ShapeAnalysis::ContourArea(TopoDS::Wire(shape));
836 di<<"Area = "<<anArea<<"\n";
837 return 0;
838}
839
ef57920a
V
840
841static Standard_Integer checkselfintersection
842 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
843{
844 if (argc < 2)
845 {
586db386 846 di<<"Call please \"checkselfintersection wire [face]\"\n";
ef57920a
V
847 return 1;
848 }
849
850 // Get wire.
851 const char* arg1 = argv[1];
852 TopoDS_Shape wire = DBRep::Get(arg1);
853 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
854 {
586db386 855 di<<"A null shape or not a wire is used.\n";
ef57920a
V
856 return 2;
857 }
858
859 // Get face if the user provided us with a face.
860 TopoDS_Shape face;
861 if (argc > 2)
862 {
863 const char* arg2 = argv[2];
864 face = DBRep::Get(arg2);
865 if (face.IsNull() || face.ShapeType() != TopAbs_FACE)
866 {
586db386 867 di<<"A null shape or not a face is used.\n";
ef57920a
V
868 return 3;
869 }
870 }
871
872 // If the face is null, make a plane inside the wire.
873 if (face.IsNull())
874 {
875 BRepBuilderAPI_MakeFace mkFace(TopoDS::Wire(wire), true);
876 if (mkFace.IsDone())
877 face = mkFace.Face();
878 else
879 {
586db386 880 di<<"Can't make a face for the wire. Provide please a face for analysis.\n";
ef57920a
V
881 return 4;
882 }
883 }
884
885 ShapeAnalysis_Wire analyser(TopoDS::Wire(wire), TopoDS::Face(face), Precision::Confusion());
886 Standard_Boolean result = analyser.CheckSelfIntersection();
887
888 if (result == Standard_True)
586db386 889 di<<"A self-intersecting wire.\n";
ef57920a 890 else
586db386 891 di<<"Not self-intersecting wire.\n";
ef57920a
V
892 return 0;
893}
894
c31e0def 895static Standard_Integer checkedge(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
896{
897 if (argc < 2)
898 {
586db386 899 di<<"Call please \"checkedge edge [face]\"\n";
c31e0def 900 return 1;
901 }
902
903 // Get edge.
904 const char* arg1 = argv[1];
905 TopoDS_Shape edge = DBRep::Get(arg1);
906 if (edge.IsNull() || edge.ShapeType() != TopAbs_EDGE)
907 {
586db386 908 di<<"A null shape or not an edge is used.\n";
c31e0def 909 return 2;
910 }
911
912 // Get face.
913 TopoDS_Shape face;
914 if (argc == 3)
915 {
916 const char* arg2 = argv[2];
917 face = DBRep::Get(arg2);
918 if (face.IsNull() || face.ShapeType() != TopAbs_FACE)
919 {
586db386 920 di<<"A null shape or not a face is used.\n";
c31e0def 921 return 3;
922 }
923 }
924
925 // Analysis of the edge.
926 ShapeAnalysis_Edge analyser;
927 Standard_Boolean isOk(Standard_True);
928
929 // Curve 3D.
930 if (analyser.HasCurve3d(TopoDS::Edge(edge)))
931 {
932 // Check vertices.
933 if (analyser.CheckVerticesWithCurve3d(TopoDS::Edge(edge)))
934 {
935 isOk = Standard_False;
936 di<<"Vertices of the edge don't coincide with start/end points of 3d-curve (using tolerance of the vertices).\n";
937 }
938 }
939 else
940 {
941 isOk = Standard_False;
942 di<<"Edge doesn't have a 3d-curve\n";
943 }
944
945 if (!face.IsNull())
946 {
947 // Curve 2D.
948 if (analyser.HasPCurve(TopoDS::Edge(edge), TopoDS::Face(face)))
949 {
950 // Check vertices.
951 if (analyser.CheckVerticesWithPCurve(TopoDS::Edge(edge), TopoDS::Face(face)))
952 {
953 isOk = Standard_False;
954 di<<"Vertices of the edge don't coincide with start/end points of 2d-curve (using tolerance of the vertices).\n";
955 }
956 }
957 else
958 {
959 isOk = Standard_False;
960 di<<"Edge doesn't have a 2d-curve on this face\n";
961 }
962 }
963
964 if (isOk)
965 di<<"Edge seems OK.\n";
966
967 return 0;
968}
969
7fd59977 970//=======================================================================
971//function : InitCommands
972//purpose :
973//=======================================================================
974
975 void SWDRAW_ShapeAnalysis::InitCommands(Draw_Interpretor& theCommands)
976{
977 static Standard_Integer initactor = 0;
978 if (initactor) return; initactor = 1;
979
980 Standard_CString g = SWDRAW::GroupName();
981
982 theCommands.Add ("tolerance","shape [tolmin tolmax:real]", __FILE__,tolerance,g);
983 theCommands.Add ("projface","nom_face X Y [Z]", __FILE__,projface,g);
984 theCommands.Add ("projcurve","nom_edge | curve3d | curve3d first last + X Y Z",
985 __FILE__,projcurve,g);
986 theCommands.Add ("anaface","nomface",__FILE__,anaface,g);
987 theCommands.Add ("statshape","shape [particul] : stats/particularites",
988 __FILE__,XSHAPE_statshape,g);
989 theCommands.Add ("comptol","shape [nbpoints]",__FILE__,XSHAPE_comptoledge,g);
990 theCommands.Add("freebounds",
991 "shp toler [splitclosed [splitopen]] - free bounds; toler <= 0 for shells (no sewing call)",
992 __FILE__, freebounds, g);
993
994 const char* groupold="DE: old";
995 theCommands.Add("fbprops",
996 "shp [toler [splitclosed [splitopen]]] - free bounds properties; toler <= 0 or not specified - for shells (no sewing call)",
997 __FILE__, FreeBoundsProps, groupold);
998 theCommands.Add("fbclose",
999 "shp sewtoler closetoler [splitclosed [splitopen]] - closes free bounds; use sewtoler <= 0 for shells (no sewing call)",
1000 __FILE__, closefreebounds, groupold);
1001 theCommands.Add("K_VISEDG",
1002 "K_VISEDG Visu of free edge of a compound of faces.",
1003 __FILE__, MyVISEDG, groupold);
1004
1005 theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold);
ef57920a 1006 theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g);
c31e0def 1007 theCommands.Add ("checkedge","edge [face]", __FILE__,checkedge,g);
7fd59977 1008}