// Created on: 1993-06-17 // Created by: Jean Yves LEBEY // Copyright (c) 1993-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #ifdef DRAW #include #include #include #include #include #include static TCollection_AsciiString PRODINS("dins "); #endif #ifdef OCCT_DEBUG extern Standard_Boolean TopOpeBRepBuild_GettraceCHK(); extern Standard_Boolean TopOpeBRepBuild_GettraceCHKOK(); extern Standard_Boolean TopOpeBRepBuild_GettraceCHKNOK(); Standard_EXPORT void debaddss(){} Standard_IMPORT TopOpeBRepBuild_Builder* LOCAL_PBUILDER_DEB; #endif //======================================================================= //function : TopOpeBRepBuild_ShapeSet //purpose : //======================================================================= TopOpeBRepBuild_ShapeSet::TopOpeBRepBuild_ShapeSet(const TopAbs_ShapeEnum SubShapeType,const Standard_Boolean checkshape) : mySubShapeType(SubShapeType), myCheckShape(checkshape) { if (SubShapeType == TopAbs_EDGE) myShapeType = TopAbs_FACE; else if (SubShapeType == TopAbs_VERTEX) myShapeType = TopAbs_EDGE; else Standard_ProgramError::Raise("ShapeSet : bad ShapeType"); myDEBNumber = 0; myCheckShape = Standard_False; // temporary NYI } TopOpeBRepBuild_ShapeSet::~TopOpeBRepBuild_ShapeSet() {} //======================================================================= //function : AddShape //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::AddShape(const TopoDS_Shape& S) { Standard_Boolean chk = CheckShape(S); #ifdef OCCT_DEBUG DumpCheck(cout," AddShape",S,chk); #endif if (!chk) return; ProcessAddShape(S); } //======================================================================= //function : AddStartElement //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::AddStartElement(const TopoDS_Shape& S) { Standard_Boolean chk = CheckShape(S); #ifdef OCCT_DEBUG DumpCheck(cout," AddStartElement",S,chk); #endif if (!chk) return; ProcessAddStartElement(S); } //======================================================================= //function : AddElement //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::AddElement(const TopoDS_Shape& S) { Standard_Boolean chk = CheckShape(S); #ifdef OCCT_DEBUG DumpCheck(cout," AddElement",S,chk); #endif if (!chk) return; ProcessAddElement(S); } //======================================================================= //function : ProcessAddShape //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::ProcessAddShape(const TopoDS_Shape& S) { if ( !myOMSH.Contains(S) ) { myOMSH.Add(S); myShapes.Append(S); } } //======================================================================= //function : ProcessStartElement //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::ProcessAddStartElement(const TopoDS_Shape& S) { if ( !myOMSS.Contains(S) ) { myOMSS.Add(S); myStartShapes.Append(S); ProcessAddElement(S); } } //======================================================================= //function : ProcessAddElement //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::ProcessAddElement(const TopoDS_Shape& S) { if ( !myOMES.Contains(S) ) { myOMES.Add(S); TopTools_ListOfShape Lemp; TopOpeBRepTool_ShapeExplorer Ex(S,mySubShapeType); for (; Ex.More(); Ex.Next()) { const TopoDS_Shape& subshape = Ex.Current(); Standard_Boolean b = ( ! mySubShapeMap.Contains(subshape) ); if ( b ) mySubShapeMap.Add(subshape,Lemp); mySubShapeMap.ChangeFromKey(subshape).Append(S); } } } //======================================================================= //function : StartElements //purpose : //======================================================================= const TopTools_ListOfShape& TopOpeBRepBuild_ShapeSet::StartElements()const { return myStartShapes; } //======================================================================= //function : InitShapes //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::InitShapes() { myShapesIter.Initialize(myShapes); } //======================================================================= //function : MoreShapes //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreShapes()const { Standard_Boolean b = myShapesIter.More(); return b; } //======================================================================= //function : NextShape //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::NextShape() { myShapesIter.Next(); } //======================================================================= //function : Shape //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::Shape()const { const TopoDS_Shape& S = myShapesIter.Value(); return S; } //======================================================================= //function : InitStartElements //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::InitStartElements() { myStartShapesIter.Initialize(myStartShapes); } //======================================================================= //function : MoreStartElements //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreStartElements()const { Standard_Boolean b = myStartShapesIter.More(); return b; } //======================================================================= //function : NextStartElement //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::NextStartElement() { myStartShapesIter.Next(); } //======================================================================= //function : StartElement //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::StartElement()const { const TopoDS_Shape& S = myStartShapesIter.Value(); return S; } //======================================================================= //function : InitNeighbours //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::InitNeighbours(const TopoDS_Shape& S) { mySubShapeExplorer.Init(S,mySubShapeType); myCurrentShape = S; FindNeighbours(); } //======================================================================= //function : MoreNeighbours //purpose : //======================================================================= Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreNeighbours() { Standard_Boolean b = myIncidentShapesIter.More(); return b; } //======================================================================= //function : NextNeighbour //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::NextNeighbour() { myIncidentShapesIter.Next(); Standard_Boolean noisimore = ! myIncidentShapesIter.More(); if ( noisimore ) { Standard_Boolean ssemore = mySubShapeExplorer.More(); if ( ssemore ) { mySubShapeExplorer.Next(); FindNeighbours(); } } } //======================================================================= //function : Neighbour //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::Neighbour()const { const TopoDS_Shape& S = myIncidentShapesIter.Value(); return S; } //======================================================================= //function : ChangeStartShapes //purpose : //======================================================================= TopTools_ListOfShape& TopOpeBRepBuild_ShapeSet::ChangeStartShapes() { return myStartShapes; } //======================================================================= //function : FindNeighbours //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::FindNeighbours() { while (mySubShapeExplorer.More()) { // l = list of edges neighbour of edge myCurrentShape trough // the vertex mySubShapeExplorer.Current(), which is a vertex of the // edge myCurrentShape. const TopoDS_Shape& V = mySubShapeExplorer.Current(); const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V); // myIncidentShapesIter iterates on the neighbour edges of the edge // given as InitNeighbours() argument (this edge has been stored // in the field myCurrentShape). myIncidentShapesIter.Initialize(l); if (myIncidentShapesIter.More()) break; else mySubShapeExplorer.Next(); } } //======================================================================= //function : MakeNeighboursList //purpose : // (Earg = Edge, Varg = Vertex) to find connected to Earg by Varg //======================================================================= const TopTools_ListOfShape & TopOpeBRepBuild_ShapeSet::MakeNeighboursList(const TopoDS_Shape& /*Earg*/, const TopoDS_Shape& Varg) { const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg); return l; } //======================================================================= //function : MaxNumberSubShape //purpose : //======================================================================= Standard_Integer TopOpeBRepBuild_ShapeSet::MaxNumberSubShape(const TopoDS_Shape& Shape) { Standard_Integer i, m = 0; TopOpeBRepTool_ShapeExplorer SE(Shape, mySubShapeType); TopTools_ListIteratorOfListOfShape LI; while(SE.More()) { const TopoDS_Shape& SubShape = SE.Current(); if(!mySubShapeMap.Contains(SubShape)) { SE.Next(); continue; } const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(SubShape); LI.Initialize(l); for(i = 0;LI.More();LI.Next(), i++) {} m = Max(m, i); SE.Next(); } return m; } //======================================================================= //function : CheckShape //purpose : //======================================================================= void TopOpeBRepBuild_ShapeSet::CheckShape(const Standard_Boolean checkshape) { myCheckShape = checkshape; #ifdef OCCT_DEBUG if (TopOpeBRepBuild_GettraceCHK() && !myCheckShape) { DumpName(cout,"no checkshape set on ");cout< curr) { cout<<"#Block number"< currloc) { currloc++;ne++; // to know if ste or ele is displayed; start const TopTools_ListOfShape& LSE = StartElements(); it.Initialize(LSE); while(it.More()) if(it.Value() == N) break; else it.Next(); enam = ""; if(it.More()) { enam = enam+"ste"+ne+"newB"+nb; // name = enam.ToCString(); // Handle(TestTopOpeDraw_DrawableSHA) Dloc = // new TestTopOpeDraw_DrawableSHA // (N, Draw_blanc, Draw_blanc, Draw_blanc, Draw_blanc, // 100., 2, 30, name, Draw_blanc); // Draw::Set(name,Dloc); DBRep::Set(enam.ToCString(),N); // cout<