Skip to content

Commit 2fb37e2

Browse files
committed
Merge branch 'develop' of https://github.com/febiosoftware/FEBioStudio into develop
2 parents eca8d6d + b4051bd commit 2fb37e2

5 files changed

Lines changed: 200 additions & 3 deletions

File tree

FEBioStudio/EditPanel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SOFTWARE.*/
3535
#include <MeshTools/FESmoothSurfaceMesh.h>
3636
#include <MeshTools/FEEdgeCollapse.h>
3737
#include <MeshTools/FEFixJaggedEdges.h>
38+
#include <MeshTools/FEInsertTriangle.h>
3839
#include <MeshTools/FEExtrudeEdges.h>
3940
#include <MeshTools/FEFixSurfaceMesh.h>
4041
#include <MeshTools/FECVDDecimationModifier.h>
@@ -124,6 +125,7 @@ REGISTER_CLASS(FECurveIntersect , CLASS_SURFACE_MODIFIER, "Project Cur
124125
REGISTER_CLASS(FEWeldSurfaceNodes , CLASS_SURFACE_MODIFIER, "Weld Nodes" , 0xFF);
125126
REGISTER_CLASS(MMGSurfaceRemesh , CLASS_SURFACE_MODIFIER, "MMG Remesh" , 0xFF);
126127
REGISTER_CLASS(FEFixJaggedEdges , CLASS_SURFACE_MODIFIER, "Fix Jagged Edges", 0xFF);
128+
REGISTER_CLASS(FEInsertTriangle , CLASS_SURFACE_MODIFIER, "Insert Triangle" , 0xFF);
127129
REGISTER_CLASS(FEExtrudeEdges , CLASS_SURFACE_MODIFIER, "Extrude Edges" , 0xFF);
128130
REGISTER_CLASS(FEFillHole , CLASS_SURFACE_MODIFIER, "Fill Holes" , 0xFF);
129131

MeshTools/FEFillHole.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,18 @@ void FEFillHole::FillPieHole(FSSurfaceMesh* pm)
12741274
// clear tags
12751275
pm->TagAllNodes(0);
12761276

1277+
// see if any edges are selected. If so, we only fill holes that have at least one selected edge
1278+
bool selectedEdgesOnly = false;
1279+
for (int i = 0; i < pm->Edges(); ++i)
1280+
{
1281+
FSEdge& edge = pm->Edge(i);
1282+
if (edge.IsSelected())
1283+
{
1284+
selectedEdgesOnly = true;
1285+
break;
1286+
}
1287+
}
1288+
12771289
// build the node-edge table
12781290
m_NEL.Build(pm);
12791291

@@ -1317,8 +1329,33 @@ void FEFillHole::FillPieHole(FSSurfaceMesh* pm)
13171329
EdgeRing ri;
13181330
if (FindEdgeRing(*pm, i, ri))
13191331
{
1320-
ring.push_back(ri);
1321-
for (int j = 0; j < ri.size(); ++j) pm->Node(ri[j]).m_ntag -= 2;
1332+
// make sure at least one of the edges is selected
1333+
bool baddRing = true;
1334+
if (selectedEdgesOnly)
1335+
{
1336+
baddRing = false;
1337+
for (int j = 0; j < ri.size(); ++j)
1338+
{
1339+
auto edgeList = m_NEL.EdgeList(ri[j]);
1340+
for (int k = 0; k < edgeList.size(); ++k)
1341+
{
1342+
if (edgeList[k].pe->IsSelected())
1343+
{
1344+
baddRing = true;
1345+
break;
1346+
}
1347+
}
1348+
}
1349+
}
1350+
if (baddRing)
1351+
{
1352+
ring.push_back(ri);
1353+
for (int j = 0; j < ri.size(); ++j) pm->Node(ri[j]).m_ntag -= 2;
1354+
}
1355+
else
1356+
{
1357+
for (int j = 0; j < ri.size(); ++j) pm->Node(ri[j]).m_ntag = 0;
1358+
}
13221359
}
13231360
}
13241361
setProgress(100.0 * (i + 1.0) / (double)pm->Nodes());

MeshTools/FEInsertTriangle.cpp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*This file is part of the FEBio Studio source code and is licensed under the MIT license
2+
listed below.
3+
4+
See Copyright-FEBio-Studio.txt for details.
5+
6+
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
7+
the City of New York, and others.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.*/
26+
27+
#include "stdafx.h"
28+
#include "FEInsertTriangle.h"
29+
#include <MeshLib/FSSurfaceMesh.h>
30+
#include <map>
31+
32+
// This routine fills triangles where there are reentrant corners along a boundary
33+
// curve consisting of a chain of edges. The user-specified "angle" determines the
34+
// threshold of the deviation of the angle at the reentrant apex from 180 degrees
35+
// (an angle of zero means that a nearly straight pair of consecutive edges could be
36+
// filled with a triangle).
37+
38+
FEInsertTriangle::FEInsertTriangle() : FESurfaceModifier("Insert Triangle")
39+
{
40+
m_n = vec3d(0,0,1);
41+
AddVecParam(m_n,"normal", "approximate triangle normal");
42+
}
43+
44+
FSSurfaceMesh* FEInsertTriangle::Apply(FSSurfaceMesh* pm)
45+
{
46+
// create a copy of this mesh
47+
FSSurfaceMesh* mesh = new FSSurfaceMesh(*pm);
48+
49+
// get approximate surface normal
50+
m_n = GetVecValue(0);
51+
52+
// get selected nodes
53+
std::vector<FSNode> node;
54+
node.reserve(mesh->Nodes());
55+
std::vector<int> ID;
56+
ID.reserve(mesh->Nodes());
57+
58+
for (int i=0; i<mesh->Nodes(); ++i) {
59+
FSNode& ni = mesh->Node(i);
60+
if (ni.IsSelected()) {
61+
node.push_back(ni);
62+
ID.push_back(i);
63+
}
64+
}
65+
if (node.size() != 3) {
66+
error("Three nodes should be selected.");
67+
return nullptr;
68+
}
69+
70+
// create triangle from three selected nodes
71+
// allocate room for the new face
72+
int NF = mesh->Faces();
73+
mesh->Create(0, 0, NF + 1);
74+
FSFace& face = mesh->Face(NF);
75+
vec3d fn = (node[1].r - node[0].r) ^ (node[2].r - node[0].r);
76+
face.SetType(FE_FACE_TRI3);
77+
if (fn*m_n > 0) {
78+
face.n[0] = ID[0];
79+
face.n[1] = ID[1];
80+
face.n[2] = ID[2];
81+
} else {
82+
face.n[0] = ID[0];
83+
face.n[1] = ID[2];
84+
face.n[2] = ID[1];
85+
}
86+
face.m_gid = 0;
87+
88+
// rebuild the mesh
89+
mesh->RebuildMesh();
90+
91+
// unselect all the nodes
92+
for (int i=0; i< mesh->Nodes(); ++i) {
93+
FSNode& ni = mesh->Node(i);
94+
ni.Unselect();
95+
}
96+
97+
// determine which nodes should remain selected
98+
NF = mesh->Faces();
99+
face = mesh->Face(NF-1);
100+
for (int i=0; i< face.Edges(); ++i) {
101+
FSEdge edge = face.GetEdge(i);
102+
// check how many faces in the mesh have this edge
103+
int count = 0;
104+
for (int j=0; j< mesh->Faces(); ++j) {
105+
FSFace& oface = mesh->Face(j);
106+
if (oface.HasEdge(edge.n[0], edge.n[1])) ++count;
107+
}
108+
if (count == 1) {
109+
FSNode& n0 = mesh->Node(edge.n[0]);
110+
n0.Select();
111+
FSNode& n1 = mesh->Node(edge.n[1]);
112+
n1.Select();
113+
}
114+
}
115+
116+
return mesh;
117+
}

MeshTools/FEInsertTriangle.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*This file is part of the FEBio Studio source code and is licensed under the MIT license
2+
listed below.
3+
4+
See Copyright-FEBio-Studio.txt for details.
5+
6+
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
7+
the City of New York, and others.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.*/
26+
27+
#pragma once
28+
#include "FESurfaceModifier.h"
29+
30+
class FEInsertTriangle : public FESurfaceModifier
31+
{
32+
public:
33+
FEInsertTriangle();
34+
35+
FSSurfaceMesh* Apply(FSSurfaceMesh* mesh);
36+
37+
void SetNormal(vec3d n) { m_n = n; }
38+
39+
private:
40+
vec3d m_n;
41+
};

MeshTools/NetGenOCCMesher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ FSMesh* NetGenOCCMesher::BuildMesh()
321321
return mesh;
322322

323323
#else
324-
SetErrorMessage("This version of FEBio Studio was not built with NetGen support.");
324+
error("This version of FEBio Studio was not built with NetGen support.");
325325
return nullptr;
326326
#endif // HAS_NETGEN
327327
}

0 commit comments

Comments
 (0)