Need to merge 3 "csg" faces and get rid of the boundary only between 2 of them

5 views (last 30 days)
I am creating shapes with csg command. I have 3 rectangles (R1,R2,R3 labeled F1,F2,F3 in figure below), thus 2 boundaries (E11, E5). I would like to delete the boundary (E11) between 2 faces F2 & F3. I can delete the edge (E11) by manipulating directly the matrix "dl" but then I still have separated subdomains F2 & F3. The command "csgdel" deletes all common boundaries whatever "bt" tensor I put in it.
Here is the piece of code below:
close all;
clear all;
% build basic shapes
R1 = ([3 4 -0.025 0.025 0.025 -0.025 -0.075 -0.075 -0.0625 -0.0625]');
R2 = ([3 4 -0.025 0.025 0.025 -0.025 -0.0625 -0.0625 -0.057 -0.057]');
R3 = ([3 4 -0.005 0.005 0.005 -0.005 -0.057 -0.057 0 0]');
% Combine the shapes into one matrix
gd = [R1,R2,R3];
% Give names for the shapes
ns = char('R1','R2','R3');
ns = ns';
% Specify the union of shapes
% Use + for union, * for intersection, - for set difference, and
% parentheses for grouping. + and * have the same grouping precedence. - has higher
% grouping precedence.
sf = 'R1+(R2+R3)';
% combines the basic shapes using the set formula
[dl,bt] = decsg(gd,sf,ns);
% View the geometry with and without boundary removal.
figure;
pdegplot(dl,'EdgeLabels','on','FaceLabels','on');
axis equal;
% Here I would like to remove only E11 and keep 2 domains F1 and F2 (merge
% of R2+R3)
% I tried the follwing below
dl1=dl
dl1(:,11)=[]; % this would only remove E11 but I still have 2 domains F2 and F3
figure;
pdegplot(dl1,'EdgeLabels','on','FaceLabels','on');
axis equal;
% This removes ALL face boundaries (which is not what I want)
[dl2,bt2] = csgdel(dl1,bt);
figure;
pdegplot(dl2,'EdgeLabels','on','FaceLabels','on');
axis equal;
I appreciate your help.

Accepted Answer

Ravi Kumar
Ravi Kumar on 14 Feb 2018
Looks like this is what you want:
close all;
% build basic shapes
R1 = ([3 4 -0.025 0.025 0.025 -0.025 -0.075 -0.075 -0.0625 -0.0625]');
R2 = ([3 4 -0.025 0.025 0.025 -0.025 -0.0625 -0.0625 -0.057 -0.057]');
R3 = ([3 4 -0.005 0.005 0.005 -0.005 -0.057 -0.057 0 0]');
% Combine the shapes into one matrix
gd = [R1,R2,R3];
% Give names for the shapes
ns = char('R1','R2','R3');
ns = ns';
% Specify the union of shapes
% Use + for union, * for intersection, - for set difference, and
% parentheses for grouping. + and * have the same grouping precedence. - has higher
% grouping precedence.
sf = 'R1+R2+R3';
% combines the basic shapes using the set formula
[dl,bt] = decsg(gd,sf,ns);
% View the geometry with and without boundary removal.
figure;
pdegplot(dl,'EdgeLabels','on','FaceLabels','on');
axis equal;
% Delete edge 11
[dl2,bt2] = csgdel(dl,bt,11);
figure;
pdegplot(dl2,'EdgeLabels','on','FaceLabels','on');
axis equal;

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!