1 // Created on: 2000-03-16
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 <TopoDS_Shape.hxx>
28 #include <TopoDS_Face.hxx>
30 #include <TCollection_AsciiString.hxx>
32 #include <IntTools_FaceFace.hxx>
33 #include <IntTools_SequenceOfCurves.hxx>
34 #include <IntTools_Curve.hxx>
36 #include <Geom_Curve.hxx>
37 #include <DrawTrSurf.hxx>
40 #include <IntTools_Tools.hxx>
43 static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char** );
44 static Standard_Integer bcurtolerance (Draw_Interpretor& di, Standard_Integer n, const char** a);
46 //=======================================================================
47 //function : BOPTest::CurveCommands
49 //=======================================================================
50 void BOPTest::CurveCommands(Draw_Interpretor& theCommands)
52 static Standard_Boolean done = Standard_False;
56 const char* g = "CCR commands";
58 theCommands.Add("bopcurves" , "Use bopcurves> F1 F2", __FILE__, bopcurves, g);
59 theCommands.Add("bcurtolerance" , " use >bcurtolerance C3Dtrim, Tol\n", __FILE__, bcurtolerance, g);
62 //=======================================================================
63 //function : bopcurves
65 //=======================================================================
66 Standard_Integer bopcurves (Draw_Interpretor& di,
71 di << " Use bopcurves> F1 F2\n";
75 TopoDS_Shape S1 = DBRep::Get(a[1]);
76 TopoDS_Shape S2 = DBRep::Get(a[2]);
77 TopAbs_ShapeEnum aType;
79 if (S1.IsNull() || S2.IsNull()) {
80 di << " Null shapes is not allowed \n";
85 if (aType != TopAbs_FACE) {
86 di << " Type mismatch F1\n";
90 if (aType != TopAbs_FACE) {
91 di << " Type mismatch F2\n";
96 const TopoDS_Face& aF1=TopoDS::Face(S1);
97 const TopoDS_Face& aF2=TopoDS::Face(S2);
99 Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
100 Standard_Boolean bToSplit;
101 Standard_Integer i, aNbCurves;
102 Standard_Real anAppTol, aTolR;
103 TCollection_AsciiString aNm("c_");
105 bToSplit=Standard_False;
106 aToApproxC3d=Standard_True;
107 aToApproxC2dOnS1=Standard_False;
108 aToApproxC2dOnS2=Standard_False;
112 IntTools_FaceFace aFF;
114 aFF.SetParameters (aToApproxC3d,
119 aFF.Perform (aF1, aF2);
121 anIsDone=aFF.IsDone();
123 //printf(" anIsDone=%d\n", anIsDone);
124 di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
128 aFF.PrepareLines3D(bToSplit);
129 const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
132 aTolR=aFF.TolReached3d();
133 di << "Tolerance Reached=" << aTolR << "\n";
135 aNbCurves=aSCs.Length();
137 di << " has no 3d curve\n";
141 for (i=1; i<=aNbCurves; i++) {
142 const IntTools_Curve& anIC=aSCs(i);
144 Handle (Geom_Curve) aC3D=anIC.Curve();
147 di << " has Null 3d curve# " << i << "%d\n";
151 TCollection_AsciiString anIndx(i), aNmx;
153 Standard_CString name= aNmx.ToCString();
154 DrawTrSurf::Set(name, aC3D);
163 //=======================================================================
164 //function : bcurtolerance
166 //=======================================================================
167 Standard_Integer bcurtolerance (Draw_Interpretor& di,
172 di << " use >bcurtolerance C3D [Tol=1.e-7]\n";
176 Handle(Geom_Curve) aC3D = DrawTrSurf::GetCurve(a[1]);
177 if ( aC3D.IsNull()) {
178 di << " Null Curve is not allowed here\n";
182 Standard_Real aTolMax, aTol;
186 aTol=Draw::Atof(a[2]);
192 aTolMax=IntTools_Tools::CurveTolerance(aC3D, aTol);
193 //printf(" aTolMax=%16.11f\n", aTolMax);
194 di << " aTolMax=" << aTolMax << "\n";