KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ifsg_faceset.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 Cirilo Bernardo <[email protected]>
5 * Copyright (C) 2020 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
25
26#include <iostream>
27#include <sstream>
28#include <wx/log.h>
29
32
33
34extern char BadParent[];
35extern char WrongParent[];
36
37
39{
40 m_node = nullptr;
41
42 if( !create )
43 return ;
44
45 m_node = new SGFACESET( nullptr );
46
48}
49
50
52{
53 m_node = new SGFACESET( nullptr );
54
55 if( !m_node->SetParent( aParent ) )
56 {
57 delete m_node;
58 m_node = nullptr;
59
60 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
62
63 return;
64 }
65
67}
68
69
71{
72 SGNODE* pp = aParent.GetRawPtr();
73
74#ifdef DEBUG
75 if( ! pp )
76 {
77 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
78 BadParent );
79 }
80#endif
81
82 m_node = new SGFACESET( nullptr );
83
84 if( !m_node->SetParent( pp ) )
85 {
86 delete m_node;
87 m_node = nullptr;
88
89 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
91
92 return;
93 }
94
96}
97
98
100{
101 if( m_node )
103
104 m_node = nullptr;
105
106 if( !aNode )
107 return false;
108
109 if( S3D::SGTYPE_FACESET != aNode->GetNodeType() )
110 {
111 return false;
112 }
113
114 m_node = aNode;
116
117 return true;
118}
119
120
122{
123 if( m_node )
125
126 m_node = new SGFACESET( aParent );
127
128 if( aParent != m_node->GetParent() )
129 {
130 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGFACESET" ),
131 __FILE__, __FUNCTION__, __LINE__,
132 aParent->GetNodeTypeName( aParent->GetNodeType() ) );
133
134 delete m_node;
135 m_node = nullptr;
136 return false;
137 }
138
140
141 return true;
142}
143
144
146{
147 SGNODE* np = aParent.GetRawPtr();
148
149 wxCHECK( np, false );
150
151 return NewNode( np );
152}
153
154
156{
157 if( m_node )
158 return ( (SGFACESET*) m_node )->CalcNormals( aPtr );
159
160 return false;
161}
bool Attach(SGNODE *aNode) override
Function Attach associates a given SGNODE* with this wrapper.
bool NewNode(SGNODE *aParent) override
Function NewNode creates a new node to associate with this wrapper.
IFSG_FACESET(bool create)
bool CalcNormals(SGNODE **aPtr)
IFSG_NODE represents the base class of all DLL-safe Scene Graph nodes.
Definition: ifsg_node.h:55
SGNODE * GetRawPtr(void) noexcept
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:65
SGNODE * m_node
Definition: ifsg_node.h:57
Define an indexed face set for a scenegraph.
Definition: sg_faceset.h:47
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
virtual bool SetParent(SGNODE *aParent, bool notify=true)=0
Set the parent SGNODE of this object.
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
Definition: sg_node.cpp:110
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
Definition: sg_node.cpp:104
void AssociateWrapper(SGNODE **aWrapperRef) noexcept
Associate this object with a handle to itself.
Definition: sg_node.cpp:207
const char * GetNodeTypeName(S3D::SGTYPES aNodeType) const noexcept
Definition: sg_node.cpp:164
void DisassociateWrapper(SGNODE **aWrapperRef) noexcept
Remove the association between an IFSG* wrapper object and this object.
Definition: sg_node.cpp:225
char BadParent[]
Definition: ifsg_node.cpp:38
char WrongParent[]
Definition: ifsg_node.cpp:39
char BadParent[]
Definition: ifsg_node.cpp:38
char WrongParent[]
Definition: ifsg_node.cpp:39
defines the wrapper for the SGFACESET class
@ SGTYPE_FACESET
Definition: sg_types.h:40