-// Copyright (C) 2005 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 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.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// 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.
+//
+// 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
//
-
#include <Standard_Stream.hxx>
#include <GEOMImpl_LineDriver.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
-
+#include <BRepAlgoAPI_Section.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_MapOfShape.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
TopoDS_Shape aShape1 = aRefPnt1->GetValue();
TopoDS_Shape aShape2 = aRefPnt2->GetValue();
if (aShape1.ShapeType() != TopAbs_VERTEX ||
- aShape2.ShapeType() != TopAbs_VERTEX) return 0;
+ aShape2.ShapeType() != TopAbs_VERTEX) {
+ Standard_ConstructionError::Raise("Wrong arguments: two points must be given");
+ }
if (aShape1.IsSame(aShape2)) {
Standard_ConstructionError::Raise("The end points must be different");
}
}
aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape();
+ } else if (aType == LINE_TWO_FACES) {
+ Handle(GEOM_Function) aRefFace1 = aPI.GetFace1();
+ Handle(GEOM_Function) aRefFace2 = aPI.GetFace2();
+ TopoDS_Shape aShape1 = aRefFace1->GetValue();
+ TopoDS_Shape aShape2 = aRefFace2->GetValue();
+ if (aShape1.ShapeType() != TopAbs_FACE ||
+ aShape2.ShapeType() != TopAbs_FACE) {
+ Standard_ConstructionError::Raise("Wrong arguments: two faces must be given");
+ }
+ if (aShape1.IsSame(aShape2)) {
+ Standard_ConstructionError::Raise("The end faces must be different");
+ }
+ BRepAlgoAPI_Section E (aShape1, aShape2, Standard_False);
+ E.Approximation(Standard_True);
+ E.Build();
+ if (!E.IsDone()) {
+ Standard_ConstructionError::Raise("Line can not be performed on the given faces");
+ }
+ else
+ {
+ TopExp_Explorer Exp (E, TopAbs_EDGE);
+ if ( Exp.More() ){
+ aShape = Exp.Current();
+ Exp.Next();
+ }
+ else
+ {
+ Standard_ConstructionError::Raise("Faces not have intersection line");
+ aShape = E.Shape();
+ }
+ if ( Exp.More() )
+ aShape = E.Shape();
+ }
+
} else if (aType == LINE_PNT_DIR) {
Handle(GEOM_Function) aRefPnt = aPI.GetPoint1();
Handle(GEOM_Function) aRefDir = aPI.GetPoint2();
TopoDS_Shape aShape1 = aRefPnt->GetValue();
TopoDS_Shape aShape2 = aRefDir->GetValue();
- if (aShape1.ShapeType() != TopAbs_VERTEX ||
- aShape2.ShapeType() != TopAbs_EDGE) return 0;
+ if (aShape1.ShapeType() != TopAbs_VERTEX) {
+ Standard_ConstructionError::Raise("Wrong first argument: must be point");
+ }
+ if (aShape2.ShapeType() != TopAbs_EDGE) {
+ Standard_ConstructionError::Raise("Wrong second argument: must be vector");
+ }
if (aShape1.IsSame(aShape2)) {
Standard_ConstructionError::Raise("The end points must be different");
}
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_LineDriver",
- sizeof(GEOMImpl_LineDriver),
- 1,
- (Standard_Address)_Ancestors,
- (Standard_Address)NULL);
+ sizeof(GEOMImpl_LineDriver),
+ 1,
+ (Standard_Address)_Ancestors,
+ (Standard_Address)NULL);
return _aType;
}