Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

exotkGUI.cxx

Go to the documentation of this file.
00001 
00002 //   exotkGUI.cxx
00004 //    Copyright (C) 2001  Stephane Routelous
00005 //
00006 //    This file is part of exoTK.
00007 //
00008 //    exoTK is free software; you can redistribute it and/or modify
00009 //    it under the terms of the GNU General Public License as published by
00010 //    the Free Software Foundation; either version 2 of the License, or
00011 //    (at your option) any later version.
00012 //
00013 //    exoTK is distributed in the hope that it will be useful,
00014 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //    GNU General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU General Public License
00019 //    along with exoTK; if not, write to the Free Software
00020 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00028 #include <exotkGUI.hxx>
00029 
00030 #ifndef  _exotkGUI_GUI_HeaderFile
00031 #include <exotkGUI_GUI.hxx>
00032 #endif
00033 #ifndef  _TopoDS_Shape_HeaderFile
00034 #include <TopoDS_Shape.hxx>
00035 #endif
00036 #ifndef  _BRepPrimAPI_MakeBox_HeaderFile
00037 #include <BRepPrimAPI_MakeBox.hxx>
00038 #endif
00039 #ifndef  _BRepPrimAPI_MakeSphere_HeaderFile
00040 #include <BRepPrimAPI_MakeSphere.hxx>
00041 #endif
00042 #ifndef  _BRepAlgoAPI_Common_HeaderFile
00043 #include <BRepAlgoAPI_Common.hxx>
00044 #endif
00045 #ifndef  _BRepPrimAPI_MakeCylinder_HeaderFile
00046 #include <BRepPrimAPI_MakeCylinder.hxx>
00047 #endif
00048 #ifndef  _BRepAlgoAPI_Cut_HeaderFile
00049 #include <BRepAlgoAPI_Cut.hxx>
00050 #endif
00051 #ifndef  _TopTools_ListIteratorOfListOfShape_HeaderFile
00052 #include <TopTools_ListIteratorOfListOfShape.hxx>
00053 #endif
00054 #ifndef  _TopoDS_Compound_HeaderFile
00055 #include <TopoDS_Compound.hxx>
00056 #endif
00057 #ifndef  _TopExp_Explorer_HeaderFile
00058 #include <TopExp_Explorer.hxx>
00059 #endif
00060 #ifndef  _BRepFilletAPI_MakeFillet_HeaderFile
00061 #include <BRepFilletAPI_MakeFillet.hxx>
00062 #endif
00063 #ifndef  _TopOpeBRepBuild_HBuilder_HeaderFile
00064 #include <TopOpeBRepBuild_HBuilder.hxx>
00065 #endif
00066 #ifndef  _TopoDS_HeaderFile
00067 #include <TopoDS.hxx>
00068 #endif
00069 #ifndef  _BRepTools_HeaderFile
00070 #include <BRepTools.hxx>
00071 #endif
00072 
00078 namespace exotkGUI_Datas
00079 {
00081         Handle_exotkGUI_GUI theGUI;
00082         
00084         TopoDS_Shape theSample;
00085 }
00086 //==================================================================================
00087 // Function name        : exotkGUI::SetGUI
00088 //==================================================================================
00089 // Written by       : Stephane Routelous - 2001-11-22 13:51:58
00090 // Description      : 
00091 // Return type          : void 
00092 //==================================================================================
00093 // Argument         : const Handle_exotkGUI_GUI& aGUI
00094 void exotkGUI::SetGUI(const Handle_exotkGUI_GUI& aGUI)
00095 {
00096         exotkGUI_Datas::theGUI = aGUI;
00097 }
00098 
00099 
00107 TopoDS_Shape boolbl(const BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
00108 {
00109         Standard_Real t3d = 1.e-4;
00110         Standard_Real t2d = 1.e-5;
00111         Standard_Real ta  = 1.e-2;
00112         Standard_Real fl  = 1.e-3;
00113         Standard_Real tapp_angle = 1.e-2;
00114         GeomAbs_Shape blend_cont = GeomAbs_C1;
00115 
00116         TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
00117         
00118         Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
00119         TopTools_ListIteratorOfListOfShape its;
00120         
00121         TopoDS_Compound result;
00122         BRep_Builder B; 
00123         B.MakeCompound(result);
00124         
00125         TopExp_Explorer ex;
00126         for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
00127         {
00128                 const TopoDS_Shape& cutsol = ex.Current();  
00129                 
00130                 BRepFilletAPI_MakeFillet fill(cutsol);
00131                 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
00132                 fill.SetContinuity(blend_cont, tapp_angle);
00133                 its = build->Section();
00134                 while (its.More()) 
00135                 {
00136                         TopoDS_Edge E = TopoDS::Edge(its.Value());
00137                         fill.Add(aRadius, E);
00138                         its.Next();
00139                 }
00140                 
00141                 fill.Build();
00142                 if (fill.IsDone())
00143                 {
00144                         B.Add(result, fill.Shape());
00145                 }
00146                 else 
00147                 {
00148                         B.Add(result, cutsol);
00149                 }
00150         }
00151         return result;
00152 }
00153 
00162 TopoDS_Shape cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
00163 {
00164         return boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
00165 }
00166 
00175 TopoDS_Shape common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
00176 {
00177         return boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
00178 }
00179 
00180 //==================================================================================
00181 // Function name        : exotkGUI::Sample
00182 //==================================================================================
00183 // Written by       : Stephane Routelous - 2001-12-07 13:12:54
00184 // Description      : 
00185 // Return type          : TopoDS_Shape 
00186 //==================================================================================
00187 TopoDS_Shape exotkGUI::Sample()
00188 {
00189         TopoDS_Shape theReturnedSample;
00190         if (exotkGUI_Datas::theSample.IsNull())
00191         {
00192 #ifdef ComplexSample
00193                 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10);
00194                 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7);
00195 
00196                 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
00197                 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10), gp_Dir(0, 0, 1)), 3, 20);
00198                 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0), gp_Dir(1, 0, 0)), 3, 20);
00199                 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0), gp_Dir(0, 1, 0)), 3, 20);
00200                 TopoDS_Shape theTmp1 = cut_blend(theCommon,theCylinder1,0.7);
00201                 TopoDS_Shape theTmp2 = cut_blend(theTmp1,theCylinder2,0.7);
00202                 TopoDS_Shape theResult = cut_blend(theTmp2,theCylinder3,0.7);
00203 
00204                 theReturnedSample = theResult;
00205                 exotkGUI_Datas::theSample = theResult;
00206 #else
00207                 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10);
00208                 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(6);
00209                 TopoDS_Shape theCommon = common_blend(theBox,theSphere,1);
00210                 theReturnedSample = theCommon;
00211                 exotkGUI_Datas::theSample = theCommon;
00212 #endif
00213 
00214         }
00215         else
00216         {
00217                 theReturnedSample = exotkGUI_Datas::theSample;
00218         }
00219         return theReturnedSample;
00220 }
00221 
00222 Standard_Boolean exotkGUI::SetPtr(void* anHandle)
00223 {
00224         if ( !exotkGUI_Datas::theGUI.IsNull() )
00225         {
00226                 exotkGUI_Datas::theGUI->SetPtr(anHandle);
00227                 return Standard_True;
00228         }
00229         return Standard_False;
00230 }
00231 Standard_Boolean  exotkGUI::Ptr(void* anHandle)
00232 {
00233         if ( !exotkGUI_Datas::theGUI.IsNull() )
00234         {
00235                 anHandle = exotkGUI_Datas::theGUI->Ptr();
00236                 return Standard_True;
00237         }
00238         return Standard_False;
00239 }
00240 Standard_Boolean exotkGUI::UnSetPtr()
00241 {
00242         if ( !exotkGUI_Datas::theGUI.IsNull() )
00243         {
00244                 exotkGUI_Datas::theGUI->UnSetPtr();
00245                 return Standard_True;
00246         }
00247         return Standard_False;
00248 }
00249 Standard_Boolean exotkGUI::SelectColor(const Quantity_Color& aDefaultColor,Quantity_Color& aSelectedColor,Standard_Boolean& aColorIsSelected)
00250 {
00251         if ( !exotkGUI_Datas::theGUI.IsNull() )
00252         {
00253                 aColorIsSelected = exotkGUI_Datas::theGUI->SelectColor(aDefaultColor,aSelectedColor);
00254                 return Standard_True;
00255         }
00256         return Standard_False;
00257 }
00258 Standard_Boolean exotkGUI::SelectMaterial(const Graphic3d_MaterialAspect& aDefaultMaterial,Graphic3d_MaterialAspect& aSelectedMaterial,Standard_Boolean& aMaterialIsSelected)
00259 {
00260         if ( !exotkGUI_Datas::theGUI.IsNull() )
00261         {
00262                 aMaterialIsSelected = exotkGUI_Datas::theGUI->SelectMaterial(aDefaultMaterial,aSelectedMaterial);
00263                 return Standard_True;
00264         }
00265         return Standard_False;
00266 }
00267 Standard_Boolean exotkGUI::SelectTransparency(const Standard_Real aDefaultTransparency,Standard_Real& aSelectedTransparency,Standard_Boolean& aTransparencyIsSelected)
00268 {
00269         if ( !exotkGUI_Datas::theGUI.IsNull() )
00270         {
00271                 aTransparencyIsSelected = exotkGUI_Datas::theGUI->SelectTransparency(aDefaultTransparency,aSelectedTransparency);
00272                 return Standard_True;
00273         }
00274         return Standard_False;
00275 }
00276 Standard_Boolean exotkGUI::OpenDXFileDialog(TCollection_AsciiString& aFilename)
00277 {
00278         if ( !exotkGUI_Datas::theGUI.IsNull() )
00279         {
00280                 return exotkGUI_Datas::theGUI->OpenDXFileDialog(aFilename) ;
00281         }
00282         return Standard_False;
00283 }
00284 Standard_Boolean exotkGUI::SaveDXFileDialog(TCollection_AsciiString& aFilename)
00285 {
00286         if ( !exotkGUI_Datas::theGUI.IsNull() )
00287         {
00288                 return exotkGUI_Datas::theGUI->SaveDXFileDialog(aFilename);
00289         }
00290         return Standard_False;
00291 }
00292 Standard_Boolean exotkGUI::SetProgressBoxTitle(const TCollection_AsciiString& aTitle)
00293 {
00294         if ( !exotkGUI_Datas::theGUI.IsNull() )
00295         {
00296                 exotkGUI_Datas::theGUI->SetProgressBoxTitle(aTitle);
00297                 return Standard_True;
00298         }
00299         return Standard_False;
00300 }
00301 Standard_Boolean exotkGUI::SetProgressBoxText(const TCollection_AsciiString& aText)
00302 {
00303         if ( !exotkGUI_Datas::theGUI.IsNull() )
00304         {
00305                 exotkGUI_Datas::theGUI->SetProgressBoxText(aText);
00306                 return Standard_True;
00307         }
00308         return Standard_False;
00309 }
00310 TCollection_AsciiString exotkGUI::ProgressBoxText()
00311 {
00312         TCollection_AsciiString theText;
00313         if ( !exotkGUI_Datas::theGUI.IsNull() )
00314         {
00315                 return exotkGUI_Datas::theGUI->ProgressBoxText();
00316         }
00317         return theText;
00318 
00319 }
00320 Standard_Boolean exotkGUI::ProgressBoxPosition(Standard_Integer& aPosition)
00321 {
00322         if ( !exotkGUI_Datas::theGUI.IsNull() )
00323         {
00324                 aPosition = exotkGUI_Datas::theGUI->ProgressBoxPosition();
00325                 return Standard_True;
00326         }
00327         return Standard_False;
00328 }
00329 Standard_Boolean exotkGUI::SetProgressBoxPosition(const Standard_Integer aPosition)
00330 {
00331         if ( !exotkGUI_Datas::theGUI.IsNull() )
00332         {
00333                 exotkGUI_Datas::theGUI->SetProgressBoxPosition(aPosition);
00334                 return Standard_True;
00335         }
00336         return Standard_False;
00337 }
00338 Standard_Boolean exotkGUI::HideProgressBox()
00339 {
00340         if ( !exotkGUI_Datas::theGUI.IsNull() )
00341         {
00342                 exotkGUI_Datas::theGUI->HideProgressBox();
00343                 return Standard_True;
00344         }
00345         return Standard_False;
00346 }
00347 Standard_Boolean exotkGUI::ShowProgressBox()
00348 {
00349         if ( !exotkGUI_Datas::theGUI.IsNull() )
00350         {
00351                 exotkGUI_Datas::theGUI->ShowProgressBox();
00352                 return Standard_True;
00353         }
00354         return Standard_False;
00355 }
00356 Standard_Boolean exotkGUI::ManagePopup(const Handle_exotkTree_Menu& aMenu,const Standard_Integer& aX,const Standard_Integer& aY)
00357 {
00358         if ( !exotkGUI_Datas::theGUI.IsNull() )
00359         {
00360                 exotkGUI_Datas::theGUI->ManagePopup(aMenu,aX,aY);
00361                 return Standard_True;
00362         }
00363         return Standard_False;
00364 }
00365 
00366 Standard_Boolean exotkGUI::SetProgressBoxRange(const Standard_Integer aBegin, const Standard_Integer anEnd)
00367 {
00368         if ( !exotkGUI_Datas::theGUI.IsNull() )
00369         {
00370                 exotkGUI_Datas::theGUI->SetProgressBoxRange(aBegin,anEnd);
00371                 return Standard_True;
00372         }
00373         return Standard_False;
00374 
00375 }
00376 Standard_Boolean exotkGUI::ProgressBoxRange(Standard_Integer& aBegin,Standard_Integer& anEnd)
00377 {
00378         if ( !exotkGUI_Datas::theGUI.IsNull() )
00379         {
00380                 exotkGUI_Datas::theGUI->ProgressBoxRange(aBegin,anEnd);
00381                 return Standard_True;
00382         }
00383         return Standard_False;
00384 }
00385 Standard_Boolean exotkGUI::HideWaitCursor()
00386 {
00387         if ( !exotkGUI_Datas::theGUI.IsNull() )
00388         {
00389                 exotkGUI_Datas::theGUI->HideWaitCursor();
00390                 return Standard_True;
00391         }
00392         return Standard_False;
00393 }
00394 Standard_Boolean exotkGUI::ShowWaitCursor()
00395 {
00396         if ( !exotkGUI_Datas::theGUI.IsNull() )
00397         {
00398                 exotkGUI_Datas::theGUI->ShowWaitCursor();
00399                 return Standard_True;
00400         }
00401         return Standard_False;
00402 }

Generated on Wed Jan 23 12:16:41 2002 for exotk by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001