d5f74e42 |
1 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
d7223c76 |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
d7223c76 |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
d7223c76 |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
d7223c76 |
13 | |
b5163d2f |
14 | #include <StdPrs_HLRShape.hxx> |
15 | |
d7223c76 |
16 | #include <BRepAdaptor_Curve.hxx> |
17 | #include <Graphic3d_Group.hxx> |
18 | #include <Prs3d_Drawer.hxx> |
19 | #include <Prs3d_LineAspect.hxx> |
20 | #include <Prs3d_Presentation.hxx> |
d7223c76 |
21 | #include <StdPrs_HLRToolShape.hxx> |
22 | #include <StdPrs_DeflectionCurve.hxx> |
23 | #include <TopoDS_Shape.hxx> |
24 | #include <TColgp_SequenceOfPnt.hxx> |
b5163d2f |
25 | #include <HLRAlgo_Projector.hxx> |
26 | |
27 | IMPLEMENT_STANDARD_RTTIEXT(StdPrs_HLRShape, StdPrs_HLRShapeI) |
d7223c76 |
28 | |
29 | //======================================================================= |
b5163d2f |
30 | //function : ComputeHLR |
31 | //purpose : |
d7223c76 |
32 | //======================================================================= |
b5163d2f |
33 | void StdPrs_HLRShape::ComputeHLR (const Handle(Prs3d_Presentation)& thePresentation, |
34 | const TopoDS_Shape& theShape, |
35 | const Handle(Prs3d_Drawer)& theDrawer, |
36 | const Handle(Graphic3d_Camera)& theProjector) const |
d7223c76 |
37 | { |
b5163d2f |
38 | gp_Dir aBackDir = -theProjector->Direction(); |
39 | gp_Dir aXpers = theProjector->Up().Crossed (aBackDir); |
40 | gp_Ax3 anAx3 (theProjector->Center(), aBackDir, aXpers); |
41 | gp_Trsf aTrsf; |
42 | aTrsf.SetTransformation (anAx3); |
43 | const HLRAlgo_Projector aProj (aTrsf, !theProjector->IsOrthographic(), theProjector->Scale()); |
44 | |
45 | StdPrs_HLRToolShape aTool(theShape, aProj); |
d7223c76 |
46 | Standard_Integer aNbEdges = aTool.NbEdges(); |
47 | Standard_Integer anI; |
48 | Standard_Real anU1, anU2; |
49 | BRepAdaptor_Curve aCurve; |
50 | Standard_Real aDeviation = theDrawer->MaximalChordialDeviation(); |
d6c48921 |
51 | Handle(Graphic3d_Group) aGroup = thePresentation->CurrentGroup(); |
d7223c76 |
52 | |
53 | aGroup->SetPrimitivesAspect(theDrawer->SeenLineAspect()->Aspect()); |
54 | |
55 | Standard_Real anAngle = theDrawer->DeviationAngle(); |
56 | TColgp_SequenceOfPnt aPoints; |
57 | for (anI = 1; anI <= aNbEdges; ++anI) |
58 | { |
59 | for(aTool.InitVisible(anI); aTool.MoreVisible(); aTool.NextVisible()) |
60 | { |
61 | aTool.Visible(aCurve, anU1, anU2); |
62 | StdPrs_DeflectionCurve::Add(thePresentation, aCurve, |
63 | anU1, anU2, aDeviation, aPoints, anAngle); |
64 | } |
65 | } |
66 | |
67 | if(theDrawer->DrawHiddenLine()) |
68 | { |
69 | aGroup->SetPrimitivesAspect(theDrawer->HiddenLineAspect()->Aspect()); |
70 | |
71 | for (anI = 1; anI <= aNbEdges; ++anI) |
72 | { |
73 | for (aTool.InitHidden(anI); aTool.MoreHidden(); aTool.NextHidden()) |
74 | { |
75 | aTool.Hidden(aCurve, anU1, anU2); |
76 | StdPrs_DeflectionCurve::Add(thePresentation, aCurve, |
77 | anU1, anU2, aDeviation, aPoints, anAngle); |
78 | } |
79 | } |
80 | } |
81 | } |