Skip to content
Snippets Groups Projects
GEdge.h 3.93 KiB
Newer Older
Christophe Geuzaine's avatar
Christophe Geuzaine committed
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.

#ifndef _GEDGE_H_
#define _GEDGE_H_

#include "GEntity.h"
#include "GVertex.h"
#include "SVector3.h"
#include "SPoint3.h"
#include "SPoint2.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

class MElement;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
class MLine;
class ExtrudeParams;
// A model edge.
class GEdge : public GEntity {
 private:
  double _length;
  bool _tooSmall;
 protected:
  GVertex *v0, *v1;
  std::list<GFace *> l_faces;

 public:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1);
  virtual ~GEdge();
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // delete mesh data
  virtual void deleteMesh();

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get the start/end vertices of the edge
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  GVertex *getBeginVertex() const { return v0; }
  GVertex *getEndVertex() const { return v1; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // add/delete a face bounded by this edge
  void addFace(GFace *f);
  void delFace(GFace *f);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get the dimension of the edge (1)
  virtual int dim() const { return 1; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed

  // set the visibility flag
  virtual void setVisibility(char val, bool recursive=false);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // true if the edge is a seam for the given face.
  virtual bool isSeam(const GFace *face) const { return false; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get the bounding box
Claudine Bon's avatar
Claudine Bon committed
  virtual SBoundingBox3d bounds() const;
  // faces that this entity bounds
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual std::list<GFace*> faces() const { return l_faces; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get the point for the given parameter location
  virtual GPoint point(double p) const = 0;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // true if the edge contains the given parameter
  virtual bool containsParam(double pt) const;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get first derivative of edge at the given parameter
  virtual SVector3 firstDer(double par) const = 0;

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get second derivative of edge at the given parameter (default
  // implentation using central differences)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual SVector3 secondDer(double par) const;
Christophe Geuzaine's avatar
Christophe Geuzaine committed

  // get the curvature
Laurent Van Migroet's avatar
Laurent Van Migroet committed
  virtual double curvature(double par) const;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // reparmaterize the point onto the given face
  virtual SPoint2 reparamOnFace(const GFace *face, double epar, int dir) const;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // return the minimum number of segments used for meshing the edge
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual int minimumMeshSegments() const { return 1; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // return the minimum number of segments used for drawing the edge
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual int minimumDrawSegments() const { return 1; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // return a type-specific additional information string
  virtual std::string getAdditionalInfoString();
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // tell if the edge is a 3D edge (in opposition with a trimmed curve on a surface)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual bool is3D() const { return true; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get/set/compute the length of the model edge
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  inline double length() const { return _length; }
  inline void setLength(const double l) { _length = l; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  double length(const double &u0, const double &u1, const int nbQuadPoints = 4);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // get the prescribed mesh size on the edge
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual double prescribedMeshSizeAtVertex() const { return meshAttributes.meshSize; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // true if start == end and no more than 2 segments
  void setTooSmall(bool b) { _tooSmall = b; }
  bool isMeshDegenerated() const 
  { return _tooSmall || (v0 == v1 && mesh_vertices.size() < 2); }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Stefen Guzik's avatar
Stefen Guzik committed
  // number of types of elements
  int getNumElementTypes() const { return 1; }

  // get total/by-type number of elements in the mesh
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  unsigned int getNumMeshElements();
Stefen Guzik's avatar
Stefen Guzik committed
  void getNumMeshElements(unsigned *const c) const;

  // get the start of the array of a type of element
  MElement *const *getStartElementType(int type) const;

  // get the element at the given index
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  MElement *getMeshElement(unsigned int index);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // reset the mesh attributes to default values
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void resetMeshAttributes();
Laurent Van Migroet's avatar
Laurent Van Migroet committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // true if entity is periodic in the "dim" direction.
  virtual bool periodic(int dim) const { return v0 == v1; }
  struct {
Christophe Geuzaine's avatar
pp  
Christophe Geuzaine committed
    char Method;
    double coeffTransfinite;
    double meshSize;
Christophe Geuzaine's avatar
pp  
Christophe Geuzaine committed
    int nbPointsTransfinite;
    int typeTransfinite;
    int minimumMeshSegments;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    // the extrusion parameters (if any)
    ExtrudeParams *extrude;
  } meshAttributes ;
  std::vector<MLine*> lines;