1 // File: BOPTest_ProjectionCommands.cxx
2 // Created: Thu May 18 10:45:01 2000
3 // Author: Peter KURNEV
11 #include <Draw_Interpretor.hxx>
12 #include <TopoDS_Shape.hxx>
14 #include <TopoDS_Edge.hxx>
16 #include <IntTools_EdgeEdge.hxx>
17 #include <IntTools_SequenceOfCommonPrts.hxx>
18 #include <IntTools_Range.hxx>
19 #include <IntTools_CommonPrt.hxx>
20 #include <BRep_Tool.hxx>
22 //=======================================================================
25 //=======================================================================
26 static Standard_Integer bbedge (Draw_Interpretor& di,
31 di << " Use bbedge> Edge1 Edge2 f1 l1 f2 l2\n";
35 TopoDS_Shape S1 = DBRep::Get(a[1]);
36 TopoDS_Shape S2 = DBRep::Get(a[2]);
38 if (S1.IsNull() || S2.IsNull()) {
39 di << " Null shapes is not allowed \n";
43 if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
44 di << " Shapes must be EDGE type\n";
48 TopoDS_Edge E1=TopoDS::Edge(S1);
49 TopoDS_Edge E2=TopoDS::Edge(S2);
51 Standard_Integer aDiscr=30;
52 Standard_Real aTol=.0000001, aDeflection=.01;
53 Standard_Real f1, l1, f2, l2;
60 IntTools_Range aR1, aR2;
61 aR1.SetFirst(f1); aR1.SetLast(l1);
62 aR2.SetFirst(f2); aR2.SetLast(l2);
64 di << " bbedge: ===Begin===\n";
65 di << " bbedge: Discretize=" << aDiscr << "\n";
66 di << " bbedge: Tolerance =" << aTol << "\n";
67 di << " bbedge: Deflection=" << aDeflection << "\n";
69 IntTools_EdgeEdge aEE;
74 aEE.SetTolerance1(aTol);
75 aEE.SetTolerance2(aTol);
77 aEE.SetDiscretize(aDiscr);
78 aEE.SetDeflection(aDeflection);
86 Standard_Boolean anIsDone=aEE.IsDone();
87 di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
90 const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
92 Standard_Integer i,j, aNbRanges, aNbRanges2;
95 aNbRanges=aSCp.Length();
96 for (i=1; i<=aNbRanges; i++) {
97 const IntTools_CommonPrt& aCommonPrt=aSCp(i);
99 di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
100 const IntTools_Range& aRange1=aCommonPrt.Range1();
101 aRange1.Range(t1, t2);
102 di << "Range 1: [" << t1 << ", " << t2 << "]\n";
104 const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
105 aNbRanges2=aSeqOfRanges2.Length();
106 for (j=1; j<=aNbRanges2; j++) {
107 const IntTools_Range& aRange2=aSeqOfRanges2(j);
108 aRange2.Range(t1, t2);
109 di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
115 di << " bedge: ===End===\n";
119 //=======================================================================
122 //=======================================================================
123 static Standard_Integer bedge (Draw_Interpretor& di,
128 di << " Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]\n";
132 TopoDS_Shape S1 = DBRep::Get(a[1]);
133 TopoDS_Shape S2 = DBRep::Get(a[2]);
135 if (S1.IsNull() || S2.IsNull()) {
136 di << " Null shapes is not allowed \n";
140 if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
141 di << " Shapes must be EDGE type\n";
145 TopoDS_Edge E1=TopoDS::Edge(S1);
146 TopoDS_Edge E2=TopoDS::Edge(S2);
148 Standard_Integer aDiscr=30;
149 Standard_Real aTol=.0000001, aDeflection=.01;
150 Standard_Real f1, l1, f2, l2;
152 BRep_Tool::Range(E1, f1, l1);
153 BRep_Tool::Range(E2, f2, l2);
155 IntTools_Range aR1, aR2;
156 aR1.SetFirst(f1); aR1.SetLast(l1);
157 aR2.SetFirst(f2); aR2.SetLast(l2);
168 aDeflection=atof (a[5]);
171 di << " bedge: ===Begin===\n";
172 di << " bedge: Discretize=" << aDiscr << "\n";
173 di << " bedge: Tolerance =" << aTol << "\n";
174 di << " bedge: Deflection=" << aDeflection << "\n";
176 IntTools_EdgeEdge aEE;
181 aEE.SetTolerance1(aTol);
182 aEE.SetTolerance2(aTol);
184 aEE.SetDiscretize(aDiscr);
185 aEE.SetDeflection(aDeflection);
193 Standard_Boolean anIsDone=aEE.IsDone();
194 di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
197 const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
199 Standard_Integer i,j, aNbRanges, aNbRanges2;
200 Standard_Real t1, t2;
202 aNbRanges=aSCp.Length();
203 for (i=1; i<=aNbRanges; i++) {
204 const IntTools_CommonPrt& aCommonPrt=aSCp(i);
206 di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
207 const IntTools_Range& aRange1=aCommonPrt.Range1();
208 aRange1.Range(t1, t2);
209 di << "Range 1: [" << t1 << ", " << t2 << "]\n";
211 const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
212 aNbRanges2=aSeqOfRanges2.Length();
213 for (j=1; j<=aNbRanges2; j++) {
214 const IntTools_Range& aRange2=aSeqOfRanges2(j);
215 aRange2.Range(t1, t2);
216 di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
222 di << " bedge: ===End===\n";
226 //=======================================================================
227 //function : MTestCommands
229 //=======================================================================
230 void BOPTest::MTestCommands(Draw_Interpretor& theCommands)
232 static Standard_Boolean done = Standard_False;
234 done = Standard_True;
236 const char* g = "Mtest commands";
238 theCommands.Add("bedge" , "Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]", __FILE__, bedge,g);
239 theCommands.Add("bbedge", "Use bbedge> Edge1 Edge2 f1 l1 f2 l2", __FILE__, bbedge,g);