0023024: Update headers of OCCT files
[occt.git] / src / BOP / BOP_Draw.cxx
CommitLineData
b311480e 1// Created on: 2001-05-31
2// Created by: Peter KURNEV
3// Copyright (c) 2001-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
19
7fd59977 20
21
22#include <BOP_Draw.ixx>
23
24#ifdef BOPDRAW
25
26#include <stdio.h>
27
28#include <TCollection_AsciiString.hxx>
29
30#include <BRep_Tool.hxx>
31
32#include <TopTools_ListIteratorOfListOfShape.hxx>
33
34#include <TopoDS_Edge.hxx>
35#include <TopoDS_Shape.hxx>
36#include <TopoDS.hxx>
37
38#include <Geom2d_Curve.hxx>
39#include <Geom2d_TrimmedCurve.hxx>
40
41#include <DBRep.hxx>
42
43#include <DrawTrSurf.hxx>
44#include <Draw_Color.hxx>
45#include <Draw_Interpretor.hxx>
46
47
48Standard_IMPORT
49 Draw_Color DrawTrSurf_CurveColor(const Draw_Color col);
50
51Standard_IMPORT
52 Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or);
53
54Standard_EXPORT
55 Draw_Interpretor theCommands;
56//=======================================================================
57// function: DrawListOfShape
58// purpose:
59//=======================================================================
60 void BOP_Draw::DrawListOfShape (const TopTools_ListOfShape& aListOfShape,
61 const Standard_CString aName)
62
63{
64 Standard_Integer j;
65 TCollection_AsciiString aNm(aName);
66
67 j=aListOfShape.Extent();
68 if (!j) {
69 cout << " No shapes to draw" << flush;
70 return;
71 }
72
73 TopTools_ListIteratorOfListOfShape anIt(aListOfShape);
74 for (j=1; anIt.More(); anIt.Next(), j++) {
75 const TopoDS_Shape& aEx=anIt.Value();
76
77 TCollection_AsciiString aN, jIndex(j);
78 aN=aNm+jIndex;
79 Standard_CString aTxt=aN.ToCString();
80 cout << aTxt << " " << flush;
81 DBRep::Set(aTxt, aEx);
82 }
83 cout << endl << flush;
84}
85//=======================================================================
86// function: DrawListOfEdgesWithPC
87// purpose:
88//=======================================================================
89 void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& aFace,
90 const TopTools_ListOfShape& aListOfShape,
91 const Standard_Integer i,
92 const Standard_CString cName)
93
94{
95 theCommands.Eval("2dclear");
96
97 TCollection_AsciiString aName, aIndex(i), aUndscr("_"), aNm(cName);
98 aName=aName+aNm;
99 aName=aName+aIndex;
100 aName=aName+aUndscr;
101 Standard_CString aCString=aName.ToCString();
102
103 DrawListOfEdgesWithPC(aFace, aListOfShape, aCString);
104}
105
106//=======================================================================
107// function: DrawListOfEdgesWithPC
108// purpose:
109//=======================================================================
110 void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& aFace,
111 const TopTools_ListOfShape& aListOfShape,
112 const Standard_CString aName)
113
114{
115 theCommands.Eval("2dclear");
116
117 Standard_Integer j;
118 TCollection_AsciiString aNm(aName);
119
120 j=aListOfShape.Extent();
121 if (!j) {
122 cout << " No shapes to draw" << flush;
123 return;
124 }
125
126 TopTools_ListIteratorOfListOfShape anIt(aListOfShape);
127 for (j=1; anIt.More(); anIt.Next(), j++) {
128 const TopoDS_Edge& aEx=TopoDS::Edge(anIt.Value());
129
130 TCollection_AsciiString aN, jIndex(j);
131 aN=aNm+jIndex;
132 Standard_CString aTxt=aN.ToCString();
133 BOP_Draw::DrawEdgeWithPC(aFace, aEx, aTxt);
134 cout << " " << aTxt << flush;
135 }
136
137 theCommands.Eval("2dfit");
138}
139
140//=======================================================================
141// function: DrawEdgeWithPC
142// purpose:
143//=======================================================================
144 void BOP_Draw::DrawEdgeWithPC (const TopoDS_Face& aFace,
145 const TopoDS_Edge& aEdge,
146 const Standard_CString aName)
147
148{
149 Standard_Real f,l;
150
151 // Edge 3D
152 DBRep::Set(aName, aEdge);
153 // PC
154 Draw_Color col, savecol;
155 savecol = DrawTrSurf_CurveColor(Draw_rouge);
156
157 const Handle(Geom2d_Curve) c =
158 BRep_Tool::CurveOnSurface (aEdge, aFace, f, l);
159
160 col = DBRep_ColorOrientation(aEdge.Orientation());
161 DrawTrSurf_CurveColor(col);
162
163 TCollection_AsciiString aNm(aName), aAdd("_p");
164 aNm=aNm+aAdd;
165 Standard_CString aTxtPC=aNm.ToCString();
166
167 DrawTrSurf::Set(aTxtPC, new Geom2d_TrimmedCurve(c, f, l));
168
169 DrawTrSurf_CurveColor(savecol);
170}
171
172//=======================================================================
173// function: Wait
174// purpose:
175//=======================================================================
176 void BOP_Draw::Wait()
177{
178 char xx;
179 scanf ("%c", &xx);
180}
181
182#endif
183
184#ifndef BOPDRAW
185
186void BOP_Draw::DrawListOfShape (const TopTools_ListOfShape& ,
187 const Standard_CString ){}
188void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& ,
189 const TopTools_ListOfShape& ,
190 const Standard_Integer ,
191 const Standard_CString ){}
192void BOP_Draw::DrawListOfEdgesWithPC (const TopoDS_Face& ,
193 const TopTools_ListOfShape& ,
194 const Standard_CString ){}
195void BOP_Draw::DrawEdgeWithPC (const TopoDS_Face& ,
196 const TopoDS_Edge& ,
197 const Standard_CString ){}
198void BOP_Draw::Wait(){}
199
200#endif
201