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>
39 #include <IntTools_Tools.hxx>
42 static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char** );
43 static Standard_Integer bcurtolerance (Draw_Interpretor& di, Standard_Integer n, const char** a);
45 //=======================================================================
46 //function : BOPTest::CurveCommands
48 //=======================================================================
49 void BOPTest::CurveCommands(Draw_Interpretor& theCommands)
51 static Standard_Boolean done = Standard_False;
55 const char* g = "CCR commands";
57 theCommands.Add("bopcurves" , "Use bopcurves> F1 F2", __FILE__, bopcurves, g);
58 theCommands.Add("bcurtolerance" , " use >bcurtolerance C3Dtrim, Tol\n", __FILE__, bcurtolerance, g);
61 //=======================================================================
62 //function : bopcurves
64 //=======================================================================
65 Standard_Integer bopcurves (Draw_Interpretor& di,
70 di << " Use bopcurves> F1 F2\n";
74 TopoDS_Shape S1 = DBRep::Get(a[1]);
75 TopoDS_Shape S2 = DBRep::Get(a[2]);
76 TopAbs_ShapeEnum aType;
78 if (S1.IsNull() || S2.IsNull()) {
79 di << " Null shapes is not allowed \n";
84 if (aType != TopAbs_FACE) {
85 di << " Type mismatch F1\n";
89 if (aType != TopAbs_FACE) {
90 di << " Type mismatch F2\n";
95 const TopoDS_Face& aF1=TopoDS::Face(S1);
96 const TopoDS_Face& aF2=TopoDS::Face(S2);
98 Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
99 Standard_Boolean bToSplit;
100 Standard_Integer i, aNbCurves;
101 Standard_Real anAppTol, aTolR;
102 TCollection_AsciiString aNm("c_");
104 bToSplit=Standard_False;
105 aToApproxC3d=Standard_True;
106 aToApproxC2dOnS1=Standard_False;
107 aToApproxC2dOnS2=Standard_False;
111 IntTools_FaceFace aFF;
113 aFF.SetParameters (aToApproxC3d,
118 aFF.Perform (aF1, aF2);
120 anIsDone=aFF.IsDone();
122 //printf(" anIsDone=%d\n", anIsDone);
123 di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
127 aFF.PrepareLines3D(bToSplit);
128 const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
131 aTolR=aFF.TolReached3d();
132 di << "Tolerance Reached=" << aTolR << "\n";
134 aNbCurves=aSCs.Length();
136 di << " has no 3d curve\n";
140 for (i=1; i<=aNbCurves; i++) {
141 const IntTools_Curve& anIC=aSCs(i);
143 Handle (Geom_Curve) aC3D=anIC.Curve();
146 di << " has Null 3d curve# " << i << "%d\n";
150 TCollection_AsciiString anIndx(i), aNmx;
152 Standard_CString name= aNmx.ToCString();
153 DrawTrSurf::Set(name, aC3D);
162 //=======================================================================
163 //function : bcurtolerance
165 //=======================================================================
166 Standard_Integer bcurtolerance (Draw_Interpretor& di,
171 di << " use >bcurtolerance C3D [Tol=1.e-7]\n";
175 Handle(Geom_Curve) aC3D = DrawTrSurf::GetCurve(a[1]);
176 if ( aC3D.IsNull()) {
177 di << " Null Curve is not allowed here\n";
181 Standard_Real aTolMax, aTol;
191 aTolMax=IntTools_Tools::CurveTolerance(aC3D, aTol);
192 //printf(" aTolMax=%16.11f\n", aTolMax);
193 di << " aTolMax=" << aTolMax << "\n";