* Added OpenCascade XDE Support to enable importing of individual surface colours from STEP Geometry

* Extended the Clipping Planes functionality to the Geometry mode for OCC Geometry
* Added the option to specify the maximum mesh size for each individual face in an OCC Geometry
This commit is contained in:
Philippose Rajan 2009-01-30 22:17:20 +00:00
parent 34bfd4a349
commit 85867fb240
5 changed files with 2005 additions and 1796 deletions

View File

@ -564,8 +564,9 @@ namespace netgen
double maxh = mparam.maxh;
// Philippose - 15/01/2009
double maxh = geom.face_maxh[k-1];
//double maxh = mparam.maxh;
mparam.checkoverlap = 0;
// int noldpoints = mesh->GetNP();
int noldsurfel = mesh.GetNSE();
@ -1112,7 +1113,6 @@ namespace netgen
mesh->SetLocalH (bb.PMin(), bb.PMax(), 0.5);
if (mparam.uselocalh)
{
@ -1126,7 +1126,6 @@ namespace netgen
double maxedgelen = 0;
double minedgelen = 1e99;
multithread.task = "Setting local mesh size (elements per edge)";
// setting elements per edge
@ -1147,15 +1146,44 @@ namespace netgen
continue;
}
double localh = len/mparam.segmentsperedge;
double s0, s1;
// Philippose - 23/01/2009
// Find all the parent faces of a given edge
// and limit the mesh size of the edge based on the
// mesh size limit of the face
TopTools_IndexedDataMapOfShapeListOfShape edge_face_map;
edge_face_map.Clear();
TopExp::MapShapesAndAncestors(geom.shape, TopAbs_EDGE, TopAbs_FACE, edge_face_map);
const TopTools_ListOfShape& parent_faces = edge_face_map.FindFromKey(e);
TopTools_ListIteratorOfListOfShape parent_face_list;
for(parent_face_list.Initialize(parent_faces); parent_face_list.More(); parent_face_list.Next())
{
TopoDS_Face parent_face = TopoDS::Face(parent_face_list.Value());
int face_index = geom.fmap.FindIndex(parent_face);
if(face_index >= 1) localh = min(localh,geom.face_maxh[face_index - 1]);
}
Handle(Geom_Curve) c = BRep_Tool::Curve(e, s0, s1);
maxedgelen = max (maxedgelen, len);
minedgelen = min (minedgelen, len);
int maxj = 2 * (int) ceil (localh/len);
// Philippose - 23/01/2009
// Modified the calculation of maxj, because the
// method used so far always results in maxj = 2,
// which causes the localh to be set only at the
// starting, mid and end of the edge.
// Old Algorithm:
// int maxj = 2 * (int) ceil (localh/len);
int maxj = max((int) ceil(len/localh), 2);
for (int j = 0; j <= maxj; j++)
{
gp_Pnt pnt = c->Value (s0+double(j)/maxj*(s1-s0));
@ -1163,12 +1191,8 @@ namespace netgen
}
}
multithread.task = "Setting local mesh size (edge curvature)";
// setting edge curvature
int nsections = 20;
@ -1189,12 +1213,11 @@ namespace netgen
double s = s0 + j/(double) nsections * (s1-s0);
prop.SetParameter (s);
double curvature = prop.Curvature();
if(curvature > maxcur) maxcur = curvature;
if(curvature> maxcur) maxcur = curvature;
if (curvature >= 1e99)
continue;
gp_Pnt pnt = c->Value (s);
mesh->RestrictLocalH (Point3d(pnt.X(), pnt.Y(), pnt.Z()),
@ -1203,8 +1226,6 @@ namespace netgen
// (*testout) << "edge " << i << " max. curvature: " << maxcur << endl;
}
multithread.task = "Setting local mesh size (face curvature)";
// setting face curvature
@ -1247,7 +1268,6 @@ namespace netgen
}
}
// setting close edges
if (stlparam.resthcloseedgeenable)
@ -1346,13 +1366,11 @@ namespace netgen
}
}
multithread.task = savetask;
}
}
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK;
@ -1419,8 +1437,6 @@ namespace netgen
}
*/
#ifdef LOG_STREAM
(*logout) << "Edges meshed" << endl
<< "time = " << GetTime() << " sec" << endl
@ -1455,8 +1471,6 @@ namespace netgen
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME)
{
multithread.task = "Volume meshing";
@ -1498,7 +1512,6 @@ namespace netgen
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME)
{
multithread.task = "Volume optimization";
@ -1518,7 +1531,6 @@ namespace netgen
<< "points: " << mesh->GetNP() << endl;
#endif
// cout << "Optimization complete" << endl;
}
@ -1531,8 +1543,6 @@ namespace netgen
for (int i = 1; i <= mesh->GetNSeg(); i++)
(*testout) << mesh->LineSegment(i) << endl;
return TCL_OK;
}
}

View File

@ -841,6 +841,14 @@ namespace netgen
facemeshstatus.SetSize (fmap.Extent());
facemeshstatus = 0;
// Philippose - 15/01/2009
face_maxh.SetSize (fmap.Extent());
face_maxh = mparam.maxh;
// Philippose - 17/01/2009
face_sel_status.SetSize (fmap.Extent());
face_sel_status = 0;
fvispar.SetSize (fmap.Extent());
evispar.SetSize (emap.Extent());
vvispar.SetSize (vmap.Extent());
@ -1127,59 +1135,135 @@ namespace netgen
return occgeo;
}
OCCGeometry * LoadOCC_STEP (const char * filename)
{
// Philippose - 29/01/2009
/* Special STEP File load function including the ability
to extract individual surface colours via the extended
OpenCascade XDE and XCAF Feature set.
*/
OCCGeometry * LoadOCC_STEP (const char * filename)
{
OCCGeometry * occgeo;
occgeo = new OCCGeometry;
STEPControl_Reader reader;
// Initiate a dummy XCAF Application to handle the STEP XCAF Document
static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication();
// Create an XCAF Document to contain the STEP file itself
Handle_TDocStd_Document step_doc;
// Check if a STEP File is already open under this handle, if so, close it to prevent
// Segmentation Faults when trying to create a new document
if(dummy_app->NbDocuments() > 0)
{
dummy_app->GetDocument(1,step_doc);
dummy_app->Close(step_doc);
}
dummy_app->NewDocument ("STEP-XCAF",step_doc);
STEPCAFControl_Reader reader;
Standard_Integer stat = reader.ReadFile((char*)filename);
Standard_Integer nb = reader.NbRootsForTransfer();
reader.TransferRoots (); // Tranlate STEP -> OCC
// Enable transfer of colours
reader.SetColorMode(Standard_True);
reader.Transfer(step_doc);
occgeo->shape = reader.OneShape();
// Read in the shape(s) and the colours present in the STEP File
Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main());
Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main());
TDF_LabelSequence step_shapes;
step_shape_contents->GetShapes(step_shapes);
/*
// List out the available colours in the STEP File as Colour Names
TDF_LabelSequence allColours;
stepColourContents->GetColors(allColours);
cout << "Number of colours in STEP = " << allColours.Length() << endl;
for(int i = 1; i <= allColours.Length(); i++)
{
Quantity_Color col;
stepColourContents->GetColor(allColours.Value(i),col);
cout << "Colour [" << i << "] = " << col.StringName(col.Name()) << endl;
}
*/
occgeo->shape = step_shape_contents->GetShape(step_shapes.Value(1));
occgeo->face_colours = step_colour_contents;
occgeo->changed = 1;
occgeo->BuildFMap();
//
//Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
//sfs->Init(occgeo->shape);
//sfs->Perform();
//Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe(occgeo->shape);
//sfwf->FixSmallEdges();
//sfwf->FixWireGaps();
/*
// JS
TopoDS_Compound aRes;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aRes);
for (TopExp_Explorer exp(occgeo->shape, TopAbs_SOLID); exp.More(); exp.Next())
{
aBuilder.Add (aRes, exp.Current());
cout << "solid" << endl;
}
for (TopExp_Explorer exp(aRes, TopAbs_SOLID); exp.More(); exp.Next())
{
cout << "compound has shapes solid" << endl;
}
occgeo->shape = aRes;
occgeo->changed = 1;
occgeo->BuildFMap();
*/
//
occgeo->BuildVisualizationMesh();
PrintContents (occgeo);
return occgeo;
}
}
// Philippose - 29/01/2009
// The LOADOCC_STEP Function has been replaced by the one
// above, which also includes support for the OpenCascade
// XDE Features.
//
// OCCGeometry * LoadOCC_STEP (const char * filename)
// {
// OCCGeometry * occgeo;
// occgeo = new OCCGeometry;
//
// STEPControl_Reader reader;
// Standard_Integer stat = reader.ReadFile((char*)filename);
// Standard_Integer nb = reader.NbRootsForTransfer();
// reader.TransferRoots (); // Tranlate STEP -> OCC
//
//
//
// occgeo->shape = reader.OneShape();
// occgeo->changed = 1;
// occgeo->BuildFMap();
// //
// //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
// //sfs->Init(occgeo->shape);
// //sfs->Perform();
// //Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe(occgeo->shape);
// //sfwf->FixSmallEdges();
// //sfwf->FixWireGaps();
//
//
//
// /*
// // JS
// TopoDS_Compound aRes;
// BRep_Builder aBuilder;
// aBuilder.MakeCompound (aRes);
//
// for (TopExp_Explorer exp(occgeo->shape, TopAbs_SOLID); exp.More(); exp.Next())
// {
// aBuilder.Add (aRes, exp.Current());
// cout << "solid" << endl;
// }
//
// for (TopExp_Explorer exp(aRes, TopAbs_SOLID); exp.More(); exp.Next())
// {
// cout << "compound has shapes solid" << endl;
// }
// occgeo->shape = aRes;
// occgeo->changed = 1;
// occgeo->BuildFMap();
// */
//
//
// occgeo->BuildVisualizationMesh();
// PrintContents (occgeo);
//
// return occgeo;
// }
OCCGeometry * LoadOCC_BREP (const char * filename)
{

View File

@ -11,9 +11,9 @@
#include <meshing.hpp>
#include <BRep_Tool.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include "BRep_Tool.hxx"
#include "Geom_Curve.hxx"
#include "Geom2d_Curve.hxx"
#include "Geom_Surface.hxx"
#include "GeomAPI_ProjectPointOnSurf.hxx"
#include "GeomAPI_ProjectPointOnCurve.hxx"
@ -37,6 +37,7 @@
#include "TopoDS.hxx"
#include "TopoDS_Solid.hxx"
#include "TopExp_Explorer.hxx"
#include "TopTools_ListIteratorOfListOfShape.hxx"
#include "BRep_Tool.hxx"
#include "Geom_Curve.hxx"
#include "Geom2d_Curve.hxx"
@ -62,8 +63,6 @@
#include "Poly_Triangle.hxx"
#include "GProp_GProps.hxx"
#include "BRepGProp.hxx"
#include "IGESControl_Reader.hxx"
#include "STEPControl_Reader.hxx"
#include "TopoDS_Shape.hxx"
#include "TopoDS_Face.hxx"
#include "IGESToBRep_Reader.hxx"
@ -80,8 +79,33 @@
#include "Bnd_Box.hxx"
#include "ShapeAnalysis.hxx"
#include "ShapeBuild_ReShape.hxx"
// Philippose - 29/01/2009
// OpenCascade XDE Support
// Include support for OpenCascade XDE Features
#include "TDocStd_Document.hxx"
#include "Quantity_Color.hxx"
#include "XCAFApp_Application.hxx"
#include "XCAFDoc_ShapeTool.hxx"
#include "XCAFDoc_Color.hxx"
#include "XCAFDoc_ColorTool.hxx"
#include "XCAFDoc_ColorType.hxx"
#include "XCAFDoc_LayerTool.hxx"
#include "XCAFDoc_DimTolTool.hxx"
#include "XCAFDoc_MaterialTool.hxx"
#include "XCAFDoc_DocumentTool.hxx"
#include "TDF_Label.hxx"
#include "TDF_LabelSequence.hxx"
#include "STEPCAFControl_Reader.hxx"
#include "STEPCAFControl_Writer.hxx"
#include "IGESCAFControl_Reader.hxx"
#include "IGESCAFControl_Writer.hxx"
#include "IGESControl_Reader.hxx"
#include "STEPControl_Reader.hxx"
#include "IGESControl_Writer.hxx"
#include "STEPControl_Writer.hxx"
#include "StlAPI_Writer.hxx"
#include "STEPControl_StepModelType.hxx"
@ -97,58 +121,53 @@ namespace netgen
#define PROJECTION_TOLERANCE 1e-10
#define ENTITYISVISIBLE 1
#define ENTITYISHIGHLIGHTED 2
#define ENTITYISDRAWABLE 4
class EntityVisualizationCode
{
class EntityVisualizationCode
{
int code;
public:
public:
EntityVisualizationCode()
{ code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE; }
{ code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE;}
int IsVisible ()
{ return code & ENTITYISVISIBLE; }
{ return code & ENTITYISVISIBLE;}
int IsHighlighted ()
{ return code & ENTITYISHIGHLIGHTED; }
{ return code & ENTITYISHIGHLIGHTED;}
int IsDrawable ()
{ return code & ENTITYISDRAWABLE; }
{ return code & ENTITYISDRAWABLE;}
void Show ()
{ code |= ENTITYISVISIBLE; }
{ code |= ENTITYISVISIBLE;}
void Hide ()
{ code &= ~ENTITYISVISIBLE; }
{ code &= ~ENTITYISVISIBLE;}
void Highlight ()
{ code |= ENTITYISHIGHLIGHTED; }
{ code |= ENTITYISHIGHLIGHTED;}
void Lowlight ()
{ code &= ~ENTITYISHIGHLIGHTED; }
{ code &= ~ENTITYISHIGHLIGHTED;}
void SetDrawable ()
{ code |= ENTITYISDRAWABLE; }
{ code |= ENTITYISDRAWABLE;}
void SetNotDrawable ()
{ code &= ~ENTITYISDRAWABLE; }
};
{ code &= ~ENTITYISDRAWABLE;}
};
inline double Det3 (double a00, double a01, double a02,
inline double Det3 (double a00, double a01, double a02,
double a10, double a11, double a12,
double a20, double a21, double a22)
{
{
return a00*a11*a22 + a01*a12*a20 + a10*a21*a02 - a20*a11*a02 - a10*a01*a22 - a21*a12*a00;
}
}
#define OCCGEOMETRYVISUALIZATIONNOCHANGE 0
#define OCCGEOMETRYVISUALIZATIONFULLCHANGE 1
@ -156,19 +175,36 @@ inline double Det3 (double a00, double a01, double a02,
#define OCCGEOMETRYVISUALIZATIONHALFCHANGE 2
// == redraw
class OCCGeometry
{
class OCCGeometry
{
Point<3> center;
public:
public:
TopoDS_Shape shape;
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
Array<bool> fsingular, esingular, vsingular;
Box<3> boundingbox;
// Philippose - 29/01/2009
// OpenCascade XDE Support
// XCAF Handle to make the face colours available to the rest of
// the system
Handle_XCAFDoc_ColorTool face_colours;
int changed;
Array<int> facemeshstatus;
// Philippose - 15/01/2009
// Maximum mesh size for a given face
// (Used to explicitly define mesh size limits on individual faces)
Array<double> face_maxh;
// Philippose - 15/01/2009
// Indicates which faces have been selected by the user in geometry mode
// (Currently handles only selection of one face at a time, but an array would
// help to extend this to multiple faces)
Array<bool> face_sel_status;
Array<EntityVisualizationCode> fvispar, evispar, vvispar;
double tolerance;
@ -178,7 +214,6 @@ public:
bool makesolids;
bool splitpartitions;
OCCGeometry()
{
somap.Clear();
@ -189,32 +224,34 @@ public:
vmap.Clear();
}
void BuildFMap();
Box<3> GetBoundingBox()
{ return boundingbox; }
{ return boundingbox;}
int NrSolids()
{ return somap.Extent(); }
{ return somap.Extent();}
// Philippose - 17/01/2009
// Total number of faces in the geometry
int NrFaces()
{ return fmap.Extent();}
void SetCenter()
{ center = boundingbox.Center(); }
{ center = boundingbox.Center();}
Point<3> Center()
{ return center; }
{ return center;}
void Project (int surfi, Point<3> & p) const;
bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
OCCSurface GetSurface (int surfi)
{
cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
return OCCSurface (TopoDS::Face(fmap(surfi)), PLANESPACE);
}
void BuildVisualizationMesh ();
void RecursiveTopologyTree (const TopoDS_Shape & sh,
@ -235,6 +272,60 @@ public:
void HealGeometry();
// Philippose - 15/01/2009
// Sets the maximum mesh size for a given face
// (Note: Local mesh size limited by the global max mesh size)
void SetFaceMaxH(int facenr, double faceh)
{
if((facenr> 0) && (facenr <= fmap.Extent()))
{
face_maxh[facenr-1] = min(mparam.maxh,faceh);
}
}
// Philippose - 15/01/2009
// Returns the local mesh size of a given face
double GetFaceMaxH(int facenr)
{
if((facenr> 0) && (facenr <= fmap.Extent()))
{
return face_maxh[facenr-1];
}
else
{
return 0.0;
}
}
// Philippose - 17/01/2009
// Returns the index of the currently selected face
int SelectedFace()
{
int i;
for(i = 1; i <= fmap.Extent(); i++)
{
if(face_sel_status[i-1])
{
return i;
}
}
return 0;
}
// Philippose - 17/01/2009
// Sets the currently selected face
void SetSelectedFace(int facenr)
{
face_sel_status = 0;
if((facenr >= 1) && (facenr <= fmap.Extent()))
{
face_sel_status[facenr-1] = 1;
}
}
void LowLightAll()
{
for (int i = 1; i <= fmap.Extent(); i++)
@ -250,14 +341,13 @@ public:
bool ErrorInSurfaceMeshing ();
void WriteOCC_STL(char * filename);
};
};
void PrintContents (OCCGeometry * geom);
void PrintContents (OCCGeometry * geom);
OCCGeometry * LoadOCC_IGES (const char * filename);
OCCGeometry * LoadOCC_STEP (const char * filename);
OCCGeometry * LoadOCC_BREP (const char * filename);
OCCGeometry * LoadOCC_IGES (const char * filename);
OCCGeometry * LoadOCC_STEP (const char * filename);
OCCGeometry * LoadOCC_BREP (const char * filename);
}

View File

@ -9,18 +9,25 @@
#include <csg.hpp>
#include <stlgeom.hpp>
#include <visual.hpp>
// #include <parallel.hpp>
#ifdef OCCGEOMETRY
// Philippose - 30/01/2009
// Required for OpenCascade XDE Support
#include <occgeom.hpp>
#endif
#include <visual.hpp>
namespace netgen
{
#ifdef OCCGEOMETRY
// Philippose - 30/01/2009
// Required for OpenCascade XDE Support
extern OCCGeometry * occgeometry;
#endif
extern AutoPtr<Mesh> mesh;
@ -1025,6 +1032,23 @@ namespace netgen
}
#endif
#ifdef OCCGEOMETRY
// Philippose - 30/01/2009
// OpenCascade XDE Support
// Update the colour of each face based on the STEP File Data
// if the advanced OpenCascade XDE Support has been enabled
if((col == 1) && (occgeometry))
{
TopoDS_Face face = TopoDS::Face(occgeometry->fmap(el.GetIndex()));
Quantity_Color face_colour;
occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour);
matcol[0] = face_colour.Red();
matcol[1] = face_colour.Green();
matcol[2] = face_colour.Blue();
matcol[3] = 1.0;
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol);
}
#endif
bool drawel = !el.IsDeleted();

View File

@ -2,7 +2,6 @@
#ifdef OCCGEOMETRY
#include <mystdlib.h>
#include <myadt.hpp>
#include <meshing.hpp>
@ -30,35 +29,29 @@
#include "incvis.hpp"
namespace netgen
{
#include "mvdraw.hpp"
extern OCCGeometry * occgeometry;
extern OCCGeometry * occgeometry;
/* *********************** Draw OCC Geometry **************** */
/* *********************** Draw OCC Geometry **************** */
VisualSceneOCCGeometry :: VisualSceneOCCGeometry ()
VisualSceneOCCGeometry :: VisualSceneOCCGeometry ()
: VisualScene()
{
{
trilists.SetSize(0);
linelists.SetSize(1);
}
}
VisualSceneOCCGeometry :: ~VisualSceneOCCGeometry ()
{
VisualSceneOCCGeometry :: ~VisualSceneOCCGeometry ()
{
;
}
}
void VisualSceneOCCGeometry :: DrawScene ()
{
void VisualSceneOCCGeometry :: DrawScene ()
{
if ( occgeometry->changed )
{
BuildScene();
@ -87,25 +80,26 @@ void VisualSceneOCCGeometry :: DrawScene ()
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
glLogicOp (GL_COPY);
float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f };
float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f};
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glPolygonOffset (1, 1);
glEnable (GL_POLYGON_OFFSET_FILL);
GLfloat matcoledge[] = { 0, 0, 1, 1 };
GLfloat matcolhiedge[] = { 1, 0, 0, 1 };
// Philippose - 30/01/2009
// Added clipping planes to Geometry view
SetClippingPlane();
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
matcoledge);
GLfloat matcoledge[] = { 0, 0, 1, 1};
GLfloat matcolhiedge[] = { 1, 0, 0, 1};
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge);
glLineWidth (1.0f);
if (vispar.occshowedges) glCallList (linelists.Get(1));
if (vispar.occshowsurfaces) glCallList (trilists.Get(1));
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
matcolhiedge);
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
glLineWidth (5.0f);
if (vispar.occshowedges) glCallList (linelists.Get(2));
@ -113,8 +107,7 @@ void VisualSceneOCCGeometry :: DrawScene ()
for (int i = 1; i <= occgeometry->vmap.Extent(); i++)
if (occgeometry->vvispar[i-1].IsHighlighted())
{
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
matcolhiedge);
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
glLineWidth (5.0f);
glBegin (GL_LINES);
@ -130,7 +123,6 @@ void VisualSceneOCCGeometry :: DrawScene ()
glEnd();
}
glDisable (GL_POLYGON_OFFSET_FILL);
glPopMatrix();
@ -139,12 +131,11 @@ void VisualSceneOCCGeometry :: DrawScene ()
glFinish();
glDisable (GL_POLYGON_OFFSET_FILL);
}
}
/*
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
/*
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
int i = 0, j, k;
TopExp_Explorer ex, ex_edge;
@ -368,12 +359,11 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
glEndList ();
}
*/
}
*/
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
if (occgeometry -> changed == OCCGEOMETRYVISUALIZATIONFULLCHANGE)
{
center = occgeometry -> Center();
@ -425,7 +415,6 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
CalcTransformationMatrices();
}
// Clear lists
for (int i = 1; i <= linelists.Size(); i++)
@ -436,7 +425,6 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
glDeleteLists (trilists.Elem(i), 1);
trilists.SetSize(0);
// Total wireframe
linelists.Append (glGenLists (1));
@ -484,7 +472,6 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
glEndList ();
// Highlighted edge list
linelists.Append (glGenLists (1));
@ -532,10 +519,6 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
glEndList ();
// display faces
trilists.Append (glGenLists (1));
@ -549,11 +532,17 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
float mat_col[4];
mat_col[3] = 1;
TopoDS_Face face = TopoDS::Face(occgeometry->fmap(i));
if (!occgeometry->fvispar[i-1].IsHighlighted())
{
mat_col[0] = 0.2;
mat_col[1] = 0.2;
mat_col[2] = 0.8;
// Philippose - 30/01/2009
// OpenCascade XDE Support
Quantity_Color face_colour;
occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour);
mat_col[0] = face_colour.Red();
mat_col[1] = face_colour.Green();
mat_col[2] = face_colour.Blue();
}
else
{
@ -564,7 +553,6 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
TopoDS_Face face = TopoDS::Face(occgeometry->fmap(i));
TopLoc_Location loc;
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
BRepAdaptor_Surface sf(face, Standard_False);
@ -621,12 +609,12 @@ void VisualSceneOCCGeometry :: BuildScene (int zoomall)
}
glEndList ();
}
}
void SelectFaceInOCCDialogTree (int facenr);
void SelectFaceInOCCDialogTree (int facenr);
void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
{
void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
{
int hits;
// select surface triangle by mouse click
@ -634,13 +622,11 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
GLuint selbuf[10000];
glSelectBuffer (10000, selbuf);
glRenderMode (GL_SELECT);
GLint viewport[4];
glGetIntegerv (GL_VIEWPORT, viewport);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
@ -651,8 +637,6 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
gluPickMatrix (px, viewport[3] - py, 1, 1, viewport);
glMultMatrixd (projmat);
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -661,8 +645,6 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
glPushMatrix();
glMultMatrixf (transformationmat);
glInitNames();
glPushName (1);
@ -671,6 +653,30 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
glDisable(GL_CLIP_PLANE0);
// Philippose - 30/01/2009
// Enable clipping planes for Selection mode in OCC Geometry
if (vispar.clipenable)
{
Vec<3> n(clipplane[0], clipplane[1], clipplane[2]);
double len = Abs(n);
double mu = -clipplane[3] / (len*len);
Point<3> p (mu * n);
n /= len;
Vec<3> t1 = n.GetNormal ();
Vec<3> t2 = Cross (n, t1);
double xi1mid = (center - p) * t1;
double xi2mid = (center - p) * t2;
glLoadName (0);
glBegin (GL_QUADS);
glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2);
glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2);
glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2);
glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2);
glEnd ();
}
glCallList (trilists.Get(1));
glDisable (GL_POLYGON_OFFSET_FILL);
@ -685,7 +691,6 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
glFlush();
hits = glRenderMode (GL_RENDER);
int minname = 0;
@ -704,7 +709,7 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
{
int curname = selbuf[4*i+3];
GLuint curdepth = selbuf[4*i+1];
if (curname && (curdepth > clipdepth) &&
if (curname && (curdepth> clipdepth) &&
(curdepth < mindepth || !minname))
{
mindepth = curdepth;
@ -733,20 +738,16 @@ void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
SelectFaceInOCCDialogTree (minname);
// Philippose - 30/01/2009
// Set the currently selected face in the array
// for local face mesh size definition
occgeometry->SetSelectedFace(minname);
// selecttimestamp = NextTimeStamp();
}
}
}
#endif
#endif // NOTCL