0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / StdPrs / StdPrs_HLRToolShape.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <BRepAdaptor_Curve.hxx>
17 #include <HLRAlgo_Projector.hxx>
18 #include <HLRBRep_Algo.hxx>
19 #include <HLRBRep_Data.hxx>
20 #include <StdPrs_HLRToolShape.hxx>
21 #include <TopoDS_Shape.hxx>
22
23 StdPrs_HLRToolShape::StdPrs_HLRToolShape (
24                   const TopoDS_Shape& TheShape,
25                   const HLRAlgo_Projector& TheProjector)
26 {
27   Handle(HLRBRep_Algo) Hider = new HLRBRep_Algo();
28   Standard_Integer nbIso = 0; // 5;
29   Hider->Add(TheShape, nbIso);
30   Hider->Projector(TheProjector);
31   Hider->Update();
32   Hider->Hide();
33   MyData = Hider->DataStructure();
34   MyCurrentEdgeNumber = 0;
35 }
36
37 Standard_Integer StdPrs_HLRToolShape::NbEdges() const {
38   return MyData->NbEdges();
39 }
40 void StdPrs_HLRToolShape::InitVisible(const Standard_Integer EdgeNumber) {
41   myEdgeIterator.InitVisible
42     (MyData->EDataArray().ChangeValue(EdgeNumber).Status());
43   MyCurrentEdgeNumber = EdgeNumber;
44 }
45 Standard_Boolean StdPrs_HLRToolShape::MoreVisible() const {
46   return myEdgeIterator.MoreVisible();
47 }
48 void StdPrs_HLRToolShape::NextVisible()  {
49   myEdgeIterator.NextVisible();
50 }
51 void StdPrs_HLRToolShape::Visible(BRepAdaptor_Curve& TheEdge,
52                                   Standard_Real& U1,
53                                   Standard_Real& U2) {
54
55   TheEdge = MyData->EDataArray()
56     .ChangeValue(MyCurrentEdgeNumber)
57       .ChangeGeometry()
58         .Curve();
59   Standard_ShortReal t1,t2;
60   myEdgeIterator.Visible(U1,t1,U2,t2);
61 }
62 void StdPrs_HLRToolShape::InitHidden(const Standard_Integer EdgeNumber) {
63   myEdgeIterator.InitHidden
64     (MyData->EDataArray().ChangeValue(EdgeNumber).Status());
65   MyCurrentEdgeNumber = EdgeNumber;
66 }
67 Standard_Boolean StdPrs_HLRToolShape::MoreHidden() const {
68   return myEdgeIterator.MoreHidden();
69 }
70 void StdPrs_HLRToolShape::NextHidden()  {
71    myEdgeIterator.NextHidden();
72 }
73 void StdPrs_HLRToolShape::Hidden (BRepAdaptor_Curve& TheEdge,
74                                   Standard_Real& U1,
75                                   Standard_Real& U2) {
76
77   TheEdge = MyData->EDataArray()
78     .ChangeValue(MyCurrentEdgeNumber)
79       .ChangeGeometry()
80         .Curve();
81   Standard_ShortReal t1,t2;
82   myEdgeIterator.Hidden(U1,t1,U2,t2);
83 }