KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_placeholder_utils.cpp File Reference
#include "3d_placeholder_utils.h"
#include <footprint.h>
#include <pad.h>
#include <board_item.h>
#include <layer_ids.h>
#include <base_units.h>
#include <geometry/eda_angle.h>
#include <geometry/shape_poly_set.h>
#include <pcb_shape.h>
#include <convert_shape_list_to_polygon.h>
#include <convert_basic_shapes_to_polygon.h>
#include <wx/log.h>

Go to the source code of this file.

Functions

BOX2I CalcPlaceholderLocalBox (const FOOTPRINT *aFootprint)
 Calculate a local space bounding box for a placeholder 3D model.
 
static bool buildFilledPolygonFromShapes (const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutline)
 Build a filled polygon from shapes on the given layer.
 
static bool buildPadBoundingBox (const FOOTPRINT *aFootprint, SHAPE_POLY_SET &aOutline)
 
bool GetExtrusionOutline (const FOOTPRINT *aFootprint, SHAPE_POLY_SET &aOutline, PCB_LAYER_ID aLayerOverride)
 Get the extrusion outline polygon for a footprint in board coordinates.
 
bool GetExtrusionPinOutlines (const FOOTPRINT *aFootprint, SHAPE_POLY_SET &aPinPoly, SHAPE_POLY_SET &aPegPoly)
 Get the hole outline polygons for extruded pin rendering.
 
EXTRUSION_MATERIAL_PROPS GetMaterialProps (EXTRUSION_MATERIAL aMaterial, const SFVEC3F &aDiffuse)
 
void ApplyExtrusionTransform (SHAPE_POLY_SET &aOutline, const EXTRUDED_3D_BODY *aBody, const VECTOR2I &aFpPos)
 Apply 2D extrusion transforms (rotation, scale, offset) to an outline.
 

Function Documentation

◆ ApplyExtrusionTransform()

◆ buildFilledPolygonFromShapes()

static bool buildFilledPolygonFromShapes ( const FOOTPRINT * aFootprint,
PCB_LAYER_ID aLayer,
SHAPE_POLY_SET & aOutline )
static

Build a filled polygon from shapes on the given layer.

Separates shapes into self-closed and open shapes. Self-closed shapes are converted to filled polygons. Open shapes are chained into closed contours.

Definition at line 132 of file 3d_placeholder_utils.cpp.

References SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), ARC_HIGH_DEF, CIRCLE, ConvertOutlineToPolygon(), SHAPE_POLY_SET::COutline(), ERROR_INSIDE, EDA_SHAPE::GetShape(), FOOTPRINT::GraphicalItems(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), PCB_SHAPE_T, pcbIUScale, POLY, RECTANGLE, SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Simplify(), and TransformCircleToPolygon().

Referenced by GetExtrusionOutline().

◆ buildPadBoundingBox()

◆ CalcPlaceholderLocalBox()

◆ GetExtrusionOutline()

bool GetExtrusionOutline ( const FOOTPRINT * aFootprint,
SHAPE_POLY_SET & aOutline,
PCB_LAYER_ID aLayerOverride = UNDEFINED_LAYER )

Get the extrusion outline polygon for a footprint in board coordinates.

Parameters
aFootprintthe footprint to extract an outline from.
aOutlineoutput polygon set.
aLayerOverridewhen not UNDEFINED_LAYER, use this layer instead of the footprint's extruded body layer setting.
Returns
true if outline was found.

Definition at line 261 of file 3d_placeholder_utils.cpp.

References SHAPE_POLY_SET::Append(), B_CrtYd, B_Fab, B_SilkS, buildFilledPolygonFromShapes(), buildPadBoundingBox(), F_CrtYd, F_Fab, F_SilkS, FlipLayer(), FOOTPRINT::GetCourtyard(), FOOTPRINT::GetExtrudedBody(), FOOTPRINT::GetReference(), FOOTPRINT::IsFlipped(), EXTRUDED_3D_BODY::m_layer, SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Simplify(), UNDEFINED_LAYER, and UNSELECTED_LAYER.

Referenced by RENDER_3D_RAYTRACE_BASE::addExtrudedBodyToRaytracer(), EXPORTER_STEP::buildFootprint3DShapes(), IDF_EXPORTER::createOutlineFromExtrudedBody(), PANEL_FP_PROPERTIES_3D_MODEL::OnExportExtrudedModel(), and RENDER_3D_OPENGL::renderExtrudedBodies().

◆ GetExtrusionPinOutlines()

bool GetExtrusionPinOutlines ( const FOOTPRINT * aFootprint,
SHAPE_POLY_SET & aPinPoly,
SHAPE_POLY_SET & aPegPoly )

Get the hole outline polygons for extruded pin rendering.

Collects drill hole shapes from all pads with holes, shrunk to ~90% of the drill diameter so pins sit inside the hole. Plated holes go to aPinPoly and NPTH holes go to aPegPoly.

Returns
true if at least one hole polygon was generated.

Definition at line 349 of file 3d_placeholder_utils.cpp.

References ARC_HIGH_DEF, ERROR_INSIDE, NPTH, SHAPE_POLY_SET::OutlineCount(), pad, FOOTPRINT::Pads(), SHAPE_POLY_SET::RemoveAllContours(), and SHAPE_POLY_SET::Simplify().

Referenced by RENDER_3D_RAYTRACE_BASE::addExtrudedBodyToRaytracer(), STEP_PCB_MODEL::AddExtrudedPins(), and RENDER_3D_OPENGL::renderExtrudedBodies().

◆ GetMaterialProps()

EXTRUSION_MATERIAL_PROPS GetMaterialProps ( EXTRUSION_MATERIAL aMaterial,
const SFVEC3F & aDiffuse )