Re: How to model decoupled hierarchies?



Since I'm not familiar with the problem space, the thing I am missing is
how the first structure maps into the second.

The "mapping" is the whole "business logic" and the main purpose of the
software. Basically the class surface has a methode "void reconstruct(
Object &obj)" which creates the surface sections and then delegates to
their reconstruct method. The most important class is the surface
section (abstract class and concrete implementations) since it
encapsulates the actual algorithm for reconstruction.

Since reconstruction happens between two consecutive slices of the
object (triangles are generated between the vertices of (the contours
of) two slices), the section holds references to the slices. After
construction of the surface sections, during the reconstruction phase,
temporaries have to be created. This temporaries are based on the
objects slices and contours and therefore can be shared between to
sectors (one slice is part of two sectors, once as upper once as lower
slice).

Creating this temporaries is quite time-consuming. Althougth these
temporaries are constructed using slices and contours, they logically
don't belong together.
But I suspect that I might get performance gains if I make them part of
the contours ans slices. That's why I had the idea to "wrap" them into
the analogous "PerSliceElements". Since the PerSliceElements concrete
type depends on the type of the surface sections and methodes creating
them belong to the surface sector base class, this design is not really
convenient (the pointer to the shared slice elements have to be casted
on each query, which lucky don't happen too often).

So to rephrase the question: "Is there a better solution with
equivalent or better performance?"

I am guessing that is algorithmically well-defined but tedious.
Very right.

My inclination would be to encapsulate that mapping algorithm in some
sort of factory object that builds the entire Surface structure

I "sort of" implemented it. The factory is the surface which is
creating the surface sections (they do the "real" work) and manages
worker threads which call reconstruct on the sections.

I think that might eliminate the need for objects like PerSliceElements.

These elements still contain important data which is calculated using
the object.

I am guessing you only need those to abstract how the
two surface structures are related during the construction of a Surface
from an Object.

I am not sure if I understand this right, but there is just on kind of
surface, which is creator, container and "manager" of surface sections
(which are used polymorphically).

If one encapsulates the entire construction is a single
method, the need for them goes away.

The whole creation is encapsulated in the reconstruction method.

Even if one needs to navigate back to the Object elements (e.g., to get
{x,y,z} information) from the Structure elements, one can instantiate
those direct relationships as one constructs the [Surface] structure
because one will have the corresponding Object element in hand.

That's what I am doing.

[Caveat. I am making an assumption that you need the [Surface]
structure to solve some customer problem (e.g., it is a basic part of
some sort of 3D display rendering).

That's is true. But the main purpose of the surface is calling the
"reconstruction" method. Everything else is just "nice to have".

If one can eliminate
intermediate objects like PerSliceElements, then one could have
substantial performance gains in both context switches and heap operations.

That is also a reason, they I consider my design at hand as not very
well.

A downside of delegation of responsibilities is performance when the
number of objects is large. Ultimately one could delegate
responsibilities down to the point where each bit was an object and one
could have children in the time the program executes. So at some point
one needs to find abstractions where one can substitute algorithmic
processing for static structure even though static structure is the
basis of high maintainability in the OO paradigm.


In the OO paradigm the criteria for that cut-bait point is whether the
algorithm is unique to the problem in hand. IOW, one does not want to
"hide" flow of control that is important to solving the particular
problem. But if an algorithm exists outside the scope of the particular
problem, it is fair game for encapsulation in a single method. (I have
seen an entire linear programming package encoded in FORTRAN
encapsulated as a single object method.)

I think encapsulating an Object "walker" algorithm to build a [Surface]
structure is a good compromise. That's because such an algorithm really
doesn't affect or depend on anything you actually do with the [Surface]
to solve the application problem. It is simply a mapping function for
the invariants of structures that exists beyond the scope of the
particular problem (i.e., the algorithm can be abstractly specified in
structure terms rather than specific problem terms). IOW, it's not
going to change unless you make fundamental changes to the structures
themselves, so maintainability is probably not a major issue.

I am not quite sure what exactly you mean by that. Maybe you could give
an example.

Thanks a lot for your patience and help,
Thomas Kowalski

.



Relevant Pages

  • Re: Spacing Between Slices, was Re: Error in IHE Technical Framework Vol III
    ... any other terms than 'slice thickness' and "reconstruction interval', ... This is just another example of the ambiguity of English. ... It is the same issue as radiology slices and the ...
    (comp.protocols.dicom)
  • Re: Bicubic interpolation
    ... Bicubic interpolation is best approach for good quality. ... but i am not getting how to do the design for this algorithm. ... Interpolation is about reconstruction. ... use this primitive to resample a 2d image row by row and then column by ...
    (comp.graphics.algorithms)
  • Re: Bicubic interpolation
    ... Bicubic interpolation is best approach for good quality. ... but i am not getting how to do the design for this algorithm. ... Interpolation is about reconstruction. ... use this primitive to resample a 2d image row by row and then column by ...
    (comp.graphics.algorithms)
  • 3D reconstruction.
    ... I wonder if anybody could help me to produce complete algorithm ... based on the description of system for 3d reconstruction presented in ... I do not know how to obtain camera calibration from image sequence. ... I do not know, how process of image rectification goes, and what ...
    (comp.graphics.algorithms)