1 // Created on: 1993-07-22
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-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 #include <BRepTest.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <Draw_Appli.hxx>
22 #include <BRepPrimAPI_MakeHalfSpace.hxx>
23 #include <BRepAlgo_FaceRestrictor.hxx>
25 #include <TopOpeBRepBuild_HBuilder.hxx>
26 #include <TopOpeBRepDS_HDataStructure.hxx>
28 static Standard_Integer halfspace(Draw_Interpretor& di,
29 Standard_Integer n, const char** a)
33 // Le point indiquant le cote "matiere".
34 gp_Pnt RefPnt = gp_Pnt(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
36 TopoDS_Shape Face = DBRep::Get(a[2],TopAbs_FACE);
38 TopoDS_Shape Shell = DBRep::Get(a[2],TopAbs_SHELL);
40 di << a[2] << " must be a face or a shell\n";
44 BRepPrimAPI_MakeHalfSpace Half(TopoDS::Shell(Shell),RefPnt);
46 DBRep::Set(a[1],Half.Solid());
49 di << " HalfSpace NotDone\n";
55 BRepPrimAPI_MakeHalfSpace Half(TopoDS::Face(Face),RefPnt);
57 DBRep::Set(a[1],Half.Solid());
60 di << " HalfSpace NotDone\n";
67 //=======================================================================
68 //function : buildfaces
70 //=======================================================================
72 static Standard_Integer buildfaces(Draw_Interpretor& , Standard_Integer narg, const char** a)
74 if (narg < 4) return 1;
76 TopoDS_Shape InputShape(DBRep::Get( a[2] ,TopAbs_FACE));
77 TopoDS_Face F = TopoDS::Face(InputShape);
78 BRepAlgo_FaceRestrictor FR;
81 for (Standard_Integer i = 3 ; i < narg ; i++) {
82 TopoDS_Shape InputWire(DBRep::Get(a[i],TopAbs_WIRE));
83 TopoDS_Wire W = TopoDS::Wire(InputWire);
87 if (!FR.IsDone()) return 1;
93 for (; FR.More(); FR.Next()) {
94 TopoDS_Face FF = FR.Current();
101 //=======================================================================
102 //function : TopologyCommands
104 //=======================================================================
106 void BRepTest::TopologyCommands(Draw_Interpretor& theCommands)
108 static Standard_Boolean done = Standard_False;
110 done = Standard_True;
112 DBRep::BasicCommands(theCommands);
114 const char* g = "TOPOLOGY Topological operation commands";
116 theCommands.Add("halfspace","halfspace result face/shell x y z",__FILE__,halfspace,g);
117 theCommands.Add("buildfaces","buildfaces result faceReference wire1 wire2 ...",__FILE__,buildfaces,g);