1 // Created on: 2000-05-18
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2012 OPEN CASCADE SAS
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.
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.
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.
22 #include <BOPTest.ixx>
27 #include <Draw_Interpretor.hxx>
28 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Edge.hxx>
32 #include <IntTools_EdgeEdge.hxx>
33 #include <IntTools_SequenceOfCommonPrts.hxx>
34 #include <IntTools_Range.hxx>
35 #include <IntTools_CommonPrt.hxx>
36 #include <BRep_Tool.hxx>
38 //=======================================================================
41 //=======================================================================
42 static Standard_Integer bbedge (Draw_Interpretor& di,
47 di << " Use bbedge> Edge1 Edge2 f1 l1 f2 l2\n";
51 TopoDS_Shape S1 = DBRep::Get(a[1]);
52 TopoDS_Shape S2 = DBRep::Get(a[2]);
54 if (S1.IsNull() || S2.IsNull()) {
55 di << " Null shapes is not allowed \n";
59 if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
60 di << " Shapes must be EDGE type\n";
64 TopoDS_Edge E1=TopoDS::Edge(S1);
65 TopoDS_Edge E2=TopoDS::Edge(S2);
67 Standard_Integer aDiscr=30;
68 Standard_Real aTol=.0000001, aDeflection=.01;
69 Standard_Real f1, l1, f2, l2;
76 IntTools_Range aR1, aR2;
77 aR1.SetFirst(f1); aR1.SetLast(l1);
78 aR2.SetFirst(f2); aR2.SetLast(l2);
80 di << " bbedge: ===Begin===\n";
81 di << " bbedge: Discretize=" << aDiscr << "\n";
82 di << " bbedge: Tolerance =" << aTol << "\n";
83 di << " bbedge: Deflection=" << aDeflection << "\n";
85 IntTools_EdgeEdge aEE;
90 aEE.SetTolerance1(aTol);
91 aEE.SetTolerance2(aTol);
93 aEE.SetDiscretize(aDiscr);
94 aEE.SetDeflection(aDeflection);
102 Standard_Boolean anIsDone=aEE.IsDone();
103 di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
106 const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
108 Standard_Integer i,j, aNbRanges, aNbRanges2;
109 Standard_Real t1, t2;
111 aNbRanges=aSCp.Length();
112 for (i=1; i<=aNbRanges; i++) {
113 const IntTools_CommonPrt& aCommonPrt=aSCp(i);
115 di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
116 const IntTools_Range& aRange1=aCommonPrt.Range1();
117 aRange1.Range(t1, t2);
118 di << "Range 1: [" << t1 << ", " << t2 << "]\n";
120 const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
121 aNbRanges2=aSeqOfRanges2.Length();
122 for (j=1; j<=aNbRanges2; j++) {
123 const IntTools_Range& aRange2=aSeqOfRanges2(j);
124 aRange2.Range(t1, t2);
125 di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
131 di << " bedge: ===End===\n";
135 //=======================================================================
138 //=======================================================================
139 static Standard_Integer bedge (Draw_Interpretor& di,
144 di << " Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]\n";
148 TopoDS_Shape S1 = DBRep::Get(a[1]);
149 TopoDS_Shape S2 = DBRep::Get(a[2]);
151 if (S1.IsNull() || S2.IsNull()) {
152 di << " Null shapes is not allowed \n";
156 if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
157 di << " Shapes must be EDGE type\n";
161 TopoDS_Edge E1=TopoDS::Edge(S1);
162 TopoDS_Edge E2=TopoDS::Edge(S2);
164 Standard_Integer aDiscr=30;
165 Standard_Real aTol=.0000001, aDeflection=.01;
166 Standard_Real f1, l1, f2, l2;
168 BRep_Tool::Range(E1, f1, l1);
169 BRep_Tool::Range(E2, f2, l2);
171 IntTools_Range aR1, aR2;
172 aR1.SetFirst(f1); aR1.SetLast(l1);
173 aR2.SetFirst(f2); aR2.SetLast(l2);
176 aDiscr=Draw::Atoi (a[3]);
180 aTol=Draw::Atof (a[4]);
184 aDeflection=Draw::Atof (a[5]);
187 di << " bedge: ===Begin===\n";
188 di << " bedge: Discretize=" << aDiscr << "\n";
189 di << " bedge: Tolerance =" << aTol << "\n";
190 di << " bedge: Deflection=" << aDeflection << "\n";
192 IntTools_EdgeEdge aEE;
197 aEE.SetTolerance1(aTol);
198 aEE.SetTolerance2(aTol);
200 aEE.SetDiscretize(aDiscr);
201 aEE.SetDeflection(aDeflection);
209 Standard_Boolean anIsDone=aEE.IsDone();
210 di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
213 const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
215 Standard_Integer i,j, aNbRanges, aNbRanges2;
216 Standard_Real t1, t2;
218 aNbRanges=aSCp.Length();
219 for (i=1; i<=aNbRanges; i++) {
220 const IntTools_CommonPrt& aCommonPrt=aSCp(i);
222 di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
223 const IntTools_Range& aRange1=aCommonPrt.Range1();
224 aRange1.Range(t1, t2);
225 di << "Range 1: [" << t1 << ", " << t2 << "]\n";
227 const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
228 aNbRanges2=aSeqOfRanges2.Length();
229 for (j=1; j<=aNbRanges2; j++) {
230 const IntTools_Range& aRange2=aSeqOfRanges2(j);
231 aRange2.Range(t1, t2);
232 di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
238 di << " bedge: ===End===\n";
242 //=======================================================================
243 //function : MTestCommands
245 //=======================================================================
246 void BOPTest::MTestCommands(Draw_Interpretor& theCommands)
248 static Standard_Boolean done = Standard_False;
250 done = Standard_True;
252 const char* g = "Mtest commands";
254 theCommands.Add("bedge" , "Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]", __FILE__, bedge,g);
255 theCommands.Add("bbedge", "Use bbedge> Edge1 Edge2 f1 l1 f2 l2", __FILE__, bbedge,g);