From 1a7c8d92a999024d5535c9871f35aaaf3c475c48 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 14 Jul 2006 13:31:12 +0000 Subject: [PATCH] *** empty log message *** --- Geo/GEdgeLoop.h | 9 ++++--- Geo/GEntity.h | 9 ++++--- Geo/MVertex.h | 15 +++++++----- Geo/Pair.h | 33 ++++++++++++------------- Geo/Range.h | 22 ++++++++--------- Geo/SBoundingBox3d.h | 25 +++++-------------- Geo/SPoint2.h | 38 ++++++---------------------- Geo/SPoint3.h | 43 ++++++-------------------------- Geo/SVector3.h | 53 +++++++++------------------------------- Geo/gmshEdge.cpp | 4 +-- Graphics/Entity.cpp | 3 +-- Graphics/PostElement.cpp | 4 +-- Mesh/meshGEdge.cpp | 44 ++++++++++++++++----------------- Parser/Gmsh.tab.cpp | 2 +- Parser/Gmsh.yy.cpp | 4 +-- 15 files changed, 107 insertions(+), 201 deletions(-) diff --git a/Geo/GEdgeLoop.h b/Geo/GEdgeLoop.h index 694fc22c85..9787e78ff6 100644 --- a/Geo/GEdgeLoop.h +++ b/Geo/GEdgeLoop.h @@ -1,15 +1,18 @@ -#ifndef _EDGE_LOOP_H_ -#define _EDGE_LOOP_H_ +#ifndef _GEDGE_LOOP_H_ +#define _GEDGE_LOOP_H_ + #include <list> class GEdgeLoop { + private: std::list<GEdge*> loop; std::list<int> dirs; -public : + public : GEdgeLoop (const std::list<GEdge*> & l, const std::list<int> & d) : loop (l) , dirs (d) { } }; + #endif diff --git a/Geo/GEntity.h b/Geo/GEntity.h index b38de72830..f60c088d46 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -8,6 +8,7 @@ #include "GmshDefines.h" #include <list> #include <vector> +#include <string> class GModel; class GVertex; @@ -20,8 +21,8 @@ class GRegion; class GEntity { private: - int _tag; GModel *_model; + int _tag; // DiscreteRep *mesh, *modelMesh; public: @@ -66,9 +67,9 @@ class GEntity { "DiscreteSurface", "Volume" }; - int type = (int)geomType(); - if(type < 0 || type >= sizeof(name) / sizeof(name[0])) - return "Unknown"; + unsigned int type = (unsigned int)geomType(); + if(type >= sizeof(name) / sizeof(name[0])) + return "Undefined"; else return name[type]; } diff --git a/Geo/MVertex.h b/Geo/MVertex.h index fd35b92cfe..0864fe2470 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -1,24 +1,27 @@ #ifndef _MVERTEX_H_ #define _MVERTEX_H_ + class GEntity; -class MVertex -{ + +class MVertex { + private: double x,y,z; GEntity *ge; -public : + public : MVertex ( double _x, double _y, double _z , GEntity * _ge ) : x(_x),y(_y),z(_z),ge(_ge) { } }; -class MEdgeVertex : public MVertex -{ +class MEdgeVertex : public MVertex { + private: double u; -public : + public : MEdgeVertex ( double _x, double _y, double _z , GEntity * _ge , double _u) : MVertex (_x,_y,_z,_ge),u(_u) { } }; + #endif diff --git a/Geo/Pair.h b/Geo/Pair.h index d5edd5b83b..870cd61d63 100644 --- a/Geo/Pair.h +++ b/Geo/Pair.h @@ -1,24 +1,21 @@ +#ifndef _PAIR_H_ +#define _PAIR_H_ -#ifndef H_Pair -#define H_Pair - -/** A pair of values, the types of which can be different */ +// A pair of values, the types of which can be different template <class L, class R> class Pair{ -private: - L Left; - R Right; -public: - Pair() {} - Pair( const L& left, const R& right) : Left(left), Right(right) {} - L left() const { return Left; } - void left(const L& left) { Left = left; } - R right() const { return Right; } - void right(const R& right) { Right = right; } - - L first() const { return Left; } - R second() const { return Right; } - + private: + L Left; + R Right; + public: + Pair() {} + Pair( const L& left, const R& right) : Left(left), Right(right) {} + L left() const { return Left; } + void left(const L& left) { Left = left; } + R right() const { return Right; } + void right(const R& right) { Right = right; } + L first() const { return Left; } + R second() const { return Right; } }; #endif diff --git a/Geo/Range.h b/Geo/Range.h index 227e3091f6..c0dbfb7943 100644 --- a/Geo/Range.h +++ b/Geo/Range.h @@ -1,23 +1,21 @@ -#ifndef H_Range -#define H_Range +#ifndef _RANGE_H_ +#define _RANGE_H_ -/** represents a range of values of the template type */ +// represents a range of values of the template type template <class T> -class Range{ -private: - T Low; - T High; -public: +class Range { + private: + T Low; + T High; + public: Range() {} Range( const T& low, const T& high) : Low(low), High(high) {} - T low() const { return Low; } + T low() const { return Low; } void low(const T& low) { Low = low; } - T high() const { return High; } + T high() const { return High; } void high(const T& high) { High = high; } - int contains(const T& value) const; int contains(const Range<T> & range) const; - int operator == (const Range<T> &range) const; }; diff --git a/Geo/SBoundingBox3d.h b/Geo/SBoundingBox3d.h index 1ee0046a5e..43cf47177c 100644 --- a/Geo/SBoundingBox3d.h +++ b/Geo/SBoundingBox3d.h @@ -1,37 +1,24 @@ -#ifndef H_SBoundingBox3d -#define H_SBoundingBox3d +#ifndef _SBOUNDING_BOX_3D_H_ +#define _SBOUNDING_BOX_3D_H_ #include "SPoint3.h" -/** A bounding box class - add points and it grows to be the - bounding box of the point set - */ +// A bounding box class - add points and it grows to be the bounding +// box of the point set class SBoundingBox3d { -public: - /// + public: SBoundingBox3d(); - /// SBoundingBox3d(const SPoint3 &); - /// void operator+=(const SPoint3 &pt); - /// void operator+=(const SBoundingBox3d &pt); - /// void operator*=(double scale); - /// void scale(double, double, double); - /// SPoint3 min() const; - /// SPoint3 max() const; - /// SPoint3 center() const; - /// void makeCube(); -private: + private: SPoint3 MinPt,MaxPt; - }; - #endif diff --git a/Geo/SPoint2.h b/Geo/SPoint2.h index f856a51018..b7a27abdb6 100644 --- a/Geo/SPoint2.h +++ b/Geo/SPoint2.h @@ -1,50 +1,30 @@ - -#ifndef H_SPoint2 -#define H_SPoint2 +#ifndef _SPOINT2_H_ +#define _SPOINT2_H_ #include <math.h> -/** A point in 2-space */ +// A point in 2-space class SPoint2 { -protected: + protected: double P[2]; -public: + public: SPoint2() {} - /// - SPoint2(double x, double y) - {P[0] = x; P[1] = y;} - /// - SPoint2(double *p) - {P[0] = p[0]; P[1] = p[1];} - SPoint2(const SPoint2 &pt) - {P[0] = pt.P[0]; P[1] = pt.P[1]; } + SPoint2(double x, double y) {P[0] = x; P[1] = y;} + SPoint2(double *p) {P[0] = p[0]; P[1] = p[1];} + SPoint2(const SPoint2 &pt) {P[0] = pt.P[0]; P[1] = pt.P[1]; } virtual ~SPoint2() {} - /// void setPosition(double xx, double yy); - /// void getPosition(double *xx, double *yy) const; - /// void position(double *) const; - /// inline double x(void) const; - /// inline double y(void) const; - - /// double &operator[](int); - /// double operator[](int) const; SPoint2 &operator=(const SPoint2 &p); - - /// void operator+=(const SPoint2 &p); - /// void operator-=(const SPoint2 &p); - /// void operator*=(double mult); - /// SPoint2 operator*(double mult); - operator double *() { return P; } }; @@ -90,6 +70,4 @@ inline void SPoint2::operator*=(double mult) inline SPoint2 SPoint2::operator*(double mult) { return SPoint2(P[0]*mult, P[1]*mult); } - #endif - diff --git a/Geo/SPoint3.h b/Geo/SPoint3.h index 33384bd7d7..7735c4a49c 100644 --- a/Geo/SPoint3.h +++ b/Geo/SPoint3.h @@ -1,58 +1,32 @@ +#ifndef _SPOINT3_H_ +#define _SPOINT3_H_ -#ifndef H_SPoint3 -#define H_SPoint3 - -#include <iostream> #include <math.h> -/** A point in 3-space */ +// A point in 3-space class SPoint3 { -protected: + protected: double P[3]; -public: + public: SPoint3() {} - /// - SPoint3(double x, double y, double z) - {P[0] = x; P[1] = y; P[2] = z;} - /// - SPoint3(const double *p) - {P[0] = p[0]; P[1] = p[1]; P[2] = p[2];} - - SPoint3(const SPoint3 &pt) - {P[0] = pt.P[0]; P[1] = pt.P[1]; P[2] = pt.P[2]; } - + SPoint3(double x, double y, double z) {P[0] = x; P[1] = y; P[2] = z;} + SPoint3(const double *p) {P[0] = p[0]; P[1] = p[1]; P[2] = p[2];} + SPoint3(const SPoint3 &pt) {P[0] = pt.P[0]; P[1] = pt.P[1]; P[2] = pt.P[2]; } virtual ~SPoint3() {} - /// void setPosition(double xx, double yy, double zz); - /// void getPosition(double *xx, double *yy, double *zz) const; - /// void position(double *) const; - - /// inline double x(void) const; - /// inline double y(void) const; - /// inline double z(void) const; - - /// double &operator[](int); - /// double operator[](int) const; - /// SPoint3 &operator=(const SPoint3 &p); - /// void operator+=(const SPoint3 &p); - /// void operator-=(const SPoint3 &p); - /// void operator*=(double mult); - /// SPoint3 operator*(double mult); - /// operator double *() { return P; } - }; inline SPoint3 operator + (const SPoint3 &a, const SPoint3 &b) @@ -101,4 +75,3 @@ inline double SPoint3::operator[](int i) const { return P[i]; } #endif - diff --git a/Geo/SVector3.h b/Geo/SVector3.h index 531ef299d9..c6d0501ea0 100644 --- a/Geo/SVector3.h +++ b/Geo/SVector3.h @@ -1,73 +1,45 @@ -#ifndef H_SVector3 -#define H_SVector3 +#ifndef _SVECTOR3_H_ +#define _SVECTOR3_H_ #include "SPoint3.h" -/* concrete class for vector of size 3 */ +// concrete class for vector of size 3 class SVector3 { -public: + public: SVector3() {} - /// Construct from 2 SPoints, vector from p1 to p2 - SVector3(const SPoint3 &p1, const SPoint3 &p2) - : P(p2-p1) {} - /// Construct from a single SPoint, vector from origin to p1 - SVector3(const SPoint3 &p1) - : P(p1) {} - SVector3(double x, double y, double z) - : P(x,y,z) {} - SVector3(double v) - : P(v,v,v) {} - SVector3(const double *array) - : P(array) {} - - /// + // Construct from 2 SPoints, vector from p1 to p2 + SVector3(const SPoint3 &p1, const SPoint3 &p2) : P(p2-p1) {} + // Construct from a single SPoint, vector from origin to p1 + SVector3(const SPoint3 &p1) : P(p1) {} + SVector3(double x, double y, double z) : P(x,y,z) {} + SVector3(double v) : P(v,v,v) {} + SVector3(const double *array) : P(array) {} inline double x(void) const { return P.x(); } - /// inline double y(void) const { return P.y(); } - /// inline double z(void) const { return P.z(); } - double normalize(); - // why both [] and (), why not double &operator[](int); double operator[](int) const; double &operator()(int); double operator()(int) const; - - /// SVector3 & operator += (const SVector3 &); - /// SVector3 & operator -= (const SVector3 &); - /// SVector3 & operator *= (const SVector3 &); - /// SVector3 & operator = (double); - operator double *() { return P; } - -protected: + protected: SPoint3 P; - }; -/// double norm(const SVector3 &v); -/// double dot(const SVector3 &a, const SVector3 &b); -/// SVector3 cross(const SVector3 &a, const SVector3 &b); -/// double angle(const SVector3 &a, const SVector3 &b, const SVector3 &n); -/// SVector3 operator*(double m,const SVector3 &v); -/// SVector3 operator*(const SVector3 &v, double m); -/// SVector3 operator*(const SVector3 &v1, const SVector3 &v2); -/// SVector3 operator+(const SVector3 &a,const SVector3 &b); -/// SVector3 operator-(const SVector3 &a,const SVector3 &b); inline double &SVector3::operator[](int i) @@ -82,5 +54,4 @@ inline double &SVector3::operator()(int i) inline double SVector3::operator()(int i) const { return P[i]; } - #endif diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp index e443e271a0..478650250a 100644 --- a/Geo/gmshEdge.cpp +++ b/Geo/gmshEdge.cpp @@ -21,8 +21,8 @@ Range<double> gmshEdge::parBounds(int i) const SBoundingBox3d gmshEdge::bounds() const { - double xmin,ymin,zmin; - double xmax,ymax,zmax; + double xmin = 0., ymin = 0., zmin = 0.; + double xmax = 0., ymax = 0., zmax = 0.; for (int i = 0; i < 20; i++){ double u = c->ubeg + (i/19.) * (c->uend - c->ubeg); Vertex a = InterpolateCurve(c, u, 0); diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index dfde4dcb4f..3bdc9dc761 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.64 2006-07-01 10:35:49 geuzaine Exp $ +// $Id: Entity.cpp,v 1.65 2006-07-14 13:31:08 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -19,7 +19,6 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. - #include "Mesh.h" #include "Gmsh.h" #include "GmshUI.h" diff --git a/Graphics/PostElement.cpp b/Graphics/PostElement.cpp index fe7bf6d1d0..ffc01cc246 100644 --- a/Graphics/PostElement.cpp +++ b/Graphics/PostElement.cpp @@ -1,4 +1,4 @@ -// $Id: PostElement.cpp,v 1.73 2006-04-18 09:57:42 remacle Exp $ +// $Id: PostElement.cpp,v 1.74 2006-07-14 13:31:08 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -1303,11 +1303,9 @@ void Draw_TensorElement(int type, Post_View * View, int preproNormals, int it; double DEP[3]; // déplacement relatif cdf % a config de référence double CDG[3]; // coordonnées du centre de gravité au tps t0 - double VIT[3]; // vitesse en x,y,z du cdg % au repère absolu double ROT[3]; // angles de rotation du cdg % au repère absolu double VAR[3]; // valeur des 3 variables supplémentaires double X[3],Y[3],Z[3]; - double a11,a12,a13,a21,a22,a23,a31,a32,a33; double ztmp[3]; View->TimeStep = 0; diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index c92506ab42..a0d429d6c2 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -7,7 +7,7 @@ #include "Message.h" static GEdge * _myGEdge; -static double _myGEdgeLength, t_begin,t_end,lc_begin,lc_end; +static double _myGEdgeLength, t_begin, t_end, lc_begin, lc_end; static Range<double> _myGEdgeBounds; // boooooooh !!!!!! extern Mesh *THEM; @@ -17,11 +17,11 @@ double F_Lc_bis(double t) { const double fact = (t-t_begin)/(t_end-t_begin); const double lc_here = lc_begin + fact * (lc_end-lc_begin); - SVector3 der = _myGEdge -> firstDer(t) ; + SVector3 der = _myGEdge -> firstDer(t) ; const double d = norm(der); if(THEM->BackgroundMeshType == ONFILE) { - GPoint point = _myGEdge -> point(t) ; + GPoint point = _myGEdge -> point(t) ; const double Lc = BGMXYZ(point.x(), point.y(), point.z()); if(CTX.mesh.constrained_bgmesh) return std::max(d / Lc, d / lc_here); @@ -34,8 +34,7 @@ double F_Lc_bis(double t) double F_Transfini_bis(double t) { - double val,r; - int i; + double val, r; SVector3 der = _myGEdge -> firstDer(t) ; double d = norm(der); @@ -51,7 +50,7 @@ double F_Transfini_bis(double t) else { switch (abs(type)) { - case 1: // Geometric progression ar^i; Sum of n terms = THEC->l = a (r^n-1)/(r-1) + case 1: // Geometric progression ar^i; Sum of n terms = THEC->l = a (r^n-1)/(r-1) { if(sign(type) >= 0) r = coef; @@ -63,7 +62,7 @@ double F_Transfini_bis(double t) } break; - case 2: // Bump + case 2: // Bump { double a; if(coef > 1.0) { @@ -96,16 +95,15 @@ double F_One_bis(double t) return norm(der); } - void deMeshGEdge :: operator() (GEdge *ge) { - for (int i=0;i<ge->mesh_vertices.size();i++) delete ge->mesh_vertices[i]; + for (unsigned int i=0;i<ge->mesh_vertices.size();i++) + delete ge->mesh_vertices[i]; ge->mesh_vertices.clear(); } void meshGEdge :: operator() (GEdge *ge) { - deMeshGEdge dem; dem(ge); @@ -122,10 +120,10 @@ void meshGEdge :: operator() (GEdge *ge) // first compute the length of the curve by integrating one _myGEdgeBounds = ge->parBounds(0) ; - _myGEdgeLength = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), F_One_bis, Points, 1.e-4); + _myGEdgeLength = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), + F_One_bis, Points, 1.e-4); List_Reset(Points); - lc_begin = _myGEdge->getBeginVertex()->prescribedMeshSizeAtVertex(); lc_end = _myGEdge->getEndVertex()->prescribedMeshSizeAtVertex(); @@ -135,20 +133,20 @@ void meshGEdge :: operator() (GEdge *ge) // Integrate detJ/lc du double a; int N; - if(ge->meshAttributes.Method == TRANSFINI) - { - a = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), F_Transfini_bis, Points, 1.e-7); - N = ge->meshAttributes.nbPointsTransfinite; - } - else - { - a = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), F_Lc_bis, Points, 1.e-4); - N = std::max (ge->minimumMeshSegments()+1, (int)(a + 1.)); - } + if(ge->meshAttributes.Method == TRANSFINI){ + a = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), + F_Transfini_bis, Points, 1.e-7); + N = ge->meshAttributes.nbPointsTransfinite; + } + else{ + a = Integration(_myGEdgeBounds.low(), _myGEdgeBounds.high(), + F_Lc_bis, Points, 1.e-4); + N = std::max (ge->minimumMeshSegments()+1, (int)(a + 1.)); + } const double b = a / (double)(N - 1); int count = 1, NUMP = 1; - IntPoint P1,P2; + IntPoint P1, P2; // do not consider the first and the last vertex // those are not classified on this mesh edge diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index a3dfec2d58..1b3b47f424 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -126,7 +126,7 @@ #line 1 "Gmsh.y" -// $Id: Gmsh.tab.cpp,v 1.268 2006-07-12 07:24:14 geuzaine Exp $ +// $Id: Gmsh.tab.cpp,v 1.269 2006-07-14 13:31:08 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp index b8309fadde..edfd47aa28 100644 --- a/Parser/Gmsh.yy.cpp +++ b/Parser/Gmsh.yy.cpp @@ -2,7 +2,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.267 2006-07-12 07:24:23 geuzaine Exp $ + * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.268 2006-07-14 13:31:12 geuzaine Exp $ */ #define FLEX_SCANNER @@ -727,7 +727,7 @@ char *yytext; #line 1 "Gmsh.l" #define INITIAL 0 #line 2 "Gmsh.l" -// $Id: Gmsh.yy.cpp,v 1.267 2006-07-12 07:24:23 geuzaine Exp $ +// $Id: Gmsh.yy.cpp,v 1.268 2006-07-14 13:31:12 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // -- GitLab