OpenMesh 1.9.5 ported to D
Bill Baxter
dnewsgroup at billbaxter.com
Mon Sep 24 13:45:47 PDT 2007
Jascha Wetzel wrote:
> Bill Baxter wrote:
>>> i'm curious about where it can be taken with D. circulators should
>>> simplify to delegates. maybe some of the traits business can be
>>> simplified as well.
>>
>> Well you can't really get rid of the circulators entirely. Sometimes
>> you want to go around the edges of a vertex more than once. But "one
>> time around" is certainly the common case. A second set of functions
>> that provide an opApply for circulators (and iterators) to handle that
>> common case would be nice.
>
> ah, right, and they need some state like the start vertex.
> actually, the way they look right now is pretty good.
I went ahead and added those opApplys to the iterators after your
suggestion.
> foreach ( vh; VertexVertexIterT(mesh, start_vh) ) { ... }
>> Or maybe the easiest is to endow the iterators and circulators with
>> an opApply so that this works:
>> foreach(vhandle; mesh.vertices_begin()) {
>> ...
>> }
>
> yep, for those that don't have a state.
They all have a state. You mean for those that don't need a particular
starting state?
> There wouldn't be any advantage at runtime, but FinalMeshItems and
> AttribKernel would pretty much collapse, simplfying the whole Traits
> stuff a lot. Unless i'm mistaken, the only benefit from having those two
> is to check for availability of standard properties at compile-time.
> In D we can have compile-time checks for any property. Here is a prototype:
> http://mainia.de/ctprops.d
That is pretty slick.
> That way, having standard properties merely means having a convention
> for their names and types. We could therefore easily add a large number
> of standard properties without bloating the lib and loose a lot of
> Traits complexity at the same time - D rules :)
I think would still be useful to have the most common types -- Point,
Normal, etc, defined as part of the mesh type since most practical
algorithms require those. I hacked up your ctprops to do something
along those lines.
I also think that it's good to be able to define your mesh at some point as
class Mesh(traits = DEFAULT_TRAITS)
so that if you just want a "standard mesh" you don't have to think too much.
In other words there needs to be a way to define a set of Prop!s.
So I whipped something up along those lines and put it here.
http://www.dsource.org/forums/viewtopic.php?p=16708#16708
Apart from the properties I think it might be nice if you could supply a
template mixin to the Mesh, and it would mix that for you. In that way
you can inject whatever you want into your MyMesh type. In C++ I'd make
it a base class alongside the PropertyContainer thing. But no MI in
D... Maybe PropertyContainer could be a member of the mesh instead of a
base.
--bb
More information about the Digitalmars-d-announce
mailing list