KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sg_index.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-2017 Cirilo Bernardo <[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#ifndef SG_INDEX_H
26#define SG_INDEX_H
27
28#include <vector>
29#include "3d_cache/sg/sg_node.h"
30
34class SGINDEX : public SGNODE
35{
36public:
37 SGINDEX( SGNODE* aParent );
38 virtual ~SGINDEX();
39
40 virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
41
42 SGNODE* FindNode(const char* aNodeName, const SGNODE* aCaller) noexcept override;
43 bool AddRefNode( SGNODE* aNode ) noexcept override;
44 bool AddChildNode( SGNODE* aNode ) noexcept override;
45
46 void unlinkChildNode( const SGNODE* aCaller ) noexcept override;
47 void unlinkRefNode( const SGNODE* aCaller ) noexcept override;
48
60 bool GetIndices( size_t& nIndices, int*& aIndexList );
61
68 void SetIndices( size_t nIndices, int* aIndexList );
69
70
76 void AddIndex( int aIndex );
77
78 void ReNameNodes( void ) override;
79 bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
80
81 bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
82 bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
83
84protected:
85 bool writeCoordIndex( std::ostream& aFile );
86 bool writeColorIndex( std::ostream& aFile );
87 bool writeIndexList( std::ostream& aFile );
88
89public:
90 // for internal SG consumption only
91 std::vector< int > index;
92};
93
94#endif // SG_INDEX_H
bool AddChildNode(SGNODE *aNode) noexcept override
Definition sg_index.cpp:113
void unlinkChildNode(const SGNODE *aCaller) noexcept override
Remove references to an owned child.
Definition sg_index.cpp:90
void unlinkRefNode(const SGNODE *aCaller) noexcept override
Remove pointers to a referenced node.
Definition sg_index.cpp:97
SGINDEX(SGNODE *aParent)
Definition sg_index.cpp:28
bool writeCoordIndex(std::ostream &aFile)
Definition sg_index.cpp:179
bool GetIndices(size_t &nIndices, int *&aIndexList)
Retrieve the number of indices and a pointer to the list.
Definition sg_index.cpp:122
std::vector< int > index
Definition sg_index.h:91
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
Definition sg_index.cpp:167
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
Definition sg_index.cpp:303
void AddIndex(int aIndex)
Add a single index to the list.
Definition sg_index.cpp:151
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
Definition sg_index.cpp:78
bool writeColorIndex(std::ostream &aFile)
Definition sg_index.cpp:222
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
Definition sg_index.cpp:157
void SetIndices(size_t nIndices, int *aIndexList)
Set the number of indices and creates a copy of the given index data.
Definition sg_index.cpp:137
virtual ~SGINDEX()
Definition sg_index.cpp:42
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
Definition sg_index.cpp:48
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
Definition sg_index.cpp:258
bool writeIndexList(std::ostream &aFile)
Definition sg_index.cpp:229
bool AddRefNode(SGNODE *aNode) noexcept override
Definition sg_index.cpp:104
SGNODE(SGNODE *aParent)
Definition sg_node.cpp:72