1 // File : FrontTrack_NodeGroups.cxx
2 // Created : Tue Apr 25 19:17:47 2017
3 // Author : Edward AGAPOV (eap)
5 #include "FrontTrack_NodeGroups.hxx"
6 #include "FrontTrack_Projector.hxx"
7 #include "FrontTrack_Utils.hxx"
9 #include <MEDCouplingMemArray.hxx>
10 #include <XAO_BrepGeometry.hxx>
11 #include <XAO_Xao.hxx>
13 #include <BRepBndLib.hxx>
14 #include <Bnd_Box.hxx>
16 #include <TopExp_Explorer.hxx>
17 #include <TopTools_IndexedMapOfShape.hxx>
18 #include <TopoDS_Shape.hxx>
22 //================================================================================
24 * \brief Initialize FT_Projector's with all sub-shapes of given type
25 * \param [in] theMainShape - the shape to explore
26 * \param [in] theSubType - the type of sub-shapes
27 * \param [out] theProjectors - the projectors
29 //================================================================================
31 void getProjectors( const TopoDS_Shape& theMainShape,
32 const TopAbs_ShapeEnum theSubType,
33 std::vector< FT_Projector > & theProjectors )
35 TopTools_IndexedMapOfShape subShapes;
36 TopExp::MapShapes( theMainShape, theSubType, subShapes );
38 std::cout << ". Nombre de subShapes : " << subShapes.Size() << std::endl;
41 theProjectors.resize( subShapes.Size() );
42 for ( int i = 1; i <= subShapes.Size(); ++i )
43 theProjectors[ i-1 ].setBoundaryShape( subShapes( i ));
47 //================================================================================
49 * \brief Load node groups from files
50 * \param [in] theNodeFiles - an array of names of files describing groups of nodes that
51 * will be moved onto geometry
52 * \param [in] theXaoGeom - the whole geometry to project on
53 * \param [inout] theNodeCoords - array of node coordinates
55 //================================================================================
57 void FT_NodeGroups::read( const std::vector< std::string >& theNodeFiles,
58 const XAO::Xao* theXao,
59 MEDCoupling::DataArrayDouble* theNodeCoords )
61 // get projectors for all boundary sub-shapes;
62 // index of a projector in the vector corresponds to a XAO index of a sub-shape
63 XAO::BrepGeometry* xaoGeom = dynamic_cast<XAO::BrepGeometry*>( theXao->getGeometry() );
64 getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_EDGE, _projectors[0] );
65 getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_FACE, _projectors[1] );
67 _nodesOnGeom.resize( theNodeFiles.size() );
69 // read node IDs and look for projectors to boundary sub-shapes by group name
70 FT_Utils::XaoGroups xaoGroups( theXao );
71 for ( size_t i = 0; i < theNodeFiles.size(); ++i )
73 _nodesOnGeom[i].read( theNodeFiles[i], xaoGroups, theNodeCoords, _projectors );
77 //================================================================================
79 * \brief Project and move nodes of a given group of nodes
81 //================================================================================
83 void FT_NodeGroups::projectAndMove( const int groupIndex )
85 _nodesOnGeom[ groupIndex ].projectAndMove();
88 //================================================================================
90 * \brief Return true if all nodes were successfully relocated
92 //================================================================================
94 bool FT_NodeGroups::isOK() const
96 for ( size_t i = 0; i < _nodesOnGeom.size(); ++i )
97 if ( ! _nodesOnGeom[ i ].isOK() )
103 //================================================================================
105 * \brief Print some statistics on node groups
107 //================================================================================
109 void FT_NodeGroups::dumpStat() const
111 for ( size_t i = 0; i < _nodesOnGeom.size(); ++i )
113 std::cout << _nodesOnGeom[i].getShapeDim() << "D "
114 << _nodesOnGeom[i].nbNodes() << " nodes" << std::endl;