#include <ExchangePlugin_Tools.h>
+#include <iostream>
#include <QPixmap>
/*
// Pass the results into the model
loadNamingDS(aGeomShape, aResult);
+ if (aResult->shape().get())
+ std::cout << "5 YES\n";
+ else
+ std::cout << "5 NO\n";
// create color group
if (anColorGroupSelected)
}
setResult(aResult);
+
aResult->clearShapeNameAndColor();
}
std::shared_ptr<ModelAPI_ResultBody> theResultBody)
{
//load result
+ auto ashape = theResultBody->shape();
theResultBody->store(theGeomShape);
// to store color of higher-level shape
std::string aNameMS = "Shape";
theResultBody->loadFirstLevel(theGeomShape, aNameMS);
+
+ // Block for set colors
+ {
+ //TEST(theResultBody);
+ }
}
void ExchangePlugin_Import_ImageFeature::importFile(const std::string& theFileName)
return ageom;
}
+void setColors(std::shared_ptr<ModelAPI_ResultBody> theResultBody)
+{
+ TopoDS_Shape aShape = theResultBody->shape()->impl<TopoDS_Shape>();
+ TopExp_Explorer anExp(aShape, TopAbs_SOLID);
+ while (anExp.More())
+ {
+ auto aFace = anExp.Current();
+
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aFace));
+ auto aName = theResultBody->findShapeName(aGeomShape);
+
+ if (!aName.empty())
+ {
+ auto aColor = theResultBody->findShapeColor(aName);
+
+ if (!aColor.empty())
+ theResultBody->setSubShapeColor(theResultBody, aGeomShape, { 128, 222, 2 });
+ else
+ theResultBody->setSubShapeColor(theResultBody, aGeomShape, { 255, 0, 0 });
+
+ }
+ anExp.Next();
+ }
+}
+
//=============================================================================
std::shared_ptr<GeomAPI_Shape> setGeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool,
const TDF_Label& /*theLabel*/,
theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorSurf, aCol) ||
theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorCurv, aCol)) {
double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue();
- TopoDS_Face aFace = TopoDS::Face(aXp2.Current());
- std::vector<int> aColRGB = {int(aR*255),int(aG*255),int(aB*255)};
- std::wstringstream aNameFace;
+ //TopoDS_Face aFace = TopoDS::Face(aXp2.Current());
+ std::vector<int> aColRGB = { int(aR * 255),int(aG * 255),int(aB * 255) };
+ std::wstring aNameFace;
TopoDS_Shape aShapeface = aXp2.Current();
- if (!theLoc.IsIdentity()){
- aShapeface.Move(theLoc);
+ if (!theLoc.IsIdentity()) {
+ aShapeface.Move(theLoc);
}
- aShapeGeom->setImpl(new TopoDS_Shape(aShapeface));
- theResultBody->addShapeColor(theResultBody->addShapeName(aShapeGeom, aNameFace.str()), aColRGB);
+ std::shared_ptr<GeomAPI_Shape> aFaceGeom(new GeomAPI_Shape);
+ aFaceGeom->setImpl(new TopoDS_Shape(aShapeface));
+ theResultBody->addShapeColor(theResultBody->addShapeName(aFaceGeom, aNameFace), aColRGB);
}
aXp2.Next();
}
#include <TNaming_Tool.hxx>
#include <TDF_Reference.hxx>
+#include <BRepTools.hxx>
+
// if this attribute exists, the shape is connected topology
Standard_GUID kIsConnectedTopology("e51392e0-3a4d-405d-8e36-bbfe19858ef5");
// if this attribute exists, the connected topology flag must be recomputed
int indice = 1;
std::wstringstream aName;
aName << theName;
-#if 1
+#if 0
while (myNamesShape.find(aName.str()) != myNamesShape.end()) {
#else
while (aName.str().empty() || myNamesShape.find(aName.str()) != myNamesShape.end()) {
}
///
if (!aName.empty()) {
- const std::vector<int> &aColor = findShapeColor(aName);
+ const std::vector<int>& aColor = findShapeColor(aName);
+ std::vector<int> aColor2 = {};
if (!aColor.empty()) {
ModelAPI_Tools::setColor(anOwner, aGeomFace, aColor);
+ ModelAPI_Tools::getColor(anOwner, aGeomFace, aColor2);
+ //std::cout << std::endl << aColor[0] << " " << aColor[1] << " " << aColor[2] << std::endl;
+ //if (!aColor2.empty())
+ // std::cout << aColor2[0] << " " << aColor2[1] << " " << aColor2[2] << std::endl;
}
}
}