1 // Created on: 1995-09-08
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // modified by mps (juillet 96) : ajout de la commande distmini
24 #include <BRepTest.hxx>
26 #include <TopoDS_Shape.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <BRepExtrema_Poly.hxx>
29 #include <BRepExtrema_DistShapeShape.hxx>
30 #include <BRepLib_MakeEdge.hxx>
31 #include <BRepLib_MakeEdge.hxx>
32 #include <BRepLib_MakeVertex.hxx>
34 #include <Draw_Interpretor.hxx>
39 //=======================================================================
42 //=======================================================================
44 static Standard_Integer distance (Draw_Interpretor& di,
50 const char *name1 = a[1];
51 const char *name2 = a[2];
53 TopoDS_Shape S1 = DBRep::Get(name1);
54 TopoDS_Shape S2 = DBRep::Get(name2);
55 if (S1.IsNull() || S2.IsNull()) return 1;
58 if (!BRepExtrema_Poly::Distance(S1,S2,P1,P2,D)) return 1;
59 //cout << " distance : " << D << endl;
60 di << " distance : " << D << "\n";
61 TopoDS_Edge E = BRepLib_MakeEdge(P1,P2);
62 DBRep::Set("distance",E);
65 static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const char** a)
72 const char *ns1 = (a[2]), *ns2 = (a[3]), *ns0 = (a[1]);
73 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)) ;
74 BRepExtrema_DistShapeShape dst(S1 ,S2 );
81 Standard_SStream aSStream;
87 sprintf(named, "%s%s" ,ns0,"_val");
89 Draw::Set(tempd,dst.Value());
92 for (i1=1; i1<= dst.NbSolution(); i1++)
95 P1 = (dst.PointOnShape1(i1));
96 P2 = (dst.PointOnShape2(i1));
97 if (dst.Value()<=1.e-9)
99 TopoDS_Vertex V =BRepLib_MakeVertex(P1);
102 sprintf(namev, "%s" ,ns0);
103 else sprintf(namev, "%s%d" ,ns0,i1);
110 TopoDS_Edge E = BRepLib_MakeEdge (P1, P2);
112 {sprintf(name,"%s",ns0);}
113 else {sprintf(name,"%s%d",ns0,i1);}
121 else di << "probleme"<< "\n";
122 //else cout << "probleme"<< endl;
126 //=======================================================================
127 //function : ExtremaCommands
129 //=======================================================================
131 void BRepTest::ExtremaCommands(Draw_Interpretor& theCommands)
133 static Standard_Boolean done = Standard_False;
135 done = Standard_True;
137 const char* g = "TOPOLOGY Extrema commands";
139 theCommands.Add("dist","dist Shape1 Shape2" ,__FILE__,distance,g);
142 theCommands.Add("distmini",
143 "distmini name Shape1 Shape2",