From 87ceb14207c74f7ae5157b9048e439e7c5cd2dc6 Mon Sep 17 00:00:00 2001 From: rnc Date: Mon, 5 Mar 2012 15:33:17 +0000 Subject: [PATCH] small modifications --- src/GEOMImpl/GEOMImpl_PrismDriver.cxx | 118 ++++++++++++-------------- 1 file changed, 56 insertions(+), 62 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index eabed5f25..200ecd8e3 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -203,82 +203,76 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const for(;anExp.More();anExp.Next()) { solidCount++; + if (solidCount > 1) + Standard_ConstructionError::Raise("The input shape is a compound with more than one solid"); } if (solidCount == 0) - { Standard_ConstructionError::Raise("The input shape is a compound without any solid"); - } - else if (solidCount > 1) - { - Standard_ConstructionError::Raise("The input shape is a compound with more than one solid"); - } } - - TopoDS_Face aFaceBase; - if (aSketch.ShapeType() == TopAbs_FACE) +// if (aSketch.ShapeType() == TopAbs_FACE) +// { +// aFaceBase = TopoDS::Face(aSketch); +// } +// else +// { + TopoDS_Wire aWire = TopoDS_Wire(); + + if (aSketch.ShapeType() == TopAbs_EDGE) { - aFaceBase = TopoDS::Face(aSketch); + aWire = BRepBuilderAPI_MakeWire(TopoDS::Edge(aSketch)); + } + else if (aSketch.ShapeType() == TopAbs_WIRE) + { + aWire = TopoDS::Wire(aSketch); } else { - TopoDS_Wire aWire = TopoDS_Wire(); + Standard_ConstructionError::Raise("The input profile is neither a wire, nor edge"); + } + + TopoDS_Vertex aV1, aV2; + TopExp::Vertices(aWire, aV1, aV2); + if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) ) + aWire.Closed( true ); + + if (!aWire.Closed()) + Standard_ConstructionError::Raise("The input profile is not closed"); - if (aSketch.ShapeType() == TopAbs_EDGE) - { - aWire = BRepBuilderAPI_MakeWire(TopoDS::Edge(aSketch)); - } - else if (aSketch.ShapeType() == TopAbs_WIRE) - { - aWire = TopoDS::Wire(aSketch); - } - else + // history of the Base wire (RefBase) + Handle(GEOM_Object) aSuppObj; + TDF_LabelSequence aLabelSeq; + aRefBase->GetDependency(aLabelSeq); + + // If the base wire has only one dependency we use it + // to determine the right normal of the face which + // must be oriented towards outside of the solid (like the support face) + if (aLabelSeq.Length()==1) + { + TDF_Label anArgumentRefLabel = aLabelSeq.Value(1); + aSuppObj = GEOM_Object::GetReferencedObject(anArgumentRefLabel); + } + + // Construction of the face if the wire hasn't any support face + TopoDS_Face aFaceBase = BRepBuilderAPI_MakeFace(aWire); + + if(!aSuppObj.IsNull()) // If the wire has a support + { + TopoDS_Shape aSupport = aSuppObj->GetValue(); + if (aSupport.ShapeType() == TopAbs_FACE) { - Standard_ConstructionError::Raise("The input sketch is not a wire, an edge or a face"); - } - - TopoDS_Vertex aV1, aV2; - TopExp::Vertices(aWire, aV1, aV2); - if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) ) - aWire.Closed( true ); - - if (!aWire.Closed()) - Standard_ConstructionError::Raise("The edge or wire is not closed"); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aSupport)); + TopoDS_Face aTempFace = BRepBuilderAPI_MakeFace(aSurf, aWire); - // history of the Base wire (RefBase) - Handle(GEOM_Object) aSuppObj; - TDF_LabelSequence aLabelSeq; - aRefBase->GetDependency(aLabelSeq); - - // If the base wire has only one dependency we use it - // to determine the right normal of the face which - // must be oriented towards outside of the solid (like the support face) - if (aLabelSeq.Length()==1) - { - TDF_Label anArgumentRefLabel = aLabelSeq.Value(1); - aSuppObj = GEOM_Object::GetReferencedObject(anArgumentRefLabel); - } - - // Construction of the face if the wire hasn't any support face - aFaceBase = BRepBuilderAPI_MakeFace(aWire); - - if(!aSuppObj.IsNull()) // If the wire has a support - { - TopoDS_Shape aSupport = aSuppObj->GetValue(); - if (aSupport.ShapeType() == TopAbs_FACE) + if(aTempFace.Orientation() != TopoDS::Face(aSupport).Orientation()) { - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aSupport)); - TopoDS_Face aTempFace = BRepBuilderAPI_MakeFace(aSurf, aWire); - - if(aTempFace.Orientation() != TopoDS::Face(aSupport).Orientation()) - { - aFaceBase=TopoDS::Face(aTempFace.Reversed()); - } - else - aFaceBase=aTempFace; + aFaceBase=TopoDS::Face(aTempFace.Reversed()); } - } - } + else + aFaceBase=aTempFace; + } + } +// } // Invert height and angle if the operation is an extruded cut bool invert = !isProtrusion; -- 2.39.2