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