-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
// File: BlockFix_UnionEdges.cxx
// Created: 07.12.04 15:27:30
// Author: Sergey KUUL
Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2);
gp_Dir Dir1 = L1->Position().Direction();
gp_Dir Dir2 = L2->Position().Direction();
- if(!Dir1.IsEqual(Dir2,Precision::Angular())) continue;
+ //if(!Dir1.IsEqual(Dir2,Precision::Angular())) {
+ //if(!Dir1.IsParallel(Dir2,Precision::Angular())) {
+ if(!Dir1.IsParallel(Dir2,Tol)) {
+ continue;
+ }
// can union lines => create new edge
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
gp_Pnt PV1 = BRep_Tool::Pnt(V1);
B.Add (E,V1); B.Add (E,V2);
B.UpdateVertex(V1, 0., E, 0.);
B.UpdateVertex(V2, dist, E, 0.);
- ShapeFix_Edge sfe;
- sfe.FixAddPCurve(E,aFace,Standard_False);
- sfe.FixSameParameter(E);
+ //ShapeFix_Edge sfe;
+ //sfe.FixAddPCurve(E,aFace,Standard_False);
+ //sfe.FixSameParameter(E);
aChain.Remove(j);
aChain.SetValue(j,E);
j--;
gp_Dir D1(gp_Vec(P0,PV1));
gp_Dir D2(gp_Vec(P0,PV2));
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
+ if(fabs(fpar)>Precision::Confusion()) {
+ // check orientation
+ gp_Dir ND = C->XAxis().Direction().Crossed(D1);
+ if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
+ fpar = -fpar;
+ }
+ }
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
+ if(fabs(lpar)>Precision::Confusion()) {
+ // check orientation
+ gp_Dir ND = C->XAxis().Direction().Crossed(D2);
+ if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
+ lpar = -lpar;
+ }
+ }
+ if (lpar < fpar) lpar += 2*M_PI;
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
B.MakeEdge (E,tc,Precision::Confusion());
B.Add(E,V1);
B.UpdateVertex(V1, fpar, E, 0.);
B.UpdateVertex(V2, lpar, E, 0.);
}
- ShapeFix_Edge sfe;
- sfe.FixAddPCurve(E,aFace,Standard_False);
- sfe.FixSameParameter(E);
aChain.Remove(j);
aChain.SetValue(j,E);
j--;
TopoDS_Shape aResult = myContext->Apply(Shape);
// processing each solid
- TopExp_Explorer exps;
- for(exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
- TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
+ TopAbs_ShapeEnum aType = TopAbs_SOLID;
+ TopExp_Explorer exps (Shape, aType);
+ if (!exps.More()) {
+ aType = TopAbs_SHELL;
+ exps.Init(Shape, aType);
+ }
+ for (; exps.More(); exps.Next()) {
+ //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
+ TopoDS_Shape aSolid = exps.Current();
TopTools_IndexedMapOfShape ChangedFaces;
// processing each face
TopExp_Explorer exp;
- for(exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) {
+ for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) {
TopoDS_Face aFace =
TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD)));
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
- for(TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
+ for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
- if(!aMapEdgeFaces.Contains(edge)) continue;
+ if (!aMapEdgeFaces.Contains(edge)) continue;
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter(aList);
- for( ; anIter.More(); anIter.Next()) {
+ for ( ; anIter.More(); anIter.Next()) {
TopoDS_Face face = TopoDS::Face(anIter.Value());
TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value()));
- if(face1.IsSame(aFace)) continue;
- if(aMapFacesEdges.Contains(face)) {
+ if (face1.IsSame(aFace)) continue;
+ if (aMapFacesEdges.Contains(face)) {
aMapFacesEdges.ChangeFromKey(face).Append(edge);
}
else {
}
}
- for(Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) {
+ for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) {
const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
TopTools_SequenceOfShape SeqEdges;
TopTools_ListIteratorOfListOfShape anIter(ListEdges);
- for( ; anIter.More(); anIter.Next()) {
+ for ( ; anIter.More(); anIter.Next()) {
SeqEdges.Append(anIter.Value());
}
- if(SeqEdges.Length()==1) continue;
+ if (SeqEdges.Length()==1) continue;
TopoDS_Edge E;
- if( MergeEdges(SeqEdges,aFace,Tol,E) ) {
+ if ( MergeEdges(SeqEdges,aFace,Tol,E) ) {
// now we have only one edge - aChain.Value(1)
// we have to replace old ListEdges with this new edge
aContext->Replace(SeqEdges(1),E);
- for(Standard_Integer j=2; j<=SeqEdges.Length(); j++) {
+ for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) {
aContext->Remove(SeqEdges(j));
}
TopoDS_Face tmpF = TopoDS::Face(exp.Current());
- if( !ChangedFaces.Contains(tmpF) )
+ if ( !ChangedFaces.Contains(tmpF) )
ChangedFaces.Add(tmpF);
tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i));
- if( !ChangedFaces.Contains(tmpF) )
+ if ( !ChangedFaces.Contains(tmpF) )
ChangedFaces.Add(tmpF);
}
}
} // end processing each face
// fix changed faces and replace them in the local context
- for(Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) {
+ for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) {
TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i)));
Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace);
sff->SetContext(myContext);
aContext->Replace(aFace,sff->Face());
}
- if(ChangedFaces.Extent()>0) {
+ if (ChangedFaces.Extent() > 0) {
// fix changed shell and replace it in the local context
TopoDS_Shape aRes1 = aContext->Apply(aRes);
TopExp_Explorer expsh;
- for(expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) {
+ for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) {
TopoDS_Shell aShell = TopoDS::Shell(expsh.Current());
Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell;
sfsh->FixFaceOrientation(aShell);