gibbonCode / GIBBON

The Geometry and Image-Based Bioengineering add-On for MATLAB
http://gibboncode.org/
GNU Affero General Public License v3.0
187 stars 60 forks source link

Cannot import .smesh file in runTetGen #139

Closed wu-qiyuan closed 2 years ago

wu-qiyuan commented 2 years ago

I was following the example from doc to import mesh from .stl file and generate mesh using runTetGen() function, but got an error like this:

--- Importing TetGen files --- 20-Jun-2022 12:25:46 Warning: path/GIBBON/data/temp/temp.1.node import unsuccesful > In importTETGEN (line 29) In runTetGen (line 354) In test (line 51) --- Done --- 20-Jun-2022 12:25:49

A .smesh file was created in /temp folder but was not read. Here's the log previous to the warning listed above: (It seems not to be the GLIBC version problem because I've tried same thing on another Windows machine, and the .smesh file was checked to be fine)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- Writing SMESH file --- 20-Jun-2022 12:25:42 ----> Adding node field ----> Adding facet field ----> Adding holes specification ----> Adding region specification --- Done --- 20-Jun-2022 12:25:42 --- Running TetGen to mesh input boundary--- 20-Jun-2022 12:25:42 path/GIBBON/lib_ext/tetGen/lin64/tetgen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by path/GIBBON/lib_ext/tetGen/lin64/tetgen) --- Done --- 20-Jun-2022 12:25:42

According to the documentation, there should be an utility to import .smesh file and get output like this:

Opening /mnt/data/MATLAB/GIBBON/data/temp/temp.smesh.

Is there any way to solve this? Thank you!

Here's my code:

clear; close all; clc;

% plot settings
fontSize=15;
faceAlpha1=0.3;
faceAlpha2=1;
cMap=gjet(4);
patchColor=cMap(1,:);
markerSize=25;

%Set main folder
defaultFolder = fileparts(fileparts(mfilename('fullpath')));
% pathName=fullfile(defaultFolder,'testcase1');
pathName=fullfile(defaultFolder,'data','STL');
% pathName = defaultFolder;

%File name for STL
fileName=fullfile(pathName,'femur.stl');

[stlStruct] = import_STL(fileName);

F=stlStruct.solidFaces{1}; %Faces
V=stlStruct.solidVertices{1}; %Vertices

[F,V]=mergeVertices(F,V); % Merging nodes

% cFigure;
% title('Imported patch data from STL','fontSize',25);
% gpatch(F,V,'gw');
% axisGeom;
% camlight('headlight');
% lighting phong; axis off;
% gdrawnow;

C=ones(size(F,1),1); %Face boundary markers (aka face colors)
V_regions=getInnerPoint(F,V); %Define region points
V_holes=[]; %Define hole points
[regionTetVolumes]=tetVolMeanEst(F,V); %Volume estimate for regular tets
stringOpt='-pq1.2AaY'; %Options for tetgen

%Create tetgen input structure
inputStruct.stringOpt=stringOpt; %Tetgen options
inputStruct.Faces=F; %Boundary faces
inputStruct.Nodes=V; %Nodes of boundary
inputStruct.faceBoundaryMarker=C;
inputStruct.regionPoints=V_regions; %Interior points for regions
inputStruct.holePoints=V_holes; %Interior points for holes
inputStruct.regionA=regionTetVolumes; %Desired tetrahedral volume for each region

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

E=meshOutput.elements; %The elements
V=meshOutput.nodes; %The vertices or nodes
CE=meshOutput.elementMaterialID; %Element material or region id
Fb=meshOutput.facesBoundary; %The boundary faces
Cb=meshOutput.boundaryMarker; %The boundary markers

hf=cFigure;
subplot(1,2,1); hold on;
title('Input boundaries','FontSize',fontSize);
hp(1)=gpatch(Fb,V,Cb,'k',faceAlpha1);
hp(2)=plotV(V_regions,'r.','MarkerSize',markerSize);
legend(hp,{'Input mesh','Interior point(s)'},'Location','NorthWestOutside');
axisGeom(gca,fontSize); camlight headlight;
colormap(cMap); icolorbar;

hs=subplot(1,2,2); hold on;
title('Tetrahedral mesh','FontSize',fontSize);

% Visualizing using |meshView|
optionStruct.hFig=[hf,hs];
meshView(meshOutput,optionStruct);

axisGeom(gca,fontSize);
gdrawnow;
Kevin-Mattheus-Moerman commented 2 years ago

@wu-qiyuan thanks for trying GIBBON and for posting this issue.

This is difficult to trouble shoot. If the file is there it should import okay, unless it is empty or the content is somehow invalid.

Are there any other tetgen error/warning messages? Have you looked at the content of the smesh file? Does it look okay?

wu-qiyuan commented 2 years ago

Thank you for responding! The .smesh file is OK, but not other files (e.g. .node , .ele) generated. I reinstalled GIBBON on Windows machine and it worked! The issue is probably due to GLIBC version.