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

- fixed embedded version
- removed OCC STL meshgen for now (OCC/triangle clashes with our own version
of triangle)
parent 4a6f2a07
Branches
Tags
No related merge requests found
// $Id: GFace.cpp,v 1.43 2008-02-05 14:40:29 remacle Exp $
// $Id: GFace.cpp,v 1.44 2008-02-05 15:59:34 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -23,13 +23,13 @@
#include "GFace.h"
#include "GEdge.h"
#include "MElement.h"
#include "VertexArray.h"
#if defined(HAVE_GMSH_EMBEDDED)
# include "GmshEmbedded.h"
#else
# include "Message.h"
# include "Numeric.h"
# include "VertexArray.h"
# include "Context.h"
# if defined(HAVE_GSL)
# include <gsl/gsl_vector.h>
......@@ -43,7 +43,8 @@ void dsvdcmp(double **a, int m, int n, double w[], double **v);
extern Context_T CTX;
GFace::GFace(GModel *model, int tag) : GEntity(model, tag), r1(0), r2(0), va_geom_triangles(0)
GFace::GFace(GModel *model, int tag)
: GEntity(model, tag), r1(0), r2(0), va_geom_triangles(0)
{
meshStatistics.status = GFace::PENDING;
resetMeshAttributes();
......@@ -67,7 +68,7 @@ GFace::~GFace()
for(unsigned int i = 0; i < quadrangles.size(); i++)
delete quadrangles[i];
if (va_geom_triangles)
if(va_geom_triangles)
delete va_geom_triangles;
}
......
......@@ -73,9 +73,9 @@ class GFace : public GEntity
// i.e. closed edge loops. the first wire is the one that is the
// outer contour of the face.
void resolveWires();
// builds a STL triangulation and fill the vertex array va_geom_triangles
// by default, do nothing
virtual bool buildSTLTriangulation () {return false;}
// builds a STL triangulation and fill the vertex array
// va_geom_triangles (by default, do nothing)
virtual bool buildSTLTriangulation () { return false; }
public:
GFace(GModel *model, int tag);
virtual ~GFace();
......@@ -210,7 +210,6 @@ class GFace : public GEntity
// Vertex array to draw the geometry efficiently
VertexArray *va_geom_triangles;
};
#endif
// $Id: OCCFace.cpp,v 1.29 2008-02-05 14:40:29 remacle Exp $
// $Id: OCCFace.cpp,v 1.30 2008-02-05 15:59:34 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -38,7 +38,8 @@
#include "Geom_BezierSurface.hxx"
#include "Geom_Plane.hxx"
#include "gp_Pln.hxx"
#include "BRepMesh_FastDiscret.hxx"
// FIX THIS WHEN TRIANGLE IS GONE
//#include "BRepMesh_FastDiscret.hxx"
OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape &emap)
: GFace(m, num), s(_s)
......@@ -274,80 +275,75 @@ surface_params OCCFace::getSurfaceParams() const
return p;
}
bool OCCFace::buildSTLTriangulation ()
bool OCCFace::buildSTLTriangulation()
{
if (va_geom_triangles){
// FIX THIS WHEN TRIANGLE IS GONE
return false;
/*
if(va_geom_triangles){
delete va_geom_triangles;
va_geom_triangles = 0;
}
TopLoc_Location loc;
int p1,p2,p3;
Bnd_Box aBox;
Standard_Boolean bWithShare;
Standard_Real aDiscret, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Standard_Real dX, dY, dZ, dMax, aCoeff, aAngle;
BRepBndLib::Add(s, aBox);
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
TopLoc_Location loc;
int p1, p2, p3;
Bnd_Box aBox;
Standard_Boolean bWithShare;
Standard_Real aDiscret, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Standard_Real dX, dY, dZ, dMax, aCoeff, aAngle;
BRepBndLib::Add(s, aBox);
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
// if (tag() > 100)return;
dX=aXmax-aXmin;
dY=aYmax-aYmin;
dZ=aZmax-aZmin;
dMax=dX;
if (dY>dMax) {
dMax=dY;
}
if (dZ>dMax) {
dMax=dZ;
}
//
aCoeff=0.01;
aDiscret=aCoeff*dMax;
BRepMesh_FastDiscret aMesher(aDiscret,
0.5,
aBox,
bWithShare,
Standard_True,
Standard_False,
Standard_True);
aMesher.Add(s);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (s, loc);
if (triangulation.IsNull()){
Msg(WARNING,"OCC STL triangulation failed!\n"); // return;
return false;
}
int ntriangles = triangulation -> NbTriangles();
if (!triangulation->HasUVNodes())
return false;
va_geom_triangles = new VertexArray(3,ntriangles);
unsigned int c = CTX.color.geom.surface;
unsigned int col[4] = {c, c, c, c};
for (int j = 1; j <= ntriangles; j++){
Poly_Triangle triangle = (triangulation -> Triangles())(j);
triangle.Get (p1,p2,p3);
gp_Pnt2d x1 = (triangulation->UVNodes())(p1);
gp_Pnt2d x2 = (triangulation->UVNodes())(p2);
gp_Pnt2d x3 = (triangulation->UVNodes())(p3);
GPoint gp1 = point (x1.X(),x1.Y());
GPoint gp2 = point (x2.X(),x2.Y());
GPoint gp3 = point (x3.X(),x3.Y());
SVector3 n[3];
n[0] = normal (SPoint2(x1.X(),x1.Y()));
n[1] = normal (SPoint2(x2.X(),x2.Y()));
n[2] = normal (SPoint2(x3.X(),x3.Y()));
double x[3] = {gp1.x(),gp2.x(),gp3.x()};
double y[3] = {gp1.y(),gp2.y(),gp3.y()};
double z[3] = {gp1.z(),gp2.z(),gp3.z()};
va_geom_triangles->add (x,y,z,n,col);
}
va_geom_triangles->finalize();
return true;
dX = aXmax-aXmin;
dY = aYmax-aYmin;
dZ = aZmax-aZmin;
dMax = dX;
if(dY > dMax) {
dMax = dY;
}
if(dZ > dMax) {
dMax = dZ;
}
//
aCoeff = 0.01;
aDiscret = aCoeff * dMax;
BRepMesh_FastDiscret aMesher(aDiscret, 0.5, aBox, bWithShare, Standard_True,
Standard_False, Standard_True);
aMesher.Add(s);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(s, loc);
if (triangulation.IsNull()){
Msg(WARNING,"OCC STL triangulation failed");
return false;
}
int ntriangles = triangulation->NbTriangles();
if(!triangulation->HasUVNodes()) return false;
va_geom_triangles = new VertexArray(3, ntriangles);
unsigned int c = CTX.color.geom.surface;
unsigned int col[4] = {c, c, c, c};
for (int j = 1; j <= ntriangles; j++){
Poly_Triangle triangle = (triangulation->Triangles())(j);
triangle.Get(p1,p2,p3);
gp_Pnt2d x1 = (triangulation->UVNodes())(p1);
gp_Pnt2d x2 = (triangulation->UVNodes())(p2);
gp_Pnt2d x3 = (triangulation->UVNodes())(p3);
GPoint gp1 = point(x1.X(), x1.Y());
GPoint gp2 = point(x2.X(), x2.Y());
GPoint gp3 = point(x3.X(), x3.Y());
SVector3 n[3];
n[0] = normal(SPoint2(x1.X(), x1.Y()));
n[1] = normal(SPoint2(x2.X(), x2.Y()));
n[2] = normal(SPoint2(x3.X(), x3.Y()));
double x[3] = {gp1.x(), gp2.x(), gp3.x()};
double y[3] = {gp1.y(), gp2.y(), gp3.y()};
double z[3] = {gp1.z(), gp2.z(), gp3.z()};
va_geom_triangles->add(x, y, z, n, col);
}
va_geom_triangles->finalize();
return true;
*/
}
#endif
// $Id: Geom.cpp,v 1.146 2008-02-05 14:40:30 remacle Exp $
// $Id: Geom.cpp,v 1.147 2008-02-05 15:59:34 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -202,6 +202,7 @@ class drawGEdge {
void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalArray,
int forceColor=0, unsigned int color=0);
class drawGFace {
private:
void _drawNonPlaneGFace(GFace *f)
......@@ -447,7 +448,8 @@ public :
}
if(f->va_geom_triangles)
drawArrays(f, f->va_geom_triangles, GL_TRIANGLES, CTX.geom.light, CTX.geom.surfaces,CTX.color.geom.surface);
drawArrays(f, f->va_geom_triangles, GL_TRIANGLES, CTX.geom.light,
CTX.geom.surfaces, CTX.color.geom.surface);
else if(f->geomType() == GEntity::Plane)
_drawPlaneGFace(f);
else if(f->geomType() == GEntity::ProjectionFace ||
......
// $Id: Mesh.cpp,v 1.212 2008-02-05 14:40:30 remacle Exp $
// $Id: Mesh.cpp,v 1.213 2008-02-05 15:59:34 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -441,7 +441,7 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements,
}
void drawArrays(GEntity *e, VertexArray *va, GLint type, bool useNormalArray,
int forceColor=0, unsigned int color=0)
int forceColor=0, unsigned int color=0)
{
if(!va) return;
......
// merge a surface mesh
// merge a surface mesh (any format will work: .msh, .unv, etc.)
Merge "sphere-surf.stl";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment