ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Drawing a triangular mesh
Posted by Adil on Nov-04-2021 18:54
Hi,

I'm new to ChartDirector. Indeed, I got my developer licence yesterday.

I would like to overlay a TIN (Triangular Irregular Network) which is a 2D triangular mesh on the top of a contour chart for post-processing an engineering Finite Element application.

Because there is no direct way to plot a TIN in the library, there are two workarounds:

1) First, by plotting all the individual edges connecting two points of the TIN by calling the addLine method.

2) Alternatively, by calling the addLineLayer of an XYChart chart that will plot all the TIN edges.

Which method do you advise for greater performance? The TIN objects can typically have a size of 100000 edges for the target applications.

Thanks,
Adil

  Re: Drawing a triangular mesh
Posted by Peter Kwan on Nov-05-2021 11:07
Hi Adil,

For 100000 edges, I think a third method DrawArea.line can be considered.

I am not sure which programming langauge you are using, so I just use C# as an example. If you need me to translate the code to another programming language, please let me know.

The code is like:

.... create the contour chart as usual ....

// Draw the chart
// makeChart3 in C#, makeChart in C++
DrawArea d = c.makeChart3();

// Use DrawArea.line to add lines over the chart
for (int i = 0; i < edgeCount; ++i) {
    ... obtain end points (x1, y1) and (x2, y2) of an edge ...

    // Draw  a line with the dark grey color (0x444444) and line width = 1
    // The getXCoor/getYCoor is to convert the data coordinates to pixel coordinates
    d.line(c.getXCoor(x1), c.getYCoor(y1), c.getXCoor(x2), c.getYCoor(y2), 0x444444, 1);
}


The addLineLayer can also be fast if you can pre-processed the edges into continuous lines. That is, instead of edge A to B, edge B to C, edge C to D, you can connect them to become one line A to B to C to D. In this way, there result will be a smaller number of lines, each with many edges.

Regards
Peter Kwan

  Re: Drawing a triangular mesh
Posted by Adil on Nov-05-2021 16:52
Hi Peter,

Thanks for your suggestion. My project is in C++ but I know C# too.
I'll test your method and come back to you if there are further issues.

Kind Regards,
Adil

  Re: Drawing a triangular mesh
Posted by Adil on Nov-05-2021 16:54
Hi Peter,

Thanks for your suggestion. My project is in C++ but I know C# too.
I'll test your method and come back to you if there are further issues.

Kind Regards,
Adil