1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_CompoundBuilder.cpp
4 // Created: 24 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #include <GeomAlgoAPI_CompoundBuilder.h>
8 #include <BRep_Builder.hxx>
9 #include <TopoDS_Compound.hxx>
10 #include <TopTools_IndexedMapOfShape.hxx>
13 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_CompoundBuilder::compound(
14 std::list<std::shared_ptr<GeomAPI_Shape> > theShapes)
16 BRep_Builder aBuilder;
17 TopoDS_Compound aComp;
18 aBuilder.MakeCompound(aComp);
20 std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theShapes.begin(), aLast =
22 for (; anIt != aLast; anIt++) {
23 aBuilder.Add(aComp, (*anIt)->impl<TopoDS_Shape>());
26 std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
27 aRes->setImpl(new TopoDS_Shape(aComp));
31 int GeomAlgoAPI_CompoundBuilder::id(
32 std::shared_ptr<GeomAPI_Shape> theContext, std::shared_ptr<GeomAPI_Shape> theSub)
35 TopoDS_Shape aMainShape = theContext->impl<TopoDS_Shape>();
36 const TopoDS_Shape& aSubShape = theSub->impl<TopoDS_Shape>();
37 if (!aMainShape.IsNull() && !aSubShape.IsNull()) {
38 TopTools_IndexedMapOfShape aSubShapesMap;
39 TopExp::MapShapes(aMainShape, aSubShapesMap);
40 anID = aSubShapesMap.FindIndex(aSubShape);