mesh.h
来自「finite element mesh 参数化有限元网格划分」· C头文件 代码 · 共 922 行 · 第 1/3 页
H
922 行
// mesh.h
#ifndef MESH_H
#define MESH_H
#include "renderer.h"
#include "params.h"
#include "info.h"
#include "corner.h"
#include "edge.h"
#include "face.h"
#include "vr.h"
#include "wrl.h"
class Renderer;
class Scenes;
/** \nosubgrouping */
/** Handles the mesh functions, such as I/O, VRML export, mesh geometry functions etc.
*/
class Mesh {
friend Renderer;
friend Scenes;
public:
#ifndef SKIP_THIS
Mesh();
~Mesh();
#endif
/************************************************/
/** \name I/O Operations */
//@{
/** Loads a VRML file and renders it
\param fileName The path of the *.wrl file to load
\retval OK Operation succeeded
\retval NullPointerGiven \e fileName is NULL.
\retval OversizedString \e fileName is longer than MAX_STRING_SIZE.
\retval FileNotFound File isn't found in given path.
\retval WrongFileFormat VRML is not in the right format (has no IndexedFaceSets or has other geometry shapes (Box etc.)).
\note \e fileName should be shorter than MAX_STRING_SIZE characters. \n
The vertices' IDs are initialized according to each vertex's index in the IFS->coord->point array. \n
The faces' IDs are initialized according to the face's position in the IFS->coordIndex array, such that each face is defined by 4 values in the coordIndex array (the 3 vertices and an extra '-1').
The first face (with FaceID=0) is defined by the first 4 values in the array, the second face (with FaceID=1) by the next 4 and so on
*/
RESULT openVRMLFile(const char* fileName);
/** Saves the current mesh to a VRML file
\param fileName The path of the *.wrl file to be saved. If NULL, the mesh will be saved to the predefined VRML file (when previously saved or loaded)
\retval OK Operation succeeded
\retval NullPointerGiven \e fileName is NULL and there is no predefined VRML file (the mesh wasn't saved before).
\retval OversizedString \e fileName is longer than MAX_STRING_SIZE.
\retval FileNotFound File isn't found in given path.
\retval MeshNotValid Mesh is either non valid or is not specified
\note \e fileName should be shorter than MAX_STRING_SIZE characters.\n
The file saved contains only the geometry and connectivity (i.e. vertices and faces), and disregards colors, highlights, spheres, lines, cylinders and plates
*/
RESULT saveVRMLFile(const char* fileName = NULL);
/** Saves the current mesh to a VRML file, saving all the highlighted vertices/edges/faces and their colors
\retval OK Operation succeeded
\retval NullPointerGiven \e fileName is NULL and there is no predefined VRML file (the mesh wasn't saved before).
\retval OversizedString \e fileName is longer than MAX_STRING_SIZE.
\retval FileNotFound File isn't found in given path.
\retval MeshNotValid Mesh is either non valid or is not specified
\note \e fileName should be shorter than MAX_STRING_SIZE characters.\n
The file saved contains the geometry and connectivity (i.e. vertices and faces), as well as colors, highlights, spheres, lines, cylinders and plates
*/
RESULT VRMLExport(const char* fileName);
/** Get the name of the current VRML file
\param fileName \out A pointer to a string to which the file name will be copied
\retval OK Operation succeeded
\retval NullPointerGiven \e fileName is NULL and there is no predefined VRML file (the mesh wasn't saved before).
\retval MeshNotValid Mesh is either non valid or is not specified
*/
RESULT getFileName(char* fileName);
//@}
/************************************************/
/** \name IFS/model */
//@{
/** Get the current mesh's bounding box
\param bBoxMin \out The minimum coordinate of the bounding box
\param bBoxMax \out The maximum coordinate of the bounding box
\param bBoxDim \out The dimensions of the bounding box (=bBoxMax-bBoxMin)
\param center \out The center coordinate of the bounding box
\retval OK Operation succeeded
\retval MeshNotValid Mesh is either non valid or is not specified
\note If line/sphere/cylinder/plates drawing is enabled, the bounding box is calculated according to the model as well as the lines/spheres/cylinders to draw.
Otherwise, they lines are not added to the calculation
*/
RESULT getBoundingBox(Coord &bBoxMin, Coord &bBoxMax, Coord &bBoxDim, Coord ¢er);
/** Get a copy of the current IndexedFaceSet which represents the mesh
\param IFS \out A copy of the IndexedFaceSet of the mesh
\retval OK Operation succeeded
\retval NullPointerGiven \e IFS is NULL
\retval MeshNotValid Mesh is either non valid or is not specified
\note \e IFS should be allocated by the user before the call to the function.
The structure itself is changed inside the function to be a copy of the mesh.
This means that changing the updated structure returned to the user, won't change the data structure used by the API, only the user's local copy
*/
RESULT getIFS(VRIndexedFaceSet* IFS);
/** Sets the current model to be a copy of the given IndexedFaceSet
\param IFS The IndexedFaceSet of the mesh
\retval OK Operation succeeded
\retval NullPointerGiven \e IFS is NULL
*/
RESULT setIFS(const VRIndexedFaceSet* IFS);
/** Starts a new empty model (clears the current mesh and the screen).
\retval OK Operation succeeded
\note This function is usually followed by a call to Renderer::setAutoScale()
\sa Renderer::setAutoScale()
*/
RESULT startNewModel();
//@}
/************************************************/
/** \name Line drawing */
//@{
/** Adds a line to be drawn.
\param line The line to be added.
\param color The color of the new line, or NULL for the default line color
\param lineID \out The ID of the new added line
\retval OK Operation succeeded
*/
RESULT addLine(Line line, LineID &lineID, const Color* color = NULL);
/** Set the line's coordinates
\param lineID The ID of the line
\param line The Line object with the new coordinates
\retval OK Operation succeeded
\retval LineNotFound No line was found with the given ID
*/
RESULT setLine(LineID lineID, Line line);
/** Get a copy of a line with a given ID
\param lineID The ID of the line
\param line \out A copy of the line.
\retval OK Operation succeeded
\retval LineNotFound No line was found with the given ID
*/
RESULT getLine(LineID lineID, Line& line);
/** Set the width of a line with a given ID
\param lineID The ID of the line
\param width The new width of the line
\retval OK Operation succeeded
\retval LineNotFound No line was found with the given ID
*/
RESULT setLineWidth(LineID lineID, double width=DEFAULT_LINE_WIDTH);
/** Get the width of a line with a given ID
\param lineID The ID of the line
\param width \out The width of the line
\retval OK Operation succeeded
\retval LineNotFound No line was found with the given ID
*/
RESULT getLineWidth(LineID lineID, double &width);
/** Remove the given line
\param lineID The ID of the line to remove
\retval OK Operation succeeded
\retval LineNotFound No line was found with the given ID
*/
RESULT removeLine(LineID lineID);
/** Remove all lines
\retval OK Operation succeeded
*/
RESULT removeAllLines();
//@}
/************************************************/
/** \name Sphere drawing */
//@{
/** Adds a sphere to be drawn.
\param sphere The sphere to be added.
\param color The color of the new sphere, or NULL for the default sphere color
\param sId \out The ID of the new added sphere
\retval OK Operation succeeded
*/
RESULT addSphere(Sphere sphere, SphereID &sId, const Color* color = NULL);
/** Set the sphere's parameters (center and radius)
\param sId The ID of the sphere
\param sphere The Sphere object with the new parameters
\retval OK Operation succeeded
\retval SphereNotFound No sphere was found with the given ID
*/
RESULT setSphere(SphereID sId, Sphere sphere);
/** Get a copy of a sphere with a given ID
\param sId The ID of the sphere
\param sphere \out A copy of the sphere.
\retval OK Operation succeeded
\retval SphereNotFound No sphere was found with the given ID
*/
RESULT getSphere(SphereID sId, Sphere& sphere);
/** Remove the given sphere
\param sId The ID of the sphere to remove
\retval OK Operation succeeded
\retval SphereNotFound No sphere was found with the given ID
*/
RESULT removeSphere(SphereID sId);
/** Remove all spheres
\retval OK Operation succeeded
*/
RESULT removeAllSpheres();
//@}
/************************************************/
/** \name Cylinder drawing */
//@{
/** Adds a cylinder to be drawn.
\param cylinder The cylinder to be added.
\param color The color of the new cylinder, or NULL for the default cylinder color
\param cId \out The ID of the new added cylinder
\retval OK Operation succeeded
*/
RESULT addCylinder(Cylinder cylinder, CylinderID &cId, const Color* color = NULL);
/** Set the cylinder's parameters
\param cId The ID of the cylinder
\param cylinder The Cylinder object with the new parameters
\retval OK Operation succeeded
\retval CylinderNotFound No cylinder was found with the given ID
*/
RESULT setCylinder(CylinderID cId, Cylinder cylinder);
/** Get a copy of a cylinder with a given ID
\param cId The ID of the cylinder
\param cylinder \out A copy of the cylinder.
\retval OK Operation succeeded
\retval CylinderNotFound No cylinder was found with the given ID
*/
RESULT getCylinder(CylinderID cId, Cylinder& cylinder);
/** Remove the given cylinder
\param cId The ID of the cylinder to remove
\retval OK Operation succeeded
\retval CylinderNotFound No cylinder was found with the given ID
*/
RESULT removeCylinder(CylinderID cId);
/** Remove all cylinders
\retval OK Operation succeeded
*/
RESULT removeAllCylinders();
//@}
/************************************************/
/** \name Plate drawing */
//@{
/** Adds a plate to be drawn.
\param plate The plate to be added.
\param color The color of the new plate, or NULL for the default plate color
\param pId \out The ID of the new added plate
\retval OK Operation succeeded
*/
RESULT addPlate(Plate plate, PlateID &pId, const Color* color = NULL);
/** Set the plate's parameters
\param pId The ID of the plate
\param plate The Plate object with the new parameters
\retval OK Operation succeeded
\retval PlateNotFound No plate was found with the given ID
*/
RESULT setPlate(PlateID pId, Plate plate);
/** Get a copy of a plate with a given ID
\param pId The ID of the plate
\param plate \out A copy of the plate.
\retval OK Operation succeeded
\retval PlateNotFound No plate was found with the given ID
*/
RESULT getPlate(PlateID pId, Plate& plate);
/** Remove the given plate
\param pId The ID of the plate to remove
\retval OK Operation succeeded
\retval PlateNotFound No plate was found with the given ID
*/
RESULT removePlate(PlateID pId);
/** Remove all plates
\retval OK Operation succeeded
*/
RESULT removeAllPlates();
//@}
/************************************************/
/** \name Mesh Geometry */
//@{
/** Get the total number of vertices in the mesh model
\param count \out The number of vertices
\retval OK Operation succeeded
*/
RESULT getVerticesCount(VertexID& count);
/** Get the total number of unique geometric edges in the mesh model.
If an edge has 2 EdgeID's, the edge is counted only once.
\param count \out The number of vertices
\retval OK Operation succeeded
*/
RESULT getEdgesCount(EdgeID& count);
/** Get the total number of edges ID's in the mesh model.
If an edge has 2 EdgeID's, both ID's will be counted.
\param count \out The number of edges
\retval OK Operation succeeded
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?