1 // NeL - MMORPG Framework <https://wiki.ryzom.dev/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "nel/ligo/primitive_utils.h"
24 std::string
buildPrimPath(const IPrimitive
*prim
)
31 prim
->getPropertyByName("name", name
);
35 path
= name
+ "." + path
;
37 prim
= prim
->getParent();
42 void selectPrimByPath(IPrimitive
*rootNode
, const std::string
&path
, TPrimitiveSet
&result
)
44 std::vector
<std::string
> parts
;
45 NLMISC::explode(path
, std::string("."), parts
, false);
46 // IPrimitive * tmpChild;
53 // handle a special case
54 if (parts
.size() > 1 && parts
[1] == "primitive")
56 parts
[0] += ".primitive";
57 parts
.erase(parts
.begin()+1);
60 TPrimitiveSet candidats
, nextStep
;
61 candidats
.push_back(rootNode
);
63 // check root validity
65 rootNode
->getPropertyByName("name", name
);
66 if (name
!= parts
.front())
69 for (uint i
=1; i
<parts
.size(); ++i
)
71 for (uint j
=0; j
<candidats
.size(); ++j
)
73 for (uint k
=0; k
<candidats
[j
]->getNumChildren(); ++k
)
77 candidats
[j
]->getChild(child
, k
);
79 child
->getPropertyByName("name", name
);
83 nextStep
.push_back(child
);
88 candidats
.swap(nextStep
);
92 result
.swap(candidats
);
94 // for (uint i=0; i<parts.size(); ++i)
96 // for (uint j=0; j<candidats.size(); ++j)
98 // std::string tmpName;
99 // std::vector<std::string> name;
100 // candidats[j]->getPropertyByName("name", tmpName);
101 // NLMISC::explode(tmpName,".",name);
104 // for(uint k=0;k<name.size();k++)
106 // if (name.at(k)==parts[i+k])
116 // if (i == parts.size()-1)
121 // for(uint k=0;k<candidats[j]->getNumChildren();k++)
123 // candidats[j]->getChild(tmpChild,k);
124 // nextStep.push_back(tmpChild);
128 //// result.push_back(candidats[j]);
135 // candidats.swap(nextStep);
138 // if (candidats.empty())
143 // result.swap(candidats);
144 //result.push_back(candidats.at(0)->getParent());
147 } // namespace NLLIGO