SHAPER  9.12.0
GeomAlgoAPI_NExplode Class Reference

Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9. More...

Public Types

enum  ShapeOrder { ORDER_BY_HASH_VALUE , ORDER_BY_MIDDLE_POINT }
 Different orders of shape explosion. More...
 

Public Member Functions

 GeomAlgoAPI_NExplode (const GeomShapePtr theContext, const GeomAPI_Shape::ShapeType theShapeType, const ShapeOrder theOrder=ORDER_BY_MIDDLE_POINT)
 Initializes the sorted list of shapes by the context shape and type of sub-shapes. More...
 
 GeomAlgoAPI_NExplode (const ListOfShape &theShapes, const ShapeOrder theOrder=ORDER_BY_MIDDLE_POINT)
 Initializes the sorted list of shapes. More...
 
int index (const GeomShapePtr theSubShape)
 Returns an index (started from one) of sub-shape in the sorted list. Returns 0 if not found. More...
 
GeomShapePtr shape (const int theIndex)
 Returns a shape by an index (started from one). Returns null if not found. More...
 
void reorder (const ShapeOrder theNewOrder)
 Reorder the shapes. More...
 

Protected Attributes

std::vector< GeomShapePtr > mySorted
 

Detailed Description

Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9.

Algorithm is copied from GEOM module, which uses nexplode Draw command from OCCT. Used for getting index of sub0shape in WeakNaming algorithm.

Member Enumeration Documentation

◆ ShapeOrder

Different orders of shape explosion.

Enumerator
ORDER_BY_HASH_VALUE 

kept for compatibility

ORDER_BY_MIDDLE_POINT 

modern approach comparing middle points of shapes

Constructor & Destructor Documentation

◆ GeomAlgoAPI_NExplode() [1/2]

GeomAlgoAPI_NExplode::GeomAlgoAPI_NExplode ( const GeomShapePtr  theContext,
const GeomAPI_Shape::ShapeType  theShapeType,
const ShapeOrder  theOrder = ORDER_BY_MIDDLE_POINT 
)

Initializes the sorted list of shapes by the context shape and type of sub-shapes.

◆ GeomAlgoAPI_NExplode() [2/2]

GeomAlgoAPI_NExplode::GeomAlgoAPI_NExplode ( const ListOfShape &  theShapes,
const ShapeOrder  theOrder = ORDER_BY_MIDDLE_POINT 
)

Initializes the sorted list of shapes.

Member Function Documentation

◆ index()

int GeomAlgoAPI_NExplode::index ( const GeomShapePtr  theSubShape)

Returns an index (started from one) of sub-shape in the sorted list. Returns 0 if not found.

◆ shape()

GeomShapePtr GeomAlgoAPI_NExplode::shape ( const int  theIndex)

Returns a shape by an index (started from one). Returns null if not found.

◆ reorder()

void GeomAlgoAPI_NExplode::reorder ( const ShapeOrder  theNewOrder)

Reorder the shapes.