Skip to content

Commit

Permalink
various fixes to src/bool3d()
Browse files Browse the repository at this point in the history
  • Loading branch information
apaoluzzi committed Sep 10, 2019
1 parent 0bb3f2d commit 76c9402
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
16 changes: 10 additions & 6 deletions examples/3d/bool3d.jl
@@ -1,5 +1,6 @@
using LinearAlgebraicRepresentation, ViewerGL, SparseArrays
Lar = LinearAlgebraicRepresentation; GL = ViewerGL
using Base.union

# 3D Boolean example generation
#-------------------------------------------------------------------------------
Expand All @@ -12,14 +13,14 @@ EV = Lar.simplexFacets(FV)
sphere = V,FV,EV

# three cubes in "assembly"
assembly = Lar.Struct([ sphere,
Lar.t(.3,.4,.25), Lar.r(pi/5,0,0), Lar.r(0,0,pi/12), sphere,
Lar.t(-.2,.4,-.2), Lar.r(0,pi/5,0), Lar.r(0,pi/12,0), sphere ])
assembly = Lar.Struct([ cube,
Lar.t(.3,.4,.25), Lar.r(pi/5,0,0), Lar.r(0,0,pi/12), cube,
Lar.t(-.2,.4,-.2), Lar.r(0,pi/5,0), Lar.r(0,pi/12,0), cube ])

V,FV,EV = Lar.struct2lar(assembly)
GL.VIEW([ GL.GLGrid(V,FV), GL.GLFrame ]);

W, copEV, copFE, copCF, boolmatrix = Lar.bool3d(assembly)
W, (copEV, copFE, copCF), boolmatrix = Lar.bool3d(assembly)
Matrix(boolmatrix)
#three-chains = [ for k = 1:3]

Expand All @@ -33,9 +34,12 @@ AorBorC = A .| B .| C
AorBorC = .|(A,B,C)
AandBandC = A .& B .& C
AandBandC = .&(A,B,C)
AminusBminusC = .&(A, .!(B .| C)) # A - B - C

union = Matrix(copCF)' * Int.(AorBorC) # coord vector of Faces
union = .|(A,B,C)
union = Matrix(copCF)' * Int.(union) # coord vector of Faces
intersection = Matrix(copCF)' * Int.(AandBandC) # coord vector of Faces
difference = Matrix(copCF)' * Int.(AminusBminusC) # coord vector of Faces

V,CVs,FVs,EVs = Lar.pols2tria(W, copEV, copFE, copCF) # whole assembly
Fs = union
Expand All @@ -55,7 +59,7 @@ V,CVs,FVs,EVs = Lar.pols2tria(W, copEV, copFE, copCF, Fs) # part of assembly

GL.VIEW(GL.GLExplode(V,FVs,1.5,1.5,1.5,99,1));
GL.VIEW(GL.GLExplode(V,EVs,1.,1.,1.,99,1));
meshes = GL.GLExplode(V,CVs[2:end],1.5,1.5,1.5,99,0.2);
meshes = GL.GLExplode(V,CVs[2:end],1.5,1.5,1.5,99,1);
GL.VIEW( push!( meshes, GL.GLFrame) );

# GL.VIEW(GL.GLExplode(V,[EVor],1.,1.,1.,99,1));
Expand Down
4 changes: 2 additions & 2 deletions src/bool.jl
Expand Up @@ -347,12 +347,12 @@ function bool3d(assembly)
boolmatrix[k+1,l+1] = 1
end
end
return W, copEV, copFE, copCF, boolmatrix
return W, (copEV, copFE, copCF), boolmatrix
end
function bool3d(expr, assembly)
V, copEV, copFE, copCF, boolmatrix = bool3d(assembly)
# TODO please see template "bool2d()" in src/bool2d.jl
return V, copEV, copFE, copCF, boolmatrix, result
return V, (copEV, copFE, copCF), boolmatrix, result
end

################################################################################
Expand Down
4 changes: 2 additions & 2 deletions src/interface.jl
Expand Up @@ -313,10 +313,10 @@ function coboundary_1( V::Lar.Points, FV::Lar.Cells, EV::Lar.Cells, convex=true:
cscFV = Lar.characteristicMatrix(FV)
cscEV = Lar.characteristicMatrix(EV)
##if size(V,1) == 3
##copFE = u_coboundary_1( FV::Lar.Cells, EV::Lar.Cells )
##copFE = Lar.u_coboundary_1( FV::Lar.Cells, EV::Lar.Cells )
##elseif size(V,1) == 2
# greedy generation of incidence number signs
copFE = coboundary_1( V, cscFV::Lar.ChainOp, cscEV::Lar.ChainOp, convex, exterior)
copFE = Lar.coboundary_1( V, cscFV::Lar.ChainOp, cscEV::Lar.ChainOp, convex, exterior)
##end
return copFE
end
Expand Down
3 changes: 0 additions & 3 deletions src/utilities.jl
Expand Up @@ -1270,11 +1270,8 @@ original and generated edges. `V` is given by column.
function triangulate2d(V, EV)
# data for Constrained Delaunay Triangulation (CDT)
points = convert(Array{Float64,2}, V')
@show points
points_map = Array{Int64,1}(collect(1:1:size(points)[1]))
@show points_map
edges_list = convert(Array{Int64,2}, hcat(EV...)')
@show edges_list
edge_boundary = [true for k=1:size(edges_list,1)] ## dead code !!
trias = Triangle.constrained_triangulation(points,points_map,edges_list)
innertriangles = Array{Int64,1}[]
Expand Down

0 comments on commit 76c9402

Please sign in to comment.