-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 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
#include <Model_BodyBuilder.h>
+#include <Locale_Convert.h>
+
#include <Model_Data.h>
#include <Model_Document.h>
#include <ModelAPI_Session.h>
case TopAbs_VERTEX: return GENERATED_VERTICES_TAG;
case TopAbs_EDGE: return GENERATED_EDGES_TAG;
case TopAbs_FACE: return GENERATED_FACES_TAG;
+ default: break; // [to avoid compilation warning]
}
return INVALID_TAG;
case TopAbs_VERTEX: return MODIFIED_VERTICES_TAG;
case TopAbs_EDGE: return MODIFIED_EDGES_TAG;
case TopAbs_FACE: return MODIFIED_FACES_TAG;
+ default: break; // [to avoid compilation warning]
}
return INVALID_TAG;
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());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
- TDF_Label aShapeLab = aData->shapeLab();
// clean builders
if (theIsCleanStored)
clean();
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());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
if (aFind == myBuilders.end()) {
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- myBuilders[theTag] = new TNaming_Builder(
- theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag));
+ TDF_Label aLab = theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag);
+ myBuilders[theTag] = new TNaming_Builder(aLab);
aFind = myBuilders.find(theTag);
}
return aFind->second;
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());
+ std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
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();
+ bool aStore = (*anOldIter)->isCompound() || (*anOldIter)->isShell() || (*anOldIter)->isWire() ||
+ (*anOldIter)->isCompSolid();
if (!aStore) {
ListOfShape aNews; // check this old really modifies theNewShape
theMakeShape->modified(*anOldIter, aNews);
for(; anEntriesIter.More(); anEntriesIter.Next()) {
anEntriesIter.Value()->Label().ForgetAttribute(kEXTERNAL_SHAPE_REF);
}
+ // to clear old shapes in all sub-labels (they may be left without builders on Open)
+ TDF_ChildIDIterator aNSIter(aLab, TNaming_NamedShape::GetID(), true);
+ for(; aNSIter.More(); aNSIter.Next()) {
+ aNSIter.Value()->Label().ForgetAttribute(aNSIter.Value());
+ }
}
void Model_BodyBuilder::cleanCash()
//=======================================================================
void Model_BodyBuilder::loadFirstLevel(GeomShapePtr theShape, const std::string& theName)
{
- if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ GeomShapePtr aShapePtr = shape();
+ if (theShape->isNull() || !aShapePtr.get())
+ return;
+ TopoDS_Shape aShape = shape()->impl<TopoDS_Shape>();
+ if (aShape.IsNull())
+ return;
std::string aName;
if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
TopoDS_Iterator itr(aShape);