KiCad PCB EDA Suite
raytracing/create_scene.cpp File Reference

Go to the source code of this file.

Macros

#define UNITS3D_TO_UNITSPCB   ( IU_PER_MM )
 Scale conversion from 3d model units to pcb units. More...
 

Functions

static float TransparencyControl (float aGrayColorValue, float aTransparency)
 Perform an interpolation step to easy control the transparency based on the gray color value and transparency. More...
 
void buildBoardBoundingBoxPoly (const BOARD *aBoard, SHAPE_POLY_SET &aOutline)
 Get the complete bounding box of the board (including all items). More...
 

Macro Definition Documentation

◆ UNITS3D_TO_UNITSPCB

#define UNITS3D_TO_UNITSPCB   ( IU_PER_MM )

Scale conversion from 3d model units to pcb units.

Definition at line 68 of file raytracing/create_scene.cpp.

Function Documentation

◆ buildBoardBoundingBoxPoly()

void buildBoardBoundingBoxPoly ( const BOARD aBoard,
SHAPE_POLY_SET aOutline 
)

Get the complete bounding box of the board (including all items).

The vertex numbers and segment numbers of the rectangle returned. 1 ------------— |1 2| 0| |2 |0 3| ------------— 3

Definition at line 920 of file convert_shape_list_to_polygon.cpp.

921 {
922  EDA_RECT bbbox = aBoard->GetBoundingBox();
923  SHAPE_LINE_CHAIN chain;
924 
925  // If null area, uses the global bounding box.
926  if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
927  bbbox = aBoard->ComputeBoundingBox();
928 
929  // Ensure non null area. If happen, gives a minimal size.
930  if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
931  bbbox.Inflate( Millimeter2iu( 1.0 ) );
932 
933  // Inflate slightly (by 1/10th the size of the box)
934  bbbox.Inflate( bbbox.GetWidth() / 10, bbbox.GetHeight() / 10 );
935 
936  chain.Append( bbbox.GetOrigin() );
937  chain.Append( bbbox.GetOrigin().x, bbbox.GetEnd().y );
938  chain.Append( bbbox.GetEnd() );
939  chain.Append( bbbox.GetEnd().x, bbbox.GetOrigin().y );
940  chain.SetClosed( true );
941 
942  aOutline.RemoveAllContours();
943  aOutline.AddOutline( chain );
944 }
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:724
int GetWidth() const
Definition: eda_rect.h:109
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const wxPoint GetEnd() const
Definition: eda_rect.h:103
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
const wxPoint GetOrigin() const
Definition: eda_rect.h:101
int GetHeight() const
Definition: eda_rect.h:110
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1082
static constexpr int Millimeter2iu(double mm)
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), BOARD::ComputeBoundingBox(), BOARD::GetBoundingBox(), EDA_RECT::GetEnd(), EDA_RECT::GetHeight(), EDA_RECT::GetOrigin(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), Millimeter2iu(), SHAPE_POLY_SET::RemoveAllContours(), and SHAPE_LINE_CHAIN::SetClosed().

Referenced by BuildFootprintPolygonOutlines(), and RENDER_3D_RAYTRACE::Reload().

◆ TransparencyControl()

static float TransparencyControl ( float  aGrayColorValue,
float  aTransparency 
)
static

Perform an interpolation step to easy control the transparency based on the gray color value and transparency.

Parameters
aGrayColorValue- diffuse gray value
aTransparency- control
Returns
transparency to use in material

Definition at line 54 of file raytracing/create_scene.cpp.

55 {
56  const float aaa = aTransparency * aTransparency * aTransparency;
57 
58  // 1.00-1.05*(1.0-x)^3
59  float ca = 1.0f - aTransparency;
60  ca = 1.00f - 1.05f * ca * ca * ca;
61 
62  return glm::max( glm::min( aGrayColorValue * ca + aaa, 1.0f ), 0.0f );
63 }

Referenced by RENDER_3D_RAYTRACE::setupMaterials().