thliebig / AppCSXCAD

Minimal GUI Application using the QCSXCAD library.
http://openEMS.de
GNU General Public License v3.0
6 stars 12 forks source link

Polygon visualization artifact #4

Open blazra opened 4 years ago

blazra commented 4 years ago

Hi,

for certain polygons the AppCSXCAD is showing a weird artifact - it looks like some vertices are missing. From the openEMS --debug-PEC dump it seems like openEMS is seeing the correct polygon - just the AppCSXCAD is visualizing it incorrectly. Maybe related to this http://openems.de/forum/viewtopic.php?f=3&t=444 ?

Should look like this: image

AppCSXCAD shows this: image

openEMS PEC dump (white) with AppCSXCAD .stl export (blue) for comparison: image

I have minimized the test-case into this script:

close all
clear
clc

FDTD = InitFDTD();

CSX = InitCSX();
CSX = AddMetal(CSX, 'metal');
p(1,1) = 0.00457; p(2,1) = 0.00718;
p(1,2) = 0.00457; p(2,2) = 0.00782;
p(1,3) = 0.00492; p(2,3) = 0.00782;
p(1,4) = 0.00492; p(2,4) = 0.00768;
p(1,5) = 0.00551; p(2,5) = 0.00768;
p(1,6) = 0.00551; p(2,6) = 0.00832;
p(1,7) = 0.00492; p(2,7) = 0.00832;
p(1,8) = 0.00492; p(2,8) = 0.00818;
p(1,9) = 0.00457; p(2,9) = 0.00818;
p(1,10) = 0.00457; p(2,10) = 0.00882;
p(1,11) = 0.00398; p(2,11) = 0.00882;
p(1,12) = 0.00398; p(2,12) = 0.00718;
CSX = AddPolygon( CSX, 'metal', 200, 2, 0.00018001, p);

mesh.x = 0:10e-3;
mesh.y = 0:10e-3;
mesh.z = 0:30e-3;
CSX = DefineRectGrid(CSX, 1, mesh);

WriteOpenEMS('model.xml', FDTD, CSX);
CSXGeomPlot('model.xml');

Generated .xml and the script: appcsxcad_testcase.zip

openEMS version:

---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.35-63-gba793ac
 | (C) 2010-2018 Thorsten Liebig <thorsten.liebig@gmx.de>  GPL license
 ---------------------------------------------------------------------- 
        Used external libraries:
                CSXCAD -- Version: v0.6.2-93-gef6e409
                hdf5   -- Version: 1.10.5
                          compiled against: HDF5 library version: 1.10.5
                tinyxml -- compiled against: 2.6.2
                fparser
                boost  -- compiled against: 1_72
                vtk -- Version: 8.2.0
                       compiled against: 8.2.0
ALEEF02 commented 2 weeks ago

I'm having similar issues trying to visualize a ground plane with a hole for a via, as shown below. This portion for drawing a plane with via holes is adapted from documentation of the MATLAB portion here

bounding = {
    'x': mesh.GetSimArea()[:, 0],
    'y': mesh.GetSimArea()[:, 1],
    'z': mesh.GetSimArea()[:, 2],
    }

p = np.zeros((2, 26))
p[:, 0] = [bounding['x'][0], bounding['y'][0]]
p[:, 1] = [0, bounding['y'][0]]
a = np.linspace(-np.pi, np.pi, 19)
p[:, 2:21] = [
    (VIA_GAP + VIA_OUTTER_DIAMETER/2) * np.sin(a),
    (VIA_GAP + VIA_OUTTER_DIAMETER/2) * np.cos(a)
    ]
p[:, 21] = [0, bounding['y'][0]]
p[:, 22] = [bounding['x'][-1], bounding['y'][0]]
p[:, 23] = [bounding['x'][-1], bounding['y'][-1]]
p[:, 24] = [bounding['x'][0], bounding['y'][-1]]
p[:, 25] = [bounding['x'][0], bounding['y'][0]]
gnd.AddPolygon(p, 'z', elevation=(OUTTER_SUBSTRATE_THICKNESS + MIDDLE_SUBSTRATE_THICKNESS), priority=10)

image Where a polygon is expected on the entire top plane.

Modifying the code as such...

bounding = {
    'x': mesh.GetSimArea()[:, 0],
    'y': mesh.GetSimArea()[:, 1],
    'z': mesh.GetSimArea()[:, 2],
    }

p = np.zeros((2, 25))
p[:, 0] = [bounding['x'][0], bounding['y'][0]]
p[:, 1] = [0, bounding['y'][0]]
a = np.linspace(-np.pi, np.pi, 19)
p[:, 2:21] = [
    (VIA_GAP) * np.sin(a),
    (VIA_GAP) * np.cos(a)
    ]
p[:, 21] = [0, bounding['y'][0]]
p[:, 22] = [bounding['x'][-1], bounding['y'][0]]
p[:, 23] = [bounding['x'][-1], bounding['y'][-1]]
p[:, 24] = [bounding['x'][0], bounding['y'][-1]]
gnd.AddPolygon(p, 'z', elevation=(OUTTER_SUBSTRATE_THICKNESS + MIDDLE_SUBSTRATE_THICKNESS), priority=10)

creates this, where the polygon doesn't have the hole in the middle and is simply a triangle. image\ image

Plotting the object p in MatPlotLib verifies we have (at least geometrically) properly created the object. image