summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_GraphicDriver_5.cxx
blob: 2f62b4cf57bfe80586e2cae71cd07e4a3b204265 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147


// File   OpenGl_GraphicDriver_5.cxx
// Created  Mardi 28 janvier 1997
// Author CAL

//-Copyright  MatraDatavision 1997

//-Version  

//-Design Declaration des variables specifiques aux Drivers

//-Warning  Un driver encapsule les Pex et OpenGl drivers

//-References 

//-Language C++ 2.0

//-Declarations

// for the class
#include <OpenGl_GraphicDriver.jxx>

#include <Aspect_DriverDefinitionError.hxx>

#include <OpenGl_tgl_funcs.hxx>

//-Aliases

//-Global data definitions

//-Methods, in order

void OpenGl_GraphicDriver::DumpGroup (const Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_structure_exploration");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_structure_exploration
    (long (MyCGroup.Struct->Id), long (MyCGroup.LabelBegin), long (MyCGroup.LabelEnd));

}

void OpenGl_GraphicDriver::DumpStructure (const Graphic3d_CStructure& ACStructure) {

  Graphic3d_CStructure MyCStructure = ACStructure;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_structure_exploration");
    PrintCStructure (MyCStructure, 1);
  }
  call_togl_structure_exploration (long (MyCStructure.Id), 0, 0);

}

void OpenGl_GraphicDriver::DumpView (const Graphic3d_CView& ACView) {

  Graphic3d_CView MyCView = ACView;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_view_exploration");
    PrintCView (MyCView, 1);
  }
  call_togl_view_exploration (long (MyCView.ViewId));

}

Standard_Boolean OpenGl_GraphicDriver::ElementExploration (const Graphic3d_CStructure & ACStructure, const Standard_Integer ElementNumber, Graphic3d_VertexNC& AVertex, Graphic3d_Vector& AVector) {

  Graphic3d_CStructure MyCStructure = ACStructure;

  Quantity_Color AColor;
  long AType;

  CALL_DEF_POINT Pt;
  CALL_DEF_NORMAL Npt, Nfa;
  CALL_DEF_COLOR Cpt;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_element_exploration");
    PrintCStructure (MyCStructure, 1);
  }
  call_togl_element_exploration (MyCStructure.Id, ElementNumber, &AType, &Pt, &Npt, &Cpt, &Nfa);

  if (! AType) return (Standard_False);
  else {
    AVertex.SetCoord
      (double (Pt.x), double (Pt.y), double (Pt.z));
    AVertex.SetNormal
      (double (Npt.dx), double (Npt.dy), double (Npt.dz));
    AColor.SetValues
      (double (Cpt.r), double (Cpt.g),
      double (Cpt.b), Quantity_TOC_RGB);
    AVertex.SetColor (AColor);
    AVector.SetCoord
      (double (Nfa.dx), double (Nfa.dy), double (Nfa.dz));
    return (Standard_True);
  }
}

Graphic3d_TypeOfPrimitive OpenGl_GraphicDriver::ElementType (const Graphic3d_CStructure & ACStructure, const Standard_Integer ElementNumber) {

  Graphic3d_CStructure MyCStructure = ACStructure;

  long AType;
  Graphic3d_TypeOfPrimitive top;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_element_type");
    PrintCStructure (MyCStructure, 1);
  }
  call_togl_element_type (MyCStructure.Id, ElementNumber, &AType);

  switch (AType) {

    case 0:
      top = Graphic3d_TOP_UNDEFINED;
      break;
    case 1:
      top = Graphic3d_TOP_POLYLINE;
      break;
    case 2:
      top = Graphic3d_TOP_POLYGON;
      break;
    case 3:
      top = Graphic3d_TOP_TRIANGLEMESH;
      break;
    case 4:
      top = Graphic3d_TOP_QUADRANGLEMESH;
      break;
    case 5:
      top = Graphic3d_TOP_TEXT;
      break;
    case 6:
      top = Graphic3d_TOP_MARKER;
      break;
    default:
      top = Graphic3d_TOP_UNDEFINED;
      break;

  }

  return (top);
}