KiCad PCB EDA Suite
Loading...
Searching...
No Matches
opengl/create_scene.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2023 CERN
6 * Copyright (C) 2015-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "render_3d_opengl.h"
27#include <board.h>
28#include <footprint.h>
29#include "../../3d_math.h"
31#include <trigo.h>
32#include <project.h>
33#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility
34#include <fp_lib_table.h>
35#include <eda_3d_viewer_frame.h>
36#include <project_pcb.h>
37
38
40 TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop,
41 float aZbot )
42{
43 const SFVEC2F& center = aCircle->GetCenter();
44 const float radius = aCircle->GetRadius() * 2.0f; // Double because the render triangle
45
46 // This is a small adjustment to the circle texture
47 const float texture_factor = ( 8.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
48 const float f = ( sqrtf( 2.0f ) / 2.0f ) * radius * texture_factor;
49
50 // Top and Bot segments ends are just triangle semi-circles, so need to add it in duplicated.
51 aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ),
52 SFVEC3F( center.x - f, center.y, aZtop ),
53 SFVEC3F( center.x, center.y - f, aZtop ) );
54
55 aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZtop ),
56 SFVEC3F( center.x + f, center.y, aZtop ),
57 SFVEC3F( center.x, center.y + f, aZtop ) );
58
59 aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZbot ),
60 SFVEC3F( center.x + f, center.y, aZbot ),
61 SFVEC3F( center.x, center.y - f, aZbot ) );
62
63 aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZbot ),
64 SFVEC3F( center.x - f, center.y, aZbot ),
65 SFVEC3F( center.x, center.y + f, aZbot ) );
66}
67
68
70 TRIANGLE_DISPLAY_LIST* aDstLayer,
71 float aZtop, float aZbot )
72{
73 const SFVEC2F& v0 = aPoly->GetV0();
74 const SFVEC2F& v1 = aPoly->GetV1();
75 const SFVEC2F& v2 = aPoly->GetV2();
76 const SFVEC2F& v3 = aPoly->GetV3();
77
78 addTopAndBottomTriangles( aDstLayer, v0, v2, v1, aZtop, aZbot );
79 addTopAndBottomTriangles( aDstLayer, v2, v0, v3, aZtop, aZbot );
80}
81
82
83void RENDER_3D_OPENGL::generateRing( const SFVEC2F& aCenter, float aInnerRadius,
84 float aOuterRadius, unsigned int aNr_sides_per_circle,
85 std::vector< SFVEC2F >& aInnerContourResult,
86 std::vector< SFVEC2F >& aOuterContourResult,
87 bool aInvertOrder )
88{
89 aInnerContourResult.clear();
90 aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
91
92 aOuterContourResult.clear();
93 aOuterContourResult.reserve( aNr_sides_per_circle + 2 );
94
95 const int delta = 3600 / aNr_sides_per_circle;
96
97 for( int ii = 0; ii < 3600; ii += delta )
98 {
99 float angle = (float)( aInvertOrder ? ( 3600 - ii ) : ii )
100 * 2.0f * glm::pi<float>() / 3600.0f;
101 const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
102
103 aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius,
104 aCenter.y + rotatedDir.y * aInnerRadius );
105
106 aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius,
107 aCenter.y + rotatedDir.y * aOuterRadius );
108 }
109
110 aInnerContourResult.push_back( aInnerContourResult[0] );
111 aOuterContourResult.push_back( aOuterContourResult[0] );
112
113 wxASSERT( aInnerContourResult.size() == aOuterContourResult.size() );
114}
115
116
118 float aZtop, float aZbot )
119{
120 const SFVEC2F& center = aRing->GetCenter();
121 const float inner = aRing->GetInnerRadius();
122 const float outer = aRing->GetOuterRadius();
123
124 std::vector< SFVEC2F > innerContour;
125 std::vector< SFVEC2F > outerContour;
126
127 generateRing( center, inner, outer, m_boardAdapter.GetCircleSegmentCount( outer * 2.0f ),
128 innerContour, outerContour, false );
129
130 // This will add the top and bot quads that will form the approximated ring
131 for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
132 {
133 const SFVEC2F& vi0 = innerContour[i + 0];
134 const SFVEC2F& vi1 = innerContour[i + 1];
135 const SFVEC2F& vo0 = outerContour[i + 0];
136 const SFVEC2F& vo1 = outerContour[i + 1];
137
138 aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
139 SFVEC3F( vi0.x, vi0.y, aZtop ),
140 SFVEC3F( vo0.x, vo0.y, aZtop ),
141 SFVEC3F( vo1.x, vo1.y, aZtop ) );
142
143 aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
144 SFVEC3F( vo1.x, vo1.y, aZbot ),
145 SFVEC3F( vo0.x, vo0.y, aZbot ),
146 SFVEC3F( vi0.x, vi0.y, aZbot ) );
147 }
148}
149
150
152 TRIANGLE_DISPLAY_LIST* aDstLayer,
153 float aZtop, float aZbot )
154{
155 const SFVEC2F& v1 = aTri->GetP1();
156 const SFVEC2F& v2 = aTri->GetP2();
157 const SFVEC2F& v3 = aTri->GetP3();
158
159 addTopAndBottomTriangles( aDstLayer, v1, v2, v3, aZtop, aZbot );
160}
161
162
164 TRIANGLE_DISPLAY_LIST* aDstLayer,
165 float aZtop, float aZbot )
166{
167 const SFVEC2F& leftStart = aSeg->GetLeftStar();
168 const SFVEC2F& leftEnd = aSeg->GetLeftEnd();
169 const SFVEC2F& leftDir = aSeg->GetLeftDir();
170
171 const SFVEC2F& rightStart = aSeg->GetRightStar();
172 const SFVEC2F& rightEnd = aSeg->GetRightEnd();
173 const SFVEC2F& rightDir = aSeg->GetRightDir();
174 const float radius = aSeg->GetRadius();
175
176 const SFVEC2F& start = aSeg->GetStart();
177 const SFVEC2F& end = aSeg->GetEnd();
178
179 const float texture_factor = ( 12.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
180 const float texture_factorF = ( 6.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
181
182 const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f );
183 const float radius_triangle_factor = ( radius_of_the_square - radius ) / radius;
184
185 const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor,
186 rightDir.x * radius * radius_triangle_factor );
187
188 const SFVEC2F factorE = SFVEC2F( -leftDir.y * radius * radius_triangle_factor,
189 leftDir.x * radius * radius_triangle_factor );
190
191 // Top end segment triangles (semi-circles)
193 SFVEC3F( rightEnd.x + texture_factor * factorS.x,
194 rightEnd.y + texture_factor * factorS.y,
195 aZtop ),
196 SFVEC3F( leftStart.x + texture_factor * factorE.x,
197 leftStart.y + texture_factor * factorE.y,
198 aZtop ),
199 SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
200 start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
201 aZtop ) );
202
204 SFVEC3F( leftEnd.x + texture_factor * factorE.x,
205 leftEnd.y + texture_factor * factorE.y, aZtop ),
206 SFVEC3F( rightStart.x + texture_factor * factorS.x,
207 rightStart.y + texture_factor * factorS.y, aZtop ),
208 SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
209 end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
210 aZtop ) );
211
212 // Bot end segment triangles (semi-circles)
214 SFVEC3F( leftStart.x + texture_factor * factorE.x,
215 leftStart.y + texture_factor * factorE.y,
216 aZbot ),
217 SFVEC3F( rightEnd.x + texture_factor * factorS.x,
218 rightEnd.y + texture_factor * factorS.y,
219 aZbot ),
220 SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
221 start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
222 aZbot ) );
223
225 SFVEC3F( rightStart.x + texture_factor * factorS.x,
226 rightStart.y + texture_factor * factorS.y, aZbot ),
227 SFVEC3F( leftEnd.x + texture_factor * factorE.x,
228 leftEnd.y + texture_factor * factorE.y, aZbot ),
229 SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
230 end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
231 aZbot ) );
232
233 // Segment top and bot planes
234 aDstLayer->m_layer_top_triangles->AddQuad(
235 SFVEC3F( rightEnd.x, rightEnd.y, aZtop ),
236 SFVEC3F( rightStart.x, rightStart.y, aZtop ),
237 SFVEC3F( leftEnd.x, leftEnd.y, aZtop ),
238 SFVEC3F( leftStart.x, leftStart.y, aZtop ) );
239
240 aDstLayer->m_layer_bot_triangles->AddQuad(
241 SFVEC3F( rightEnd.x, rightEnd.y, aZbot ),
242 SFVEC3F( leftStart.x, leftStart.y, aZbot ),
243 SFVEC3F( leftEnd.x, leftEnd.y, aZbot ),
244 SFVEC3F( rightStart.x, rightStart.y, aZbot ) );
245}
246
247
249 const SHAPE_POLY_SET& aPoly, float aZtop,
250 float aZbot, bool aInvertFaces,
251 const BVH_CONTAINER_2D* aThroughHoles )
252{
253 OPENGL_RENDER_LIST* ret = nullptr;
254
255 if( aListHolesObject2d.size() > 0 )
256 {
257 TRIANGLE_DISPLAY_LIST* layerTriangles =
258 new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 );
259
260 // Convert the list of objects(filled circles) to triangle layer structure
261 for( const OBJECT_2D* itemOnLayer : aListHolesObject2d )
262 {
263 const OBJECT_2D* object2d_A = itemOnLayer;
264
265 wxASSERT( ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::FILLED_CIRCLE )
266 || ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::ROUNDSEG ) );
267
268 switch( object2d_A->GetObjectType() )
269 {
270 case OBJECT_2D_TYPE::FILLED_CIRCLE:
271 addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
272 layerTriangles, aZtop, aZbot );
273 break;
274
275 case OBJECT_2D_TYPE::ROUNDSEG:
276 addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
277 layerTriangles, aZtop, aZbot );
278 break;
279
280 default:
281 wxFAIL_MSG( wxT( "RENDER_3D_OPENGL::generateHoles: Object type not implemented" ) );
282 break;
283 }
284 }
285
286 // Note: he can have a aListHolesObject2d with holes but without contours
287 // eg: when there are only NPTH on the list and the contours were not added
288 if( aPoly.OutlineCount() > 0 )
289 {
290 layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop,
292 aInvertFaces, aThroughHoles );
293 }
294
295 ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop );
296
297 delete layerTriangles;
298 }
299
300 return ret;
301}
302
303
305 const SHAPE_POLY_SET* aPolyList,
306 PCB_LAYER_ID aLayer,
307 const BVH_CONTAINER_2D* aThroughHoles )
308{
309 if( aContainer == nullptr )
310 return nullptr;
311
312 const LIST_OBJECT2D& listObject2d = aContainer->GetList();
313
314 if( listObject2d.size() == 0 )
315 return nullptr;
316
317 float layer_z_bot = 0.0f;
318 float layer_z_top = 0.0f;
319
320 getLayerZPos( aLayer, layer_z_top, layer_z_bot );
321
322 // Calculate an estimation for the nr of triangles based on the nr of objects
323 unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
324
325 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( nrTrianglesEstimation );
326
327 // store in a list so it will be latter deleted
328 m_triangles.push_back( layerTriangles );
329
330 // Load the 2D (X,Y axis) component of shapes
331 for( const OBJECT_2D* itemOnLayer : listObject2d )
332 {
333 const OBJECT_2D* object2d_A = itemOnLayer;
334
335 switch( object2d_A->GetObjectType() )
336 {
337 case OBJECT_2D_TYPE::FILLED_CIRCLE:
338 addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
339 layerTriangles, layer_z_top, layer_z_bot );
340 break;
341
342 case OBJECT_2D_TYPE::POLYGON4PT:
343 addObjectTriangles( static_cast<const POLYGON_4PT_2D*>( object2d_A ),
344 layerTriangles, layer_z_top, layer_z_bot );
345 break;
346
347 case OBJECT_2D_TYPE::RING:
348 addObjectTriangles( static_cast<const RING_2D*>( object2d_A ),
349 layerTriangles, layer_z_top, layer_z_bot );
350 break;
351
352 case OBJECT_2D_TYPE::TRIANGLE:
353 addObjectTriangles( static_cast<const TRIANGLE_2D*>( object2d_A ),
354 layerTriangles, layer_z_top, layer_z_bot );
355 break;
356
357 case OBJECT_2D_TYPE::ROUNDSEG:
358 addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
359 layerTriangles, layer_z_top, layer_z_bot );
360 break;
361
362 default:
363 wxFAIL_MSG( wxT( "RENDER_3D_OPENGL: Object type is not implemented" ) );
364 break;
365 }
366 }
367
368 if( aPolyList && aPolyList->OutlineCount() > 0 )
369 {
370 layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top,
371 m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles );
372 }
373
374 // Create display list
375 return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
376}
377
378
380{
381 float layer_z_bot = 0.0f;
382 float layer_z_top = 0.0f;
383
384 getLayerZPos( aLayer, layer_z_top, layer_z_bot );
385
386 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( 1 );
387
388 // store in a list so it will be latter deleted
389 m_triangles.push_back( layerTriangles );
390
391 return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
392}
393
394
396 const BVH_CONTAINER_2D* aThroughHoles )
397{
398 OPENGL_RENDER_LIST* dispLists = nullptr;
399 CONTAINER_2D boardContainer;
400
401 ConvertPolygonToTriangles( aBoardPoly, boardContainer, m_boardAdapter.BiuTo3dUnits(),
402 (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
403
404 const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
405
406 if( listBoardObject2d.size() > 0 )
407 {
408 // We will set a unitary Z so it will in future used with transformations since the
409 // board poly will be used not only to draw itself but also the solder mask layers.
410 const float layer_z_top = 1.0f;
411 const float layer_z_bot = 0.0f;
412
413 TRIANGLE_DISPLAY_LIST* layerTriangles =
414 new TRIANGLE_DISPLAY_LIST( listBoardObject2d.size() );
415
416 // Convert the list of objects(triangles) to triangle layer structure
417 for( const OBJECT_2D* itemOnLayer : listBoardObject2d )
418 {
419 const OBJECT_2D* object2d_A = itemOnLayer;
420
421 wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
422
423 const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
424
425 const SFVEC2F& v1 = tri->GetP1();
426 const SFVEC2F& v2 = tri->GetP2();
427 const SFVEC2F& v3 = tri->GetP3();
428
429 addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
430 }
431
432 if( aBoardPoly.OutlineCount() > 0 )
433 {
434 layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top,
436 aThroughHoles );
437
438 dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
439 layer_z_top, layer_z_top );
440 }
441
442 delete layerTriangles;
443 }
444
445 return dispLists;
446}
447
448
449void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
450{
451 m_reloadRequested = false;
452
453 freeAllLists();
454
456
457 unsigned stats_startReloadTime = GetRunningMicroSecs();
458
459 m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
460
462 m_camera.SetBoardLookAtPos( camera_pos );
463
464 if( aStatusReporter )
465 aStatusReporter->Report( _( "Load OpenGL: board" ) );
466
467 // Create Board
469
472 m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
473 m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
474 m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
475 m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
477
481
485
486 m_boardWithHoles = createBoard( board_poly_with_holes );
487
488 if( m_antiBoard )
490
491 // Create Through Holes and vias
492 if( aStatusReporter )
493 aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
494
496
499
501 1.0f, 0.0f, false, &m_boardAdapter.GetTH_IDs() );
502
504 m_boardAdapter.GetViaTH_ODPolys(), 1.0f, 0.0f, false );
505
507 {
510 1.0f, 0.0f, false );
511 }
512
513 const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
514 const MAP_POLY& outerMapHoles = m_boardAdapter.GetHoleOdPolysMap();
515
516 wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
517
519
520 if( outerMapHoles.size() > 0 )
521 {
522 float layer_z_bot = 0.0f;
523 float layer_z_top = 0.0f;
524
525 for( const auto& [ layer, poly ] : outerMapHoles )
526 {
527 getLayerZPos( layer, layer_z_top, layer_z_bot );
528
529 m_outerLayerHoles[layer] = generateHoles( map_holes.at( layer )->GetList(), *poly,
530 layer_z_top, layer_z_bot, false );
531 }
532
533 for( const auto& [ layer, poly ] : innerMapHoles )
534 {
535 getLayerZPos( layer, layer_z_top, layer_z_bot );
536
537 m_innerLayerHoles[layer] = generateHoles( map_holes.at( layer )->GetList(), *poly,
538 layer_z_top, layer_z_bot, false );
539 }
540 }
541
542 // Generate vertical cylinders of vias and pads (copper)
544
545 // Add layers maps
546 if( aStatusReporter )
547 aStatusReporter->Report( _( "Load OpenGL: layers" ) );
548
549 std::bitset<LAYER_3D_END> visibilityFlags = m_boardAdapter.GetVisibleLayers();
550 const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
551 wxString msg;
552
553 for( const auto& [ layer, container2d ] : m_boardAdapter.GetLayerMap() )
554 {
555 if( !m_boardAdapter.Is3dLayerEnabled( layer, visibilityFlags ) )
556 continue;
557
558 if( aStatusReporter )
559 {
560 msg = m_boardAdapter.GetBoard()->GetLayerName( layer );
561 aStatusReporter->Report( wxString::Format( _( "Load OpenGL layer %s" ), msg ) );
562 }
563
564 SHAPE_POLY_SET polyListSubtracted;
565 SHAPE_POLY_SET* polyList = nullptr;
566
567 // Load the vertical (Z axis) component of shapes
568
570 {
571 if( map_poly.find( layer ) != map_poly.end() )
572 {
573 polyListSubtracted = *map_poly.at( layer );
574
575 if( LSET::PhysicalLayersMask().test( layer ) )
576 {
577 polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
579 }
580
581 if( layer != B_Mask && layer != F_Mask )
582 {
583 polyListSubtracted.BooleanSubtract( m_boardAdapter.GetTH_ODPolys(),
585 polyListSubtracted.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys(),
587 }
588
590 {
591 if( layer == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
592 {
593 polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ),
595 }
596 else if( layer == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() )
597 {
598 polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ),
600 }
601 }
602
603 polyList = &polyListSubtracted;
604 }
605 }
606
607 OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, polyList, layer,
609
610 if( oglList != nullptr )
611 m_layers[layer] = oglList;
612 }
613
615 {
616 const SHAPE_POLY_SET* frontPlatedPadPolys = m_boardAdapter.GetFrontPlatedPadPolys();
617 const SHAPE_POLY_SET* backPlatedPadPolys = m_boardAdapter.GetBackPlatedPadPolys();
618
619 if( frontPlatedPadPolys )
620 {
621 SHAPE_POLY_SET poly = frontPlatedPadPolys->CloneDropTriangulation();
625
627
628 // An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront
629 if( m_layers.count( F_Cu ) == 0 )
631 }
632
633 if( backPlatedPadPolys )
634 {
635 SHAPE_POLY_SET poly = backPlatedPadPolys->CloneDropTriangulation();
639
641
642 // An entry for B_Cu must exist in m_layers or we'll never look at m_platedPadsBack
643 if( m_layers.count( B_Cu ) == 0 )
645 }
646 }
647
649 {
650 if( const BVH_CONTAINER_2D* padsFront = m_boardAdapter.GetOffboardPadsFront() )
651 m_offboardPadsFront = generateLayerList( padsFront, nullptr, F_Cu );
652
653 if( const BVH_CONTAINER_2D* padsBack = m_boardAdapter.GetOffboardPadsBack() )
654 m_offboardPadsBack = generateLayerList( padsBack, nullptr, B_Cu );
655 }
656
657 // Load 3D models
658 if( aStatusReporter )
659 aStatusReporter->Report( _( "Loading 3D models..." ) );
660
661 load3dModels( aStatusReporter );
662
663 if( aStatusReporter )
664 {
665 // Calculation time in seconds
666 double calculation_time = (double)( GetRunningMicroSecs() - stats_startReloadTime) / 1e6;
667
668 aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
669 }
670}
671
672
674 const SFVEC2F& v1, const SFVEC2F& v2, float top,
675 float bot )
676{
677 aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
678 SFVEC3F( v1.x, v1.y, bot ),
679 SFVEC3F( v2.x, v2.y, bot ) );
680
682 SFVEC3F( v1.x, v1.y, top ),
683 SFVEC3F( v0.x, v0.y, top ) );
684}
685
686
687void RENDER_3D_OPENGL::getLayerZPos( PCB_LAYER_ID aLayer, float& aOutZtop, float& aOutZbot ) const
688{
689 aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayer );
690 aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayer );
691
692 if( aOutZtop < aOutZbot )
693 {
694 float tmpFloat = aOutZbot;
695 aOutZbot = aOutZtop;
696 aOutZtop = tmpFloat;
697 }
698}
699
700
701void RENDER_3D_OPENGL::generateCylinder( const SFVEC2F& aCenter, float aInnerRadius,
702 float aOuterRadius, float aZtop, float aZbot,
703 unsigned int aNr_sides_per_circle,
704 TRIANGLE_DISPLAY_LIST* aDstLayer )
705{
706 std::vector< SFVEC2F > innerContour;
707 std::vector< SFVEC2F > outerContour;
708
709 generateRing( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, innerContour,
710 outerContour, false );
711
712 for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
713 {
714 const SFVEC2F& vi0 = innerContour[i + 0];
715 const SFVEC2F& vi1 = innerContour[i + 1];
716 const SFVEC2F& vo0 = outerContour[i + 0];
717 const SFVEC2F& vo1 = outerContour[i + 1];
718
719 aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
720 SFVEC3F( vi0.x, vi0.y, aZtop ),
721 SFVEC3F( vo0.x, vo0.y, aZtop ),
722 SFVEC3F( vo1.x, vo1.y, aZtop ) );
723
724 aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
725 SFVEC3F( vo1.x, vo1.y, aZbot ),
726 SFVEC3F( vo0.x, vo0.y, aZbot ),
727 SFVEC3F( vi0.x, vi0.y, aZbot ) );
728 }
729
730 aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
731 aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
732}
733
734
736{
737 if( !m_boardAdapter.GetBoard() )
738 return;
739
740 const int platingThickness = m_boardAdapter.GetHolePlatingThickness();
741 const float platingThickness3d = platingThickness * m_boardAdapter.BiuTo3dUnits();
742
743 if( m_boardAdapter.GetViaCount() > 0 )
744 {
745 float averageDiameter = m_boardAdapter.GetAverageViaHoleDiameter();
746 unsigned int averageSegCount = m_boardAdapter.GetCircleSegmentCount( averageDiameter );
747 unsigned int trianglesEstimate = averageSegCount * 8 * m_boardAdapter.GetViaCount();
748
749 TRIANGLE_DISPLAY_LIST* layerTriangleVIA = new TRIANGLE_DISPLAY_LIST( trianglesEstimate );
750
751 // Insert plated vertical holes inside the board
752
753 // Insert vias holes (vertical cylinders)
754 for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
755 {
756 if( track->Type() == PCB_VIA_T )
757 {
758 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
759
760 if( via->GetViaType() == VIATYPE::THROUGH )
761 continue; // handle with pad holes so castellation is taken into account
762
763 const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
764 const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
765 const float hole_inner_radius = holediameter / 2.0f;
766
767 const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
768 -via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
769
770 PCB_LAYER_ID top_layer, bottom_layer;
771 via->LayerPair( &top_layer, &bottom_layer );
772
773 float ztop, zbot, dummy;
774
775 getLayerZPos( top_layer, ztop, dummy );
776 getLayerZPos( bottom_layer, dummy, zbot );
777
778 wxASSERT( zbot < ztop );
779
780 generateCylinder( via_center, hole_inner_radius,
781 hole_inner_radius + platingThickness3d,
782 ztop, zbot, nrSegments, layerTriangleVIA );
783 }
784 }
785
786 m_vias = new OPENGL_RENDER_LIST( *layerTriangleVIA, 0, 0.0f, 0.0f );
787
788 delete layerTriangleVIA;
789 }
790
791
793 {
794 SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes
795 SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes
796
797 tht_outer_holes_poly.RemoveAllContours();
798 tht_inner_holes_poly.RemoveAllContours();
799
800 // Insert through-via holes (vertical cylinders)
801 for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
802 {
803 if( track->Type() == PCB_VIA_T )
804 {
805 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
806
807 if( via->GetViaType() == VIATYPE::THROUGH )
808 {
809 TransformCircleToPolygon( tht_outer_holes_poly, via->GetPosition(),
810 via->GetDrill() / 2 + platingThickness,
812
813 TransformCircleToPolygon( tht_inner_holes_poly, via->GetPosition(),
814 via->GetDrill() / 2, ARC_HIGH_DEF, ERROR_INSIDE );
815 }
816 }
817 }
818
819 // Insert pads holes (vertical cylinders)
820 for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
821 {
822 for( const PAD* pad : footprint->Pads() )
823 {
824 if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
825 {
826 const VECTOR2I drillsize = pad->GetDrillSize();
827 const bool hasHole = drillsize.x && drillsize.y;
828
829 if( !hasHole )
830 continue;
831
832 pad->TransformHoleToPolygon( tht_outer_holes_poly, platingThickness,
834 pad->TransformHoleToPolygon( tht_inner_holes_poly, 0, ARC_HIGH_DEF,
835 ERROR_INSIDE );
836 }
837 }
838 }
839
840 // Subtract the holes
841 tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
842
844
845 CONTAINER_2D holesContainer;
846
847 ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
849
850 const LIST_OBJECT2D& holes2D = holesContainer.GetList();
851
852 if( holes2D.size() > 0 )
853 {
854 float layer_z_top, layer_z_bot, dummy;
855
856 getLayerZPos( F_Cu, layer_z_top, dummy );
857 getLayerZPos( B_Cu, dummy, layer_z_bot );
858
859 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( holes2D.size() );
860
861 // Convert the list of objects(triangles) to triangle layer structure
862 for( const OBJECT_2D* itemOnLayer : holes2D )
863 {
864 const OBJECT_2D* object2d_A = itemOnLayer;
865
866 wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
867
868 const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
869
870 const SFVEC2F& v1 = tri->GetP1();
871 const SFVEC2F& v2 = tri->GetP2();
872 const SFVEC2F& v3 = tri->GetP3();
873
874 addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
875 }
876
877 wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
878
879 if( tht_outer_holes_poly.OutlineCount() > 0 )
880 {
881 layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
882 layer_z_bot, layer_z_top,
883 m_boardAdapter.BiuTo3dUnits(), false );
884
885 m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
886 layer_z_top, layer_z_top );
887 }
888
889 delete layerTriangles;
890 }
891 }
892}
893
894
896{
897 if( m_3dModelMap.size() > 0 )
898 return;
899
900 wxFrame* frame = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_canvas->GetParent() );
901
902 if( frame )
903 {
904 STATUSBAR_REPORTER activityReporter( frame->GetStatusBar(),
905 (int) EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
906 load3dModels( &activityReporter );
907 }
908 else
909 {
910 load3dModels( nullptr );
911 }
912}
913
914
916{
917 if( !m_boardAdapter.GetBoard() )
918 return;
919
924 {
925 return;
926 }
927
928 // Go for all footprints
929 for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
930 {
931 wxString libraryName = footprint->GetFPID().GetLibNickname();
932 wxString footprintBasePath = wxEmptyString;
933
935 {
936 try
937 {
938 // FindRow() can throw an exception
939 const FP_LIB_TABLE_ROW* fpRow =
941 ->FindRow( libraryName, false );
942
943 if( fpRow )
944 footprintBasePath = fpRow->GetFullURI( true );
945 }
946 catch( ... )
947 {
948 // Do nothing if the libraryName is not found in lib table
949 }
950 }
951
952 for( const FP_3DMODEL& fp_model : footprint->Models() )
953 {
954 if( fp_model.m_Show && !fp_model.m_Filename.empty() )
955 {
956 if( aStatusReporter )
957 {
958 // Display the short filename of the 3D fp_model loaded:
959 // (the full name is usually too long to be displayed)
960 wxFileName fn( fp_model.m_Filename );
961 aStatusReporter->Report( wxString::Format( _( "Loading %s..." ),
962 fn.GetFullName() ) );
963 }
964
965 // Check if the fp_model is not present in our cache map
966 // (Not already loaded in memory)
967 if( m_3dModelMap.find( fp_model.m_Filename ) == m_3dModelMap.end() )
968 {
969 // It is not present, try get it from cache
970 const S3DMODEL* modelPtr =
971 m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath );
972
973 // only add it if the return is not NULL
974 if( modelPtr )
975 {
977 MODEL_3D* model = new MODEL_3D( *modelPtr, materialMode );
978
979 m_3dModelMap[ fp_model.m_Filename ] = model;
980 }
981 }
982 }
983 }
984 }
985}
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:71
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
std::map< PCB_LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: board_adapter.h:59
std::map< PCB_LAYER_ID, BVH_CONTAINER_2D * > MAP_CONTAINER_2D_BASE
A type that stores a container of 2d objects for each layer id.
Definition: board_adapter.h:56
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
const MAP_CONTAINER_2D_BASE & GetLayerHoleMap() const noexcept
const SHAPE_POLY_SET & GetBoardPoly() const noexcept
Get the current polygon of the epoxy board.
const SHAPE_POLY_SET & GetNPTH_ODPolys() const noexcept
const BVH_CONTAINER_2D * GetOffboardPadsFront() const noexcept
const SHAPE_POLY_SET & GetViaTH_ODPolys() const noexcept
const MAP_POLY & GetPolyMap() const noexcept
Get map of polygon's layers.
const MAP_POLY & GetHoleOdPolysMap() const noexcept
std::bitset< LAYER_3D_END > GetVisibleLayers() const
bool m_IsPreviewer
true if we're in a 3D preview panel, false for the standard 3D viewer
int GetHolePlatingThickness() const noexcept
Get the hole plating thickness (NB: in BOARD UNITS!).
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
const BVH_CONTAINER_2D & GetViaAnnuli() const noexcept
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.
const BVH_CONTAINER_2D * GetOffboardPadsBack() const noexcept
const BVH_CONTAINER_2D & GetTH_IDs() const noexcept
const BVH_CONTAINER_2D * GetPlatedPadsBack() const noexcept
const MAP_POLY & GetHoleIdPolysMap() const noexcept
float GetAverageViaHoleDiameter() const noexcept
const SHAPE_POLY_SET * GetFrontPlatedPadPolys()
unsigned int GetViaCount() const noexcept
const BOARD * GetBoard() const noexcept
const SFVEC3F & GetBoardCenter() const noexcept
The board center position in 3D units.
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.
const BVH_CONTAINER_2D & GetTH_ODs() const noexcept
const SHAPE_POLY_SET * GetBackPlatedPadPolys()
const MAP_CONTAINER_2D_BASE & GetLayerMap() const noexcept
Get the map of containers that have the objects per layer.
EDA_3D_VIEWER_SETTINGS * m_Cfg
unsigned int GetHoleCount() const noexcept
const BVH_CONTAINER_2D * GetPlatedPadsFront() const noexcept
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
const BVH_CONTAINER_2D & GetViaTH_ODs() const noexcept
const SHAPE_POLY_SET & GetViaAnnuliPolys() const noexcept
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer, const std::bitset< LAYER_3D_END > &aVisibilityFlags) const
Check if a layer is enabled.
S3D_CACHE * Get3dCacheManager() const noexcept
Definition: board_adapter.h:83
const SHAPE_POLY_SET & GetTH_ODPolys() const noexcept
Get through hole outside diameter 2D polygons.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
FOOTPRINTS & Footprints()
Definition: board.h:318
TRACKS & Tracks()
Definition: board.h:315
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:515
PROJECT * GetProject() const
Definition: board.h:457
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: camera.cpp:123
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
const SFVEC2F & GetCenter() const
float GetRadius() const
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:879
static OBJECT_2D_STATS & Instance()
Definition: object_2d.h:137
void ResetStats()
Definition: object_2d.h:122
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.
void SetItIsTransparent(bool aSetTransparent)
Definition: pad.h:58
Simple non-intersecting polygon with 4 points.
const SFVEC2F & GetV3() const
const SFVEC2F & GetV0() const
const SFVEC2F & GetV1() const
const SFVEC2F & GetV2() const
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
bool m_reloadRequested
The window size that this camera is working.
EDA_3D_CANVAS * m_canvas
Settings reference in use for this render.
BOARD_ADAPTER & m_boardAdapter
OPENGL_RENDER_LIST * m_board
void reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
OPENGL_RENDER_LIST * m_vias
OPENGL_RENDER_LIST * generateHoles(const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
void generateCylinder(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST *aDstLayer)
OPENGL_RENDER_LIST * m_outerThroughHoleRings
OPENGL_RENDER_LIST * m_offboardPadsFront
void generateRing(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
SHAPE_POLY_SET m_antiBoardPolys
The negative polygon representation of the board outline.
void load3dModels(REPORTER *aStatusReporter)
Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects.
OPENGL_RENDER_LIST * generateLayerList(const BVH_CONTAINER_2D *aContainer, const SHAPE_POLY_SET *aPolyList, PCB_LAYER_ID aLayer, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OPENGL_RENDER_LIST * createBoard(const SHAPE_POLY_SET &aBoardPoly, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
void Load3dModelsIfNeeded()
Load footprint models if they are not already loaded, i.e.
void addObjectTriangles(const RING_2D *aRing, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
MAP_OGL_DISP_LISTS m_layers
MAP_OGL_DISP_LISTS m_innerLayerHoles
OPENGL_RENDER_LIST * m_boardWithHoles
MAP_OGL_DISP_LISTS m_outerLayerHoles
OPENGL_RENDER_LIST * m_offboardPadsBack
std::map< wxString, MODEL_3D * > m_3dModelMap
OPENGL_RENDER_LIST * generateEmptyLayerList(PCB_LAYER_ID aLayer)
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
OPENGL_RENDER_LIST * m_outerViaThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoles
OPENGL_RENDER_LIST * m_platedPadsFront
OPENGL_RENDER_LIST * m_antiBoard
void getLayerZPos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
OPENGL_RENDER_LIST * m_padHoles
void addTopAndBottomTriangles(TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
OPENGL_RENDER_LIST * m_platedPadsBack
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
float GetOuterRadius() const
Definition: ring_2d.h:48
float GetInnerRadius() const
Definition: ring_2d.h:47
const SFVEC2F & GetCenter() const
Definition: ring_2d.h:46
const SFVEC2F & GetLeftEnd() const
const SFVEC2F & GetRightEnd() const
const SFVEC2F & GetLeftStar() const
const SFVEC2F & GetLeftDir() const
const SFVEC2F & GetEnd() const
float GetRadius() const
float GetRadiusSquared() const
const SFVEC2F & GetStart() const
const SFVEC2F & GetRightDir() const
const SFVEC2F & GetRightStar() const
S3DMODEL * GetModel(const wxString &aModelFileName, const wxString &aBasePath)
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for displa...
Definition: 3d_cache.cpp:634
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:309
const SFVEC2F & GetP2() const
Definition: triangle_2d.h:45
const SFVEC2F & GetP3() const
Definition: triangle_2d.h:46
const SFVEC2F & GetP1() const
Definition: triangle_2d.h:44
Store arrays of triangles to be used to create display lists.
TRIANGLE_LIST * m_layer_bot_segment_ends
TRIANGLE_LIST * m_layer_top_segment_ends
TRIANGLE_LIST * m_layer_bot_triangles
TRIANGLE_LIST * m_layer_top_triangles
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
T y
Definition: vector3.h:63
T x
Definition: vector3.h:62
std::list< OBJECT_2D * > LIST_OBJECT2D
Definition: container_2d.h:38
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
#define _(s)
Declaration of the eda_3d_viewer class.
@ ERROR_INSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Mask
Definition: layer_ids.h:107
@ B_Cu
Definition: layer_ids.h:96
@ F_Mask
Definition: layer_ids.h:108
@ F_SilkS
Definition: layer_ids.h:105
@ B_SilkS
Definition: layer_ids.h:104
@ F_Cu
Definition: layer_ids.h:65
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
#define SIZE_OF_CIRCLE_TEXTURE
std::vector< FAB_LAYER_COLOR > dummy
Store the a model based on meshes and materials.
Definition: c3dmodel.h:91
VECTOR3I v1(5, 5, 5)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
VECTOR2I v3(-2, 1)
constexpr int delta
void ConvertPolygonToTriangles(const SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:95
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44