b311480e |
1 | // Created on: 2002-03-18 |
2 | // Created by: QA Admin |
973c2be1 |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
7fd59977 |
16 | #include <stdio.h> |
17 | |
1cd84fee |
18 | #include <QABugs.hxx> |
7fd59977 |
19 | |
91322f44 |
20 | #include <Draw.hxx> |
7fd59977 |
21 | #include <Draw_Interpretor.hxx> |
22 | #include <DBRep.hxx> |
23 | #include <DrawTrSurf.hxx> |
24 | #include <AIS_InteractiveContext.hxx> |
25 | #include <ViewerTest.hxx> |
5e27df78 |
26 | #include <ViewerTest_EventManager.hxx> |
7fd59977 |
27 | #include <AIS_Shape.hxx> |
28 | #include <TopoDS_Shape.hxx> |
29 | |
30 | #include <Geom_Circle.hxx> |
31 | #include <Geom_Ellipse.hxx> |
32 | #include <Geom_Plane.hxx> |
543a9964 |
33 | #include <Geom_BSplineSurface.hxx> |
7fd59977 |
34 | #include <gp_Pln.hxx> |
35 | #include <Geom2d_Curve.hxx> |
36 | #include <GeomAPI.hxx> |
37 | #include <Geom2dAdaptor_Curve.hxx> |
38 | #include <Geom2dGcc_QualifiedCurve.hxx> |
39 | #include <Geom2dGcc_Lin2d2Tan.hxx> |
40 | #include <Geom2d_Line.hxx> |
41 | #include <BRepBuilderAPI_MakeEdge.hxx> |
42 | #include <TopoDS_Edge.hxx> |
43 | #include <Precision.hxx> |
44 | #include <Geom2d_Circle.hxx> |
0b85f9a6 |
45 | #include <Geom2dGcc_QCurve.hxx> |
7fd59977 |
46 | #include <GccEnt_QualifiedCirc.hxx> |
54e37688 |
47 | #include <Geom2dGcc_Lin2d2TanIter.hxx> |
7fd59977 |
48 | #include <BRepBuilderAPI_MakeWire.hxx> |
49 | #include <TopExp_Explorer.hxx> |
50 | #include <TopoDS.hxx> |
51 | #include <TopoDS_Wire.hxx> |
52 | #include <BRep_Tool.hxx> |
53 | #include <gp_Circ.hxx> |
54 | #include <BRepOffsetAPI_MakePipeShell.hxx> |
55 | #include <AIS_Trihedron.hxx> |
56 | #include <Geom_Axis2Placement.hxx> |
57 | #include <V3d_View.hxx> |
7fd59977 |
58 | #include <BRepBuilderAPI_MakeVertex.hxx> |
59 | #include <AIS_LengthDimension.hxx> |
60 | #include <AIS_RadiusDimension.hxx> |
61 | #include <BRepPrimAPI_MakeBox.hxx> |
62 | #include <GeomAdaptor_Surface.hxx> |
63 | #include <Extrema_ExtPS.hxx> |
64 | #include <Geom_CartesianPoint.hxx> |
65 | #include <Geom2d_CartesianPoint.hxx> |
66 | #include <Geom2dGcc_Circ2d3Tan.hxx> |
67 | #include <Aspect_Window.hxx> |
68 | |
69 | #include <TopoDS_Compound.hxx> |
70 | #include <TopoDS_CompSolid.hxx> |
71 | #include <StdSelect_ShapeTypeFilter.hxx> |
7fd59977 |
72 | #include <Prs3d_Projector.hxx> |
73 | #include <HLRAlgo_Projector.hxx> |
7fd59977 |
74 | #include <Standard_ErrorHandler.hxx> |
aff395a3 |
75 | #include <Font_NameOfFont.hxx> |
7fd59977 |
76 | |
77 | static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/) |
78 | { |
79 | Standard_Character abuf[16]; |
80 | //Standard_Character * abuf = new Standard_Character[16]; |
81 | |
82 | Standard_CString st = abuf; |
83 | |
84 | Handle(Geom_Circle) cir = new Geom_Circle (gp_Ax2 (gp_Pnt (823.687192, 502.366825, 478.960440), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 50); |
85 | Handle(Geom_Ellipse) ell = new Geom_Ellipse (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 150, 100); |
86 | Handle(Geom_Plane) plne = new Geom_Plane (gp_Ax3 (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)))); |
87 | |
88 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
89 | |
90 | gp_Pln pln = plne->Pln(); |
91 | Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln); |
91322f44 |
92 | Sprintf(abuf,"ell"); |
7fd59977 |
93 | DrawTrSurf::Set(st,curve2d); |
94 | if(!aContext.IsNull()) { |
95 | Handle(AIS_Shape) aisp = |
96 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge()); |
0577ae8c |
97 | aContext->Display (aisp, Standard_False); |
7fd59977 |
98 | } |
99 | |
100 | Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln); |
91322f44 |
101 | Sprintf(abuf,"cil"); |
7fd59977 |
102 | DrawTrSurf::Set(st,fromcurve2d); |
103 | if(!aContext.IsNull()) { |
104 | Handle(AIS_Shape) aisp = |
105 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge()); |
0577ae8c |
106 | aContext->Display (aisp, Standard_False); |
7fd59977 |
107 | } |
108 | |
109 | Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d); |
110 | Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside); |
111 | Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside); |
112 | Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0); |
113 | Standard_Integer i=0; |
114 | for(i=0;i<lintan.NbSolutions();i++) { |
91322f44 |
115 | Sprintf(abuf,"lintan_%d",i); |
7fd59977 |
116 | Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i)); |
117 | DrawTrSurf::Set(st,glin); |
118 | if(!aContext.IsNull()) { |
119 | Handle(AIS_Shape) aisp = |
0577ae8c |
120 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); |
121 | aContext->Display (aisp, Standard_False); |
7fd59977 |
122 | } |
123 | } |
0577ae8c |
124 | aContext->UpdateCurrentViewer(); |
7fd59977 |
125 | di << " Is Done = \n" << (Standard_Integer) lintan.IsDone(); |
126 | return 0; |
127 | } |
128 | |
129 | static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
130 | { |
131 | if (argc != 4 && argc != 5 && argc != 6 && argc != 7) { |
586db386 |
132 | di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]\n"; |
7fd59977 |
133 | return 1; |
134 | } |
135 | |
136 | Standard_Real par1 = 0.0, par2 = 0.0; |
137 | Standard_Real tol = Precision::Angular(); |
138 | if (argc >= 5) |
91322f44 |
139 | par1 = Draw::Atof(argv[4]); |
7fd59977 |
140 | if (argc == 6) |
91322f44 |
141 | par2 = Draw::Atof(argv[5]); |
7fd59977 |
142 | if (argc == 7) |
91322f44 |
143 | tol = Draw::Atof(argv[6]); |
7fd59977 |
144 | Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]); |
145 | Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]); |
146 | if (aCur2d1.IsNull() || aCur2d2.IsNull()) { |
586db386 |
147 | di << "Faulty : not curves\n"; |
7fd59977 |
148 | return 1; |
149 | } |
150 | Standard_Boolean c1IsCircle = Standard_False; |
151 | Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1); |
152 | if (!aCir2d.IsNull()) { |
153 | c1IsCircle = Standard_True; |
91322f44 |
154 | if (argc == 6) tol = Draw::Atof(argv[5]); |
7fd59977 |
155 | } |
156 | if(c1IsCircle) { |
157 | Geom2dAdaptor_Curve acur(aCur2d2); |
0b85f9a6 |
158 | Geom2dGcc_QCurve qcur(acur, GccEnt_unqualified); |
7fd59977 |
159 | GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified); |
54e37688 |
160 | Geom2dGcc_Lin2d2TanIter lintan(qfromcur, qcur , par1, tol); |
7fd59977 |
161 | if (lintan.IsDone()) { |
162 | gp_Lin2d lin = lintan.ThisSolution(); |
163 | Handle(Geom2d_Line) glin = new Geom2d_Line(lin); |
164 | DrawTrSurf::Set(argv[1], glin); |
165 | } else { |
586db386 |
166 | di << "Faulty : tangent line is not done.\n"; |
7fd59977 |
167 | } |
168 | } |
169 | else { |
170 | Geom2dAdaptor_Curve acur1(aCur2d1); |
171 | Geom2dAdaptor_Curve acur2(aCur2d2); |
0b85f9a6 |
172 | Geom2dGcc_QCurve qcur1(acur1, GccEnt_unqualified); |
173 | Geom2dGcc_QCurve qcur2(acur2, GccEnt_unqualified); |
54e37688 |
174 | Geom2dGcc_Lin2d2TanIter lintan(qcur1, qcur2 , par1, par2, tol); |
7fd59977 |
175 | if (lintan.IsDone()) { |
176 | gp_Lin2d lin = lintan.ThisSolution(); |
177 | Handle(Geom2d_Line) glin = new Geom2d_Line(lin); |
178 | DrawTrSurf::Set(argv[1], glin); |
179 | } else { |
586db386 |
180 | di << "Faulty : tangent line is not done.\n"; |
7fd59977 |
181 | } |
182 | } |
183 | return 0; |
184 | } |
185 | |
186 | static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
187 | { |
188 | if(argc!=3) |
189 | { |
586db386 |
190 | di << "Usage : " << argv[0] << " shape result\n"; |
7fd59977 |
191 | return 1; |
192 | } |
193 | |
194 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
195 | if(aContext.IsNull()) { |
196 | di << "use 'vinit' command before " << argv[0] << "\n"; |
197 | return 1; |
198 | } |
199 | |
200 | TopoDS_Shape aResult = DBRep::Get(argv[1]); |
201 | |
202 | BRepBuilderAPI_MakeWire bRepSpineWire; |
203 | TopExp_Explorer exp_(aResult, TopAbs_WIRE); |
204 | |
205 | Standard_Integer i = 0; |
206 | for(;exp_.More();exp_.Next()){ |
207 | i++; |
208 | bRepSpineWire.Add(TopoDS::Wire(exp_.Current())); |
209 | } |
210 | |
211 | //printf("total no of wires are ............. %d\n", i); |
212 | di << "total no of wires are ............. " << i << "\n"; |
213 | |
214 | TopoDS_Wire spineWire = bRepSpineWire.Wire(); |
0577ae8c |
215 | aContext->Display (new AIS_Shape(spineWire), Standard_False); |
7fd59977 |
216 | |
217 | DBRep::Set("slineW",spineWire); |
218 | |
219 | TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE); |
220 | Standard_Real first, last; |
857ffd5e |
221 | Handle(Geom_Curve) curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last); |
7fd59977 |
222 | gp_Pnt firstPnt; |
223 | gp_Vec tanVec; |
224 | curl_->D1(first, firstPnt, tanVec); |
225 | tanVec.Normalize(); |
226 | gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z()); |
227 | gp_Ax2 gpAx2(firstPnt, tanDir); |
228 | gp_Circ gpCirc(gpAx2, 2.5); |
229 | BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge()); |
230 | TopoDS_Wire topoWire(aMWire); |
0577ae8c |
231 | aContext->Display (new AIS_Shape(topoWire), Standard_False); |
7fd59977 |
232 | |
233 | DBRep::Set("topoW",topoWire); |
234 | |
235 | BRepOffsetAPI_MakePipeShell bRepPipe(spineWire); |
236 | bRepPipe.Add(topoWire); |
237 | bRepPipe.Build(); |
238 | |
0577ae8c |
239 | aContext->Display (new AIS_Shape(bRepPipe.Shape()), Standard_True); |
7fd59977 |
240 | |
241 | DBRep::Set(argv[2],bRepPipe.Shape()); |
242 | |
243 | return 0; |
244 | } |
245 | |
60bf98ae |
246 | static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
7fd59977 |
247 | { |
248 | if (argc > 1) { |
586db386 |
249 | di<<"Function don't has parameters\n"; |
7fd59977 |
250 | return 1; |
251 | } |
252 | |
60bf98ae |
253 | if(ViewerTest::GetAISContext().IsNull()) |
254 | { |
255 | di << "View was not created. Use 'vinit' command before " |
256 | << argv[0] << "\n"; |
257 | return 1; |
258 | } |
259 | Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext(); |
7fd59977 |
260 | |
261 | //The following dimesion code has problems regarding arrow_size. The desired effect is not produced. |
262 | /***************************************/ |
263 | //First view |
264 | /***************************************/ |
265 | gp_Pnt p1 = gp_Pnt(602.51,50.,0.); |
266 | gp_Pnt p2 = gp_Pnt(602.51,200.,0.); |
267 | gp_Pnt p3 = gp_Pnt(102.51,200.,0.); |
268 | gp_Pnt p4 = gp_Pnt(102.51,170.,0.); |
269 | gp_Pnt p5 = gp_Pnt(502.51,170.,0.); |
270 | gp_Pnt p6 = gp_Pnt(502.51,80.,0.); |
271 | gp_Pnt p7 = gp_Pnt(102.51,80.,0.); |
272 | gp_Pnt p8 = gp_Pnt(102.51,50.,0.); |
273 | TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1); |
274 | TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2); |
275 | TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3); |
276 | TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4); |
277 | TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5); |
278 | TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6); |
279 | TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7); |
280 | TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8); |
281 | gp_Pnt plnpt(0, 0, 0); |
282 | gp_Dir plndir(0, 0, 1); |
283 | Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir); |
60bf98ae |
284 | Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); |
285 | anAspect->MakeArrows3d (Standard_True); |
286 | anAspect->ArrowAspect()->SetAngle (M_PI/180.0 * 10.0); |
7fd59977 |
287 | /***************************************/ |
288 | //dimension "L 502.51" |
289 | /***************************************/ |
a6eb515f |
290 | Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln()); |
60bf98ae |
291 | anAspect->ArrowAspect()->SetLength (30.0); |
292 | len->SetDimensionAspect (anAspect); |
0577ae8c |
293 | context->Display (len, Standard_False); |
7fd59977 |
294 | /***************************************/ |
295 | //dimension "L 90" |
296 | /***************************************/ |
60bf98ae |
297 | Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln()); |
298 | len1->SetDimensionAspect (anAspect); |
299 | len1->SetFlyout (30.0); |
300 | anAspect->ArrowAspect()->SetLength (100.0); |
0577ae8c |
301 | context->Display (len1, Standard_False); |
7fd59977 |
302 | /***************************************/ |
303 | //dimension "L 150" |
304 | /***************************************/ |
a6eb515f |
305 | Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln()); |
60bf98ae |
306 | len2->SetDimensionAspect (anAspect); |
0577ae8c |
307 | context->Display (len2, Standard_False); |
7fd59977 |
308 | /***************************************/ |
309 | //dimension "R 88.58" |
310 | /***************************************/ |
311 | gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58); |
312 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) ); |
a6eb515f |
313 | Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1); |
60bf98ae |
314 | dim1->SetDimensionAspect (anAspect); |
0577ae8c |
315 | context->Display (dim1, Standard_False); |
7fd59977 |
316 | /***************************************/ |
317 | //dimension "R 43.80" |
318 | /***************************************/ |
319 | gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80); |
320 | TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1); |
a6eb515f |
321 | dim1 = new AIS_RadiusDimension(E_cir1); |
60bf98ae |
322 | anAspect->ArrowAspect()->SetLength (60.0); |
323 | dim1->SetDimensionAspect (anAspect); |
0577ae8c |
324 | context->Display (dim1, Standard_False); |
7fd59977 |
325 | /***************************************/ |
326 | //dimension "R 17.86" |
327 | /***************************************/ |
328 | gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86); |
329 | TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2); |
a6eb515f |
330 | dim1 = new AIS_RadiusDimension(E_cir2); |
60bf98ae |
331 | anAspect->ArrowAspect()->SetLength (40.0); |
332 | dim1->SetDimensionAspect (anAspect); |
0577ae8c |
333 | context->Display (dim1, Standard_True); |
7fd59977 |
334 | |
335 | return 0; |
336 | } |
337 | |
338 | static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) |
339 | { |
340 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
341 | if(aContext.IsNull()) { |
342 | di << "use 'vinit' command before " << argv[0] << "\n"; |
343 | return 1; |
344 | } |
345 | |
346 | BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100)); |
347 | BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300)); |
348 | BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500)); |
349 | |
c3282ec1 |
350 | Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape()); |
351 | Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape()); |
352 | Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape()); |
7fd59977 |
353 | |
0577ae8c |
354 | aContext->Display (ais1, Standard_False); |
355 | aContext->Display (ais2, Standard_False); |
356 | aContext->Display (ais3, Standard_False); |
7fd59977 |
357 | |
0577ae8c |
358 | aContext->AddOrRemoveSelected (ais1, Standard_False); |
359 | aContext->AddOrRemoveSelected (ais2, Standard_False); |
360 | aContext->AddOrRemoveSelected (ais3, Standard_False); |
7fd59977 |
361 | |
c3282ec1 |
362 | di << "\n No of currents = " << aContext->NbSelected(); |
7fd59977 |
363 | |
c3282ec1 |
364 | aContext->InitSelected(); |
7fd59977 |
365 | |
366 | int count = 1; |
c3282ec1 |
367 | while(aContext->MoreSelected()) |
7fd59977 |
368 | { |
369 | di << "\n count is = " << count++; |
c3282ec1 |
370 | Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive(); |
0577ae8c |
371 | aContext->AddOrRemoveSelected (ais, Standard_False); |
c3282ec1 |
372 | aContext->InitSelected(); |
7fd59977 |
373 | } |
374 | |
0577ae8c |
375 | aContext->UpdateCurrentViewer(); |
376 | |
7fd59977 |
377 | return 0; |
378 | } |
379 | |
7fd59977 |
380 | static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d) |
381 | { |
382 | int ret = 0; |
857ffd5e |
383 | Handle(Geom_Plane) gpln = new Geom_Plane(pln); |
7fd59977 |
384 | GeomAdaptor_Surface adsur(gpln); |
385 | Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001); |
386 | if( extps.IsDone() ) |
387 | { |
388 | int index; |
389 | for(index=1; index<= extps.NbExt(); index++ ) |
390 | { |
391 | Extrema_POnSurf pons = extps.Point(index); |
392 | Standard_Real U, V; |
393 | pons.Parameter(U, V); |
394 | pnt2d.SetCoord(U, V); |
395 | ret = 1; |
396 | } |
397 | } |
398 | return ret; |
399 | } |
400 | |
401 | static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** ) |
402 | { |
403 | gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) ); |
857ffd5e |
404 | Handle(Geom_Circle) h_cir1 = new Geom_Circle( ax21, 25 ); |
7fd59977 |
405 | |
406 | gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) ); |
857ffd5e |
407 | Handle(Geom_Circle) h_cir2 = new Geom_Circle( ax22, 25 ); |
7fd59977 |
408 | |
409 | gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) ); |
857ffd5e |
410 | Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln); |
411 | Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln); |
7fd59977 |
412 | |
413 | Geom2dAdaptor_Curve adop1(cir2d1); |
414 | Geom2dAdaptor_Curve adop2(cir2d2); |
415 | |
416 | Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing); |
417 | Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing); |
418 | |
857ffd5e |
419 | Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0,175,0); |
7fd59977 |
420 | |
421 | gp_Pnt pt3d = h_carpt->Pnt(); |
422 | gp_Pnt2d pt2d; |
423 | geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d); |
424 | |
425 | Standard_CString st; |
426 | st = "cir2d1"; |
427 | DrawTrSurf::Set(st,cir2d1); |
428 | st = "cir2d2"; |
429 | DrawTrSurf::Set(st,cir2d2); |
430 | st = "pt2d"; |
431 | DrawTrSurf::Set(st,pt2d); |
432 | |
857ffd5e |
433 | Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d); |
7fd59977 |
434 | Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0); |
435 | |
436 | int res = 0; |
437 | Standard_Character buf[10]; |
438 | buf[0] = '\0'; |
439 | |
440 | if( sol.IsDone() ) { |
441 | res = sol.NbSolutions(); |
442 | for(Standard_Integer i=1;i<=res;i++) { |
443 | Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i)); |
91322f44 |
444 | Sprintf(buf,"Result_%d",i); |
7fd59977 |
445 | st = buf; |
446 | DrawTrSurf::Set(st,aC); |
447 | } |
448 | } |
449 | else |
450 | di << "\n Faulty: no solutions found "; |
451 | //printf("\n Faulty: no solutions found "); |
452 | |
453 | //printf("\n Num of solutions are %d ", res ); |
454 | di << "\n Num of solutions are " << res << " "; |
455 | |
456 | return 0; |
457 | } |
458 | |
459 | static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
460 | { |
461 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
462 | if(aContext.IsNull()) |
463 | { |
464 | di << "use 'vinit' command before " << argv[0] << "\n"; |
465 | return -1; |
466 | } |
467 | if ( argc != 3) { |
586db386 |
468 | di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view\n"; |
7fd59977 |
469 | return 1; |
470 | } |
471 | |
91322f44 |
472 | Standard_Integer HLR = Draw::Atoi(argv[1]); |
7fd59977 |
473 | if (HLR != 0) { |
474 | HLR = 1; |
475 | } |
476 | |
18d715bd |
477 | TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName(); |
7fd59977 |
478 | Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); |
5e27df78 |
479 | aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE); |
18d715bd |
480 | Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window(); |
7fd59977 |
481 | Handle(V3d_View) aNewView = aViewer->CreateView(); |
5e27df78 |
482 | ViewerTest::CurrentView (aNewView); |
18d715bd |
483 | TCollection_AsciiString aNewName=anOldName + "_new"; |
484 | ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView()); |
5e27df78 |
485 | aNewView->SetWindow (asp); |
7fd59977 |
486 | if (!asp->IsMapped()) asp->Map(); |
18d715bd |
487 | aNewView->Redraw(); |
488 | ViewerTest::RemoveView(anOldName,false); |
5e27df78 |
489 | ViewerTest::UnsetEventManager(); |
490 | ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext())); |
491 | |
de75ed09 |
492 | if (HLR == 1) |
493 | { |
494 | di << "HLR\n"; |
18d715bd |
495 | ViewerTest::CurrentView()->SetComputedMode (Standard_True); |
7fd59977 |
496 | } |
497 | |
498 | return 0; |
499 | } |
500 | |
7fd59977 |
501 | static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) |
502 | { |
503 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
504 | if(aContext.IsNull()) { |
505 | di << "use 'vinit' command before " << argv[0] << "\n"; |
506 | return 1; |
507 | } |
508 | |
509 | BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100)); |
510 | BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300)); |
511 | BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500)); |
512 | |
543a9964 |
513 | Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape()); |
514 | Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape()); |
515 | Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape()); |
7fd59977 |
516 | |
0577ae8c |
517 | aContext->Display (ais1, Standard_False); |
518 | aContext->Display (ais2, Standard_False); |
519 | aContext->Display (ais3, Standard_False); |
7fd59977 |
520 | |
0577ae8c |
521 | aContext->AddOrRemoveSelected (ais1, Standard_False); |
522 | aContext->AddOrRemoveSelected (ais2, Standard_False); |
523 | aContext->AddOrRemoveSelected (ais3, Standard_False); |
7fd59977 |
524 | |
525 | di << "\n No of selected = " << aContext->NbSelected(); |
526 | |
527 | aContext->InitSelected(); |
528 | |
529 | int count = 1; |
530 | while(aContext->MoreSelected()) |
531 | { |
532 | di << "\n count is = %d" << count++; |
857ffd5e |
533 | Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive(); |
0577ae8c |
534 | aContext->AddOrRemoveSelected (ais, Standard_False); |
7fd59977 |
535 | aContext->InitSelected(); |
536 | } |
537 | |
0577ae8c |
538 | aContext->UpdateCurrentViewer(); |
539 | |
7fd59977 |
540 | return 0; |
541 | } |
542 | |
7fd59977 |
543 | #include <BRepBndLib.hxx> |
544 | #include <Draw.hxx> |
545 | //======================================================================= |
546 | //function : OCC566 |
547 | //purpose : |
548 | //======================================================================= |
549 | static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a) |
550 | { |
551 | if (n < 2) { |
586db386 |
552 | di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]\n"; |
7fd59977 |
553 | return 1; |
554 | } |
555 | TopoDS_Shape S = DBRep::Get(a[1]); |
556 | if (S.IsNull()) return 1; |
557 | Bnd_Box B; |
558 | BRepBndLib::AddClose(S,B); |
559 | Standard_Real axmin,aymin,azmin,axmax,aymax,azmax; |
560 | B.Get(axmin,aymin,azmin,axmax,aymax,azmax); |
561 | di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax; |
562 | if (n >= 8) { |
563 | Draw::Set(a[2],axmin) ; |
564 | Draw::Set(a[3],aymin) ; |
565 | Draw::Set(a[4],azmin) ; |
566 | Draw::Set(a[5],axmax) ; |
567 | Draw::Set(a[6],aymax) ; |
568 | Draw::Set(a[7],azmax) ; |
569 | } |
570 | return 0; |
571 | } |
572 | |
573 | #include <BRepFilletAPI_MakeFillet.hxx> |
574 | //======================================================================= |
575 | //function : OCC570 |
576 | //purpose : |
577 | //======================================================================= |
578 | static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
579 | { |
580 | if (argc < 2) { |
586db386 |
581 | di<<"Usage: " << argv[0] << " result\n"; |
7fd59977 |
582 | return 1; |
583 | } |
584 | |
585 | BRepPrimAPI_MakeBox mkBox(100.,100.,100.); |
586 | TopoDS_Shape aBox = mkBox.Shape(); |
587 | |
588 | TopExp_Explorer aExp; |
589 | aExp.Init(aBox,TopAbs_WIRE); |
590 | if (aExp.More()) |
591 | { |
592 | TopoDS_Shape aWire = aExp.Current(); |
593 | |
594 | aExp.Init(aWire,TopAbs_EDGE); |
595 | TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next(); |
596 | TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next(); |
597 | TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next(); |
598 | TopoDS_Edge e4 = TopoDS::Edge(aExp.Current()); |
599 | |
600 | try |
601 | { |
602 | OCC_CATCH_SIGNALS |
603 | BRepFilletAPI_MakeFillet mkFillet(aBox); |
604 | mkFillet.SetContinuity(GeomAbs_C1,.001); |
605 | |
606 | // Setup variable fillet data |
607 | TColgp_Array1OfPnt2d t_pnt(1,4); |
608 | t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0)); |
609 | t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0)); |
610 | t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0)); |
611 | t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0)); |
612 | |
613 | // HERE: |
614 | // It is impossible to build fillet if at least one edge |
615 | // with variable radius is added!!! If all are constant, everything is ok. |
616 | mkFillet.Add(t_pnt,e1); |
617 | mkFillet.Add(5.0,e2); |
618 | mkFillet.Add(t_pnt,e3); |
619 | mkFillet.Add(5.0,e4); |
620 | |
621 | mkFillet.Build(); |
622 | TopoDS_Shape aFinalShape = mkFillet.Shape(); |
623 | |
624 | DBRep::Set(argv[1],aFinalShape); |
625 | } |
626 | catch(Standard_Failure) |
627 | { |
586db386 |
628 | di << argv[0] << ": Exception in fillet\n"; |
7fd59977 |
629 | return 2; |
630 | } |
631 | } |
632 | |
633 | return 0; |
634 | } |
635 | |
636 | #include <Law_Interpol.hxx> |
637 | |
638 | static Standard_Real t3d = 1.e-4; |
639 | static Standard_Real t2d = 1.e-5; |
640 | static Standard_Real ta = 1.e-2; |
641 | static Standard_Real fl = 1.e-3; |
642 | static Standard_Real tapp_angle = 1.e-2; |
643 | static GeomAbs_Shape blend_cont = GeomAbs_C1; |
644 | |
7fd59977 |
645 | static BRepFilletAPI_MakeFillet* Rake = 0; |
646 | static char name[100]; |
647 | |
648 | static void printtolblend(Draw_Interpretor& di) |
649 | { |
650 | di<<"tolerance ang : "<<ta<<"\n"; |
651 | di<<"tolerance 3d : "<<t3d<<"\n"; |
652 | di<<"tolerance 2d : "<<t2d<<"\n"; |
653 | di<<"fleche : "<<fl<<"\n"; |
654 | |
655 | di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n"; |
656 | } |
657 | |
658 | static Standard_Integer MKEVOL(Draw_Interpretor& di, |
659 | Standard_Integer narg, |
660 | const char ** a) |
661 | { |
662 | if(Rake != 0) {delete Rake; Rake = 0;} |
663 | printtolblend(di); |
664 | if (narg < 3) return 1; |
665 | TopoDS_Shape V = DBRep::Get(a[2]); |
666 | Rake = new BRepFilletAPI_MakeFillet(V); |
667 | Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl); |
668 | Rake->SetContinuity(blend_cont, tapp_angle); |
669 | if (narg == 4) { |
670 | ChFi3d_FilletShape FSh = ChFi3d_Rational; |
671 | if (!strcasecmp(a[3], "Q")) { |
672 | FSh = ChFi3d_QuasiAngular; |
673 | } |
674 | else if (!strcasecmp(a[3], "P")) { |
675 | FSh = ChFi3d_Polynomial; |
676 | } |
677 | Rake->SetFilletShape(FSh); |
678 | } |
679 | strcpy(name, a[1]); |
680 | return 0; |
681 | } |
682 | |
683 | static Standard_Integer UPDATEVOL(Draw_Interpretor& di, |
684 | Standard_Integer narg, |
685 | const char ** a) |
686 | { |
687 | if(Rake == 0){ |
586db386 |
688 | di << "MakeFillet non initialise\n"; |
7fd59977 |
689 | return 1 ; |
690 | } |
691 | if(narg%2 != 0 || narg < 4) return 1; |
692 | TColgp_Array1OfPnt2d uandr(1,(narg/2)-1); |
693 | Standard_Real Rad, Par; |
694 | TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE)); |
695 | TopoDS_Edge E = TopoDS::Edge(aLocalEdge); |
696 | for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){ |
91322f44 |
697 | Par = Draw::Atof(a[2*ii]); |
698 | Rad = Draw::Atof(a[2*ii + 1]); |
7fd59977 |
699 | uandr.ChangeValue(ii).SetCoord(Par,Rad); |
700 | } |
701 | //HELPDESK: Add law creation |
702 | const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw"); |
703 | if (aLawMode) |
704 | { |
586db386 |
705 | di<<"INFO: Using law to define variable fillet\n"; |
7fd59977 |
706 | Handle(Law_Interpol) law = new Law_Interpol; |
707 | law->Set(uandr); |
708 | Rake->Add(law,E); |
709 | } |
710 | else |
711 | Rake->Add(uandr,E); |
712 | |
713 | return 0; |
714 | } |
715 | |
716 | static Standard_Integer BUILDEVOL(Draw_Interpretor& di, |
717 | Standard_Integer, |
718 | const char **) |
719 | { |
720 | if(Rake == 0){ |
586db386 |
721 | di << "MakeFillet non initialise\n"; |
7fd59977 |
722 | return 1 ; |
723 | } |
724 | Rake->Build(); |
725 | if(Rake->IsDone()){ |
726 | TopoDS_Shape result = Rake->Shape(); |
727 | DBRep::Set(name,result); |
728 | if(Rake != 0) {delete Rake; Rake = 0;} |
729 | return 0; |
730 | } |
731 | if(Rake != 0) {delete Rake; Rake = 0;} |
732 | return 1; |
733 | } |
734 | |
735 | #include <TColGeom_SequenceOfCurve.hxx> |
736 | #include <Geom_TrimmedCurve.hxx> |
737 | #include <GeomFill_NSections.hxx> |
738 | #include <BRepBuilderAPI_MakeFace.hxx> |
739 | //======================================================================= |
740 | //function : OCC606 |
741 | //purpose : |
742 | //======================================================================= |
743 | static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a ) |
744 | { |
745 | if (n != 3 && n != 4) |
746 | { |
586db386 |
747 | di << "Usage : " << a[0] << " result shape [-t]\n"; |
7fd59977 |
748 | return 0; |
749 | } |
750 | |
751 | Standard_Boolean TrimMode = (n == 4); |
586db386 |
752 | if (TrimMode) di<<"INFO: Using trimmed curves...\n"; |
753 | else di<<"INFO: Using non trimmed curves...\n"; |
7fd59977 |
754 | |
755 | TopoDS_Shape S = DBRep::Get(a[2]); |
756 | |
757 | TopExp_Explorer t_exp(S,TopAbs_EDGE); |
758 | TColGeom_SequenceOfCurve n_curves1; |
759 | TColStd_SequenceOfReal np; |
760 | Standard_Real param = 5.0; |
761 | |
762 | for (;t_exp.More();t_exp.Next()) |
763 | { |
764 | Standard_Real f,l; |
765 | Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l); |
766 | if (!h_cur.IsNull()) |
767 | { |
768 | if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l); |
769 | |
770 | n_curves1.Append(h_cur); |
771 | np.Append(param); |
772 | param += 1.0; |
773 | } |
774 | } |
775 | |
776 | if (n_curves1.Length()>1 && !np.IsEmpty()) |
777 | { |
778 | try |
779 | { |
780 | OCC_CATCH_SIGNALS |
781 | GeomFill_NSections b_surface1(n_curves1, np); |
782 | b_surface1.ComputeSurface(); |
783 | Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface(); |
784 | if (!result_surf1.IsNull()) |
785 | { |
1c72dff6 |
786 | BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion()); |
7fd59977 |
787 | TopoDS_Face bsp_face1 = b_face1.Face(); |
788 | DBRep::Set(a[1],bsp_face1); |
789 | } |
790 | } |
791 | catch(Standard_Failure) |
792 | { |
586db386 |
793 | di<<"ERROR: Exception in GeomFill_NSections\n"; |
7fd59977 |
794 | } |
795 | } |
796 | |
797 | |
798 | return 0; |
799 | } |
800 | |
801 | //======================================================================= |
802 | //function : OCC813 |
803 | //purpose : |
804 | //======================================================================= |
805 | static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
806 | { |
807 | if (argc < 3) |
808 | { |
586db386 |
809 | di << "Usage : " << argv[0] << " U V\n"; |
7fd59977 |
810 | return 1; |
811 | } |
812 | |
813 | Standard_CString str; |
91322f44 |
814 | Standard_Real U = Draw::Atof(argv[1]); |
815 | Standard_Real V = Draw::Atof(argv[2]); |
7fd59977 |
816 | |
817 | //Between ellipse and point: |
818 | |
819 | Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716), |
820 | gp_Dir(0.173648,0.984808,0.000000), |
821 | gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100); |
822 | Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716), |
823 | gp_Dir(0.173648,0.984808,0.000000), |
824 | gp_Dir(-0.932169,0.164367,-0.322560))) ); |
825 | |
826 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
827 | |
828 | gp_Pnt2d pt2d(U,V); |
829 | gp_Pln pln = plne->Pln(); |
830 | |
831 | str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d); |
832 | |
833 | Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln); |
834 | Geom2dAdaptor_Curve acur(curve2d); |
835 | Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside); |
836 | |
837 | str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d); |
838 | if(!aContext.IsNull()) { |
839 | Handle(AIS_Shape) aisp = |
840 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge()); |
0577ae8c |
841 | aContext->Display (aisp, Standard_False); |
7fd59977 |
842 | } |
843 | |
844 | //This does not give any solutions. |
845 | Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1); |
846 | di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n"; |
847 | |
848 | Standard_Character abuf[16]; |
849 | Standard_CString st = abuf; |
850 | |
851 | Standard_Integer i; |
852 | for(i=1;i<=lintan.NbSolutions();i++) { |
91322f44 |
853 | Sprintf(abuf,"lintan_%d",i); |
7fd59977 |
854 | Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i)); |
855 | DrawTrSurf::Set(st,glin); |
856 | if(!aContext.IsNull()) { |
857 | Handle(AIS_Shape) aisp = |
0577ae8c |
858 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); |
859 | aContext->Display (aisp, Standard_False); |
7fd59977 |
860 | } |
861 | } |
862 | |
0577ae8c |
863 | if (!aContext.IsNull()) |
864 | { |
865 | aContext->UpdateCurrentViewer(); |
866 | } |
867 | |
7fd59977 |
868 | return 0; |
869 | } |
870 | |
871 | //======================================================================= |
872 | //function : OCC814 |
873 | //purpose : |
874 | //======================================================================= |
875 | static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
876 | { |
877 | if (argc > 1) |
878 | { |
879 | di << "Usage : " << argv[0] << "\n"; |
880 | return 1; |
881 | } |
882 | |
883 | Standard_CString str; |
884 | |
885 | //Between Ellipse and Circle: |
886 | |
887 | Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440), |
888 | gp_Dir(0.173648,0.984808,0.000000), |
889 | gp_Dir(-0.932169,0.164367,-0.322560)), 50); |
890 | Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716), |
891 | gp_Dir(0.173648,0.984808,0.000000), |
892 | gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100); |
893 | Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716), |
894 | gp_Dir(0.173648,0.984808,0.000000), |
895 | gp_Dir(-0.932169,0.164367,-0.322560))) ); |
896 | |
897 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
898 | |
899 | gp_Pln pln = plne->Pln(); |
900 | Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln); |
901 | Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln); |
902 | |
903 | str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d); |
904 | str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d); |
905 | if(!aContext.IsNull()) { |
906 | Handle(AIS_Shape) aisp = |
907 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge()); |
0577ae8c |
908 | aContext->Display (aisp, Standard_False); |
7fd59977 |
909 | } |
910 | if(!aContext.IsNull()) { |
911 | Handle(AIS_Shape) aisp = |
912 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge()); |
0577ae8c |
913 | aContext->Display (aisp, Standard_False); |
7fd59977 |
914 | } |
915 | |
916 | Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d); |
917 | |
918 | Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ; |
919 | Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ; |
920 | |
921 | //This does not give any solutions. |
922 | Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1); |
923 | di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n"; |
924 | |
925 | Standard_Character abuf[16]; |
926 | Standard_CString st = abuf; |
927 | |
928 | Standard_Integer i; |
929 | for(i=1;i<=lintan.NbSolutions();i++) { |
91322f44 |
930 | Sprintf(abuf,"lintan_%d",i); |
7fd59977 |
931 | Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i)); |
932 | DrawTrSurf::Set(st,glin); |
933 | if(!aContext.IsNull()) { |
934 | Handle(AIS_Shape) aisp = |
0577ae8c |
935 | new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); |
936 | aContext->Display (aisp, Standard_False); |
7fd59977 |
937 | } |
938 | } |
939 | |
0577ae8c |
940 | if (!aContext.IsNull()) |
941 | { |
942 | aContext->UpdateCurrentViewer(); |
943 | } |
944 | |
7fd59977 |
945 | return 0; |
946 | } |
947 | |
948 | #include <ShapeAnalysis_Wire.hxx> |
949 | #include <IntRes2d_SequenceOfIntersectionPoint.hxx> |
950 | #include <TColgp_SequenceOfPnt.hxx> |
951 | #include <ShapeFix_Wire.hxx> |
952 | //======================================================================= |
953 | //function : OCC884 |
954 | //purpose : |
955 | //======================================================================= |
956 | static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
957 | { |
958 | if (argc < 3 || argc > 5) |
959 | { |
586db386 |
960 | di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]\n"; |
7fd59977 |
961 | return 1; |
962 | } |
963 | |
964 | TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape |
965 | |
966 | TopExp_Explorer exp(shape, TopAbs_EDGE); |
967 | if (!exp.More()) |
968 | { |
586db386 |
969 | di<<"Error: no edge found\n"; |
7fd59977 |
970 | return 1; |
971 | } |
972 | |
973 | BRep_Builder builder; |
974 | TopoDS_Wire wire; |
975 | builder.MakeWire(wire); |
976 | builder.Add(wire, TopoDS::Edge(exp.Current())); |
977 | |
978 | // HelpDesk: Create planar face if possible |
979 | TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True); |
980 | |
981 | Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire; |
982 | advWA->Load(wire); |
983 | advWA->SetFace(face); |
984 | advWA->SetPrecision(0.001); |
985 | |
986 | IntRes2d_SequenceOfIntersectionPoint points2d; |
987 | TColgp_SequenceOfPnt points3d; |
988 | |
989 | di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n"; |
990 | |
991 | ShapeExtend_Status status = ShapeExtend_FAIL1; |
992 | if (advWA->StatusSelfIntersection(status)) |
993 | di << "Info: No P Curve found in the edge\n"; |
994 | |
995 | status = ShapeExtend_FAIL2; |
996 | if (advWA->StatusSelfIntersection(status)) |
997 | di << "Info: No Vertices found in the edge\n"; |
998 | |
999 | status = ShapeExtend_DONE1; |
1000 | if (advWA->StatusSelfIntersection(status)) |
1001 | di << "Info: Self-intersection found in the edge\n"; |
1002 | |
1003 | Standard_Integer i, num = points2d.Length(); |
1004 | di << "Info: No. of self-intersection points : " << num << "\n"; |
1005 | |
1006 | char str[80]; |
75259fc5 |
1007 | Standard_CString aName = str; |
7fd59977 |
1008 | for (i = 1; i <= num; ++i) |
1009 | { |
1010 | gp_Pnt pt = points3d(i); |
1011 | di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n"; |
91322f44 |
1012 | Sprintf(str,"p_%d",i); |
75259fc5 |
1013 | DrawTrSurf::Set(aName,pt); |
7fd59977 |
1014 | } |
1015 | |
1016 | Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; |
1017 | sfw->Load(wire); |
1018 | sfw->SetFace(face); |
1019 | |
91322f44 |
1020 | if (argc > 3) sfw->SetPrecision(Draw::Atof(argv[3])/*0.1*/); |
1021 | if (argc > 4) sfw->SetMaxTolerance(Draw::Atof(argv[4])); |
7fd59977 |
1022 | di << "Info: Precision is set to " << sfw->Precision() << "\n"; |
1023 | di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n"; |
1024 | |
1025 | sfw->ModifyTopologyMode() = 1; |
1026 | sfw->ModifyGeometryMode() = 1; |
1027 | sfw->FixSelfIntersectingEdgeMode() = 1; |
1028 | //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection()); |
1029 | di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n"; |
1030 | |
1031 | DBRep::Set(argv[1],sfw->Wire()); |
1032 | |
1033 | status = ShapeExtend_OK; |
1034 | if (sfw->StatusSelfIntersection(status)) |
1035 | di << "Info: ShapeExtend_OK : No intersection found\n"; |
1036 | //printf("Info: ShapeExtend_OK : No intersection found\n"); |
1037 | |
1038 | status = ShapeExtend_FAIL1; |
1039 | if (sfw->StatusSelfIntersection(status)) |
1040 | di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n"; |
1041 | |
1042 | status = ShapeExtend_FAIL2; |
1043 | if (sfw->StatusSelfIntersection(status)) |
1044 | di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n"; |
1045 | |
1046 | status = ShapeExtend_FAIL3; |
1047 | if (sfw->StatusSelfIntersection(status)) |
1048 | di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n"; |
1049 | |
1050 | status = ShapeExtend_DONE1; |
1051 | if (sfw->StatusSelfIntersection(status)) |
1052 | di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n"; |
1053 | |
1054 | status = ShapeExtend_DONE2; |
1055 | if (sfw->StatusSelfIntersection(status)) |
1056 | di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n"; |
1057 | |
1058 | status = ShapeExtend_DONE3; |
1059 | if (sfw->StatusSelfIntersection(status)) |
1060 | di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n"; |
1061 | |
1062 | status = ShapeExtend_DONE4; |
1063 | if (sfw->StatusSelfIntersection(status)) |
1064 | di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n"; |
1065 | |
1066 | status = ShapeExtend_DONE5; |
1067 | if (sfw->StatusSelfIntersection(status)) |
1068 | di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n"; |
1069 | |
1070 | status = ShapeExtend_DONE6; |
1071 | if (sfw->StatusSelfIntersection(status)) |
1072 | di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n"; |
1073 | |
1074 | status = ShapeExtend_DONE7; |
1075 | if (sfw->StatusSelfIntersection(status)) |
1076 | di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n"; |
1077 | |
1078 | return 0; |
1079 | } |
1080 | |
7fd59977 |
1081 | #include <Graphic3d_MaterialAspect.hxx> |
6262338c |
1082 | #include <Prs3d_Drawer.hxx> |
7fd59977 |
1083 | #include <Prs3d_ShadingAspect.hxx> |
1084 | //======================================================================= |
1085 | //function : OCC1174_1 |
1086 | //purpose : |
1087 | //======================================================================= |
1088 | static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1089 | { |
1090 | if (argc != 2) |
1091 | { |
586db386 |
1092 | di << "Usage : " << argv[0] << " shape\n"; |
7fd59977 |
1093 | return 1; |
1094 | } |
1095 | |
6262338c |
1096 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); |
1097 | if(anAISContext.IsNull()) |
7fd59977 |
1098 | { |
1099 | di << "use 'vinit' command before " << argv[0] << "\n"; |
1100 | return 1; |
1101 | } |
1102 | |
6262338c |
1103 | TopoDS_Shape aShape = DBRep::Get(argv[1]); |
1104 | |
1105 | Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape); |
7fd59977 |
1106 | |
6262338c |
1107 | Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB); |
1108 | Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB); |
7fd59977 |
1109 | |
6262338c |
1110 | Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes(); |
1111 | Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect(); |
7fd59977 |
1112 | |
6262338c |
1113 | Graphic3d_MaterialAspect aFront = aShadingAspect->Material(Aspect_TOFM_FRONT_SIDE); |
1114 | aFront.SetAmbientColor(aColF); |
1115 | aFront.SetDiffuseColor(aColF); |
1116 | aFront.SetSpecularColor(aColF); |
1117 | aFront.SetEmissiveColor(aColF); |
1118 | aFront.SetTransparency(0.0); |
1119 | aShadingAspect->SetMaterial(aFront,Aspect_TOFM_FRONT_SIDE); |
7fd59977 |
1120 | |
6262338c |
1121 | Graphic3d_MaterialAspect aBack = aShadingAspect->Material(Aspect_TOFM_BACK_SIDE); |
1122 | aBack.SetAmbientColor(aColB); |
1123 | aBack.SetDiffuseColor(aColB); |
1124 | aBack.SetSpecularColor(aColB); |
1125 | aBack.SetEmissiveColor(aColB); |
1126 | aBack.SetTransparency(0.0); |
1127 | aShadingAspect->SetMaterial(aBack,Aspect_TOFM_BACK_SIDE); |
7fd59977 |
1128 | |
6262338c |
1129 | aDrawer->SetShadingAspect (aShadingAspect); |
7fd59977 |
1130 | |
0577ae8c |
1131 | anAISContext->Display (anAisIO, 1, 0, Standard_True); |
7fd59977 |
1132 | |
1133 | Standard_Real r, g, b; |
6262338c |
1134 | aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB); |
7fd59977 |
1135 | di << "Info: color on front side (" << r << "," << g << "," << b << ")\n"; |
6262338c |
1136 | aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB); |
7fd59977 |
1137 | di << "Info: color on back side (" << r << "," << g << "," << b << ")\n"; |
1138 | |
1139 | return 0; |
1140 | } |
1141 | |
1142 | //======================================================================= |
1143 | //function : OCC1174_2 |
1144 | //purpose : |
1145 | //======================================================================= |
1146 | static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1147 | { |
1148 | if (argc != 2) |
1149 | { |
586db386 |
1150 | di << "Usage : " << argv[0] << " shape\n"; |
7fd59977 |
1151 | return 1; |
1152 | } |
1153 | |
1154 | Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); |
1155 | if(AISContext.IsNull()) |
1156 | { |
1157 | di << "use 'vinit' command before " << argv[0] << "\n"; |
1158 | return 1; |
1159 | } |
1160 | |
1161 | TopoDS_Shape sh = DBRep::Get(argv[1]); |
1162 | |
1163 | Handle(AIS_Shape) ais = new AIS_Shape(sh); |
0577ae8c |
1164 | AISContext->Display (ais, 1, 0, Standard_False); |
1165 | AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False); |
7fd59977 |
1166 | |
1167 | Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB); |
1168 | Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB); |
1169 | Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect(); |
1170 | |
1171 | Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE); |
1172 | front.SetAmbientColor(colf); |
1173 | front.SetDiffuseColor(colf); |
1174 | front.SetSpecularColor(colf); |
1175 | front.SetEmissiveColor(colf); |
4e1bc39a |
1176 | front.SetTransparency (0.4f); |
7fd59977 |
1177 | sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE); |
1178 | |
1179 | Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE); |
1180 | back.SetAmbientColor(colb); |
1181 | back.SetDiffuseColor(colb); |
1182 | back.SetSpecularColor(colb); |
1183 | back.SetEmissiveColor(colb); |
4e1bc39a |
1184 | back.SetTransparency (0.2f); |
7fd59977 |
1185 | sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE); |
1186 | |
0577ae8c |
1187 | AISContext->Redisplay (ais, 1, 0); |
7fd59977 |
1188 | |
1189 | return 0; |
1190 | } |
1191 | |
7fd59977 |
1192 | #include <TopoDS_Solid.hxx> |
1193 | #include <BRepFeat_MakeDPrism.hxx> |
1194 | //======================================================================= |
1195 | //function : OCCN1 |
1196 | //purpose : FEATURE OPERATION (BOSS and SLOT) |
1197 | //======================================================================= |
1198 | static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1199 | { |
1200 | if (argc != 4) |
1201 | { |
586db386 |
1202 | di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length\n"; |
7fd59977 |
1203 | return 1; |
1204 | } |
1205 | |
1206 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
1207 | if(aContext.IsNull()) |
1208 | { |
1209 | di << "use 'vinit' command before " << argv[0] << "\n"; |
1210 | return 1; |
1211 | } |
91322f44 |
1212 | Standard_Real angle = Draw::Atof(argv[1]); |
1213 | Standard_Integer fuse = Draw::Atoi(argv[2]); |
1214 | Standard_Real length = Draw::Atof(argv[3]); |
7fd59977 |
1215 | |
1216 | BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0)); |
1217 | BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0)); |
1218 | BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0)); |
1219 | BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0)); |
1220 | TopoDS_Edge ted1 = edge1.Edge(); |
1221 | TopoDS_Edge ted2 = edge2.Edge(); |
1222 | TopoDS_Edge ted3 = edge3.Edge(); |
1223 | TopoDS_Edge ted4 = edge4.Edge(); |
1224 | |
1225 | BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4); |
1226 | TopoDS_Wire twire = wire.Wire(); |
1227 | |
1228 | BRepBuilderAPI_MakeFace face(twire); |
1229 | TopoDS_Face tface = face.Face(); |
857ffd5e |
1230 | ////////Handle(AIS_Shape) face_ais = new AIS_Shape( tface ); |
7fd59977 |
1231 | ////////aContext->Display(face_ais); |
1232 | |
1233 | TopoDS_Solid box; |
1234 | BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100); |
1235 | box = block.Solid(); |
1236 | |
1237 | TopoDS_Face top_face; |
1238 | top_face = block.TopFace(); |
1239 | |
1240 | BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse, |
1241 | Standard_True); |
1242 | |
1243 | slot.Perform(length); |
1244 | TopoDS_Shape S2 = slot.Shape(); |
1245 | |
1246 | DBRep::Set("OCCN1_tface",tface); |
1247 | DBRep::Set("OCCN1_slot",S2); |
1248 | |
1249 | return 0; |
1250 | } |
1251 | |
1252 | #include <BRepPrimAPI_MakeCylinder.hxx> |
1253 | #include <BRepPrimAPI_MakeSphere.hxx> |
1254 | #include <BRepAlgoAPI_Section.hxx> |
7fd59977 |
1255 | //======================================================================= |
1256 | //function : OCCN2 |
1257 | //purpose : BOOLEAN OPERATION |
1258 | //======================================================================= |
1259 | static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1260 | { |
1261 | if (argc > 2) { |
431d0f18 |
1262 | di << "Usage : " << argv[0] << "\n"; |
7fd59977 |
1263 | return 1; |
1264 | } |
7fd59977 |
1265 | |
1266 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
1267 | if(aContext.IsNull()) |
1268 | { |
1269 | di << "use 'vinit' command before " << argv[0] << "\n"; |
1270 | return 1; |
1271 | } |
1272 | |
1273 | BRepPrimAPI_MakeCylinder cylinder(50,200); |
1274 | TopoDS_Shape cylinder_sh = cylinder.Shape(); |
1275 | |
1276 | BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50); |
1277 | TopoDS_Shape sphere_sh = sphere.Shape(); |
1278 | |
431d0f18 |
1279 | di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)\n"; |
1280 | BRepAlgoAPI_Section section(cylinder_sh, sphere_sh); |
1281 | if (!section.IsDone()){ |
1282 | di << "Error performing intersection: not done.\n"; |
7fd59977 |
1283 | } |
431d0f18 |
1284 | const TopoDS_Shape& shape = section.Shape(); |
7fd59977 |
1285 | |
1286 | DBRep::Set("OCCN2_cylinder",cylinder_sh); |
1287 | DBRep::Set("OCCN2_sphere",sphere_sh); |
1288 | DBRep::Set("OCCN2_section",shape); |
1289 | |
1290 | return 0; |
1291 | } |
1292 | |
1293 | #include <TColgp_Array1OfPnt.hxx> |
1294 | #include <Geom_BezierCurve.hxx> |
1295 | |
1296 | static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1297 | { |
1298 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
1299 | if(aContext.IsNull()) |
1300 | { |
1301 | di << "use 'vinit' command before " << argv[0] << "\n"; |
1302 | return 1; |
1303 | } |
1304 | if(argc != 3) { |
586db386 |
1305 | di << "Usage : " << argv[0] << " nbpoles result\n"; |
7fd59977 |
1306 | return 1; |
1307 | } |
1308 | |
91322f44 |
1309 | int poles=Draw::Atoi(argv[1]); |
7fd59977 |
1310 | |
1311 | TColgp_Array1OfPnt arr(1, poles); |
1312 | for(int i=1; i<=poles; i++) |
1313 | arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45)); |
1314 | |
857ffd5e |
1315 | Handle(Geom_BezierCurve) bez = new Geom_BezierCurve(arr); |
7fd59977 |
1316 | if(bez.IsNull()) { |
1317 | di << "\n The curve is not created.\n"; |
1318 | } else { |
1319 | di << "\n Degree = " << bez->Degree() << "\n"; |
1320 | } |
1321 | TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge(); |
857ffd5e |
1322 | Handle(AIS_Shape) ais = new AIS_Shape(sh); |
0577ae8c |
1323 | aContext->Display (ais, Standard_True); |
7fd59977 |
1324 | DrawTrSurf::Set(argv[2],bez); |
1325 | return 0; |
1326 | } |
1327 | |
1328 | #include <TopTools_IndexedMapOfShape.hxx> |
1329 | #include <TopExp.hxx> |
1330 | |
1331 | static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1332 | { |
1333 | if (argc != 10) { |
586db386 |
1334 | di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection\n"; |
7fd59977 |
1335 | return 1; |
1336 | } |
1337 | |
1338 | TopoDS_Shape shape = DBRep::Get(argv[5]); |
1339 | |
1340 | TopExp_Explorer exp(shape, TopAbs_WIRE); |
1341 | TopoDS_Shape wire = exp.Current(); |
1342 | |
1343 | Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire; |
1344 | advWA->Load(TopoDS::Wire(wire)); |
1345 | |
1346 | DBRep::Set(argv[3],wire); |
1347 | |
1348 | TopoDS_Face face = |
1349 | BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True); |
1350 | |
1351 | DBRep::Set(argv[4],face); |
1352 | |
1353 | advWA->SetFace(face); |
5e27df78 |
1354 | Standard_Real precision_to_ana = 0.0001; |
7fd59977 |
1355 | advWA->SetPrecision(precision_to_ana); |
1356 | |
1357 | TopTools_IndexedMapOfShape M; |
1358 | TopExp::MapShapes(wire, TopAbs_EDGE, M); |
1359 | |
1360 | int j= 1; |
1361 | for(j= 1; j<=M.Extent(); ++j) { |
1362 | Standard_Integer num=1; |
1363 | IntRes2d_SequenceOfIntersectionPoint points2d; |
1364 | TColgp_SequenceOfPnt points3d; |
1365 | |
1366 | cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " << |
1367 | advWA->CheckSelfIntersectingEdge(j, points2d, points3d); |
1368 | |
1369 | |
1370 | ShapeExtend_Status status = ShapeExtend_FAIL1; |
1371 | if(advWA->StatusSelfIntersection(status)) |
1372 | |
1373 | status = ShapeExtend_FAIL2; |
1374 | if(advWA->StatusSelfIntersection(status)) |
1375 | di << "\n No Vertices found in the edge"; |
1376 | |
1377 | status = ShapeExtend_DONE1; |
1378 | if(advWA->StatusSelfIntersection(status)) |
1379 | di << "\n Self-intersection found in the edge"; |
1380 | |
1381 | num = points2d.Length(); |
1382 | di << "\n No. of self-intersecting edges : " << num; |
1383 | |
1384 | for(int i=1; i<=num; ++i) { |
1385 | gp_Pnt pt = points3d(i); |
1386 | di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")"; |
1387 | } |
1388 | |
1389 | } |
1390 | |
857ffd5e |
1391 | Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; |
7fd59977 |
1392 | sfw->Load(TopoDS::Wire(wire)); |
1393 | sfw->SetFace(face); |
1394 | sfw->SetPrecision(Precision::Confusion()); |
1395 | |
1396 | sfw->FixReorderMode() = 1; |
1397 | sfw->ClosedWireMode() = 1; |
1398 | sfw->FixDegeneratedMode() = 1; |
1399 | sfw->FixConnectedMode() = 1; |
1400 | sfw->ModifyTopologyMode() = 1; |
1401 | sfw->ModifyGeometryMode() = 1; |
1402 | sfw->FixSelfIntersectionMode() = 1; |
1403 | sfw->FixSelfIntersectingEdgeMode() = 1; |
1404 | sfw->FixIntersectingEdgesMode() = 1; |
1405 | sfw->FixNonAdjacentIntersectingEdgesMode() = 1; |
1406 | sfw->FixEdgeCurvesMode() = 1; |
1407 | |
1408 | sfw->ModifyRemoveLoopMode() = 1; |
1409 | sfw->SetMaxTolerance(1.0); |
1410 | |
1411 | di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder(); |
1412 | di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated(); |
1413 | di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected(); |
1414 | di << "\n"; |
1415 | di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection(); |
1416 | di << "\n"; |
1417 | |
1418 | Draw::Set(argv[6],sfw->FixReorder()) ; |
1419 | Draw::Set(argv[7],sfw->FixDegenerated()) ; |
1420 | Draw::Set(argv[8],sfw->FixConnected()) ; |
1421 | Draw::Set(argv[9],sfw->FixSelfIntersection()) ; |
1422 | |
1423 | ShapeExtend_Status status = ShapeExtend_OK; |
1424 | if(sfw->StatusSelfIntersection(status)) |
1425 | di << "\n ShapeExtend_OK : No intersection found"; |
1426 | |
1427 | status = ShapeExtend_FAIL1; |
1428 | if(sfw->StatusSelfIntersection(status)) |
1429 | di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)"; |
1430 | |
1431 | status = ShapeExtend_FAIL2; |
1432 | if(sfw->StatusSelfIntersection(status)) |
1433 | di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)"; |
1434 | |
1435 | status = ShapeExtend_FAIL3; |
1436 | if(sfw->StatusSelfIntersection(status)) |
1437 | di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)"; |
1438 | |
1439 | status = ShapeExtend_DONE1; |
1440 | if(sfw->StatusSelfIntersection(status)) |
1441 | di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection"; |
1442 | |
1443 | status = ShapeExtend_DONE2; |
1444 | if(sfw->StatusSelfIntersection(status)) |
1445 | di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection"; |
1446 | |
1447 | status = ShapeExtend_DONE3; |
1448 | if(sfw->StatusSelfIntersection(status)) |
1449 | di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection"; |
1450 | |
1451 | status = ShapeExtend_DONE4; |
1452 | if(sfw->StatusSelfIntersection(status)) |
1453 | di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified"; |
1454 | |
1455 | status = ShapeExtend_DONE5; |
1456 | if(sfw->StatusSelfIntersection(status)) |
1457 | di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)"; |
1458 | |
1459 | status = ShapeExtend_DONE6; |
1460 | if(sfw->StatusSelfIntersection(status)) |
1461 | di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection"; |
1462 | |
1463 | status = ShapeExtend_DONE7; |
1464 | if(sfw->StatusSelfIntersection(status)) |
1465 | di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection"; |
1466 | |
1467 | TopoDS_Wire finalwire = sfw->Wire(); |
1468 | |
1469 | DBRep::Set(argv[1],finalwire); |
1470 | |
1471 | |
1472 | advWA->Load(TopoDS::Wire(finalwire)); |
1473 | |
1474 | TopoDS_Face fface = |
1475 | BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True); |
1476 | |
1477 | DBRep::Set(argv[2],fface); |
1478 | |
1479 | advWA->SetFace(fface); |
1480 | |
1481 | TopTools_IndexedMapOfShape fM; |
1482 | TopExp::MapShapes(finalwire, TopAbs_EDGE, fM); |
1483 | |
1484 | for(j= 1; j<=fM.Extent(); ++j) { |
1485 | Standard_Integer num=1; |
1486 | IntRes2d_SequenceOfIntersectionPoint points2d; |
1487 | TColgp_SequenceOfPnt points3d; |
1488 | |
1489 | di << "\n j =" << j << ", CheckSelfIntersectingEdge = " << |
1490 | (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d); |
1491 | |
1492 | |
51740958 |
1493 | status = ShapeExtend_FAIL1; |
7fd59977 |
1494 | if(advWA->StatusSelfIntersection(status)) |
1495 | |
1496 | status = ShapeExtend_FAIL2; |
1497 | if(advWA->StatusSelfIntersection(status)) |
1498 | di << "\n No Vertices found in the edge"; |
1499 | |
1500 | status = ShapeExtend_DONE1; |
1501 | if(advWA->StatusSelfIntersection(status)) |
1502 | di << "\n Self-intersection found in the edge"; |
1503 | |
1504 | num = points2d.Length(); |
1505 | di << "\n No. of self-intersecting edges : " << num; |
1506 | |
1507 | for(int i=1; i<=num; ++i) { |
1508 | gp_Pnt pt = points3d(i); |
1509 | di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")"; |
1510 | } |
1511 | |
1512 | } |
1513 | |
1514 | di << "\n"; |
1515 | |
1516 | return 0; |
1517 | } |
1518 | |
1cd84fee |
1519 | void QABugs::Commands_17(Draw_Interpretor& theCommands) { |
1365140b |
1520 | const char *group = "QABugs"; |
7fd59977 |
1521 | |
1522 | theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group); |
1523 | theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group); |
1524 | theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group); |
7fd59977 |
1525 | theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group); |
1526 | theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group); |
7fd59977 |
1527 | theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group); |
1528 | theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group); |
7fd59977 |
1529 | theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group); |
7fd59977 |
1530 | theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group); |
1531 | theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group); |
1532 | |
1533 | theCommands.Add("OCC570mkevol", |
1534 | "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol", |
1535 | __FILE__, MKEVOL,group); |
1536 | theCommands.Add("OCC570updatevol", |
1537 | "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol", |
1538 | __FILE__, UPDATEVOL,group); |
1539 | theCommands.Add("OCC570updatevollaw", |
1540 | "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw", |
1541 | __FILE__, UPDATEVOL,group); |
1542 | theCommands.Add("OCC570buildevol", |
1543 | "OCC570buildevol; end of the evol fillet computation", |
1544 | __FILE__, BUILDEVOL,group); |
1545 | |
1546 | theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group); |
1547 | |
1548 | theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group); |
1549 | theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group); |
1550 | theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group); |
7fd59977 |
1551 | |
1552 | theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group); |
1553 | theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group); |
1554 | |
7fd59977 |
1555 | theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group); |
1556 | theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group); |
1557 | |
1558 | theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group); |
1559 | |
1560 | theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group); |
1561 | |
7fd59977 |
1562 | return; |
1563 | } |