Subject:
|
Re: dll file for use with Visual Basic Express
|
Newsgroups:
|
lugnet.cad.dev
|
Date:
|
Wed, 18 Jun 2008 20:00:39 GMT
|
Viewed:
|
8990 times
|
| |
| |
In lugnet.cad.dev, Roland Melkert wrote:
> But I think, if there was going to be an 'official' LDraw api it should
> be open source C++ or even C core wise.
>
> You could then compile this 'core' source into a DLL for windows and
> create additional source for Delphi, Visual Basic, etc wrapping it in
> classes in the client language.
For what it's worth, LDView is Open Source (GPL v2), and all of its LDraw file
loading code is kept in a separate library (which I call LDLoader). This
library depends on one other of my libraries (which I call TCFoundation, short
for Travis Cobbs's Foundation library). In theory, anyone who is happy with GPL
v2 can use LDLoader from LDView, but I've never really advertised it as a
general-purpose solution. LDLoader is C++. Accessing it from C would require a
C wrapper library to be written.
LDLoader compiles and builds on Windows, Mac, and Linux (as well as likely other
platforms). Also, in Windows it has been built under VC++ 6, VC++ 2003, VC++
2005, and VC++ 2008.
Since LDLoader makes sure not to have multiple copies of the same file loaded
into memory (it uses multiple references to the same data), it cannot provide a
full BFC solution. Some of the actual BFC logic has to be in the code that
traverses LDLoader's tree, since a cylinder primitive (for example) can be used
in different places with three different BFC states: unknown, normal, or
inverted.
> But it might be hard to create an efficient api because reading dat
> files is mostly about pushing data around, and every application has
> different requirements on how that data is used. Therefore the services
> of the API might be little more then returning a list of eg triangle
> coordinates.
LDLoader provides a model object (LDLMainModel), and actually turning that into
geometry is the responsibility of the user. All the model information is kept
in easily accessible format, though. So, for instance when you're looking at a
triangle line, you get a list of 3 points, a color, and BFC info. A quad line
is the same, but with 4 points. Triangles, quads, lines and conditional lines
all share a common base class, so you can ask it for the point count and
individual points. And LDView itself of course can act as a sample
implementation of using LDLoader.
> And because most applications need different kinds of data structures
> using the API might cause considerable overhead due to converting the
> API data to internal data etc.
Well, the data needs to be loaded into memory, and while it's possible to load
things directly into your final data structures, I'm not sure it's possible to
do this particularly efficiently. LDLoader caches all the files that have been
loaded so that when it comes to a reference to a file that has already been
loaded, it simply hooks into the existing one, instead of reloading the file.
Any good parser will do this, of course, but doing this while having the data
end up directly in final data structures is tough. For example, many (most?)
LDraw tools really want parts to be individual entities. So they don't need the
hierarchy of information underneath, they just want all the geometry for the
whole part. So you need to first load the part as a hierarchy, and then
"flatten" it. At the moment, part flattening is left up to LDLoader users (and
LDView is the only user), but I could add the flattening as a discreet operation
there fairly easily.
LDLoader also has some other useful stuff, like a primitive recognition class.
Create a subclass of that, and call into its primitive recognition function, and
it will call a different member function in your sub-class for each type of
recognized primitive, after having extracted all the pertinent data from the
filename (like knowing that 1-4cyli.dat is a cylinder primitive with 0.25 as the
cylinder fraction). I do this while traversing the LDLoader's model tree to
trigger my custom primitive substitution code in LDView.
--Travis
|
|
Message has 2 Replies: | | Re: dll file for use with Visual Basic Express
|
| I forgot to mention something fairly important (which may be obvious). LDLoader is a library for loading LDraw files into an internal memory format that is easy to deal with. It handle parsing, error checking (and reporting, via callbacks), and some (...) (16 years ago, 18-Jun-08, to lugnet.cad.dev)
| | | Re: dll file for use with Visual Basic Express
|
| (...) I know that LDView is a very good tool. And I know also that the code is under GPL. But there are people out there (me too) that do not know about C or C++. So it would be great to have a DLL to handle the core methods (and maybe objects) for (...) (16 years ago, 19-Jun-08, to lugnet.cad.dev)
|
Message is in Reply To:
| | Re: dll file for use with Visual Basic Express
|
| (...) I like the idea, I had some head breakers while trying to read LDraw files correctly the first time (especially regarding to reading recursive winding information). But I think, if there was going to be an 'official' LDraw api it should be (...) (16 years ago, 18-Jun-08, to lugnet.cad.dev)
|
8 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|