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

exotkUtils_BRep.cxx

Go to the documentation of this file.
00001 
00002 //   exotkUtils_BRep.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 <exotkUtils_BRep.hxx>
00029 #ifndef  _TopTools_HSequenceOfShape_HeaderFile
00030 #include <TopTools_HSequenceOfShape.hxx>
00031 #endif
00032 #ifndef  _TopoDS_Shape_HeaderFile
00033 #include <TopoDS_Shape.hxx>
00034 #endif
00035 #ifndef  _TopoDS_Compound_HeaderFile
00036 #include <TopoDS_Compound.hxx>
00037 #endif
00038 #ifndef  _BRep_Builder_HeaderFile
00039 #include <BRep_Builder.hxx>
00040 #endif
00041 #ifndef  _TCollection_AsciiString_HeaderFile
00042 #include <TCollection_AsciiString.hxx>
00043 #endif
00044 
00045 
00046 //==================================================================================
00047 // Function name        : exotkUtils_BRep::BuildShape
00048 //==================================================================================
00049 // Written by       : Stephane Routelous - 2001-11-08 19:01:56
00050 // Description      : 
00051 // Return type          : Standard_Boolean 
00052 //==================================================================================
00053 // Argument         : TopoDS_Shape& aShape
00054 // Argument         : const Handle_TopTools_HSequenceOfShape& aSequenceOfShape
00055 Standard_Boolean exotkUtils_BRep::BuildShape(TopoDS_Shape& aShape,const Handle_TopTools_HSequenceOfShape& aSequenceOfShape)
00056 {
00057         Standard_Boolean Success = Standard_False;
00058         Standard_Integer theNbShapes = 0;
00059         TopoDS_Compound theCompound;
00060         BRep_Builder theBuilder;
00061         theBuilder.MakeCompound(theCompound);
00062         if ( !aSequenceOfShape.IsNull() )
00063         {
00064                 if ( !aSequenceOfShape->IsEmpty() )
00065                 {
00066                         for ( Standard_Integer theSequenceIterator = 1 ; theSequenceIterator <= aSequenceOfShape->Length() ; theSequenceIterator ++ )
00067                         {
00068                                 TopoDS_Shape theCurrentShape = aSequenceOfShape->Value(theSequenceIterator);
00069                                 if ( !theCurrentShape.IsNull() )
00070                                 {
00071                                         theNbShapes++;
00072                                         if ( theNbShapes == 1 )
00073                                         {
00074                                                 aShape = theCurrentShape;
00075                                         }
00076                                         theBuilder.Add(theCompound,theCurrentShape);
00077                                 }
00078                         }
00079                 }
00080         }
00081 
00082         if ( theNbShapes > 0 )
00083         {
00084                 if ( theNbShapes > 1 )
00085                 {
00086                         aShape = theCompound;
00087                 }
00088                 Success = Standard_True;
00089         }
00090         return Success;
00091 }
00092 
00093 
00094 //==================================================================================
00095 // Function name        : exotkUtils_BRep::NameFromShapeType
00096 //==================================================================================
00097 // Written by       : Stephane Routelous - 2001-11-20 19:04:11
00098 // Description      : 
00099 // Return type          : TCollection_AsciiString 
00100 //==================================================================================
00101 // Argument         : const TopoDS_Shape &aShape
00102 TCollection_AsciiString exotkUtils_BRep::NameFromShapeType(const TopoDS_Shape &aShape)
00103 {
00104         TCollection_AsciiString theName;
00105 
00106         if ( !aShape.IsNull() )
00107         {
00108                 switch ( aShape.ShapeType() )
00109                 {
00110                 case TopAbs_VERTEX:
00111                         theName = TCollection_AsciiString("Vertex");
00112                         break;
00113                 case TopAbs_FACE:
00114                         theName = TCollection_AsciiString("Face");
00115                         break;
00116                 case TopAbs_WIRE:
00117                         theName = TCollection_AsciiString("Wire");
00118                         break;
00119                 case TopAbs_EDGE:
00120                         theName = TCollection_AsciiString("Edge");
00121                         break;
00122                 case TopAbs_SHELL:
00123                         theName = TCollection_AsciiString("Shell");
00124                         break;
00125                 case TopAbs_COMPOUND:
00126                         theName = TCollection_AsciiString("Compound");
00127                         break;
00128                 case TopAbs_SOLID:
00129                         theName = TCollection_AsciiString("Solid");
00130                         break;
00131                 case TopAbs_COMPSOLID:
00132                         theName = TCollection_AsciiString("CompSolid");
00133                         break;
00134                 }
00135         }
00136         return theName;
00137 }

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