diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index b7706348..daf1d262 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -208,6 +208,20 @@ namespace netgen */ mesh.AddFaceDescriptor (FaceDescriptor(facenr, solidnr0, solidnr1, 0)); + + // Philippose - 06/07/2009 + // Add the face colour to the mesh data + Quantity_Color face_colour; + + if(!(geom.face_colours.IsNull()) + && (geom.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))) + { + mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(face_colour.Red(),face_colour.Green(),face_colour.Blue())); + } + else + { + mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(0.0,1.0,0.0)); + } // ACHTUNG! STIMMT NICHT ALLGEMEIN (RG) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 29a5aebe..340ebc01 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -1162,57 +1162,7 @@ namespace netgen } - - // Philippose - 23/02/2009 - // The LOADOCC_IGES Function has been replaced by the one - // above, which also includes support for the OpenCascade - // XDE Features. - // - //OCCGeometry * LoadOCC_IGES (const char * filename) - //{ - // OCCGeometry * occgeo; - // occgeo = new OCCGeometry; - - // IGESControl_Reader reader; - - // Standard_Integer stat = reader.ReadFile((char*)filename); - - // // pre OCC52-times: - // // Standard_Integer stat = reader.LoadFile((char*)filename); - // // reader.Clear(); - - - // reader.TransferRoots(); // Tranlate IGES -> OCC - - // // pre OCC52-times: - // // reader.TransferRoots(Standard_False); // Tranlate IGES -> OCC - - // //reader.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); - - // 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->DropSmallEdgesMode() = Standard_True; - // // sfwf->FixSmallEdges(); - // // sfwf->FixWireGaps(); - - // // - - - // // occgeo->BuildVisualizationMesh(); - // occgeo->CalcBoundingBox(); - // PrintContents (occgeo); - - // return occgeo; - //} - // Philippose - 29/01/2009 @@ -1263,9 +1213,9 @@ namespace netgen PrintMessage(4,"Number of colours in STEP File: ",all_colours.Length()); for(int i = 1; i <= all_colours.Length(); i++) { - Quantity_Color col; - step_colour_contents->GetColor(all_colours.Value(i),col); - PrintMessage(4, "Colour [", i, "] = ",col.StringName(col.Name())); + Quantity_Color col; + step_colour_contents->GetColor(all_colours.Value(i),col); + PrintMessage(4, "Colour [", i, "] = ",col.StringName(col.Name())); } @@ -1285,64 +1235,6 @@ namespace netgen - // 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; - // } - diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index 13ced0ef..e50e5cd6 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -2,7 +2,6 @@ #include - #include #include #include @@ -10,31 +9,14 @@ // #include -#ifdef OCCGEOMETRY -// Philippose - 30/01/2009 -// Required for OpenCascade XDE Support -#include -#endif - #include - namespace netgen { - -#ifdef OCCGEOMETRY - // Philippose - 30/01/2009 - // Required for OpenCascade XDE Support - extern OCCGeometry * occgeometry; -#endif - - extern AutoPtr mesh; extern STLGeometry * stlgeometry; VisualSceneMesh vsmesh; - - VisualSceneMesh :: VisualSceneMesh () : VisualScene() { @@ -1031,37 +1013,19 @@ 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; - // Philippose - 23/02/2009 - // Check to see if colours have been extracted first!! - // Forum bug-fox (Jean-Yves - 23/02/2009) - if(!(occgeometry->face_colours.IsNull()) - &&(occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))) - { - matcol[0] = face_colour.Red(); - matcol[1] = face_colour.Green(); - matcol[2] = face_colour.Blue(); - } - else - { - matcol[0] = 0.0; - matcol[1] = 1.0; - matcol[2] = 0.0; - } + // Philippose - 06/07/2009 + // Modified the colour system to integrate the face colours into + // the mesh data structure, rather than limit it to the OCC geometry + // structure... allows other geometry types to use face colours too + if(col == 1) + { + matcol[0] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().X(); + matcol[1] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().Y(); + matcol[2] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().Z(); - - matcol[3] = 1.0; - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); - } -#endif + matcol[3] = 1.0; + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); + } bool drawel = !el.IsDeleted();