Is there an easy way to obtain this to a list?
std::vector<BRLCAD::VectorList::Element> list;
VectorList vl;
db->Plot(objectName.c_str(), vl);
class Callback : public BRLCAD::VectorList::ElementCallback {
bool operator()(BRLCAD::VectorList::Element *element) {
list.push_back(*element);
return true;
}
};
Callback b;
vl.Iterate(b);
I need to get the elements in a VectorList to a list (vector) @Daniel Rossberg
Apparently I can't get them to a list even if use globally available lists.
Since *element
is stack allocated it will have been destroyed if I just add element
(pointer) to a list (vector<Element*>) by the time I actually access it.
Also I cannot copy it and create a new object since Element
is an abstract class. Can somebody help me with this?
It is possible to create a list of copies from the elements, but I decided no not explicitly support it (e.g. by providing a Clone() method), because this is not how this list should be used. It would slow down the process. Instead, you should move the corresponding drawing functions to a call-back class:
class ElementOpenGL : public BRLCAD::VectorList::ConstElementCallback {
public:
virtual bool operator()(const Element* element) {
switch (element->Type()) {
case BRLCAD::VectorList::Element::PointDraw:
BRLCAD::VectorList::PointDraw* pointDraw = static_cast<BRLCAD::VectorList::PointDraw*>(element);
// put your OpenGL code here
break;
case BRLCAD::VectorList::Element::PointSize:
BRLCAD::VectorList::PointSize* pointSize = static_cast<BRLCAD::VectorList::PointSize*>(element);
// put your OpenGL code here
break;
// ...
}
}
};
void DrawVectorList(const VectorList& vectorList) {
ElementOpenGL elementOpenGL;
vectorList.Iterate(elementOpenGL);
}
This code demonstrates the principle only. It doesn't contain all necessary methods, checks, etc..
Any future plans to bring coreinterface to the main repo? What if I want to access coreinterfaces from there? My current plan is to rewrite stuff not to include things from coreinterfaces. Alternatively do we plan to bring it there?
We're actually planning to migrate the main repository to github - once we do that, we may do something like include coreInterface as a submodule - not decided yet.
@Sadeep Darshana By keeping it separate, the MOOSE API cannot not become tangled with the low-level C API. That's entirely intentional and helps keep the implementation clean.
It does complicate some things, but for now it's worth it.
starseeker said:
We're actually planning to migrate the main repository to github - once we do that, we may do something like include coreInterface as a submodule - not decided yet.
you might keep it as a seperate branch actually
It's also pure C++, and while we do allow C++ in the low-level library implementation (i.e., not in public headers), they are nowhere close to being good C++ designwise even on the backend.
starseeker said:
We're actually planning to migrate the main repository to github - once we do that, we may do something like include coreInterface as a submodule - not decided yet.
Possibly the other way around since it's layered on top. It's more like some of the BRL-CAD libs are proper 3rd party dependencies.
Where it gets complicated is wanting to use MOOSE in utilities and new commands, as they can't live in the main repo, but that's the tradeoff for now.
Once the main build is shifted to the superbuild pattern, we can actually start making pieces of BRL-CAD into "proper" projects that are built as part of the parent build. Once we do that, coreInteface could do the same thing and reference those subprojects.
Sadeep Darshana said:
Any future plans to bring coreinterface to the main repo?
The MOOSE is designed to be entirely on top of the BRL-CAD core libraries. There is no need to move it to the main (or more precisely core) repository. Vice versa, MOOSE classes should not be used in the core libraries.
Not to be confused with the core interface ;)
MOOSE demonstrates how I think the interface should be constructed on top of the classical BRL-CAD libraries. The functionality is the same as the one of rt^3's coreInterface, but if you talk about integration and software architecture, the development direction is more MOOSE than coreIntterface.
What do you see as the biggest architecture and integration difference between coreInterface and MOOSE?? I kind of viewed them as "the same", just with MOOSE now slightly more cleaned up and evolved but architecturally the same. Both present a canonical OO API over the low-level libs. Are there major implementation differences?
What does MOOSE mean? Do the letters stand for words?
It's fluctuated, but this is what has stuck with me:
Modular Object-Oriented Solidity Engine
It's also a play on words homage as it's how you pronounce the last name of the person that started BRL-CAD, Mike Muuss.
Ubject-Uriented doesn't quite work, though ;)
noticed his name in dedication
brilliant scientist, huge personality, super friendly, got me latched onto the project young :)
I also encountered his name when for some reason I was looking at ping command
Was the same person when I looked back at the dedication
The API of MOOSE and coreInterface are essentially the same. The difference is how they are build, how their libraries depend on the BRL-CAD installation.
The brlcad.dll for Windows is a hack in the main repository. I tried to to extend it to build a library for Linux too, but without success. I.e., I succeeded to build a shared library, but it still depends on the BRL-CAD installation. The standard build in rt^3 depends on the BRL-CAD installation too.
The problem with the BRL-CAD installation is that a program from for example Debian doesn't has it. And, without being available in the big distributions, the number of users is very limited.
Therefore MOOSE demonstrates an approach and architecture to overcome this. Without affecting the standard BRL-CAD repository and build, it generates a single self-consistent library (i.e., it depends only on some libraries contained in every big Linux distribution) which can go into a libbrlcad package, defines a SDK which can go into a libbrlcad-dev package, and there is an example for an application using these too.
Therefore, the difference is not in the features of the API, but the integration with the other software.
Ah, I took your earlier comment to mean that the APIs were different, hence a little surprise.
For what it's worth, cmake now finally does provide a sublibrary mechanism that would make a libbrlcad possible without recompilation so it could once again simply be the union of its sublibs.
I mean, to be clear, MOOSE also requires a build of BRL-CAD, it just presumably doesn't need to be installed since it's linking in all the libs statically. It's the result that is standalone because of the static linkage.
BTW, there are minor differences in the C++ APIs:
@Daniel Rossberg Any chance I can get a permanent Object*
instead of void Database::Get ( const char* objectName, ObjectCallback& callback)?
Because this is very slow when editing properties
Think about dragging an object with mouse, I have to call Get (which will search the entire db for the string path I give) for every delta change of a property
The drawing speed is also not sufficient for such a scenario.
Sadeep Darshana said:
Daniel Rossberg Any chance I can get a permanent
Object*
instead of void Database::Get ( const char* objectName, ObjectCallback& callback)?
There is a Object* Get(const char* objectName) const;
method (right below the other Get() method you mentioned in brlcad/ConstDatabase.h ;). But, you need to Destroy() it when you are done. And, don't forget to write it back to the database to see the effect.
I didn't think I could use it since it was a copy. Didn't occur to me that I could write it back.
Does Object::Name() contains the entire path too as opposed to just the name, to determine where in the hierarchy it is added?
Hey @Sean
The Object subclasses are just wrappers for the rt_~_internal structs and just is their behavior. Modifying these structs doesn't change the database either. You have to use rt_~_import5() and rt_~_export5() to read/write them from/to the database. The Get() method with the call-back in the C++ interface does the write-back automatically. If you use the other Get(), you need to export the struct explicitly to the database if you want to have the changes an effect to it.
However, this should make it easier to implement the dialogs. "OK" calls Set(), "Cancel" not.
The name is just the name of the object. The path is build from the combinations in between the selected object (usually a group combination) and the object in question. This path doesn't have to be unique.
You can get the path from a tree walk algorithm.
is Combination::SetHasColor(false) working?
because when I query with Combination::HasColor() after calling Combination::SetHasColor(false) on a combination it still gives true.
Combination::SetHasColor(true) is working as expected
I also have trouble with setting color
Combination::SetGreen, Combination::SetBlue, Combination::SetRed apparently don't change the colors.
Database::Set gives an error when setting Combinations, it worked fine for solids. So I'm setting via ObjectCallback.
What am I doing wrong?
Sadeep Darshana said:
is Combination::SetHasColor(false) working?
because when I query with Combination::HasColor() after calling Combination::SetHasColor(false) on a combination it still gives true.
Can you debug this and see what happens in line 992 of Combination.cpp? Maybe
Internal()->rgb_valid = (value ? '\1' : '\0');
would be better there.
Or
Internal()->rgb_valid = (value ? 1 : 0);
?
Sadeep Darshana said:
Combination::SetGreen, Combination::SetBlue, Combination::SetRed apparently don't change the colors.
Database::Set gives an error when setting Combinations, it worked fine for solids. So I'm setting via ObjectCallback.
What am I doing wrong?
Which values do your colors have?
And - which error?
Last updated: Jan 09 2025 at 00:46 UTC