本文整理汇总了C++中TopTools_IndexedMapOfShape类的典型用法代码示例。如果您正苦于以下问题:C++ TopTools_IndexedMapOfShape类的具体用法?C++ TopTools_IndexedMapOfShape怎么用?C++ TopTools_IndexedMapOfShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TopTools_IndexedMapOfShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFaceTraits
// Set the face traits
void SetFaceTraits (PNamedShape loft)
{
// designated names of the faces
std::vector<std::string> names(5);
names[0]="Bottom";
names[1]="Top";
names[2]="TrailingEdge";
names[3]="Inside";
names[4]="Outside";
// map of faces
TopTools_IndexedMapOfShape map;
TopExp::MapShapes(loft->Shape(), TopAbs_FACE, map);
// check if number of faces is correct (only valid for ruled surfaces lofts)
if (map.Extent() != 5 && map.Extent() != 4) {
LOG(ERROR) << "CCPACSWingSegment: Unable to determine face names in ruled surface loft";
return;
}
// remove trailing edge name if there is no trailing edge
if (map.Extent() == 4) {
names.erase(names.begin()+2);
}
// set face trait names
for (int i = 0; i < map.Extent(); i++) {
CFaceTraits traits = loft->GetFaceTraits(i);
traits.SetName(names[i].c_str());
loft->SetFaceTraits(i, traits);
}
}
示例2: countEdges
void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s)
{
TopTools_IndexedMapOfShape mapOfEdges;
TopExp::MapShapes(s, TopAbs_EDGE, mapOfEdges);
int num = mapOfEdges.Extent();
Base::Console().Message("COUNT - %s has %d edges\n",text,num);
}
示例3: Handle
//=======================================================================
//function : CloseContour
//purpose :
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
Standard_Boolean isByVertex = theHI->GetIsCommonVertex();
Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
ShHealOper_CloseContour aHealer (theOriginalShape);
Standard_Boolean aResult = Standard_False;
if ( aWires.IsNull() ) {
if ( theOriginalShape.ShapeType() == TopAbs_WIRE )
aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex);
}
else {
TopTools_SequenceOfShape aShapesWires;
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes(theOriginalShape, aShapes);
for (int i = 1; i <= aWires->Length(); i++) {
int indexOfWire = aWires->Value(i);
TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
aShapesWires.Append(aWire);
}
aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex );
}
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption( aHealer.GetErrorStatus() );
return aResult;
}
示例4: TestMkFillet
void TestMkFillet(){
TopoDS_Shape Box = BRepPrimAPI_MakeBox(10., 10., 10.);
BRepFilletAPI_MakeFillet mkFillet(Box);
TopTools_IndexedMapOfShape edges;
TopExp::MapShapes(Box, TopAbs_EDGE, edges);
TopoDS_Edge edge = TopoDS::Edge(edges.FindKey(3));
mkFillet.Add(1., 1., edge);
mkFillet.Build();
TopoDS_Shape result = mkFillet.Shape();
TopTools_IndexedMapOfShape faces;
TopExp::MapShapes(Box, TopAbs_FACE, faces);
TopoDS_Face face = TopoDS::Face(faces.FindKey(3));
TopTools_ListOfShape modified = mkFillet.Modified(face);
TopTools_ListIteratorOfListOfShape modIt;
for (int i=1; modIt.More(); modIt.Next(), i++){
TopoDS_Face curFace = TopoDS::Face(modIt.Value());
TopoNamingHelper::WriteShape(curFace, "00_02_ModifiedFace", i);
}
TopoNamingHelper::WriteShape(result, "00_00_FilletResult");
TopoNamingHelper::WriteShape(face, "00_01_BaseFace_3");
}
示例5: FacePassKey
//=======================================================================
//function : FacePassKey
//purpose :
//=======================================================================
void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF,
GEOMAlgo_PassKeyShape& aPK)
{
Standard_Integer i, aNbE;
TopoDS_Shape aER;
TopTools_ListOfShape aLE;
TopTools_IndexedMapOfShape aME;
//
TopExp::MapShapes(aF, TopAbs_EDGE, aME);
//
aNbE=aME.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Shape& aE=aME(i);
//
const TopoDS_Edge& aEE=*((TopoDS_Edge*)&aE);
if (BRep_Tool::Degenerated(aEE)) {
continue;
}
//
if (myOrigins.IsBound(aE)) {
aER=myOrigins.Find(aE);
}
else {
aER=aE;
}
aLE.Append(aER);
}
aPK.SetShapes(aLE);
}
示例6: aHealer
//=======================================================================
//function : AddPointOnEdge
//purpose :
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
Standard_Boolean isByParameter = theHI->GetIsByParameter();
Standard_Integer anIndex = theHI->GetIndex();
Standard_Real aValue = theHI->GetDevideEdgeValue();
ShHealOper_EdgeDivide aHealer (theOriginalShape);
Standard_Boolean aResult = Standard_False;
if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
if (theOriginalShape.ShapeType() == TopAbs_EDGE)
aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
} else {
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes(theOriginalShape, aShapes);
TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
if (aEdgeShape.ShapeType() == TopAbs_EDGE)
aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
}
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption( aHealer.GetErrorStatus() );
return aResult;
}
示例7:
int StdMeshers_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const vector < SMESH_subMesh * >&meshFaces,
const TopoDS_Vertex & V0,
const TopoDS_Vertex & V1,
const TopoDS_Vertex & V2, const TopoDS_Vertex & V3)
{
//MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex");
int faceIndex = -1;
for (int i = 1; i < 6; i++)
{
const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape();
//const TopoDS_Face& F = TopoDS::Face(aFace);
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
bool verticesInShape = false;
if (M.Contains(V0))
if (M.Contains(V1))
if (M.Contains(V2))
if (M.Contains(V3))
verticesInShape = true;
if (verticesInShape)
{
faceIndex = i;
break;
}
}
//IPAL21120 ASSERT(faceIndex > 0);
//SCRUTE(faceIndex);
return faceIndex;
}
示例8: while
void ResultEntry::buildEntryName()
{
ResultEntry *parentEntry = this;
while(parentEntry->parent != 0)
{
ResultEntry *temp = parentEntry->parent;
if (temp->parent == 0)
break;
parentEntry = parentEntry->parent;
}
QString stringOut;
QTextStream stream(&stringOut);
TopTools_IndexedMapOfShape shapeMap;
int index(-1);
switch (this->shape.ShapeType())
{
case TopAbs_COMPOUND:
TopExp::MapShapes(parentEntry->shape, TopAbs_COMPOUND, shapeMap);
stream << "Compound";
break;
case TopAbs_COMPSOLID:
TopExp::MapShapes(parentEntry->shape, TopAbs_COMPSOLID, shapeMap);
stream << "CompSolid";
break;
case TopAbs_SOLID:
TopExp::MapShapes(parentEntry->shape, TopAbs_SOLID, shapeMap);
stream << "Solid";
break;
case TopAbs_SHELL:
TopExp::MapShapes(parentEntry->shape, TopAbs_SHELL, shapeMap);
stream << "Shell";
break;
case TopAbs_WIRE:
TopExp::MapShapes(parentEntry->shape, TopAbs_WIRE, shapeMap);
stream << "Wire";
break;
case TopAbs_FACE:
TopExp::MapShapes(parentEntry->shape, TopAbs_FACE, shapeMap);
stream << "Face";
break;
case TopAbs_EDGE:
TopExp::MapShapes(parentEntry->shape, TopAbs_EDGE, shapeMap);
stream << "Edge";
break;
case TopAbs_VERTEX:
TopExp::MapShapes(parentEntry->shape, TopAbs_VERTEX, shapeMap);
stream << "Vertex";
break;
default:
stream << "Unexpected shape type";
break;
}
index = shapeMap.FindIndex(this->shape);
stream << index;
this->name = stringOut;
}
示例9: on_shapeObject_activated
void DlgFilletEdges::on_shapeObject_activated(int index)
{
d->object = 0;
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
model->removeRows(0, model->rowCount());
QByteArray name = ui->shapeObject->itemData(index).toByteArray();
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc)
return;
App::DocumentObject* part = doc->getObject((const char*)name);
if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
d->object = part;
TopoDS_Shape myShape = static_cast<Part::Feature*>(part)->Shape.getValue();
// build up map edge->face
TopTools_IndexedDataMapOfShapeListOfShape edge2Face;
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, edge2Face);
TopTools_IndexedMapOfShape mapOfShape;
TopExp::MapShapes(myShape, TopAbs_EDGE, mapOfShape);
// populate the model
d->edge_ids.clear();
for (int i=1; i<= edge2Face.Extent(); ++i) {
// set the index value as user data to use it in accept()
const TopTools_ListOfShape& los = edge2Face.FindFromIndex(i);
if (los.Extent() == 2) {
// set the index value as user data to use it in accept()
const TopoDS_Shape& edge = edge2Face.FindKey(i);
// Now check also the continuity to only allow C0-continious
// faces
const TopoDS_Shape& face1 = los.First();
const TopoDS_Shape& face2 = los.Last();
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
TopoDS::Face(face1),
TopoDS::Face(face2));
if (cont == GeomAbs_C0) {
int id = mapOfShape.FindIndex(edge);
d->edge_ids.push_back(id);
}
}
}
model->insertRows(0, d->edge_ids.size());
int index = 0;
for (std::vector<int>::iterator it = d->edge_ids.begin(); it != d->edge_ids.end(); ++it) {
model->setData(model->index(index, 0), QVariant(tr("Edge%1").arg(*it)));
model->setData(model->index(index, 0), QVariant(*it), Qt::UserRole);
model->setData(model->index(index, 1), QVariant(QLocale::system().toString(1.0,'f',2)));
model->setData(model->index(index, 2), QVariant(QLocale::system().toString(1.0,'f',2)));
std::stringstream element;
element << "Edge" << *it;
if (Gui::Selection().isSelected(part, element.str().c_str()))
model->setData(model->index(index, 0), Qt::Checked, Qt::CheckStateRole);
else
model->setData(model->index(index, 0), Qt::Unchecked, Qt::CheckStateRole);
index++;
}
}
}
示例10:
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void GEOMAlgo_Gluer2::BuildResult()
{
Standard_Boolean bHasImage;
TopoDS_Shape aCnew, aCXnew;
TopoDS_Iterator aItC;
BRep_Builder aBB;
//
myErrorStatus=0;
myWarningStatus=0;
//
aItC.Initialize(myArgument);
for (; aItC.More(); aItC.Next()) {
const TopoDS_Shape& aCx=aItC.Value();
bHasImage=HasImage(aCx);
if (bHasImage) {
break;
}
}
//
if (!bHasImage) {
myShape=myArgument;
return;
}
//
GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCnew);
//
aItC.Initialize(myArgument);
for (; aItC.More(); aItC.Next()) {
const TopoDS_Shape& aCX=aItC.Value();
if (myOrigins.IsBound(aCX)) {
aCXnew=myOrigins.Find(aCX);
aCXnew.Orientation(aCX.Orientation());
aBB.Add(aCnew, aCXnew);
}
else {
aBB.Add(aCnew, aCX);
}
}
//
if (!myKeepNonSolids) {
Standard_Integer i, aNb;
TopoDS_Shape aCnew1;
TopTools_IndexedMapOfShape aM;
//
GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCnew1);
//
TopExp::MapShapes(aCnew, TopAbs_SOLID, aM);
aNb=aM.Extent();
for (i=1; i<=aNb; ++i) {
const TopoDS_Shape& aS=aM(i);
aBB.Add(aCnew1, aS);
}
aCnew=aCnew1;
}
//
myShape=aCnew;
}
示例11: Handle
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOM_SubShapeDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOM_ISubShape aCI (aFunction);
TDF_Label aLabel = aCI.GetMainShape()->GetOwnerEntry();
if (aLabel.IsRoot()) return 0;
Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
if (anObj.IsNull()) return 0;
TopoDS_Shape aMainShape = anObj->GetValue();
if (aMainShape.IsNull()) return 0;
Handle(TColStd_HArray1OfInteger) anIndices = aCI.GetIndices();
if (anIndices.IsNull() || anIndices->Length() <= 0) return 0;
BRep_Builder B;
TopoDS_Compound aCompound;
TopoDS_Shape aShape;
if (anIndices->Length() == 1 && anIndices->Value(1) == -1) { //The empty sub-shape
B.MakeCompound(aCompound);
aShape = aCompound;
}
else {
TopTools_IndexedMapOfShape aMapOfShapes;
TopExp::MapShapes(aMainShape, aMapOfShapes);
if (anIndices->Length() > 1) {
B.MakeCompound(aCompound);
for (int i = anIndices->Lower(); i <= anIndices->Upper(); i++) {
if (aMapOfShapes.Extent() < anIndices->Value(i))
Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range");
TopoDS_Shape aSubShape = aMapOfShapes.FindKey(anIndices->Value(i));
if (aSubShape.IsNull()) continue;
B.Add(aCompound,aSubShape);
}
aShape = aCompound;
}
else {
int i = anIndices->Lower();
if (aMapOfShapes.Extent() < anIndices->Value(i))
Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range");
aShape = aMapOfShapes.FindKey(anIndices->Value(i));
}
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例12: MakeBRepShapes
//=======================================================================
//function : FillBRepShapes
//purpose :
//=======================================================================
void GEOMAlgo_Gluer2::FillBRepShapes(const TopAbs_ShapeEnum theType)
{
Standard_Boolean bHasImage, bIsToWork;
Standard_Integer i, aNbE;
TopoDS_Iterator aItS;
TopoDS_Shape aEnew;
TopTools_IndexedMapOfShape aME;
TopTools_MapOfShape aMFence;
TopTools_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
myWarningStatus=0;
//
TopExp::MapShapes(myArgument, theType, aME);
//
aNbE=aME.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Shape& aE=aME(i);
//
if (!aMFence.Add(aE)) {
continue;
}
//
bIsToWork=myOriginsToWork.IsBound(aE);
bHasImage=HasImage(aE);
if (!bHasImage && !bIsToWork) {
continue;
}
//
MakeBRepShapes(aE, aEnew);
//
//myImages / myOrigins
if (bIsToWork) {
const TopoDS_Shape& aSkey=myOriginsToWork.Find(aE);
const TopTools_ListOfShape& aLSD=myImagesToWork.Find(aSkey);
//
myImages.Bind(aEnew, aLSD);
//
aItLS.Initialize(aLSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aEx=aItLS.Value();
myOrigins.Bind(aEx, aEnew);
//
aMFence.Add(aEx);
}
}
else {
TopTools_ListOfShape aLSD;
//
aLSD.Append(aE);
myImages.Bind(aEnew, aLSD);
myOrigins.Bind(aE, aEnew);
}
}//for (i=1; i<=aNbF; ++i) {
}
示例13: highlightReferences
void ViewProviderShapeBinder::highlightReferences(const bool on, bool /*auxillery*/)
{
Part::Feature* obj;
std::vector<std::string> subs;
if(getObject()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()))
PartDesign::ShapeBinder::getFilteredReferences(&static_cast<PartDesign::ShapeBinder*>(getObject())->Support, obj, subs);
else
return;
PartGui::ViewProviderPart* svp = dynamic_cast<PartGui::ViewProviderPart*>(
Gui::Application::Instance->getViewProvider(obj));
if (svp == NULL) return;
if (on) {
if (!subs.empty() && originalLineColors.empty()) {
TopTools_IndexedMapOfShape eMap;
TopExp::MapShapes(obj->Shape.getValue(), TopAbs_EDGE, eMap);
originalLineColors = svp->LineColorArray.getValues();
std::vector<App::Color> lcolors = originalLineColors;
lcolors.resize(eMap.Extent(), svp->LineColor.getValue());
TopExp::MapShapes(obj->Shape.getValue(), TopAbs_FACE, eMap);
originalFaceColors = svp->DiffuseColor.getValues();
std::vector<App::Color> fcolors = originalFaceColors;
fcolors.resize(eMap.Extent(), svp->ShapeColor.getValue());
for (std::string e : subs) {
// Note: stoi may throw, but it strictly shouldn't happen
if(e.substr(4) == "Edge") {
int idx = std::stoi(e.substr(4)) - 1;
assert ( idx>=0 );
if ( idx < (ssize_t) lcolors.size() )
lcolors[idx] = App::Color(1.0,0.0,1.0); // magenta
}
else if(e.substr(4) == "Face") {
int idx = std::stoi(e.substr(4)) - 1;
assert ( idx>=0 );
if ( idx < (ssize_t) fcolors.size() )
fcolors[idx] = App::Color(1.0,0.0,1.0); // magenta
}
}
svp->LineColorArray.setValues(lcolors);
svp->DiffuseColor.setValues(fcolors);
}
} else {
if (!subs.empty() && !originalLineColors.empty()) {
svp->LineColorArray.setValues(originalLineColors);
originalLineColors.clear();
svp->DiffuseColor.setValues(originalFaceColors);
originalFaceColors.clear();
}
}
}
示例14: addFacesToSelection
void addFacesToSelection(Gui::View3DInventorViewer* /*viewer*/,
const Gui::ViewVolumeProjection& proj,
const Base::Polygon2d& polygon,
const TopoDS_Shape& shape)
{
try {
TopTools_IndexedMapOfShape M;
TopExp_Explorer xp_face(shape,TopAbs_FACE);
while (xp_face.More()) {
M.Add(xp_face.Current());
xp_face.Next();
}
App::Document* appdoc = doc->getDocument();
for (Standard_Integer k = 1; k <= M.Extent(); k++) {
const TopoDS_Shape& face = M(k);
TopExp_Explorer xp_vertex(face,TopAbs_VERTEX);
while (xp_vertex.More()) {
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(xp_vertex.Current()));
Base::Vector3d pt2d;
pt2d = proj(Base::Vector3d(p.X(), p.Y(), p.Z()));
if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
#if 0
// TODO
if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer))
#endif
{
std::stringstream str;
str << "Face" << k;
Gui::Selection().addSelection(appdoc->getName(), obj->getNameInDocument(), str.str().c_str());
break;
}
}
xp_vertex.Next();
}
//GProp_GProps props;
//BRepGProp::SurfaceProperties(face, props);
//gp_Pnt c = props.CentreOfMass();
//Base::Vector3d pt2d;
//pt2d = proj(Base::Vector3d(c.X(), c.Y(), c.Z()));
//if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
// if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer)) {
// std::stringstream str;
// str << "Face" << k;
// Gui::Selection().addSelection(appdoc->getName(), obj->getNameInDocument(), str.str().c_str());
// }
//}
}
}
catch (...) {
}
}
示例15: get_loops
int OCCSurface::get_loops( DLIList<OCCLoop*>& result_list )
{
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*myTopoDSFace, TopAbs_WIRE, M);
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *loop = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
result_list.append_unique(dynamic_cast<OCCLoop*>(loop));
}
return result_list.size();
}