0024162: Eliminate CLang compiler warning
[occt.git] / src / DsgPrs / DsgPrs_FixPresentation.cxx
CommitLineData
b311480e 1// Created on: 1996-04-01
2// Created by: Flore Lantheaume
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21#include <DsgPrs_FixPresentation.ixx>
22
b8ddfc2f 23#include <Graphic3d_ArrayOfSegments.hxx>
7fd59977 24#include <Graphic3d_Group.hxx>
25#include <Graphic3d_AspectMarker3d.hxx>
26#include <Graphic3d_AspectLine3d.hxx>
a577aaab 27#include <Graphic3d_ArrayOfPoints.hxx>
7fd59977 28#include <Graphic3d_Vertex.hxx>
29
30#include <Prs3d_LengthAspect.hxx>
31#include <Prs3d_LineAspect.hxx>
32#include <Prs3d_Root.hxx>
33
34#include <Aspect_TypeOfLine.hxx>
35#include <Aspect_TypeOfMarker.hxx>
36#include <Aspect_AspectMarker.hxx>
37
38#include <gp_Vec.hxx>
39#include <gp_Dir.hxx>
40#include <gp_Pnt.hxx>
41#include <gp_Ax1.hxx>
42
43#include <Quantity_Color.hxx>
44
45
7fd59977 46//=======================================================================
47//function : Add
48//purpose :
49//=======================================================================
50
51void DsgPrs_FixPresentation::Add(
52 const Handle(Prs3d_Presentation)& aPresentation,
53 const Handle(Prs3d_Drawer)& aDrawer,
54 const gp_Pnt& aPntAttach,
55 const gp_Pnt& aPntEnd,
56 const gp_Dir& aNormPln,
57 const Standard_Real symbsize)
58{
59 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
60 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
61
b8ddfc2f 62 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(10);
63
7fd59977 64 //Trace du segment de raccordement
b8ddfc2f 65 aPrims->AddVertex(aPntAttach);
66 aPrims->AddVertex(aPntEnd);
7fd59977 67
68 // trace du symbole 'Fix'
b8ddfc2f 69 gp_Vec dirac(aPntAttach, aPntEnd); // vecteur directeur du seg. de raccord
7fd59977 70 dirac.Normalize();
71 gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln));
72 gp_Ax1 ax(aPntEnd, aNormPln);
b8ddfc2f 73 norac.Rotate(ax, M_PI/8); // vecteur normal au seg. de raccord
7fd59977 74 norac*=(symbsize/2);
75 gp_Pnt P1 = aPntEnd.Translated(norac);
76 gp_Pnt P2 = aPntEnd.Translated(-norac);
77
b8ddfc2f 78 aPrims->AddVertex(P1);
79 aPrims->AddVertex(P2);
7fd59977 80
81 // trace des 'dents'
82 norac*=0.8;
83 P1 = aPntEnd.Translated(norac);
84 P2 = aPntEnd.Translated(-norac);
85 dirac*=(symbsize/2);
b8ddfc2f 86 gp_Pnt PF = P1;
7fd59977 87 gp_Pnt PL = PF.Translated(dirac);
88 PL.Translate(norac);
7fd59977 89
b8ddfc2f 90 aPrims->AddVertex(PF);
91 aPrims->AddVertex(PL);
92
93 PF = P2;
7fd59977 94 PL = PF.Translated(dirac);
95 PL.Translate(norac);
7fd59977 96
b8ddfc2f 97 aPrims->AddVertex(PF);
98 aPrims->AddVertex(PL);
99
100 PF.SetXYZ(0.5*(P1.XYZ() + P2.XYZ()));
7fd59977 101 PL = PF.Translated(dirac);
102 PL.Translate(norac);
b8ddfc2f 103
104 aPrims->AddVertex(PF);
105 aPrims->AddVertex(PL);
106
107 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 108
109 // On ajoute un rond au point d'attache
110 Prs3d_Root::NewGroup(aPresentation);
111 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
a577aaab 112 Quantity_Color aColor;
113 Aspect_TypeOfLine aType;
114 Standard_Real aWidth;
115 LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth);
116 Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0);
117 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp);
118 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
119 anArrayOfPoints->AddVertex (aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
120 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
7fd59977 121}