Giter Site home page Giter Site logo

Comments (3)

jpv20 avatar jpv20 commented on June 11, 2024

Kevin,

can you reply with your history from Matlab?

jonathan

from gibbon.

Kevin-Mattheus-Moerman avatar Kevin-Mattheus-Moerman commented on June 11, 2024

I cannot retrieve the full history it seems but below is a code which is very close to the steps I showed (I'll add more comments soon and will add it then as an intro/demo):

clear; close all; clc;

%% Control parameters
radiusSphere=1;

%% Plot settings

markerSize=50; 
lineWidth=2;
faceAlpha=1; 
fontSize=35;
%% Define coordinates

V=[0 0 0; 1 0 0; 0 1 0; 1 1 0]; %Vertices
F=[1 2 4 3]; %A quadrilateral face

[Ft,Vt]=quad2tri(F,V); %Convert to triangles
Ct=[1 2]'; %Face color label

%% Visualize

cFigure; 
plotV(Vt,'k.','MarkerSize',markerSize); %Vertices
gpatch(Ft,Vt,Ct,'k',faceAlpha,lineWidth);
patchNormPlot(Ft,Vt);
patchAnnotate(Ft,Vt,0.1,'FontSize',fontSize);
axisGeom;
colormap gjet; icolorbar;
camlight headlight;
drawnow;

%% Creating a sphere mesh

[F,V]=geoSphere(3,radiusSphere);
C=V(:,3); %Color as Z coordinates
CF=vertexToFaceMeasure(F,C); %Convert a nodal color to a face color

%% Visualize

cFigure; hold on;
gpatch(F,V,C,'k',faceAlpha,1);
patchNormPlot(F,V);
axisGeom;
colormap gjet; colorbar;
camlight headlight;
drawnow;

%% Cut sphere in half
% THis is where the sphere is cut in half

% Define logic to cut
logicPositive=CF>0;
[logicPositive]=triSurfLogicSharpFix(F,logicPositive,3);

F=F(logicPositive,:);
CF=CF(logicPositive,:);
[F,V]=patchCleanUnused(F,V);

Eb=patchBoundary(F,V);
indicesBoundaryCurve=edgeListToCurve(Eb);
indicesBoundaryCurve=indicesBoundaryCurve(1:end-1);

angleThreshold=(160/180)*pi;
isClosedPath=1;
[F,V,indicesBoundaryCurve]=triSurfSelfTriangulateBoundary(F,V,indicesBoundaryCurve,angleThreshold,isClosedPath);
C=V(:,3); %Color as Z coordinates
CF=vertexToFaceMeasure(F,C);

%%

cPar.depth=radiusSphere; 
cPar.patchType='tri'; 
cPar.dir=-1;
cPar.numSteps=ceil(cPar.depth/mean(patchEdgeLengths(F,V)));
cPar.closeLoopOpt=1; 
[F2,V2]=polyExtrude(V(indicesBoundaryCurve,:),cPar);
F2=fliplr(F2);

[F,V,C]=joinElementSets({F,F2},{V,V2});

[F,V,~,indFix]=mergeVertices(F,V);
Eb=patchBoundary(F,V);
indicesBoundaryCurve=edgeListToCurve(Eb);
indicesBoundaryCurve=indicesBoundaryCurve(1:end-1);

%%
cFigure; hold on;
gpatch(F,V,C,'k',faceAlpha,1);
patchNormPlot(F,V);
gpatch(F2,V2,'gw','k',faceAlpha,1);
patchNormPlot(F2,V2);
plotV(V(indicesBoundaryCurve,:),'g.-','MarkerSize',markerSize,'lineWidth',lineWidth);
axisGeom;
colormap gjet; colorbar;
camlight headlight;
drawnow;

%%

pointSpacing=mean(patchEdgeLengths(F,V));
[Fb,Vb]=regionTriMesh2D({V(indicesBoundaryCurve,[1 2])},pointSpacing,0,0);
Vb(:,3)=min(V(:,3));
Fb=fliplr(Fb);

[F,V,C]=joinElementSets({F,Fb},{V,Vb});

[F,V,~,indFix]=mergeVertices(F,V);
indicesBoundaryCurve=indFix(indicesBoundaryCurve);

%%
cFigure; hold on;
hp=gpatch(F,V,C,'k',faceAlpha,1);
patchNormPlot(F,V);
plotV(V(indicesBoundaryCurve,:),'g.-','MarkerSize',markerSize,'lineWidth',lineWidth);
axisGeom;
colormap gjet; icolorbar;
camlight headlight;
drawnow;

%%
% Define region points
[V_regions]=getInnerPoint(F,V);

cFigure; hold on;
hp=gpatch(F,V,'kw','none',0.5,1);

plotV(V_regions,'g.-','MarkerSize',markerSize,'lineWidth',lineWidth);

axisGeom;
colormap gjet; icolorbar;
camlight headlight;
drawnow;
%%

% Regional mesh volume parameter
[regionA]=tetVolMeanEst(F,V); %Volume for regular tets

%% 
% CREATING THE tetgen INPUT STRUCTURE
inputStruct.stringOpt='-pq1.2AaY';
inputStruct.Faces=F;
inputStruct.Nodes=V;
inputStruct.holePoints=[];
inputStruct.faceBoundaryMarker=C; %Face boundary markers
inputStruct.regionPoints=V_regions; %region points
inputStruct.regionA=regionA;

%% 
% Mesh model using tetrahedral elements using tetGen 
[meshOutput]=runTetGen(inputStruct); %Run tetGen 

%% 
% Access model element and patch data
Fb=meshOutput.facesBoundary;
Cb=meshOutput.boundaryMarker;
V=meshOutput.nodes;
CE=meshOutput.elementMaterialID;
E=meshOutput.elements;

%% Visualizing mesh using |meshView|, see also |anim8|

meshView(meshOutput);

%%

from gibbon.

Kevin-Mattheus-Moerman avatar Kevin-Mattheus-Moerman commented on June 11, 2024

I'll close this issue for now. Let me know if you need anything else.

from gibbon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.