Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
20acc9a9
Commit
20acc9a9
authored
Aug 27, 2012
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3D viewer: fix a very minor issue, and more code cleaning.
parent
55429109
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
346 deletions
+187
-346
3d_draw.cpp
3d-viewer/3d_draw.cpp
+39
-55
3d_draw_basic_functions.cpp
3d-viewer/3d_draw_basic_functions.cpp
+109
-269
3d_draw_basic_functions.h
3d-viewer/3d_draw_basic_functions.h
+2
-18
info3d_visu.h
3d-viewer/info3d_visu.h
+37
-4
No files found.
3d-viewer/3d_draw.cpp
View file @
20acc9a9
...
...
@@ -236,9 +236,7 @@ void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
{
int
layer
=
aZone
->
GetLayer
();
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
if
(
layer
==
LAST_COPPER_LAYER
)
layer
=
g_Parm_3D_Visu
.
m_CopperLayersCount
-
1
;
...
...
@@ -532,9 +530,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
{
int
layer
=
segment
->
GetLayer
();
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
SetGLColor
(
color
);
...
...
@@ -633,9 +629,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
s_Text3DWidth
=
text
->
GetThickness
();
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
wxSize
size
=
text
->
m_Size
;
s_thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
s_thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
if
(
text
->
m_Mirror
)
NEGATE
(
size
.
x
);
...
...
@@ -752,15 +746,41 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
int
color
=
g_ColorsSettings
.
GetLayerColor
(
m_Layer
);
SetGLColor
(
color
);
// for outline shape = S_POLYGON:
// We must compute true coordinates from m_PolyPoints
// which are relative to module position and module orientation = 0
std
::
vector
<
CPolyPt
>
polycorners
;
if
(
m_Shape
==
S_POLYGON
)
{
polycorners
.
reserve
(
m_PolyPoints
.
size
()
);
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
CPolyPt
corner
;
for
(
unsigned
ii
=
0
;
ii
<
m_PolyPoints
.
size
();
ii
++
)
{
corner
.
x
=
m_PolyPoints
[
ii
].
x
;
corner
.
y
=
m_PolyPoints
[
ii
].
y
;
RotatePoint
(
&
corner
.
x
,
&
corner
.
y
,
module
->
GetOrientation
()
);
if
(
module
)
{
corner
.
x
+=
module
->
m_Pos
.
x
;
corner
.
y
+=
module
->
m_Pos
.
y
;
}
polycorners
.
push_back
(
corner
);
}
polycorners
.
back
().
end_contour
=
true
;
}
if
(
m_Layer
==
EDGE_N
)
{
for
(
int
layer
=
0
;
layer
<
g_Parm_3D_Visu
.
m_CopperLayersCount
;
layer
++
)
{
glNormal3f
(
0.0
,
0.0
,
(
layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
thickness
=
m_Layer
>=
FIRST_NO_COPPER_LAYER
?
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
m_Layer
);
switch
(
m_Shape
)
{
...
...
@@ -788,26 +808,9 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
break
;
case
S_POLYGON
:
{
// We must compute true coordinates from m_PolyPoints
// which are relative to module position and module orientation = 0
std
::
vector
<
wxPoint
>
points
=
m_PolyPoints
;
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
if
(
module
==
NULL
)
break
;
for
(
unsigned
ii
=
0
;
ii
<
points
.
size
();
ii
++
)
{
wxPoint
&
pt
=
points
[
ii
];
RotatePoint
(
&
pt
.
x
,
&
pt
.
y
,
module
->
GetOrientation
()
);
pt
+=
module
->
m_Pos
;
}
Draw3D_HorizontalPolygon
(
points
,
zpos
,
0
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
break
;
Draw3D_SolidHorizontalPolyPolygons
(
polycorners
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
break
;
default
:
D
(
printf
(
"Error: Shape nr %d not implemented!
\n
"
,
m_Shape
);
)
...
...
@@ -817,9 +820,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
}
else
{
int
thickness
=
m_Layer
>=
FIRST_NO_COPPER_LAYER
?
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
m_Layer
);
glNormal3f
(
0.0
,
0.0
,
(
m_Layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
m_Layer
);
...
...
@@ -849,26 +850,9 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
break
;
case
S_POLYGON
:
{
// We must compute true coordinates from m_PolyPoints
// which are relative to module position and module orientation = 0
std
::
vector
<
wxPoint
>
points
=
m_PolyPoints
;
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
if
(
module
==
NULL
)
break
;
for
(
unsigned
ii
=
0
;
ii
<
points
.
size
();
ii
++
)
{
wxPoint
&
pt
=
points
[
ii
];
RotatePoint
(
&
pt
.
x
,
&
pt
.
y
,
module
->
GetOrientation
()
);
pt
+=
module
->
m_Pos
;
}
Draw3D_HorizontalPolygon
(
points
,
zpos
,
0
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
break
;
Draw3D_SolidHorizontalPolyPolygons
(
polycorners
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
break
;
default
:
D
(
printf
(
"Error: Shape nr %d not implemented!
\n
"
,
m_Shape
);
)
...
...
3d-viewer/3d_draw_basic_functions.cpp
View file @
20acc9a9
...
...
@@ -51,17 +51,55 @@ static void CALLBACK tessBeginCB( GLenum which );
static
void
CALLBACK
tessEndCB
();
static
void
CALLBACK
tessErrorCB
(
GLenum
errorCode
);
static
void
CALLBACK
tessCPolyPt2Vertex
(
const
GLvoid
*
data
);
static
void
CALLBACK
tesswxPoint2Vertex
(
const
GLvoid
*
data
);
/** draw a ring using 3D primitives, in a plane parallel to the XY plane
* @param aCenterPos = position of the center (Board internal units)
* @param aOuterRadius = radius of the external circle (Board internal units)
* @param aInnerRadius = radius of the circle (Board internal units)
* @param aZpos = z position in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
/* Draw3D_VerticalPolygonalCylinder is a helper function.
*
* draws a "vertical cylinder" having a polygon shape
* from Z position = aZpos to aZpos + aHeight
* Used to create the vertical sides of 3D horizontal shapes with thickness.
*/
static
void
Draw3D_FlatRing
(
wxPoint
aCenterPos
,
int
aOuterRadius
,
int
aInnerRadius
,
int
aZpos
,
double
aBiuTo3DUnits
);
static
void
Draw3D_VerticalPolygonalCylinder
(
const
std
::
vector
<
CPolyPt
>&
aPolysList
,
int
aHeight
,
int
aZpos
,
double
aBiuTo3DUnits
)
{
if
(
aHeight
==
0
)
return
;
std
::
vector
<
S3D_VERTEX
>
coords
;
coords
.
resize
(
4
);
// Init Z position of the 4 points of a GL_QUAD
coords
[
0
].
z
=
aZpos
;
coords
[
1
].
z
=
aZpos
+
aHeight
;
coords
[
2
].
z
=
coords
[
1
].
z
;
coords
[
3
].
z
=
coords
[
0
].
z
;
// Draw the vertical polygonal side
int
startContour
=
0
;
for
(
unsigned
ii
=
0
;
ii
<
aPolysList
.
size
();
ii
++
)
{
unsigned
jj
=
ii
+
1
;
if
(
aPolysList
[
ii
].
end_contour
||
jj
>=
aPolysList
.
size
()
)
{
jj
=
startContour
;
startContour
=
ii
+
1
;
}
// Build the 4 vertices of each GL_QUAD
coords
[
0
].
x
=
aPolysList
[
jj
].
x
;
coords
[
0
].
y
=
-
aPolysList
[
jj
].
y
;
coords
[
1
].
x
=
coords
[
0
].
x
;
coords
[
1
].
y
=
coords
[
0
].
y
;
// only z change
coords
[
2
].
x
=
aPolysList
[
ii
].
x
;
coords
[
2
].
y
=
-
aPolysList
[
ii
].
y
;
coords
[
3
].
x
=
coords
[
2
].
x
;
coords
[
3
].
y
=
coords
[
2
].
y
;
// only z change
// Creates the GL_QUAD
Set_Object_Data
(
coords
,
aBiuTo3DUnits
);
}
}
void
SetGLColor
(
int
color
)
...
...
@@ -80,7 +118,7 @@ void SetGLColor( int color )
* aZpos = z position in board internal units
* aThickness = thickness in board internal units
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness
1
0, a solid object is drawn.
* If aThickness
>
0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
...
...
@@ -153,37 +191,8 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,
if
(
aThickness
==
0
)
return
;
// Build the 3D data : vertical sides
std
::
vector
<
S3D_VERTEX
>
vertices
;
vertices
.
resize
(
4
);
vertices
[
0
].
z
=
aZpos
+
(
aThickness
/
2
);
vertices
[
1
].
z
=
aZpos
-
(
aThickness
/
2
);
vertices
[
2
].
z
=
vertices
[
1
].
z
;
vertices
[
3
].
z
=
vertices
[
0
].
z
;
int
startContour
=
0
;
for
(
unsigned
ii
=
0
;
ii
<
polylist
.
size
();
ii
++
)
{
int
jj
=
ii
+
1
;
if
(
polylist
[
ii
].
end_contour
==
1
)
{
jj
=
startContour
;
startContour
=
ii
+
1
;
}
vertices
[
0
].
x
=
polylist
[
ii
].
x
;
vertices
[
0
].
y
=
-
polylist
[
ii
].
y
;
vertices
[
1
].
x
=
vertices
[
0
].
x
;
vertices
[
1
].
y
=
vertices
[
0
].
y
;
// Z only changes.
vertices
[
2
].
x
=
polylist
[
jj
].
x
;
vertices
[
2
].
y
=
-
polylist
[
jj
].
y
;
vertices
[
3
].
x
=
vertices
[
2
].
x
;
vertices
[
3
].
y
=
vertices
[
2
].
y
;
// Z only changes.
Set_Object_Data
(
vertices
,
aBiuTo3DUnits
);
}
// Build the 3D data : vertical side
Draw3D_VerticalPolygonalCylinder
(
polylist
,
aThickness
,
aZpos
,
aBiuTo3DUnits
);
glNormal3f
(
0.0
,
0.0
,
1.0
);
}
...
...
@@ -221,82 +230,39 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
std
::
vector
<
S3D_VERTEX
>
coords
;
coords
.
resize
(
4
);
std
::
vector
<
CPolyPt
>
inner_cornerBuffer
;
if
(
aThickness
)
// build the the vertical inner polygon (hole)
TransformCircleToPolygon
(
inner_cornerBuffer
,
aCenterPos
,
aRadius
-
(
aThickness
/
2
),
slice
);
if
(
aHeight
)
{
// Draw the outer vertical side
// Init Z position of the 4 points of a GL_QUAD
coords
[
0
].
z
=
aZpos
;
coords
[
1
].
z
=
aZpos
+
aHeight
;
coords
[
2
].
z
=
coords
[
1
].
z
;
coords
[
3
].
z
=
coords
[
0
].
z
;
for
(
unsigned
ii
=
0
;
ii
<
outer_cornerBuffer
.
size
();
ii
++
)
{
unsigned
jj
=
ii
+
1
;
if
(
jj
>=
outer_cornerBuffer
.
size
()
)
jj
=
0
;
// Build the 4 vertices of each GL_QUAD
coords
[
0
].
x
=
outer_cornerBuffer
[
jj
].
x
;
coords
[
0
].
y
=
-
outer_cornerBuffer
[
jj
].
y
;
coords
[
1
].
x
=
coords
[
0
].
x
;
coords
[
1
].
y
=
coords
[
0
].
y
;
// only z change
coords
[
2
].
x
=
outer_cornerBuffer
[
ii
].
x
;
coords
[
2
].
y
=
-
outer_cornerBuffer
[
ii
].
y
;
coords
[
3
].
x
=
coords
[
2
].
x
;
coords
[
3
].
y
=
coords
[
2
].
y
;
// only z change
// Creates the GL_QUAD
Set_Object_Data
(
coords
,
aBiuTo3DUnits
);
}
glNormal3f
(
0.0
,
0.0
,
1.0
);
// Normal is Z axis
// Draw the vertical outer side
Draw3D_VerticalPolygonalCylinder
(
outer_cornerBuffer
,
aHeight
,
aZpos
,
aBiuTo3DUnits
);
if
(
aThickness
)
// Draws the vertical inner side (hole)
Draw3D_VerticalPolygonalCylinder
(
inner_cornerBuffer
,
aHeight
,
aZpos
,
aBiuTo3DUnits
);
}
if
(
aThickness
==
0
)
return
;
// draw top (front) and bottom (back) horizontal sides (rings)
S3D_VERTEX
centerPos
;
centerPos
.
x
=
aCenterPos
.
x
*
aBiuTo3DUnits
;
centerPos
.
y
=
-
aCenterPos
.
y
*
aBiuTo3DUnits
;
Draw3D_FlatRing
(
aCenterPos
,
aRadius
+
aThickness
/
2
,
aRadius
-
aThickness
/
2
,
aZpos
+
aHeight
,
aBiuTo3DUnits
);
glNormal3f
(
0.0
,
0.0
,
-
1.0
);
Draw3D_FlatRing
(
aCenterPos
,
aRadius
+
aThickness
/
2
,
aRadius
-
aThickness
/
2
,
aZpos
,
aBiuTo3DUnits
);
if
(
aHeight
)
if
(
aThickness
)
{
// Draws the vertical inner side (hole)
std
::
vector
<
CPolyPt
>
inner_cornerBuffer
;
TransformCircleToPolygon
(
inner_cornerBuffer
,
aCenterPos
,
aRadius
-
(
aThickness
/
2
),
slice
);
// draw top (front) and bottom (back) horizontal sides (rings)
glNormal3f
(
0.0
,
0.0
,
1.0
);
outer_cornerBuffer
.
insert
(
outer_cornerBuffer
.
end
(),
inner_cornerBuffer
.
begin
(),
inner_cornerBuffer
.
end
()
);
std
::
vector
<
CPolyPt
>
polygon
;
for
(
unsigned
ii
=
0
;
ii
<
inner_cornerBuffer
.
size
();
ii
++
)
ConvertPolysListWithHolesToOnePolygon
(
outer_cornerBuffer
,
polygon
);
// draw top (front) horizontal ring
Draw3D_SolidHorizontalPolyPolygons
(
polygon
,
aZpos
+
aHeight
,
0
,
aBiuTo3DUnits
);
if
(
aHeight
)
{
unsigned
jj
=
ii
+
1
;
if
(
jj
>=
inner_cornerBuffer
.
size
()
)
jj
=
0
;
// Build the 4 vertices of each GL_QUAD
coords
[
0
].
x
=
inner_cornerBuffer
[
ii
].
x
;
coords
[
0
].
y
=
-
inner_cornerBuffer
[
ii
].
y
;
coords
[
1
].
x
=
coords
[
0
].
x
;
coords
[
1
].
y
=
coords
[
0
].
y
;
// only z change
coords
[
2
].
x
=
inner_cornerBuffer
[
jj
].
x
;
coords
[
2
].
y
=
-
inner_cornerBuffer
[
jj
].
y
;
coords
[
3
].
x
=
coords
[
2
].
x
;
coords
[
3
].
y
=
coords
[
2
].
y
;
// only z change
Set_Object_Data
(
coords
,
aBiuTo3DUnits
);
// draw bottom (back) horizontal ring
glNormal3f
(
0.0
,
0.0
,
-
1.0
);
Draw3D_SolidHorizontalPolyPolygons
(
polygon
,
aZpos
,
0
,
aBiuTo3DUnits
);
}
}
...
...
@@ -308,6 +274,8 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
* Function Draw3D_ZaxisOblongCylinder:
* draw a segment with an oblong hole.
* Used to draw oblong holes
* If aHeight = height of the cylinder is 0, only one ring will be drawn
* If aThickness = 0, only one cylinder will be drawn
*/
void
Draw3D_ZaxisOblongCylinder
(
wxPoint
aAxis1Pos
,
wxPoint
aAxis2Pos
,
int
aRadius
,
int
aHeight
,
int
aThickness
,
...
...
@@ -316,39 +284,43 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
const
int
slice
=
SEGM_PER_CIRCLE
;
// Build the points to approximate oblong cylinder by segments
std
::
vector
<
CPolyPt
>
cornerBuffer
;
TransformRoundedEndsSegmentToPolygon
(
cornerBuffer
,
aAxis1Pos
,
aAxis2Pos
,
slice
,
aRadius
*
2
);
std
::
vector
<
CPolyPt
>
outer_cornerBuffer
;
// Draw the cylinder
std
::
vector
<
S3D_VERTEX
>
coords
;
coords
.
resize
(
4
);
int
width
=
aThickness
+
aRadius
*
2
;
TransformRoundedEndsSegmentToPolygon
(
outer_cornerBuffer
,
aAxis1Pos
,
aAxis2Pos
,
slice
,
width
);
// Init Z position of the 4 points of a GL_QUAD
coords
[
0
].
z
=
aZpos
;
coords
[
1
].
z
=
aZpos
+
aHeight
;
coords
[
2
].
z
=
coords
[
1
].
z
;
coords
[
3
].
z
=
coords
[
0
].
z
;
// Draw the oblong outer cylinder
if
(
aHeight
)
Draw3D_VerticalPolygonalCylinder
(
outer_cornerBuffer
,
aHeight
,
aZpos
,
aBiuTo3DUnits
);
for
(
unsigned
ii
=
0
;
ii
<
cornerBuffer
.
size
();
ii
++
)
if
(
aThickness
)
{
unsigned
jj
=
ii
+
1
;
std
::
vector
<
CPolyPt
>
inner_cornerBuffer
;
width
=
aThickness
-
aRadius
*
2
;
TransformRoundedEndsSegmentToPolygon
(
inner_cornerBuffer
,
aAxis1Pos
,
aAxis2Pos
,
slice
,
width
);
if
(
jj
>=
cornerBuffer
.
size
()
)
jj
=
0
;
// Draw the oblong inner cylinder
if
(
aHeight
)
Draw3D_VerticalPolygonalCylinder
(
inner_cornerBuffer
,
aHeight
,
aZpos
,
aBiuTo3DUnits
);
// Build the 4 vertices of each GL_QUAD
coords
[
0
].
x
=
cornerBuffer
[
ii
].
x
;
coords
[
0
].
y
=
-
cornerBuffer
[
ii
].
y
;
coords
[
1
].
x
=
coords
[
0
].
x
;
coords
[
1
].
y
=
coords
[
0
].
y
;
// only z change
coords
[
2
].
x
=
cornerBuffer
[
jj
].
x
;
coords
[
2
].
y
=
-
cornerBuffer
[
jj
].
y
;
coords
[
3
].
x
=
coords
[
2
].
x
;
coords
[
3
].
y
=
coords
[
2
].
y
;
// only z change
// draw top (front) horizontal side (ring)
outer_cornerBuffer
.
insert
(
outer_cornerBuffer
.
end
(),
inner_cornerBuffer
.
begin
(),
inner_cornerBuffer
.
end
()
);
std
::
vector
<
CPolyPt
>
polygon
;
Set_Object_Data
(
coords
,
aBiuTo3DUnits
);
ConvertPolysListWithHolesToOnePolygon
(
outer_cornerBuffer
,
polygon
);
glNormal3f
(
0.0
,
0.0
,
1.0
);
Draw3D_SolidHorizontalPolyPolygons
(
polygon
,
aZpos
+
aHeight
,
0
,
aBiuTo3DUnits
);
if
(
aHeight
)
{
// draw bottom (back) horizontal side (ring)
glNormal3f
(
0.0
,
0.0
,
-
1.0
);
Draw3D_SolidHorizontalPolyPolygons
(
polygon
,
aZpos
,
0
,
aBiuTo3DUnits
);
}
}
glNormal3f
(
0.0
,
0.0
,
1.0
);
// Normal is Z axis
...
...
@@ -388,128 +360,6 @@ void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint,
}
/** draw a ring using 3D primitives, in a plane parallel to the XY plane
* @param aCenterPos = position of the center (Board internal units)
* @param aOuterRadius = radius of the external circle (Board internal units)
* @param aInnerRadius = radius of the circle (Board internal units)
* @param aZpos = z position in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
*/
void
Draw3D_FlatRing
(
wxPoint
aCenterPos
,
int
aOuterRadius
,
int
aInnerRadius
,
int
aZpos
,
double
aBiuTo3DUnits
)
{
const
int
slice
=
SEGM_PER_CIRCLE
;
const
int
rot_angle
=
ANGLE_INC
(
slice
);
double
cposx
=
aCenterPos
.
x
*
aBiuTo3DUnits
;
double
cposy
=
-
aCenterPos
.
y
*
aBiuTo3DUnits
;
glBegin
(
GL_QUAD_STRIP
);
double
zpos
=
aZpos
*
aBiuTo3DUnits
;
for
(
int
ii
=
0
;
ii
<=
slice
;
ii
++
)
{
double
x
=
aInnerRadius
*
aBiuTo3DUnits
;
double
y
=
0.0
;
RotatePoint
(
&
x
,
&
y
,
ii
*
rot_angle
);
glVertex3f
(
x
+
cposx
,
y
+
cposy
,
zpos
);
x
=
aOuterRadius
*
aBiuTo3DUnits
;
y
=
0.0
;
RotatePoint
(
&
x
,
&
y
,
ii
*
rot_angle
);
glVertex3f
(
x
+
cposx
,
y
+
cposy
,
zpos
);
}
glEnd
();
}
/* draw one solid polygon
* aCornersList = a std::vector<wxPoint> list of corners, in board internal units
* aZpos = z position in board internal units
* aThickness = thickness in board internal units
* aIu_to_3Dunits = board internal units to 3D units scaling value
*/
void
Draw3D_HorizontalPolygon
(
std
::
vector
<
wxPoint
>&
aCornersList
,
int
aZpos
,
int
aThickness
,
double
aBiuTo3DUnits
)
{
GLUtesselator
*
tess
=
gluNewTess
();
gluTessCallback
(
tess
,
GLU_TESS_BEGIN
,
(
void
(
CALLBACK
*
)
()
)
tessBeginCB
);
gluTessCallback
(
tess
,
GLU_TESS_END
,
(
void
(
CALLBACK
*
)
()
)
tessEndCB
);
gluTessCallback
(
tess
,
GLU_TESS_ERROR
,
(
void
(
CALLBACK
*
)
()
)
tessErrorCB
);
gluTessCallback
(
tess
,
GLU_TESS_VERTEX
,
(
void
(
CALLBACK
*
)
()
)
tesswxPoint2Vertex
);
GLdouble
v_data
[
3
];
v_data
[
2
]
=
(
aZpos
+
(
aThickness
/
2
)
)
*
aBiuTo3DUnits
;
g_Parm_3D_Visu
.
m_CurrentZpos
=
v_data
[
2
];
// gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
// Draw solid polygon
if
(
aThickness
)
glNormal3f
(
0.0
,
0.0
,
1.0
);
for
(
int
side
=
0
;
side
<
2
;
side
++
)
{
gluTessBeginPolygon
(
tess
,
NULL
);
gluTessBeginContour
(
tess
);
for
(
unsigned
ii
=
0
;
ii
<
aCornersList
.
size
();
ii
++
)
{
v_data
[
0
]
=
aCornersList
[
ii
].
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
v_data
[
1
]
=
-
aCornersList
[
ii
].
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
// gluTessVertex store pointers on data, not data, so do not store
// different corners values in a temporary variable
// but send pointer on each corner value in aCornersList
gluTessVertex
(
tess
,
v_data
,
&
aCornersList
[
ii
]
);
}
gluTessEndContour
(
tess
);
gluTessEndPolygon
(
tess
);
if
(
aThickness
==
0
)
break
;
glNormal3f
(
0.0
,
0.0
,
-
1.0
);
v_data
[
2
]
=
(
aZpos
-
(
aThickness
/
2
)
)
*
aBiuTo3DUnits
;
g_Parm_3D_Visu
.
m_CurrentZpos
=
v_data
[
2
];
}
gluDeleteTess
(
tess
);
if
(
aThickness
==
0
)
return
;
// Build the 3D data : vertical sides
std
::
vector
<
S3D_VERTEX
>
vertices
;
vertices
.
resize
(
4
);
vertices
[
0
].
z
=
aZpos
+
(
aThickness
/
2
);
vertices
[
1
].
z
=
aZpos
-
(
aThickness
/
2
);
vertices
[
2
].
z
=
vertices
[
1
].
z
;
vertices
[
3
].
z
=
vertices
[
0
].
z
;
for
(
unsigned
ii
=
0
;
ii
<
aCornersList
.
size
();
ii
++
)
{
unsigned
jj
=
ii
+
1
;
if
(
jj
>=
aCornersList
.
size
()
)
jj
=
0
;
vertices
[
0
].
x
=
aCornersList
[
ii
].
x
;
vertices
[
0
].
y
=
-
aCornersList
[
ii
].
y
;
vertices
[
1
].
x
=
vertices
[
0
].
x
;
vertices
[
1
].
y
=
vertices
[
0
].
y
;
// Z only changes.
vertices
[
2
].
x
=
aCornersList
[
jj
].
x
;
vertices
[
2
].
y
=
-
aCornersList
[
jj
].
y
;
vertices
[
3
].
x
=
vertices
[
2
].
x
;
vertices
[
3
].
y
=
vertices
[
2
].
y
;
// Z only changes.
Set_Object_Data
(
vertices
,
aBiuTo3DUnits
);
}
}
// /////////////////////////////////////////////////////////////////////////////
// GLU_TESS CALLBACKS
// /////////////////////////////////////////////////////////////////////////////
...
...
@@ -537,16 +387,6 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
}
void
CALLBACK
tesswxPoint2Vertex
(
const
GLvoid
*
data
)
{
const
wxPoint
*
ptr
=
(
const
wxPoint
*
)
data
;
glVertex3f
(
ptr
->
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
-
ptr
->
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
g_Parm_3D_Visu
.
m_CurrentZpos
);
}
void
CALLBACK
tessErrorCB
(
GLenum
errorCode
)
{
#if defined(DEBUG)
...
...
3d-viewer/3d_draw_basic_functions.h
View file @
20acc9a9
...
...
@@ -31,22 +31,6 @@
// angle increment to draw a circle, approximated by segments
#define ANGLE_INC( x ) ( 3600 / (x) )
/**
* Function Draw3D_HorizontalPolygon
* draw one solid polygon
* @param aCornersList = a std::vector<wxPoint> list of corners, in board internal units
* @param aZpos = z position in board internal units
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness 1 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void
Draw3D_HorizontalPolygon
(
std
::
vector
<
wxPoint
>&
aCornersList
,
int
aZpos
,
int
aThickness
,
double
aBiuTo3DUnits
);
/** draw all solid polygons found in aPolysList
* @param aPolysList = the poligon list to draw
* @param aZpos = z position in board internal units
...
...
@@ -67,7 +51,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness
1
0, a solid object is drawn.
* If aThickness
>
0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
...
...
@@ -82,7 +66,7 @@ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPol
* @param aZpos = z position of segment in board units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness
1
0, a solid object is drawn.
* If aThickness
>
0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
...
...
3d-viewer/info3d_visu.h
View file @
20acc9a9
...
...
@@ -109,15 +109,23 @@ public: INFO3D_VISU();
void
InitSettings
(
BOARD
*
aBoard
);
/**
* function
m_BiuTo3Dunits
* function
GetLayerZcoordBIU
* @return the Z coordinate of the layer aLayer, in Board Internal Units
* @param aLayer: the layer number
* @param aLayer
Id
: the layer number
*/
int
GetLayerZcoordBIU
(
int
aLayer
)
int
GetLayerZcoordBIU
(
int
aLayer
Id
)
{
return
(
int
)
(
m_LayerZcoord
[
aLayer
]
/
m_BiuTo3Dunits
);
return
(
int
)
(
m_LayerZcoord
[
aLayer
Id
]
/
m_BiuTo3Dunits
);
}
/**
* function GetCopperThicknessBIU
* @return the thickness (Z size) of the copper, in Board Internal Units
* note: the thickness (Z size) of the copper is not the thickness
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int
GetCopperThicknessBIU
()
const
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
...
...
@@ -125,17 +133,42 @@ public: INFO3D_VISU();
:
0
;
}
/**
* function GetEpoxyThicknessBIU
* @return the thickness (Z size) of the epoxy board, in Board Internal Units
*/
int
GetEpoxyThicknessBIU
()
const
{
return
(
int
)
(
m_EpoxyThickness
/
m_BiuTo3Dunits
);
}
/**
* function GetNonCopperLayerThicknessBIU
* @return the thickness (Z size) of a technical layer,
* in Board Internal Units
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int
GetNonCopperLayerThicknessBIU
()
const
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
(
int
)
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
:
0
;
}
/**
* function GetNonCopperLayerThicknessBIU
* @return the thickness (Z size) of the copper or a technical layer,
* in Board Internal Units, depending on the layer id
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int
GetLayerObjectThicknessBIU
(
int
aLayerId
)
const
{
return
aLayerId
>=
FIRST_NO_COPPER_LAYER
?
GetNonCopperLayerThicknessBIU
()
:
GetCopperThicknessBIU
();
}
};
extern
INFO3D_VISU
g_Parm_3D_Visu
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment