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
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.
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.
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.
23 #include <DsgPrs_FixPresentation.ixx>
25 #include <Graphic3d_Array1OfVertex.hxx>
26 #include <Graphic3d_Group.hxx>
27 #include <Graphic3d_AspectMarker3d.hxx>
28 #include <Graphic3d_AspectLine3d.hxx>
29 #include <Graphic3d_Vertex.hxx>
31 #include <Prs3d_LengthAspect.hxx>
32 #include <Prs3d_LineAspect.hxx>
33 #include <Prs3d_Root.hxx>
35 #include <Aspect_TypeOfLine.hxx>
36 #include <Aspect_TypeOfMarker.hxx>
37 #include <Aspect_AspectMarker.hxx>
44 #include <Quantity_Color.hxx>
49 //=======================================================================
52 //=======================================================================
54 void DsgPrs_FixPresentation::Add(
55 const Handle(Prs3d_Presentation)& aPresentation,
56 const Handle(Prs3d_Drawer)& aDrawer,
57 const gp_Pnt& aPntAttach,
58 const gp_Pnt& aPntEnd,
59 const gp_Dir& aNormPln,
60 const Standard_Real symbsize)
62 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
63 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
65 //Trace du segment de raccordement
66 Graphic3d_Array1OfVertex V(1,2);
67 V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
68 V(2).SetCoord(aPntEnd.X(), aPntEnd.Y(), aPntEnd.Z() );
69 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
71 // trace du symbole 'Fix'
72 Prs3d_Root::NewGroup(aPresentation);
73 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
76 gp_Vec dirac(aPntAttach, aPntEnd);
77 // vecteur directeur du seg. de raccord
79 gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln));
80 gp_Ax1 ax(aPntEnd, aNormPln);
81 norac.Rotate(ax, M_PI/8);
82 // vecteur normal au seg. de raccord
84 gp_Pnt P1 = aPntEnd.Translated(norac);
85 gp_Pnt P2 = aPntEnd.Translated(-norac);
87 V(1).SetCoord(P1.X(),P1.Y(),P1.Z());
88 V(2).SetCoord(P2.X(),P2.Y(),P2.Z());
89 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
93 P1 = aPntEnd.Translated(norac);
94 P2 = aPntEnd.Translated(-norac);
97 gp_Pnt PL = PF.Translated(dirac);
99 V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
100 V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
101 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
104 PL = PF.Translated(dirac);
106 V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
107 V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
108 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
110 PF.SetXYZ((P1.XYZ() + P2.XYZ())/2);
111 PL = PF.Translated(dirac);
113 V(1).SetCoord( PF.X(), PF.Y(), PF.Z() );
114 V(2).SetCoord( PL.X(), PL.Y(), PL.Z() );
115 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
117 // On ajoute un rond au point d'attache
118 Prs3d_Root::NewGroup(aPresentation);
119 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
120 Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
121 MarkerAsp->SetType(Aspect_TOM_BALL);
122 MarkerAsp->SetScale(0.8);
123 Quantity_Color acolor;
124 Aspect_TypeOfLine atype;
125 Standard_Real awidth;
126 LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
127 MarkerAsp->SetColor(acolor);
128 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
129 Graphic3d_Vertex V3d(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
130 Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);