00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00048
00049
00050
00051
00052
00053
00054
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
00096
00097
00098
00099
00100
00101
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 }