0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / StdPrs / StdPrs_HLRShape.cxx
1 // Copyright (c) 2013-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <BRepAdaptor_Curve.hxx>
15 #include <Graphic3d_Group.hxx>
16 #include <Prs3d_Drawer.hxx>
17 #include <Prs3d_LineAspect.hxx>
18 #include <Prs3d_Presentation.hxx>
19 #include <Prs3d_Projector.hxx>
20 #include <StdPrs_HLRShape.hxx>
21 #include <StdPrs_HLRToolShape.hxx>
22 #include <StdPrs_DeflectionCurve.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <TColgp_SequenceOfPnt.hxx>
25
26 //=======================================================================
27 //function : Add
28 //purpose  : 
29 //=======================================================================
30
31 void StdPrs_HLRShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
32                            const TopoDS_Shape&               theShape,
33                            const Handle(Prs3d_Drawer)&       theDrawer,
34                            const Handle(Prs3d_Projector)&    theProjector)
35 {
36   StdPrs_HLRToolShape aTool(theShape, theProjector->Projector());
37   Standard_Integer aNbEdges = aTool.NbEdges();
38   Standard_Integer anI;
39   Standard_Real anU1, anU2;
40   BRepAdaptor_Curve aCurve;
41   Standard_Real aDeviation = theDrawer->MaximalChordialDeviation();
42   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
43
44   aGroup->SetPrimitivesAspect(theDrawer->SeenLineAspect()->Aspect());
45   
46   Standard_Real anAngle = theDrawer->DeviationAngle();
47   TColgp_SequenceOfPnt aPoints;
48   for (anI = 1; anI <= aNbEdges; ++anI)
49   {
50     for(aTool.InitVisible(anI); aTool.MoreVisible(); aTool.NextVisible())
51     {
52       aTool.Visible(aCurve, anU1, anU2);
53       StdPrs_DeflectionCurve::Add(thePresentation, aCurve,
54                                   anU1, anU2, aDeviation, aPoints, anAngle);
55     }
56   }
57
58   if(theDrawer->DrawHiddenLine())
59   {
60     aGroup->SetPrimitivesAspect(theDrawer->HiddenLineAspect()->Aspect());
61     
62     for (anI = 1; anI <= aNbEdges; ++anI)
63     {
64       for (aTool.InitHidden(anI); aTool.MoreHidden(); aTool.NextHidden())
65       {
66         aTool.Hidden(aCurve, anU1, anU2);
67         StdPrs_DeflectionCurve::Add(thePresentation, aCurve,
68                                     anU1, anU2, aDeviation, aPoints, anAngle);
69       }
70     }
71   }
72