-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: Model_ResultBody.cpp
-// Created: 08 Jul 2014
-// Author: Mikhail PONIKAROV
+// 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>
+//
#include <Model_BodyBuilder.h>
if (aShapeNew.IsNull())
return; // null shape inside
aBuilder.Modify(aShapeOld, aShapeNew);
- if (theDecomposeSolidsTag && aShapeNew.ShapeType() == TopAbs_COMPOUND) {
- // make sub elements as subs
-
- // register name if it is possible
- TCollection_AsciiString aName;
- if(!aBuilder.NamedShape()->IsEmpty()) {
- Handle(TDataStd_Name) anAttr;
- if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
- aName = TCollection_AsciiString(anAttr->Get()).ToCString();
- }
- }
-
- TopoDS_Iterator aSubIter(aShapeNew);
- for(int aTag = theDecomposeSolidsTag; aSubIter.More(); aSubIter.Next()) {
- const TopoDS_Shape& aShape = aSubIter.Value();
- Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aShape, aShapeLab);
- if(!aNS.IsNull() && !aNS->IsEmpty()) {
- // This shape is already in document, don't add it.
- continue;
- }
- TNaming_Builder aSubBuilder(aShapeLab.FindChild(aTag++));
- aSubBuilder.Generated(aSubIter.Value());
- if(!aName.IsEmpty()) {
- TCollection_AsciiString aShapeType = aShape.ShapeType() == TopAbs_EDGE ? "_Edge_" :
- aShape.ShapeType() == TopAbs_FACE ? "_Face_" :
- aShape.ShapeType() == TopAbs_SOLID ? "_Solid_" :
- "_Shape_";
- std::string aSolidName =
- (aName + aShapeType + TCollection_AsciiString(aTag - theDecomposeSolidsTag))
- .ToCString();
- std::shared_ptr<Model_Document> aDoc =
- std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(aSubBuilder.NamedShape()->Label(), aSolidName);
- TDataStd_Name::Set(aSubBuilder.NamedShape()->Label(), aSolidName.c_str());
- }
- }
- } else if(!aBuilder.NamedShape()->IsEmpty()) {
+ if(!aBuilder.NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
const int theTag,
const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate)
+ const bool theIsStoreSeparate,
+ const bool theIsStoreAsGenerated)
{
int anIndex = 1;
int aTag = theTag;
GeomShapePtr aGeomNewShape(new GeomAPI_Shape());
aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape));
if(!aRoot.IsSame(aNewShape) && aResultShape->isSubShape(aGeomNewShape)) {
- builder(aTag)->Modify(aRoot,aNewShape);
+ if(theIsStoreAsGenerated) {
+ // Here we store shapes as generated, to avoid problem when one parent shape produce
+ // several child shapes. In this case naming could not determine which shape to select.
+ builder(aTag)->Generated(aRoot,aNewShape);
+ } else {
+ builder(aTag)->Modify(aRoot,aNewShape);
+ }
if(isBuilt) {
if(theIsStoreSeparate) {
aStream.str(std::string());