// 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_SplitCommonVertex,ShapeFix_Root) //======================================================================= //function : ShapeFix_SplitCommonVertex //purpose : //======================================================================= ShapeFix_SplitCommonVertex::ShapeFix_SplitCommonVertex() { myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK ); SetPrecision(Precision::Confusion()); } //======================================================================= //function : Init //purpose : //======================================================================= void ShapeFix_SplitCommonVertex::Init(const TopoDS_Shape& S) { myShape = S; if ( Context().IsNull() ) SetContext ( new ShapeBuild_ReShape ); myResult = myShape; Context()->Apply(myShape); } //======================================================================= //function : Perform //purpose : //======================================================================= void ShapeFix_SplitCommonVertex::Perform() { TopAbs_ShapeEnum st = myShape.ShapeType(); if(st>TopAbs_FACE) return; for(TopExp_Explorer itf(myShape,TopAbs_FACE); itf.More(); itf.Next()) { TopoDS_Shape tmpFace = Context()->Apply(itf.Current()); TopoDS_Face F = TopoDS::Face(tmpFace); if(F.IsNull()) continue; // analys face and split if necessary TopTools_SequenceOfShape wires; for(TopoDS_Iterator itw(F,Standard_False); itw.More(); itw.Next()) { if(itw.Value().ShapeType() != TopAbs_WIRE) continue; wires.Append(itw.Value()); } if(wires.Length()<2) continue; TopTools_DataMapOfShapeShape MapVV; MapVV.Clear(); for(Standard_Integer nw1=1; nw1NbEdges(); ne2++) { TopoDS_Edge E = sewd2->Edge(ne2); TopoDS_Vertex FV = sae.FirstVertex(E); TopoDS_Vertex LV = sae.LastVertex(E); Standard_Boolean IsCoinc = Standard_False; if(FV==V2) { FV=Vnew; IsCoinc = Standard_True; } if(LV==V2) { LV=Vnew; IsCoinc = Standard_True; } if(IsCoinc) { TopoDS_Edge NewE = sbe.CopyReplaceVertices(E,FV,LV); Context()->Replace(E,NewE); } } } } } } } if ( !MapVV.IsEmpty() ) SendWarning( Message_Msg( "Fix.SplitCommonVertex.MSG0" )); } myShape = Context()->Apply(myShape); } //======================================================================= //function : Shape //purpose : //======================================================================= TopoDS_Shape ShapeFix_SplitCommonVertex::Shape() { return myShape; }