b311480e |
1 | // Created on: 1997-07-24 |
2 | // Created by: Xuan PHAM PHU |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <TestTopOpe.hxx> |
23 | #include <TopOpeBRepTool_2d.hxx> |
24 | #include <TopOpeBRepTool_C2DF.hxx> |
25 | #include <TopOpeBRepTool_CORRISO.hxx> |
26 | #include <TopOpeBRepTool_TOOL.hxx> |
27 | #include <TopOpeBRepTool_REGUS.hxx> |
28 | #include <TopOpeBRepTool_CLASSI.hxx> |
29 | #include <TopOpeBRepTool_TOOL.hxx> |
30 | #include <TopOpeBRepBuild_define.hxx> |
31 | |
32 | #include <gp_Pnt2d.hxx> |
33 | #include <gp_Trsf2d.hxx> |
34 | #include <gp_Pnt2d.hxx> |
35 | #include <gp_Dir2d.hxx> |
36 | #include <gp_Vec2d.hxx> |
37 | #include <BRepAdaptor_Curve2d.hxx> |
38 | #include <BndLib_Add2dCurve.hxx> |
39 | #include <BRepLProp_SLProps.hxx> |
40 | #include <Geom_Curve.hxx> |
41 | #include <Geom2dAdaptor_Curve.hxx> |
42 | #include <Geom2d_Line.hxx> |
43 | #include <Geom2d_Curve.hxx> |
44 | #include <Geom2d_TrimmedCurve.hxx> |
45 | #include <Geom_Line.hxx> |
46 | #include <Geom_Surface.hxx> |
47 | #include <GeomAPI_IntCS.hxx> |
48 | #include <TopoDS.hxx> |
49 | #include <TopoDS_Solid.hxx> |
50 | #include <TopoDS_Wire.hxx> |
51 | #include <TopoDS_Compound.hxx> |
52 | #include <TopExp.hxx> |
53 | #include <TopExp_Explorer.hxx> |
54 | #include <BRep_Tool.hxx> |
55 | #include <BRep_Builder.hxx> |
56 | #include <Precision.hxx> |
57 | #include <Bnd_Box2d.hxx> |
58 | #include <Bnd_Array1OfBox2d.hxx> |
59 | #include <BRepClass3d_SolidClassifier.hxx> |
60 | |
61 | #include <TopOpeBRepTool.hxx> |
62 | #include <TopOpeBRepDS.hxx> |
63 | #include <TopOpeBRepBuild_FaceBuilder.hxx> |
64 | #include <TopOpeBRepBuild_ShellToSolid.hxx> |
65 | #include <TopOpeBRepTool_EXPORT.hxx> |
66 | #include <TopOpeBRepTool_SolidClassifier.hxx> |
67 | #include <TopOpeBRepTool_ShapeClassifier.hxx> |
68 | #include <TopOpeBRepDS_EXPORT.hxx> |
69 | |
91322f44 |
70 | #include <Draw.hxx> |
7fd59977 |
71 | #include <Draw_Interpretor.hxx> |
72 | #include <DrawTrSurf.hxx> |
73 | #include <Draw_Color.hxx> |
74 | #include <DBRep.hxx> |
75 | |
d633fd70 |
76 | #include <Extrema_ExtFlag.hxx> |
77 | #include <Extrema_ExtAlgo.hxx> |
78 | |
7fd59977 |
79 | #ifdef DRAW |
80 | #include <TopOpeBRepTool_DRAW.hxx> |
81 | #endif |
82 | |
83 | Standard_IMPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col); |
84 | Standard_IMPORT void DBRep_WriteColorOrientation (); |
85 | Standard_IMPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or); |
86 | |
87 | Standard_IMPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col); |
88 | Standard_IMPORT void DBRep_WriteColorOrientation (); |
89 | Standard_IMPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or); |
90 | Standard_EXPORT void FUN_tool_mkBnd2d(const TopoDS_Shape& W, const TopoDS_Shape& F,Bnd_Box2d& B2d); |
91 | Standard_EXPORT void FUN_tool_UpdateBnd2d(Bnd_Box2d& B2d, const Bnd_Box2d& newB2d); |
92 | Standard_IMPORT Standard_Integer FUN_tool_classiBnd2d(const Bnd_Array1OfBox2d& B,const Standard_Boolean chklarge = Standard_True); |
93 | Standard_IMPORT Standard_Boolean FUN_tool_chkp2dFORinE(const gp_Pnt2d& p2d,const TopoDS_Edge& E, |
94 | const TopoDS_Face& F, Standard_Real& tol2d); |
95 | Standard_IMPORT TopoDS_Vertex FUN_tool_getv(const Standard_Integer Index,const TopoDS_Edge& E); |
96 | |
97 | |
98 | #define SAME (-1) |
99 | #define DIFF (-2) |
100 | #define UNKNOWN ( 0) |
101 | #define oneINtwo ( 1) |
102 | #define twoINone ( 2) |
103 | |
7fd59977 |
104 | static void FUN_test_draw(TCollection_AsciiString aa, |
105 | const TopoDS_Edge& E, const TopoDS_Face& F, |
106 | const Standard_Integer ie, |
107 | Draw_Interpretor& di) |
108 | { |
109 | if (E.IsNull()) {di<<"************* null edge\n"; return;} |
110 | Standard_Real f,l; const Handle(Geom2d_Curve)& PC = BRep_Tool::CurveOnSurface(E,F,f,l); |
111 | if (PC.IsNull()) {di<<"************* no curv on surf\n"; return;} |
112 | TCollection_AsciiString bb(aa); bb += TCollection_AsciiString(ie); |
113 | char* aaa = (char *)bb.ToCString(); |
114 | |
115 | Standard_Boolean coldef = Standard_False; |
116 | TopExp_Explorer ex(F,TopAbs_EDGE); |
117 | Draw_Color col; |
118 | #ifdef DEB |
119 | Draw_Color savecol = |
120 | #endif |
121 | DrawTrSurf_CurveColor(Draw_Color(Draw_rouge)); |
122 | for (; ex.More(); ex.Next()) |
123 | if (E.IsEqual(ex.Current())) |
124 | {col = DBRep_ColorOrientation(ex.Current().Orientation()); |
125 | coldef = Standard_True; |
126 | break;} |
127 | if (!coldef) col = DBRep_ColorOrientation(E.Orientation()); |
128 | |
129 | DrawTrSurf_CurveColor(col); |
130 | DrawTrSurf::Set(aaa,new Geom2d_TrimmedCurve(PC,f,l)); |
131 | } |
132 | |
133 | void FUN_draw(const TCollection_AsciiString aa,const TopoDS_Shape& s) |
134 | {char* aaa = (char *)aa.ToCString(); DBRep::Set(aaa,s);} |
135 | |
136 | void FUN_cout(const gp_Pnt2d& p2d, Draw_Interpretor& di) |
137 | {di <<" = ("<<p2d.X()<<" "<<p2d.Y()<<") ";} |
138 | |
139 | #ifdef DEB |
140 | Standard_IMPORT void FUN_tool_coutsta(const Standard_Integer& sta, const Standard_Integer& i1, const Standard_Integer& i2); |
141 | #endif |
142 | |
143 | |
144 | Standard_Integer regularize(Draw_Interpretor& di, Standard_Integer n, const char** a) |
145 | { |
146 | if (n < 2) return 1; |
147 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
148 | TopoDS_Face fa = TopoDS::Face(aLocalShape); |
149 | // TopoDS_Face fa = TopoDS::Face(DBRep::Get(a[1])); |
150 | if (fa.IsNull()) {di<<"null face"<<"\n"; return 1;} |
151 | |
152 | TopTools_DataMapOfShapeListOfShape ESplits; |
153 | TopTools_ListOfShape lof; |
154 | TopOpeBRepTool::Regularize(fa, lof, ESplits); |
155 | Standard_Integer nfa = lof.Extent(); |
156 | di<<"face gives "<<nfa<<" newfaces"<<"\n"; |
157 | |
158 | Standard_Integer i = 0; |
159 | TopTools_ListIteratorOfListOfShape itlof(lof) ; |
160 | for ( ; itlof.More(); itlof.Next()) { |
161 | i++; |
162 | TCollection_AsciiString aa = TCollection_AsciiString("fa_"); |
163 | aa += TCollection_AsciiString(i); |
164 | FUN_draw(aa,itlof.Value()); |
165 | } |
166 | BRep_Builder BB; |
167 | TopoDS_Compound CC; BB.MakeCompound(CC); |
168 | for (itlof.Initialize(lof); itlof.More(); itlof.Next()) BB.Add(CC, itlof.Value()); |
169 | di<<"resulting compound is cmp"<<"\n"; |
170 | TCollection_AsciiString aa = TCollection_AsciiString("cmp"); |
171 | FUN_draw(aa,CC); |
172 | |
173 | return 0; |
174 | } |
175 | |
176 | static Standard_Integer splitF(Draw_Interpretor& di, Standard_Integer n, const char** a) |
177 | { |
178 | if (n < 2) return 1; |
179 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
180 | const TopoDS_Face& fa = TopoDS::Face(aLocalShape); |
181 | // const TopoDS_Face& fa = TopoDS::Face(DBRep::Get(a[1])); |
182 | if (fa.IsNull()) {di<<"null face"<<"\n"; return 1;} |
183 | |
184 | TopTools_ListOfShape fsplits; |
185 | // Standard_Boolean splitok = FUN_tool_SplitF(fa,fsplits); |
186 | Standard_Boolean splitok = TopOpeBRepTool_REGUS::SplitF(fa,fsplits); |
187 | |
188 | if (!splitok) {di<<"no splits"<<"\n"; return 0;} |
189 | di<<"fa gives "<<fsplits.Extent()<<" splits"<<"\n"; |
190 | |
191 | BRep_Builder BB; |
192 | TopoDS_Compound CC; BB.MakeCompound(CC); |
193 | for (TopTools_ListIteratorOfListOfShape it(fsplits); it.More(); it.Next()) BB.Add(CC, it.Value()); |
194 | |
195 | di<<"resulting compound is cmp"<<"\n"; |
196 | TCollection_AsciiString aa = TCollection_AsciiString("cmp"); |
197 | FUN_draw(aa,CC); |
198 | return 0; |
199 | } |
200 | |
201 | |
202 | static Standard_Integer regush(Draw_Interpretor& di, Standard_Integer n, const char** a) |
203 | { |
204 | if (n < 2) return 1; |
205 | const TopoDS_Shape& sha = DBRep::Get(a[1]); |
206 | if (sha.IsNull()) {di<<"null shape"<<"\n"; return 1;} |
207 | TopExp_Explorer ex(sha, TopAbs_SOLID); |
208 | const TopoDS_Solid& so = TopoDS::Solid(ex.Current()); |
209 | if (so.IsNull()) {di<<"no solid"<<"\n"; return 1;} |
210 | |
211 | TopTools_DataMapOfShapeListOfShape FSplits; |
212 | TopTools_DataMapOfShapeListOfShape OldSheNewShe; |
213 | |
214 | BRep_Builder BB; |
215 | TopoDS_Compound CC; BB.MakeCompound(CC); |
216 | Standard_Integer nshe = 0; |
217 | Standard_Boolean regu = TopOpeBRepTool::RegularizeShells(so,OldSheNewShe,FSplits); |
218 | if (!regu) {di<<"solid gives no new shell"<<"\n";} |
219 | else { |
220 | Standard_Integer noldshe = OldSheNewShe.Extent(); |
221 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape ite(OldSheNewShe); |
222 | for (; ite.More(); ite.Next()){ |
223 | const TopoDS_Shape& oldshe = ite.Key(); |
224 | const TopTools_ListOfShape& newshells = ite.Value(); |
225 | if (newshells.IsEmpty()) {BB.Add(CC,oldshe); nshe++;} |
226 | else { |
227 | for (TopTools_ListIteratorOfListOfShape it(newshells); it.More(); it.Next()){ |
228 | BB.Add(CC,it.Value()); nshe++; |
229 | } |
230 | } |
231 | } // i = 1..noldshe |
232 | di <<"noldshe = "<<noldshe<<" gives nshe = "<<nshe<<"\n"; |
233 | di<<"resulting compound is cmp"<<"\n"; |
234 | TCollection_AsciiString aa = TCollection_AsciiString("cmp"); |
235 | FUN_draw(aa,CC); |
236 | } |
237 | return 0; |
238 | } |
239 | |
240 | Standard_Integer reguso(Draw_Interpretor& di, Standard_Integer n, const char** a) |
241 | { |
242 | if (n < 2) return 1; |
243 | const TopoDS_Shape& sha = DBRep::Get(a[1]); |
244 | if (sha.IsNull()) {di<<"null shape"<<"\n"; return 1;} |
245 | TopExp_Explorer ex(sha, TopAbs_SOLID); |
246 | const TopoDS_Solid& so = TopoDS::Solid(ex.Current()); |
247 | if (so.IsNull()) {di<<"no solid"<<"\n"; return 1;} |
248 | |
249 | TopTools_DataMapOfShapeListOfShape FSplits; |
250 | TopTools_DataMapOfShapeListOfShape OldSheNewShe; |
251 | |
252 | BRep_Builder BB; |
253 | TopoDS_Compound CC; BB.MakeCompound(CC); |
254 | // Standard_Integer nshe = 0; |
255 | Standard_Boolean regu = TopOpeBRepTool::RegularizeShells(so,OldSheNewShe,FSplits); |
256 | if (!regu) {di<<"solid gives no new shell"<<"\n";} |
257 | else { |
258 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(OldSheNewShe); |
259 | |
260 | TopOpeBRepBuild_ShellToSolid SheToSo; |
261 | for (; itm.More(); itm.Next()) { |
262 | const TopTools_ListOfShape& lns = itm.Value(); |
7fd59977 |
263 | TopTools_ListIteratorOfListOfShape itsh(lns); |
264 | for (; itsh.More(); itsh.Next()) { |
265 | const TopoDS_Shell& she = TopoDS::Shell(itsh.Value()); |
266 | SheToSo.AddShell(she); |
267 | } |
268 | } |
269 | TopTools_ListOfShape splits; |
270 | SheToSo.MakeSolids(so,splits); |
271 | |
272 | BRep_Builder BB; |
273 | TopoDS_Compound CC; BB.MakeCompound(CC); |
274 | Standard_Integer nSo = 0; |
275 | TopTools_ListIteratorOfListOfShape itSo(splits); |
276 | for (; itSo.More(); itSo.Next()) { |
277 | const TopoDS_Shape& spli = itSo.Value(); |
278 | BB.Add(CC,spli); |
279 | nSo++; |
280 | } |
281 | di<<"so gives "<<nSo<<" new solids"<<"\n"; |
282 | di<<"resulting compound is cmp"<<"\n"; |
283 | TCollection_AsciiString aa = TCollection_AsciiString("cmp"); |
284 | FUN_draw(aa,CC); |
285 | } |
286 | return 0; |
287 | } |
288 | |
289 | static Standard_Integer purge(Draw_Interpretor& di, Standard_Integer n, const char** a) |
290 | { |
291 | |
292 | if (n < 2) return 1; |
293 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
294 | TopoDS_Face fa = TopoDS::Face(aLocalShape); |
295 | // TopoDS_Face fa = TopoDS::Face(DBRep::Get(a[1])); |
296 | if (fa.IsNull()) return 1; |
297 | TopOpeBRepTool_CORRISO CORRISO(fa); |
298 | Standard_Real tolF = BRep_Tool::Tolerance(fa); |
299 | Standard_Real uperiod; Standard_Boolean uclosed = CORRISO.Refclosed(1,uperiod); |
300 | Standard_Real vperiod; Standard_Boolean vclosed = CORRISO.Refclosed(2,vperiod); |
301 | if (!uclosed && !vclosed) return 1; |
302 | Standard_Boolean inU = uclosed ? Standard_True : Standard_False; |
303 | Standard_Real xmin = inU ? (CORRISO.GASref().FirstUParameter()) : (CORRISO.GASref().LastUParameter()); |
304 | Standard_Real xper = inU ? uperiod : vperiod; |
305 | Standard_Real tolx = inU ? (CORRISO.Tol(1,tolF)) : (CORRISO.Tol(2,tolF)); |
306 | |
307 | BRep_Builder BB; |
308 | TopTools_ListOfShape lWs; Standard_Boolean hasnew = Standard_False; |
309 | TopExp_Explorer exw(fa, TopAbs_WIRE); |
310 | for (; exw.More(); exw.Next()){ |
311 | const TopoDS_Shape& W = exw.Current(); |
312 | |
313 | CORRISO.Init(W); |
314 | Standard_Boolean ok = CORRISO.UVClosed(); |
315 | if (ok) {lWs.Append(W); continue;} |
316 | |
317 | TopTools_ListOfShape cEds; |
318 | TopTools_ListIteratorOfListOfShape ite(CORRISO.Eds()); |
319 | for (; ite.More(); ite.Next()){ |
320 | const TopoDS_Edge& E = TopoDS::Edge(ite.Value()); |
321 | Standard_Boolean closing = BRep_Tool::IsClosed(E,fa); |
322 | if (!closing) {// xpu231198 : pcurve modified, the information is lost |
323 | TopOpeBRepTool_C2DF C2DF; Standard_Boolean isb = CORRISO.UVRep(E,C2DF); |
324 | if (!isb) return 1;//NYIRAISE |
325 | Standard_Boolean onclo = TopOpeBRepTool_TOOL::IsonCLO(C2DF,inU,xmin,xper,tolx); |
326 | if (onclo) closing=Standard_True; |
327 | } |
328 | if (closing) cEds.Append(E); |
329 | } |
330 | Standard_Integer ncE = cEds.Extent(); |
331 | Standard_Boolean nopurge = (ncE <= 1); |
332 | if (nopurge) {lWs.Append(W); continue;} |
333 | |
334 | // Checking <W> |
335 | TopTools_ListOfShape lfyE; Standard_Boolean topurge = CORRISO.PurgeFyClosingE(cEds,lfyE); |
336 | if (!topurge) {lWs.Append(W); continue;} |
337 | |
338 | TopoDS_Wire Wi; BB.MakeWire(Wi); // Add une TShape |
339 | Wi.Free(Standard_True); |
340 | ite.Initialize(CORRISO.Eds()); |
341 | for (; ite.More(); ite.Next()) { |
342 | const TopoDS_Edge& ed = TopoDS::Edge(ite.Value()); |
343 | Standard_Boolean equ = Standard_False; |
344 | for (TopTools_ListIteratorOfListOfShape itlfyE(lfyE);itlfyE.More();itlfyE.Next()) { |
345 | const TopoDS_Shape& fyE = itlfyE.Value(); |
346 | if (ed.IsEqual(fyE)) { |
347 | equ = Standard_True; |
348 | break; |
349 | } |
350 | } |
351 | if (equ) { |
352 | continue; |
353 | } |
354 | BB.Add(Wi,ed); |
355 | } |
356 | lWs.Append(Wi); |
357 | } // exw |
358 | |
359 | if (!hasnew) return 1; |
360 | |
361 | // Building up the new face : |
362 | aLocalShape = fa.EmptyCopied(); |
363 | TopoDS_Face newF = TopoDS::Face(aLocalShape); |
364 | // TopoDS_Face newF = TopoDS::Face(fa.EmptyCopied()); |
365 | TopTools_ListIteratorOfListOfShape itw(lWs); |
366 | for (; itw.More(); itw.Next()) BB.Add(newF, TopoDS::Wire(itw.Value())); |
367 | |
368 | di <<"New face built is newF"<<"\n"; |
369 | TCollection_AsciiString aa("newF"); |
370 | FUN_draw(aa, newF); |
371 | return 0; |
372 | } |
373 | |
374 | |
375 | Standard_Integer correctONISO(Draw_Interpretor& di, Standard_Integer n, const char** a) |
376 | { |
377 | if (n < 3) return 1; |
378 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
379 | TopoDS_Face F = TopoDS::Face(aLocalShape); |
380 | aLocalShape = DBRep::Get(a[2]); |
381 | TopoDS_Face Fsp = TopoDS::Face(aLocalShape); |
382 | // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1])); |
383 | // TopoDS_Face Fsp = TopoDS::Face(DBRep::Get(a[2])); |
384 | |
385 | FC2D_Prepare(F,F); |
386 | |
387 | if (F.IsNull() || Fsp.IsNull()) {di<<"NULL shape(s)"<<"\n";return 1;} |
388 | |
389 | TopOpeBRepTool::CorrectONUVISO(F,Fsp); |
390 | TCollection_AsciiString aa("newFsp"); |
391 | FUN_draw(aa,Fsp); |
392 | di<<"-> newFsp"<<"\n"; |
393 | |
394 | return 0; |
395 | } |
396 | |
397 | // ====================================================================== |
398 | // useful commands : |
399 | // ====================================================================== |
400 | |
401 | static Standard_Integer isclosingE(Draw_Interpretor& di, Standard_Integer n, const char** a) |
402 | { |
403 | if (n < 3) return 1; |
404 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]) ; |
405 | TopoDS_Edge ed = TopoDS::Edge(aLocalShape); |
406 | aLocalShape = DBRep::Get(a[2]); |
407 | TopoDS_Face fa = TopoDS::Face(aLocalShape); |
408 | // TopoDS_Edge ed = TopoDS::Edge(DBRep::Get(a[1])); |
409 | // TopoDS_Face fa = TopoDS::Face(DBRep::Get(a[2])); |
410 | Standard_Boolean isclosing = BRep_Tool::IsClosed(ed,fa); |
411 | TopAbs_Orientation oriE = ed.Orientation(); |
412 | if (isclosing) {di <<"edge is "; |
413 | //TopAbs::Print(oriE,cout); |
414 | Standard_SStream aSStream; |
415 | TopAbs::Print(oriE,aSStream); |
416 | di << aSStream; |
417 | di<<" closing edge"<<"\n";} |
418 | else di <<"edge is NOT closing edge"<<"\n"; |
419 | return 0; |
420 | } |
421 | |
422 | static Standard_Integer compareshsh(Draw_Interpretor& di, Standard_Integer n, const char** a) |
423 | { |
424 | if (n < 3) return 1; |
425 | TopoDS_Shape sh1 = DBRep::Get(a[1]); |
426 | TopoDS_Shape sh2 = DBRep::Get(a[2]); |
427 | Standard_Boolean issame = sh1.IsSame(sh2); |
428 | if (issame) di<<" same shapes"<<"\n"; |
429 | else di <<" shapes are not same"<<"\n"; |
430 | Standard_Boolean isequal = sh1.IsEqual(sh2); if (isequal) di<<" equal shapes"<<"\n"; |
431 | return 0; |
432 | } |
433 | static Standard_Integer pcurveedgeonface(Draw_Interpretor& di, Standard_Integer n, const char** a) |
434 | { |
435 | if (n < 3) return 1; |
436 | TopoDS_Shape ed = DBRep::Get(a[1]); |
437 | TopoDS_Shape fa = DBRep::Get(a[2]); |
438 | TCollection_AsciiString aa("edonfa_"); |
439 | FUN_test_draw(aa,TopoDS::Edge(ed),TopoDS::Face(fa),0,di); |
440 | return 0; |
441 | } |
442 | |
443 | static Standard_Integer pcurvesonface(Draw_Interpretor& di, Standard_Integer n, const char** a) |
444 | { |
445 | if (n < 3) return 1; |
446 | TopoDS_Shape sh = DBRep::Get(a[2]); |
447 | TopoDS_Shape fa = DBRep::Get(a[3]); |
448 | TopExp_Explorer exe(sh, TopAbs_EDGE); |
449 | Standard_Integer i = 0; |
450 | for (; exe.More(); exe.Next()){ |
451 | i++; |
452 | TCollection_AsciiString aa(a[1]); |
453 | FUN_test_draw(aa,TopoDS::Edge(exe.Current()),TopoDS::Face(fa),i,di); |
454 | } |
455 | return 0; |
456 | } |
457 | |
458 | static Standard_Integer orivine(Draw_Interpretor& di, Standard_Integer n, const char** a) |
459 | { |
460 | if (n < 3) return 1; |
461 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
462 | TopoDS_Vertex v = TopoDS::Vertex(aLocalShape); |
463 | aLocalShape = DBRep::Get(a[2]); |
464 | TopoDS_Edge ed = TopoDS::Edge(aLocalShape); |
465 | // TopoDS_Vertex v = TopoDS::Vertex(DBRep::Get(a[1])); |
466 | // TopoDS_Edge ed = TopoDS::Edge(DBRep::Get(a[2])); |
467 | |
468 | Standard_Integer ori = TopOpeBRepTool_TOOL::OriinSor(v,ed); |
469 | if (ori==0) di<<"v not in ed"<<"\n"; |
470 | else if (ori==1) di<<"v FORWARD in ed"<<"\n"; |
471 | else if (ori==2) di<<"v REVERSED in ed"<<"\n"; |
472 | else if (ori==3) di<<"v INTERNAL in ed"<<"\n"; |
473 | else if (ori==4) di<<"v EXTERNAL in ed"<<"\n"; |
474 | else if (ori==5) di<<"v CLOSING in ed"<<"\n"; |
475 | return 0; |
476 | } |
477 | |
478 | static Standard_Integer vine(Draw_Interpretor& di, Standard_Integer n, const char** a) |
479 | { |
480 | if (n < 4) return 1; |
481 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
482 | TopoDS_Vertex v = TopoDS::Vertex(aLocalShape); |
483 | aLocalShape = DBRep::Get(a[2]); |
484 | TopoDS_Edge ed = TopoDS::Edge(aLocalShape); |
485 | aLocalShape = DBRep::Get(a[3]); |
486 | TopoDS_Face fa = TopoDS::Face(aLocalShape); |
487 | // TopoDS_Vertex v = TopoDS::Vertex(DBRep::Get(a[1])); |
488 | // TopoDS_Edge ed = TopoDS::Edge(DBRep::Get(a[2])); |
489 | // TopoDS_Face fa = TopoDS::Face(DBRep::Get(a[3])); |
490 | |
491 | Standard_Real pf,pl; |
492 | const Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(ed,fa,pf,pl); |
493 | gp_Pnt2d p2df, p2dl; PC->D0(pf,p2df); PC->D0(pl,p2dl); |
494 | di << "p2df";FUN_cout(p2df,di); di << "p2dl";FUN_cout(p2dl,di);di<<"\n"; |
495 | |
496 | Standard_Integer ori = TopOpeBRepTool_TOOL::OriinSor(v,ed); |
497 | if (ori==0) {di<<"v not in ed"<<"\n"; return 0;} |
498 | else if (ori==1) di<<"v FORWARD in ed"<<"\n"; |
499 | else if (ori==2) di<<"v REVERSED in ed"<<"\n"; |
500 | else if (ori==3) di<<"v INTERNAL in ed"<<"\n"; |
501 | else if (ori==4) di<<"v EXTERNAL in ed"<<"\n"; |
502 | else if (ori==5) di<<"v CLOSING in ed"<<"\n"; |
503 | |
504 | if ((ori == 1) || (ori == 2)) { |
505 | Standard_Real par = TopOpeBRepTool_TOOL::ParE(ori,ed);//FUN_tool_parOnE(ind,ed,fa); |
506 | gp_Pnt2d p2d; PC->D0(par,p2d); |
507 | di <<"p2d : with TopOpeBRepTool_TOOL::ParE";FUN_cout(p2d,di);di<<"\n"; |
508 | } |
509 | |
510 | Standard_Real par = BRep_Tool::Parameter(v,ed,fa); |
511 | gp_Pnt2d pp2d; PC->D0(par,pp2d); |
512 | di <<"p2d computed with BRep_Tool::Parameter";FUN_cout(pp2d,di);di<<"\n"; |
513 | |
514 | return 0; |
515 | } |
516 | |
517 | static Standard_Integer issubshape(Draw_Interpretor& di, Standard_Integer n, const char** a) |
518 | { |
519 | if (n < 3) return 1; |
520 | TopoDS_Shape subshape = DBRep::Get(a[1]); |
521 | TopoDS_Shape shape = DBRep::Get(a[2]); |
522 | TopExp_Explorer ex(shape, subshape.ShapeType()); |
523 | Standard_Boolean issubs = Standard_False; |
524 | for (; ex.More(); ex.Next()) |
525 | if (ex.Current().IsSame(subshape)) {issubs = Standard_True; break;} |
526 | |
527 | if (issubs) di<<" is subshape"<<"\n"; |
528 | else di<<" is NOT subshape"<<"\n"; |
529 | return 0; |
530 | } |
531 | |
532 | void FUN_mkBnd2dBREP(const TopoDS_Shape& W, const TopoDS_Shape& F,Bnd_Box2d& B2d,const Standard_Integer& i) |
533 | { |
534 | // greater <B> with <W>'s UV representation on <F> |
535 | Standard_Real tol = 1.e-8; |
536 | TopExp_Explorer ex; |
537 | for (ex.Init(W, TopAbs_EDGE); ex.More(); ex.Next()) { |
538 | // for (TopExp_Explorer ex(W, TopAbs_EDGE); ex.More(); ex.Next()) { |
539 | if (i == 0) { |
540 | FUN_tool_mkBnd2d(W,F,B2d); |
541 | } |
542 | if (i == 1) { |
543 | BRepAdaptor_Curve2d BC2d(TopoDS::Edge(ex.Current()), TopoDS::Face(F)); |
544 | BndLib_Add2dCurve::Add(BC2d, tol, B2d); |
545 | } |
546 | if (i == 2) { |
547 | Standard_Real f,l; |
548 | Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),TopoDS::Face(F),f,l); |
549 | Geom2dAdaptor_Curve GC2d(PC); |
550 | BndLib_Add2dCurve::Add(GC2d, tol, B2d); |
551 | } |
552 | if (i == 3) { |
553 | TopLoc_Location L; Standard_Real f,l; |
554 | const Handle(Geom_Surface)& S = BRep_Tool::Surface(TopoDS::Face(F),L); |
555 | const Handle(Geom2d_Curve)& PC = BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),S,L,f,l); |
556 | Geom2dAdaptor_Curve GC2d(PC); |
557 | BndLib_Add2dCurve::Add(GC2d, tol, B2d); |
558 | } |
559 | |
560 | } //ex(W,EDGE) |
561 | } |
562 | |
563 | static Standard_Integer drawbnd2d(Draw_Interpretor& , Standard_Integer n, const char** a) |
564 | { |
565 | if (n < 5) return 1; |
91322f44 |
566 | Standard_Integer i = Draw::Atoi(a[4]); |
7fd59977 |
567 | TopoDS_Shape W = DBRep::Get(a[2]); |
568 | TopoDS_Shape F = DBRep::Get(a[3]); |
569 | if (W.IsNull() || F.IsNull()) return 1; |
570 | Bnd_Box2d B2d; |
571 | Standard_Real umin,vmin,umax,vmax; |
572 | FUN_mkBnd2dBREP(W,F,B2d,i); |
573 | B2d.Get(umin,vmin,umax,vmax); |
574 | |
575 | Handle(Geom2d_Line) cx = new Geom2d_Line(gp_Pnt2d(umin,vmin),gp_Dir2d(1.,0.)); |
576 | Handle(Geom2d_Line) cy = new Geom2d_Line(gp_Pnt2d(umin,vmin),gp_Dir2d(0.,1.)); |
577 | gp_Trsf2d tx; gp_Vec2d vx(umax-umin,0.); tx.SetTranslation(vx); |
578 | gp_Trsf2d ty; gp_Vec2d vy(0.,vmax-vmin); ty.SetTranslation(vy); |
579 | |
580 | Handle(Geom2d_TrimmedCurve) tcx = new Geom2d_TrimmedCurve(cx,0.,umax-umin); |
581 | Handle(Geom2d_TrimmedCurve) tcy = new Geom2d_TrimmedCurve(cy,0.,vmax-vmin); |
582 | Handle(Geom2d_TrimmedCurve) tccx = Handle(Geom2d_TrimmedCurve)::DownCast(tcx->Copy()); tccx->Transform(ty); |
583 | Handle(Geom2d_TrimmedCurve) tccy = Handle(Geom2d_TrimmedCurve)::DownCast(tcy->Copy()); tccy->Transform(tx); |
584 | |
585 | Draw_Color col(Draw_blanc); |
586 | DrawTrSurf_CurveColor(col); |
587 | |
588 | TCollection_AsciiString aa3 = TCollection_AsciiString(a[1]); aa3 += TCollection_AsciiString(3); |
589 | TCollection_AsciiString aa4 = TCollection_AsciiString(a[1]); aa4 += TCollection_AsciiString(4); |
590 | |
591 | TCollection_AsciiString aa; |
592 | aa=TCollection_AsciiString(a[1]); aa+=TCollection_AsciiString(1); char* aaa = (char *)aa.ToCString(); DrawTrSurf::Set(aaa,tcx); |
593 | aa=TCollection_AsciiString(a[1]); aa+=TCollection_AsciiString(2); aaa=(char *)aa.ToCString(); DrawTrSurf::Set(aaa,tcy); |
594 | aa=TCollection_AsciiString(a[1]); aa+=TCollection_AsciiString(3); aaa=(char *)aa.ToCString(); DrawTrSurf::Set(aaa,tccx); |
595 | aa=TCollection_AsciiString(a[1]); aa+=TCollection_AsciiString(4); aaa=(char *)aa.ToCString(); DrawTrSurf::Set(aaa,tccy); |
596 | return 0; |
597 | } |
598 | |
599 | static Standard_Integer classifBnd2d(Draw_Interpretor& di, Standard_Integer n, const char** a) |
600 | { |
601 | if (n < 5) return 1; |
602 | TopoDS_Shape W1 = DBRep::Get(a[1]); |
603 | TopoDS_Shape W2 = DBRep::Get(a[2]); |
604 | TopoDS_Shape F = DBRep::Get(a[3]); |
7fd59977 |
605 | |
606 | TopoDS_Wire w1 = TopoDS::Wire(W1); |
607 | TopoDS_Wire w2 = TopoDS::Wire(W2); |
608 | TopoDS_Face Fref = TopoDS::Face(F); |
609 | |
610 | TopOpeBRepTool_CLASSI classi; classi.Init2d(Fref); |
611 | Standard_Real tolF = BRep_Tool::Tolerance(Fref); |
612 | Standard_Real toluv = TopOpeBRepTool_TOOL::TolUV(Fref,tolF); |
613 | |
614 | if (w1.IsNull() || w2.IsNull() || Fref.IsNull()) return 1; |
615 | |
616 | Standard_Integer sta = classi.ClassiBnd2d(w1,w2,toluv,Standard_True); |
617 | di <<"wires classification : checklarge=true "; |
618 | #ifdef DEB |
619 | FUN_tool_coutsta(sta,1,2); |
620 | #endif |
621 | |
622 | sta = classi.ClassiBnd2d(w1,w2,toluv,Standard_False); |
623 | di <<"wires classification : checklarge=false "; |
624 | #ifdef DEB |
625 | FUN_tool_coutsta(sta,1,2); |
626 | #endif |
627 | |
628 | return 0; |
629 | } |
630 | |
631 | static Standard_Integer pntonc(Draw_Interpretor& di, Standard_Integer n, const char** a) |
632 | { |
633 | if (n < 3) return 1; |
91322f44 |
634 | Standard_Real x = Draw::Atof(a[1]); |
7fd59977 |
635 | Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]); |
636 | if (C.IsNull()) {di<<"null curve"<<"\n"; return 1;} |
637 | gp_Pnt p = C->Value(x); |
638 | di<<"point on curve of parameter "<<x<<" =("<<p.X()<<","; |
639 | di<<p.Y()<<","<<p.Z()<<")"<<"\n"; |
640 | return 0; |
641 | } |
642 | |
643 | static Standard_Integer pntonc2d(Draw_Interpretor& di, Standard_Integer n, const char** a) |
644 | { |
645 | if (n < 4) return 1; |
91322f44 |
646 | Standard_Real x = Draw::Atof(a[1]); |
7fd59977 |
647 | Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]); |
648 | if (C2d.IsNull()) {di<<"null curve"<<"\n"; return 1;} |
649 | Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[3]); |
650 | if (S.IsNull()) {di<<"null surface"<<"\n"; return 1;} |
651 | gp_Pnt2d p2d = C2d->Value(x); |
652 | di<<"point on curve of parameter "<<x<<" =("<<p2d.X()<<","<<p2d.Y()<<")"<<"\n"; |
653 | gp_Pnt p = S->Value(p2d.X(),p2d.Y()); |
654 | di<<"point on curve of parameter "<<x<<" =("<<p.X()<<","; |
655 | di<<p.Y()<<","<<p.Z()<<")"<<"\n"; |
656 | return 0; |
657 | } |
658 | |
659 | static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const char** a) |
660 | { |
d633fd70 |
661 | if (n < 3) { |
662 | di << "projponf f pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]\n"; |
663 | return 1; |
664 | } |
665 | // |
7fd59977 |
666 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
667 | TopoDS_Face f = TopoDS::Face(aLocalShape); |
d633fd70 |
668 | // |
669 | if (f.IsNull()) { |
670 | di<<"null shape"<<"\n"; |
671 | return 1; |
672 | } |
673 | // |
674 | Standard_Real dist=0.; |
675 | Standard_Boolean ok; |
676 | gp_Pnt2d uv; |
677 | gp_Pnt p, pproj; |
95978b28 |
678 | Extrema_ExtAlgo anExtAlgo = Extrema_ExtAlgo_Grad; |
679 | Extrema_ExtFlag anExtFlag = Extrema_ExtFlag_MINMAX; |
d633fd70 |
680 | // |
681 | DrawTrSurf::GetPoint(a[2], p); |
682 | // |
683 | if (n > 3) { |
684 | const char* key1 = a[3]; |
685 | const char* key2 = (n > 4) ? a[4] : NULL; |
686 | if (key1) { |
687 | if (!strcasecmp(key1,"-min")) { |
95978b28 |
688 | anExtFlag = Extrema_ExtFlag_MIN; |
d633fd70 |
689 | } else if (!strcasecmp(key1,"-max")) { |
95978b28 |
690 | anExtFlag = Extrema_ExtFlag_MAX; |
d633fd70 |
691 | } else { |
95978b28 |
692 | anExtAlgo = (!strcasecmp(key1,"-t")) ? Extrema_ExtAlgo_Tree : anExtAlgo; |
d633fd70 |
693 | } |
694 | } |
695 | if (key2) { |
95978b28 |
696 | anExtAlgo = (!strcasecmp(key2,"-t")) ? Extrema_ExtAlgo_Tree : anExtAlgo; |
d633fd70 |
697 | } |
698 | } |
95978b28 |
699 | ok = FUN_tool_projPonF(p, f, uv, dist, anExtFlag, anExtAlgo); |
d633fd70 |
700 | // |
701 | if (!ok) { |
702 | di<<"projection failed"<<"\n"; |
703 | return 1; |
704 | } |
705 | // |
706 | ok = FUN_tool_value(uv,f,pproj); |
707 | if (!ok) { |
708 | di<<"projection failed"<<"\n"; |
709 | return 1; |
710 | } |
711 | // |
7fd59977 |
712 | di<<"proj dist = "<<dist<<" uvproj = ("<<uv.X()<<" "<<uv.Y(); |
713 | di<<"); pproj = ("<<pproj.X()<<" "<<pproj.Y()<<" "<<pproj.Z()<<")"<<"\n"; |
714 | return 0; |
715 | } |
716 | |
717 | static Standard_Integer tolmax(Draw_Interpretor& di, Standard_Integer n, const char** a) |
718 | { |
719 | if (n < 2) return 1; |
720 | TopoDS_Shape s = DBRep::Get(a[1]); |
721 | if (s.IsNull()) {di<<"null shape"<<"\n"; return 1;} |
722 | Standard_Real tol = FUN_tool_maxtol(s); |
723 | di<<"max tol = "<<tol<<"\n"; |
724 | return 0; |
725 | } |
726 | |
727 | static Standard_Integer solidclassifier(Draw_Interpretor& di, Standard_Integer n, const char** a) |
728 | { |
729 | if (n < 4) return 1; |
730 | TopoDS_Shape s = DBRep::Get(a[1]); |
731 | if (s.IsNull()) {di<<"null shape"<<"\n";return 1;} |
732 | gp_Pnt p; DrawTrSurf::GetPoint(a[2], p); |
91322f44 |
733 | Standard_Real tol = Draw::Atof(a[3]); |
7fd59977 |
734 | |
735 | TopOpeBRepTool_SolidClassifier soclassi; |
736 | TopAbs_State sta = TopAbs_UNKNOWN; |
737 | if (s.ShapeType() == TopAbs_SOLID) soclassi.Classify(TopoDS::Solid(s),p,tol); |
738 | else if (s.ShapeType() == TopAbs_SHELL) soclassi.Classify(TopoDS::Shell(s),p,tol); |
739 | else {di<<"shape is not a solid nor a shell => KO"<<"\n"; return 1;} |
740 | |
741 | sta = soclassi.State(); |
742 | di<<"point is "; |
743 | //TopAbs::Print(sta,cout); |
744 | Standard_SStream aSStream; |
745 | TopAbs::Print(sta,aSStream); |
746 | di << aSStream; |
747 | di<<" shape s"<<"\n"; |
748 | return 0; |
749 | } |
750 | |
751 | static Standard_Integer class3dclassifier(Draw_Interpretor& di, Standard_Integer n, const char** a) |
752 | { |
753 | if (n < 4) return 1; |
754 | TopoDS_Shape s = DBRep::Get(a[1]); |
755 | if (s.IsNull()) {di<<"null shape"<<"\n";return 1;} |
756 | gp_Pnt p; DrawTrSurf::GetPoint(a[2], p); |
91322f44 |
757 | Standard_Real tol = Draw::Atof(a[3]); |
7fd59977 |
758 | |
759 | BRepClass3d_SolidClassifier soclassi(s); |
760 | TopAbs_State sta = TopAbs_UNKNOWN; |
761 | soclassi.Perform(p,tol); |
762 | |
763 | sta = soclassi.State(); |
764 | di<<"point is "; |
765 | //TopAbs::Print(sta,cout); |
766 | Standard_SStream aSStream; |
767 | TopAbs::Print(sta,aSStream); |
768 | di << aSStream; |
769 | di<<" shape s"<<"\n"; |
770 | return 0; |
771 | } |
772 | static Standard_Integer shapeclassifier(Draw_Interpretor& di, Standard_Integer n, const char** a) |
773 | { |
774 | if (n < 3) return 1; |
775 | TopoDS_Shape sh = DBRep::Get(a[1]); |
776 | if (sh.IsNull()) {di<<"null shape"<<"\n";return 1;} |
777 | TopoDS_Shape shref = DBRep::Get(a[2]); |
778 | if (shref.IsNull()) {di<<"null reference shape"<<"\n";return 1;} |
779 | Standard_Boolean hastoavoid = (n > 3); |
780 | TopTools_ListOfShape toavoid; |
781 | if (hastoavoid) { |
782 | for (Standard_Integer i=3; i<=n; i++) { |
783 | TopoDS_Shape shtoavoid = DBRep::Get(a[i]); |
784 | if (shtoavoid.IsNull()) {di<<"null toavoid shape"<<"\n";return 1;} |
785 | toavoid.Append(shtoavoid); |
786 | } |
787 | } |
788 | |
789 | TopOpeBRepTool_ShapeClassifier shclassi; |
790 | TopAbs_State sta = TopAbs_UNKNOWN; |
791 | if (hastoavoid) sta = shclassi.StateShapeShape(sh,shref); |
792 | else if (toavoid.Extent() == 1) sta = shclassi.StateShapeShape(sh,toavoid.First(),shref); |
793 | else sta = shclassi.StateShapeShape(sh,toavoid,shref); |
794 | |
795 | di<<"shape is "; |
796 | //TopAbs::Print(sta,cout); |
797 | Standard_SStream aSStream; |
798 | TopAbs::Print(sta,aSStream); |
799 | di << aSStream; |
800 | di<<" shape ref"<<"\n"; |
801 | return 0; |
802 | } |
803 | |
804 | |
805 | // normals .. |
806 | static Standard_Integer normal(Draw_Interpretor& di, Standard_Integer n, const char** a) |
807 | { |
808 | if (n < 3) return 1; |
809 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
810 | TopoDS_Face f = TopoDS::Face(aLocalShape); |
811 | // TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1])); |
812 | if (f.IsNull()) {di<<"null shape"<<"\n";return 1;} |
813 | gp_Pnt p; DrawTrSurf::GetPoint(a[2], p); |
302f96fb |
814 | |
7fd59977 |
815 | Standard_Real dist=0.; gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_projPonF(p,f,uv,dist); |
816 | if (!ok) {di<<"projection failed"<<"\n"; return 1;} |
817 | #ifdef DEB |
818 | gp_Vec ngf = |
819 | #endif |
820 | FUN_tool_nggeomF(uv,f); |
821 | TCollection_AsciiString aa("ngS"); |
822 | #ifdef DRAW |
823 | FUN_tool_draw(aa,p,ngf,length); |
824 | #endif |
825 | return 0; |
826 | } |
827 | |
828 | static Standard_Integer curvature(Draw_Interpretor& di, Standard_Integer n, const char** a) |
829 | { |
830 | if (n < 5) return 1; |
831 | TopoDS_Shape aLocalShape = DBRep::Get(a[1]); |
832 | TopoDS_Face f = TopoDS::Face(aLocalShape); |
833 | // TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1])); |
834 | if (f.IsNull()) {di<<"null shape"<<"\n";return 1;} |
91322f44 |
835 | Standard_Real x = Draw::Atof(a[2]); |
836 | Standard_Real y = Draw::Atof(a[3]); |
837 | Standard_Real z = Draw::Atof(a[4]); |
7fd59977 |
838 | Handle(Geom_Line) line = new Geom_Line(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Dir(x,y,z))); |
839 | BRepAdaptor_Surface BS(f); |
840 | Handle(Geom_Surface) su = BRep_Tool::Surface(f); |
841 | GeomAPI_IntCS intcs(line,su); |
842 | Standard_Boolean done = intcs.IsDone(); |
843 | if (!done) {di<<"intersection point on surface not found"<<"\n"; return 1;} |
844 | Standard_Integer npnts = intcs.NbPoints(); |
845 | if (npnts < 1) {di<<"intersection point on surface not found"<<"\n"; return 1;} |
846 | |
847 | Standard_Real tol = Precision::Confusion(); |
848 | BRepLProp_SLProps props(BS,2,tol); |
849 | Standard_Real Cur1=0., Cur2=0.; |
850 | gp_Dir Norm,D1,D2; |
851 | for (Standard_Integer i = 1; i <= npnts; i++) { |
852 | gp_Pnt p = intcs.Point(i); |
853 | Standard_Real u,v,w; intcs.Parameters(i,u,v,w); |
854 | di<<"point("<<i<<") = { ("<<p.X()<<" "<<p.Y()<<" "<<p.Z()<<"), ("<<u<<" "<<v<<") }"<<"\n"; |
855 | props.SetParameters(u,v); |
856 | Standard_Boolean curdef = props.IsCurvatureDefined(); |
857 | if (!curdef) {di<<"!IsCurvatureDefined"<<"\n"; continue;} |
858 | Standard_Boolean umbilic = props.IsUmbilic(); |
859 | if (umbilic) { |
860 | Cur1 = Cur2 = props.MeanCurvature(); |
861 | D1 = gp_Dir(0,0,1); |
862 | D2 = gp_Dir(0,1,0); |
863 | di<<"umbilic"; |
864 | } |
865 | else { |
866 | Cur1 = props.MaxCurvature(); |
867 | Cur2 = props.MinCurvature(); |
868 | props.CurvatureDirections(D1,D2); |
869 | } |
870 | Norm = gp_Dir(D1^D2); |
871 | di<<"D1 = ("<<D1.X()<<" "<<D1.Y()<<" "<<D1.Z()<<" "<<")"<<"\n"; |
872 | di<<"D2 = ("<<D2.X()<<" "<<D2.Y()<<" "<<D2.Z()<<" "<<")"<<"\n"; |
873 | di<<"Norm = ("<<Norm.X()<<" "<<Norm.Y()<<" "<<Norm.Z()<<" "<<")"<<"\n"; |
874 | } // i |
875 | return 0; |
876 | } |
877 | |
878 | void TestTopOpe::CORCommands(Draw_Interpretor& theCommands) |
879 | { |
880 | static Standard_Boolean done = Standard_False; |
881 | if (done) return; done = Standard_True; |
882 | const char* g = "TestTopOpe CORCommands"; |
883 | // purge, regularization commands : |
884 | theCommands.Add("purge", "purge f", __FILE__, purge, g); |
885 | theCommands.Add("corrISO", "corrISO f Fsp", __FILE__, correctONISO, g); |
886 | theCommands.Add("regufa", "regufa f", __FILE__, regularize, g); |
887 | theCommands.Add("splitf", "splitf f", __FILE__, splitF, g); |
888 | theCommands.Add("regush", "regush so", __FILE__, regush, g); |
889 | theCommands.Add("reguso", "reguso so", __FILE__, reguso, g); |
890 | // builder commands : |
891 | theCommands.Add("soclass", "soclass sh pnt tol", __FILE__, solidclassifier, g); |
892 | theCommands.Add("shclass", "shclass sh shref <toavoid>", __FILE__, shapeclassifier, g); |
893 | theCommands.Add("clclass", "clclass sh shref <toavoid>", __FILE__, class3dclassifier, g); |
894 | |
895 | // useful commands : |
896 | theCommands.Add("cled", "cled ed f", __FILE__, isclosingE, g); |
897 | theCommands.Add("compare", "compare s1 s2", __FILE__, compareshsh, g); |
898 | theCommands.Add("edonfa", "edonfa ed f", __FILE__, pcurveedgeonface, g); |
899 | theCommands.Add("pconfa", "pconfa name s f", __FILE__, pcurvesonface, g); |
900 | theCommands.Add("orivine", "orivine v ed", __FILE__, orivine, g); |
901 | theCommands.Add("vine", "vine v ed fa", __FILE__, vine, g); |
902 | theCommands.Add("issubsh", "issubsh subsh sh", __FILE__, issubshape, g); |
903 | theCommands.Add("bnd2d", "bnd2d name W F i", __FILE__, drawbnd2d, g); |
904 | theCommands.Add("classibnd2d","classibnd2d W1 W2 F i", __FILE__, classifBnd2d, g); |
905 | theCommands.Add("pntonc", "pntonc par C3d", __FILE__, pntonc, g); |
906 | theCommands.Add("pntonc2d", "pntonc2d par C2d S", __FILE__, pntonc2d, g); |
d633fd70 |
907 | theCommands.Add("projponf", |
908 | "projponf f pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]", |
909 | __FILE__, projponf, g); |
7fd59977 |
910 | theCommands.Add("tolmax", "tolmax s", __FILE__, tolmax, g); |
911 | theCommands.Add("normal", "normal f p3d length", __FILE__, normal, g); |
912 | theCommands.Add("curvature", "curvature f x y z", __FILE__, curvature , g); |
913 | |
914 | } |