1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// File: DsgPrs_PerpenPresentation.cxx
// Created: Tue Nov 28 12:15:12 1995
// Author: Jean-Pierre COMBE
// <jpi>
#include <DsgPrs_PerpenPresentation.ixx>
#include <gp_Lin.hxx>
#include <gp_Dir.hxx>
#include <ElCLib.hxx>
#include <gce_MakeLin.hxx>
#include <gce_MakeDir.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <StdPrs_Point.hxx>
void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Prs3d_Drawer)& aDrawer,
const gp_Pnt& pAx1,
const gp_Pnt& pAx2,
const gp_Pnt& pnt1,
const gp_Pnt& pnt2,
const gp_Pnt& OffsetPoint,
const Standard_Boolean intOut1,
const Standard_Boolean intOut2)
{
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
Graphic3d_Array1OfVertex V1(1,2);
Graphic3d_Array1OfVertex V2(1,2);
Quantity_Length X1,Y1,Z1;
Quantity_Length X2,Y2,Z2;
// 1er segment
OffsetPoint.Coord(X1,Y1,Z1);
V1(1).SetCoord(X1,Y1,Z1);
pAx1.Coord(X2,Y2,Z2);
V1(2).SetCoord(X2,Y2,Z2); //ou directt dir1.XYZ
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V1);
Prs3d_Root::NewGroup(aPresentation);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
// 2e segment
pAx2.Coord(X2,Y2,Z2);
V2(1).SetCoord(X1,Y1,Z1);
V2(2).SetCoord(X2,Y2,Z2);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
Prs3d_Root::NewGroup(aPresentation);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
// points attache
Graphic3d_Array1OfVertex V3(1,2);
if (intOut1) {
pAx1.Coord(X1,Y1,Z1);
V3(1).SetCoord(X1,Y1,Z1);
pnt1.Coord(X2,Y2,Z2);
V3(2).SetCoord(X2,Y2,Z2);
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
Prs3d_Root::NewGroup(aPresentation);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
}
if (intOut2) {
pAx2.Coord(X1,Y1,Z1);
V3(1).SetCoord(X1,Y1,Z1);
pnt2.Coord(X2,Y2,Z2);
V3(2).SetCoord(X2,Y2,Z2);
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
Prs3d_Root::NewGroup(aPresentation);
Prs3d_Root::CurrentGroup(aPresentation)->
SetPrimitivesAspect(LA->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
}
// Symbol
Graphic3d_Array1OfVertex V4(1,3);
gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1));
gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2));
Standard_Real dist1(OffsetPoint.Distance(pAx1));
Standard_Real dist2(OffsetPoint.Distance(pAx2));
vec1 *= dist1;
vec1 *= .2;
vec2 *= dist2;
vec2 *= .2;
gp_Pnt pAx11 = OffsetPoint.Translated(vec1);
gp_Pnt pAx22 = OffsetPoint.Translated(vec2);
gp_Pnt p_symb = pAx22.Translated(vec1);
pAx11.Coord(X1,Y1,Z1);
V4(1).SetCoord(X1,Y1,Z1);
p_symb.Coord(X1,Y1,Z1);
V4(2).SetCoord(X1,Y1,Z1);
pAx22.Coord(X1,Y1,Z1);
V4(3).SetCoord(X1,Y1,Z1);
LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V4);
Prs3d_Root::NewGroup(aPresentation);
}
|