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

exotkBRepTree.cxx

Go to the documentation of this file.
00001 
00002 //   exotkBRepTree.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 <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 //              theNode->SetName(exotkUtils_BRep::NameFromShapeType(aShape));
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 }

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