}
//--------------------------------------------------------------------------------------
-void ExchangeAPI_Import::setParameters(const std::string & theFilePath,
+void ExchangeAPI_Import::setParameters(const std::string & theFilePath,
const bool anScalInterUnits,
const bool anMaterials,
const bool anColor)
{
fillAttribute(theFilePath, mystepfilePath);
fillAttribute("STEP", feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()));
- fillAttribute(anScalInterUnits, feature()->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()));
- fillAttribute(anMaterials, feature()->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()));
- fillAttribute(anColor, feature()->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()));
+ fillAttribute(anScalInterUnits,
+ feature()->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()));
+ fillAttribute(anMaterials,
+ feature()->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()));
+ fillAttribute(anColor,
+ feature()->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()));
execute();
}
void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
{
fillAttribute(theFilePath, myfilePath);
- std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath);
+ std::string aFrom = "\\";
+ std::string aTo = "\\\\";
+ std::string aFilePath = theFilePath;
+ for(std::size_t aPos = aFilePath.find(aFrom);
+ aPos != std::string::npos;
+ aPos = aFilePath.find(aFrom, aPos)) {
+ aFilePath.replace(aPos, aFrom.size(), aTo);
+ aPos += aTo.size();
+ }
+ std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
fillAttribute(anExtension, feature()->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()));
execute();
}
FeaturePtr aBase = feature();
std::string aPartName = theDumper.name(aBase->document());
- AttributeStringPtr aImportTypeAttr = aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+ AttributeStringPtr aImportTypeAttr =
+ aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
std::string aFormat = aImportTypeAttr->value();
std::string aFilePath;
if (aFormat == "STEP" || aFormat == "STP")
theDumper << aBase << " = model.addImportStep(" << aPartName << ", \""
<< aFilePath << "\"" ;
- theDumper << ", " << scalinterunits()->value()
+ theDumper << ", " << scalinterunits()->value()
<< ", " << materials()->value()
<< ", " << colors()->value() << ")"<< std::endl;
}else{
EXCHANGEAPI_EXPORT
ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
const std::string & theFilePath,
- const bool anScalInterUnits,
- const bool anMaterials,
- const bool anColor);
-
+ const bool theScalInterUnits,
+ const bool theMaterials,
+ const bool theColor);
+
/// Destructor
EXCHANGEAPI_EXPORT
virtual ~ExchangeAPI_Import();
/// Set point values
EXCHANGEAPI_EXPORT
void setFilePath(const std::string & theFilePath);
-
+
EXCHANGEAPI_EXPORT
- void setParameters(const std::string & theFilePath,
+ void setParameters(const std::string & theFilePath,
const bool anScalInterUnits,
const bool anMaterials,
const bool anColor);
const bool anScalInterUnits,
const bool anMaterials,
const bool anColor);
-
+
/** \ingroup CPPHighAPI
* \brief Import features from the file to the document after the current feature (or to the end).
*/
if (aFormat == "STEP" || aFormat == "STP")
{
aFilePathAttr = string(ExchangePlugin_Import::STEP_FILE_PATH_ID());
- aFilePath = aFilePathAttr->value();
+ aFilePath = aFilePathAttr->value();
// get the document where to import
aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
aTargetAttr = integer(STEP_TARGET_PART_ID());
{
aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
}
-
- AttributeStringPtr aImportTypeAttr = aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+
+ AttributeStringPtr aImportTypeAttr =
+ aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
aData->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())
->setValue(boolean(ExchangePlugin_Import::STEP_MATERIALS_ID())->value());
aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID());
aTargetAttr = integer(STEP_TARGET_PART_ID());
updatePart(aPartsAttr, aTargetAttr);
- }
+ }
}
-void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr, AttributeIntegerPtr &aTargetAttr)
+void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr &aPartsAttr,
+ AttributeIntegerPtr &aTargetAttr)
{
// update the list of target parts
SessionPtr aSession = ModelAPI_Session::get();
data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId());
aFeaturesAttribute->setIsArgument(false);
-
+
ModelAPI_Session::get()->validators()->registerNotObligatory(
getKind(), ExchangePlugin_ImportFeature::FEATURES_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::STEP_COLORS_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::STEP_MATERIALS_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::FILE_PATH_ID());
+
}
/*
ResultBodyPtr result = document()->createBody(data());
bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())->value();
- bool anMaterialsGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value();
+ bool anMaterialsGroupSelected =
+ boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value();
if (anExtension == "BREP" || anExtension == "BRP") {
aGeomShape = BREPImport(theFileName, anExtension, anError);
} else if (anExtension == "STEP" || anExtension == "STP") {
- bool anScalInterUnits = boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
-
+ bool anScalInterUnits =
+ boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
try{
if (aFeature)
document()->removeFeature(aFeature);
}
-
+
aGeomShape = STEPImportAttributs(theFileName, result, anScalInterUnits,
- anMaterialsGroupSelected, anColorGroupSelected,theMaterialShape,anError);
-
+ anMaterialsGroupSelected, anColorGroupSelected,
+ theMaterialShape,anError);
+
}
catch (OSD_Exception& e) {
//Try to load STEP file without colors...
loadNamingDS(aGeomShape, result);
// create color group
- if (anColorGroupSelected)
+ if (anColorGroupSelected)
{
setColorGroups(result);
}
setMaterielGroup(result,theMaterialShape);
}
- setResult(result);
+ setResult(result);
}
-void ExchangePlugin_ImportFeature::setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody)
+void ExchangePlugin_ImportFeature::setColorGroups(
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody)
{
std::vector<int> aColor;
- int indice = 1;
- std::list< std::vector<int> > aColorsRead;
+ int indice = 1;
+ std::list< std::vector<int> > aColorsRead;
ModelAPI_Tools::getColor(theResultBody, aColor);
if ( it == aColorsRead.end() ){
std::wstringstream colorName;
colorName<<L"Color_"<<indice;
- setColorGroup( theResultBody, aColor, colorName.str() );
+ setColorGroup(theResultBody, aColor, colorName.str());
indice++;
aColorsRead.push_back(aColor);
}
GeomShapePtr aShape = theResultBody->shape();
aSelectionList->setSelectionType(aShape->shapeTypeStr() );
aSelectionList->append(theResultBody,aShape);
- }
+ }
}
- // add element with the same color
+ // add element with the same color
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(theResultBody, allRes);
- for(std::list<ResultPtr>::iterator aRes = allRes.begin();
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin();
aRes != allRes.end(); ++aRes) {
ModelAPI_Tools::getColor(*aRes, aColor);
GeomShapePtr aShape = (*aRes)->shape();
}
}
+ ModelAPI_Tools::setColor(aGroupFeature->lastResult(),theColor);
+
if (aSelectionList->size() == 0 ){
document()->removeFeature(aGroupFeature);
}
}
-void ExchangePlugin_ImportFeature::setMaterielGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape)
+void ExchangePlugin_ImportFeature::setMaterielGroup(
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape)
{
- int indice = 1;
- std::map< std::wstring, std::list<std::wstring>>::iterator it;
+ int indice = 1;
+ std::map< std::wstring, std::list<std::wstring>>::iterator it;
for( it = theMaterialShape.begin(); it != theMaterialShape.end(); ++it) {
-
+
std::shared_ptr<ModelAPI_Feature> aGroupFeature = addFeature("Group");
// group name
aGroupFeature->data()->setName((*it).first);
// fill selection
AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
- std::string aSelectionType = "solid" ;
- aSelectionList->setSelectionType(aSelectionType);
GeomShapePtr aShape = theResultBody->shape();
-
+
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(theResultBody, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) {
-
+
GeomShapePtr aShape = (*aRes)->shape();
for(std::list<std::wstring>::iterator aResMat = it->second.begin();
aResMat != it->second.end(); ++aResMat) {
if( aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
- {
+ {
aSelectionList->append(theResultBody,aShape);
+ aSelectionList->setSelectionType(aShape->shapeTypeStr() );
break;
}
}
document()->removeFeature(aGroupFeature);
}
}
-}
-
-
+}
void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
{
/// Loads Naming data structure to the document
void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape,
std::shared_ptr<ModelAPI_ResultBody> theResultBody);
-
- // Set groups of color
+ // Set groups of color
void setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody);
// set a group of color
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
-
+//JL_CGLB
#include <XCAFApp_Application.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <OSD_Exception.hxx>
// Set "C" numeric locale to save numbers correctly
// Kernel_Utils::Localizer loc;
-
+
STEPControl_Reader aReader;
//VSR: 16/09/09: Convert to METERS
std::shared_ptr<GeomAPI_Shape> STEPImportAttributs(const std::string& theFileName,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const bool anScalInterUnits,
- const bool anMaterials,
- const bool anColor,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- std::string& theError)
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const bool anScalInterUnits,
+ const bool anMaterials,
+ const bool anColor,
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape,
+ std::string& theError)
{
-
+
STEPControl_Reader aReader;
std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
//VSR: 16/09/09: Convert to METERS
return aGeomShape;
}
- return readAttributes(cafreader,theResultBody,anMaterials, theMaterialShape, "STEP-XCAF");
+ return readAttributes(cafreader,
+ theResultBody,
+ anMaterials,
+ theMaterialShape,
+ "STEP-XCAF",
+ theError);
}
/// Implementation of the import STEP files algorithms with Attributs (Name, Color, Materials)
GEOMALGOAPI_EXPORT
std::shared_ptr<GeomAPI_Shape> STEPImportAttributs(const std::string& theFileName,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const bool anScalInterUnits,
- const bool anMaterials,
- const bool anColor,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- std::string& theError);
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const bool anScalInterUnits,
+ const bool anMaterials,
+ const bool anColor,
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape,
+ std::string& theError);
#endif /* GEOMALGOAPI_STEPIMPORT_H_ */
#include <TDocStd_Document.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_MaterialTool.hxx>
+#include <XCAFDoc_MaterialTool.hxx>
#include <Quantity_Color.hxx>
#include <TopoDS.hxx>
#include <STEPConstruct.hxx>
std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const bool anMaterials,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- const std::string &format)
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape,
+ const std::string &format,
+ std::string& theError)
{
// dummy XCAF Application to handle the STEP XCAF Document
Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel,
TopLoc_Location(),theResultBody,theMaterialShape,false);
-
- std::shared_ptr<GeomAPI_Shape> ageom = setgeom(shapeTool,mainLabel);
-
- STEPControl_Reader aReader = reader.ChangeReader();
-
+ std::shared_ptr<GeomAPI_Shape> ageom = setgeom(shapeTool,mainLabel,theError);
+
+ STEPControl_Reader aReader = reader.ChangeReader();
+
// BEGIN: reading materials of sub-shapes from file
if ( anMaterials )
{
}
}
- return ageom;
+ return ageom;
}
std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const TDF_Label &label)
+ const TDF_Label &label,
+ std::string& theError)
{
BRep_Builder B;
TopoDS_Compound compound;
} else {
for (Standard_Integer i=1; i<frshapes.Length(); i++) {
TopoDS_Shape S = shapeTool->GetShape(frshapes.Value(i));
-
TDF_Label aLabel = shapeTool->FindShape(S, Standard_False);
if ( (!aLabel.IsNull()) && (shapeTool->IsShape(aLabel)) ) {
if (shapeTool->IsFree(aLabel) ) {
continue;
}
else {
- B.Add(compound, S);
+ if (!shapeTool->IsReference(aLabel) ){
+ for(TDF_ChildIterator it(aLabel); it.More(); it.Next()) {
+ B.Add(compound, shapeTool->GetShape(it.Value()) );
+ }
+ }else{
+ B.Add(compound, S);
+ }
}
}
}
}
+
TopoDS_Shape shape = compound;
+ // Check if any BRep entity has been read, there must be at least a vertex
+ if ( !TopExp_Explorer( shape, TopAbs_VERTEX ).More() )
+ {
+ theError = "No geometrical data in the imported file.";
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape());
+ return aGeomShape;
+ }
+
aGeomShape->setImpl(new TopoDS_Shape(shape));
return aGeomShape;
}
const TDF_Label &label,
const TopLoc_Location &loc,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape,
bool isRef)
{
std::wstring shapeName;
shapeName = Locale::Convert::toWString(TCollection_AsciiString(name).ToCString()) ;
}
-
+
TopLoc_Location partLoc = loc;
Handle(XCAFDoc_Location) l;
if(label.FindAttribute(XCAFDoc_Location::GetID(), l)) {
setShapeAttributes( shapeTool, colorTool, materialTool, ref,
partLoc,theResultBody,theMaterialShape,true);
}
-
+
if( shapeTool->IsSimpleShape(label) && (isRef || shapeTool->IsFree(label))) {
TopoDS_Shape shape = shapeTool->GetShape(label);
if(materialTool->GetMaterial(label, matName, matDescription, matDensity,
matDensName, matDensValType)) {
- std::wstring nameMaterial = Locale::Convert::toWString(matName->ToCString());
-
+ std::wstring nameMaterial = Locale::Convert::toWString(matName->ToCString());
+
theMaterialShape[nameMaterial].push_back(shapeName);
}
-
Quantity_Color col;
if(colorTool->GetColor(label, XCAFDoc_ColorGen, col)) {
double r = col.Red(), g = col.Green(), b = col.Blue();
double r = col.Red(), g = col.Green(), b = col.Blue();
TopoDS_Face face = TopoDS::Face(xp2.Current());
std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- std::wstringstream aNameFace;
+ std::wstringstream aNameFace;
TopoDS_Shape shapeface = xp2.Current();
if (!loc.IsIdentity()){
shapeface.Move(loc);
colorTool->GetColor(xp1.Current(), XCAFDoc_ColorCurv, col)) {
double r = col.Red(), g = col.Green(), b = col.Blue();
std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- std::wstringstream aNameEdge;
+ std::wstringstream aNameEdge;
aNameEdge << L"Edge_"<< shapeName;
aShapeGeom->setImpl(new TopoDS_Shape(xp1.Current() ));
theResultBody->addShapeColor(
}
}
else {
- int indiceChild = 1;
+ int indiceChild = 1;
- if (!shapeTool->IsReference(label)){
+ if (!shapeTool->IsReference(label) ){
TopoDS_Shape shape = shapeTool->GetShape(label);
std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
aShapeGeom->setImpl(new TopoDS_Shape(shape));
shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
}
- for(TDF_ChildIterator it(label); it.More(); it.Next()) {
+ for(TDF_ChildIterator it(label); it.More(); it.Next()) {
setShapeAttributes( shapeTool, colorTool, materialTool,
it.Value(), partLoc,theResultBody,theMaterialShape, isRef);
std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
aShapeGeom->setImpl(new TopoDS_Shape(aSub));
std::wstring nom = theResultBody->findShapeName(aShapeGeom);
- std::wstring matName= Locale::Convert::toWString(aMatName->ToCString());
+ std::wstring matName= Locale::Convert::toWString(aMatName->ToCString());
theMaterialShape[matName].push_back(nom);
}
#define GEOMALGOAPI_STEPIMPORTXCAF_H_
#include <GeomAlgoAPI.h>
-#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shape.hxx>
#include <string>
#include <vector>
#include <ModelAPI_ResultBody.h>
#include <TopTools_IndexedMapOfShape.hxx>
- // read Attributs of step file
+ // read Attributs of step file
GEOMALGOAPI_EXPORT
std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const bool anMaterials,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- const std::string &format);
- // read attributs for label
- GEOMALGOAPI_EXPORT
+ std::map< std::wstring,
+ std::list<std::wstring>> &theMaterialShape,
+ const std::string &format,
+ std::string& theError);
+ // read attributs for label
+ GEOMALGOAPI_EXPORT
void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
const Handle(XCAFDoc_ColorTool) &colorTool,
const Handle(XCAFDoc_MaterialTool) &materialTool,
std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
bool isRef);
-// read geometry
-GEOMALGOAPI_EXPORT
+// read geometry
+GEOMALGOAPI_EXPORT
std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const TDF_Label &label);
+ const TDF_Label &label,
+ std::string& theError);
// store Materiel for theShapeLabel in the map theMaterialShape
-GEOMALGOAPI_EXPORT
+GEOMALGOAPI_EXPORT
void StoreMaterial( std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const Handle(Standard_Transient) &theEnti,
const TopTools_IndexedMapOfShape &theIndices,
}
std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
- const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex,const std::wstring& theNameShape )
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData,
+ const int theIndex,
+ const std::wstring& theNameShape )
{
TDF_Label aLab = resultLabel(theFeatureData, theIndex);
TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
//! Initializes the data fields of the feature
void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag);
-
+
//! Allows to store the result in the data tree of the document
//! (attaches 'data' of result to tree)
void storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector<int>& color) {
if( myColorsShape.find(theName) == myColorsShape.end())
- myColorsShape[ theName ] = color;
+ myColorsShape[ theName ] = color;
}
-std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,const std::wstring& theName ){
+std::wstring Model_ResultBody::addShapeName(std::shared_ptr<GeomAPI_Shape> theshape,
+ const std::wstring& theName ){
- int indice = 1;
- std::wstringstream aName;
+ int indice = 1;
+ std::wstringstream aName;
aName << theName;
while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
aName.str(L"");
- aName << theName << L"__" << indice;
+ aName << theName << L"__" << indice;
indice++;
}
myNamesShape[ aName.str() ] = theshape;
std::wstring Model_ResultBody::findShapeName(std::shared_ptr<GeomAPI_Shape> theshape){
TopoDS_Shape aShape = theshape->impl<TopoDS_Shape>();
- for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it = myNamesShape.begin();
+ for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+ myNamesShape.begin();
it != myNamesShape.end();
++it)
- {
+ {
TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
if( (aShape.IsSame(curSelectedShape))) {
return (*it).first;
}
-
}
return L"material not found" ;
}
-void Model_ResultBody::setShapeName(std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
- std::map< std::wstring, std::vector<int>> & theColorsShape)
+void Model_ResultBody::setShapeName(
+ std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,
+ std::map< std::wstring, std::vector<int>> & theColorsShape)
{
myNamesShape = theshapename;
myColorsShape = theColorsShape;
}
+
void Model_ResultBody::clearShapeNameAndColor(){
myNamesShape.clear();
myColorsShape.clear();
if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
std::wstring thenameshape = L"";
// find shape name read
- for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it = myNamesShape.begin();
+ for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+ myNamesShape.begin();
it != myNamesShape.end();
++it)
- {
+ {
TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
if( !(aShapesIter.Value().IsSame(curSelectedShape))) continue;
thenameshape = (*it).first;
}
aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape);
//finf color read
- std::map< std::wstring, std::vector<int>>::iterator itColor = myColorsShape.find(thenameshape);
+ std::map< std::wstring, std::vector<int>>::iterator itColor =
+ myColorsShape.find(thenameshape);
if(itColor != myColorsShape.end()){
ModelAPI_Tools::setColor(aSub,(*itColor).second);
- }
+ }
aSub->setShapeName(myNamesShape,myColorsShape);
mySubs.push_back(aSub);
mySubsMap[aSub] = int(mySubs.size() - 1);
aSub->ModelAPI_ResultBody::setIsConcealed(true);
std::dynamic_pointer_cast<Model_ResultBody>(aSub)->updateConcealment();
}
-
+
} else { // just update shape of this result
aSub = mySubs[aSubIndex];
}
friend class Model_Objects;
- // Add shape Name for read shape in step file
+ // Add shape Name for read shape in step file
std::wstring addShapeName(std::shared_ptr<GeomAPI_Shape>,const std::wstring& theName) override;
- // Add color for shape Name read shape in step file
+ // Add color for shape Name read shape in step file
void addShapeColor( const std::wstring& theName,std::vector<int>& color) override;
- // Set the map of name and color read shape in step file
- void setShapeName(std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theshapename,std::map< std::wstring, std::vector<int>> & theColorsShape) override;
+ // Set the map of name and color read shape in step file
+ void setShapeName(std::map< std::wstring,
+ std::shared_ptr<GeomAPI_Shape> > &theshapename,
+ std::map< std::wstring,
+ std::vector<int>> & theColorsShape) override;
// find the name of shapp read in step file
std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theshape) override;
// Clear the map of name and color read shape in step file
void clearShapeNameAndColor() override;
-
- // map with the name read in step file and shape
+
+ // map with the name read in step file and shape
std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > myNamesShape;
- // map with the name contruct and color read
- std::map< std::wstring, std::vector<int>> myColorsShape;
+ // map with the name contruct and color read
+ std::map< std::wstring, std::vector<int>> myColorsShape;
};
SET(PROJECT_LIBRARIES
Config
GeomAPI
- Locale
${OpenCASCADE_ApplicationFramework_LIBRARIES}
)
SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
Test19707.py
Test19726.py
Test19912.py
- Test19932.py
- Test19989.py
)