From: dbv Date: Tue, 6 Sep 2016 09:36:28 +0000 (+0300) Subject: Fix for naming in Build features. X-Git-Tag: V_2.5.0~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=42de443bf267cba7278df5dd4ae8a5f19612bd25;p=modules%2Fshaper.git Fix for naming in Build features. --- diff --git a/src/BuildPlugin/BuildPlugin_Edge.cpp b/src/BuildPlugin/BuildPlugin_Edge.cpp index df60a8715..b78100d15 100644 --- a/src/BuildPlugin/BuildPlugin_Edge.cpp +++ b/src/BuildPlugin/BuildPlugin_Edge.cpp @@ -9,6 +9,8 @@ #include #include +#include + //================================================================================================= BuildPlugin_Edge::BuildPlugin_Edge() { @@ -59,9 +61,36 @@ void BuildPlugin_Edge::execute() return; } + // Copy shape. + GeomAlgoAPI_Copy aCopyAlgo(aShape); + + // Check that algo is done. + if(!aCopyAlgo.isDone()) { + setError("Error: " + getKind() + " algorithm failed."); + return; + } + + // Check if shape is not null. + if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { + setError("Error: Resulting shape is null."); + return; + } + + // Check that resulting shape is valid. + if(!aCopyAlgo.isValid()) { + setError("Error: Resulting shape is not valid."); + return; + } + // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->store(aShape); + aResultBody->storeModified(aShape, aCopyAlgo.shape()); + std::shared_ptr aSubShapes = aCopyAlgo.mapOfSubShapes(); + int aModVertexTag = 1; + std::string aModVertexName = "Modified_Vertex"; + aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, + aModVertexTag, aModVertexName, *aSubShapes.get()); + setResult(aResultBody, aResultIndex); ++aResultIndex; } diff --git a/src/BuildPlugin/BuildPlugin_Vertex.cpp b/src/BuildPlugin/BuildPlugin_Vertex.cpp index d70bcc497..9ba785754 100644 --- a/src/BuildPlugin/BuildPlugin_Vertex.cpp +++ b/src/BuildPlugin/BuildPlugin_Vertex.cpp @@ -9,6 +9,8 @@ #include #include +#include + //================================================================================================= BuildPlugin_Vertex::BuildPlugin_Vertex() { @@ -59,9 +61,30 @@ void BuildPlugin_Vertex::execute() return; } + // Copy shape. + GeomAlgoAPI_Copy aCopyAlgo(aShape); + + // Check that algo is done. + if(!aCopyAlgo.isDone()) { + setError("Error: " + getKind() + " algorithm failed."); + return; + } + + // Check if shape is not null. + if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { + setError("Error: Resulting shape is null."); + return; + } + + // Check that resulting shape is valid. + if(!aCopyAlgo.isValid()) { + setError("Error: Resulting shape is not valid."); + return; + } + // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->store(aShape); + aResultBody->storeModified(aShape, aCopyAlgo.shape()); setResult(aResultBody, aResultIndex); ++aResultIndex; } diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index bb0ce3fe4..c4ff34d4d 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -45,6 +45,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_BoxPoints.h GeomAlgoAPI_XAOExport.h GeomAlgoAPI_XAOImport.h + GeomAlgoAPI_Copy.h ) SET(PROJECT_SOURCES @@ -86,6 +87,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_BoxPoints.cpp GeomAlgoAPI_XAOExport.cpp GeomAlgoAPI_XAOImport.cpp + GeomAlgoAPI_Copy.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i index 762d6b44f..7e6272505 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@ -35,6 +35,7 @@ %shared_ptr(GeomAlgoAPI_Transform) %shared_ptr(GeomAlgoAPI_Box) %shared_ptr(GeomAlgoAPI_BoxPoints) +%shared_ptr(GeomAlgoAPI_Copy) // all supported interfaces %include "GeomAlgoAPI_MakeShape.h" @@ -70,6 +71,7 @@ %include "GeomAlgoAPI_ShapeBuilder.h" %include "GeomAlgoAPI_Exception.h" %include "GeomAlgoAPI_ShapeAPI.h" +%include "GeomAlgoAPI_Copy.h" %typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(*$1)), $descriptor(std::shared_ptr *), SWIG_POINTER_OWN | 0 ); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp new file mode 100644 index 000000000..68f682df9 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_Copy.cpp +// Created: 06 Sept 2016 +// Author: Dmitry Bobylev + +#include "GeomAlgoAPI_Copy.h" + + +#include + +//================================================================================================= +GeomAlgoAPI_Copy::GeomAlgoAPI_Copy(const std::shared_ptr theShape, + const bool theCopyGeom, + const bool theCopyMesh) +{ + build(theShape, theCopyGeom, theCopyMesh); +} + + +//================================================================================================= +void GeomAlgoAPI_Copy::build(const std::shared_ptr theShape, + const bool theCopyGeom, + const bool theCopyMesh) +{ + if(!theShape.get()) { + return; + } + + // Getting shape. + const TopoDS_Shape& aBaseShape = theShape->impl(); + + // Creating copy. + BRepBuilderAPI_Copy* aBuilder = new BRepBuilderAPI_Copy(aBaseShape, theCopyGeom, theCopyMesh); + this->setImpl(aBuilder); + this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape); + + TopoDS_Shape aResult = aBuilder->Shape(); + + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aShape); + this->setDone(true); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Copy.h b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.h new file mode 100644 index 000000000..66e5aadc7 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.h @@ -0,0 +1,34 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_Copy.h +// Created: 06 Sept 2016 +// Author: Dmitry Bobylev + +#ifndef GeomAlgoAPI_Copy_H_ +#define GeomAlgoAPI_Copy_H_ + +#include +#include + +#include + +/// \class GeomAlgoAPI_Copy +/// \ingroup DataAlgo +/// \brief Duplication of a shape. +class GeomAlgoAPI_Copy : public GeomAlgoAPI_MakeShape +{ +public: + + /// Constructor. + GEOMALGOAPI_EXPORT GeomAlgoAPI_Copy(const std::shared_ptr theShape, + const bool theCopyGeom = true, + const bool theCopyMesh = false); + +private: + /// Builds resulting shape. + void build(const std::shared_ptr theShape, + const bool theCopyGeom = true, + const bool theCopyMesh = false); +}; + +#endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp index fa9e808bf..14b3bcb38 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp @@ -157,6 +157,11 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theSha } const TopoDS_Shape& aTopoDSShape = myShape->impl(); + for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) { + std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); + myMap->bind(aCurrentShape, aCurrentShape); + } for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) { std::shared_ptr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_swig.h b/src/GeomAlgoAPI/GeomAlgoAPI_swig.h index 668a5d1b0..39468c701 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_swig.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_swig.h @@ -40,11 +40,12 @@ #include "GeomAlgoAPI_Pipe.h" #include "GeomAlgoAPI_WireBuilder.h" #include "GeomAlgoAPI_Sewing.h" - #include "GeomAlgoAPI_ShapeBuilder.h" + #include "GeomAlgoAPI_ShapeBuilder.h" #include "GeomAlgoAPI_Exception.h" #include "GeomAlgoAPI_ShapeAPI.h" #include "GeomAlgoAPI_Box.h" #include "GeomAlgoAPI_BoxPoints.h" + #include "GeomAlgoAPI_Copy.h" #include #include