KiCad PCB EDA Suite
Loading...
Searching...
No Matches
container_3d.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 The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
24
25#include "container_3d.h"
26#include <cstdio>
27
29{
30 m_objects.clear();
31 m_bbox.Reset();
32}
33
34
36{
37 if( !m_objects.empty() )
38 {
39 for( OBJECT_3D* object : m_objects )
40 delete object;
41
42 m_objects.clear();
43 }
44
45 m_bbox.Reset();
46}
47
48
53
54
55void CONTAINER_3D_BASE::ConvertTo( std::vector<const OBJECT_3D*> &aOutVector ) const
56{
57 aOutVector.resize( m_objects.size() );
58
59 if( !m_objects.empty() )
60 {
61 unsigned int i = 0;
62
63 for( const OBJECT_3D* object : m_objects )
64 {
65 wxASSERT( object );
66 aOutVector[i++] = object;
67 }
68 }
69}
70
71
72bool CONTAINER_3D::Intersect( const RAY &aRay, HITINFO &aHitInfo ) const
73{
74
75 if( !m_bbox.Intersect( aRay ) )
76 return false;
77
78 bool hitted = false;
79
80 for( const OBJECT_3D* object : m_objects )
81 {
82 if( object->Intersect( aRay, aHitInfo) )
83 hitted = true;
84 }
85
86 return hitted;
87}
88
89
90bool CONTAINER_3D::IntersectP( const RAY &aRay, float aMaxDistance ) const
91{
92 for( const OBJECT_3D* object : m_objects )
93 {
94 if( object->IntersectP( aRay, aMaxDistance ) )
95 return true;
96 }
97
98 return false;
99}
void ConvertTo(std::vector< const OBJECT_3D * > &aOutVector) const
std::list< OBJECT_3D * > m_objects
virtual ~CONTAINER_3D_BASE()
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
Stores the hit information of a ray with a point on the surface of a object.
Definition hitinfo.h:32
Definition ray.h:59