00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00028 #include <exotkBRepTree.hxx>
00029
00030 #ifndef _exotkBRepTree_ShapeNode_HeaderFile
00031 #include <exotkBRepTree_ShapeNode.hxx>
00032 #endif
00033 #ifndef _TopoDS_Shape_HeaderFile
00034 #include <TopoDS_Shape.hxx>
00035 #endif
00036 #ifndef _TopoDS_Iterator_HeaderFile
00037 #include <TopoDS_Iterator.hxx>
00038 #endif
00039 #ifndef _exotkUtils_BRep_HeaderFile
00040 #include <exotkUtils_BRep.hxx>
00041 #endif
00042 #ifndef _TopTools_IndexedMapOfShape_HeaderFile
00043 #include <TopTools_IndexedMapOfShape.hxx>
00044 #endif
00045 #ifndef _BRep_Tool_HeaderFile
00046 #include <BRep_Tool.hxx>
00047 #endif
00048 #ifndef _exotkUtils_Geom_HeaderFile
00049 #include <exotkUtils_Geom.hxx>
00050 #endif
00051 #ifndef _TopoDS_HeaderFile
00052 #include <TopoDS.hxx>
00053 #endif
00054
00055 namespace exotkBRepTree_Datas
00056 {
00057 TopTools_IndexedMapOfShape theShapeMap;
00058 }
00059 Handle_exotkBRepTree_ShapeNode exotkBRepTree::ComputeTopNode(const TopoDS_Shape &aShape,const TCollection_AsciiString& aName)
00060 {
00061 exotkBRepTree_Datas::theShapeMap.Clear();
00062 Handle_exotkBRepTree_ShapeNode theTopNode = BuildRec(aShape);
00063 Handle_exotkBRepTree_ShapeNode theShapeNode = new exotkBRepTree_ShapeNode();
00064 theShapeNode->AppendChild(theTopNode);
00065 theShapeNode->SetName(aName);
00066 return theShapeNode;
00067 }
00068
00069 Handle_exotkBRepTree_ShapeNode exotkBRepTree::BuildRec(const TopoDS_Shape &aShape)
00070 {
00071 Handle_exotkBRepTree_ShapeNode theNode;
00072 if ( !aShape.IsNull() )
00073 {
00074 theNode = new exotkBRepTree_ShapeNode();
00075 theNode->SetShape(aShape);
00076
00077 TCollection_AsciiString theName;
00078 TopAbs_ShapeEnum theShapeType = aShape.ShapeType();
00079 if ( theShapeType == TopAbs_FACE )
00080 {
00081 Handle_Geom_Surface theSurface = BRep_Tool::Surface( TopoDS::Face(aShape) );
00082 theName = exotkUtils_Geom::NameFromSurfaceType(theSurface);
00083 theName += " ";
00084 }
00085 else if (theShapeType == TopAbs_EDGE)
00086 {
00087 Standard_Real dummy1,dummy2;
00088 Handle_Geom_Curve theCurve = BRep_Tool::Curve(TopoDS::Edge(aShape),dummy1,dummy2);
00089 theName = exotkUtils_Geom::NameFromCurveType(theCurve);
00090 theName += " ";
00091 }
00092 theName += exotkUtils_BRep::NameFromShapeType(aShape);
00093 Standard_Integer theIndex = exotkBRepTree_Datas::theShapeMap.Add(aShape);
00094 theName += TCollection_AsciiString(" #") + TCollection_AsciiString(theIndex);
00095 theNode->SetName(theName);
00096 for ( TopoDS_Iterator theShapeIter( aShape );theShapeIter.More(); theShapeIter.Next() )
00097 {
00098 Handle_exotkBRepTree_ShapeNode theCurrentNode = BuildRec( theShapeIter.Value() );
00099 theNode->AppendChild(theCurrentNode);
00100 }
00101 }
00102 return theNode;
00103 }