b311480e |
1 | // Created on: 2002-05-28 |
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. |
b311480e |
15 | |
1cd84fee |
16 | #include <QABugs.hxx> |
7fd59977 |
17 | |
91322f44 |
18 | #include <Draw.hxx> |
7fd59977 |
19 | #include <Draw_Interpretor.hxx> |
20 | #include <DBRep.hxx> |
21 | #include <DrawTrSurf.hxx> |
22 | #include <AIS_InteractiveContext.hxx> |
23 | #include <ViewerTest.hxx> |
24 | #include <AIS_Shape.hxx> |
25 | #include <TopoDS_Shape.hxx> |
26 | |
27 | #include <BRepBuilderAPI_MakePolygon.hxx> |
28 | #include <TopoDS_Face.hxx> |
29 | #include <BRepBuilderAPI_MakeFace.hxx> |
30 | #include <gp_Pnt.hxx> |
31 | #include <gp_Dir.hxx> |
32 | #include <gp_Ax1.hxx> |
33 | #include <BRepPrimAPI_MakeRevol.hxx> |
34 | |
35 | #include <BRepAlgoAPI_Fuse.hxx> |
7fd59977 |
36 | |
37 | #include <GProp_GProps.hxx> |
38 | #include <BRepGProp.hxx> |
39 | #include <TopExp_Explorer.hxx> |
40 | #include <TopoDS.hxx> |
41 | #include <BRepMesh_IncrementalMesh.hxx> |
42 | #include <BRep_Tool.hxx> |
43 | #include <Poly_Triangulation.hxx> |
44 | #include <TopExp.hxx> |
45 | #include <ChFi3d_FilletShape.hxx> |
46 | #include <BRepFilletAPI_MakeFillet.hxx> |
47 | #include <Standard_ErrorHandler.hxx> |
543a9964 |
48 | #include <Geom_TrimmedCurve.hxx> |
49 | #include <Geom_BSplineSurface.hxx> |
7fd59977 |
50 | |
431d0f18 |
51 | #include <ShapeUpgrade_UnifySameDomain.hxx> |
52 | |
7fd59977 |
53 | static Standard_Integer OCC426 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
54 | { |
431d0f18 |
55 | if(argc != 8) { |
56 | di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 shape7\n"; |
7fd59977 |
57 | return 1; |
58 | } |
7fd59977 |
59 | |
60 | BRepBuilderAPI_MakePolygon W1; |
61 | W1.Add(gp_Pnt(10, 0, 0)); |
62 | W1.Add(gp_Pnt(20, 0, 0)); |
63 | W1.Add(gp_Pnt(20, 0, 10)); |
64 | W1.Add(gp_Pnt(10, 0, 10)); |
65 | W1.Add(gp_Pnt(10, 0, 0)); |
66 | |
67 | Standard_Boolean OnlyPlane1 = Standard_False; |
68 | TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), OnlyPlane1); |
69 | |
70 | gp_Pnt P1(0, 0, 0); |
71 | gp_Dir D1(0, 0, 30); |
72 | gp_Ax1 A1(P1,D1); |
c6541a0c |
73 | Standard_Real angle1 = 360 * (M_PI / 180.0); |
7fd59977 |
74 | TopoDS_Shape rs1 = BRepPrimAPI_MakeRevol(F1, A1, angle1); |
75 | |
76 | BRepBuilderAPI_MakePolygon W2; |
77 | Standard_Real f1 = 7.0710678118654752440; |
78 | Standard_Real f2 = 14.1421356237309504880; |
79 | W2.Add(gp_Pnt(f1, f1, 10)); |
80 | W2.Add(gp_Pnt(f2, f2, 10)); |
81 | W2.Add(gp_Pnt(f2, f2, 20)); |
82 | W2.Add(gp_Pnt(f1, f1, 20)); |
83 | W2.Add(gp_Pnt(f1, f1, 10)); |
84 | |
85 | Standard_Boolean OnlyPlane2 = Standard_False; |
86 | TopoDS_Face F2 = BRepBuilderAPI_MakeFace(W2.Wire(), OnlyPlane2); |
87 | |
88 | gp_Pnt P2(0, 0, 0); |
89 | gp_Dir D2(0, 0, 30); |
90 | gp_Ax1 A2(P2,D2); |
c6541a0c |
91 | Standard_Real angle2 = 270 * (M_PI / 180.0); |
7fd59977 |
92 | TopoDS_Shape rs2 = BRepPrimAPI_MakeRevol(F2, A2, angle2); |
93 | |
94 | BRepBuilderAPI_MakePolygon W3; |
95 | W3.Add(gp_Pnt(10, 0, 20)); |
96 | W3.Add(gp_Pnt(20, 0, 20)); |
97 | W3.Add(gp_Pnt(20, 0, 30)); |
98 | W3.Add(gp_Pnt(10, 0, 30)); |
99 | W3.Add(gp_Pnt(10, 0, 20)); |
100 | |
101 | Standard_Boolean OnlyPlane3 = Standard_False; |
102 | TopoDS_Face F3 = BRepBuilderAPI_MakeFace(W3.Wire(), OnlyPlane3); |
103 | |
104 | gp_Pnt P3(0, 0, 0); |
105 | gp_Dir D3(0, 0, 30); |
106 | gp_Ax1 A3(P3,D3); |
c6541a0c |
107 | Standard_Real angle3 = 360 * (M_PI / 180.0); |
7fd59977 |
108 | TopoDS_Shape rs3 = BRepPrimAPI_MakeRevol(F3, A3, angle3); |
109 | |
431d0f18 |
110 | di << "fuse32 = BRepAlgoAPI_Fuse(rs3, rs2)\n"; |
111 | di << "fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1)\n"; |
112 | TopoDS_Shape fuse32 = BRepAlgoAPI_Fuse(rs3, rs2).Shape(); |
113 | TopoDS_Shape fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1).Shape(); |
114 | |
115 | // unify the faces of the Fuse result |
116 | ShapeUpgrade_UnifySameDomain anUnify(fuse321, Standard_True, Standard_True, Standard_True); |
117 | anUnify.Build(); |
118 | const TopoDS_Shape& aFuseUnif = anUnify.Shape(); |
7fd59977 |
119 | |
431d0f18 |
120 | //Give the mass claculation of the shpae "aFuseUnif" |
7fd59977 |
121 | GProp_GProps G; |
431d0f18 |
122 | BRepGProp::VolumeProperties(aFuseUnif, G); |
586db386 |
123 | di<<" \n"; |
124 | di<<"Mass: "<<G.Mass()<<"\n\n"; |
7fd59977 |
125 | |
586db386 |
126 | di << "Trianglating Faces .....\n"; |
7fd59977 |
127 | TopExp_Explorer ExpFace; |
128 | |
431d0f18 |
129 | for (ExpFace.Init (aFuseUnif,TopAbs_FACE); ExpFace.More(); ExpFace.Next()) |
7fd59977 |
130 | { |
131 | TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current()); |
132 | TopologicalFace.Orientation (TopAbs_FORWARD) ; |
133 | BRepMesh_IncrementalMesh IM(TopologicalFace, 1); |
134 | TopLoc_Location loc; |
135 | Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(TopologicalFace, loc); |
136 | if (facing.IsNull()) |
d3f26155 |
137 | { |
586db386 |
138 | di << "Triangulation FAILED for this face\n"; |
d3f26155 |
139 | continue; |
140 | } |
7fd59977 |
141 | di << "No of Triangles = " << facing->NbTriangles() << "\n"; |
142 | } |
586db386 |
143 | di<<"Triangulation of all Faces Completed. \n\n"; |
7fd59977 |
144 | |
145 | TopTools_IndexedDataMapOfShapeListOfShape edgemap; |
431d0f18 |
146 | TopExp::MapShapesAndAncestors(aFuseUnif, TopAbs_EDGE, TopAbs_SOLID, edgemap); |
7fd59977 |
147 | di << "No. of Edges: " << edgemap.Extent() << "\n"; |
148 | ChFi3d_FilletShape FShape = ChFi3d_Rational; |
431d0f18 |
149 | BRepFilletAPI_MakeFillet blend(aFuseUnif,FShape); |
586db386 |
150 | di << "Adding Edges ..... \n"; |
7fd59977 |
151 | for(int i = 1; i <= edgemap.Extent(); i++) |
152 | { |
153 | // cout << "Adding Edge : " << i << endl; |
154 | TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) ); |
155 | if(!edg.IsNull()) blend.Add(1, edg); |
156 | } |
586db386 |
157 | di << "All Edges added ! Now Building the Blend ... \n"; |
158 | di<<" \n"; |
7fd59977 |
159 | blend.Build(); |
160 | |
161 | //DBRep::Set ( argv[1], fuse321 ); |
162 | DBRep::Set ( argv[1], blend ); |
163 | DBRep::Set ( argv[2], rs1 ); |
164 | DBRep::Set ( argv[3], rs2 ); |
165 | DBRep::Set ( argv[4], rs3 ); |
166 | DBRep::Set ( argv[5], fuse32 ); |
167 | DBRep::Set ( argv[6], fuse321 ); |
431d0f18 |
168 | DBRep::Set ( argv[7], aFuseUnif ); |
7fd59977 |
169 | |
170 | return 0; |
171 | } |
172 | |
173 | #include <Geom_SurfaceOfRevolution.hxx> |
174 | //======================================================================= |
175 | //function : isPeriodic |
176 | //purpose : |
177 | //======================================================================= |
178 | static Standard_Integer isPeriodic(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
179 | { |
180 | try |
181 | { |
182 | OCC_CATCH_SIGNALS |
183 | // 1. Verify amount of arguments of the command |
184 | if (argc < 2) { di << "isperiodic FAULTY. Use : isperiodic surfaceOfRevolution"; return 0;} |
185 | // 2. Retrieve surface |
186 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]); |
187 | if(aSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface"; return 0;} |
188 | Handle(Geom_SurfaceOfRevolution) aRevolSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf); |
189 | if(aRevolSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface of revolution"; return 0;} |
190 | // 3. Verify whether entry surface is u-periodic and v-periodic |
191 | if(aRevolSurf->IsUPeriodic()) {di << "Surface is u-periodic \n";} else {di << "Surface is not u-periodic \n";} |
192 | if(aRevolSurf->IsVPeriodic()) {di << "Surface is v-periodic \n";} else {di << "Surface is not v-periodic \n";} |
193 | } |
194 | catch (Standard_Failure) {di << "isperiodic Exception \n" ;return 0;} |
195 | |
196 | return 0; |
197 | } |
198 | |
199 | #include <Precision.hxx> |
200 | #include <Extrema_ExtPS.hxx> |
201 | #include <GeomAdaptor_Surface.hxx> |
202 | //======================================================================= |
203 | //function : OCC486 |
204 | //purpose : |
205 | //======================================================================= |
206 | static Standard_Integer OCC486(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
207 | { |
208 | try |
209 | { |
210 | OCC_CATCH_SIGNALS |
211 | if (argc < 2) { di << "OCC486 FAULTY. Use : OCC486 surf x y z du dv"; return 1;} |
212 | |
213 | Standard_Real du = 0; |
214 | Standard_Real dv = 0; |
215 | |
216 | Handle(Geom_Surface) GS; |
217 | GS = DrawTrSurf::GetSurface(argv[1]); |
218 | if (GS.IsNull()) { di << "OCC486 FAULTY. Null surface /n";return 1;} |
91322f44 |
219 | gp_Pnt P3D( Draw::Atof(argv[2]),Draw::Atof(argv[3]),Draw::Atof(argv[4]) ); |
7fd59977 |
220 | |
221 | Standard_Real Tol = Precision::PConfusion(); |
222 | Extrema_ExtPS myExtPS; |
91322f44 |
223 | if (argc > 5) du = Draw::Atof(argv[5]); |
224 | if (argc > 6) dv = Draw::Atof(argv[6]); |
7fd59977 |
225 | |
226 | Standard_Real uf, ul, vf, vl; |
227 | GS->Bounds(uf, ul, vf, vl); |
228 | |
229 | GeomAdaptor_Surface aSurf(GS); |
230 | myExtPS.Initialize (aSurf, uf-du, ul+du, vf-dv, vl+dv, Tol, Tol ); |
231 | myExtPS.Perform ( P3D ); |
232 | Standard_Integer nPSurf = ( myExtPS.IsDone() ? myExtPS.NbExt() : 0 ); |
233 | |
234 | if ( nPSurf > 0 ) |
d3f26155 |
235 | { |
236 | //Standard_Real distMin = myExtPS.Value ( 1 ); |
237 | Standard_Real distMin = myExtPS.SquareDistance ( 1 ); |
238 | Standard_Integer indMin=1; |
239 | for (Standard_Integer sol = 2; sol <= nPSurf ; sol++) |
240 | { |
241 | //Standard_Real dist = myExtPS.Value(sol); |
242 | Standard_Real dist = myExtPS.SquareDistance(sol); |
243 | if ( distMin > dist ) |
244 | { |
245 | distMin = dist; |
246 | indMin = sol; |
247 | } |
248 | } |
249 | distMin = sqrt(distMin); |
250 | Standard_Real S, T; |
251 | myExtPS.Point(indMin).Parameter ( S, T ); |
252 | gp_Pnt aCheckPnt = aSurf.Value( S, T ); |
253 | Standard_Real aCheckDist = P3D.Distance(aCheckPnt); |
254 | di << "Solution is : U = "<< S << "\t V = "<< T << "\n"; |
255 | di << "Solution is : X = "<< aCheckPnt.X() << "\t Y = "<< aCheckPnt.Y() << "\t Z = "<< aCheckPnt.Z() << "\n"; |
256 | di << "ExtremaDistance = " << distMin << "\n"; |
257 | di << "CheckDistance = " << aCheckDist << "\n"; |
258 | |
259 | if(fabs(distMin - aCheckDist) < Precision::Confusion()) return 0; |
260 | else return 1; |
261 | } |
7fd59977 |
262 | else return 1; |
263 | } |
264 | catch (Standard_Failure) {di << "OCC486 Exception \n" ;return 1;} |
7fd59977 |
265 | } |
266 | |
267 | #include <GC_MakeArcOfCircle.hxx> |
268 | #include <BRepBuilderAPI_MakeEdge.hxx> |
269 | #include <BRepBuilderAPI_MakeWire.hxx> |
270 | #include <TopoDS_Wire.hxx> |
271 | #include <BRepBuilderAPI_MakeFace.hxx> |
272 | #include <Geom_Plane.hxx> |
273 | #include <gp_Pln.hxx> |
274 | #include <BRepPrimAPI_MakePrism.hxx> |
275 | #include <BRepOffsetAPI_DraftAngle.hxx> |
276 | //======================================================================= |
277 | //function : OCC712 |
278 | //purpose : |
279 | //======================================================================= |
280 | static Standard_Integer OCC712 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { |
281 | if (argc != 3) { |
586db386 |
282 | di << "Usage : " << argv[0] << " draftAngle slabThick\n"; |
7fd59977 |
283 | return 1; |
284 | } |
285 | //NOTE: Case:1 - draftAngle = 15, slabThick = 30 --> Fails |
286 | // Case:2 draftAngle = 10, slabThick = 30 --> Ok |
287 | // Case:3 draftAngle = 10, slabThick = 40 --> Ok |
288 | // |
289 | // -------------------------------------------------- |
91322f44 |
290 | Standard_Real draftAngle = Draw::Atof(argv[1]); |
291 | Standard_Real slabThick = Draw::Atof(argv[2]); |
7fd59977 |
292 | |
293 | Standard_Real f1 = 75; |
294 | Standard_Real f2 = 35; |
295 | |
296 | gp_Pnt p1(-f2, f2, 0); |
297 | gp_Pnt p2( 0, f1, 0); |
298 | gp_Pnt p3( f2, f2, 0); |
299 | gp_Pnt p4( f1, 0, 0); |
300 | gp_Pnt p5( f2, -f2, 0); |
301 | gp_Pnt p6( 0, -f1, 0); |
302 | gp_Pnt p7(-f2, -f2, 0); |
303 | gp_Pnt p8(-f1, 0, 0); |
304 | |
305 | GC_MakeArcOfCircle arc1(p1, p2, p3); |
306 | GC_MakeArcOfCircle arc2(p3, p4, p5); |
307 | GC_MakeArcOfCircle arc3(p5, p6, p7); |
308 | GC_MakeArcOfCircle arc4(p7, p8, p1); |
309 | |
310 | TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value()); |
311 | TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value()); |
312 | TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value()); |
313 | TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(arc4.Value()); |
314 | |
315 | BRepBuilderAPI_MakeWire MW; |
316 | MW.Add(e1); |
317 | MW.Add(e2); |
318 | MW.Add(e3); |
319 | MW.Add(e4); |
320 | |
321 | if (!MW.IsDone()) |
322 | { |
586db386 |
323 | di << "my Wire not done\n"; |
7fd59977 |
324 | return 1; |
325 | } |
326 | TopoDS_Wire W = MW.Wire(); |
327 | |
328 | TopoDS_Face F = BRepBuilderAPI_MakeFace(W); |
329 | if ( F.IsNull()) |
330 | { |
586db386 |
331 | di << " Error in Face creation \n"; |
7fd59977 |
332 | return 1; |
333 | } |
334 | |
335 | Handle(Geom_Surface) surf = BRep_Tool::Surface(F); |
336 | Handle (Geom_Plane) P = Handle(Geom_Plane)::DownCast(surf); |
337 | gp_Pln slabPln = P->Pln(); |
338 | |
339 | try |
340 | { |
341 | OCC_CATCH_SIGNALS |
342 | gp_Dir slabDir(0, 0, 1); |
343 | gp_Vec slabVect(slabDir); |
344 | slabVect *= slabThick; |
345 | |
346 | BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True); |
347 | if ( ! slab.IsDone() ) |
348 | { |
586db386 |
349 | di << " Error in Slab creation \n"; |
7fd59977 |
350 | return 1; |
351 | } |
352 | |
353 | TopoDS_Shape slabShape = slab.Shape(); |
354 | if (fabs(draftAngle) > 0.01) |
355 | { |
c6541a0c |
356 | Standard_Real angle = draftAngle*(M_PI / 180.0); |
7fd59977 |
357 | BRepOffsetAPI_DraftAngle draftSlab(slabShape); |
358 | |
359 | TopoDS_Shape fShape = slab.FirstShape(); |
360 | TopoDS_Shape lShape = slab.LastShape(); |
361 | |
362 | TopExp_Explorer ex; |
363 | for(ex.Init(slabShape, TopAbs_FACE); ex.More(); ex.Next()) |
364 | { |
365 | TopoDS_Face aFace = TopoDS::Face(ex.Current()); |
366 | if(aFace.IsSame(fShape) || aFace.IsSame(lShape)) continue; |
367 | draftSlab.Add(aFace, slabDir, angle, slabPln); |
368 | if (!draftSlab.AddDone()) |
369 | { |
586db386 |
370 | di << " Error in Add \n"; |
7fd59977 |
371 | return 1; |
372 | } |
373 | } |
374 | |
586db386 |
375 | di << "All Faces added. Building... \n"; //cout.flush(); |
7fd59977 |
376 | draftSlab.Build(); |
586db386 |
377 | di << "Build done...\n"; //cout.flush(); |
7fd59977 |
378 | if (!draftSlab.IsDone()) //--------------> STEP:1 |
379 | { |
586db386 |
380 | di << " Error in Build \n"; |
7fd59977 |
381 | return 1; |
382 | } |
383 | slabShape = draftSlab.Shape(); |
384 | DBRep::Set(argv[1], slabShape); |
385 | } |
386 | } |
387 | catch ( Standard_Failure ) //--------------------> STEP:2 |
388 | { |
586db386 |
389 | di << " Error in Draft Slab \n"; |
7fd59977 |
390 | return 1; |
391 | } |
392 | return 0; |
393 | } |
394 | |
395 | //======================================================================= |
396 | // performTriangulation |
397 | //======================================================================= |
398 | |
399 | Standard_Integer performTriangulation (TopoDS_Shape aShape, Draw_Interpretor& di) |
400 | { |
401 | int failed=0, total=0; |
402 | TopExp_Explorer ExpFace; |
403 | Handle(Poly_Triangulation) facing; |
404 | |
405 | for (ExpFace.Init(aShape,TopAbs_FACE); ExpFace.More(); ExpFace.Next()) |
406 | { |
407 | total++; |
408 | TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current()); |
409 | TopologicalFace.Orientation (TopAbs_FORWARD) ; |
410 | BRepMesh_IncrementalMesh IM(TopologicalFace, 1); |
411 | TopLoc_Location loc; |
412 | facing = BRep_Tool::Triangulation(TopologicalFace, loc); |
413 | di << "Face " << total << " - "; |
414 | if (facing.IsNull()) |
415 | { |
416 | failed++; |
586db386 |
417 | di << "******************** FAILED during Triangulation \n"; |
7fd59977 |
418 | } |
419 | else |
420 | { |
586db386 |
421 | di << facing->NbTriangles() << " Triangles\n"; |
7fd59977 |
422 | } |
423 | } |
586db386 |
424 | di<<"Triangulation of all Faces Completed: \n\n"; |
7fd59977 |
425 | if (failed == 0) return 1; |
586db386 |
426 | di<<"***************************************************\n"; |
427 | di<<"******* ********\n"; |
428 | di<<"***** Triangulation FAILED for " << failed << " of " << total << " Faces ******\n"; |
429 | di<<"******* ********\n"; |
430 | di<<"***************************************************\n"; |
7fd59977 |
431 | return 0; |
432 | } |
433 | |
434 | #include <BRepPrimAPI_MakeCylinder.hxx> |
435 | #include <BRepPrimAPI_MakeCone.hxx> |
436 | #include <BRepAlgoAPI_Cut.hxx> |
7fd59977 |
437 | //======================================================================= |
438 | //function : OCC822_1 |
439 | //purpose : |
440 | //======================================================================= |
441 | static Standard_Integer OCC822_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { |
442 | |
431d0f18 |
443 | if(argc != 4) { |
444 | di << "Usage : " << argv[0] << " name1 name2 result\n"; |
7fd59977 |
445 | return 1; |
446 | } |
7fd59977 |
447 | |
448 | int index = 1; |
449 | |
450 | gp_Pnt P1(0, 0, 0); |
451 | gp_Dir D1(0, 0, 1); |
452 | gp_Ax2 A1(P1,D1); |
453 | |
454 | BRepPrimAPI_MakeCylinder cylMakerIn(A1, 40, 110); |
455 | BRepPrimAPI_MakeCylinder cylMakerOut(A1, 50, 100); |
456 | TopoDS_Shape cylIn = cylMakerIn.Shape(); |
457 | TopoDS_Shape cylOut = cylMakerOut.Shape(); |
458 | |
459 | gp_Pnt P2(0, 0, 0); |
460 | gp_Dir D2(0, 0, -1); |
461 | gp_Ax2 A2(P2,D2); |
462 | |
463 | BRepPrimAPI_MakeCone conMakerIn(A2, 40, 60, 110); |
464 | BRepPrimAPI_MakeCone conMakerOut(A2, 50, 70, 100); |
465 | TopoDS_Shape conIn = conMakerIn.Shape(); |
466 | TopoDS_Shape conOut = conMakerOut.Shape(); |
467 | |
586db386 |
468 | di << "All primitives created..... Creating Boolean\n"; |
7fd59977 |
469 | |
7fd59977 |
470 | try |
431d0f18 |
471 | { |
7fd59977 |
472 | OCC_CATCH_SIGNALS |
7fd59977 |
473 | |
431d0f18 |
474 | di << "theIn = BRepAlgoAPI_Fuse(cylIn, conIn)\n"; |
475 | di << "theOut = BRepAlgoAPI_Fuse(cylOut, conOut)\n"; |
476 | di << "theRes = BRepAlgoAPI_Cut(theOut, theIn)\n"; |
477 | TopoDS_Shape theIn = BRepAlgoAPI_Fuse(cylIn, conIn).Shape(); |
478 | TopoDS_Shape theOut = BRepAlgoAPI_Fuse(cylOut, conOut).Shape(); |
479 | TopoDS_Shape theRes = BRepAlgoAPI_Cut(theOut, theIn).Shape(); |
7fd59977 |
480 | |
431d0f18 |
481 | if (index < argc) DBRep::Set(argv[index++], theIn); |
482 | if (index < argc) DBRep::Set(argv[index++], theOut); |
483 | if (index < argc) DBRep::Set(argv[index++], theRes); |
484 | di << "Booleans Created ! Triangulating !\n"; |
485 | |
486 | performTriangulation(theRes, di); |
487 | } |
7fd59977 |
488 | catch ( Standard_Failure ) |
431d0f18 |
489 | { |
490 | di << "*********************************************************\n"; |
491 | di << "***** ******\n"; |
492 | di << "***** Standard_Failure : Exception in Shoe Function *****\n"; |
493 | di << "***** ******\n"; |
494 | di << "*********************************************************\n"; |
495 | return 1; |
496 | } |
7fd59977 |
497 | return 0; |
498 | |
499 | } |
500 | |
501 | #include <BRepPrimAPI_MakeBox.hxx> |
502 | #include <BRepPrimAPI_MakeSphere.hxx> |
431d0f18 |
503 | |
7fd59977 |
504 | //======================================================================= |
505 | // OCC822_2 |
506 | //======================================================================= |
507 | |
508 | static Standard_Integer OCC822_2 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
509 | { |
431d0f18 |
510 | if(argc != 4) { |
511 | di << "Usage : " << argv[0] << " name1 name2 result\n"; |
7fd59977 |
512 | return 1; |
513 | } |
7fd59977 |
514 | |
515 | int index = 1; |
516 | |
517 | gp_Dir xDir(1, 0, 0); |
518 | gp_Dir zDir(0, 0, 1); |
519 | gp_Pnt cen1(0, 0, 0); |
520 | gp_Ax2 cor1(cen1, zDir, xDir); |
521 | BRepPrimAPI_MakeBox boxMaker(cor1, 100, 100, 100); |
522 | TopoDS_Shape box = boxMaker.Shape(); |
523 | if (index < argc) DBRep::Set(argv[index++], box); |
524 | |
525 | BRepPrimAPI_MakeSphere sphereMaker(gp_Pnt(100.0, 50.0, 50.0), 25.0); |
526 | TopoDS_Shape sph = sphereMaker.Shape(); |
527 | if (index < argc) DBRep::Set(argv[index++], sph); |
528 | |
586db386 |
529 | di << "All primitives created..... Creating Cut Objects\n"; |
7fd59977 |
530 | |
7fd59977 |
531 | try |
431d0f18 |
532 | { |
7fd59977 |
533 | OCC_CATCH_SIGNALS |
7fd59977 |
534 | |
431d0f18 |
535 | di << "fuse = BRepAlgoAPI_Fuse(box, sph)\n"; |
536 | TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box, sph).Shape(); |
537 | |
538 | if (index < argc) DBRep::Set(argv[index++], fuse); |
539 | di << "Object Created ! Now Triangulating !"; |
540 | |
541 | performTriangulation(fuse, di); |
542 | } |
7fd59977 |
543 | catch ( Standard_Failure ) |
431d0f18 |
544 | { |
545 | di << "*********************************************************\n"; |
546 | di << "***** ******\n"; |
547 | di << "***** Standard_Failure : Exception in HSP Function ******\n"; |
548 | di << "***** ******\n"; |
549 | di << "*********************************************************\n"; |
550 | return 1; |
551 | } |
7fd59977 |
552 | |
553 | return 0; |
554 | } |
555 | |
556 | //======================================================================= |
557 | // OCC823 |
558 | //======================================================================= |
559 | |
560 | static Standard_Integer OCC823 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
561 | { |
431d0f18 |
562 | if(argc != 4) { |
563 | di << "Usage : " << argv[0] << " name1 name2 result\n"; |
7fd59977 |
564 | return 1; |
565 | } |
431d0f18 |
566 | |
7fd59977 |
567 | int index = 1; |
568 | Standard_Real size = 0.001; |
569 | |
570 | gp_Pnt P1(40, 50, 0); |
571 | gp_Dir D1(100, 0, 0); |
572 | gp_Ax2 A1(P1,D1); |
573 | BRepPrimAPI_MakeCylinder mkCyl1(A1, 20, 100); |
574 | TopoDS_Shape cyl1 = mkCyl1.Shape(); |
575 | if (index < argc) DBRep::Set(argv[index++], cyl1); |
576 | |
577 | gp_Pnt P2(100, 50, size); |
578 | gp_Dir D2(0, size, 80); |
579 | gp_Ax2 A2(P2,D2); |
580 | BRepPrimAPI_MakeCylinder mkCyl2(A2, 20, 80); |
581 | TopoDS_Shape cyl2 = mkCyl2.Shape(); |
582 | if (index < argc) DBRep::Set(argv[index++], cyl2); |
583 | |
586db386 |
584 | di << "All primitives created..... Creating Boolean\n"; |
7fd59977 |
585 | |
7fd59977 |
586 | try |
431d0f18 |
587 | { |
7fd59977 |
588 | OCC_CATCH_SIGNALS |
7fd59977 |
589 | |
431d0f18 |
590 | di << "fuse = BRepAlgoAPI_Fuse(cyl2, cyl1)\n"; |
591 | TopoDS_Shape fuse = BRepAlgoAPI_Fuse(cyl2, cyl1).Shape(); |
592 | |
593 | if (index < argc) DBRep::Set(argv[index++], fuse); |
594 | di << "Fuse Created ! Triangulating !\n"; |
595 | |
596 | performTriangulation(fuse, di); |
597 | } |
598 | catch (Standard_Failure) |
599 | { |
600 | di << "*********************************************************\n"; |
601 | di << "***** ******\n"; |
602 | di << "***** Standard_Failure : Exception in TEE Function ******\n"; |
603 | di << "***** ******\n"; |
604 | di << "*********************************************************\n"; |
605 | return 1; |
606 | } |
7fd59977 |
607 | return 0; |
608 | } |
609 | |
610 | //======================================================================= |
611 | // OCC824 |
612 | //======================================================================= |
613 | |
614 | static Standard_Integer OCC824 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
615 | { |
431d0f18 |
616 | if(argc != 4) { |
617 | di << "Usage : " << argv[0] << " name1 name2 result\n"; |
7fd59977 |
618 | return 1; |
619 | } |
431d0f18 |
620 | |
7fd59977 |
621 | int index = 1; |
622 | |
623 | gp_Pnt P1(100, 0, 0); |
624 | gp_Dir D1(-1, 0, 0); |
625 | gp_Ax2 A1(P1,D1); |
626 | BRepPrimAPI_MakeCylinder mkCyl(A1, 20, 100); |
627 | TopoDS_Shape cyl = mkCyl.Shape(); |
628 | if (index < argc) DBRep::Set(argv[index++], cyl); |
629 | |
630 | BRepPrimAPI_MakeSphere sphere(P1, 20.0); |
631 | TopoDS_Shape sph = sphere.Shape(); |
632 | if (index < argc) DBRep::Set(argv[index++], sph); |
633 | |
586db386 |
634 | di << "All primitives created..... Creating Boolean\n"; |
7fd59977 |
635 | |
7fd59977 |
636 | try |
431d0f18 |
637 | { |
7fd59977 |
638 | OCC_CATCH_SIGNALS |
7fd59977 |
639 | |
431d0f18 |
640 | di << "fuse = BRepAlgoAPI_Fuse(cyl, sph)\n"; |
641 | TopoDS_Shape fuse = BRepAlgoAPI_Fuse(cyl, sph).Shape(); |
642 | |
643 | di << "Fuse Created ! Triangulating !\n"; |
644 | if (index < argc) DBRep::Set(argv[index++], fuse); |
645 | |
646 | performTriangulation(fuse, di); |
647 | } |
648 | catch (Standard_Failure) |
649 | { |
650 | di << "*********************************************************\n"; |
651 | di << "***** ******\n"; |
652 | di << "***** Standard_Failure : Exception in YOU Function ******\n"; |
653 | di << "***** ******\n"; |
654 | di << "*********************************************************\n"; |
655 | return 1; |
656 | } |
7fd59977 |
657 | return 0; |
658 | } |
659 | |
660 | #include <TColgp_Array2OfPnt.hxx> |
661 | #include <GeomConvert.hxx> |
662 | #include <Geom_BezierSurface.hxx> |
663 | #include <BRepPrimAPI_MakeHalfSpace.hxx> |
664 | |
665 | //======================================================================= |
666 | // OCC825 |
667 | //======================================================================= |
668 | |
669 | static Standard_Integer OCC825 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
670 | { |
431d0f18 |
671 | if(argc != 6) { |
672 | di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2\n"; |
7fd59977 |
673 | return 1; |
674 | } |
431d0f18 |
675 | |
7fd59977 |
676 | int index = 1; |
677 | |
678 | Standard_Real size = 50; |
679 | TColgp_Array2OfPnt poles(1, 2, 1, 2); |
680 | |
681 | poles(1, 1).SetCoord(-size, 0, -size); |
682 | poles(1, 2).SetCoord(-size, 0, size); |
683 | poles(2, 1).SetCoord( size, 0, -size); |
684 | poles(2, 2).SetCoord( size, 0, size); |
685 | |
686 | Handle(Geom_BezierSurface) BezSurf = new Geom_BezierSurface(poles); |
687 | Handle(Geom_BSplineSurface) BSpSurf = GeomConvert::SurfaceToBSplineSurface(BezSurf); |
1c72dff6 |
688 | BRepBuilderAPI_MakeFace faceMaker(BSpSurf, Precision::Confusion()); |
7fd59977 |
689 | TopoDS_Face face = faceMaker.Face(); |
690 | |
691 | gp_Pnt pnt(0, size, 0); |
692 | BRepPrimAPI_MakeHalfSpace *hSpace = new BRepPrimAPI_MakeHalfSpace(face,pnt); |
693 | TopoDS_Shape hsp = hSpace->Solid(); |
694 | if (index < argc) DBRep::Set(argv[index++], hsp); |
695 | |
696 | BRepPrimAPI_MakeSphere sphere1(gp_Pnt(0.0, 0.0, 0.0), 25.0); |
697 | TopoDS_Shape sph1 = sphere1.Shape(); |
698 | if (index < argc) DBRep::Set(argv[index++], sph1); |
699 | |
700 | BRepPrimAPI_MakeSphere sphere2(gp_Pnt(0.0, 0.00001, 0.0), 25.0); |
701 | TopoDS_Shape sph2 = sphere2.Shape(); |
702 | if (index < argc) DBRep::Set(argv[index++], sph2); |
703 | |
586db386 |
704 | di << "All primitives created..... Creating Cut Objects\n"; |
7fd59977 |
705 | |
7fd59977 |
706 | try |
431d0f18 |
707 | { |
7fd59977 |
708 | OCC_CATCH_SIGNALS |
7fd59977 |
709 | |
431d0f18 |
710 | di << "cut1 = BRepAlgoAPI_Cut(sph1, hsp)\n"; |
711 | TopoDS_Shape cut1 = BRepAlgoAPI_Cut(sph1, hsp).Shape(); |
7fd59977 |
712 | |
431d0f18 |
713 | if (index < argc) DBRep::Set(argv[index++], cut1); |
714 | di << "CUT 1 Created ! " ; |
7fd59977 |
715 | |
7fd59977 |
716 | |
431d0f18 |
717 | di << "cut2 = BRepAlgoAPI_Cut(sph2, hsp)\n"; |
718 | TopoDS_Shape cut2 = BRepAlgoAPI_Cut(sph2, hsp).Shape(); |
719 | |
720 | if (index < argc) DBRep::Set(argv[index++], cut2); |
721 | di << "CUT 2 Created !\n\n"; |
722 | |
723 | GProp_GProps G; |
724 | BRepGProp::VolumeProperties(cut1, G); |
725 | di << "CUT 1 Mass = " << G.Mass() << "\n\n"; |
726 | BRepGProp::VolumeProperties(cut2, G); |
727 | di << "CUT 2 Mass = " << G.Mass() << "\n\n"; |
728 | |
729 | di << "Trianglating Faces of CUT 1 .....\n"; |
730 | performTriangulation(cut1, di); |
731 | |
732 | di << "Trianglating Faces of CUT 2 .....\n"; |
733 | performTriangulation(cut2, di); |
734 | } |
735 | catch (Standard_Failure) |
736 | { |
737 | di << "*********************************************************\n"; |
738 | di << "***** ******\n"; |
739 | di << "***** Standard_Failure : Exception in HSP Function ******\n"; |
740 | di << "***** ******\n"; |
741 | di << "*********************************************************\n"; |
742 | return 1; |
743 | } |
744 | |
745 | di << "*************************************************************\n"; |
746 | di << " CUT 1 and CUT 2 gives entirely different results during\n"; |
747 | di << " mass computation and face triangulation, eventhough the\n"; |
748 | di << " two spheres are located more or less at the same position.\n"; |
749 | di << "*************************************************************\n"; |
7fd59977 |
750 | |
751 | return 0; |
752 | } |
753 | |
754 | //======================================================================= |
755 | // OCC826 |
756 | //======================================================================= |
757 | |
758 | static Standard_Integer OCC826 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
759 | { |
431d0f18 |
760 | if(argc != 4) { |
761 | di << "Usage : " << argv[0] << " name1 name2 result\n"; |
7fd59977 |
762 | return 1; |
763 | } |
431d0f18 |
764 | |
7fd59977 |
765 | int index = 1; |
766 | |
767 | Standard_Real x1 = 181.82808; |
768 | Standard_Real x2 = 202.39390; |
769 | Standard_Real y1 = 31.011970; |
770 | Standard_Real y2 = 123.06856; |
771 | |
772 | BRepBuilderAPI_MakePolygon W1; |
773 | W1.Add(gp_Pnt(x1, y1, 0)); |
774 | W1.Add(gp_Pnt(x2, y1, 0)); |
775 | W1.Add(gp_Pnt(x2, y2, 0)); |
776 | W1.Add(gp_Pnt(x1, y2, 0)); |
777 | W1.Add(gp_Pnt(x1, y1, 0)); |
778 | |
779 | Standard_Boolean myFalse = Standard_False; |
780 | TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse); |
781 | |
782 | gp_Pnt P1(0, 0, 0); |
783 | gp_Dir D1(0, 30, 0); |
784 | gp_Ax1 A1(P1,D1); |
c6541a0c |
785 | Standard_Real angle1 = 360 * (M_PI / 180.0); |
7fd59977 |
786 | TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1); |
787 | if (index < argc) DBRep::Set(argv[index++], rev); |
788 | |
789 | BRepPrimAPI_MakeSphere sphere(gp_Pnt(166.373, 77.0402, 96.0555), 23.218586); |
790 | TopoDS_Shape sph = sphere.Shape(); |
791 | if (index < argc) DBRep::Set(argv[index++], sph); |
792 | |
586db386 |
793 | di << "All primitives created..... Creating Boolean\n"; |
7fd59977 |
794 | |
7fd59977 |
795 | try |
431d0f18 |
796 | { |
7fd59977 |
797 | OCC_CATCH_SIGNALS |
431d0f18 |
798 | |
799 | di << "fuse = BRepAlgoAPI_Fuse(rev, sph)\n"; |
800 | TopoDS_Shape fuse = BRepAlgoAPI_Fuse(rev, sph).Shape(); |
801 | |
802 | if (index < argc) DBRep::Set(argv[index++], fuse); |
803 | di << "Fuse Created ! Triangulating !\n"; |
804 | performTriangulation(fuse, di); |
805 | } |
806 | catch (Standard_Failure) |
807 | { |
808 | di << "*********************************************************\n"; |
809 | di << "***** ******\n"; |
810 | di << "***** Standard_Failure : Exception in SPH Function ******\n"; |
811 | di << "***** ******\n"; |
812 | di << "*********************************************************\n"; |
813 | return 1; |
814 | } |
7fd59977 |
815 | return 0; |
816 | } |
817 | |
818 | #include <BRepPrimAPI_MakeTorus.hxx> |
819 | //======================================================================= |
820 | // OCC827 |
821 | //======================================================================= |
822 | |
823 | static Standard_Integer OCC827 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
824 | { |
431d0f18 |
825 | if(argc != 6) { |
826 | di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2\n"; |
7fd59977 |
827 | return 1; |
828 | } |
431d0f18 |
829 | |
7fd59977 |
830 | int index = 1; |
831 | |
832 | BRepBuilderAPI_MakePolygon W1; |
833 | W1.Add(gp_Pnt(10, 0, 0)); |
834 | W1.Add(gp_Pnt(20, 0, 0)); |
835 | W1.Add(gp_Pnt(20, 0, 50)); |
836 | W1.Add(gp_Pnt(10, 0, 50)); |
837 | W1.Add(gp_Pnt(10, 0, 0)); |
838 | |
839 | Standard_Boolean myFalse = Standard_False; |
840 | TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse); |
841 | |
842 | gp_Pnt P1(0, 0, 0); |
843 | gp_Dir D1(0, 0, 30); |
844 | gp_Ax1 A1(P1,D1); |
c6541a0c |
845 | Standard_Real angle1 = 360 * (M_PI / 180.0); |
7fd59977 |
846 | TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1); |
847 | if (index < argc) DBRep::Set(argv[index++], rev); |
848 | |
849 | gp_Pnt P2(0, 0, 50); |
850 | gp_Dir D2(0, 0, 30); |
851 | gp_Ax2 A2(P2,D2); |
852 | Standard_Real majRad = 15; |
853 | Standard_Real minRad = 5; |
854 | BRepPrimAPI_MakeTorus Torus1(A2, majRad, minRad); |
855 | TopoDS_Shape tor1 = Torus1.Shape(); |
856 | if (index < argc) DBRep::Set(argv[index++], tor1); |
857 | |
858 | gp_Pnt P3(0, 0, 10); |
859 | gp_Dir D3(0, 0, 30); |
860 | gp_Ax2 A3(P3,D3); |
861 | BRepPrimAPI_MakeTorus Torus2(A3, majRad, minRad); |
862 | TopoDS_Shape tor2 = Torus2.Shape(); |
863 | if (index < argc) DBRep::Set(argv[index++], tor2); |
864 | |
586db386 |
865 | di << "All primitives created..... Creating Boolean\n"; |
7fd59977 |
866 | |
7fd59977 |
867 | try |
431d0f18 |
868 | { |
7fd59977 |
869 | OCC_CATCH_SIGNALS |
7fd59977 |
870 | |
431d0f18 |
871 | di << "Fuse1 = BRepAlgoAPI_Fuse(tor1, rev)\n"; |
872 | TopoDS_Shape fuse1 = BRepAlgoAPI_Fuse(tor1, rev).Shape(); |
873 | |
874 | if (index < argc) DBRep::Set(argv[index++], fuse1); |
875 | di << "Fuse1 Created ! Creating Fuse 2\n"; |
876 | |
877 | di << "Fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1)\n"; |
878 | TopoDS_Shape fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1).Shape(); |
879 | |
880 | if (index < argc) DBRep::Set(argv[index++], fuse2); |
881 | di << "Fuse2 Created ! Triangulating !\n"; |
882 | |
883 | performTriangulation(fuse2, di); |
884 | } |
885 | catch (Standard_Failure) |
886 | { |
887 | di << "*********************************************************\n"; |
888 | di << "***** ******\n"; |
889 | di << "***** Standard_Failure : Exception in REV Function ******\n"; |
890 | di << "***** ******\n"; |
891 | di << "*********************************************************\n"; |
892 | return 1; |
893 | } |
7fd59977 |
894 | return 0; |
895 | } |
896 | |
897 | //======================================================================= |
898 | // performBlend |
899 | //======================================================================= |
900 | |
901 | int performBlend (TopoDS_Shape aShape, Standard_Real rad, TopoDS_Shape& bShape, Draw_Interpretor& di) |
902 | { |
903 | Standard_Integer status = 0; |
904 | TopoDS_Shape newShape; |
905 | TopTools_IndexedDataMapOfShapeListOfShape edgemap; |
906 | TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_SOLID,edgemap); |
907 | di << "Blending All Edges: No. of Edges: " << edgemap.Extent() << "\n"; |
908 | ChFi3d_FilletShape FShape = ChFi3d_Rational; |
909 | BRepFilletAPI_MakeFillet blend(aShape,FShape); |
910 | for(int i = 1; i <= edgemap.Extent(); i++) |
911 | { |
912 | TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) ); |
913 | if(!edg.IsNull()) blend.Add(rad, edg); |
914 | } |
915 | |
916 | try |
917 | { |
918 | OCC_CATCH_SIGNALS |
919 | blend.Build(); |
920 | if(!blend.HasResult() || blend.Shape().IsNull()) { |
921 | status = 1; |
922 | } |
923 | } |
924 | catch ( Standard_Failure ) |
925 | { |
926 | status = 1; |
927 | } |
928 | if(status) { |
586db386 |
929 | di<<"*******************************************************\n"; |
930 | di<<"****** *******\n"; |
931 | di<<"****** Blending Failed (Radius = " << rad << ") *******\n"; |
932 | di<<"****** *******\n"; |
933 | di<<"*******************************************************\n"; |
7fd59977 |
934 | return 1; |
935 | } else { |
586db386 |
936 | di<<"Blending successfully performed on all Edges: \n\n"; |
7fd59977 |
937 | } |
938 | bShape = blend.Shape(); |
939 | return 0; |
940 | } |
941 | |
942 | #include <GC_MakeSegment.hxx> |
943 | //======================================================================= |
944 | // OCC828 |
945 | //======================================================================= |
946 | |
947 | static Standard_Integer OCC828 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv) |
948 | { |
949 | if(argc != 2) { |
586db386 |
950 | di << "Usage : " << argv[0] << " shape\n"; |
7fd59977 |
951 | } |
952 | int index = 1; |
953 | |
954 | Standard_Real slabThick = 111; |
955 | |
956 | gp_Pnt p11(-27.598139, -7.0408573, 0.0); |
957 | gp_Pnt p12(-28.483755, -17.487625, 0.0); |
958 | gp_Pnt p13(-19.555504, -22.983587, 0.0); |
959 | GC_MakeArcOfCircle arc1(p11, p12, p13); |
960 | |
961 | gp_Pnt p21(12.125083, -22.983587, 0.0); |
962 | gp_Pnt p22(21.1572, -17.27554, 0.0); |
963 | gp_Pnt p23(19.878168, -6.6677585, 0.0); |
964 | GC_MakeArcOfCircle arc2(p21, p22, p23); |
965 | |
966 | gp_Pnt p31(3.265825, 13.724955, 0.0); |
967 | gp_Pnt p32(-4.7233953, 17.406338, 0.0); |
968 | gp_Pnt p33(-12.529893, 13.351856, 0.0); |
969 | GC_MakeArcOfCircle arc3(p31, p32, p33); |
970 | |
971 | GC_MakeSegment ln1(p13, p21); |
972 | GC_MakeSegment ln2(p23, p31); |
973 | GC_MakeSegment ln3(p33, p11); |
974 | |
975 | TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value()); |
976 | TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value()); |
977 | TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value()); |
978 | |
979 | TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(ln1.Value()); |
980 | TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge(ln2.Value()); |
981 | TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge(ln3.Value()); |
982 | |
983 | BRepBuilderAPI_MakeWire MW; |
984 | MW.Add(e1); |
985 | MW.Add(e4); |
986 | MW.Add(e2); |
987 | MW.Add(e5); |
988 | MW.Add(e3); |
989 | MW.Add(e6); |
990 | |
991 | if (!MW.IsDone()) |
992 | { |
586db386 |
993 | di << "my Wire not done\n"; |
7fd59977 |
994 | return 1; |
995 | } |
996 | |
997 | TopoDS_Wire W = MW.Wire(); |
998 | TopoDS_Face F = BRepBuilderAPI_MakeFace(W); |
999 | if ( F.IsNull()) |
1000 | { |
586db386 |
1001 | di << " Error in Face creation \n"; |
7fd59977 |
1002 | return 1; |
1003 | } |
1004 | |
1005 | try |
1006 | { |
1007 | OCC_CATCH_SIGNALS |
1008 | gp_Dir slabDir(0, 0, 1); |
1009 | gp_Vec slabVect(slabDir); |
1010 | slabVect *= slabThick; |
1011 | |
1012 | BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True); |
1013 | if ( ! slab.IsDone() ) |
1014 | { |
586db386 |
1015 | di << " Error in Slab creation \n"; |
7fd59977 |
1016 | return 1; |
1017 | } |
1018 | if (index < argc) DBRep::Set(argv[index++], slab.Shape()); |
1019 | |
1020 | // cout << "Slab Successfully Created ! Now Blending ..." << endl; |
1021 | // TopoDS_Shape aShape; |
1022 | // int ret = performBlend(slab.Shape(), radius, aShape); |
1023 | // if (ret) return 1; |
1024 | // if (index < argc) DBRep::Set(argv[index++], aShape); |
1025 | |
1026 | // cout << "Blending Successfully Done ! Now Triangulating ..." << endl; |
1027 | // performTriangulation(aShape); |
1028 | } |
1029 | catch ( Standard_Failure ) |
1030 | { |
586db386 |
1031 | di << " Error in Draft Slab \n"; |
7fd59977 |
1032 | return 1; |
1033 | } |
1034 | return 0; |
1035 | } |
1036 | |
1cd84fee |
1037 | void QABugs::Commands_10(Draw_Interpretor& theCommands) { |
1365140b |
1038 | const char *group = "QABugs"; |
7fd59977 |
1039 | |
431d0f18 |
1040 | theCommands.Add ("OCC426", "OCC426 shape1 shape2 shape3 shape4 shape5 shape6 shape7", __FILE__, OCC426, group); |
7fd59977 |
1041 | |
1042 | theCommands.Add("isperiodic", "Use : isperiodic surfaceOfRevolution", __FILE__, isPeriodic, group); |
1043 | theCommands.Add("OCC486", "Use : OCC486 surf x y z du dv ", __FILE__, OCC486, group); |
1044 | theCommands.Add("OCC712", "OCC712 draftAngle slabThick", __FILE__, OCC712, group); |
431d0f18 |
1045 | theCommands.Add("OCC822_1", "OCC822_1 name1 name2 result", __FILE__,OCC822_1, group); |
1046 | theCommands.Add("OCC822_2", "OCC822_2 name1 name2 result", __FILE__,OCC822_2, group); |
1047 | theCommands.Add("OCC823", "OCC823 name1 name2 result", __FILE__,OCC823, group); |
1048 | theCommands.Add("OCC824", "OCC824 name1 name2 result", __FILE__,OCC824, group); |
1049 | theCommands.Add("OCC825", "OCC825 name1 name2 name3 name4 name5", __FILE__,OCC825, group); |
1050 | theCommands.Add("OCC826", "OCC826 name1 name2 result", __FILE__,OCC826, group); |
1051 | theCommands.Add("OCC827", "OCC827 name1 name2 name3 result1 result2", __FILE__,OCC827, group); |
7fd59977 |
1052 | theCommands.Add("OCC828", "OCC828 redius shape result ", __FILE__,OCC828, group); |
1053 | |
1054 | return; |
1055 | } |