Revision: 44728
http://brlcad.svn.sourceforge.net/brlcad/?rev=44728&view=rev
Author: davidloman
Date: 2011-06-02 16:12:54 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
Add NULL_POINTER return value static. Add in recursive functions for pulling
an entire tree of geometry rather than just the children of an object.
Modified Paths:
--------------
geomcore/trunk/include/BrlcadDb.h
geomcore/trunk/src/GS/BrlcadDb.cxx
Modified: geomcore/trunk/include/BrlcadDb.h
===================================================================
--- geomcore/trunk/include/BrlcadDb.h 2011-06-02 16:11:12 UTC (rev 44727)
+++ geomcore/trunk/include/BrlcadDb.h 2011-06-02 16:12:54 UTC (rev 44728)
@@ -79,12 +79,15 @@
* Bulk build of ExtObjects from 'nameList' and place them into extList
*
* Return Values:
- * 0 = Success
+ * 0 >= Number of items added to extList;
* -1 = db_open() failed
* -2 = either nameList or extList was NULL
*/
- int getExtObjs(const std::list<std::string>* nameList,
- std::list<ExtObject*>* extList, bool recursive = false);
+ int getExtObjs(
+ const std::list<std::string>* nameList,
+ std::list<ExtObject*>* extList,
+ bool recursive = false,
+ std::string startPath = "");
private:
std::string path;
@@ -138,7 +141,7 @@
* NOTE: Does not call open() or close(). See getExtObjs().
*/
int _getExtObjs(const std::list<std::string>* nameList,
- std::list<ExtObject*>* extList, bool recursive = false);
+ std::list<ExtObject*>* extList, bool recursive, std::string startPath);
};
Modified: geomcore/trunk/src/GS/BrlcadDb.cxx
===================================================================
--- geomcore/trunk/src/GS/BrlcadDb.cxx 2011-06-02 16:11:12 UTC (rev 44727)
+++ geomcore/trunk/src/GS/BrlcadDb.cxx 2011-06-02 16:12:54 UTC (rev 44728)
@@ -31,6 +31,7 @@
int BrlcadDb::FS_PATH_NOT_VALID = -1;
int BrlcadDb::G_PATH_NOT_VALID = -2;
int BrlcadDb::CORRUPT_OBJ_DATA = -3;
+int BrlcadDb::NULL_POINTER = -4;
BrlcadDb*
BrlcadDb::makeDb(const std::string path) {
@@ -273,25 +274,31 @@
int
BrlcadDb::getExtObjs(const std::list<std::string>* nameList,
- std::list<ExtObject*>* extList)
+ std::list<ExtObject*>* extList, bool recursive, std::string startPath)
{
if (nameList == NULL || extList == NULL) return -2;
if (this->open() == false) return -1;
- int retVal = this->_getExtObjs(nameList,extList);
+ int retVal = this->_getExtObjs(nameList, extList, recursive, startPath);
this->close();
return retVal;
}
int
BrlcadDb::_getExtObjs(const std::list<std::string>* nameList,
- std::list<ExtObject*>* extList)
+ std::list<ExtObject*>* extList, bool recursive, std::string startPath)
{
- if (nameList == NULL || extList == NULL) return -2;
+ if (nameList == NULL || extList == NULL) return BrlcadDb::NULL_POINTER;
ExtObject* extObj = NULL;
std::string strObj = "";
- std::list<std::string>::const_iterator it = nameList->begin();
+ std::string newPath = "";
+ std::list<std::string>::const_iterator it;
+ int retVal = 0;
+ std::string child = "";
+ std::list<std::string> children;
+ /* Generate objects for names on nameList and add ExtObjects to extList */
+ it = nameList->begin();
for (; it != nameList->end();++it) {
strObj = *it;
@@ -302,11 +309,24 @@
if (extObj == NULL) {
/* ERROR! */
Logger::getInstance()->logERROR("BrlcadDb", "No extObject returned
for: " + strObj);
+
} else {
extList->push_back(extObj);
- }
- }
- return 0;
+ if (recursive) {
+ /* Get children of strObj */
+ children.clear();
+ retVal = this->_list(strObj, &children);
+
+ /* Recurse only if no error and >0 children */
+ if (retVal > 0)
+ newPath = startPath + "/" + strObj;
+ this->_getExtObjs( &children, extList, true, newPath);
+
+ } /* if (recursive) */
+ } /* if(extObj == NULL) */
+ } /* for loop */
+
+ return extList->size();
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today.
http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits