0028599: Replacement of old Boolean operations with new ones in BRepProj_Projection...
[occt.git] / src / BRepTest / BRepTest_ProjectionCommands.cxx
CommitLineData
b311480e 1// Created on: 1998-03-03
2// Created by: Didier PIFFAULT
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <GeometryTest.hxx>
18#include <DrawTrSurf.hxx>
19#include <Draw_Appli.hxx>
20#include <TopoDS_Shape.hxx>
21#include <DBRep.hxx>
22#include <Draw_Interpretor.hxx>
23#include <BRepProj_Projection.hxx>
24#include <TopExp_Explorer.hxx>
25#include <BRepTest.hxx>
26#include <TopoDS.hxx>
7fd59977 27#include <stdio.h>
57c28b61 28
03cca6f7 29//=======================================================================
30//function : prj
31//purpose : Draw command for Conical and Cylindrical projection
32//=======================================================================
7fd59977 33static Standard_Integer prj(Draw_Interpretor& di, Standard_Integer n, const char** a)
03cca6f7 34{
35 if (n != 7)
36 {
37 di.PrintHelp(a[0]);
38 return 1;
7fd59977 39 }
03cca6f7 40 //
41 TopoDS_Shape anInputWire = DBRep::Get(a[2]);
42 TopoDS_Shape anInputShape = DBRep::Get(a[3]);
43 if (anInputWire.IsNull() || anInputShape.IsNull())
44 {
45 di << "Null input shapes\n";
46 return 1;
7fd59977 47 }
03cca6f7 48 //
49 Standard_Real X = Draw::Atof(a[4]),
50 Y = Draw::Atof(a[5]),
51 Z = Draw::Atof(a[6]);
52 //
53 Standard_Boolean bCylProj = !strcmp(a[0], "prj");
54 //
55 BRepProj_Projection aPrj = bCylProj ?
56 BRepProj_Projection(anInputWire, anInputShape, gp_Dir(X, Y, Z)) :
57 BRepProj_Projection(anInputWire, anInputShape, gp_Pnt(X, Y, Z));
58 //
59 if (!aPrj.IsDone())
60 {
61 di << "Not done\n";
62 return 0;
63 }
64 //
65 for (Standard_Integer i = 1; aPrj.More(); aPrj.Next(), ++i)
66 {
67 char name[255];
68 Sprintf(name, "%s_%d", a[1], i);
69 DBRep::Set(name, aPrj.Current());
70 di << name << " ";
71 }
72 //
73 di << "\n";
7fd59977 74 return 0;
75}
76
7fd59977 77/*********************************************************************************/
78
03cca6f7 79void BRepTest::ProjectionCommands(Draw_Interpretor& theCommands)
7fd59977 80{
81 static Standard_Boolean loaded = Standard_False;
82 if (loaded) return;
83 loaded = Standard_True;
84
85 const char* g = "Projection of wire commands";
86
03cca6f7 87 theCommands.Add("prj","prj result w s x y z: "
88 "Cylindrical projection of w (wire or edge) on s (faces) along direction.\n",
89 __FILE__, prj, g);
90 //
91 theCommands.Add("cprj","cprj result w s x y z: "
92 "Conical projection of w (wire or edge) on s (faces).\n",
93 __FILE__, prj, g);
7fd59977 94}