KiCad PCB EDA Suite
ccontainer.h
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 <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 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, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef _CCONTAINER_H_
31 #define _CCONTAINER_H_
32 
33 #include "../shapes3D/cobject.h"
34 #include <list>
35 #include <vector>
36 
37 typedef std::list<COBJECT *> LIST_OBJECT;
38 typedef std::vector<COBJECT *> VECTOR_OBJECT;
39 typedef std::vector<const COBJECT *> CONST_VECTOR_OBJECT;
40 
42 {
43 protected:
46 
47 public:
49 
50  virtual ~CGENERICCONTAINER();
51 
52  void Add( COBJECT *aObject )
53  {
54  if( aObject ) // Only add if it is a valid pointer
55  {
56  m_objects.push_back( aObject );
57  m_bbox.Union( aObject->GetBBox() );
58  }
59  }
60 
61  void Clear();
62 
63  const LIST_OBJECT &GetList() const { return m_objects; }
64 
65  void ConvertTo( CONST_VECTOR_OBJECT &aOutVector ) const;
66 
67  const CBBOX &GetBBox() const { return m_bbox; }
68 
69  virtual bool Intersect( const RAY &aRay, HITINFO &aHitInfo ) const = 0;
70  virtual bool IntersectP( const RAY &aRay, float aMaxDistance ) const = 0;
71 
72 private:
73 };
74 
75 
77 {
78 public:
79  bool Intersect( const RAY &aRay, HITINFO &aHitInfo ) const override;
80  bool IntersectP( const RAY &aRay, float aMaxDistance ) const override;
81 };
82 
83 #endif // _CCONTAINER_H_
virtual bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const =0
std::vector< COBJECT * > VECTOR_OBJECT
Definition: ccontainer.h:38
std::vector< const COBJECT * > CONST_VECTOR_OBJECT
Definition: ccontainer.h:39
virtual bool IntersectP(const RAY &aRay, float aMaxDistance) const =0
LIST_OBJECT m_objects
Definition: ccontainer.h:45
Definition: ray.h:43
void Union(const SFVEC3F &aPoint)
Function Union recalculate the bounding box adding a point.
Definition: cbbox.cpp:105
void ConvertTo(CONST_VECTOR_OBJECT &aOutVector) const
Definition: ccontainer.cpp:64
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
Definition: ccontainer.cpp:106
const CBBOX & GetBBox() const
Definition: cobject.h:94
void Add(COBJECT *aObject)
Definition: ccontainer.h:52
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
Definition: ccontainer.cpp:84
const CBBOX & GetBBox() const
Definition: ccontainer.h:67
Stores the hit information of a ray with a point on the surface of a object.
Definition: hitinfo.h:40
virtual ~CGENERICCONTAINER()
Definition: ccontainer.cpp:58
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
std::list< COBJECT * > LIST_OBJECT
Definition: ccontainer.h:37
const LIST_OBJECT & GetList() const
Definition: ccontainer.h:63