1 // Created on: 1995-09-08
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // modified by mps (juillet 96) : ajout de la commande distmini
20 #include <BRepTest.hxx>
21 #include <BRepExtrema_Poly.hxx>
22 #include <BRepExtrema_DistShapeShape.hxx>
23 #include <BRepLib_MakeEdge.hxx>
24 #include <BRepLib_MakeVertex.hxx>
31 //=======================================================================
34 //=======================================================================
36 static Standard_Integer distance (Draw_Interpretor& di,
42 const char *name1 = a[1];
43 const char *name2 = a[2];
45 TopoDS_Shape S1 = DBRep::Get(name1);
46 TopoDS_Shape S2 = DBRep::Get(name2);
47 if (S1.IsNull() || S2.IsNull()) return 1;
50 if (!BRepExtrema_Poly::Distance(S1,S2,P1,P2,D)) return 1;
51 //cout << " distance : " << D << endl;
52 di << " distance : " << D << "\n";
53 TopoDS_Edge E = BRepLib_MakeEdge(P1,P2);
54 DBRep::Set("distance",E);
58 static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const char** a)
65 const char *ns1 = (a[2]), *ns2 = (a[3]), *ns0 = (a[1]);
66 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)) ;
67 BRepExtrema_DistShapeShape dst(S1 ,S2 );
74 Standard_SStream aSStream;
80 Sprintf(named, "%s%s" ,ns0,"_val");
82 Draw::Set(tempd,dst.Value());
85 for (i1=1; i1<= dst.NbSolution(); i1++)
88 P1 = (dst.PointOnShape1(i1));
89 P2 = (dst.PointOnShape2(i1));
90 if (dst.Value()<=1.e-9)
92 TopoDS_Vertex V =BRepLib_MakeVertex(P1);
95 Sprintf(namev, "%s" ,ns0);
96 else Sprintf(namev, "%s%d" ,ns0,i1);
103 TopoDS_Edge E = BRepLib_MakeEdge (P1, P2);
105 {Sprintf(name,"%s",ns0);}
106 else {Sprintf(name,"%s%d",ns0,i1);}
114 else di << "probleme"<< "\n";
115 //else cout << "probleme"<< endl;
119 //=======================================================================
120 //function : ExtremaCommands
122 //=======================================================================
124 void BRepTest::ExtremaCommands (Draw_Interpretor& theCommands)
126 static const char* aGroup = "TOPOLOGY Extrema commands";
127 static Standard_Boolean isDone = Standard_False;
132 isDone = Standard_True;
134 theCommands.Add ("dist",
135 "dist Shape1 Shape2",
140 theCommands.Add ("distmini",
141 "distmini name Shape1 Shape2",