KiCad PCB EDA Suite
raytracing/create_scene.cpp File Reference

Go to the source code of this file.

Macros

#define UNITS3D_TO_UNITSPCB   ( pcbIUScale.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   ( pcbIUScale.IU_PER_MM )

Scale conversion from 3d model units to pcb units.

Definition at line 70 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 740 of file convert_shape_list_to_polygon.cpp.

741{
742 BOX2I bbbox = aBoard->GetBoundingBox();
743 SHAPE_LINE_CHAIN chain;
744
745 // If null area, uses the global bounding box.
746 if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
747 bbbox = aBoard->ComputeBoundingBox();
748
749 // Ensure non null area. If happen, gives a minimal size.
750 if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
751 bbbox.Inflate( pcbIUScale.mmToIU( 1.0 ) );
752
753 // Inflate slightly (by 1/10th the size of the box)
754 bbbox.Inflate( bbbox.GetWidth() / 10, bbbox.GetHeight() / 10 );
755
756 chain.Append( bbbox.GetOrigin() );
757 chain.Append( bbbox.GetOrigin().x, bbbox.GetEnd().y );
758 chain.Append( bbbox.GetEnd() );
759 chain.Append( bbbox.GetEnd().x, bbbox.GetOrigin().y );
760 chain.SetClosed( true );
761
762 aOutline.RemoveAllContours();
763 aOutline.AddOutline( chain );
764}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:809
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1235
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
const Vec GetEnd() const
Definition: box2.h:185
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), BOARD::ComputeBoundingBox(), BOARD::GetBoundingBox(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), EDA_IU_SCALE::mmToIU(), pcbIUScale, SHAPE_POLY_SET::RemoveAllContours(), SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

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 56 of file raytracing/create_scene.cpp.

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

Referenced by RENDER_3D_RAYTRACE::setupMaterials().