# General information about the project.
project = u'SHAPER'
-copyright = u'2014-2017 CEA/DEN, EDF R&D'
+copyright = u'2014-2019 CEA/DEN, EDF R&D'
# Copyright is shown via custom footer
html_show_copyright = False
# built documents.
#
# The short X.Y version.
- version = u'3.0.0'
+ version = u'9.2.0'
# The full version, including alpha/beta/rc tags.
- release = u'3.0.0'
+ release = u'9.2.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_CompSolid.h"
{
data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
}
-
- //=================================================================================================
- void BuildPlugin_CompSolid::execute()
- {
- // all the needed checkings are in validator, so, here just make and store result
- ListOfShape anOriginalShapes;
- AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (!aShape.get())
- aShape = aSelection->context()->shape();
- anOriginalShapes.push_back(aShape);
- }
- std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgo(
- new GeomAlgoAPI_MakeVolume(anOriginalShapes, false));
- GeomShapePtr aVolumeRes = anAlgo->shape();
-
- // check and process result of volume maker
- GeomShapePtr aResShape = getSingleSubshape(aVolumeRes);
- storeResult(anOriginalShapes, aResShape, anAlgo);
- }
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef BuildPlugin_CompSolid_H_
/// Request for initialization of data model of the feature: adding all attributes.
BUILDPLUGIN_EXPORT virtual void initAttributes();
-
- /// Creates a new part document if needed.
- BUILDPLUGIN_EXPORT virtual void execute();
};
#endif
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Compound.h"
int anIndexToRemove = 0;
if (aCopyCompound) {
ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++);
- aResultBody->store(aCopyCompound);
+ aResultBody->storeModified(anOriginalShapes, aCopyCompound, aCopyAlgo);
aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX);
aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::EDGE);
aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::FACE);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Edge.h"
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aShape, aCopyAlgo->shape());
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aShape);
+ aResultBody->storeModified(aBaseShapes, aCopyAlgo->shape(), aCopyAlgo);
aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX);
setResult(aResultBody, aResultIndex);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Face.h"
#include <GeomAPI_Pln.h>
#include <GeomAPI_ShapeExplorer.h>
+ #include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_SketchBuilder.h>
#include <GeomAlgoAPI_Copy.h>
// Collect base shapes.
ListOfShape anEdges;
ListOfShape anOriginalFaces;
+ ListOfShape aContexts;
+ getOriginalShapesAndContexts(BASE_OBJECTS_ID(), anOriginalFaces, aContexts);
+ anOriginalFaces.clear();
std::list< std::shared_ptr<GeomAPI_Dir> > aListOfNormals;
for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
// Build faces by edges.
ListOfShape aFaces;
+ GeomMakeShapePtr aFaceBuilder;
if (!anEdges.empty())
- buildFacesByEdges(anEdges, aListOfNormals, aFaces);
+ buildFacesByEdges(anEdges, aListOfNormals, aFaces, aFaceBuilder);
+ int aNbFacesFromEdges = (int)aFaces.size();
// Add faces selected by user.
aFaces.insert(aFaces.end(), anOriginalFaces.begin(), anOriginalFaces.end());
// Store result.
int anIndex = 0;
for(ListOfShape::const_iterator anIt = aFaces.cbegin(); anIt != aFaces.cend(); ++anIt) {
- ResultBodyPtr aResultBody = document()->createBody(data(), anIndex);
- GeomShapePtr aShape = *anIt;
- GeomAlgoAPI_Copy aCopy(aShape);
- aShape = aCopy.shape();
- aResultBody->store(aShape);
-
- // Store edges.
- int anEdgeIndex = 1;
- for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
- GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex));
- ++anEdgeIndex;
- }
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList);
+ if (anIndex < aNbFacesFromEdges)
+ aMakeShapeList->appendAlgo(aFaceBuilder);
- setResult(aResultBody, anIndex);
- ++anIndex;
+ GeomShapePtr aShape = *anIt;
+ GeomMakeShapePtr aCopy(new GeomAlgoAPI_Copy(aShape));
+ aMakeShapeList->appendAlgo(aCopy);
+
+ ListOfShape aBaseShapes;
+ if (anIndex < aNbFacesFromEdges)
+ aBaseShapes = anEdges;
+ else
+ aBaseShapes.push_back(aShape);
+ storeResult(aMakeShapeList, aBaseShapes, aContexts, aCopy->shape(), anIndex++);
}
removeResults(anIndex);
void BuildPlugin_Face::buildFacesByEdges(
const ListOfShape& theEdges,
const std::list< std::shared_ptr<GeomAPI_Dir> >& theNormals,
- ListOfShape& theFaces) const
+ ListOfShape& theFaces,
+ std::shared_ptr<GeomAlgoAPI_MakeShape>& theBuilderAlgo) const
{
// Get plane.
std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(theEdges);
}
// Get faces.
- GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(),
- aPln->direction(), theEdges, theFaces);
+ std::shared_ptr<GeomAlgoAPI_SketchBuilder> aSketchBuilder(
+ new GeomAlgoAPI_SketchBuilder(aPln, theEdges));
+ theFaces = aSketchBuilder->faces();
+ theBuilderAlgo = aSketchBuilder;
// Get wires from faces.
ListOfShape aWires;
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef BuildPlugin_Face_H_
#define BuildPlugin_Face_H_
#include "BuildPlugin.h"
-
- #include <ModelAPI_Feature.h>
+ #include "BuildPlugin_Shape.h"
class GeomAPI_Dir;
class GeomAPI_Shape;
+ class GeomAlgoAPI_MakeShape;
/// \class BuildPlugin_Face
/// \ingroup Plugins
/// \brief Feature for creation of face from sketch edges or existing wires.
- class BuildPlugin_Face: public ModelAPI_Feature
+ class BuildPlugin_Face: public BuildPlugin_Shape
{
public:
/// Use plugin manager for features creation
/// Create faces basing on the list of edges
void buildFacesByEdges(const std::list< std::shared_ptr<GeomAPI_Shape> >& theEdges,
const std::list< std::shared_ptr<GeomAPI_Dir> >& theNormals,
- std::list< std::shared_ptr<GeomAPI_Shape> >& theFaces) const;
+ std::list< std::shared_ptr<GeomAPI_Shape> >& theFaces,
+ std::shared_ptr<GeomAlgoAPI_MakeShape>& theBuilderAlgo) const;
};
#endif
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Shell.h"
AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
// Collect base shapes.
- ListOfShape aShapes;
- for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if(!aShape.get()) {
- aShape = aSelection->context()->shape();
- }
- aShapes.push_back(aShape);
- }
+ ListOfShape aShapes, aContexts;
+ getOriginalShapesAndContexts(BASE_OBJECTS_ID(), aShapes, aContexts);
// Sew faces.
GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes));
int anIndex = 0;
for(GeomAPI_ShapeExplorer anExp(aResult, GeomAPI_Shape::SHELL); anExp.more(); anExp.next()) {
GeomShapePtr aShell = anExp.current();
- ResultBodyPtr aResultBody = document()->createBody(data(), anIndex);
- aResultBody->store(aShell);
- for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) {
- for (GeomAPI_ShapeExplorer aFaceExp(*anIt, GeomAPI_Shape::FACE);
- aFaceExp.more();
- aFaceExp.next())
- {
- GeomShapePtr aFace = aFaceExp.current();
- ListOfShape aHistory;
- aSewingAlgo->modified(aFace, aHistory);
- for (ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
- aHistoryIt != aHistory.cend();
- ++aHistoryIt)
- {
- GeomShapePtr aHistoryShape = *aHistoryIt;
- if (aShell->isSubShape(aHistoryShape, false)) {
- aResultBody->loadModifiedShapes(aSewingAlgo,
- aFace,
- GeomAPI_Shape::EDGE);
- aResultBody->loadModifiedShapes(aSewingAlgo,
- aFace,
- GeomAPI_Shape::FACE);
- break;
- }
- }
- }
- }
- setResult(aResultBody, anIndex);
- ++anIndex;
+ storeResult(aSewingAlgo, aShapes, aContexts, aShell, anIndex++);
}
removeResults(anIndex);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef BuildPlugin_Shell_H_
#define BuildPlugin_Shell_H_
#include "BuildPlugin.h"
-
- #include <ModelAPI_Feature.h>
+ #include "BuildPlugin_Shape.h"
/// \class BuildPlugin_Shell
/// \ingroup Plugins
/// \brief Feature for creation of shell from faces and shells.
- class BuildPlugin_Shell: public ModelAPI_Feature
+ class BuildPlugin_Shell: public BuildPlugin_Shape
{
public:
/// Use plugin manager for features creation
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Solid.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
+ #include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
#include <GeomAlgoAPI_MakeVolume.h>
void BuildPlugin_Solid::execute()
{
// all the needed checkings are in validator, so, here just make and store result
- ListOfShape anOriginalShapes;
- AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (!aShape.get())
- aShape = aSelection->context()->shape();
- anOriginalShapes.push_back(aShape);
- }
+ ListOfShape anOriginalFaces;
+ ListOfShape anOriginalSolids;
+ getOriginalShapesAndContexts(BASE_OBJECTS_ID(), anOriginalFaces, anOriginalSolids);
+
std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgo(
- new GeomAlgoAPI_MakeVolume(anOriginalShapes, false));
+ new GeomAlgoAPI_MakeVolume(anOriginalFaces, false));
// check and process result of volume maker
GeomShapePtr aResShape = getSingleSubshape(anAlgo->shape());
- storeResult(anOriginalShapes, aResShape, anAlgo);
- }
-
- void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
- const GeomShapePtr& theResultShape,
- const GeomMakeShapePtr& theAlgorithm)
- {
- ResultBodyPtr aResultBody = document()->createBody(data());
- aResultBody->store(theResultShape);
-
- // Store faces
- for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
- anIt != theOriginalShapes.cend();
- ++anIt)
- {
- GeomShapePtr aShape = *anIt;
- aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE);
- }
- setResult(aResultBody);
+ storeResult(anAlgo, anOriginalFaces, anOriginalSolids, aResShape);
}
GeomShapePtr BuildPlugin_Solid::getSingleSubshape(const GeomShapePtr& theCompound)
-// Copyright (C) 2017-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef BuildPlugin_Solid_H_
#define BuildPlugin_Solid_H_
#include "BuildPlugin.h"
-
- #include <GeomAPI_Shape.h>
- #include <ModelAPI_Feature.h>
-
- class GeomAlgoAPI_MakeShape;
+ #include "BuildPlugin_Shape.h"
/// \class BuildPlugin_Solid
/// \ingroup Plugins
/// \brief Feature for creation of solid from faces or shells.
- class BuildPlugin_Solid: public ModelAPI_Feature
+ class BuildPlugin_Solid: public BuildPlugin_Shape
{
public:
/// Use plugin manager for features creation
BUILDPLUGIN_EXPORT virtual void execute();
protected:
- /// Store result of algorithm
- void storeResult(const ListOfShape& theOriginalShapes,
- const GeomShapePtr& theResultShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
/// Explode compound to get single shape
GeomShapePtr getSingleSubshape(const GeomShapePtr& theCompound);
};
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "BuildPlugin_Validators.h"
}
// Check that selected objects have closed contours.
- ListOfShape aFaces;
- GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(),
- aPln->direction(), anEdges, aFaces);
+ GeomAlgoAPI_SketchBuilder aBuilder(aPln, anEdges);
+ const ListOfShape& aFaces = aBuilder.faces();
if(aFaces.empty()) {
theError = "Selected objects do not generate closed contour.";
return false;
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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(Common)
INCLUDE(UnitTest)
SET(PROJECT_HEADERS
BuildPlugin.h
BuildPlugin_Plugin.h
+ BuildPlugin_Shape.h
BuildPlugin_Vertex.h
BuildPlugin_Edge.h
BuildPlugin_Wire.h
SET(PROJECT_SOURCES
BuildPlugin_Plugin.cpp
+ BuildPlugin_Shape.cpp
BuildPlugin_Vertex.cpp
BuildPlugin_Edge.cpp
BuildPlugin_Wire.cpp
TestCompSolid.py
TestCompound.py
TestCompound_ErrorMsg.py
+ TestCompound_History.py
TestSubShapes.py
TestSubShapes_ErrorMsg.py
TestFilling.py
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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(Common)
INCLUDE(UnitTest)
CollectionPlugin_Field.h
CollectionPlugin_WidgetCreator.h
CollectionPlugin_WidgetField.h
- CollectionPlugin_Validators.h
+ CollectionPlugin_Validators.h
)
SET(PROJECT_MOC_HEADERS
CollectionPlugin_Field.cpp
CollectionPlugin_WidgetCreator.cpp
CollectionPlugin_WidgetField.cpp
- CollectionPlugin_Validators.cpp
+ CollectionPlugin_Validators.cpp
)
SET(XML_RESOURCES
TestGroup2.py
TestField.py
TestGroup1799.py
- TestGroupMove.py
- TestGroupMove2.py
- TestGroupMove3.py
+ TestGroupMove01.py
+ TestGroupMove02.py
+ TestGroupMove03.py
+ TestGroupMove04.py
+ TestGroupMove05.py
+ TestGroupMove06.py
+ TestGroupMove07.py
+ TestGroupMove08.py
+ TestGroupMove09.py
+ TestGroupMove10.py
+ TestGroupMove11.py
+ TestGroupMove12.py
+ TestGroupMove13.py
+ TestGroupMove14.py
+ TestGroupMove15.py
+ TestGroupMove16.py
+ TestGroupMove17.py
+ TestGroupMove18.py
+ TestGroupMove19.py
TestGroupShareTopology.py
)
--- /dev/null
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
++# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
++#
++# 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, or (at your option) any later version.
++#
++# 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
++#
+
+ # Test that box partitioned is splitted: group with edge becomes 2 edges group,
+ # group with not-touched vertex keeps this vertex.
+
+ from salome.shaper import model
+ from ModelAPI import *
+
+ model.begin()
+ partSet = model.moduleDocument()
+ Part_1 = model.addPart(partSet)
+ Part_1_doc = Part_1.document()
+ Box_1 = model.addBox(Part_1_doc, 20, 10, 10)
+ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), 10, True)
+ Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")])
+ Group_2 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]")])
+ Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")])
+ model.do()
+ # move groups
+ Part_1_doc.moveFeature(Group_1.feature(), Partition_1.feature())
+ Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
+ model.end()
+
+ # Check groups
+ aFactory = ModelAPI_Session.get().validators()
+ selectionList = Group_1.feature().selectionList("group_list")
+ assert(selectionList.size() == 2)
+ assert(aFactory.validate(Group_1.feature()))
+
+ selectionList = Group_2.feature().selectionList("group_list")
+ assert(selectionList.size() == 1)
+ assert(aFactory.validate(Group_2.feature()))
--- /dev/null
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
++# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
++#
++# 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, or (at your option) any later version.
++#
++# 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
++#
+
+ # Test that removed vertex, selected in the group makes empty group => invalid one
+
+ from salome.shaper import model
+ from ModelAPI import *
+
+ model.begin()
+ partSet = model.moduleDocument()
+ Part_1 = model.addPart(partSet)
+ Part_1_doc = Part_1.document()
+ Box_1 = model.addBox(Part_1_doc, 10, 10, 20)
+ Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"))
+ Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]")])
+ Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")])
+ Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPSOLID", "Partition_1_1"))
+ Remove_SubShapes_1.setSubShapesToKeep([model.selection("SOLID", "Partition_1_1_2")])
+ model.do()
+ # move group
+ Part_1_doc.moveFeature(Group_1.feature(), Remove_SubShapes_1.feature())
+ model.end()
+
+ # Check group
+ aFactory = ModelAPI_Session.get().validators()
+ selectionList = Group_1.feature().selectionList("group_list")
+ assert(selectionList.size() == 0)
+ assert(aFactory.validate(Group_1.feature()) == False)
--- /dev/null
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
++# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
++#
++# 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, or (at your option) any later version.
++#
++# 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
++#
+
+ # Test that partition divides cylinder into 4 faces, there is no edges in a group moved to the end
+ # Based on the CEA report mail 04.12.2018, page 2
+
+ from SketchAPI import *
+
+ from ModelAPI import *
+ from GeomAPI import *
+ from salome.shaper import model
+
+ model.begin()
+ partSet = model.moduleDocument()
+ Part_1 = model.addPart(partSet)
+ Part_1_doc = Part_1.document()
+ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+ SketchArc_1 = Sketch_1.addArc(-1.103476974288834e-12, 24.99999999999979, 24.49489742783218, 30, 0, 50, False)
+ SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+ SketchLine_1 = SketchProjection_1.createdFeature()
+ SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result())
+ SketchLine_2 = Sketch_1.addLine(0, 50, -10, 50)
+ SketchLine_2.setAuxiliary(True)
+ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.startPoint())
+ SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
+ SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
+ SketchLine_3 = Sketch_1.addLine(24.49489742783218, 30, 24.49489742783218, 5)
+ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_3.startPoint())
+ SketchLine_4 = Sketch_1.addLine(24.49489742783218, 5, 34.49489742783218, 5)
+ SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+ SketchLine_5 = Sketch_1.addLine(34.49489742783218, 5, 34.49489742783218, 0)
+ SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+ SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+ SketchLine_6 = SketchProjection_2.createdFeature()
+ SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
+ SketchLine_7 = Sketch_1.addLine(34.49489742783218, 0, 0, 0)
+ SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
+ SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_7.endPoint())
+ SketchLine_8 = Sketch_1.addLine(0, 50, 0, 0)
+ SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_8.startPoint())
+ SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_8.endPoint())
+ SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
+ SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
+ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result())
+ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), 10)
+ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 5)
+ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 25)
+ SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 50)
+ SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_2.result(), 10)
+ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 25)
+ model.do()
+ Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_8f-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
+ Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3")])
+ Partition_1_objects = [model.selection("SOLID", "Revolution_1_1"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/YOZ")]
+ Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
+ model.do()
+
+ # move group
+ Part_1_doc.moveFeature(Group_1.feature(), Partition_1.feature())
+ model.end()
+
+ # Check group: result must be four faces
+ aFactory = ModelAPI_Session.get().validators()
+ selectionList = Group_1.feature().selectionList("group_list")
+ assert(selectionList.size() == 4)
+ assert(aFactory.validate(Group_1.feature()))
+ for i in range(4):
+ assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.FACE)
+
+ assert(model.checkPythonDump())
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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(Common)
INCLUDE(UnitTest)
TestBooleanCut_WireCompound_WireCompound.py
TestBooleanCut_Compound_Solid.py
TestBooleanCut_ErrorMsg.py
+ TestBooleanCut_SolidsHistory.py
TestBooleanSmash_Face_Face.py
TestBooleanSmash_SubSolid_Solid.py
TestBooleanSmash_CompSolid_Solid.py
TestBooleanSmash_ErrorMsg.py
+ TestBooleanSmash_SolidsHistory.py
TestBooleanFuse_SimpleMode.py
TestBooleanFuse_RemoveEdges.py
TestBooleanFuse_ErrorMsg.py
TestBooleanCommon_CompSolidCompound_Shell.py
TestBooleanCommon_CompSolidCompound_CompSolidCompound.py
TestBooleanCommon_ErrorMsg.py
+ TestBooleanCommon_SolidsHistory.py
Test2596.py
Test2592.py
Test2588.py
TestPartitionSubCompsolidWithPlane3.py
TestPartitionSubCompsolidWithPlane4.py
TestPartitionSubCompsolidWithPlane5.py
+ TestPartitionArgsUpdate.py
+ TestPartition_SolidsHistory.py
TestBooleanFuse_Vertex_Vertex.py
TestBooleanFuse_VertexCompound_VertexCompound.py
TestBooleanFuse_Edge_Edge.py
TestBooleanFuse_CompSolid_Face.py
TestBooleanFuse_CompSolid_CompSolid.py
TestBooleanFuse_CompSolidCompound_CompSolidCompound.py
+ TestBooleanFuse_SolidsHistory.py
TestFillet.py
TestFillet1.py
TestFillet_ErrorMsg.py
+ TestFillet_History.py
TestScale1.py
TestScale2.py
Test1816.py
+ Test1876.py
Test2631.py
+ Test2636.py
Test2650.py
Test2681.py
Test2686.py
Test2692.py
Test2617.py
Test2729.py
+ Test2738.py
Test2751.py
+ Test2826.py
+ Test2854.py
)
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_BooleanCommon.h"
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- GeomShapePtr aBaseShape = anObjects.front();
- anObjects.pop_front();
+ ListOfShape anEmptyTools;
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aBaseShape,
anObjects,
+ anEmptyTools,
aMakeShapeList,
aShape);
+ GeomShapePtr aBaseShape = anObjects.front();
+ anObjects.pop_front();
setResult(aResultBody, aResultIndex);
aResultIndex++;
if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
-
+ ListOfShape anObjectList;
+ anObjectList.push_back(anObject);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- anObject,
+ anObjectList,
aTools,
aMakeShapeList,
aResShape);
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ ListOfShape aCompSolidList;
+ aCompSolidList.push_back(aCompSolid);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aCompSolid,
+ aCompSolidList,
aTools,
aMakeShapeList,
aResultShape);
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ ListOfShape aCompoundList;
+ aCompoundList.push_back(aCompound);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aCompound,
+ aCompoundList,
aTools,
aMakeShapeList,
aResultShape);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_BooleanCut.h"
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ ListOfShape anObjectList;
+ anObjectList.push_back(anObject);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- anObject,
+ anObjectList,
aTools,
aMakeShapeList,
aResShape);
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ ListOfShape anObjectList;
+ anObjectList.push_back(aCompSolid);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aCompSolid,
+ anObjectList,
aTools,
aMakeShapeList,
aResultShape);
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ ListOfShape anObjectList;
+ anObjectList.push_back(aCompound);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aCompound,
+ anObjectList,
aTools,
aMakeShapeList,
aResultShape);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_BooleanFill.h"
+ #include "FeaturesPlugin_Tools.h"
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
+ #include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_MakeShapeCustom.h>
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_Partition.h>
return;
}
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+ ListOfShape aResultShapesList;
+
// For solids cut each object with all tools.
for(ListOfShape::iterator
anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
+ // tools should be added to the list to fulfill the correct history of modification
+ aListWithObject.insert(aListWithObject.end(), aTools.begin(), aTools.end());
+
ListOfShape aUsedTools = aTools;
aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
- loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, aMakeShapeList);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aListWithObject, aUsedTools,
+ aMakeShapeList, aResShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = anObject;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResShape);
}
// Compsolids handling
ListOfShape aUsedTools = aTools;
aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
- loadNamingDS(aResultBody,
- aCompSolid,
- aUsedTools,
- aResultShape,
- aMakeShapeList);
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aCompSolid);
+ // tools should be added to the list to fulfill the correct history of modification
+ aBaseShapes.insert(aBaseShapes.end(), aTools.begin(), aTools.end());
+
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, aUsedTools,
+ aMakeShapeList, aResultShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aCompSolid;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResultShape);
}
+ // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
+ // result shape has been deleted, but in another it was modified or stayed.
+ GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_BooleanFuse.h"
int aResultIndex = 0;
- GeomShapePtr aBackShape = anOriginalShapes.back();
- anOriginalShapes.pop_back();
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ ListOfShape anEmptyTools;
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aBackShape,
anOriginalShapes,
+ anEmptyTools,
aMakeShapeList,
aShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
- aBackShape,
+ GeomShapePtr(),
anOriginalShapes,
aMakeShapeList,
aShape);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_BooleanSmash.h"
aMakeShapeList->appendAlgo(aFillerAlgo);
}
- std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
- anOriginalShapes.pop_front();
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aFrontShape,
+ anOriginalShapes,
anOriginalShapes,
aMakeShapeList,
aShape);
aResultIndex++;
FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
- aFrontShape,
+ GeomShapePtr(),
anOriginalShapes,
aMakeShapeList,
aShape);
-// Copyright (C) 2017 CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Fillet.h"
+ #include "FeaturesPlugin_Tools.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Validator.h>
+ #include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Fillet.h>
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_Tools.h>
return anEdges;
}
- // If theShape is a compound of single shape, return it
+ // If theShape is a compound of a single sub-shape, return this sub-shape
static GeomShapePtr unwrapCompound(const GeomShapePtr& theShape)
{
GeomShapePtr aShape = theShape;
if (!aCreationMethod)
return;
- GeomAPI_DataMapOfShapeMapOfShapes aSolidsAndSubs;
+ std::list<std::pair<GeomShapePtr, ListOfShape> > aSolidsAndSubs;
- // getting objects and sort them accroding to parent solids
+ // getting objects and sort them according to parent solids
AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECT_LIST_ID());
for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); ++anObjectsIndex) {
AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
if (!aParent)
return;
+ // searching this parent is already in the list aSolidsAndSubs
+ std::list<std::pair<GeomShapePtr, ListOfShape> >::iterator aSearch = aSolidsAndSubs.begin();
+ ListOfShape* aFound;
+ for(; aSearch != aSolidsAndSubs.end(); aSearch++) {
+ if (aSearch->first->isSame(aParent)) {
+ aFound = &(aSearch->second);
+ break;
+ }
+ }
+ if (aSearch == aSolidsAndSubs.end()) { // not found, so, add a new one
+ aSolidsAndSubs.push_back(std::pair<GeomShapePtr, ListOfShape>(aParent, ListOfShape()));
+ aFound = &(aSolidsAndSubs.back().second);
+ }
+
ListOfShape anEdgesAndVertices;
collectSubs(anObject, anEdgesAndVertices, GeomAPI_Shape::EDGE);
collectSubs(anObject, anEdgesAndVertices, GeomAPI_Shape::VERTEX);
for (ListOfShape::iterator aEIt = anEdgesAndVertices.begin();
aEIt != anEdgesAndVertices.end(); ++aEIt)
- aSolidsAndSubs.add(aParent, *aEIt);
+ aFound->push_back(*aEIt);
}
bool isFixedRadius = true;
int aResultIndex = 0;
std::string anError;
- GeomAPI_DataMapOfShapeMapOfShapes::iterator anIt = aSolidsAndSubs.begin();
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+ ListOfShape anOriginalShapesList, aResultShapesList;
+
+ std::list<std::pair<GeomShapePtr, ListOfShape> >::iterator anIt = aSolidsAndSubs.begin();
for (; anIt != aSolidsAndSubs.end(); ++anIt) {
- GeomShapePtr aSolid = anIt.first();
- ListOfShape aFilletEdgesAndVertices = anIt.second();
+ GeomShapePtr aSolid = anIt->first;
+ ListOfShape aFilletEdgesAndVertices = anIt->second;
ListOfShape aFilletEdges = selectEdges(aFilletEdgesAndVertices);
if (isFixedRadius)
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, aSolid, aResult, aFilletBuilder);
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aSolid);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aFilletBuilder, aResult, "Fillet");
+
setResult(aResultBody, aResultIndex);
aResultIndex++;
- }
- removeResults(aResultIndex);
- }
- void FeaturesPlugin_Fillet::loadNamingDS(
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const std::shared_ptr<GeomAPI_Shape> theBaseShape,
- const std::shared_ptr<GeomAPI_Shape> theResultShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape)
- {
- //load result
- if(theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- return;
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aSolid;
+ aRBA.makeShape = aFilletBuilder;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResult);
+ anOriginalShapesList.push_back(aSolid);
+
+ const std::string aFilletFaceName = "Fillet";
+ ListOfShape::iterator aSelectedBase = aFilletEdges.begin();
+ for(; aSelectedBase != aFilletEdges.end(); aSelectedBase++) {
+ GeomShapePtr aBase = *aSelectedBase;
+ // Store new faces generated from edges and vertices
+ aResultBody->loadGeneratedShapes(
+ aFilletBuilder, aBase, GeomAPI_Shape::EDGE, aFilletFaceName, true);
+ }
}
- theResultBody->storeModified(theBaseShape, theResultShape);
+ // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
+ // result shape has been deleted, but in another it was modified or stayed.
+ GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
+ anOriginalShapesList, aResultShapesCompound);
- const std::string aFilletFaceName = "Fillet_Face";
-
- // Store modified faces
- theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
-
- // Store new faces generated from edges and vertices
- theResultBody->loadGeneratedShapes(theMakeShape,
- theBaseShape,
- GeomAPI_Shape::EDGE,
- aFilletFaceName);
- theResultBody->loadGeneratedShapes(theMakeShape,
- theBaseShape,
- GeomAPI_Shape::VERTEX,
- aFilletFaceName);
-
- // Deleted shapes
- theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
- theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
+ removeResults(aResultIndex);
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_FusionFaces.h"
+ #include "FeaturesPlugin_Tools.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
// Store result
GeomShapePtr aResultShape = anAlgo->shape();
ResultBodyPtr aResultBody = document()->createBody(data());
- if (aResultShape->isEqual(aBaseShape)) {
- aResultBody->store(aResultShape);
- } else {
- aResultBody->storeModified(aBaseShape, aResultShape);
- aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE);
- aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE);
- }
+ ListOfShape aBaseShapesList;
+ aBaseShapesList.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapesList, ListOfShape(),
+ anAlgo, aResultShape);
setResult(aResultBody);
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Intersection.h"
setResult(aResultBody, aResultIndex);
aResultIndex++;
-
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
return;
}
- theResultBody->storeModified(theObjects.front(), aResultShape);
+ theResultBody->storeModified(theObjects, aResultShape, theMakeShape);
const int aShapeTypesNb = 3;
const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = {GeomAPI_Shape::VERTEX,
-// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
// File: FeaturesPlugin_MultiRotation.cpp
// Created: 30 Jan 2017
// Author: Clarisse Genrault (CEA)
#include <FeaturesPlugin_MultiRotation.h>
+ #include <FeaturesPlugin_Tools.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+ #include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_Translation.h>
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > aListOfRotationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfRotationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int i=0; i<nbCopies; i++) {
std::shared_ptr<GeomAlgoAPI_Rotation> aRotationnAlgo(
break;
}
aListOfShape.push_back(aRotationnAlgo->shape());
- aListOfRotationAlgo.push_back(aRotationnAlgo);
+ aListOfRotationAlgo->appendAlgo(aRotationnAlgo);
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfRotationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfRotationAlgo, aCompound, "Rotated");
setResult(aResultBody, aResultIndex);
}
}
}
#endif
-
- //=================================================================================================
- void FeaturesPlugin_MultiRotation::loadNamingDS(
- std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
- {
- for (std::list<std::shared_ptr<GeomAlgoAPI_Rotation> >::const_iterator anIt =
- theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) {
- // naming of faces
- theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face");
-
- // naming of edges
- theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge");
-
- // naming of vertex
- theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex");
- }
- }
-// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
// File: FeaturesPlugin_MultiRotation.h
// Created: 30 Jan 2017
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape, int nb);
#endif
-
- void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Rotation> > theListOfRotationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
-#endif // FEATURESPLUGIN_MULTIROTATION_H_
+#endif // FEATURESPLUGIN_MULTIROTATION_H_
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <FeaturesPlugin_MultiTranslation.h>
+ #include <FeaturesPlugin_Tools.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+ #include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_Tools.h>
#include <GeomAPI_Ax1.h>
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int i=0; i<nbCopies; i++) {
std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
break;
}
aListOfShape.push_back(aTranslationAlgo->shape());
- aListOfTranslationAlgo.push_back(aTranslationAlgo);
+ aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfTranslationAlgo, aCompound, "Translated");
setResult(aResultBody, aResultIndex);
}
} else {
std::string anError;
ListOfShape aListOfShape;
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > aListOfTranslationAlgo;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>
+ aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList);
for (int j=0; j<aSecondNbCopies; j++) {
for (int i=0; i<aFirstNbCopies; i++) {
break;
}
aListOfShape.push_back(aTranslationAlgo->shape());
- aListOfTranslationAlgo.push_back(aTranslationAlgo);
+ aListOfTranslationAlgo->appendAlgo(aTranslationAlgo);
}
}
std::shared_ptr<GeomAPI_Shape> aCompound =
GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aCompound);
- loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape);
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ aListOfTranslationAlgo, aCompound, "Translated");
+
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
- //=================================================================================================
- void FeaturesPlugin_MultiTranslation::loadNamingDS(
- std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
- {
- for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
- theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
- // naming of faces
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::FACE,
- "Translated_Face");
-
- // naming of edges
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::EDGE,
- "Translated_Edge");
-
- // naming of vertex
- theResultBody->loadModifiedShapes(*anIt,
- theBaseShape,
- GeomAPI_Shape::VERTEX,
- "Translated_Vertex");
- }
- }
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef FEATURESPLUGIN_MULTITRANSLATION_H_
/// Perform the multi translation in two directions.
void performTwoDirection();
-
- void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif // FEATURESPLUGIN_MULTITRANSLATION_H_
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Partition.h"
const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
const int theIndex)
{
- // Find base. The most complicated is the real modified object (#1799 if box is partitioned by
- // two planes the box is the base, not planes, independently on the order in the list).
- GeomShapePtr aBaseShape;
- for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
- GeomShapePtr anObjectShape = *anIt;
- GeomShapePtr aCandidate =
- findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape);
- if(!aCandidate.get()) {
- aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape);
- }
- if (!aCandidate.get())
- aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape);
-
- if(aCandidate.get()) {
- if (!aBaseShape.get() || aBaseShape->shapeType() > aCandidate->shapeType()) {
- aBaseShape = aCandidate;
- }
- }
- }
-
// Create result body.
ResultBodyPtr aResultBody = document()->createBody(data(), theIndex);
- // Store modified shape.
- if(!aBaseShape.get() || aBaseShape->isEqual(theResultShape)) {
- aResultBody->store(theResultShape, false);
- setResult(aResultBody, theIndex);
- return;
+ // if result is same as one of the base object, no modification was performed
+ for(ListOfShape::const_iterator anObj = theObjects.cbegin(); anObj != theObjects.cend(); ++anObj)
+ {
+ if (anObj->get() && (*anObj)->isSame(theResultShape)) {
+ aResultBody->store(theResultShape, false);
+ setResult(aResultBody, theIndex);
+ return;
+ }
}
- aResultBody->storeModified(aBaseShape, theResultShape);
+ aResultBody->storeModified(theObjects, theResultShape, theMakeShape);
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end());
//================= Auxiliary functions ===================================================
- GeomShapePtr findBase(const GeomShapePtr theObjectShape,
- const GeomShapePtr theResultShape,
- const GeomAPI_Shape::ShapeType theShapeType,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
- {
- GeomShapePtr aBaseShape;
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
- for(GeomAPI_ShapeExplorer anObjectSubShapesExp(theObjectShape, theShapeType);
- anObjectSubShapesExp.more();
- anObjectSubShapesExp.next()) {
- GeomShapePtr anObjectSubShape = anObjectSubShapesExp.current();
- ListOfShape aModifiedShapes;
- theMakeShape->modified(anObjectSubShape, aModifiedShapes);
- for(ListOfShape::const_iterator
- aModIt = aModifiedShapes.cbegin(); aModIt != aModifiedShapes.cend(); ++aModIt) {
- GeomShapePtr aModShape = *aModIt;
- if(aMapOfSubShapes->isBound(aModShape)) {
- aModShape = aMapOfSubShapes->find(aModShape);
- }
- if(theResultShape->isSubShape(aModShape)) {
- aBaseShape = theObjectShape;
- break;
- }
- }
- if(aBaseShape.get()) {
- break;
- }
- }
-
- return aBaseShape;
- }
-
static CompsolidSubs::iterator findOrAdd(CompsolidSubs& theList, const GeomShapePtr& theCompsolid)
{
CompsolidSubs::iterator aFound = theList.begin();
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Placement.h"
//LoadNamingDS
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aTransformAlgo->shape());
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aTransformAlgo, "Placed");
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aShapes, ListOfShape(),
+ aTransformAlgo, aTransformAlgo->shape(), "Placed");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <FeaturesPlugin_Rotation.h>
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aRotationAlgo->shape());
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aShapes,
+ ListOfShape(),
+ aRotationAlgo,
+ aRotationAlgo->shape(),
+ "Rotated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aRotationAlgo->shape());
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aShapes,
+ ListOfShape(),
+ aRotationAlgo,
+ aRotationAlgo->shape(),
+ "Rotated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <FeaturesPlugin_Scale.h>
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aShapes,
+ ListOfShape(),
+ aScaleAlgo,
+ aScaleAlgo->shape(),
+ "Scaled");
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aShapes,
+ ListOfShape(),
+ aScaleAlgo,
+ aScaleAlgo->shape(),
+ "Scaled");
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <FeaturesPlugin_Symmetry.h>
// Store and name the result.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
- aResultBody->storeModified(theBaseShape, aCompound);
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBaseShape, anAlgoList, "Symmetried");
+
+ ListOfShape aBaseShapes;
+ aBaseShapes.push_back(theBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+ anAlgoList, aCompound, "Symmetried");
+
setResult(aResultBody, theResultIndex);
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "FeaturesPlugin_Tools.h"
//==================================================================================================
void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
+ const ListOfShape& theBaseShapes,
const ListOfShape& theTools,
const GeomMakeShapePtr& theMakeShape,
- const GeomShapePtr theResultShape)
+ const GeomShapePtr theResultShape,
+ const std::string& theNamePrefix)
{
- if (theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- return;
- }
+ theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape);
- theResultBody->storeModified(theBaseShape, theResultShape);
+ ListOfShape aShapes = theBaseShapes;
+ ListOfShape::const_iterator aToolIter = theTools.cbegin();
+ for(; aToolIter != theTools.cend(); aToolIter++)
+ aShapes.push_back(*aToolIter);
- ListOfShape aShapes = theTools;
- aShapes.push_front(theBaseShape);
+ std::string aVertexName, anEdgeName, aFaceName;
+ if (!theNamePrefix.empty()) {
+ aVertexName = theNamePrefix + "_Vertex";
+ anEdgeName = theNamePrefix + "_Edge";
+ aFaceName = theNamePrefix + "_Face";
+ }
for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
{
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX);
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE);
- theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aVertexName);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, anEdgeName);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, aFaceName);
}
}
//==================================================================================================
void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
+ const GeomShapePtr& theBaseShape,
const GeomMakeShapePtr& theMakeShape,
const std::string theName)
{
const GeomShapePtr theResultShapesCompound)
{
ListOfShape aShapes = theTools;
- aShapes.push_front(theBaseShape);
+ if (theBaseShape.get())
+ aShapes.push_front(theBaseShape);
for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++)
{
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef FeaturesPlugin_Tools_H_
public:
static void loadModifiedShapes(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
+ const ListOfShape& theBaseShapes,
const ListOfShape& theTools,
const GeomMakeShapePtr& theMakeShape,
- const GeomShapePtr theResultShape);
+ const GeomShapePtr theResultShape,
+ const std::string& theNamePrefix = "");
static void loadModifiedShapes(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
+ const GeomShapePtr& theBaseShape,
const GeomMakeShapePtr& theMakeShape,
const std::string theName);
-
/// Stores deleted shapes.
static void loadDeletedShapes(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <FeaturesPlugin_Translation.h>
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aBaseShape,
+ aShapes,
+ ListOfShape(),
aTranslationAlgo,
+ aTranslationAlgo->shape(),
"Translated");
setResult(aResultBody, aResultIndex);
}
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aBaseShape,
+ aShapes,
+ ListOfShape(),
aTranslationAlgo,
+ aTranslationAlgo->shape(),
"Translated");
setResult(aResultBody, aResultIndex);
}
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aBaseShape,
+ aShapes,
+ ListOfShape(),
aTranslationAlgo,
+ aTranslationAlgo->shape(),
"Translated");
setResult(aResultBody, aResultIndex);
}
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
# -*- coding: utf-8 -*-
Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_2_2"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]
Face_1 = model.addFace(Part_1_doc, Face_1_objects)
Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Recover_1_1"), model.selection("FACE", "Face_1_1")])
- Group_1_objects = [model.selection("VERTEX", "[Intersection_1_1_3/Intersection_1_1_3&Face_1_1/Edge_3][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_9/Intersection_1_1_9&Face_1_1/Edge_7][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_7/Intersection_1_1_7&Face_1_1/Edge_5][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_2/Intersection_1_1_2&Face_1_1/Edge_2][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_6/Intersection_1_1_6&Face_1_1/Edge_4][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_10/Intersection_1_1_10&Face_1_1/Edge_8][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_8/Intersection_1_1_8&Face_1_1/Edge_6][weak_name_1]")]
+ Group_1_objects = [
+ model.selection("VERTEX", "[Intersection_1_1_3/Intersection_1_1_3&Face_1_1/Edge_3][weak_name_2]"),
+ model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_2]"),
+ model.selection("VERTEX", "[Intersection_1_1_9/Intersection_1_1_9&Face_1_1/Edge_7][weak_name_1]"),
+ model.selection("VERTEX", "[Intersection_1_1_7/Intersection_1_1_7&Face_1_1/Edge_5][weak_name_2]"),
+ model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_2]"),
+ model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_1]"),
+ model.selection("VERTEX", "[Intersection_1_1_2/Intersection_1_1_2&Face_1_1/Edge_2][weak_name_1]"),
+ model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_1]"),
+ model.selection("VERTEX", "[Intersection_1_1_6/Intersection_1_1_6&Face_1_1/Edge_4][weak_name_2]"),
+ model.selection("VERTEX", "[Intersection_1_1_10/Intersection_1_1_10&Face_1_1/Edge_8][weak_name_1]"),
+ model.selection("VERTEX", "[Intersection_1_1_8/Intersection_1_1_8&Face_1_1/Edge_6][weak_name_1]")]
+
Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
Group_2_objects = [model.selection("EDGE", "Intersection_1_1_7"), model.selection("EDGE", "Intersection_1_1_6"), model.selection("EDGE", "Intersection_1_1_3"), model.selection("EDGE", "Intersection_1_1_11"), model.selection("EDGE", "Intersection_1_1_5"), model.selection("EDGE", "Intersection_1_1_1"), model.selection("EDGE", "Intersection_1_1_4"), model.selection("EDGE", "Intersection_1_1_2"), model.selection("EDGE", "Intersection_1_1_10"), model.selection("EDGE", "Intersection_1_1_9"), model.selection("EDGE", "Intersection_1_1_8")]
Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAPI_Shape.h"
return false;
}
+
+ bool GeomAPI_Shape::Comparator::operator()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
+ const std::shared_ptr<GeomAPI_Shape>& theShape2) const
+ {
+ return theShape1->impl<TopoDS_Shape>().TShape() < theShape2->impl<TopoDS_Shape>().TShape();
+ }
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GeomAPI_Shape_H_
/// 8 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S and F/S;<br>
/// 9 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S, F/S and S/S - all interferences (Default value)
GEOMAPI_EXPORT bool isSelfIntersected(const int theLevelOfCheck = 9) const;
+
+ public:
+ class Comparator
+ {
+ public:
+ /// Return \c true if the address of the first shape is less than the address of the second
+ GEOMAPI_EXPORT
+ bool operator ()(const std::shared_ptr<GeomAPI_Shape>& theShape1,
+ const std::shared_ptr<GeomAPI_Shape>& theShape2) const;
+ };
};
//! Pointer on list of shapes
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/* GeomAPI.i */
%shared_ptr(GeomAlgoAPI_Revolution)
%shared_ptr(GeomAlgoAPI_Rotation)
%shared_ptr(GeomAlgoAPI_Sewing)
+ %shared_ptr(GeomAlgoAPI_SketchBuilder)
%shared_ptr(GeomAlgoAPI_ShapeBuilder)
%shared_ptr(GeomAlgoAPI_Translation)
%shared_ptr(GeomAlgoAPI_Transform)
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_Boolean.h"
#include <BOPAlgo_BOP.hxx>
#include <TopTools_ListOfShape.hxx>
+ #include <TopoDS_Iterator.hxx>
+ #include <TopExp_Explorer.hxx>
//=================================================================================================
GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const GeomShapePtr theObject,
if(aResult.ShapeType() == TopAbs_COMPOUND) {
std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
aGeomShape->setImpl(new TopoDS_Shape(aResult));
- ListOfShape aCompSolids, aFreeSolids;
+ ListOfShape aResults;
aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
GeomAPI_Shape::COMPSOLID,
- aCompSolids,
- aFreeSolids);
+ aResults);
aResult = aGeomShape->impl<TopoDS_Shape>();
}
this->setShape(aShape);
this->setDone(true);
}
+
+ static bool isHistoryType(TopAbs_ShapeEnum theType) {
+ return theType == TopAbs_VERTEX || theType == TopAbs_EDGE ||
+ theType == TopAbs_FACE || theType == TopAbs_SOLID;
+ }
+
+ /// searches the corresponding result for theOld
+ static void searchResult(const TopoDS_Shape& theOld, const TopoDS_Shape& theResult,
+ BOPAlgo_BOP* theBuilder, TopTools_MapOfShape& theNews)
+ {
+ if (theResult.ShapeType() == theOld.ShapeType()) { // check some sub-shape produces a sub-result
+ if (theOld.IsSame(theResult)) {
+ theNews.Add(theResult);
+ return;
+ }
+ // searching for new result by sub-shapes of aSubType type
+ TopAbs_ShapeEnum aSubType = TopAbs_ShapeEnum(int(theOld.ShapeType()) + 1);
+ while(aSubType < TopAbs_VERTEX && !isHistoryType(aSubType))
+ aSubType = TopAbs_ShapeEnum(int(aSubType) + 1);
+ if (aSubType == TopAbs_SHAPE)
+ return;
+ TopTools_MapOfShape aResSubs;
+ for(TopExp_Explorer aResExp(theResult, aSubType); aResExp.More(); aResExp.Next())
+ aResSubs.Add(aResExp.Current());
+ for(TopExp_Explorer anExp(theOld, aSubType); anExp.More(); anExp.Next()) {
+ const TopTools_ListOfShape& aNewSubs = theBuilder->Modified(anExp.Current());
+ // searching for this new sub in theResult
+ for(TopTools_ListIteratorOfListOfShape aNewSub(aNewSubs); aNewSub.More(); aNewSub.Next()) {
+ if (aResSubs.Contains(aNewSub.Value())) {
+ theNews.Add(theResult);
+ return;
+ }
+ }
+ }
+ } else if (theResult.ShapeType() < theOld.ShapeType()) { // recursive search among sub-shapes
+ for(TopoDS_Iterator aSubResults(theResult); aSubResults.More(); aSubResults.Next()) {
+ searchResult(theOld, aSubResults.Value(), theBuilder, theNews);
+ }
+ }
+ }
+
+ // check the shape is on the higher level of compound or compsolid
+ bool isInComp(const TopoDS_Shape& theComp, const TopoDS_Shape& theShape) {
+ if (theComp.ShapeType() == TopAbs_COMPOUND || theComp.ShapeType() == TopAbs_COMPSOLID) {
+ for(TopoDS_Iterator anIter(theComp); anIter.More(); anIter.Next()) {
+ if (isInComp(anIter.Value(), theShape))
+ return true;
+ }
+ } else return theShape.IsSame(theComp);
+ return false;
+ }
+
+ //=================================================================================================
+ /// make arguments of Fuse produce result shapes with "modified" evolution
+ void GeomAlgoAPI_Boolean::modified(const GeomShapePtr theOldShape, ListOfShape& theNewShapes)
+ {
+ BOPAlgo_BOP* aBuilder = this->implPtr<BOPAlgo_BOP>();
+ if (aBuilder->Operation() == BOPAlgo_FUSE) { // only for fuse and when old is and argument
+ TopoDS_Shape anOld = theOldShape->impl<TopoDS_Shape>();
+ bool isOldComp = anOld.ShapeType() == TopAbs_COMPOUND || anOld.ShapeType() == TopAbs_COMPSOLID;
+ bool aFound = false;
+ TopTools_ListIteratorOfListOfShape anIter(aBuilder->Arguments());
+ for(; !aFound && anIter.More(); anIter.Next())
+ aFound = anOld.IsSame(anIter.Value()) || (!isOldComp && isInComp(anIter.Value(), anOld));
+ for(anIter.Initialize(aBuilder->Tools()); !aFound && anIter.More(); anIter.Next())
+ aFound = anOld.IsSame(anIter.Value()) || (!isOldComp && isInComp(anIter.Value(), anOld));
+ if (aFound) {
+ TopoDS_Shape aResult = aBuilder->Shape();
+ TopTools_MapOfShape aNewsMap;
+ searchResult(anOld, aResult, aBuilder, aNewsMap);
+ if (!aNewsMap.IsEmpty()) {
+ for(TopTools_MapIteratorOfMapOfShape aNewsIter(aNewsMap); aNewsIter.More(); aNewsIter.Next())
+ {
+ GeomShapePtr aShape(new GeomAPI_Shape);
+ aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aNewsIter.Value()));
+ theNewShapes.push_back(aShape);
+ }
+ return;
+ }
+ }
+ }
+ GeomAlgoAPI_MakeShape::modified(theOldShape, theNewShapes); // default behavior
+ }
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GeomAlgoAPI_Boolean_H_
const ListOfShape& theTools,
const OperationType theOperationType);
+ /// Redefinition of the generic method for the Fuse problem: OCCT 30481
+ GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes);
+
private:
/// Builds resulting shape.
void build(const ListOfShape& theObjects,
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_MakeVolume.h"
+ #include <GeomAPI_ShapeExplorer.h>
+
#include <GeomAlgoAPI_ShapeTools.h>
#include <BOPAlgo_MakerVolume.hxx>
this->setShape(aShape);
this->setDone(true);
}
+
+ //=================================================================================================
+ void GeomAlgoAPI_MakeVolume::modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
+ {
+ if (theOldShape->shapeType() == GeomAPI_Shape::SOLID) {
+ ListOfShape aNewShapes;
+ // collect faces and parent shapes, if it is not done yet
+ if (!isNewShapesCollected(theOldShape, GeomAPI_Shape::FACE))
+ collectNewShapes(theOldShape, GeomAPI_Shape::FACE);
+
+ for (GeomAPI_ShapeExplorer anIt(shape(), GeomAPI_Shape::SOLID); anIt.more(); anIt.next()) {
+ for (GeomAPI_ShapeExplorer anExp(anIt.current(), GeomAPI_Shape::FACE);
+ anExp.more(); anExp.next()) {
+ GeomShapePtr anOldShapesCompound =
+ oldShapesForNew(theOldShape, anExp.current(), GeomAPI_Shape::FACE);
+ if (!anOldShapesCompound->isNull()) {
+ aNewShapes.push_back(anIt.current());
+ break;
+ }
+ }
+ }
+
+ if (!aNewShapes.empty())
+ theNewShapes = aNewShapes;
+ }
+ else
+ GeomAlgoAPI_MakeShape::modified(theOldShape, theNewShapes);
+ }
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GeomAlgoAPI_MakeVolume_H_
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeVolume(const ListOfShape& theFaces,
const bool theAvoidInternal);
+ /// \return the list of shapes modified from the shape \a theShape.
+ /// \param[in] theOldShape base shape.
+ /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared!
+ GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes);
+
private:
/// Builds resulting shape.
void build(const ListOfShape& theFaces);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_Sewing.h"
}
//==================================================================================================
+ #include <GeomAPI_ShapeExplorer.h>
+ #include <GeomAPI_ShapeIterator.h>
+
+ typedef std::map<GeomShapePtr, ListOfShape, GeomAPI_Shape::Comparator> MapFaceSolid;
+ static void facesBelongingToSolids(const GeomShapePtr& theShape,
+ MapFaceSolid& theShapeRelations)
+ {
+ for (GeomAPI_ShapeExplorer aSolidExp(theShape, GeomAPI_Shape::SHELL);
+ aSolidExp.more(); aSolidExp.next()) {
+ GeomShapePtr aSolid = aSolidExp.current();
+ for (GeomAPI_ShapeExplorer aFaceExp(aSolid, GeomAPI_Shape::FACE);
+ aFaceExp.more(); aFaceExp.next())
+ theShapeRelations[aFaceExp.current()].push_back(aSolid);
+ }
+ }
+
+ static bool isShapeInList(const GeomShapePtr& theShape, const ListOfShape& theList)
+ {
+ for (ListOfShape::const_iterator anIt = theList.begin(); anIt != theList.end(); ++anIt)
+ if (theShape->isEqual(*anIt))
+ return true;
+ return false;
+ }
+
void GeomAlgoAPI_Sewing::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
ListOfShape& theHistory)
{
aGeomShape->setImpl(new TopoDS_Shape(anExp.Current()));
theHistory.push_back(aGeomShape);
}
+
+ if (theShape->shapeType() < GeomAPI_Shape::FACE) {
+ ListOfShape aNewShapes;
+ // collect faces and parent shapes, if it is not done yet
+ if (!isNewShapesCollected(theShape, GeomAPI_Shape::FACE))
+ collectNewShapes(theShape, GeomAPI_Shape::FACE);
+
+ for (GeomAPI_ShapeIterator anIt(shape()); anIt.more(); anIt.next()) {
+ GeomShapePtr anOldShapesCompound =
+ oldShapesForNew(theShape, anIt.current(), GeomAPI_Shape::FACE);
+ if (!anOldShapesCompound->isNull())
+ aNewShapes.push_back(anIt.current());
+ }
+
+ if (!aNewShapes.empty())
+ theHistory = aNewShapes;
+ }
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GeomAlgoAPI_ShapeTools_H_
/// \return the total area of the faces of the current shape or 0.0 if it can be computed.
GEOMALGOAPI_EXPORT static double area(const std::shared_ptr<GeomAPI_Shape> theShape);
- /// \return the centre of mass of the current face.
+ /// \return the center of mass of the current face.
/// The coordinates returned for the center of mass
/// are expressed in the absolute Cartesian coordinate system.
/// (This function works only for surfaces).
/// \brief Combines faces with common edges to shells, or solids to compsolids.
/// \param[in] theCompound compound of shapes.
/// \param[in] theType type of combine.
- /// \param[out] theCombinedShapes resulting shapes.
- /// \param[out] theFreeShapes shapes that does not have common subshapes.
+ /// \param[out] theResults resulting shapes.
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> combineShapes(
const std::shared_ptr<GeomAPI_Shape> theCompound,
- const GeomAPI_Shape::ShapeType theType,
- ListOfShape& theCombinedShapes,
- ListOfShape& theFreeShapes);
+ const GeomAPI_Shape::ShapeType theType, ListOfShape& theResults);
/// \brief Groups shapes with shared topology to compounds.
/// \param[in] theCompound compound of shapes.
/// \brief Enlarges or reduces plane to fit bounding box.
/// \return plane that fits to bounding box.
/// \param[in] thePlane base plane.
- /// \param[in] thePoints bounding box points (shoud be eight).
+ /// \param[in] thePoints bounding box points (should be eight).
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Face> fitPlaneToBox(
const std::shared_ptr<GeomAPI_Shape> thePlane,
const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
/// \brief Return a plane for list of shapes if they are all planar.
/// \param[in] theShapes shapes to find plane.
- /// \return plane where all shapes lie or empty ptr if they not planar.
+ /// \return plane where all shapes lie or empty pointer if they not planar.
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
- /// \brief Checks that vertex/edge is inside face or vertext inside wire.
+ /// \brief Checks that vertex/edge is inside face or vertex inside wire.
/// \param[in] theSubShape shape that should be inside.
/// \param[in] theBaseShape base shape.
/// \return true if edge inside the face.
std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
/// \brief Performs the split of the shape by points.
- /// \param[in] theBaseShape shape that should be splitted.
+ /// \param[in] theBaseShape shape that should be divided.
/// \param[in] thePoints container of points to split
/// \param[out] theShapes container of shapes after split
GEOMALGOAPI_EXPORT static void splitShape(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
/// \brief Performs the split of the shape by points.
- /// \param[in] theBaseShape shape that should be splitted.
+ /// \param[in] theBaseShape shape that should be divided.
/// \param[in] thePoints container of points to split
/// \param[out] theShapes container of shapes after split
GEOMALGOAPI_EXPORT static void splitShape_p(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
const std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
- /// \brief Returns a dir from a shape and an axis.
+ /// \brief Returns a direction from a shape and an axis.
/// \param[in] theBaseShape shape whose center of mass serves as the starting point of the dir.
/// \param[in] theAxis axis that serves as a direction for the dir
/// \return dir that builds from center of mass of the base shape and the axis
const std::shared_ptr<GeomAPI_Ax1> theAxis);
#endif
- /// \brief Reapproximate a wire to build a single edge
+ /// \brief Re-approximate a wire to build a single edge
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Edge> wireToEdge(
const std::shared_ptr<GeomAPI_Wire>& theWire);
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <GeomAlgoAPI_SketchBuilder.h>
#include <GeomAPI_PlanarEdges.h>
+ #include <GeomAPI_Pln.h>
+
#include <BOPAlgo_Builder.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools_WireExplorer.hxx>
}
}
- void GeomAlgoAPI_SketchBuilder::createFaces(
+ void GeomAlgoAPI_SketchBuilder::build(
const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theDirX,
const std::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::list<std::shared_ptr<GeomAPI_Shape> >& theFeatures,
- std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces)
+ const std::list<std::shared_ptr<GeomAPI_Shape> >& theEdges)
{
- if (theFeatures.empty())
+ myResultFaces.clear();
+ setDone(false);
+ if (theEdges.empty())
return;
BRep_Builder aBuilder;
aBuilder.MakeFace(aPlnFace, aPlane, Precision::Confusion());
// Use General Fuse algorithm to prepare all subfaces, bounded by given list of edges
- BOPAlgo_Builder aBB;
- aBB.AddArgument(aPlnFace);
+ BOPAlgo_Builder* aBB = new BOPAlgo_Builder;
+ aBB->AddArgument(aPlnFace);
+
+ setImpl(aBB);
+ setBuilderType(OCCT_BOPAlgo_Builder);
NCollection_List<TopoDS_Shape> anEdges;
NCollection_List<TopoDS_Shape>::Iterator aShapeIt;
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator aFeatIt = theFeatures.begin();
- for (; aFeatIt != theFeatures.end(); aFeatIt++) {
+ std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator aFeatIt = theEdges.begin();
+ for (; aFeatIt != theEdges.end(); aFeatIt++) {
std::shared_ptr<GeomAPI_Shape> aShape(*aFeatIt);
const TopoDS_Edge& anEdge = aShape->impl<TopoDS_Edge>();
if (anEdge.ShapeType() == TopAbs_EDGE)
- aBB.AddArgument(anEdge);
+ aBB->AddArgument(anEdge);
}
- aBB.Perform();
- if (aBB.HasErrors())
+ aBB->Perform();
+ if (aBB->HasErrors())
return;
+
+ TopoDS_Compound aResult;
+ aBuilder.MakeCompound(aResult);
+
// Collect faces
- TopTools_ListOfShape anAreas = aBB.Modified(aPlnFace);
- sortFaces(anAreas, theFeatures); // sort faces by the edges in them
+ TopTools_ListOfShape anAreas = aBB->Modified(aPlnFace);
+ sortFaces(anAreas, theEdges); // sort faces by the edges in them
TopTools_ListIteratorOfListOfShape anIt(anAreas);
for (; anIt.More(); anIt.Next()) {
TopoDS_Face aFace = TopoDS::Face(anIt.Value());
// to make faces equal on different platforms, we will find
// a vertex lying on an edge with the lowest index in the list of initial edges
- TopoDS_Vertex aStartVertex = findStartVertex(aWire, aFace, theFeatures);
+ TopoDS_Vertex aStartVertex = findStartVertex(aWire, aFace, theEdges);
TopoDS_Wire aNewWire;
aBuilder.MakeWire(aNewWire);
}
// store face
- aFace = aNewFace;
+ aBuilder.Add(aResult, aNewFace);
std::shared_ptr<GeomAPI_Shape> aResFace(new GeomAPI_Shape);
aResFace->setImpl(new TopoDS_Face(aFace));
- theResultFaces.push_back(aResFace);
+ myResultFaces.push_back(aResFace);
}
+
+ // update results
+ GeomShapePtr aResShape(new GeomAPI_Shape);
+ aResShape->setImpl(new TopoDS_Shape(aResult));
+ setShape(aResShape);
+ setDone(true);
}
- void GeomAlgoAPI_SketchBuilder::createFaces(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
- const std::shared_ptr<GeomAPI_Dir>& theDirX,
- const std::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::shared_ptr<GeomAPI_Shape>& theWire,
- std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces)
+ GeomAlgoAPI_SketchBuilder::GeomAlgoAPI_SketchBuilder(
+ const std::shared_ptr<GeomAPI_Pln>& thePlane,
+ const std::list<std::shared_ptr<GeomAPI_Shape> >& theEdges)
+ {
+ build(thePlane->location(), thePlane->xDirection(), thePlane->direction(), theEdges);
+ }
+
+ GeomAlgoAPI_SketchBuilder::GeomAlgoAPI_SketchBuilder(
+ const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const std::shared_ptr<GeomAPI_Dir>& theDirX,
+ const std::shared_ptr<GeomAPI_Dir>& theNorm,
+ const std::shared_ptr<GeomAPI_Shape>& theWire)
{
std::shared_ptr<GeomAPI_PlanarEdges> aWire =
std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(theWire);
if(aWire) {
// Filter wires, return only faces.
- createFaces(theOrigin, theDirX, theNorm, aWire->getEdges(), theResultFaces);
+ build(theOrigin, theDirX, theNorm, aWire->getEdges());
} else { // it may be only one circle
std::shared_ptr<GeomAPI_Edge> anEdge = std::dynamic_pointer_cast<GeomAPI_Edge>(theWire);
if (anEdge) {
std::list<std::shared_ptr<GeomAPI_Shape> > aList;
aList.push_back(anEdge);
- createFaces(theOrigin, theDirX, theNorm, aList, theResultFaces);
+ build(theOrigin, theDirX, theNorm, aList);
}
}
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef GeomAlgoAPI_SketchBuilder_H_
#define GeomAlgoAPI_SketchBuilder_H_
#include <GeomAlgoAPI.h>
+ #include <GeomAlgoAPI_MakeShape.h>
#include <memory>
#include <list>
- #include <GeomAPI_Dir.h>
- #include <GeomAPI_Pnt.h>
- #include <GeomAPI_Shape.h>
+ class GeomAPI_Dir;
+ class GeomAPI_Pln;
+ class GeomAPI_Pnt;
+ class GeomAPI_Shape;
/** \class GeomAlgoAPI_SketchBuilder
* \ingroup DataAlgo
* \brief Creates planar faces based on the list of Sketch features
*/
- class GEOMALGOAPI_EXPORT GeomAlgoAPI_SketchBuilder
+ class GeomAlgoAPI_SketchBuilder : public GeomAlgoAPI_MakeShape
{
- public:
- /** \brief Creates list of faces based on the features of the sketch
- * \param[in] theOrigin origin point of the sketch
- * \param[in] theDirX x-direction of the sketch
- * \param[in] theNorm normal of the sketch
- * \param[in] theFeatures initial features of the sketch
- * \param[out] theResultFaces faces based on closed wires
+ public:
+ /** \brief Creates list of faces based on the edges of the sketch
+ * \param[in] thePlane plane of the sketch
+ * \param[in] theEdges initial edges of the sketch
*
* The algorithm searches all loops of edges surrounding lesser areas.
*/
- static void createFaces(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
- const std::shared_ptr<GeomAPI_Dir>& theDirX,
- const std::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::list<std::shared_ptr<GeomAPI_Shape> >& theFeatures,
- std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces);
+ GEOMALGOAPI_EXPORT
+ GeomAlgoAPI_SketchBuilder(const std::shared_ptr<GeomAPI_Pln>& thePlane,
+ const std::list<std::shared_ptr<GeomAPI_Shape> >& theEdges);
/** \brief Creates list of faces and unclosed wires on basis of the features of the sketch
* \param[in] theOrigin origin point of the sketch
* \param[in] theDirX x-direction of the sketch
* \param[in] theNorm normal of the sketch
* \param[in] theWire a wire which contains all edges
- * \param[out] theResultFaces faces based on closed wires
*
* The algorithm searches all loops of edges surrounding lesser areas.
*/
- static void createFaces(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
- const std::shared_ptr<GeomAPI_Dir>& theDirX,
- const std::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::shared_ptr<GeomAPI_Shape>& theWire,
- std::list<std::shared_ptr<GeomAPI_Shape> >& theResultFaces);
+ GEOMALGOAPI_EXPORT
+ GeomAlgoAPI_SketchBuilder(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const std::shared_ptr<GeomAPI_Dir>& theDirX,
+ const std::shared_ptr<GeomAPI_Dir>& theNorm,
+ const std::shared_ptr<GeomAPI_Shape>& theWire);
+
+ /// Return list of created faces
+ GEOMALGOAPI_EXPORT const std::list<std::shared_ptr<GeomAPI_Shape> >& faces() const
+ { return myResultFaces; }
+
+ private:
+ void build(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const std::shared_ptr<GeomAPI_Dir>& theDirX,
+ const std::shared_ptr<GeomAPI_Dir>& theNorm,
+ const std::list<std::shared_ptr<GeomAPI_Shape> >& theEdges);
+
+ private:
+ std::list<std::shared_ptr<GeomAPI_Shape> > myResultFaces;
};
#endif
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_UnifySameDomain.h"
// Make compound.
GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(theShapes);
- ListOfShape aCombined, aFree;
+ ListOfShape aResults;
GeomAlgoAPI_ShapeTools::combineShapes(
aCompound,
GeomAPI_Shape::SHELL,
- aCombined,
- aFree);
+ aResults);
- if(aFree.size() > 0 || aCombined.size() > 1) {
+ if(aResults.size() > 1 ||
+ (aResults.size() == 1 && aResults.front()->shapeType() > GeomAPI_Shape::SHELL)) {
return;
}
- const TopoDS_Shape& aShell = aCombined.front()->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aShell = aResults.front()->impl<TopoDS_Shape>();
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aShell));
const ShapeUpgrade_UnifySameDomain& aUnifyAlgo = this->impl<ShapeUpgrade_UnifySameDomain>();
for (int aIsModified = 0; aIsModified <= 1; aIsModified++) {
+ if (!aUnifyAlgo.History()->IsSupportedType(aShape)) // to avoid crash in BRepTools_History
+ continue;
const TopTools_ListOfShape& aMList = aIsModified ?
aUnifyAlgo.History()->Modified(aShape) : aUnifyAlgo.History()->Generated(aShape);
for (TopTools_ListIteratorOfListOfShape aModified(aMList); aModified.More(); aModified.Next()) {
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "Model_AttributeSelection.h"
if (aWasWholeContext) {
theValShape = theOldContext->shape()->impl<TopoDS_Shape>();
}
+ TopAbs_ShapeEnum aValType = theValShape.ShapeType();
TopoDS_Shape aNewContShape = theNewContext->shape()->impl<TopoDS_Shape>();
// if a new value is unchanged in the new context, do nothing: value is correct
- TopExp_Explorer aSubExp(aNewContShape, theValShape.ShapeType());
+ TopExp_Explorer aSubExp(aNewContShape, aValType);
for(; aSubExp.More(); aSubExp.Next()) {
if (aSubExp.Current().IsSame(theValShape)) {
theShapes.Append(theValShape);
return;
}
// don't add edges generated from faces
- if (aPairIter.NewShape().ShapeType() <= theValShape.ShapeType())
+ if (aPairIter.NewShape().ShapeType() <= aValType)
theShapes.Append(aPairIter.NewShape());
}
} else if (!aPairIter.OldShape().IsNull()) { // search shape that contains this sub
- TopExp_Explorer anExp(aPairIter.OldShape(), theValShape.ShapeType());
+ TopExp_Explorer anExp(aPairIter.OldShape(), aValType);
for(; anExp.More(); anExp.Next()) {
if (anExp.Current().IsSame(theValShape)) { // found a new container
- if (aPairIter.NewShape().IsNull()) {// value was removed
- theShapes.Clear();
- return;
- }
+ if (aPairIter.NewShape().IsNull()) // skip removed high-level shape
+ continue;
aNewToOld.Bind(aPairIter.NewShape(), aPairIter.OldShape());
anOlds.Add(aPairIter.OldShape());
break;
}
}
if (aToFindPart == 2 && !aNewToOld.IsEmpty()) {
+ // also iterate the whole old shape to find not-modified shapes that contain this old
+ TopoDS_Shape anOldContShape = theOldContext->shape()->impl<TopoDS_Shape>();
+ NCollection_Map<TopAbs_ShapeEnum> aNewTypes; // types of shapes to iterate
+ TopTools_DataMapOfShapeShape::Iterator aNewTypeIter(aNewToOld);
+ for(; aNewTypeIter.More(); aNewTypeIter.Next()) {
+ if (aNewTypeIter.Key().ShapeType() != aValType)
+ aNewTypes.Add(aNewTypeIter.Key().ShapeType());
+ }
+ NCollection_Map<TopAbs_ShapeEnum>::Iterator aTypeIter(aNewTypes);
+ for(; aTypeIter.More(); aTypeIter.Next()) {
+ for(TopExp_Explorer anExp(anOldContShape, aTypeIter.Value()); anExp.More(); anExp.Next()) {
+ TopoDS_Shape anOld = anExp.Current();
+ if (aNewToOld.IsBound(anOld) || anOlds.Contains(anOld)) // this was modified
+ continue;
+ TopExp_Explorer aValExp(anOld, aValType);
+ for(; aValExp.More(); aValExp.Next()) {
+ const TopoDS_Shape& anUnchanged = aValExp.Current();
+ if (anUnchanged.IsSame(theValShape)) {
+ aNewToOld.Bind(anOld, anOld);
+ anOlds.Add(anOld);
+ break;
+ }
+ }
+ }
+ }
+
// map of sub-shapes -> number of occurrences of these shapes in containers
NCollection_DataMap<TopoDS_Shape, TopTools_MapOfShape, TopTools_ShapeMapHasher> aSubs;
TopTools_DataMapOfShapeShape::Iterator aContIter(aNewToOld);
for(; aContIter.More(); aContIter.Next()) {
- TopExp_Explorer aSubExp(aContIter.Key(), theValShape.ShapeType());
+ TopExp_Explorer aSubExp(aContIter.Key(), aValType);
for(; aSubExp.More(); aSubExp.Next()) {
if (!aSubs.IsBound(aSubExp.Current())) {
aSubs.Bind(aSubExp.Current(), TopTools_MapOfShape());
aSubsIter(aSubs);
for(; aSubsIter.More(); aSubsIter.Next()) {
if (aSubsIter.Value().Size() == aCountInOld) {
- theShapes.Append(aSubsIter.Key());
+ TopoDS_Shape anOld = aSubsIter.Key();
+ // check this exists in the new shape
+ TopExp_Explorer aNew(aNewContShape, anOld.ShapeType());
+ for (; aNew.More(); aNew.Next()) {
+ if (aNew.Current().IsSame(anOld))
+ break;
+ }
+ if (aNew.More())
+ theShapes.Append(anOld);
}
}
}
if (theShapes.IsEmpty()) { // nothing was changed
- theShapes.Append(aWasWholeContext ? TopoDS_Shape() : theValShape);
+ if (aWasWholeContext)
+ theShapes.Append(TopoDS_Shape());
+ else { // if theValShape exists in new context, add it without changes, otherwise - nothing
+ for (TopExp_Explorer aNew(aNewContShape, aValType); aNew.More(); aNew.Next()){
+ if (aNew.Current().IsSame(theValShape)) {
+ theShapes.Append(theValShape);
+ break;
+ }
+ }
+ }
+ } else if (theShapes.Size() > 1) {
+ // check it is possible to remove extra sub-shapes:
+ // keep only shapes with the same number of containers if possible
+ TopAbs_ShapeEnum anAncType = TopAbs_FACE;
+ if (aValType == TopAbs_VERTEX)
+ anAncType = TopAbs_EDGE;
+ TopoDS_Shape anOldContext = theOldContext->shape()->impl<TopoDS_Shape>();
+ TopTools_IndexedDataMapOfShapeListOfShape anOldMap;
+ TopExp::MapShapesAndUniqueAncestors(anOldContext, aValType, anAncType, anOldMap);
+ if (anOldMap.Contains(theValShape)) {
+ int aNumInOld = anOldMap.FindFromKey(theValShape).Extent();
+ TopTools_IndexedDataMapOfShapeListOfShape aNewMap;
+ TopExp::MapShapesAndUniqueAncestors(aNewContShape, aValType, anAncType, aNewMap);
+ TopTools_ListOfShape aNewResults;
+ for(TopTools_ListOfShape::Iterator aNewSubs(theShapes); aNewSubs.More(); aNewSubs.Next()) {
+ TopoDS_Shape aCand = aNewSubs.Value();
+ if (aNewMap.Contains(aCand) && aNewMap.FindFromKey(aCand).Extent() == aNumInOld)
+ aNewResults.Append(aCand);
+ }
+ if (!aNewResults.IsEmpty() && aNewResults.Size() < theShapes.Size())
+ theShapes = aNewResults;
+ }
}
}
std::list<ResultPtr>& theResults, TopTools_ListOfShape& theValShapes)
{
std::set<ResultPtr> aResults; // to avoid duplicates, new context, null if deleted
- TopTools_ListOfShape aResContShapes;
// iterate context and shape, but also if it is sub-shape of main shape, check also it
TopTools_ListOfShape aContextList;
aContextList.Append(theContShape);
aModifIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNewNS);
if (aNewNS->Evolution() == TNaming_MODIFY || aNewNS->Evolution() == TNaming_GENERATED) {
aResults.insert(aModifierObj);
- aResContShapes.Append(aModifierObj->shape()->impl<TopoDS_Shape>());
} else if (aNewNS->Evolution() == TNaming_DELETE) { // a shape was deleted => result is empty
aResults.insert(ResultPtr());
} else { // not-processed modification => don't support it
}
}
}
- if (aResults.empty())
+ // if there exist context composite and sub-result(s), leave only sub(s)
+ for(std::set<ResultPtr>::iterator aResIter = aResults.begin(); aResIter != aResults.end();) {
+ ResultPtr aParent = ModelAPI_Tools::bodyOwner(*aResIter);
+ for(; aParent.get(); aParent = ModelAPI_Tools::bodyOwner(aParent))
+ if (aResults.count(aParent))
+ break;
+ if (aParent.get()) { // erase from set, so, restart iteration
+ aResults.erase(aParent);
+ aResIter = aResults.begin();
+ } else aResIter++;
+ }
+
+ if (aResults.empty()) {
+ // check the context become concealed by operation which is earlier than this selection
+ std::list<ResultPtr> allRes;
+ ResultPtr aRoot = ModelAPI_Tools::bodyOwner(theContext, true);
+ if (!aRoot.get())
+ aRoot = theContext;
+ ResultBodyPtr aRootBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRoot);
+ if (aRootBody.get()) {
+ ModelAPI_Tools::allSubs(aRootBody, allRes);
+ allRes.push_back(aRootBody);
+ } else
+ allRes.push_back(aRoot);
+
+ FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ for (std::list<ResultPtr>::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) {
+ ResultPtr aResCont = *aSub;
+ const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
+ for (; aRef != aRefs.end(); aRef++) {
+ if (!aRef->get() || !(*aRef)->owner().get())
+ continue;
+ // concealed attribute only
+ FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
+ if (aRefFeat == aThisFeature)
+ continue;
+ if (!ModelAPI_Session::get()->validators()->isConcealed(
+ aRefFeat->getKind(), (*aRef)->id()))
+ continue;
+ if (theDoc->isLaterByDep(aThisFeature, aRefFeat)) {
+ // for extrusion cut in python script the nested sketch reference may be concealed before
+ // it is nested, so, check this composite feature is valid
+ static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
+ // need to be validated to update the "Apply" state if not previewed
+ if (aFactory->validate(aRefFeat))
+ return true; // feature conceals result, return true, so the context will be removed
+ }
+ }
+ }
return false; // no modifications found, must stay the same
+ }
// iterate all results to find further modifications
std::set<ResultPtr>::iterator aResIter = aResults.begin();
for(; aResIter != aResults.end(); aResIter++) {
return true; // theResults must be empty: everything is deleted
}
- void Model_AttributeSelection::updateInHistory()
+ void Model_AttributeSelection::updateInHistory(bool& theRemove)
{
ResultPtr aContext = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
// only bodies and parts may be modified later in the history, don't do anything otherwise
continue;
FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
- if (aRefFeat.get() && aRefFeat != owner()) {
+ if (aRefFeat.get() && aRefFeat != owner() && aRefFeat->firstResult().get()) {
FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
if (!aDoc->isLaterByDep(aRefFeat, aThisFeature)) { // found better feature
aFoundNewContext = true;
TopTools_ListOfShape aValShapes;
if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes))
{
+ std::set<ResultPtr> allContexts, aSkippedContext;
+ std::list<ResultPtr>::iterator aNewContext = aNewContexts.begin();
+ for(; aNewContext != aNewContexts.end(); aNewContext++)
+ allContexts.insert(*aNewContext);
+
+ // if there exist context composite and sub-result(s), leave only sub(s)
+ std::set<ResultPtr>::iterator aResIter = allContexts.begin();
+ for(; aResIter != allContexts.end(); aResIter++) {
+ ResultPtr aParent = ModelAPI_Tools::bodyOwner(*aResIter);
+ for(; aParent.get(); aParent = ModelAPI_Tools::bodyOwner(aParent))
+ if (allContexts.count(aParent))
+ aSkippedContext.insert(aParent);
+ }
+
GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE;
if (myParent) {
- if (myParent->selectionType() == "VERTEX") aListShapeType = GeomAPI_Shape::VERTEX;
- else if (myParent->selectionType() == "EDGE") aListShapeType = GeomAPI_Shape::EDGE;
- else if (myParent->selectionType() == "FACE") aListShapeType = GeomAPI_Shape::FACE;
+ if (myParent->selectionType() == "VERTEX" || myParent->selectionType() == "Vertices")
+ aListShapeType = GeomAPI_Shape::VERTEX;
+ else if (myParent->selectionType() == "EDGE" || myParent->selectionType() == "Edges")
+ aListShapeType = GeomAPI_Shape::EDGE;
+ else if (myParent->selectionType() == "FACE" || myParent->selectionType() == "Faces")
+ aListShapeType = GeomAPI_Shape::FACE;
}
std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
bool aFirst = true; // first is set to this, next are appended to parent
for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) {
+ if (aSkippedContext.count(*aNewCont))
+ continue;
GeomShapePtr aValueShape;
if (!aNewValues.Value().IsNull()) {
continue;
}
- ResultPtr aSetContext;
if (aFirst) {
setValue(*aNewCont, aValueShape);
- aSetContext = context();
+ aFirst = false;
} else if (myParent) {
- myParent->append(*aNewCont, aValueShape);
- aSetContext = myParent->value(myParent->size() - 1)->context();
- }
-
- // #2826 : error if context is concealed by new context where the value is not presented
- if (aSetContext.get()) {
- bool anError = false;
- std::list<ResultPtr> allRes;
- ResultPtr aCompContext;
- ResultBodyPtr aCompBody = ModelAPI_Tools::bodyOwner(aSetContext, true);
- if (aCompBody.get()) {
- ModelAPI_Tools::allSubs(aCompBody, allRes);
- allRes.push_back(aCompBody);
- aCompContext = aCompBody;
- }
- if (allRes.empty())
- allRes.push_back(aSetContext);
-
- std::list<ResultPtr>::iterator aSub = allRes.begin();
- for (; !anError && aSub != allRes.end(); aSub++) {
- ResultPtr aResCont = *aSub;
- ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResCont);
- const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
- std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
- for (; aRef != aRefs.end(); aRef++) {
- if (!aRef->get() || !(*aRef)->owner().get())
- continue;
- // concealed attribute only
- FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
- if (!aRefFeat.get())
- continue;
- if (!ModelAPI_Session::get()->validators()->isConcealed(
- aRefFeat->getKind(), (*aRef)->id()))
- continue;
- // check the found feature is older than this attribute
- if (aRefFeat == aThisFeature || aDoc->isLaterByDep(aRefFeat, aThisFeature))
- continue;
- // check the found feature don't have the value-shape
- GeomShapePtr aValue = aFirst ? value() : myParent->value(myParent->size() - 1)->value();
- if (aValue.get()) {
- std::list<ResultPtr>::const_iterator aRefResults = aRefFeat->results().cbegin();
- for(; aRefResults != aRefFeat->results().cend(); aRefResults++) {
- if ((*aRefResults)->shape().get() &&
- !(*aRefResults)->shape()->isSubShape(aValue, false)) { // set error
- ResultPtr anEmptyContext;
- std::shared_ptr<GeomAPI_Shape> anEmptyShape;
- if (aFirst) {
- setValue(anEmptyContext, anEmptyShape); // nullify the selection
- } else {
- myParent->value(myParent->size() - 1)->setValue(anEmptyContext, anEmptyShape);
- }
- Events_InfoMessage("Model_AttributeSelection",
- "Selection of sub-shape of already modified result").send();
- anError = true;
- break;
- }
- }
- if (anError)
- break;
- }
- }
- }
+ if (!myParent->isInList(*aNewCont, aValueShape)) // avoid addition of duplicates
+ myParent->append(*aNewCont, aValueShape);
}
- aFirst = false;
}
if (aFirst) { // nothing was added, all results were deleted
- ResultPtr anEmptyContext;
- std::shared_ptr<GeomAPI_Shape> anEmptyShape;
- setValue(anEmptyContext, anEmptyShape); // nullify the selection
- return;
+ if (myParent) {
+ theRemove = true;
+ } else {
+ ResultPtr anEmptyContext;
+ std::shared_ptr<GeomAPI_Shape> anEmptyShape;
+ setValue(anEmptyContext, anEmptyShape); // nullify the selection
+ return;
+ }
}
}
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef Model_AttributeSelection_H_
/// Updates the arguments of selection if something was affected by creation
/// or reorder of features upper in the history line (issue #1757)
- MODEL_EXPORT virtual void updateInHistory();
+ /// Returns theRemove true if this attribute must be removed (become deleted)
+ MODEL_EXPORT virtual void updateInHistory(bool& theRemove);
// Implementation of the name generator method from the Selector package
// This method returns the context name by the label of the sub-selected shape
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef MODEL_ATTRIBUTESTRING_H_
public:
/// Defines the std::string value
MODEL_EXPORT virtual void setValue(const std::string& theValue);
+ /// Defines the std::wstring value
+ MODEL_EXPORT virtual void setValue(const std::wstring& theValue);
/// Returns the std::string value
MODEL_EXPORT virtual std::string value();
+ /// Returns the std::wstring value
+ MODEL_EXPORT virtual std::wstring valueW();
protected:
- /// Initializes attibutes
+ /// Initializes attributes
Model_AttributeString(TDF_Label& theLabel);
/// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
virtual void reinit();
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Model_BodyBuilder.h>
{
}
+ /// Checks that shape is presented in the tree with not-selection evolution
+ /// In theOriginalLabel it returns label where NS of old sub-shape is stored
+ static bool isShapeInTree(const TDF_Label& theAccess1, const TDF_Label& theAccess2,
+ TopoDS_Shape theShape, TDF_Label& theOriginalLabel)
+ {
+ bool aResult = TNaming_Tool::HasLabel(theAccess1, theShape);
+ if (aResult) { //check evolution and a label of this shape
+ for(TNaming_SameShapeIterator aShapes(theShape, theAccess1); aShapes.More(); aShapes.Next())
+ {
+ static Handle(TNaming_NamedShape) aNS;
+ if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
+ if (aNS->Evolution() != TNaming_SELECTED) {
+ theOriginalLabel = aNS->Label();
+ return true;
+ }
+ }
+ }
+ }
+ if (!theAccess2.IsNull()) {
+ static const TDF_Label anEmpty;
+ return isShapeInTree(theAccess2, anEmpty, theShape, theOriginalLabel);
+ }
+ return false;
+ }
+
+ /// Stores entry to the external label in the entries list at this label
+ static void storeExternalReference(const TDF_Label& theExternal, const TDF_Label theThis)
+ {
+ // store information about the external document reference to restore old shape on open
+ if (!theExternal.IsNull() && !theExternal.Root().IsEqual(theThis.Root())) {
+ Handle(TDataStd_ExtStringList) anEntries;
+ if (!theThis.FindAttribute(kEXTERNAL_SHAPE_REF, anEntries)) {
+ anEntries = TDataStd_ExtStringList::Set(theThis, kEXTERNAL_SHAPE_REF);
+ }
+ TCollection_AsciiString anEntry;
+ TDF_Tool::Entry(theExternal, anEntry);
+ // check it already contains this entry
+ TDataStd_ListOfExtendedString::Iterator anIter(anEntries->List());
+ for(; anIter.More(); anIter.Next())
+ if (anIter.Value() == anEntry)
+ break;
+ if (!anIter.More()) {
+ anEntries->Append(anEntry);
+ }
+ }
+ }
+
void Model_BodyBuilder::store(const GeomShapePtr& theShape,
const bool theIsStoreSameShapes)
{
}
void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape,
- const GeomShapePtr& theToShape)
+ const GeomShapePtr& theToShape, const bool theIsCleanStored)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
TDF_Label aShapeLab = aData->shapeLab();
// clean builders
- clean();
- // store the new shape as primitive
- TNaming_Builder aBuilder(aShapeLab);
+ if (theIsCleanStored)
+ clean();
+ TNaming_Builder* aBuilder = builder(0);
if (!theFromShape || !theToShape)
return; // bad shape
TopoDS_Shape aShapeBasis = theFromShape->impl<TopoDS_Shape>();
TopoDS_Shape aShapeNew = theToShape->impl<TopoDS_Shape>();
if (aShapeNew.IsNull())
return; // null shape inside
- aBuilder.Generated(aShapeBasis, aShapeNew);
+
+ // There is no sense to write history if old shape does not exist in the document.
+ TDF_Label anAccess2 = std::dynamic_pointer_cast<Model_Document>(
+ ModelAPI_Session::get()->moduleDocument())->generalLabel();
+ TDF_Label anOriginalLabel;
+ if (!isShapeInTree(aData->shapeLab(), anAccess2, aShapeBasis, anOriginalLabel)) {
+ if (aBuilder->NamedShape()->Get().IsNull()) { // store as primitive if alone anyway
+ aBuilder->Generated(aShapeNew);
+ }
+ } else {
+ if (aBuilder->NamedShape()->Evolution() == TNaming_PRIMITIVE) { // erase primitive before
+ myBuilders.erase(0);
+ aBuilder = builder(0);
+ }
+
+ aBuilder->Generated(aShapeBasis, aShapeNew);
+ // store information about the external document reference to restore old shape on open
+ storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label());
+ }
+
// register name
- if(!aBuilder.NamedShape()->IsEmpty()) {
+ if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
- if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+ if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+ aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
}
}
}
}
}
+ void Model_BodyBuilder::storeGenerated(const std::list<GeomShapePtr>& theFromShapes,
+ const GeomShapePtr& theToShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+ {
+ bool aStored = false;
+ std::list<GeomShapePtr>::const_iterator anOldIter = theFromShapes.cbegin();
+ for (; anOldIter != theFromShapes.cend(); anOldIter++) {
+ bool aStore = (*anOldIter)->isCompound() || (*anOldIter)->isShell() || (*anOldIter)->isWire();
+ if (!aStore) {
+ ListOfShape aNews; // check this old really generates theToShape
+ theMakeShape->generated(*anOldIter, aNews);
+ ListOfShape::iterator aNewIter = aNews.begin();
+ for (; aNewIter != aNews.end(); aNewIter++) {
+ if (theToShape->isSame(*aNewIter))
+ break;
+ }
+ aStore = aNewIter != aNews.end();
+ }
+ if (aStore) {
+ storeGenerated(*anOldIter, theToShape, !aStored);
+ TNaming_Builder* aBuilder = builder(0);
+ aStored = !aBuilder->NamedShape()->IsEmpty();
+ }
+ }
+ if (!aStored) { // store as PRIMITIVE, but clean in any way
+ store(theToShape);
+ return;
+ }
+ }
+
TNaming_Builder* Model_BodyBuilder::builder(const int theTag)
{
std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
if (aData) {
// clean builders
if (theIsCleanStored) clean();
- // store the new shape as primitive
TNaming_Builder* aBuilder = builder(0);
if (!theOldShape || !theNewShape)
return; // bad shape
TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
if (aShapeNew.IsNull())
return; // null shape inside
- aBuilder->Modify(aShapeOld, aShapeNew);
+
+ // There is no sense to write history if old shape does not exist in the document.
+ TDF_Label anAccess2 = std::dynamic_pointer_cast<Model_Document>(
+ ModelAPI_Session::get()->moduleDocument())->generalLabel();
+ TDF_Label anOriginalLabel;
+ if (!isShapeInTree(aData->shapeLab(), anAccess2, aShapeOld, anOriginalLabel)) {
+ if (aBuilder->NamedShape()->Get().IsNull()) { // store as primitive if alone anyway
+ aBuilder->Generated(aShapeNew);
+ }
+ } else {
+ if (aBuilder->NamedShape()->Evolution() == TNaming_PRIMITIVE) { // erase primitive before
+ myBuilders.erase(0);
+ aBuilder = builder(0);
+ }
+
+ aBuilder->Modify(aShapeOld, aShapeNew);
+ // store information about the external document reference to restore old shape on open
+ storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label());
+ }
+
if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
- if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+ if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
}
}
+ void Model_BodyBuilder::storeModified(const std::list<GeomShapePtr>& theOldShapes,
+ const GeomShapePtr& theNewShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+ {
+ bool aStored = false;
+ std::list<GeomShapePtr>::const_iterator anOldIter = theOldShapes.cbegin();
+ for(; anOldIter != theOldShapes.cend(); anOldIter++) {
+ // compounds may cause crash if call "modified"
+ bool aStore = (*anOldIter)->isCompound() || (*anOldIter)->isShell() || (*anOldIter)->isWire();
+ if (!aStore) {
+ ListOfShape aNews; // check this old really modifies theNewShape
+ theMakeShape->modified(*anOldIter, aNews);
+ ListOfShape::iterator aNewIter = aNews.begin();
+ for(; aNewIter != aNews.end(); aNewIter++) {
+ if (theNewShape->isSame(*aNewIter))
+ break;
+ }
+ aStore = aNewIter != aNews.end();
+ }
+ if (aStore) {
+ storeModified(*anOldIter, theNewShape, !aStored);
+ TNaming_Builder* aBuilder = builder(0);
+ aStored = !aBuilder->NamedShape()->IsEmpty();
+ }
+ }
+ if (!aStored) { // store as PRIMITIVE, but clean in any way
+ store(theNewShape);
+ return;
+ }
+ }
+
void Model_BodyBuilder::clean()
{
TDF_Label aLab = std::dynamic_pointer_cast<Model_Data>(data())->shapeLab();
}
}
- /// Checks that shape is presented in the tree with not-selection evolution
- /// In theOriginalLabel it returns label where NS of old sub-shape is stored
- static bool isShapeInTree(const TDF_Label& theAccess1, const TDF_Label& theAccess2,
- TopoDS_Shape theShape, TDF_Label& theOriginalLabel)
- {
- bool aResult = TNaming_Tool::HasLabel(theAccess1, theShape);
- if (aResult) { //check evolution and a label of this shape
- for(TNaming_SameShapeIterator aShapes(theShape, theAccess1); aShapes.More(); aShapes.Next())
- {
- static Handle(TNaming_NamedShape) aNS;
- if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
- if (aNS->Evolution() != TNaming_SELECTED) {
- theOriginalLabel = aNS->Label();
- return true;
- }
- }
- }
- }
- if (!theAccess2.IsNull()) {
- static const TDF_Label anEmpty;
- return isShapeInTree(theAccess2, anEmpty, theShape, theOriginalLabel);
- }
- return false;
- }
-
- /// Stores entry to the external label in the entries list at this label
- static void storeExternalReference(const TDF_Label& theExternal, const TDF_Label theThis)
- {
- // store information about the external document reference to restore old shape on open
- if (!theExternal.IsNull() && !theExternal.Root().IsEqual(theThis.Root())) {
- Handle(TDataStd_ExtStringList) anEntries;
- if (!theThis.FindAttribute(kEXTERNAL_SHAPE_REF, anEntries)) {
- anEntries = TDataStd_ExtStringList::Set(theThis, kEXTERNAL_SHAPE_REF);
- }
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(theExternal, anEntry);
- // check it already contains this entry
- TDataStd_ListOfExtendedString::Iterator anIter(anEntries->List());
- for(; anIter.More(); anIter.Next())
- if (anIter.Value() == anEntry)
- break;
- if (!anIter.More()) {
- anEntries->Append(anEntry);
- }
- }
- }
-
void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape);
bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false);
- if (aNewShapeIsSameAsOldShape
- || aNewShapeIsNotInResultShape)
- {
+ if (aNewShapeIsSameAsOldShape || aNewShapeIsNotInResultShape)
continue;
- }
- TNaming_Builder* aBuilder;
- if (aResultShape->isSame(aNewShape)) {
- // keep the modification evolution on the root level (2241 - history propagation issue)
- aBuilder = builder(0);
- TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
- Handle(TDF_Reference) aRef;
- if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
- // Store only in case if it does not have reference.
- continue;
- }
+ if (aResultShape->isSame(aNewShape))
+ continue; // it is stored on the root level (2241 - history propagation issue)
- // Check if new shape was already stored.
- if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
-
- if (!aBuilder->NamedShape().IsNull() &&
- ((isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_GENERATED)
- || (!isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_MODIFY)))
- {
- myBuilders.erase(0); // clear old builder to avoid different evolutions crash
- aBuilder = builder(0);
- }
- } else {
- int aTag = isGenerated ? getGenerationTag(aNewShape_)
- : getModificationTag(aNewShape_);
- aBuilder = builder(aTag);
-
- // Check if new shape was already stored.
- if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
-
- buildName(aTag, theName);
- }
+ int aTag = isGenerated ? getGenerationTag(aNewShape_) : getModificationTag(aNewShape_);
+ TNaming_Builder*aBuilder = builder(aTag);
+ if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_))
+ continue; // new shape was already stored.
+ buildName(aTag, theName);
isGenerated ? aBuilder->Generated(anOldSubShape_, aNewShape_)
: aBuilder->Modify(anOldSubShape_, aNewShape_);
// store information about the external document reference to restore old shape on open
void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName)
+ const std::string& theName,
+ const bool theSaveOldIfNotInTree)
{
GeomShapePtr aResultShape = shape();
TopTools_MapOfShape anAlreadyProcessedShapes;
bool anOldSubShapeNotInTree =
!isShapeInTree(aData->shapeLab(), anAccess2, anOldSubShape_, anOriginalLabel);
if (anOldSubShapeAlreadyProcessed || anOldSubShapeNotInTree) {
- continue;
+ if (theSaveOldIfNotInTree) {
+ std::string aSelectionName = theName + "Selected";
+ generated(anOldSubShape, aSelectionName, false);
+ } else
+ continue;
}
// Get new shapes.
continue;
}
+ if (aResultShape->isSame(aNewShape))
+ continue; // it is stored on the root level
+
TopAbs_ShapeEnum aNewShapeType = aNewShape_.ShapeType();
if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
// TODO: This is a workaround. New shape should be only edge or face.
storeExternalReference(anOriginalLabel, builder(aTag)->NamedShape()->Label());
}
buildName(aTag, theName);
- } if (aResultShape->isSame(aNewShape)) {
- // keep the generation evolution on the root level (2397 - for intersection feature)
- TNaming_Builder* aBuilder = builder(0);
- TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
- Handle(TDF_Reference) aRef;
- if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
- // Store only in case if it does not have reference.
- continue;
- }
-
- // Check if new shape was already stored.
- if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
-
- if (!aBuilder->NamedShape().IsNull() &&
- aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) {
- myBuilders.erase(0); // clear old builder to avoid different evolutions crash
- aBuilder = builder(0);
- }
- aBuilder->Generated(anOldSubShape_, aNewShape_);
} else {
int aTag = getGenerationTag(aNewShape_);
if (aTag == INVALID_TAG) return;
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef Model_BodyBuilder_H_
public:
/// Stores the shape (called by the execution method).
MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
- const bool theIsStoreSameShapes = true);
+ const bool theIsStoreSameShapes = true) override;
/// Stores the generated shape (called by the execution method).
MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
- const GeomShapePtr& theToShape);
+ const GeomShapePtr& theToShape,
+ const bool theIsCleanStored = true) override;
+
+ /// Stores the root generated shapes (called by the execution method).
+ MODEL_EXPORT virtual void storeGenerated(const std::list<GeomShapePtr>& theFromShapes,
+ const GeomShapePtr& theToShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) override;
/// Stores the modified shape (called by the execution method).
/// \param theOldShape shape that produces result
/// \param theNewShape resulting shape
- /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
- /// theNewShape is compound of solids, if zero it is not used
+ /// \param theIsCleanStored erases all previous data structure of this body if true
MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true) override;
+ /// Stores the root modified shape (called by the execution method).
+ /// \param theOldShapes all shapes that produce result
+ /// \param theNewShape resulting shape
+ /// \param theIsCleanStored erases all previous data structure of this body if true
+ MODEL_EXPORT virtual void storeModified(const std::list<GeomShapePtr>& theOldShapes,
+ const GeomShapePtr& theNewShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) override;
+
/// Returns the shape-result produced by this feature
MODEL_EXPORT virtual GeomShapePtr shape();
virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName = "") override;
+ const std::string& theName = "",
+ const bool theSaveOldIfNotInTree = false) override;
/// Loads shapes of the first level (to be used during shape import)
MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Model_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <Model_Data.h>
#include <Events_Loop.h>
+ #include <GeomAPI_ShapeIterator.h>
+ #include <GeomAPI_ShapeExplorer.h>
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
+ #include <TopTools_MapOfShape.hxx>
#include <TDataStd_UAttribute.hxx>
// if this attribute exists, the shape is connected topology
void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName)
+ const std::string& theName,
+ const bool theSaveOldIfNotInTree)
{
if (mySubs.size()) { // consists of subs
for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
++aSubIter)
{
const ResultBodyPtr& aSub = *aSubIter;
- aSub->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+ aSub->loadGeneratedShapes(
+ theAlgo, theOldShape, theShapeTypeToExplore, theName, theSaveOldIfNotInTree);
}
} else { // do for this directly
- myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+ myBuilder->loadGeneratedShapes(
+ theAlgo, theOldShape, theShapeTypeToExplore, theName, theSaveOldIfNotInTree);
}
}
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
const std::string& theName)
{
- if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs
+ if (mySubs.size()) { // consists of subs
// optimization of getting of new shapes for specific sub-result
if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore))
theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore);
std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
for(; aSubIter != mySubs.cend(); aSubIter++) {
- // check that sub-shape was also created as modification of ShapeIn
- /* to find when it is needed later to enable: to store modification of sub-bodies not only as primitives
- GeomShapePtr aSubGeomShape = (*aSubIter)->shape();
- if (!theIsStoreAsGenerated && aSubGeomShape.get() && !aSubGeomShape->isNull()) {
- TopoDS_Shape aSubShape = aSubGeomShape->impl<TopoDS_Shape>();
- TopoDS_Shape aWholeIn = theShapeIn->impl<TopoDS_Shape>();
- for(TopExp_Explorer anExp(aWholeIn, aSubShape.ShapeType()); anExp.More(); anExp.Next()) {
- ListOfShape aHistory;
- std::shared_ptr<GeomAPI_Shape> aSubIn(new GeomAPI_Shape());
- aSubIn->setImpl((new TopoDS_Shape(anExp.Current())));
- theMS->modified(aSubIn, aHistory);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aHistory.begin();
- for (; anIt != aHistory.end(); anIt++) {
- if ((*anIt)->isSame(aSubGeomShape)) {
- (*aSubIter)->storeModified(aSubIn, aSubGeomShape, -2); // -2 is to avoid clearing
- }
- }
- }
- }*/
(*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
} else { // do for this directly
}
GeomShapePtr anOldSubShape = aSub->shape();
if (!aShape->isEqual(anOldSubShape)) {
- aSub->store(aShape, false);
+ if (myAlgo.get()) {
+ std::list<GeomShapePtr> anOldForSub;
+ computeOldForSub(aShape, myOlds, anOldForSub);
+ myIsGenerated ? aSub->storeGenerated(anOldForSub, aShape, myAlgo) :
+ aSub->storeModified(anOldForSub, aShape, myAlgo);
+ } else {
+ aSub->store(aShape, false);
+ }
aECreator->sendUpdated(aSub, EVENT_DISP);
aECreator->sendUpdated(aSub, EVENT_UPD);
}
}
}
+ void Model_ResultBody::updateSubs(
+ const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated)
+ {
+ myAlgo = theMakeShape;
+ myOlds = theOlds;
+ myIsGenerated = isGenerated;
+ // to avoid changing of "isDisabled" flag in the "updateSubs" cycle
+ isDisabled();
+
+ updateSubs(theThisShape, true);
+ myAlgo.reset();
+ myOlds.clear();
+ myHistoryCash.Clear();
+ }
+
+
bool Model_ResultBody::isConnectedTopology()
{
TDF_Label aDataLab = std::dynamic_pointer_cast<Model_Data>(data())->label();
aSub->cleanCash();
}
}
+
+ // adds to the theSubSubs map all sub-shapes of theSub if it is compound of compsolid
+ static void collectSubs(
+ const GeomShapePtr theSub, TopTools_MapOfShape& theSubSubs, const bool theOneLevelMore)
+ {
+ if (theSub->isNull())
+ return;
+ if (theSubSubs.Add(theSub->impl<TopoDS_Shape>())) {
+ bool aIsComp = theSub->isCompound() || theSub->isCompSolid();
+ if (aIsComp) {
+ for(GeomAPI_ShapeIterator anIter(theSub); anIter.more(); anIter.next())
+ collectSubs(anIter.current(), theSubSubs, theOneLevelMore);
+ } else if (theOneLevelMore) {
+ GeomAPI_Shape::ShapeType aSubType = GeomAPI_Shape::ShapeType(int(theSub->shapeType()) + 1);
+ if (aSubType == GeomAPI_Shape::SHAPE)
+ return;
+ if (aSubType == GeomAPI_Shape::SHELL)
+ aSubType = GeomAPI_Shape::FACE;
+ if (aSubType == GeomAPI_Shape::WIRE)
+ aSubType = GeomAPI_Shape::EDGE;
+
+ for(GeomAPI_ShapeExplorer anExp(theSub, aSubType); anExp.more(); anExp.next()) {
+ collectSubs(anExp.current(), theSubSubs, false);
+ }
+ }
+ }
+ }
+
+ void Model_ResultBody::computeOldForSub(const GeomShapePtr& theSub,
+ const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub)
+ {
+ // the old can be also used for sub-shape of theSub; collect all subs of compound or compsolid
+ TopTools_MapOfShape aSubSubs;
+ collectSubs(theSub, aSubSubs, false);
+
+ std::list<GeomShapePtr>::const_iterator aRootOlds = theAllOlds.cbegin();
+ for (; aRootOlds != theAllOlds.cend(); aRootOlds++) {
+ // use sub-shapes of olds too if they are compounds or compsolids
+ TopTools_MapOfShape anOldSubs;
+ // iterate one level more (for intersection of solids this is face)
+ collectSubs(*aRootOlds, anOldSubs, true);
+ for (TopTools_MapOfShape::Iterator anOldIter(anOldSubs); anOldIter.More(); anOldIter.Next()) {
+ TopoDS_Shape anOldShape = anOldIter.Value();
+ if (anOldShape.ShapeType() == TopAbs_COMPOUND || anOldShape.ShapeType() == TopAbs_SHELL ||
+ anOldShape.ShapeType() == TopAbs_WIRE)
+ continue; // container old-shapes are not supported by the history, may cause crash
+ GeomShapePtr anOldSub(new GeomAPI_Shape);
+ anOldSub->setImpl<TopoDS_Shape>(new TopoDS_Shape(anOldShape));
+
+ ListOfShape aNews;
+ if (myHistoryCash.IsBound(anOldShape)) {
+ const TopTools_ListOfShape& aList = myHistoryCash.Find(anOldShape);
+ for(TopTools_ListIteratorOfListOfShape anIter(aList); anIter.More(); anIter.Next()) {
+ GeomShapePtr aShape(new GeomAPI_Shape);
+ aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(anIter.Value()));
+ aNews.push_back(aShape);
+ }
+ } else {
+ myIsGenerated ? myAlgo->generated(anOldSub, aNews) : myAlgo->modified(anOldSub, aNews);
+ // MakeShape may return alone old shape if there is no history information for this input
+ if (aNews.size() == 1 && aNews.front()->isEqual(anOldSub))
+ aNews.clear();
+ // store result in the history
+ TopTools_ListOfShape aList;
+ for (ListOfShape::iterator aNewIter = aNews.begin(); aNewIter != aNews.end(); aNewIter++) {
+ aList.Append((*aNewIter)->impl<TopoDS_Shape>());
+ }
+ myHistoryCash.Bind(anOldShape, aList);
+ }
+
+ for (ListOfShape::iterator aNewIter = aNews.begin(); aNewIter != aNews.end(); aNewIter++) {
+ if (aSubSubs.Contains((*aNewIter)->impl<TopoDS_Shape>())) {
+ // check list already contains this sub
+ std::list<GeomShapePtr>::iterator aResIter = theOldForSub.begin();
+ for(; aResIter != theOldForSub.end(); aResIter++)
+ if ((*aResIter)->isSame(anOldSub))
+ break;
+ if (aResIter == theOldForSub.end())
+ theOldForSub.push_back(anOldSub); // found old used for new theSubShape creation
+ break;
+ }
+ }
+ }
+ }
+ }
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef Model_ResultBody_H_
#include <vector>
#include <map>
+ #include <TopTools_DataMapOfShapeListOfShape.hxx>
+
/**\class Model_ResultBody
* \ingroup DataModel
* \brief The body (shape) result of a feature.
std::map<ObjectPtr, int> mySubsMap;
/// Keeps the last state of the concealment flag in order to update it when needed.
bool myLastConcealed;
+ /// History information for update subs
+ std::shared_ptr<GeomAlgoAPI_MakeShape> myAlgo;
+ /// All old shapes used for the root result construction
+ std::list<GeomShapePtr> myOlds;
+ /// Information about the kind of the history information: modified or generated
+ bool myIsGenerated;
+ /// Map from old shape to list of new shapes, cash for computeOldForSub method
+ TopTools_DataMapOfShapeListOfShape myHistoryCash;
public:
virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName = "") override;
+ const std::string& theName = "",
+ const bool theSaveOldIfNotInTree = false) override;
/// load modified shapes for sub-objects
MODEL_EXPORT
void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
const bool theShapeChanged = true);
+ /// Updates the sub-bodies in accordance to the algorithm history information
+ void updateSubs(
+ const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated);
+
// Checks the state of children and parents to send events of creation/erase when needed
void updateConcealment();
+ /// Adds to theOldForSub only old shapes that where used for theSub creation
+ void computeOldForSub(const GeomShapePtr& theSub,
+ const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub);
+
friend class Model_Objects;
};
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Model_ResultConstruction.h>
}
}
- std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
- GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
- aWirePtr->norm(), aWirePtr, aFaces);
+ GeomAlgoAPI_SketchBuilder aSketchBuilder(aWirePtr->origin(), aWirePtr->dirX(),
+ aWirePtr->norm(), aWirePtr);
+ const ListOfShape& aFaces = aSketchBuilder.faces();
// order is important to store faces in the same order if sketch is created from scratch
NCollection_IndexedDataMap<TopoDS_Face, TColStd_ListOfInteger> aNewIndices; // edges indices
- std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
+ std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator aFIter = aFaces.begin();
for (; aFIter != aFaces.end(); aFIter++) {
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
// put them to a label, trying to keep the same faces on the same labels
aNotFound += 1.;
}
}
- if (aNotFound < aBestNotFound) {
+ if (aNotFound <= aBestNotFound) { // less and equal to find better "found": #2859
if (aFound > aBestFound) {
aBestNotFound = aNotFound;
aBestFound = aFound;
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Model_Update.h>
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
const std::set<ObjectPtr>& anObjs = aMsg->objects();
std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
+ std::list<ObjectPtr> aFeatures, aResults;
for(; anObjIter != anObjs.cend(); anObjIter++) {
if (std::dynamic_pointer_cast<Model_Document>((*anObjIter)->document())->executeFeatures()) {
if ((*anObjIter)->groupName() == ModelAPI_Feature::group()) {
// results creation means enabling, not update
- ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kUpdatedEvent);
+ aFeatures.push_back(*anObjIter);
} else {
- ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kRedisplayEvent);
+ aResults.push_back(*anObjIter);
}
}
}
+ ModelAPI_EventCreator::get()->sendUpdated(aFeatures, kUpdatedEvent);
+ ModelAPI_EventCreator::get()->sendUpdated(aResults, kRedisplayEvent);
return;
}
if (theMessage->eventID() == kUpdatedEvent) {
if (aSelAttr) {
ObjectPtr aContext = aSelAttr->context();
// update argument only if the referenced object is ready to use
- if (aContext.get() && !aContext->isDisabled() && !aSelAttr->isInvalid()) {
+ if (aContext.get() && !aContext->isDisabled()) {
if (isReason(theFeature, aContext)) {
if (!aSelAttr->update()) {
bool isObligatory = !aFactory->isNotObligatory(
aState = ModelAPI_StateInvalidArgument;
}
}
- } else if (aContext.get() || aSelAttr->isInvalid()) {
+ } else if (aContext.get()) {
// here it may be not obligatory, but if the reference is wrong, it should not be correct
bool isObligatory = aFactory->isCase(theFeature, theFeature->data()->id(aSel));
if (isObligatory)
for (; aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<Model_AttributeSelection> aSel =
std::dynamic_pointer_cast<Model_AttributeSelection>(*aRefsIter);
- aSel->updateInHistory();
+ bool aRemove = false;
+ aSel->updateInHistory(aRemove);
}
// update the selection list attributes if any
aRefs = (*anObj)->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+ std::set<int> aRemoveSet;
std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
for(int a = aSel->size() - 1; a >= 0; a--) {
std::shared_ptr<Model_AttributeSelection> aSelAttr =
std::dynamic_pointer_cast<Model_AttributeSelection>(aSel->value(a));
- if (aSelAttr.get())
- aSelAttr->updateInHistory();
+ if (aSelAttr.get()) {
+ bool theRemove = false;
+ aSelAttr->updateInHistory(theRemove);
+ if (theRemove) {
+ aRemoveSet.insert(a);
+ }
+ }
}
+ aSel->remove(aRemoveSet);
}
}
}
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef ModelAPI_BodyBuilder_H_
/// Stores the generated shape (called by the execution method).
virtual void storeGenerated(const GeomShapePtr& theFromShape,
- const GeomShapePtr& theToShape) = 0;
+ const GeomShapePtr& theToShape,
+ const bool theIsCleanStored = true) = 0;
+
+ /// Stores the root generated shapes (called by the execution method).
+ virtual void storeGenerated(const std::list<GeomShapePtr>& theFromShapes,
+ const GeomShapePtr& theToShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) = 0;
/// Stores the modified shape (called by the execution method).
virtual void storeModified(const GeomShapePtr& theOldShape,
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true) = 0;
+ /// Stores the root modified shapes (called by the execution method).
+ virtual void storeModified(const std::list<GeomShapePtr>& theOldShapes,
+ const GeomShapePtr& theNewShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)=0;
+
/// Returns the shape-result produced by this feature
virtual GeomShapePtr shape() = 0;
virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName = "") = 0;
+ const std::string& theName = "",
+ const bool theSaveOldIfNotInTree = false) = 0;
/// load shapes of the first level (to be used during shape import)
virtual void loadFirstLevel(GeomShapePtr theShape,
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModelAPI_ResultBody.h"
updateSubs(theToShape);
}
+ void ModelAPI_ResultBody::storeGenerated(
+ const std::list<GeomShapePtr>& theFromShapes, const GeomShapePtr& theToShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+ {
+ myBuilder->storeGenerated(theFromShapes, theToShape, theMakeShape);
+ myConnect = ConnectionNotComputed;
+
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+ aECreator->sendUpdated(data()->owner(), aRedispEvent);
+
+ updateSubs(theToShape, theFromShapes, theMakeShape, true);
+ }
+
void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
const GeomShapePtr& theNewShape,
const bool theIsCleanStored)
updateSubs(theNewShape);
}
+ void ModelAPI_ResultBody::storeModified(
+ const std::list<GeomShapePtr>& theOldShapes, const GeomShapePtr& theNewShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+ {
+ myBuilder->storeModified(theOldShapes, theNewShape, theMakeShape);
+ myConnect = ConnectionNotComputed;
+
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+ aECreator->sendUpdated(data()->owner(), aRedispEvent);
+
+ updateSubs(theNewShape, theOldShapes, theMakeShape, false);
+ }
+
GeomShapePtr ModelAPI_ResultBody::shape()
{
return myBuilder->shape();
-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef ModelAPI_ResultBody_H_
MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
const GeomShapePtr& theToShape);
+ /// Stores the root modified shapes (called by the execution method).
+ MODELAPI_EXPORT virtual void storeGenerated(
+ const std::list<GeomShapePtr>& theFromShapes, const GeomShapePtr& theToShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
+
/// Stores the modified shape (called by the execution method).
MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true);
+ /// Stores the root modified shapes (called by the execution method).
+ MODELAPI_EXPORT virtual void storeModified(
+ const std::list<GeomShapePtr>& theOldShapes, const GeomShapePtr& theNewShape,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
+
/// Returns the shape-result produced by this feature
MODELAPI_EXPORT virtual GeomShapePtr shape();
virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName = "") = 0;
+ const std::string& theName = "",
+ const bool theSaveOldIfNotInTree = false) = 0;
/// load shapes of the first level (to be used during shape import)
MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape,
const bool theShapeChanged = true) = 0;
+ /// Updates the sub-bodies in accordance to the algorithm history information
+ MODELAPI_EXPORT virtual void updateSubs(
+ const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated) = 0;
+
/// Cleans cash related to the already stored elements
MODELAPI_EXPORT virtual void cleanCash() = 0;
-## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
# -*- coding: utf-8 -*-
ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), "h", 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
Fillet_1_objects = [model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_16&weak_name_2]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_18&weak_name_2]")]
Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
- Group_1_objects = [model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_1"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_4"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_2"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_3")]
+ Group_1_objects = [
+ model.selection("FACE", "(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_14)(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_15)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_1)"),
+ model.selection("FACE", "(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_11)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_16)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_2)"),
+ model.selection("FACE", "(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_13)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_6)"),
+ model.selection("FACE", "(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_5)(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_12)")
+ ]
Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
- Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)][Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)]")])
- Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Fillet_1_1/Modified_Face&Sketch_3/SketchLine_9][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][Fillet_1_1/Modified_Face&Sketch_3/SketchLine_12]")])
+ Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_9][Fillet_1_1/MF:Fillet_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3][Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_9]")])
+ Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3][Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12]")])
model.do()
Folder_1 = model.addFolder(Part_1_doc, Sketch_3, ExtrusionCut_2)
-## Copyright (C) 2017 CEA/DEN, EDF R&D
-##
-## 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, or (at your option) any later version.
-##
-## 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<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
"""
Test moving the entities in the complex sketch by the example of a clamp
Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_14f-SketchLine_16r-SketchArc_3_2r-SketchLine_15f-SketchLine_13r-SketchArc_2_2r-SketchCircle_2_2r")], model.selection(), -165, 155)
Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
- Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)"))
+ Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5)"))
SketchLine_17 = Sketch_3.addLine(145, 0, 165, 0)
- SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Extrusion_1_1/From_Face&Sketch_2/SketchLine_6][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_1&Extrusion_2_1/To_Face][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7]"))
+ SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_6&Extrusion_1_1/From_Face][Fuse_1_1/Modified_Face&Extrusion_2_1/To_Face&Sketch_1/SketchLine_1][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5]"))
SketchPoint_2 = SketchProjection_2.createdFeature()
SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchAPI_Point(SketchPoint_2).result())
SketchLine_18 = Sketch_3.addLine(165, 0, 165, -20)
SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchArc_5.center())
SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_20.result(), SketchArc_5.endPoint())
SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchArc_5.startPoint(), SketchLine_19.result())
- SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face][(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)]"))
+ SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face][(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)(Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5)]"))
SketchConstraintTangent_5 = Sketch_3.setTangent(SketchArc_5.results()[1], SketchLine_21.result())
model.do()
- ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2r-SketchLine_18r-SketchLine_17r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
- ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2f-SketchLine_20r-SketchArc_5_2r-SketchLine_19r")], model.selection(), model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9)(ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchArc_4_2)(ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
+ ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2r-SketchLine_18r-SketchLine_17r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_2/SketchLine_9&Sketch_1/SketchLine_2"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
+ ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2f-SketchLine_20r-SketchArc_5_2r-SketchLine_19r")], model.selection(), model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_9&Sketch_1/SketchLine_2)(ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchArc_4_2)(ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
model.do()
model.end()