mesh.h
来自「finite element mesh 参数化有限元网格划分」· C头文件 代码 · 共 922 行 · 第 1/3 页
H
922 行
\param removedFaces \out If not NULL, will contain the ID's of the faces which were removed during the process
\param removedEdges \out If not NULL, will contain the IDs of the edges which were removed during the process
\retval OK Operation succeeded
\retval VertexNotFound No vertex was found with the given ID
\retval VerticesNotIncident One of the left and right vertices is not incident to the given vertex to be split
\note The output lists need to be allocated before use. Also, the function does not empty the lists before use, so make sure the lists are empty (unless you want the new data to be added to previous list elements).
*/
RESULT vertexSplit(VertexID vID, Coord coordinate, VertexID left, VertexID right, VertexID& newVertex, LinkedList<FaceID>* newFacesIDs=NULL, LinkedList<FaceID>* removedFaces=NULL, LinkedList<EdgeID>* removedEdges=NULL);
/** Adds a new vertex at the specified coordinate, and adds new faces to the model. The new faces that will be created are: (in the correct orientation)\n
\e newVertex \e neighbouringVertices[0].v1 \e neighbouringVertices[0].v2 \n
\e newVertex \e neighbouringVertices[1].v1 \e neighbouringVertices[1].v2 \n
\e newVertex \e neighbouringVertices[2].v1 \e neighbouringVertices[2].v2 \n
etc. \n
Which means that in each new face, the new added vertex is the first vertex, then the 2 other vertices are defined as an Edge in \e neighbouringVertices
\param coordinate Coordinate of the new vertex.
\param vID \out The ID of the new added vertex
\param neighbouringVertices A list of Edges. Each Edge defines a new face (along with the new vertex) to be added.
\param newFacesIDs If not NULL, will contain the IDs of the new faces which were created during the process
\retval OK Operation succeeded
\retval VertexNotFound One of the given neighboring vertices' IDs was not found.
\note if \e neighbouringVertices is NULL, the vertex is added with no adjacent vertices \n
The output list needs to be allocated before use. Also, the function does not empty the lists before use, so make sure the lists are empty (unless you want the new data to be added to previous list elements).
*/
RESULT addVertex(Coord coordinate, VertexID& vID, const LinkedList<Edge>* neighbouringVertices = NULL, LinkedList<FaceID>* newFacesIDs = NULL);
/** Adds a face to the mesh
\param face Specifies the new face to be added, according to its 3 vertices' IDs
\param fID \out The ID of the new added face
\param check Whether to check the mesh for the existence of such a face
\param color The color of the new face, or NULL for the default face color
\retval OK Operation succeeded
\retval FaceExists \e check is true, and the face already exists in the mesh (the new face was NOT added to the mesh as a result).
\retval VertexNotFound No vertex was found with one of the given face's vertices' IDs
*/
RESULT addFace(Face face, FaceID& fID, bool check=false, const Color* color=NULL);
//@}
/************************************************/
/** \name Validation */
//@{
// indicates whether the model is empty
#ifndef SKIP_THIS
bool isEmpty();
#endif
/** Checks whether the model is empty (no vertices).
\retval true The model is empty (contains no vertices)
\retval false The model is not empty (has at least one vertex)
*/
bool isModelEmpty();
/** Checks whether the data structures are empty (model is empty, and there are no lines, spheres, cylinders and plates to draw)
\retval true The data structures are empty
\retval false The data structures are not empty
*/
bool isTotallyEmpty();
/** Checks whether there are any lines to draw
\retval true There are lines to draw
\retval false There aren't any lines to draw
*/
bool hasLines();
/** Checks whether there are any spheres to draw
\retval true There are spheres to draw
\retval false There aren't any spheres to draw
*/
bool hasSpheres();
/** Checks whether there are any cylinders to draw
\retval true There are cylinders to draw
\retval false There aren't any cylinders to draw
*/
bool hasCylinders();
/** Checks whether there are any plates to draw
\retval true There are plates to draw
\retval false There aren't any plates to draw
*/
bool hasPlates();
/** Checks whether the given vertex id is valid
\retval true \e vid is valid
\retval false \e vid is not valid
*/
bool isValidVertexIndex(VertexID vID);
/** Checks whether the given edge id is valid
\retval true \e eID is valid
\retval false \e eID is not valid
*/
bool isValidEdgeIndex(EdgeID eID);
/** Checks whether the given face id is valid
\retval true \e fID is valid
\retval false \e fID is not valid
*/
bool isValidFaceIndex(FaceID fID);
/** Checks whether the given line id is valid
\retval true \e lID is valid
\retval false \e lID is not valid
*/
bool isValidLineIndex(LineID lID);
/** Checks whether the given sphere id is valid
\retval true \e sID is valid
\retval false \e sID is not valid
*/
bool isValidSphereIndex(SphereID sID);
/** Checks whether the given cylinder id is valid
\retval true \e cID is valid
\retval false \e cID is not valid
*/
bool isValidCylinderIndex(CylinderID cID);
/** Checks whether the given plate id is valid
\retval true \e pID is valid
\retval false \e pID is not valid
*/
bool isValidPlateIndex(PlateID pID);
/** Checks whether the given vertex is on a boundary
\param vID The vertex ID
\param boundary \out If true, the vertex is on a boundary. Otherwise, false.
\retval OK Operation succeeded
\retval VertexNotFound No vertex was found with one of the given IDs
*/
RESULT isBoundaryVertex(VertexID vID, bool& boundary);
/** Checks whether the given edge is on a boundary
\param eID The edge ID
\param boundary \out If true, the edge is on a boundary. Otherwise, false.
\retval OK Operation succeeded
\retval EdgeNotFound No edge was found with one of the given IDs
*/
RESULT isBoundaryEdge(EdgeID eID, bool& boundary);
/** Checks whether the given face is on a boundary
\param fID The face ID
\param boundary \out If true, the face is on a boundary. Otherwise, false.
\retval OK Operation succeeded
\retval FaceNotFound No face was found with one of the given IDs
*/
RESULT isBoundaryFace(FaceID fID, bool& boundary);
//@}
/********* Misc. ***********/
#ifndef SKIP_THIS
// set the renderer instance
RESULT setRenderer(Renderer* renderer);
#endif
private:
// The renderer instance
Renderer* renderer;
/********* projection settings. ***********/
VRViewpoint* vrViewpoint;
VRSFFloat clipNear;
VRSFFloat clipFar;
VRSFFloat frustumHalfWidth;
VRSFFloat paramScale;
double scalefactor;
double znear, zfar;
/********* Normals ***********/
// calculate normals
void getNormals();
void getFaceNormal(FaceID face, VRSFVec3f normal);
/********* Bounding box ***********/
VRSFVec3f bBoxMin; // min point
VRSFVec3f bBoxMax; // max point
VRSFVec3f bBoxDim; // bb dimensions
VRSFVec3f center; // bb center
// calculate the bounding box
void getBoundingBox();
bool bboxValid;
/********* I/O ***********/
// current VRML file name
char* fileName;
// actually write the output file
RESULT writeVRMLFile(bool exprt = false);
// combine all IFS's into one IFS
VRIndexedFaceSet* combineIFS(VRMFNode IFS_list);
void getCubeVertices(VertexID v1, VertexID v2, Coord *coords, double dist);
void getCubeVertices(Coord coord1, Coord coord2, Coord *coords, double dist);
/********* mesh geometry ***********/
// The combined IndexedFaceSet of the model
VRIndexedFaceSet* vrIFS;
// database (corner table)
Corner* cornerTable; // corner table
// keeping validation + colors
VertexInfo* verticesInfo; // vertices info: colors + validation + a list of corners
EdgeInfo* edgesInfo; // edges info: colors + validation
FaceInfo* facesInfo; // faces info: colors + validation
// total size of vertices/edges/facesInfo (including empty places)
long verticesInfoSize;
long edgesInfoSize;
long facesInfoSize;
// lists of the empty vertices/faces places in the vertices/facesInfo array
LinkedList<VertexID> emptyVertices;
LinkedList<FaceID> emptyFaces;
// counting vertices/edges/faces
VertexID numOfVertices;
EdgeID numOfEdges;
FaceID numOfPolys;
// check validation for a vertex/edge/face ID
bool checkVertexIndex(VertexID vID);
bool checkEdgeIndex(EdgeID eID);
bool checkFaceIndex(FaceID fID);
EdgeID countDoubleEdges();
RESULT m_edgeCollapse(VertexID vertexID1, VertexID vertexID2, LinkedList<FaceID>* removedFaces=NULL, LinkedList<EdgeID>* removedEdges=NULL);
RESULT m_addFace(Face face, FaceID& faceId, bool check=false);
RESULT m_removeFace(FaceID faceID, LinkedList<VertexID>* affectedVertices=NULL, LinkedList<EdgeID>* removedEdges=NULL);
RESULT m_removeVertex(VertexID vertexID, LinkedList<FaceID>* removedFaces=NULL, LinkedList<EdgeID>* removedEdges=NULL);
RESULT m_addVertex(Coord coordinate, VertexID& newVertex, const LinkedList<Edge>* neighbouringVertices = NULL, LinkedList<FaceID>* newFacesIDs = NULL);
bool areNeighbours(VertexID vertexIndex1, VertexID vertexIndex2, FaceID &t1, FaceID &t2);
FaceID getNewFaceIndex();
VertexID getNewVertexIndex();
// reallocate memory for databases
void allocCornerTable(int oldSize, int newSize);
void allocFacesInfo(int oldSize, int newSize);
void allocEdgesInfo(int oldSize, int newSize);
void allocVerticesInfo(int oldSize, int newSize);
void allocLines(int oldSize, int newSize);
void allocLinesInfo(int oldSize, int newSize);
void allocSpheres(int oldSize, int newSize);
void allocCylinders(int oldSize, int newSize);
void allocPlates(int oldSize, int newSize);
void allocSpheresInfo(int oldSize, int newSize);
void allocCylindersInfo(int oldSize, int newSize);
void allocPlatesInfo(int oldSize, int newSize);
/********* lines ***********/
Line* lines; // lines
LineInfo* linesInfo; // lines info: colors + validation
long linesInfoSize; // the total size of linesInfo (including empty places)
LineID numOfLines; // total number of non-empty lines
LinkedList<LineID> emptyLines; // a list of the empty lines places in the lines array
// check validation for a line ID
bool checkLineIndex(LineID lID);
LineID getNewLineIndex();
/********* spheres ***********/
Sphere* spheres; // spheres
SphereInfo* spheresInfo; // spheres info: colors + validation
long spheresInfoSize; // the total size of spheresInfo (including empty places)
SphereID numOfSpheres; // total number of non-empty spheres
LinkedList<SphereID> emptySpheres; // a list of the empty spheres places in the spheres array
// check validation for a sphere ID
bool checkSphereIndex(SphereID sID);
SphereID getNewSphereIndex();
/********* cylinders ***********/
Cylinder* cylinders; // cylinders
CylinderInfo* cylindersInfo; // cylinders info: colors + validation
long cylindersInfoSize; // the total size of cylindersInfo (including empty places)
CylinderID numOfCylinders; // total number of non-empty cylinders
LinkedList<CylinderID> emptyCylinders; // a list of the empty cylinders places in the cylinders array
// check validation for a cylinder ID
bool checkCylinderIndex(CylinderID cID);
CylinderID getNewCylinderIndex();
double getAngle(Coord v1, Coord v2);
/********* plates ***********/
Plate* plates; // plates
PlateInfo* platesInfo; // plates info: colors + validation
long platesInfoSize; // the total size of platesInfo (including empty places)
PlateID numOfPlates; // total number of non-empty plates
LinkedList<PlateID> emptyPlates; // a list of the empty plates places in the plates array
// check validation for a plate ID
bool checkPlateIndex(PlateID pID);
CylinderID getNewPlateIndex();
/********* mutex ***********/
HANDLE mutex;
void lock();
void unlock();
};
extern Mesh *mesh;
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?