0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
42cf5bc1 17#include <DsgPrs_FixPresentation.hxx>
b6472664 18
42cf5bc1 19#include <gp_Ax1.hxx>
20#include <gp_Dir.hxx>
21#include <gp_Pnt.hxx>
22#include <gp_Vec.hxx>
23#include <Graphic3d_ArrayOfPoints.hxx>
b8ddfc2f 24#include <Graphic3d_ArrayOfSegments.hxx>
7fd59977 25#include <Graphic3d_AspectLine3d.hxx>
42cf5bc1 26#include <Graphic3d_AspectMarker3d.hxx>
27#include <Graphic3d_Group.hxx>
a6eb515f 28#include <Prs3d_DimensionAspect.hxx>
7fd59977 29#include <Prs3d_LineAspect.hxx>
42cf5bc1 30#include <Prs3d_Presentation.hxx>
7fd59977 31
7fd59977 32//=======================================================================
33//function : Add
34//purpose :
35//=======================================================================
7fd59977 36void DsgPrs_FixPresentation::Add(
37 const Handle(Prs3d_Presentation)& aPresentation,
38 const Handle(Prs3d_Drawer)& aDrawer,
39 const gp_Pnt& aPntAttach,
40 const gp_Pnt& aPntEnd,
41 const gp_Dir& aNormPln,
42 const Standard_Real symbsize)
43{
a6eb515f 44 Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
d6c48921 45 aPresentation->CurrentGroup()->SetPrimitivesAspect(LA->LineAspect()->Aspect());
7fd59977 46
b8ddfc2f 47 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(10);
48
7fd59977 49 //Trace du segment de raccordement
b8ddfc2f 50 aPrims->AddVertex(aPntAttach);
51 aPrims->AddVertex(aPntEnd);
7fd59977 52
53 // trace du symbole 'Fix'
b8ddfc2f 54 gp_Vec dirac(aPntAttach, aPntEnd); // vecteur directeur du seg. de raccord
7fd59977 55 dirac.Normalize();
56 gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln));
57 gp_Ax1 ax(aPntEnd, aNormPln);
b8ddfc2f 58 norac.Rotate(ax, M_PI/8); // vecteur normal au seg. de raccord
7fd59977 59 norac*=(symbsize/2);
60 gp_Pnt P1 = aPntEnd.Translated(norac);
61 gp_Pnt P2 = aPntEnd.Translated(-norac);
62
b8ddfc2f 63 aPrims->AddVertex(P1);
64 aPrims->AddVertex(P2);
7fd59977 65
66 // trace des 'dents'
67 norac*=0.8;
68 P1 = aPntEnd.Translated(norac);
69 P2 = aPntEnd.Translated(-norac);
70 dirac*=(symbsize/2);
b8ddfc2f 71 gp_Pnt PF = P1;
7fd59977 72 gp_Pnt PL = PF.Translated(dirac);
73 PL.Translate(norac);
7fd59977 74
b8ddfc2f 75 aPrims->AddVertex(PF);
76 aPrims->AddVertex(PL);
77
78 PF = P2;
7fd59977 79 PL = PF.Translated(dirac);
80 PL.Translate(norac);
7fd59977 81
b8ddfc2f 82 aPrims->AddVertex(PF);
83 aPrims->AddVertex(PL);
84
85 PF.SetXYZ(0.5*(P1.XYZ() + P2.XYZ()));
7fd59977 86 PL = PF.Translated(dirac);
87 PL.Translate(norac);
b8ddfc2f 88
89 aPrims->AddVertex(PF);
90 aPrims->AddVertex(PL);
91
d6c48921 92 aPresentation->CurrentGroup()->AddPrimitiveArray(aPrims);
7fd59977 93
d6c48921 94 aPresentation->NewGroup();
95 aPresentation->CurrentGroup()->SetPrimitivesAspect(LA->LineAspect()->Aspect());
b6472664 96 Quantity_Color aColor = LA->LineAspect()->Aspect()->Color();
a577aaab 97 Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0);
d6c48921 98 aPresentation->CurrentGroup()->SetPrimitivesAspect (aMarkerAsp);
a577aaab 99 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
100 anArrayOfPoints->AddVertex (aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
d6c48921 101 aPresentation->CurrentGroup()->AddPrimitiveArray (anArrayOfPoints);
7fd59977 102}