Skip to content
Snippets Groups Projects
Commit c46977ee authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

removed remaining Discrete Line/Surface stuff
parent f6d7520b
No related branches found
No related tags found
No related merge requests found
// $Id: Print_Geo.cpp,v 1.38 2005-04-19 16:03:10 remacle Exp $
// $Id: Print_Geo.cpp,v 1.39 2005-05-13 05:09:07 geuzaine Exp $
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
......@@ -133,59 +133,6 @@ void Print_Curve(void *a, void *b)
}
void Print_Discrete_Curve(void *a, void *b)
{
Curve *c = *(Curve **) a;
if(c->Num < 0) return;
// if we have a SEGM_rep, print it:
if(c->theSegmRep){
if(!List_Nbr(c->Control_Points))
fprintf(FOUT, "Discrete Line (%d) = {%d}\n",
c->Num, c->theSegmRep->num_points);
else
fprintf(FOUT, "Discrete Line {%d} = {%d}\n",
c->Num, c->theSegmRep->num_points);
fprintf(FOUT, "{\n");
for(int i = 0; i < List_Nbr(c->theSegmRep->points); i++){
if(i){
fprintf(FOUT, ",");
if(!(i%3)) fprintf(FOUT, "\n");
}
fprintf(FOUT, "%.16g",
*(double*)List_Pointer_Fast(c->theSegmRep->points, i));
}
fprintf(FOUT, "};\n");
return;
}
// else, print the mesh:
if(!List_Nbr(c->Vertices))
return;
if(!List_Nbr(c->Control_Points))
fprintf(FOUT, "Discrete Line (%d) = {%d}\n",
c->Num, List_Nbr(c->Vertices));
else
fprintf(FOUT, "Discrete Line {%d} = {%d}\n",
c->Num, List_Nbr(c->Vertices));
fprintf(FOUT, "{\n");
for(int i = 0; i < List_Nbr(c->Vertices); i++){
Vertex *v = *(Vertex**)List_Pointer(c->Vertices, i);
fprintf(FOUT, " %.16g,%.16g,%.16g", v->Pos.X, v->Pos.Y, v->Pos.Z);
if(i != List_Nbr(c->Vertices) - 1)
fprintf(FOUT, ",\n");
else
fprintf(FOUT, "\n");
}
fprintf(FOUT, "};\n");
}
void Print_Surface(void *a, void *b)
{
Curve *c;
......@@ -264,134 +211,6 @@ void Print_Surface(void *a, void *b)
}
}
void Print_Discrete_Surface(void *a, void *b)
{
throw;
// Surface *s = *(Surface **) a;
// // if we have a poly_rep, print it:
// if(s->thePolyRep){
// if(!List_Nbr(s->Generatrices))
// fprintf(FOUT, "Discrete Surface (%d) = {%d, %d}\n",
// s->Num, s->thePolyRep->num_points, s->thePolyRep->num_polys);
// else
// fprintf(FOUT, "Discrete Surface {%d} = {%d, %d}\n",
// s->Num, s->thePolyRep->num_points, s->thePolyRep->num_polys);
// fprintf(FOUT, "{\n");
// for(int i = 0; i < List_Nbr(s->thePolyRep->points_and_normals); i++){
// if(i){
// fprintf(FOUT, ",");
// if(!(i%6)) fprintf(FOUT, "\n");
// }
// fprintf(FOUT, "%.16g",
// *(double*)List_Pointer_Fast(s->thePolyRep->points_and_normals, i));
// }
// fprintf(FOUT, "}\n");
// fprintf(FOUT, "{\n");
// for(int i = 0; i < List_Nbr(s->thePolyRep->polygons); i++){
// if(i){
// fprintf(FOUT, ",");
// if(!(i%4)) fprintf(FOUT, "\n");
// }
// fprintf(FOUT, "%.16g", *(double*)List_Pointer_Fast(s->thePolyRep->polygons, i));
// }
// fprintf(FOUT, "};\n");
// return;
// }
// // else, print the surface mesh:
// if(!Tree_Nbr(s->Vertices))
// return;
// List_T *verts = Tree2List(s->Vertices);
// List_T *tmp = Tree2List(s->Simplexes);
// List_T *tris = Tree2List(s->SimplexesBase);
// List_Copy(tmp, tris);
// List_Delete(tmp);
// List_T *quads = Tree2List(s->Quadrangles);
// // compute smoothed normals
// smooth_normals norms;
// for(int i = 0; i < List_Nbr(tris); i++){
// SimplexBase *t = *(SimplexBase**)List_Pointer(tris, i);
// if(t->V[2]){
// double n[3];
// normal3points(t->V[0]->Pos.X, t->V[0]->Pos.Y, t->V[0]->Pos.Z,
// t->V[1]->Pos.X, t->V[1]->Pos.Y, t->V[1]->Pos.Z,
// t->V[2]->Pos.X, t->V[2]->Pos.Y, t->V[2]->Pos.Z, n);
// norms.add(t->V[0]->Pos.X, t->V[0]->Pos.Y, t->V[0]->Pos.Z, n[0], n[1], n[2]);
// norms.add(t->V[1]->Pos.X, t->V[1]->Pos.Y, t->V[1]->Pos.Z, n[0], n[1], n[2]);
// norms.add(t->V[2]->Pos.X, t->V[2]->Pos.Y, t->V[2]->Pos.Z, n[0], n[1], n[2]);
// }
// }
// for(int i = 0; i < List_Nbr(quads); i++){
// Quadrangle *q = *(Quadrangle**)List_Pointer(quads, i);
// double n[3];
// normal3points(q->V[0]->Pos.X, q->V[0]->Pos.Y, q->V[0]->Pos.Z,
// q->V[1]->Pos.X, q->V[1]->Pos.Y, q->V[1]->Pos.Z,
// q->V[2]->Pos.X, q->V[2]->Pos.Y, q->V[2]->Pos.Z, n);
// norms.add(q->V[0]->Pos.X, q->V[0]->Pos.Y, q->V[0]->Pos.Z, n[0], n[1], n[2]);
// norms.add(q->V[1]->Pos.X, q->V[1]->Pos.Y, q->V[1]->Pos.Z, n[0], n[1], n[2]);
// norms.add(q->V[2]->Pos.X, q->V[2]->Pos.Y, q->V[2]->Pos.Z, n[0], n[1], n[2]);
// norms.add(q->V[3]->Pos.X, q->V[3]->Pos.Y, q->V[3]->Pos.Z, n[0], n[1], n[2]);
// }
// if(!List_Nbr(s->Generatrices))
// fprintf(FOUT, "Discrete Surface (%d) = {%d, %d}\n",
// s->Num, List_Nbr(verts), List_Nbr(tris)+List_Nbr(quads));
// else
// fprintf(FOUT, "Discrete Surface {%d} = {%d, %d}\n",
// s->Num, List_Nbr(verts), List_Nbr(tris)+List_Nbr(quads));
// // print nodes and create dense vertex numbering
// fprintf(FOUT, "{\n");
// map<int, int> nodes;
// for(int i = 0; i < List_Nbr(verts); i++){
// Vertex *v = *(Vertex**)List_Pointer(verts, i);
// nodes[v->Num] = i;
// double n[3] = {0.,0.,0.};
// norms.get(v->Pos.X, v->Pos.Y, v->Pos.Z, n[0], n[1], n[2], 180.);
// fprintf(FOUT, " %.16g,%.16g,%.16g, %g,%g,%g",
// v->Pos.X, v->Pos.Y, v->Pos.Z, n[0], n[1], n[2]);
// if(i != List_Nbr(verts) - 1)
// fprintf(FOUT, ",\n");
// else
// fprintf(FOUT, "\n");
// }
// fprintf(FOUT, "}\n");
// // print polygons
// fprintf(FOUT, "{\n");
// for(int i = 0; i < List_Nbr(tris); i++){
// SimplexBase *t = *(SimplexBase**)List_Pointer(tris, i);
// if(t->V[2])
// fprintf(FOUT, " 3, %d,%d,%d",
// nodes[t->V[0]->Num], nodes[t->V[1]->Num], nodes[t->V[2]->Num]);
// if(List_Nbr(quads) || i != List_Nbr(tris) - 1)
// fprintf(FOUT, ",\n");
// else
// fprintf(FOUT, "\n");
// }
// for(int i = 0; i < List_Nbr(quads); i++){
// Quadrangle *q = *(Quadrangle**)List_Pointer(quads, i);
// fprintf(FOUT, " 4, %d,%d,%d,%d", nodes[q->V[0]->Num], nodes[q->V[1]->Num],
// nodes[q->V[2]->Num], nodes[q->V[3]->Num]);
// if(i != List_Nbr(quads) - 1)
// fprintf(FOUT, ",\n");
// else
// fprintf(FOUT, "\n");
// }
// fprintf(FOUT, "};\n");
// List_Delete(verts);
// List_Delete(tris);
// List_Delete(quads);
//
}
void Print_Volume(void *a, void *b)
{
Surface *s;
......@@ -455,7 +274,7 @@ void Print_PhysicalGroups(void *a, void *b)
}
void Print_Geo(Mesh * M, char *filename, int discrete_curves, int discrete_surf)
void Print_Geo(Mesh * M, char *filename, int discrete_curve, int discrete_surface)
{
if(filename) {
FOUT = fopen(filename, "w");
......@@ -471,10 +290,6 @@ void Print_Geo(Mesh * M, char *filename, int discrete_curves, int discrete_surf)
Tree_Action(M->Points, Print_Point);
Tree_Action(M->Curves, Print_Curve);
Tree_Action(M->Surfaces, Print_Surface);
if(discrete_curves)
Tree_Action(M->Curves, Print_Discrete_Curve);
if(discrete_surf)
Tree_Action(M->Surfaces, Print_Discrete_Surface);
Tree_Action(M->Volumes, Print_Volume);
List_Action(M->PhysicalGroups, Print_PhysicalGroups);
......
// $Id: Create.cpp,v 1.71 2005-04-28 16:45:45 geuzaine Exp $
// $Id: Create.cpp,v 1.72 2005-05-13 05:09:08 geuzaine Exp $
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
......@@ -535,7 +535,6 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste,
pC->cp = NULL;
pC->Vertices = List_Create(2, 20, sizeof(Vertex *));
pC->Extrude = NULL;
pC->theSegmRep = 0;
pC->Typ = Typ;
pC->Num = Num;
THEM->MaxLineNum = IMAX(THEM->MaxLineNum, Num);
......@@ -644,8 +643,6 @@ void Free_Curve(void *a, void *b)
Free(pC->k);
List_Delete(pC->Control_Points);
Free(pC->cp);
if(pC->theSegmRep)
delete pC->theSegmRep;
Free(pC);
pC = NULL;
}
......
// $Id: DiscreteSurface.cpp,v 1.13 2005-05-09 06:56:13 remacle Exp $
// $Id: DiscreteSurface.cpp,v 1.14 2005-05-13 05:09:08 geuzaine Exp $
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
......@@ -18,10 +18,6 @@
// USA.
//
// Please report all bugs and problems to "gmsh@geuz.org".
//
// Contributor(s):
// Nicolas Tardieu
//
#include "Gmsh.h"
#include "Numeric.h"
......@@ -37,107 +33,6 @@
extern Mesh *THEM;
extern Context_T CTX;
#define VAL_INF 1.e200
static Tree_T * VertexBound = NULL;
static void InsertInVertexBound(void *a, void *b)
{
Tree_Insert(VertexBound, a);
}
// Polygonal representation of discrete surfaces
POLY_rep::POLY_rep()
: num_points(0), num_polys(0)
{
points_and_normals = List_Create(100, 100, sizeof(double));
polygons = List_Create(100, 100, sizeof(double));
bounding_box[0] = bounding_box[2] = bounding_box[4] = VAL_INF;
bounding_box[1] = bounding_box[3] = bounding_box[5] = -VAL_INF;
}
POLY_rep::POLY_rep(int _num_points, int _num_polys, List_T *_p, List_T *_pol)
: num_points(_num_points), num_polys(_num_polys),
points_and_normals(_p), polygons(_pol)
{
bounding_box[0] = bounding_box[2] = bounding_box[4] = VAL_INF;
bounding_box[1] = bounding_box[3] = bounding_box[5] = -VAL_INF;
// check num points
if(List_Nbr(points_and_normals) != num_points * 6){
Msg(GERROR, "Wrong number of points in discrete surface");
if(polygons){
List_Delete(polygons);
polygons = 0;
}
if(points_and_normals){
List_Delete(points_and_normals);
points_and_normals = 0;
}
return;
}
// compute the bbox
compute_bounding_box();
// check polygons
int k = 0;
while (k < List_Nbr(polygons)){
double *points = (double*)List_Pointer(polygons,k);
k += ((int)points[0] + 1);
for(int i = 0; i < (int)points[0]; i++){
if(6 * (int)points[1+i] >= List_Nbr(points_and_normals)){
Msg(GERROR, "Wrong point index in discrete surface");
if(polygons){
List_Delete(polygons);
polygons = 0;
}
if(points_and_normals){
List_Delete(points_and_normals);
points_and_normals = 0;
}
return;
}
}
}
}
void POLY_rep::compute_bounding_box()
{
for(int i = 0; i < List_Nbr(points_and_normals); i+=6){
double *points = (double*)List_Pointer(points_and_normals, i);
if(points[0] < bounding_box[0]) bounding_box[0] = points[0];
if(points[0] > bounding_box[1]) bounding_box[1] = points[0];
if(points[1] < bounding_box[2]) bounding_box[2] = points[1];
if(points[1] > bounding_box[3]) bounding_box[3] = points[1];
if(points[2] < bounding_box[4]) bounding_box[4] = points[2];
if(points[2] > bounding_box[5]) bounding_box[5] = points[2];
}
}
POLY_rep::~POLY_rep()
{
if(polygons) List_Delete(polygons);
if(points_and_normals) List_Delete(points_and_normals);
}
double SetLC(Vertex *v1, Vertex *v2, Vertex *v3, double factor)
{
double lc1 = sqrt((v1->Pos.X - v2->Pos.X) * (v1->Pos.X - v2->Pos.X) +
(v1->Pos.Y - v2->Pos.Y) * (v1->Pos.Y - v2->Pos.Y) +
(v1->Pos.Z - v2->Pos.Z) * (v1->Pos.Z - v2->Pos.Z));
double lc2 = sqrt((v1->Pos.X - v3->Pos.X) * (v1->Pos.X - v3->Pos.X) +
(v1->Pos.Y - v3->Pos.Y) * (v1->Pos.Y - v3->Pos.Y) +
(v1->Pos.Z - v3->Pos.Z) * (v1->Pos.Z - v3->Pos.Z));
double lc3 = sqrt((v2->Pos.X - v3->Pos.X) * (v2->Pos.X - v3->Pos.X) +
(v2->Pos.Y - v3->Pos.Y) * (v2->Pos.Y - v3->Pos.Y) +
(v2->Pos.Z - v3->Pos.Z) * (v2->Pos.Z - v3->Pos.Z));
double lc = DMAX(lc1, DMAX(lc2, lc3)) * factor;
v1->lc = v2->lc = v3->lc = lc;
return lc;
}
void Mesh_To_BDS(Surface *s, BDS_Mesh *m)
{
List_T *vertices = Tree2List ( s->Vertices ) ;
......@@ -194,302 +89,6 @@ void BDS_To_Mesh(Mesh *m)
}
void POLY_rep_To_Mesh(POLY_rep *prep, Surface *s)
{
printf ("compareposition : %22.15e\n",CTX.lc);
VertexBound = Tree_Create(sizeof(Vertex *), comparePosition);
Tree_Action(THEM->Vertices, InsertInVertexBound);
Vertex **verts = new Vertex*[List_Nbr(prep->points_and_normals)/6];
for(int i = 0; i < List_Nbr(prep->points_and_normals); i+=6){
double *point = (double*)List_Pointer(prep->points_and_normals, i);
Vertex *v = Create_Vertex(++THEM->MaxPointNum, point[0], point[1], point[2], 1.0, 0.0);
Vertex **pv;
if(!(pv = (Vertex**)Tree_PQuery(VertexBound, &v))){
Tree_Add(VertexBound, &v);
Tree_Add(s->Vertices, &v);
verts[i/6] = v;
}
else{
Free_Vertex(&v, NULL);
Tree_Insert(s->Vertices, pv);
verts[i/6] = *pv;
}
}
int k = 0;
while (k < List_Nbr(prep->polygons)){
double *points = (double*)List_Pointer(prep->polygons,k);
k+= ((int)points[0] + 1);
if (points[0] == 3){
Vertex *v1 = verts[(int)points[1]];
Vertex *v2 = verts[(int)points[2]];
Vertex *v3 = verts[(int)points[3]];
SetLC(v1, v2, v3, CTX.mesh.lc_factor);
Simplex *simp = Create_Simplex(v1, v2, v3, NULL);
simp->iEnt = s->Num;
Tree_Add(s->Simplexes, &simp);
}
else if (points[0] == 4){
Vertex *v1 = verts[(int)points[1]];
Vertex *v2 = verts[(int)points[2]];
Vertex *v3 = verts[(int)points[3]];
Vertex *v4 = verts[(int)points[4]];
SetLC(v1, v2, v3, CTX.mesh.lc_factor);
v4->lc = v1->lc;
Quadrangle *quad = Create_Quadrangle(v1, v2, v3, v4);
quad->iEnt = s->Num;
Tree_Add(s->Quadrangles, &quad);
}
}
Tree_Delete(VertexBound);
delete [] verts;
}
// Routines to process STL surfaces
static void ComputeNormal(Surface * Surface, double Normal[3])
{
Curve *Curve1;
List_Read(Surface->Generatrices, 0, &Curve1);
Curve *Curve2;
List_Read(Surface->Generatrices, 1, &Curve2);
Vertex *Point11 = Curve1->beg;
Vertex *Point12 = Curve1->end;
Vertex *Point21 = Curve2->beg;
Vertex *Point22 = Curve2->end;
double vec1[3];
vec1[0] = (Point12->Pos.X) - (Point11->Pos.X);
vec1[1] = (Point12->Pos.Y) - (Point11->Pos.Y);
vec1[2] = (Point12->Pos.Z) - (Point11->Pos.Z);
double vec2[3];
vec2[0] = (Point22->Pos.X) - (Point21->Pos.X);
vec2[1] = (Point22->Pos.Y) - (Point21->Pos.Y);
vec2[2] = (Point22->Pos.Z) - (Point21->Pos.Z);
prodve(vec1, vec2, Normal);
norme(Normal);
}
static bool BelongToPhysicalEntity(int SurfaceNumber,
PhysicalGroup * CurrentPhysicalGroup)
{
PhysicalGroup *PhysicalGroup;
int NbPhysicalGroup = List_Nbr(THEM->PhysicalGroups);
bool Belong = false;
// Search if the current Surface belongs to the current PhysicalGroup
if(CurrentPhysicalGroup != NULL) {
if(List_Search(CurrentPhysicalGroup->Entities, &SurfaceNumber, fcmp_int)) {
Belong = true;
}
}
// Search if the current Surface belongs to another PhysicalGroup
if(!Belong) {
for(int i = 0; i < NbPhysicalGroup; i++) {
List_Read(THEM->PhysicalGroups, i, &PhysicalGroup);
if((PhysicalGroup->Typ == MSH_PHYSICAL_SURFACE) && (!Belong)) {
if(List_Search(PhysicalGroup->Entities, &SurfaceNumber, fcmp_int)) {
Belong = true;
break;
}
}
}
}
return Belong;
}
static void AddCorrectNeighborToPhysical(Surface * Surf1, PhysicalGroup * CurrentPhysicalGroup)
{
double Normal1[3], Normal2[3];
int elem2;
List_T *pSurfaceList = Tree2List(THEM->Surfaces);
Surface *Surf2;
int NbSimplex = Tree_Nbr(THEM->Surfaces);
Curve *Curve1;
Curve *Curve2;
ComputeNormal(Surf1, Normal1);
// Scan all the elements to find a Surface not belonging to an existing PhysicalGroup
for(elem2 = 1; elem2 < NbSimplex; elem2++) {
List_Read(pSurfaceList, elem2, &Surf2);
if(BelongToPhysicalEntity(Surf2->Num, CurrentPhysicalGroup)) {
continue;
}
ComputeNormal(Surf2, Normal2);
double Scal =
Normal1[0] * Normal2[0] + Normal1[1] * Normal2[1] +
Normal1[2] * Normal2[2];
// If the normals are OK, determine if the surfaces are neighbors
if((fabs(Scal) > 0.90) && ((Surf1->Num) != (Surf2->Num))) {
bool Exit = false;
for(int i = 0; i < 3; i++) {
if(!Exit) {
for(int j = 0; j < 3; j++) {
List_Read(Surf1->Generatrices, i, &Curve1);
List_Read(Surf2->Generatrices, j, &Curve2);
// The Surface have a common Edge
if(fabs(Curve1->Num) == fabs(Curve2->Num)) {
List_Add(CurrentPhysicalGroup->Entities, &(Surf2->Num));
AddCorrectNeighborToPhysical(Surf2, CurrentPhysicalGroup);
Exit = true;
break;
}
}
}
}
}
}
}
static void CreatePhysicalSurface()
{
Surface *Surf1;
PhysicalGroup *CurrentPhysicalGroup;
int NbSimplex = Tree_Nbr(THEM->Surfaces);
List_T *pSurfaceList = Tree2List(THEM->Surfaces);
// Scan all Simplexes to find correct Neighbors and add them to a PhysicalGroup
for(int elem1 = 0; elem1 < NbSimplex; elem1++) {
List_Read(pSurfaceList, elem1, &Surf1);
if(BelongToPhysicalEntity((Surf1->Num), NULL))
continue;
CurrentPhysicalGroup = (PhysicalGroup *) Malloc(sizeof(PhysicalGroup));
CurrentPhysicalGroup->Num = List_Nbr(THEM->PhysicalGroups)+1;
CurrentPhysicalGroup->Entities = List_Create(1, 1, sizeof(int));
CurrentPhysicalGroup->Typ = MSH_PHYSICAL_SURFACE;
CurrentPhysicalGroup->Visible = VIS_GEOM | VIS_MESH;
List_Add(CurrentPhysicalGroup->Entities, &(Surf1->Num));
AddCorrectNeighborToPhysical(Surf1, CurrentPhysicalGroup);
if(List_Nbr(CurrentPhysicalGroup->Entities) > 0)
List_Add(THEM->PhysicalGroups, &CurrentPhysicalGroup);
else
Free(CurrentPhysicalGroup);
}
}
SEGM_rep::SEGM_rep()
: num_points(0)
{
points = List_Create(100, 100, sizeof(double));
bounding_box[0] = bounding_box[2] = bounding_box[4] = VAL_INF;
bounding_box[1] = bounding_box[3] = bounding_box[5] = -VAL_INF;
}
SEGM_rep::SEGM_rep(int _num_points, List_T *_p)
: num_points(_num_points), points(_p)
{
bounding_box[0] = bounding_box[2] = bounding_box[4] = VAL_INF;
bounding_box[1] = bounding_box[3] = bounding_box[5] = -VAL_INF;
// check num points
if(List_Nbr(points) != num_points * 3){
Msg(GERROR, "Wrong number of points in discrete curve");
if(points){
List_Delete(points);
points = 0;
}
return;
}
// compute the bbox
compute_bounding_box();
}
void SEGM_rep::compute_bounding_box()
{
for(int i = 0; i < List_Nbr(points); i+=3){
double *p = (double*)List_Pointer(points, i);
if(p[0] < bounding_box[0]) bounding_box[0] = p[0];
if(p[0] > bounding_box[1]) bounding_box[1] = p[0];
if(p[1] < bounding_box[2]) bounding_box[2] = p[1];
if(p[1] > bounding_box[3]) bounding_box[3] = p[1];
if(p[2] < bounding_box[4]) bounding_box[4] = p[2];
if(p[2] > bounding_box[5]) bounding_box[5] = p[2];
}
}
SEGM_rep::~SEGM_rep()
{
if(points) List_Delete(points);
}
double SetLC(Vertex *v1, Vertex *v2, double factor)
{
double lc = sqrt((v1->Pos.X - v2->Pos.X) * (v1->Pos.X - v2->Pos.X) +
(v1->Pos.Y - v2->Pos.Y) * (v1->Pos.Y - v2->Pos.Y) +
(v1->Pos.Z - v2->Pos.Z) * (v1->Pos.Z - v2->Pos.Z));
v1->lc = v2->lc = lc;
return lc;
}
void SEGM_rep_To_Mesh(SEGM_rep *srep, Curve *c)
{
VertexBound = Tree_Create(sizeof(Vertex *), comparePosition);
Tree_Action(THEM->Vertices, InsertInVertexBound);
int N = List_Nbr(srep->points)/3;
Vertex **verts = new Vertex*[N];
for(int i = 0; i < List_Nbr(srep->points); i+=3){
double *point = (double*)List_Pointer(srep->points, i);
// if the curve's end points exist, use their identification
// numbers (that's how we do things in 1D_Mesh, and it makes
// things easier for point extrusions in the old extrusion
// algorithm)
int num;
if(i == 0 && c->beg)
num = c->beg->Num;
else if(i/3 == N-1 && c->end)
num = c->end->Num;
else
num = ++THEM->MaxPointNum;
Vertex *v = Create_Vertex(num, point[0], point[1], point[2], 1.0, 0.0);
Vertex **pv;
if(!(pv = (Vertex**)Tree_PQuery(VertexBound, &v))){
Tree_Add(VertexBound, &v);
List_Add(c->Vertices, &v);
v->ListCurves = List_Create(1, 1, sizeof(Curve *));
List_Add(v->ListCurves, &c);
Tree_Add(THEM->Vertices, &v);
verts[i/3] = v;
}
else{
Free_Vertex(&v, NULL);
List_Add(c->Vertices, pv);
if((*pv)->ListCurves)
List_Add((*pv)->ListCurves, &c);
verts[i/3] = *pv;
}
}
for(int i = 0; i < N-1; i++){
Vertex *v1 = verts[i];
Vertex *v2 = verts[i+1];
SetLC(v1, v2, CTX.mesh.lc_factor);
Simplex *simp = Create_Simplex(v1, v2, NULL, NULL);
simp->iEnt = c->Num;
Tree_Add(c->Simplexes, &simp);
}
Tree_Delete(VertexBound);
delete [] verts;
}
// Public interface for discrete surface/curve mesh algo
int MeshDiscreteSurface(Surface *s)
......@@ -515,16 +114,7 @@ int MeshDiscreteSurface(Surface *s)
int MeshDiscreteCurve(Curve *c)
{
if(c->theSegmRep){
// Use the discrete representation as the curve mesh. Most of the
// time we should of course remesh/enhance/refine this (as there
// is no guarantee that this mesh fits at interfaces, etc.), but
// we don't have any routines to do that at the moment--so let's
// just use it and hope for the best.
SEGM_rep_To_Mesh(c->theSegmRep, c);
return 1;
}
else if(c->Typ == MSH_SEGM_DISCRETE){
if(c->Typ == MSH_SEGM_DISCRETE){
// nothing else to do: we assume that the elements have alreay
// been created
return 1;
......
......@@ -251,7 +251,6 @@ struct _Surf{
CylParam Cyl;
Grid_T Grid; // fast search grid
ExtrudeParams *Extrude;
// POLY_rep *thePolyRep;
BDS_Mesh *bds;
int Dirty; // flag to prevent any meshing
DrawingColor Color;
......@@ -377,7 +376,6 @@ typedef struct{
char functu[256], functv[256], functw[256];
int Dirty; // flag to prevent any meshing
DrawingColor Color;
SEGM_rep *theSegmRep;
BDS_Mesh *bds;
}Curve;
......@@ -445,7 +443,7 @@ void mai3d(Mesh *M, int Asked);
void Init_Mesh(Mesh *M);
void Create_BgMesh(int i, double d, Mesh *m);
void Print_Geo(Mesh *M, char *c, int discrete_curves=0, int discrete_surf=0);
void Print_Geo(Mesh *M, char *c, int discrete_curve=0, int discrete_surface=0);
void Print_Mesh(Mesh *M, char *c, int Type);
void Read_Mesh(Mesh *M, FILE *fp, char *filename, int Type);
void GetStatistics(double s[50]);
......
$Id: FAQ,v 1.60 2005-05-12 15:43:12 geuzaine Exp $
$Id: FAQ,v 1.61 2005-05-13 05:09:08 geuzaine Exp $
This is the Gmsh FAQ
......@@ -249,11 +249,7 @@ option panel. From the command line, you can also use '-order 2'.
* 5.10 Can I import an existing surface mesh in Gmsh and use it to
build a 3D mesh?
Yes, either in the form of a STL triangulation, or by using the
'Discrete Surface' commands. Note that Gmsh cannot currently modify
the surface mesh you provide in this way, so the surface mesh has to
be conform (without gaps, hanging nodes, etc.) and must contain
surface elements having the (final) desired sizes.
Yes, either in the form of a STL triangulation, or FIXME: TODO
* 5.11 How do I define boundary conditions or material properties in
Gmsh?
......
\input texinfo.tex @c -*-texinfo-*-
@c $Id: gmsh.texi,v 1.182 2005-04-04 15:41:45 geuzaine Exp $
@c $Id: gmsh.texi,v 1.183 2005-05-13 05:09:08 geuzaine Exp $
@c
@c Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
@c
......@@ -1515,14 +1515,6 @@ spline's identification number; the @var{expression-list} on the right hand
side should contain the identification numbers of all the spline's control
points.
@item Discrete Line ( @var{expression} ) = @{ @var{expression} @} @{ @var{expression-list} @};
Creates a discrete line, i.e., a line defined by a series of points. The
@var{expression} on the right hand side gives the number of points in the
discretization and the @var{expression-list} gives the list of these points,
by groups of three coordinates (X, Y and Z). This discretization is used
both for the graphical representation and for the one-dimensional mesh of
the line.
@item Line Loop ( @var{expression} ) = @{ @var{expression-list} @};
Creates an oriented line loop. The @var{expression} inside the parentheses
is the line loop's identification number; the @var{expression-list} on the
......@@ -1584,34 +1576,6 @@ the ruled surface's identification number; the @var{expression-list} on the
right hand side should the identification number of a single line loop,
composed of either three or four elementary lines.
@item Discrete Surface ( @var{expression} ) = @{ @var{expression}, @var{expression} @} @{ @var{expression-list} @} @{ @var{expression-list} @};
Creates a discrete surface, i.e., a surface defined by a polygonal
discretization (usually a triangulation). The two @w{@var{expression}s} on
the right hand side give the number of points and the number of polygons
in the discretization, respectively. The first @var{expression-list} gives
the list of discretization points and their associated normals, by groups of
six @w{@var{expression}s} (three node coordinates and three normal
components for each point). The second @var{expression-list} gives the list
of polygons, by groups of (@var{N}+1) @w{@var{expression}s} (the first
expression being equal to @var{N}, the number of points in the polygon, and
the @var{N} following expressions referring to the indices of the points in
the first list). For example, a triangulation of a unit square surface in
the X-Y plane with two triangles could be defined as:
@example
Discrete Surface (1) = @{4, 2@}
@{ 0,0,0, 0,0,1,
1,0,0, 0,0,1,
1,1,0, 0,0,1,
0,1,0, 0,0,1 @}
@{ 3, 0,1,2,
3, 0,2,3 @};
@end example
The polygonal discretization is used for the graphical representation of the
surface and is also used as the actual two-dimensional mesh of the surface
if all the polygons are triangles or quadrangles.
@c todo:
@c @item Trimmed Surface ( @var{expression} ) = @{ @var{expression}, @{ @var{expression-list} @} @};
......@@ -2113,25 +2077,6 @@ for triangles or quadrangles given in @ref{Gmsh node ordering}.
Here is a list of all other mesh commands currently available:
@ftable @code
@item Discrete Line @{ @var{expression} @} = @{ @var{expression} @} @{ @var{expression-list} @};
Associates a discretization with the (existing) curve @var{expression}.
This discretization is used both for the graphical representation and for
the one-dimensional mesh of the line.
See the definition of @code{Discrete Line} in @ref{Lines}, for an
explanation of the meaning of the @var{expression} and the
@var{expression-list} on the right hand side.
@item Discrete Surface @{ @var{expression} @} = @{ @var{expression}, @var{expression} @} @{ @var{expression-list} @} @{ @var{expression-list} @};
Associates a polygonal discretization with the (existing) surface
@var{expression}. This polygonal discretization is used for the graphical
representation of the surface and can also be used as the actual
two-dimensional mesh of the surface if all the polygons are triangles.
See the definition of @code{Discrete Surface} in @ref{Surfaces}, for an
explanation of the meaning of the @w{@var{expression}s} and
@w{@var{expression-list}s} on the right hand side.
@item Color @var{color-expression} @{ Point | Line | Surface | Volume @{ @var{expression-list} @}; @dots{} @}
Sets the mesh color of the entities in @var{expression-list} to @var{color-expression}.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment