G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsTriMeshToSolid< T > Class Template Reference

Detailed Description

template<class T>
class gismo::gsTriMeshToSolid< T >

Class gsTriMeshToSolid object.

Construct an instance of this class from a gsMesh, and then use it to perform "CAD model reconstruction" to produce a gsSolid.

+ Collaboration diagram for gsTriMeshToSolid< T >:

Public Member Functions

void calcPatchNumbers ()
 Each face obtains a patch number, faces of the same number belong to the same patch.
 
gsBSpline< T > * calcTCurve (Vertex v1, Vertex v2)
 calculates a B-spline of degree one from 2 vertices. More...
 
gsBSpline< T > * calcTCurve (Vertex v1, Vertex v2, Vertex v3)
 calculates a B-spline of degree two from 3 vertices. More...
 
gsCurveLoop< T > * calculateLoop (std::vector< Vertex > outerPoints, std::vector< bool > const &isCorner, bool noSmooth=false)
 calculates a curve loop consisting of B-spline curves of degree one and two from a vector of vertices and the information about the convexity of these vertices. More...
 
void divideAndMergePatches (T innerAngle, T patchAreaWeight, T mergeSmallPatches)
 Improve surface segmentation by using more complex rules. More...
 
void getFaces (std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag)
 Computes data describing the patch structure of the mesh. More...
 
void getFeatures (T angleGrad, bool &bWarnNonManifold, bool &bWarnBorders)
 generates edges for a mesh consisting of vertices and faces. Determines if these edges are sharp, depending on the angle between the two adjacent faces of the edges. More...
 
void getPatchData (T angle, T innerAngle, T patchAreaWeight, T mergeSmallPatches, std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag, std::string filenameFeatures, int useFeatures)
 Computes data describing the patch structure of the mesh. Combines getFeatures and getFaces. More...
 
void readEdges (std::string const &fn, std::vector< gsEdge< T > > &edges)
 reads a text file consisting of lines of 6 values, each line representing an edge. More...
 
void setSharpEdges (std::vector< gsEdge< T > > &featEdges, int useFeatures)
 Sets sharp edges according to the value of useFeatures. More...
 
void storeNeighboringFaces ()
 Store each edge's neighboring faces.
 
void toSolid (gsSolid< T > &sl, std::vector< std::vector< VertexHandle > > &iPoints, std::vector< std::vector< VertexHandle > > &oPoints, std::vector< std::vector< std::vector< VertexHandle > > > &innerBdrys, std::vector< std::vector< Vertex > > &innerBdrysMassP, std::vector< std::vector< bool > > &oPointsConvexFlag, std::vector< gsMesh< T > * > &paraMeshes, std::vector< gsMesh< T > * > &fitMeshes, std::vector< gsMesh< T > * > &patchMeshes, int kvOuterPoints, int kvAdditionalInnerPoints, bool plot, int meshPoints, bool moreInner=true, T wE=5, T wI=1, int closeBoundary=0, bool noSmooth=false)
 Parametrized a number of patches given by iPoints, oPoints, innerBdrys, innerBdrysMassP and oPointsConvexFlag, fits B-spline surfaces to them and trimmes the resulting surfaces. The trimmed surfaces are then added to the empty solid sl and a half-edge structure for sl is generated. If desired, in paraview plotable meshes to visualize the solid are generated. More...
 

Static Public Member Functions

static bool approxEqual (const gsEdge< T > &e1, const gsEdge< T > &e2)
 checks if two edges are very close to each other. More...
 
static T calcAngle (EdgeHandle e1, EdgeHandle e2, int faceNum)
 calculates the conditioned angle between 2 edges. More...
 
static T calcArea (FaceHandle f1)
 using Heron's Formula for the area of a triangle. More...
 
static T calcBdryLength (std::vector< VertexHandle > vec)
 Adds up the lengths between 2 neighboring vertices of a vector of vertices. More...
 
static T calcDist (VertexHandle v1, VertexHandle v2)
 calculates the distance between 2 vertices. More...
 
static T calcWeight (VertexHandle v1, VertexHandle v2, std::set< VertexHandle > const &vertexFaceSet)
 calculates a weight between 2 vertices used in Floater's algorithm. More...
 
static gsVertex< T > getMassP (std::vector< VertexHandle > vec)
 calculates the mass point of a vector of vertices. More...
 
static Vertex giveMidpoint (Vertex v1, Vertex v2)
 calculates the midpoint of two vertices. More...
 
static std::vector< bool > isCorner (std::vector< VertexHandle > const &vertexVec3d)
 checks whether vertices are corners. More...
 
static int normalMult (gsVector3d< T > globalNormal, std::vector< FaceHandle > &face, int bigFaceIdx)
 

Member Function Documentation

bool approxEqual ( const gsEdge< T > &  e1,
const gsEdge< T > &  e2 
)
static

checks if two edges are very close to each other.

Parameters
e1- first edge.
e2- second edge.
Returns
true if the points of the edges are closer to each other than one percent of the length of the first edge.
T calcAngle ( EdgeHandle  e1,
EdgeHandle  e2,
int  faceNum 
)
static

calculates the conditioned angle between 2 edges.

Parameters
e1- first edge.
e2- second edge.
faceNum- number of the patch, used to compute the normal.
Returns
the conditioned angle.
T calcArea ( FaceHandle  f1)
static

using Heron's Formula for the area of a triangle.

Parameters
f1- the face of which the area shall be calculated.
Returns
the area of the input face f1.
T calcBdryLength ( std::vector< VertexHandle vec)
static

Adds up the lengths between 2 neighboring vertices of a vector of vertices.

Parameters
vec- a vector of vertices describing the boundary.
Returns
the length of the input vector vec.
T calcDist ( VertexHandle  v1,
VertexHandle  v2 
)
static

calculates the distance between 2 vertices.

Parameters
v1- first vertex.
v2- second vertex.
Returns
the distance.
gsBSpline< T > * calcTCurve ( Vertex  v1,
Vertex  v2 
)

calculates a B-spline of degree one from 2 vertices.

Parameters
v1- first vertex.
v2- second vertex.
Returns
the B-spline.
gsBSpline< T > * calcTCurve ( Vertex  v1,
Vertex  v2,
Vertex  v3 
)

calculates a B-spline of degree two from 3 vertices.

Parameters
v1- first vertex.
v2- second vertex.
v3- third vertex.
Returns
the B-spline.
gsCurveLoop< T > * calculateLoop ( std::vector< Vertex outerPoints,
std::vector< bool > const &  isCorner,
bool  noSmooth = false 
)

calculates a curve loop consisting of B-spline curves of degree one and two from a vector of vertices and the information about the convexity of these vertices.

Parameters
outerPoints- the vertices representing the boundary.
isCorner- information about the convexity of the vertices.
noSmooth- if set to 1, only curves of degree one will be used for the curve loop.
Returns
the resuting curve loop.
T calcWeight ( VertexHandle  v1,
VertexHandle  v2,
std::set< VertexHandle > const &  vertexFaceSet 
)
static

calculates a weight between 2 vertices used in Floater's algorithm.

Parameters
v1- first vertex.
v2- second vertex.
vertexFaceSet- used to check if both vertices are in the same patch.
Returns
the weight.
void divideAndMergePatches ( innerAngle,
patchAreaWeight,
mergeSmallPatches 
)

Improve surface segmentation by using more complex rules.

Parameters
innerAngle- after the initial patch generation there is the possibility to subdivide the larger patches by a smaller angle. Larger is defined by patchAreaWeight. innerAngle should be smaller than angle, else it will not have any effect.
patchAreaWeight- patchAreaWeight determines how large a patch has to be such that it is subdivided by using the parameter innerAngle.
mergeSmallPatches- by using a low angle a lot of small patches might be produced. mergeSmallPatches gives the opportunity to merge the small patches. mergeSmallPatches decides how "small" the patches are allowed to be before they are merged. A value of 1 will merge patches if the area of them is smaller than the average area. A value of 0 turns this option off.
void getFaces ( std::vector< std::vector< VertexHandle > > &  iPoints,
std::vector< std::vector< VertexHandle > > &  oPoints,
std::vector< std::vector< std::vector< VertexHandle > > > &  innerBdrys,
std::vector< std::vector< Vertex > > &  innerBdrysMassP,
std::vector< std::vector< bool > > &  oPointsConvexFlag 
)

Computes data describing the patch structure of the mesh.

Parameters
[out]iPoints- the data about the inner points of a patch is stored in an unsorted vector. For each patch such a vector is generated. The parameter iPoints is a vector of these generated vectors.
[out]oPoints- the data about the boundary points of a patch is stored in a counter clockwise sorted vector. For each patch such a vector is generated. The parameter oPoints is a vector of these generated vectors.
[out]innerBdrys- the data about each hole of a patch is stored in a clockwise sorted vector. For each hole of a patch such a vector is generated. For each patch a vector of its holes is generated. The parameter innerBdrys is a vector of these generated vectors.
[out]innerBdrysMassP- the data about the mass points of each hole is stored here.
[out]oPointsConvexFlag- each boundary point can be convex of not, depending on the turning angles of the adjacent edges on the boundary.
void getFeatures ( angleGrad,
bool &  bWarnNonManifold,
bool &  bWarnBorders 
)

generates edges for a mesh consisting of vertices and faces. Determines if these edges are sharp, depending on the angle between the two adjacent faces of the edges.

Parameters
angleGrad- if the angle (degree) between the two adjacent faces of an edge is bigger than angleGrad the edge is marked as sharp.
[out]bWarnNonManifold- set to one if an edge is detected with more than 2 adjacent faces.
[out]bWarnBorders- set to one if an edge is detected with 1 adjacent face.
gsVertex< T > getMassP ( std::vector< VertexHandle vec)
static

calculates the mass point of a vector of vertices.

Parameters
vec- a vector of vertices from which the mass points is calculated.
Returns
the mass point
gsTriMeshToSolid< T >::Vertex giveMidpoint ( Vertex  v1,
Vertex  v2 
)
static

calculates the midpoint of two vertices.

Parameters
v1- first vertex.
v2- second vertex.
Returns
the Vertex in the middle of v1 and v2.
std::vector< bool > isCorner ( std::vector< VertexHandle > const &  vertexVec3d)
static

checks whether vertices are corners.

Parameters
vertexVec3dvector of vertices.
Returns
vector indicating whether the corresponding vertex is a corner or not.
Todo:
Verify that this description is correct.
int normalMult ( gsVector3d< T >  globalNormal,
std::vector< FaceHandle > &  face,
int  bigFaceIdx 
)
static

Check if a given normal vector is consistent with a collection of triangles. Return +1 if the inner product of globalNormal with each triangle's normal is positive. Return -1 if all the inner products are negative. Return 0 if mixed.

void readEdges ( std::string const &  fn,
std::vector< gsEdge< T > > &  edges 
)

reads a text file consisting of lines of 6 values, each line representing an edge.

Parameters
fn- path to text file.
[out]edges- vector of the resulting edges.
void setSharpEdges ( std::vector< gsEdge< T > > &  featEdges,
int  useFeatures 
)

Sets sharp edges according to the value of useFeatures.

Parameters
featEdges- a vector of edges which can be used to manually add features.
useFeatures- if set to 1 the text file is used to add the features from the text file. If set to 2 these features are used exclusively.