Blender  V2.93
dupli_parent_finder.hh
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2020 Blender Foundation.
17  * All rights reserved.
18  */
19 #pragma once
20 
22 
23 #include "BKE_duplilist.h"
24 
25 #include <map>
26 #include <set>
27 
28 namespace blender::io {
29 
30 /* Find relations between duplicated objects. This class should be instanced for a single real
31  * object, and fed its dupli-objects. */
33  private:
34  /* To check whether an Object * is instanced by this duplicator. */
35  std::set<const Object *> dupli_set_;
36 
37  /* To find the DupliObject given its Persistent ID. */
38  typedef std::map<const PersistentID, const DupliObject *> PIDToDupliMap;
39  PIDToDupliMap pid_to_dupli_;
40 
41  /* Mapping from instancer PID to duplis instanced by it. */
42  typedef std::map<const PersistentID, std::set<const DupliObject *>> InstancerPIDToDuplisMap;
43  InstancerPIDToDuplisMap instancer_pid_to_duplis_;
44 
45  public:
46  void insert(const DupliObject *dupli_ob);
47 
48  bool is_duplicated(const Object *object) const;
49  const DupliObject *find_suitable_export_parent(const DupliObject *dupli_ob) const;
50 
51  private:
52  const DupliObject *find_duplicated_parent(const DupliObject *dupli_ob) const;
53  const DupliObject *find_instancer(const DupliObject *dupli_ob) const;
54 };
55 
56 } // namespace blender::io
#define final(a, b, c)
Definition: BLI_hash.h:35
const DupliObject * find_suitable_export_parent(const DupliObject *dupli_ob) const
void insert(const DupliObject *dupli_ob)
bool is_duplicated(const Object *object) const