#include <SMESH_Pattern.hxx>
Data Structures | |
| struct | TPoint |
Public Types | |
| enum | ErrorCode { ERR_OK, ERR_READ_NB_POINTS, ERR_READ_POINT_COORDS, ERR_READ_TOO_FEW_POINTS, ERR_READ_3D_COORD, ERR_READ_NO_KEYPOINT, ERR_READ_BAD_INDEX, ERR_READ_ELEM_POINTS, ERR_READ_NO_ELEMS, ERR_READ_BAD_KEY_POINT, ERR_SAVE_NOT_LOADED, ERR_LOAD_EMPTY_SUBMESH, ERR_LOADF_NARROW_FACE, ERR_LOADF_CLOSED_FACE, ERR_LOADF_CANT_PROJECT, ERR_LOADV_BAD_SHAPE, ERR_LOADV_COMPUTE_PARAMS, ERR_APPL_NOT_COMPUTED, ERR_APPL_NOT_LOADED, ERR_APPL_BAD_DIMENTION, ERR_APPL_BAD_NB_VERTICES, ERR_APPLF_BAD_TOPOLOGY, ERR_APPLF_BAD_VERTEX, ERR_APPLF_INTERNAL_EEROR, ERR_APPLV_BAD_SHAPE, ERR_APPLF_BAD_FACE_GEOM, ERR_MAKEM_NOT_COMPUTED, ERR_UNEXPECTED } |
Public Member Functions | |
| SMESH_Pattern () | |
| void | Clear () |
| bool | Load (const char *theFileContents) |
| bool | Load (SMESH_Mesh *theMesh, const TopoDS_Face &theFace, bool theProject=false) |
| bool | Load (SMESH_Mesh *theMesh, const TopoDS_Shell &theBlock) |
| bool | Save (std::ostream &theFile) |
| bool | Apply (const TopoDS_Face &theFace, const TopoDS_Vertex &theVertexOnKeyPoint1, const bool theReverse) |
| bool | Apply (const TopoDS_Shell &theBlock, const TopoDS_Vertex &theVertex000, const TopoDS_Vertex &theVertex001) |
| bool | Apply (const SMDS_MeshFace *theFace, const int theNodeIndexOnKeyPoint1, const bool theReverse) |
| bool | Apply (SMESH_Mesh *theMesh, const SMDS_MeshFace *theFace, const TopoDS_Shape &theSurface, const int theNodeIndexOnKeyPoint1, const bool theReverse) |
| bool | Apply (SMESH_Mesh *theMesh, std::set< const SMDS_MeshFace * > &theFaces, const int theNodeIndexOnKeyPoint1, const bool theReverse) |
| bool | Apply (const SMDS_MeshVolume *theVolume, const int theNode000Index, const int theNode001Index) |
| bool | Apply (std::set< const SMDS_MeshVolume * > &theVolumes, const int theNode000Index, const int theNode001Index) |
| bool | GetMappedPoints (std::list< const gp_XYZ * > &thePoints) const |
| bool | MakeMesh (SMESH_Mesh *theMesh, const bool toCreatePolygons=false, const bool toCreatePolyedrs=false) |
| ErrorCode | GetErrorCode () const |
| bool | IsLoaded () const |
| bool | Is2D () const |
| bool | GetPoints (std::list< const gp_XYZ * > &thePoints) const |
| const std::list< int > & | GetKeyPointIDs () const |
| const std::list< std::list < int > > & | GetElementPointIDs (bool applied) const |
| void | DumpPoints () const |
| TopoDS_Shape | GetSubShape (const int i) const |
Private Types | |
| typedef std::list< std::list < TopoDS_Edge > > | TListOfEdgesList |
| typedef std::set< const SMDS_MeshNode * > | TNodeSet |
| typedef std::list< int > | TElemDef |
Private Member Functions | |
| bool | setErrorCode (const ErrorCode theErrorCode) |
| set ErrorCode and return true if it is Ok | |
| bool | setShapeToMesh (const TopoDS_Shape &theShape) |
| std::list< TPoint * > & | getShapePoints (const TopoDS_Shape &theShape) |
| std::list< TPoint * > & | getShapePoints (const int theShapeID) |
| bool | findBoundaryPoints () |
| void | arrangeBoundaries (std::list< std::list< TPoint * > > &boundaryPoints) |
| void | computeUVOnEdge (const TopoDS_Edge &theEdge, const std::list< TPoint * > &ePoints) |
| bool | compUVByIsoIntersection (const std::list< std::list< TPoint * > > &boundaryPoints, const gp_XY &theInitUV, gp_XY &theUV, bool &theIsDeformed) |
| bool | compUVByElasticIsolines (const std::list< std::list< TPoint * > > &boundaryPoints, const std::list< TPoint * > &pointsToCompute) |
| double | setFirstEdge (std::list< TopoDS_Edge > &theWire, int theFirstEdgeID) |
| bool | sortSameSizeWires (TListOfEdgesList &theWireList, const TListOfEdgesList::iterator &theFromWire, const TListOfEdgesList::iterator &theToWire, const int theFirstEdgeID, std::list< std::list< TPoint * > > &theEdgesPointsList) |
| void | mergePoints (const bool uniteGroups) |
| void | makePolyElements (const std::vector< const SMDS_MeshNode * > &theNodes, const bool toCreatePolygons, const bool toCreatePolyedrs) |
| void | createElements (SMESH_Mesh *theMesh, const std::vector< const SMDS_MeshNode * > &theNodesVector, const std::list< std::list< int > > &theElemNodeIDs, const std::vector< const SMDS_MeshElement * > &theElements) |
| bool | getFacesDefinition (const SMDS_MeshNode **theBndNodes, const int theNbBndNodes, const std::vector< const SMDS_MeshNode * > &theNodes, std::list< int > &theFaceDefs, std::vector< int > &theQuantity) |
| bool | isReversed (const SMDS_MeshNode *theFirstNode, const std::list< int > &theIdsList) const |
| void | clearMesh (SMESH_Mesh *theMesh) const |
Static Private Member Functions | |
| static SMESHDS_SubMesh * | getSubmeshWithElements (SMESH_Mesh *theMesh, const TopoDS_Shape &theShape) |
Private Attributes | |
| bool | myIs2D |
| std::vector< TPoint > | myPoints |
| std::list< int > | myKeyPointIDs |
| std::list< TElemDef > | myElemPointIDs |
| ErrorCode | myErrorCode |
| bool | myIsComputed |
| bool | myIsBoundaryPointsFound |
| TopoDS_Shape | myShape |
| TopTools_IndexedMapOfOrientedShape | myShapeIDMap |
| std::map< int, std::list < TPoint * > > | myShapeIDToPointsMap |
| std::list< int > | myNbKeyPntInBoundary |
| std::vector< gp_XYZ > | myXYZ |
| std::list< TElemDef > | myElemXYZIDs |
| std::map< int, const SMDS_MeshNode * > | myXYZIdToNodeMap |
| std::vector< const SMDS_MeshElement * > | myElements |
| std::vector< const SMDS_MeshNode * > | myOrderedNodes |
| std::vector< const SMDS_MeshElement * > | myPolyElems |
| std::list< TElemDef > | myPolyElemXYZIDs |
| std::list< std::vector< int > > | myPolyhedronQuantities |
| std::map< TNodeSet, std::list < std::list< int > > > | myIdsOnBoundary |
| std::map< int, std::list < TElemDef * > > | myReverseConnectivity |
Friends | |
| std::ostream & | operator<< (std::ostream &OS, const TPoint &p) |
Definition at line 61 of file SMESH_Pattern.hxx.
typedef std::list< int > SMESH_Pattern.TElemDef [private] |
Definition at line 344 of file SMESH_Pattern.hxx.
typedef std::list< std::list< TopoDS_Edge > > SMESH_Pattern.TListOfEdgesList [private] |
Definition at line 291 of file SMESH_Pattern.hxx.
typedef std::set<const SMDS_MeshNode*> SMESH_Pattern.TNodeSet [private] |
Definition at line 304 of file SMESH_Pattern.hxx.
Definition at line 157 of file SMESH_Pattern.hxx.
{
ERR_OK,
// Load(file)
ERR_READ_NB_POINTS, // couldn't read nb of points
ERR_READ_POINT_COORDS, // invalid nb of point coordinates
ERR_READ_TOO_FEW_POINTS, // too few points in a pattern
ERR_READ_3D_COORD, // coordinate of 3D point out of [0,1] range
ERR_READ_NO_KEYPOINT, // no key-points in 2D pattern
ERR_READ_BAD_INDEX, // invalid point index
ERR_READ_ELEM_POINTS, // invalid nb of points in element
ERR_READ_NO_ELEMS, // no elements in a pattern
ERR_READ_BAD_KEY_POINT, // a key-point not on a boundary
// Save(file)
ERR_SAVE_NOT_LOADED, // pattern was not loaded
// Load(shape)
ERR_LOAD_EMPTY_SUBMESH, // no elements to load
// Load(face)
ERR_LOADF_NARROW_FACE, // too narrow face
ERR_LOADF_CLOSED_FACE, // closed face
ERR_LOADF_CANT_PROJECT, // impossible to project nodes
// Load(volume)
ERR_LOADV_BAD_SHAPE, // volume is not a brick of 6 faces
ERR_LOADV_COMPUTE_PARAMS, // cant compute point parameters
// Apply(shape)
ERR_APPL_NOT_COMPUTED, // mapping failed
ERR_APPL_NOT_LOADED, // pattern was not loaded
ERR_APPL_BAD_DIMENTION, // wrong shape dimention
ERR_APPL_BAD_NB_VERTICES, // keypoints - vertices mismatch
// Apply(face)
ERR_APPLF_BAD_TOPOLOGY, // bad pattern topology
ERR_APPLF_BAD_VERTEX, // first vertex not on an outer face boundary
ERR_APPLF_INTERNAL_EEROR, // program error
// Apply(volume)
ERR_APPLV_BAD_SHAPE, // volume is not a brick of 6 faces
// Apply(mesh_face)
ERR_APPLF_BAD_FACE_GEOM, // bad face geometry
// MakeMesh
ERR_MAKEM_NOT_COMPUTED, // mapping failed
//Unexpected error
ERR_UNEXPECTED // Unexpected of the pattern mapping alorithm
};
| SMESH_Pattern::SMESH_Pattern | ( | ) |
Definition at line 91 of file SMESH_Pattern.cxx.
{
}
| bool SMESH_Pattern::Apply | ( | const TopoDS_Face & | theFace, |
| const TopoDS_Vertex & | theVertexOnKeyPoint1, | ||
| const bool | theReverse | ||
| ) |
Definition at line 2348 of file SMESH_Pattern.cxx.
References SMESH_Block.GetOrderedEdges(), Handle(), MESSAGE, SMESH_Pattern.TPoint.myInitUV, SMESH_Pattern.TPoint.myU, SMESH_Pattern.TPoint.myUV, SMESH_Pattern.TPoint.myXYZ, SMESH_mechanic_editor.point, and PAL_MESH_043_3D.wire.
Referenced by SMESH_Pattern_i.ApplyTo3DBlock(), SMESH_Pattern_i.ApplyToFace(), SMESH_Pattern_i.ApplyToHexahedrons(), and SMESH_Pattern_i.ApplyToMeshFaces().
{
MESSAGE(" ::Apply(face) " );
TopoDS_Face face = theReverse ? TopoDS::Face( theFace.Reversed() ) : theFace;
if ( !setShapeToMesh( face ))
return false;
// find points on edges, it fills myNbKeyPntInBoundary
if ( !findBoundaryPoints() )
return false;
// Define the edges order so that the first edge starts at
// theVertexOnKeyPoint1
list< TopoDS_Edge > eList;
list< int > nbVertexInWires;
int nbWires = SMESH_Block::GetOrderedEdges( face, theVertexOnKeyPoint1, eList, nbVertexInWires);
if ( !theVertexOnKeyPoint1.IsSame( TopExp::FirstVertex( eList.front(), true )))
{
MESSAGE( " theVertexOnKeyPoint1 not found in the outer wire ");
return setErrorCode( ERR_APPLF_BAD_VERTEX );
}
// check nb wires and edges
list< int > l1 = myNbKeyPntInBoundary, l2 = nbVertexInWires;
l1.sort(); l2.sort();
if ( l1 != l2 )
{
MESSAGE( "Wrong nb vertices in wires" );
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
// here shapes get IDs, for the outer wire IDs are OK
list<TopoDS_Edge>::iterator elIt = eList.begin();
for ( ; elIt != eList.end(); elIt++ ) {
myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true ));
bool isClosed1 = BRep_Tool::IsClosed( *elIt, theFace );
// BEGIN: jfa for bug 0019943
if (isClosed1) {
isClosed1 = false;
for (TopExp_Explorer expw (theFace, TopAbs_WIRE); expw.More() && !isClosed1; expw.Next()) {
const TopoDS_Wire& wire = TopoDS::Wire(expw.Current());
int nbe = 0;
for (BRepTools_WireExplorer we (wire, theFace); we.More() && !isClosed1; we.Next()) {
if (we.Current().IsSame(*elIt)) {
nbe++;
if (nbe == 2) isClosed1 = true;
}
}
}
}
// END: jfa for bug 0019943
if (isClosed1)
myShapeIDMap.Add( TopExp::LastVertex( *elIt, true ));// vertex orienation is REVERSED
}
int nbVertices = myShapeIDMap.Extent();
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ )
myShapeIDMap.Add( *elIt );
myShapeIDMap.Add( face );
if ( myShapeIDToPointsMap.size() != myShapeIDMap.Extent() ) {
MESSAGE( myShapeIDToPointsMap.size() <<" != " << myShapeIDMap.Extent());
return setErrorCode( ERR_APPLF_INTERNAL_EEROR );
}
// points on edges to be used for UV computation of in-face points
list< list< TPoint* > > edgesPointsList;
edgesPointsList.push_back( list< TPoint* >() );
list< TPoint* > * edgesPoints = & edgesPointsList.back();
list< TPoint* >::iterator pIt;
// compute UV of points on the outer wire
int iE, nbEdgesInOuterWire = nbVertexInWires.front();
for (iE = 0, elIt = eList.begin();
iE < nbEdgesInOuterWire && elIt != eList.end();
iE++, elIt++ )
{
list< TPoint* > & ePoints = getShapePoints( *elIt );
// compute UV
computeUVOnEdge( *elIt, ePoints );
// collect on-edge points (excluding the last one)
edgesPoints->insert( edgesPoints->end(), ePoints.begin(), --ePoints.end());
}
// If there are several wires, define the order of edges of inner wires:
// compute UV of inner edge-points using 2 methods: the one for in-face points
// and the one for on-edge points and then choose the best edge order
// by the best correspondance of the 2 results
if ( nbWires > 1 )
{
// compute UV of inner edge-points using the method for in-face points
// and devide eList into a list of separate wires
bool aBool;
list< list< TopoDS_Edge > > wireList;
list<TopoDS_Edge>::iterator eIt = elIt;
list<int>::iterator nbEIt = nbVertexInWires.begin();
for ( nbEIt++; nbEIt != nbVertexInWires.end(); nbEIt++ )
{
int nbEdges = *nbEIt;
wireList.push_back( list< TopoDS_Edge >() );
list< TopoDS_Edge > & wire = wireList.back();
for ( iE = 0 ; iE < nbEdges; eIt++, iE++ )
{
list< TPoint* > & ePoints = getShapePoints( *eIt );
pIt = ePoints.begin();
for ( pIt++; pIt != ePoints.end(); pIt++ ) {
TPoint* p = (*pIt);
if ( !compUVByIsoIntersection( edgesPointsList, p->myInitUV, p->myUV, aBool )) {
MESSAGE("cant Apply(face)");
return false;
}
// keep the computed UV to compare against by setFirstEdge()
p->myXYZ.SetCoord( p->myUV.X(), p->myUV.Y(), 0. );
}
wire.push_back( *eIt );
}
}
// remove inner edges from eList
eList.erase( elIt, eList.end() );
// sort wireList by nb edges in a wire
sortBySize< TopoDS_Edge > ( wireList );
// an ID of the first edge of a boundary
int id1 = nbVertices + nbEdgesInOuterWire + 1;
// if ( nbSeamShapes > 0 )
// id1 += 2; // 2 vertices more
// find points - edge correspondence for wires of unique size,
// edge order within a wire should be defined only
list< list< TopoDS_Edge > >::iterator wlIt = wireList.begin();
while ( wlIt != wireList.end() )
{
list< TopoDS_Edge >& wire = (*wlIt);
int nbEdges = wire.size();
wlIt++;
if ( wlIt == wireList.end() || (*wlIt).size() != nbEdges ) // a unique size wire
{
// choose the best first edge of a wire
setFirstEdge( wire, id1 );
// compute eventual UV and collect on-edge points
edgesPointsList.push_back( list< TPoint* >() );
edgesPoints = & edgesPointsList.back();
int eID = id1;
for ( eIt = wire.begin(); eIt != wire.end(); eIt++ )
{
list< TPoint* > & ePoints = getShapePoints( eID++ );
computeUVOnEdge( *eIt, ePoints );
edgesPoints->insert( edgesPoints->end(), ePoints.begin(), (--ePoints.end()));
}
}
id1 += nbEdges;
}
// find boundary - wire correspondence for several wires of same size
id1 = nbVertices + nbEdgesInOuterWire + 1;
wlIt = wireList.begin();
while ( wlIt != wireList.end() )
{
int nbSameSize = 0, nbEdges = (*wlIt).size();
list< list< TopoDS_Edge > >::iterator wlIt2 = wlIt;
wlIt2++;
while ( wlIt2 != wireList.end() && (*wlIt2).size() == nbEdges ) { // a same size wire
nbSameSize++;
wlIt2++;
}
if ( nbSameSize > 0 )
if (!sortSameSizeWires(wireList, wlIt, wlIt2, id1, edgesPointsList))
return false;
wlIt = wlIt2;
id1 += nbEdges * ( nbSameSize + 1 );
}
// add well-ordered edges to eList
for ( wlIt = wireList.begin(); wlIt != wireList.end(); wlIt++ )
{
list< TopoDS_Edge >& wire = (*wlIt);
eList.splice( eList.end(), wire, wire.begin(), wire.end() );
}
// re-fill myShapeIDMap - all shapes get good IDs
myShapeIDMap.Clear();
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ )
myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true ));
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ )
myShapeIDMap.Add( *elIt );
myShapeIDMap.Add( face );
} // there are inner wires
// Compute XYZ of on-edge points
TopLoc_Location loc;
for ( iE = nbVertices + 1, elIt = eList.begin(); elIt != eList.end(); elIt++ )
{
BRepAdaptor_Curve C3d( *elIt );
list< TPoint* > & ePoints = getShapePoints( iE++ );
pIt = ePoints.begin();
for ( pIt++; pIt != ePoints.end(); pIt++ )
{
TPoint* point = *pIt;
point->myXYZ = C3d.Value( point->myU );
}
}
// Compute UV and XYZ of in-face points
// try to use a simple algo
list< TPoint* > & fPoints = getShapePoints( face );
bool isDeformed = false;
for ( pIt = fPoints.begin(); !isDeformed && pIt != fPoints.end(); pIt++ )
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
// try to use a complex algo if it is a difficult case
if ( isDeformed && !compUVByElasticIsolines( edgesPointsList, fPoints ))
{
for ( ; pIt != fPoints.end(); pIt++ ) // continue with the simple algo
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
}
Handle(Geom_Surface) aSurface = BRep_Tool::Surface( face, loc );
const gp_Trsf & aTrsf = loc.Transformation();
for ( pIt = fPoints.begin(); pIt != fPoints.end(); pIt++ )
{
TPoint * point = *pIt;
point->myXYZ = aSurface->Value( point->myUV.X(), point->myUV.Y() );
if ( !loc.IsIdentity() )
aTrsf.Transforms( point->myXYZ.ChangeCoord() );
}
myIsComputed = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern::Apply | ( | const SMDS_MeshFace * | theFace, |
| const int | theNodeIndexOnKeyPoint1, | ||
| const bool | theReverse | ||
| ) |
Definition at line 2605 of file SMESH_Pattern.cxx.
References MESSAGE, SMESH_Pattern.TPoint.myInitU, SMESH_Pattern.TPoint.myUV, SMESH_Pattern.TPoint.myXYZ, SMDS_MeshElement.NbCornerNodes(), SMESH_AdvancedEditor.nodes, SMDS_MeshElement.nodesIterator(), smdsNode, SMESH_AdvancedEditor.xyz1, and SMESH_AdvancedEditor.xyz2.
{
// MESSAGE(" ::Apply(MeshFace) " );
if ( !IsLoaded() ) {
MESSAGE( "Pattern not loaded" );
return setErrorCode( ERR_APPL_NOT_LOADED );
}
// check nb of nodes
const int nbFaceNodes = theFace->NbCornerNodes();
if ( nbFaceNodes != myNbKeyPntInBoundary.front() ) {
MESSAGE( myKeyPointIDs.size() << " != " << nbFaceNodes );
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
// find points on edges, it fills myNbKeyPntInBoundary
if ( !findBoundaryPoints() )
return false;
// check that there are no holes in a pattern
if (myNbKeyPntInBoundary.size() > 1 ) {
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
// Define the nodes order
list< const SMDS_MeshNode* > nodes;
list< const SMDS_MeshNode* >::iterator n = nodes.end();
SMDS_ElemIteratorPtr noIt = theFace->nodesIterator();
int iSub = 0;
while ( noIt->more() && iSub < nbFaceNodes ) {
const SMDS_MeshNode* node = smdsNode( noIt->next() );
nodes.push_back( node );
if ( iSub++ == theNodeIndexOnKeyPoint1 )
n = --nodes.end();
}
if ( n != nodes.end() ) {
if ( theReverse ) {
if ( n != --nodes.end() )
nodes.splice( nodes.begin(), nodes, ++n, nodes.end() );
nodes.reverse();
}
else if ( n != nodes.begin() )
nodes.splice( nodes.end(), nodes, nodes.begin(), n );
}
list< gp_XYZ > xyzList;
myOrderedNodes.resize( nbFaceNodes );
for ( iSub = 0, n = nodes.begin(); n != nodes.end(); ++n ) {
xyzList.push_back( gp_XYZ( (*n)->X(), (*n)->Y(), (*n)->Z() ));
myOrderedNodes[ iSub++] = *n;
}
// Define a face plane
list< gp_XYZ >::iterator xyzIt = xyzList.begin();
gp_Pnt P ( *xyzIt++ );
gp_Vec Vx( P, *xyzIt++ ), N;
do {
N = Vx ^ gp_Vec( P, *xyzIt++ );
} while ( N.SquareMagnitude() <= DBL_MIN && xyzIt != xyzList.end() );
if ( N.SquareMagnitude() <= DBL_MIN )
return setErrorCode( ERR_APPLF_BAD_FACE_GEOM );
gp_Ax2 pos( P, N, Vx );
// Compute UV of key-points on a plane
for ( xyzIt = xyzList.begin(), iSub = 1; xyzIt != xyzList.end(); xyzIt++, iSub++ )
{
gp_Vec vec ( pos.Location(), *xyzIt );
TPoint* p = getShapePoints( iSub ).front();
p->myUV.SetX( vec * pos.XDirection() );
p->myUV.SetY( vec * pos.YDirection() );
p->myXYZ = *xyzIt;
}
// points on edges to be used for UV computation of in-face points
list< list< TPoint* > > edgesPointsList;
edgesPointsList.push_back( list< TPoint* >() );
list< TPoint* > * edgesPoints = & edgesPointsList.back();
list< TPoint* >::iterator pIt;
// compute UV and XYZ of points on edges
for ( xyzIt = xyzList.begin(); xyzIt != xyzList.end(); iSub++ )
{
gp_XYZ& xyz1 = *xyzIt++;
gp_XYZ& xyz2 = ( xyzIt != xyzList.end() ) ? *xyzIt : xyzList.front();
list< TPoint* > & ePoints = getShapePoints( iSub );
ePoints.back()->myInitU = 1.0;
list< TPoint* >::const_iterator pIt = ++ePoints.begin();
while ( *pIt != ePoints.back() )
{
TPoint* p = *pIt++;
p->myXYZ = xyz1 * ( 1 - p->myInitU ) + xyz2 * p->myInitU;
gp_Vec vec ( pos.Location(), p->myXYZ );
p->myUV.SetX( vec * pos.XDirection() );
p->myUV.SetY( vec * pos.YDirection() );
}
// collect on-edge points (excluding the last one)
edgesPoints->insert( edgesPoints->end(), ePoints.begin(), --ePoints.end());
}
// Compute UV and XYZ of in-face points
// try to use a simple algo to compute UV
list< TPoint* > & fPoints = getShapePoints( iSub );
bool isDeformed = false;
for ( pIt = fPoints.begin(); !isDeformed && pIt != fPoints.end(); pIt++ )
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
// try to use a complex algo if it is a difficult case
if ( isDeformed && !compUVByElasticIsolines( edgesPointsList, fPoints ))
{
for ( ; pIt != fPoints.end(); pIt++ ) // continue with the simple algo
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
}
for ( pIt = fPoints.begin(); pIt != fPoints.end(); pIt++ )
{
(*pIt)->myXYZ = ElSLib::PlaneValue( (*pIt)->myUV.X(), (*pIt)->myUV.Y(), pos );
}
myIsComputed = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern::Apply | ( | SMESH_Mesh * | theMesh, |
| const SMDS_MeshFace * | theFace, | ||
| const TopoDS_Shape & | theSurface, | ||
| const int | theNodeIndexOnKeyPoint1, | ||
| const bool | theReverse | ||
| ) |
Definition at line 2749 of file SMESH_Pattern.cxx.
References SMESH_MesherHelper.GetNodeUV(), SMESH_MesherHelper.GetNodeUVneedInFaceNode(), Handle(), SMESH_MesherHelper.IsSeamShape(), MESSAGE, SMESH_Pattern.TPoint.myInitU, SMESH_Pattern.TPoint.myUV, SMESH_Pattern.TPoint.myXYZ, SMDS_MeshElement.NbNodes(), SMESH_AdvancedEditor.nodes, SMDS_MeshElement.nodesIterator(), SMESH_mechanic_editor.point, SMESH_MesherHelper.SetSubShape(), and smdsNode.
{
// MESSAGE(" ::Apply(MeshFace) " );
if ( theSurface.IsNull() || theSurface.ShapeType() != TopAbs_FACE ) {
return Apply( theFace, theNodeIndexOnKeyPoint1, theReverse);
}
const TopoDS_Face& face = TopoDS::Face( theSurface );
TopLoc_Location loc;
Handle(Geom_Surface) surface = BRep_Tool::Surface( face, loc );
const gp_Trsf & aTrsf = loc.Transformation();
if ( !IsLoaded() ) {
MESSAGE( "Pattern not loaded" );
return setErrorCode( ERR_APPL_NOT_LOADED );
}
// check nb of nodes
if (theFace->NbNodes() != myNbKeyPntInBoundary.front() ) {
MESSAGE( myKeyPointIDs.size() << " != " << theFace->NbNodes() );
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
// find points on edges, it fills myNbKeyPntInBoundary
if ( !findBoundaryPoints() )
return false;
// check that there are no holes in a pattern
if (myNbKeyPntInBoundary.size() > 1 ) {
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
// Define the nodes order
list< const SMDS_MeshNode* > nodes;
list< const SMDS_MeshNode* >::iterator n = nodes.end();
SMDS_ElemIteratorPtr noIt = theFace->nodesIterator();
int iSub = 0;
while ( noIt->more() ) {
const SMDS_MeshNode* node = smdsNode( noIt->next() );
nodes.push_back( node );
if ( iSub++ == theNodeIndexOnKeyPoint1 )
n = --nodes.end();
}
if ( n != nodes.end() ) {
if ( theReverse ) {
if ( n != --nodes.end() )
nodes.splice( nodes.begin(), nodes, ++n, nodes.end() );
nodes.reverse();
}
else if ( n != nodes.begin() )
nodes.splice( nodes.end(), nodes, nodes.begin(), n );
}
// find a node not on a seam edge, if necessary
SMESH_MesherHelper helper( *theMesh );
helper.SetSubShape( theSurface );
const SMDS_MeshNode* inFaceNode = 0;
if ( helper.GetNodeUVneedInFaceNode() )
{
SMESH_MeshEditor editor( theMesh );
for ( n = nodes.begin(); ( !inFaceNode && n != nodes.end()); ++n ) {
int shapeID = editor.FindShape( *n );
if ( !shapeID )
return Apply( theFace, theNodeIndexOnKeyPoint1, theReverse);
if ( !helper.IsSeamShape( shapeID ))
inFaceNode = *n;
}
}
// Set UV of key-points (i.e. of nodes of theFace )
vector< gp_XY > keyUV( theFace->NbNodes() );
myOrderedNodes.resize( theFace->NbNodes() );
for ( iSub = 1, n = nodes.begin(); n != nodes.end(); ++n, ++iSub )
{
TPoint* p = getShapePoints( iSub ).front();
p->myUV = helper.GetNodeUV( face, *n, inFaceNode );
p->myXYZ = gp_XYZ( (*n)->X(), (*n)->Y(), (*n)->Z() );
keyUV[ iSub-1 ] = p->myUV;
myOrderedNodes[ iSub-1 ] = *n;
}
// points on edges to be used for UV computation of in-face points
list< list< TPoint* > > edgesPointsList;
edgesPointsList.push_back( list< TPoint* >() );
list< TPoint* > * edgesPoints = & edgesPointsList.back();
list< TPoint* >::iterator pIt;
// compute UV and XYZ of points on edges
for ( int i = 0; i < myOrderedNodes.size(); ++i, ++iSub )
{
gp_XY& uv1 = keyUV[ i ];
gp_XY& uv2 = ( i+1 < keyUV.size() ) ? keyUV[ i+1 ] : keyUV[ 0 ];
list< TPoint* > & ePoints = getShapePoints( iSub );
ePoints.back()->myInitU = 1.0;
list< TPoint* >::const_iterator pIt = ++ePoints.begin();
while ( *pIt != ePoints.back() )
{
TPoint* p = *pIt++;
p->myUV = uv1 * ( 1 - p->myInitU ) + uv2 * p->myInitU;
p->myXYZ = surface->Value( p->myUV.X(), p->myUV.Y() );
if ( !loc.IsIdentity() )
aTrsf.Transforms( p->myXYZ.ChangeCoord() );
}
// collect on-edge points (excluding the last one)
edgesPoints->insert( edgesPoints->end(), ePoints.begin(), --ePoints.end());
}
// Compute UV and XYZ of in-face points
// try to use a simple algo to compute UV
list< TPoint* > & fPoints = getShapePoints( iSub );
bool isDeformed = false;
for ( pIt = fPoints.begin(); !isDeformed && pIt != fPoints.end(); pIt++ )
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
// try to use a complex algo if it is a difficult case
if ( isDeformed && !compUVByElasticIsolines( edgesPointsList, fPoints ))
{
for ( ; pIt != fPoints.end(); pIt++ ) // continue with the simple algo
if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
(*pIt)->myUV, isDeformed )) {
MESSAGE("cant Apply(face)");
return false;
}
}
for ( pIt = fPoints.begin(); pIt != fPoints.end(); pIt++ )
{
TPoint * point = *pIt;
point->myXYZ = surface->Value( point->myUV.X(), point->myUV.Y() );
if ( !loc.IsIdentity() )
aTrsf.Transforms( point->myXYZ.ChangeCoord() );
}
myIsComputed = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern::Apply | ( | SMESH_Mesh * | theMesh, |
| std::set< const SMDS_MeshFace * > & | theFaces, | ||
| const int | theNodeIndexOnKeyPoint1, | ||
| const bool | theReverse | ||
| ) |
Definition at line 2926 of file SMESH_Pattern.cxx.
References PAL_MESH_043_3D.face, ex05_hole1build.ll, MESSAGE, SMESH_AdvancedEditor.n1, SMESH_AdvancedEditor.n2, SMESH_fixation.shape, and undefinedXYZ().
{
MESSAGE(" ::Apply(set<MeshFace>) " );
if ( !IsLoaded() ) {
MESSAGE( "Pattern not loaded" );
return setErrorCode( ERR_APPL_NOT_LOADED );
}
// find points on edges, it fills myNbKeyPntInBoundary
if ( !findBoundaryPoints() )
return false;
// check that there are no holes in a pattern
if (myNbKeyPntInBoundary.size() > 1 ) {
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
myShape.Nullify();
myXYZ.clear();
myElemXYZIDs.clear();
myXYZIdToNodeMap.clear();
myElements.clear();
myIdsOnBoundary.clear();
myReverseConnectivity.clear();
myXYZ.resize( myPoints.size() * theFaces.size(), undefinedXYZ() );
myElements.reserve( theFaces.size() );
// to find point index
map< TPoint*, int > pointIndex;
for ( int i = 0; i < myPoints.size(); i++ )
pointIndex.insert( make_pair( & myPoints[ i ], i ));
int ind1 = 0; // lowest point index for a face
// meshed geometry
TopoDS_Shape shape;
// int shapeID = 0;
// SMESH_MeshEditor editor( theMesh );
// apply to each face in theFaces set
set<const SMDS_MeshFace*>::iterator face = theFaces.begin();
for ( ; face != theFaces.end(); ++face )
{
// int curShapeId = editor.FindShape( *face );
// if ( curShapeId != shapeID ) {
// if ( curShapeId )
// shape = theMesh->GetMeshDS()->IndexToShape( curShapeId );
// else
// shape.Nullify();
// shapeID = curShapeId;
// }
bool ok;
if ( shape.IsNull() )
ok = Apply( *face, theNodeIndexOnKeyPoint1, theReverse );
else
ok = Apply( theMesh, *face, shape, theNodeIndexOnKeyPoint1, theReverse );
if ( !ok ) {
MESSAGE( "Failed on " << *face );
continue;
}
myElements.push_back( *face );
// store computed points belonging to elements
list< TElemDef >::iterator ll = myElemPointIDs.begin();
for ( ; ll != myElemPointIDs.end(); ++ll )
{
myElemXYZIDs.push_back(TElemDef());
TElemDef& xyzIds = myElemXYZIDs.back();
TElemDef& pIds = *ll;
for ( TElemDef::iterator id = pIds.begin(); id != pIds.end(); id++ ) {
int pIndex = *id + ind1;
xyzIds.push_back( pIndex );
myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ();
myReverseConnectivity[ pIndex ].push_back( & xyzIds );
}
}
// put points on links to myIdsOnBoundary,
// they will be used to sew new elements on adjacent refined elements
int nbNodes = (*face)->NbCornerNodes(), eID = nbNodes + 1;
for ( int i = 0; i < nbNodes; i++ )
{
list< TPoint* > & linkPoints = getShapePoints( eID++ );
const SMDS_MeshNode* n1 = myOrderedNodes[ i ];
const SMDS_MeshNode* n2 = myOrderedNodes[ i + 1 == nbNodes ? 0 : i + 1 ];
// make a link and a node set
TNodeSet linkSet, node1Set;
linkSet.insert( n1 );
linkSet.insert( n2 );
node1Set.insert( n1 );
list< TPoint* >::iterator p = linkPoints.begin();
{
// map the first link point to n1
int nId = pointIndex[ *p ] + ind1;
myXYZIdToNodeMap[ nId ] = n1;
list< list< int > >& groups = myIdsOnBoundary[ node1Set ];
groups.push_back(list< int > ());
groups.back().push_back( nId );
}
// add the linkSet to the map
list< list< int > >& groups = myIdsOnBoundary[ linkSet ];
groups.push_back(list< int > ());
list< int >& indList = groups.back();
// add points to the map excluding the end points
for ( p++; *p != linkPoints.back(); p++ )
indList.push_back( pointIndex[ *p ] + ind1 );
}
ind1 += myPoints.size();
}
return !myElemXYZIDs.empty();
}
| bool SMESH_Pattern::Apply | ( | const SMDS_MeshVolume * | theVolume, |
| const int | theNode000Index, | ||
| const int | theNode001Index | ||
| ) |
Definition at line 3376 of file SMESH_Pattern.cxx.
References SMESH_Block.EdgePoint(), SMESH_Block.FacePoint(), SMESH_Block.ID_Shell, SMESH_Block.ID_V000, SMESH_Block.IsEdgeID(), SMESH_Block.IsFaceID(), SMESH_Block.IsVertexID(), SMESH_Block.LoadMeshBlock(), SMESH_Block.ShellPoint(), and SMESH_Block.VertexPoint().
{
//MESSAGE(" ::Apply(MeshVolume) " );
if (!findBoundaryPoints()) // bind ID to points
return false;
SMESH_Block block; // bind ID to shape
if (!block.LoadMeshBlock( theVolume, theNode000Index, theNode001Index, myOrderedNodes ))
return setErrorCode( ERR_APPLV_BAD_SHAPE );
// compute XYZ of points on shapes
for ( int ID = SMESH_Block::ID_V000; ID <= SMESH_Block::ID_Shell; ID++ )
{
list< TPoint* > & shapePoints = getShapePoints( ID );
list< TPoint* >::iterator pIt = shapePoints.begin();
if ( block.IsVertexID( ID ))
for ( ; pIt != shapePoints.end(); pIt++ ) {
block.VertexPoint( ID, (*pIt)->myXYZ.ChangeCoord() );
}
else if ( block.IsEdgeID( ID ))
for ( ; pIt != shapePoints.end(); pIt++ ) {
block.EdgePoint( ID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
}
else if ( block.IsFaceID( ID ))
for ( ; pIt != shapePoints.end(); pIt++ ) {
block.FacePoint( ID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
}
else
for ( ; pIt != shapePoints.end(); pIt++ )
block.ShellPoint( (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
} // loop on block sub-shapes
myIsComputed = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern::Apply | ( | const TopoDS_Shell & | theBlock, |
| const TopoDS_Vertex & | theVertex000, | ||
| const TopoDS_Vertex & | theVertex001 | ||
| ) |
Definition at line 3315 of file SMESH_Pattern.cxx.
References SMESH_Block.EdgePoint(), SMESH_Block.FacePoint(), SMESH_Block.LoadBlockShapes(), MESSAGE, SMESH_Block.ShellPoint(), and SMESH_Block.VertexPoint().
{
MESSAGE(" ::Apply(volume) " );
if (!findBoundaryPoints() || // bind ID to points
!setShapeToMesh( theBlock )) // check theBlock is a suitable shape
return false;
SMESH_Block block; // bind ID to shape
if (!block.LoadBlockShapes( theBlock, theVertex000, theVertex001, myShapeIDMap ))
return setErrorCode( ERR_APPLV_BAD_SHAPE );
// compute XYZ of points on shapes
for ( int shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ )
{
list< TPoint* > & shapePoints = getShapePoints( shapeID );
list< TPoint* >::iterator pIt = shapePoints.begin();
const TopoDS_Shape& S = myShapeIDMap( shapeID );
switch ( S.ShapeType() )
{
case TopAbs_VERTEX: {
for ( ; pIt != shapePoints.end(); pIt++ )
block.VertexPoint( shapeID, (*pIt)->myXYZ.ChangeCoord() );
break;
}
case TopAbs_EDGE: {
for ( ; pIt != shapePoints.end(); pIt++ )
block.EdgePoint( shapeID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
break;
}
case TopAbs_FACE: {
for ( ; pIt != shapePoints.end(); pIt++ )
block.FacePoint( shapeID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
break;
}
default:
for ( ; pIt != shapePoints.end(); pIt++ )
block.ShellPoint( (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
}
} // loop on block sub-shapes
myIsComputed = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern::Apply | ( | std::set< const SMDS_MeshVolume * > & | theVolumes, |
| const int | theNode000Index, | ||
| const int | theNode001Index | ||
| ) |
Definition at line 3052 of file SMESH_Pattern.cxx.
References PAL_MESH_041_mesh.e1, PAL_MESH_041_mesh.e2, SMESH_Block.GetEdgeVertexIDs(), SMESH_Block.GetFaceEdgesIDs(), SMESH_Block.ID_F1yz, SMESH_Block.ID_V000, SMESH_Block.IsEdgeID(), SMESH_Block.IsVertexID(), ex05_hole1build.ll, MESSAGE, undefinedXYZ(), and SMESH_demo_hexa2_upd.vol.
{
MESSAGE(" ::Apply(set<MeshVolumes>) " );
if ( !IsLoaded() ) {
MESSAGE( "Pattern not loaded" );
return setErrorCode( ERR_APPL_NOT_LOADED );
}
// bind ID to points
if ( !findBoundaryPoints() )
return false;
// check that there are no holes in a pattern
if (myNbKeyPntInBoundary.size() > 1 ) {
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
myShape.Nullify();
myXYZ.clear();
myElemXYZIDs.clear();
myXYZIdToNodeMap.clear();
myElements.clear();
myIdsOnBoundary.clear();
myReverseConnectivity.clear();
myXYZ.resize( myPoints.size() * theVolumes.size(), undefinedXYZ() );
myElements.reserve( theVolumes.size() );
// to find point index
map< TPoint*, int > pointIndex;
for ( int i = 0; i < myPoints.size(); i++ )
pointIndex.insert( make_pair( & myPoints[ i ], i ));
int ind1 = 0; // lowest point index for an element
// apply to each element in theVolumes set
set<const SMDS_MeshVolume*>::iterator vol = theVolumes.begin();
for ( ; vol != theVolumes.end(); ++vol )
{
if ( !Apply( *vol, theNode000Index, theNode001Index )) {
MESSAGE( "Failed on " << *vol );
continue;
}
myElements.push_back( *vol );
// store computed points belonging to elements
list< TElemDef >::iterator ll = myElemPointIDs.begin();
for ( ; ll != myElemPointIDs.end(); ++ll )
{
myElemXYZIDs.push_back(TElemDef());
TElemDef& xyzIds = myElemXYZIDs.back();
TElemDef& pIds = *ll;
for ( TElemDef::iterator id = pIds.begin(); id != pIds.end(); id++ ) {
int pIndex = *id + ind1;
xyzIds.push_back( pIndex );
myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ();
myReverseConnectivity[ pIndex ].push_back( & xyzIds );
}
}
// put points on edges and faces to myIdsOnBoundary,
// they will be used to sew new elements on adjacent refined elements
for ( int Id = SMESH_Block::ID_V000; Id <= SMESH_Block::ID_F1yz; Id++ )
{
// make a set of sub-points
TNodeSet subNodes;
vector< int > subIDs;
if ( SMESH_Block::IsVertexID( Id )) {
subNodes.insert( myOrderedNodes[ Id - 1 ]);
}
else if ( SMESH_Block::IsEdgeID( Id )) {
SMESH_Block::GetEdgeVertexIDs( Id, subIDs );
subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
}
else {
SMESH_Block::GetFaceEdgesIDs( Id, subIDs );
int e1 = subIDs[ 0 ], e2 = subIDs[ 1 ];
SMESH_Block::GetEdgeVertexIDs( e1, subIDs );
subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
SMESH_Block::GetEdgeVertexIDs( e2, subIDs );
subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
}
// add points
list< TPoint* > & points = getShapePoints( Id );
list< TPoint* >::iterator p = points.begin();
list< list< int > >& groups = myIdsOnBoundary[ subNodes ];
groups.push_back(list< int > ());
list< int >& indList = groups.back();
for ( ; p != points.end(); p++ )
indList.push_back( pointIndex[ *p ] + ind1 );
if ( subNodes.size() == 1 ) // vertex case
myXYZIdToNodeMap[ indList.back() ] = myOrderedNodes[ Id - 1 ];
}
ind1 += myPoints.size();
}
return !myElemXYZIDs.empty();
}
| void SMESH_Pattern::arrangeBoundaries | ( | std::list< std::list< TPoint * > > & | boundaryPoints | ) | [private] |
Definition at line 4227 of file SMESH_Pattern.cxx.
References SMESH_Pattern.TPoint.myInitUV, SMESH_Pattern.TPoint.myInitXYZ, SMESH_mechanic_editor.point, and reverse().
{
typedef list< list< TPoint* > >::iterator TListOfListIt;
TListOfListIt bndIt;
list< TPoint* >::iterator pIt;
int nbBoundaries = boundaryList.size();
if ( nbBoundaries > 1 )
{
// sort boundaries by nb of key-points
if ( nbBoundaries > 2 )
{
// move boundaries in tmp list
list< list< TPoint* > > tmpList;
tmpList.splice( tmpList.begin(), boundaryList, boundaryList.begin(), boundaryList.end());
// make a map nb-key-points to boundary-position-in-tmpList,
// boundary-positions get ordered in it
typedef map< int, TListOfListIt > TNbKpBndPosMap;
TNbKpBndPosMap nbKpBndPosMap;
bndIt = tmpList.begin();
list< int >::iterator nbKpIt = myNbKeyPntInBoundary.begin();
for ( ; nbKpIt != myNbKeyPntInBoundary.end(); nbKpIt++, bndIt++ ) {
int nb = *nbKpIt * nbBoundaries;
while ( nbKpBndPosMap.find ( nb ) != nbKpBndPosMap.end() )
nb++;
nbKpBndPosMap.insert( TNbKpBndPosMap::value_type( nb, bndIt ));
}
// move boundaries back to boundaryList
TNbKpBndPosMap::iterator nbKpBndPosIt = nbKpBndPosMap.begin();
for ( ; nbKpBndPosIt != nbKpBndPosMap.end(); nbKpBndPosIt++ ) {
TListOfListIt & bndPos2 = (*nbKpBndPosIt).second;
TListOfListIt bndPos1 = bndPos2++;
boundaryList.splice( boundaryList.end(), tmpList, bndPos1, bndPos2 );
}
}
// Look for the outer boundary: the one with the point with the least X
double leastX = DBL_MAX;
TListOfListIt outerBndPos;
for ( bndIt = boundaryList.begin(); bndIt != boundaryList.end(); bndIt++ )
{
list< TPoint* >& boundary = (*bndIt);
for ( pIt = boundary.begin(); pIt != boundary.end(); pIt++)
{
TPoint* point = *pIt;
if ( point->myInitXYZ.X() < leastX ) {
leastX = point->myInitXYZ.X();
outerBndPos = bndIt;
}
}
}
if ( outerBndPos != boundaryList.begin() )
boundaryList.splice( boundaryList.begin(), boundaryList, outerBndPos, ++outerBndPos );
} // if nbBoundaries > 1
// Check boundaries orientation and re-fill myKeyPointIDs
set< TPoint* > keyPointSet;
list< int >::iterator kpIt = myKeyPointIDs.begin();
for ( ; kpIt != myKeyPointIDs.end(); kpIt++ )
keyPointSet.insert( & myPoints[ *kpIt ]);
myKeyPointIDs.clear();
// update myNbKeyPntInBoundary also
list< int >::iterator nbKpIt = myNbKeyPntInBoundary.begin();
for ( bndIt = boundaryList.begin(); bndIt != boundaryList.end(); bndIt++, nbKpIt++ )
{
// find the point with the least X
double leastX = DBL_MAX;
list< TPoint* >::iterator xpIt;
list< TPoint* >& boundary = (*bndIt);
for ( pIt = boundary.begin(); pIt != boundary.end(); pIt++)
{
TPoint* point = *pIt;
if ( point->myInitXYZ.X() < leastX ) {
leastX = point->myInitXYZ.X();
xpIt = pIt;
}
}
// find points next to the point with the least X
TPoint* p = *xpIt, *pPrev, *pNext;
if ( p == boundary.front() )
pPrev = *(++boundary.rbegin());
else {
xpIt--;
pPrev = *xpIt;
xpIt++;
}
if ( p == boundary.back() )
pNext = *(++boundary.begin());
else {
xpIt++;
pNext = *xpIt;
}
// vectors of boundary direction near <p>
gp_Vec2d v1( pPrev->myInitUV, p->myInitUV ), v2( p->myInitUV, pNext->myInitUV );
double sqMag1 = v1.SquareMagnitude(), sqMag2 = v2.SquareMagnitude();
if ( sqMag1 > DBL_MIN && sqMag2 > DBL_MIN ) {
double yPrev = v1.Y() / sqrt( sqMag1 );
double yNext = v2.Y() / sqrt( sqMag2 );
double sumY = yPrev + yNext;
bool reverse;
if ( bndIt == boundaryList.begin() ) // outer boundary
reverse = sumY > 0;
else
reverse = sumY < 0;
if ( reverse )
boundary.reverse();
}
// Put key-point IDs of a well-oriented boundary in myKeyPointIDs
(*nbKpIt) = 0; // count nb of key-points again
pIt = boundary.begin();
for ( ; pIt != boundary.end(); pIt++)
{
TPoint* point = *pIt;
if ( keyPointSet.find( point ) == keyPointSet.end() )
continue;
// find an index of a keypoint
int index = 0;
vector< TPoint >::const_iterator pVecIt = myPoints.begin();
for ( ; pVecIt != myPoints.end(); pVecIt++, index++ )
if ( &(*pVecIt) == point )
break;
myKeyPointIDs.push_back( index );
(*nbKpIt)++;
}
myKeyPointIDs.pop_back(); // remove the first key-point from the back
(*nbKpIt)--;
} // loop on a list of boundaries
ASSERT( myKeyPointIDs.size() == keyPointSet.size() );
}
| void SMESH_Pattern.Clear | ( | ) |
| void SMESH_Pattern::clearMesh | ( | SMESH_Mesh * | theMesh | ) | const [private] |
Definition at line 3866 of file SMESH_Pattern.cxx.
References clearSubMesh().
{
if ( !myShape.IsNull() )
{
if ( !clearSubMesh( theMesh, myShape ) && !myIs2D ) { // myShape is SHELL but volumes may be bound to SOLID
TopTools_ListIteratorOfListOfShape it( theMesh->GetAncestors( myShape ));
for (; it.More() && it.Value().ShapeType() == TopAbs_SOLID; it.Next())
{
clearSubMesh( theMesh, it.Value() );
}
}
}
}
| void SMESH_Pattern::computeUVOnEdge | ( | const TopoDS_Edge & | theEdge, |
| const std::list< TPoint * > & | ePoints | ||
| ) | [private] |
Definition at line 985 of file SMESH_Pattern.cxx.
References Handle(), SMESH_Pattern.TPoint.myInitU, SMESH_Pattern.TPoint.myU, SMESH_Pattern.TPoint.myUV, and SMESH_mechanic_editor.point.
{
bool isForward = ( theEdge.Orientation() == TopAbs_FORWARD );
double f, l;
Handle(Geom2d_Curve) C2d =
BRep_Tool::CurveOnSurface( theEdge, TopoDS::Face( myShape ), f, l );
ePoints.back()->myInitU = 1.0;
list< TPoint* >::const_iterator pIt = ePoints.begin();
for ( pIt++; pIt != ePoints.end(); pIt++ )
{
TPoint* point = *pIt;
// U
double du = ( isForward ? point->myInitU : 1 - point->myInitU );
point->myU = ( f * ( 1 - du ) + l * du );
// UV
point->myUV = C2d->Value( point->myU ).XY();
}
}
| bool SMESH_Pattern::compUVByElasticIsolines | ( | const std::list< std::list< TPoint * > > & | boundaryPoints, |
| const std::list< TPoint * > & | pointsToCompute | ||
| ) | [private] |
WHAT IN THIS CASE ????????????? MAY BE THIS, I AM NOT SURE :(
Definition at line 1449 of file SMESH_Pattern.cxx.
References Abs(), SMESH_demo_hexa2_upd.angle, checkQuads(), ex10_grid4geometry.dir, FIX_OLD, TIsoNode.GetBoundaryNode(), TIsoNode.GetNext(), IsEqual(), TIsoNode.IsMovable(), TIsoNode.IsUVComputed(), Max(), MESSAGE, Min(), TIsoNode.myDir, TIsoNode.myInitUV, SMESH_Pattern.TPoint.myInitUV, TIsoNode.myNext, TIsoNode.myRatio, TIsoNode.myUV, SMESH_Pattern.TPoint.myUV, ex29_refine.node(), SMESH_AdvancedEditor.nodes, PI, SMESH_mechanic_editor.point, TIsoNode.SetBoundaryNode(), TIsoNode.SetNext(), TIsoNode.SetNotMovable(), and SMESH_AdvancedEditor.tol.
{
return false; // PAL17233
//cout << "============================== KEY POINTS =============================="<<endl;
// list< int >::iterator kpIt = myKeyPointIDs.begin();
// for ( ; kpIt != myKeyPointIDs.end(); kpIt++ ) {
// TPoint& p = myPoints[ *kpIt ];
// cout << "INIT: " << p.myInitUV.X() << " " << p.myInitUV.Y() <<
// " UV: " << p.myUV.X() << " " << p.myUV.Y() << endl;
// }
//cout << "=============================="<<endl;
// Define parameters of iso-grid nodes in U and V dir
set< double > paramSet[ 2 ];
list< list< TPoint* > >::const_iterator pListIt;
list< TPoint* >::const_iterator pIt;
for ( pListIt = theBndPoints.begin(); pListIt != theBndPoints.end(); pListIt++ ) {
const list< TPoint* > & pList = * pListIt;
for ( pIt = pList.begin(); pIt != pList.end(); pIt++ ) {
paramSet[0].insert( (*pIt)->myInitUV.X() );
paramSet[1].insert( (*pIt)->myInitUV.Y() );
}
}
for ( pIt = thePntToCompute.begin(); pIt != thePntToCompute.end(); pIt++ ) {
paramSet[0].insert( (*pIt)->myInitUV.X() );
paramSet[1].insert( (*pIt)->myInitUV.Y() );
}
// unite close parameters and split too long segments
int iDir;
double tol[ 2 ];
for ( iDir = 0; iDir < 2; iDir++ )
{
set< double > & params = paramSet[ iDir ];
double range = ( *params.rbegin() - *params.begin() );
double toler = range / 1e6;
tol[ iDir ] = toler;
// double maxSegment = range / params.size() / 2.;
//
// set< double >::iterator parIt = params.begin();
// double prevPar = *parIt;
// for ( parIt++; parIt != params.end(); parIt++ )
// {
// double segLen = (*parIt) - prevPar;
// if ( segLen < toler )
// ;//params.erase( prevPar ); // unite
// else if ( segLen > maxSegment )
// params.insert( prevPar + 0.5 * segLen ); // split
// prevPar = (*parIt);
// }
}
// Make nodes of a grid of iso-poly-lines
list < TIsoNode > nodes;
typedef list < TIsoNode *> TIsoLine;
map < double, TIsoLine > isoMap[ 2 ];
set< double > & params0 = paramSet[ 0 ];
set< double >::iterator par0It = params0.begin();
for ( ; par0It != params0.end(); par0It++ )
{
TIsoLine & isoLine0 = isoMap[0][ *par0It ]; // vertical isoline with const U
set< double > & params1 = paramSet[ 1 ];
set< double >::iterator par1It = params1.begin();
for ( ; par1It != params1.end(); par1It++ )
{
nodes.push_back( TIsoNode( *par0It, *par1It ) );
isoLine0.push_back( & nodes.back() );
isoMap[1][ *par1It ].push_back( & nodes.back() );
}
}
// Compute intersections of boundaries with iso-lines:
// only boundary nodes will have computed UV so far
Bnd_Box2d uvBnd;
list< list< TPoint* > >::const_iterator bndIt = theBndPoints.begin();
list< TIsoNode* > bndNodes; // nodes corresponding to outer theBndPoints
for ( ; bndIt != theBndPoints.end(); bndIt++ )
{
const list< TPoint* > & bndPoints = * bndIt;
TPoint* prevP = bndPoints.back(); // this is the first point
list< TPoint* >::const_iterator pIt = bndPoints.begin();
// loop on the edge-points
for ( ; pIt != bndPoints.end(); pIt++ )
{
TPoint* point = *pIt;
for ( iDir = 0; iDir < 2; iDir++ )
{
const int iCoord = iDir + 1;
const int iOtherCoord = 2 - iDir;
double par1 = prevP->myInitUV.Coord( iCoord );
double par2 = point->myInitUV.Coord( iCoord );
double parDif = par2 - par1;
if ( Abs( parDif ) <= DBL_MIN )
continue;
// find iso-lines intersecting a bounadry
double toler = tol[ 1 - iDir ];
double minPar = Min ( par1, par2 );
double maxPar = Max ( par1, par2 );
map < double, TIsoLine >& isos = isoMap[ iDir ];
map < double, TIsoLine >::iterator isoIt = isos.begin();
for ( ; isoIt != isos.end(); isoIt++ )
{
double isoParam = (*isoIt).first;
if ( isoParam < minPar || isoParam > maxPar )
continue;
double r = ( isoParam - par1 ) / parDif;
gp_XY uv = ( 1 - r ) * prevP->myUV + r * point->myUV;
gp_XY initUV = ( 1 - r ) * prevP->myInitUV + r * point->myInitUV;
double otherPar = initUV.Coord( iOtherCoord ); // along isoline
// find existing node with otherPar or insert a new one
TIsoLine & isoLine = (*isoIt).second;
double nodePar;
TIsoLine::iterator nIt = isoLine.begin();
for ( ; nIt != isoLine.end(); nIt++ ) {
nodePar = (*nIt)->myInitUV.Coord( iOtherCoord );
if ( nodePar >= otherPar )
break;
}
TIsoNode * node;
if ( Abs( nodePar - otherPar ) <= toler )
node = ( nIt == isoLine.end() ) ? isoLine.back() : (*nIt);
else {
nodes.push_back( TIsoNode( initUV.X(), initUV.Y() ) );
node = & nodes.back();
isoLine.insert( nIt, node );
}
node->SetNotMovable();
node->myUV = uv;
uvBnd.Add( gp_Pnt2d( uv ));
// cout << "bnd: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<" UV: "<<node->myUV.X()<<" "<<node->myUV.Y()<<endl;
// tangent dir
gp_XY tgt( point->myUV - prevP->myUV );
if ( ::IsEqual( r, 1. ))
node->myDir[ 0 ] = tgt;
else if ( ::IsEqual( r, 0. ))
node->myDir[ 1 ] = tgt;
else
node->myDir[ 1 ] = node->myDir[ 0 ] = tgt;
// keep boundary nodes corresponding to boundary points
if ( bndIt == theBndPoints.begin() && ::IsEqual( r, 1. ))
if ( bndNodes.empty() || bndNodes.back() != node )
bndNodes.push_back( node );
} // loop on isolines
} // loop on 2 directions
prevP = point;
} // loop on boundary points
} // loop on boundaries
// Define orientation
// find the point with the least X
double leastX = DBL_MAX;
TIsoNode * leftNode;
list < TIsoNode >::iterator nodeIt = nodes.begin();
for ( ; nodeIt != nodes.end(); nodeIt++ ) {
TIsoNode & node = *nodeIt;
if ( node.IsUVComputed() && node.myUV.X() < leastX ) {
leastX = node.myUV.X();
leftNode = &node;
}
// if ( node.IsUVComputed() ) {
// cout << "bndNode INIT: " << node.myInitUV.X()<<" "<<node.myInitUV.Y()<<" UV: "<<
// node.myUV.X()<<" "<<node.myUV.Y()<<endl<<
// " dir0: "<<node.myDir[0].X()<<" "<<node.myDir[0].Y() <<
// " dir1: "<<node.myDir[1].X()<<" "<<node.myDir[1].Y() << endl;
// }
}
bool reversed = ( leftNode->myDir[0].Y() + leftNode->myDir[1].Y() > 0 );
//SCRUTE( reversed );
// Prepare internal nodes:
// 1. connect nodes
// 2. compute ratios
// 3. find boundary nodes for each node
// 4. remove nodes out of the boundary
for ( iDir = 0; iDir < 2; iDir++ )
{
const int iCoord = 2 - iDir; // coord changing along an isoline
map < double, TIsoLine >& isos = isoMap[ iDir ];
map < double, TIsoLine >::iterator isoIt = isos.begin();
for ( ; isoIt != isos.end(); isoIt++ )
{
TIsoLine & isoLine = (*isoIt).second;
bool firstCompNodeFound = false;
TIsoLine::iterator lastCompNodePos, nPrevIt, nIt, nNextIt, nIt2;
nPrevIt = nIt = nNextIt = isoLine.begin();
nIt++;
nNextIt++; nNextIt++;
while ( nIt != isoLine.end() )
{
// 1. connect prev - cur
TIsoNode* node = *nIt, * prevNode = *nPrevIt;
if ( !firstCompNodeFound && prevNode->IsUVComputed() ) {
firstCompNodeFound = true;
lastCompNodePos = nPrevIt;
}
if ( firstCompNodeFound ) {
node->SetNext( prevNode, iDir, 0 );
prevNode->SetNext( node, iDir, 1 );
}
// 2. compute ratio
if ( nNextIt != isoLine.end() ) {
double par1 = prevNode->myInitUV.Coord( iCoord );
double par2 = node->myInitUV.Coord( iCoord );
double par3 = (*nNextIt)->myInitUV.Coord( iCoord );
node->myRatio[ iDir ] = ( par2 - par1 ) / ( par3 - par1 );
}
// 3. find boundary nodes
if ( node->IsUVComputed() )
lastCompNodePos = nIt;
else if ( firstCompNodeFound && nNextIt != isoLine.end() ) {
TIsoNode* bndNode1 = *lastCompNodePos, *bndNode2 = 0;
for ( nIt2 = nNextIt; nIt2 != isoLine.end(); nIt2++ )
if ( (*nIt2)->IsUVComputed() )
break;
if ( nIt2 != isoLine.end() ) {
bndNode2 = *nIt2;
node->SetBoundaryNode( bndNode1, iDir, 0 );
node->SetBoundaryNode( bndNode2, iDir, 1 );
// cout << "--------------------------------------------------"<<endl;
// cout << "bndNode1: " << bndNode1->myUV.X()<<" "<<bndNode1->myUV.Y()<<endl<<
// " dir0: "<<bndNode1->myDir[0].X()<<" "<<bndNode1->myDir[0].Y() <<
// " dir1: "<<bndNode1->myDir[1].X()<<" "<<bndNode1->myDir[1].Y() << endl;
// cout << "bndNode2: " << bndNode2->myUV.X()<<" "<<bndNode2->myUV.Y()<<endl<<
// " dir0: "<<bndNode2->myDir[0].X()<<" "<<bndNode2->myDir[0].Y() <<
// " dir1: "<<bndNode2->myDir[1].X()<<" "<<bndNode2->myDir[1].Y() << endl;
}
else {
node->SetBoundaryNode( 0, iDir, 0 );
node->SetBoundaryNode( 0, iDir, 1 );
}
}
nIt++; nPrevIt++;
if ( nNextIt != isoLine.end() ) nNextIt++;
// 4. remove nodes out of the boundary
if ( !firstCompNodeFound )
isoLine.pop_front();
} // loop on isoLine nodes
// remove nodes after the boundary
// for ( nIt = ++lastCompNodePos; nIt != isoLine.end(); nIt++ )
// (*nIt)->SetNotMovable();
isoLine.erase( ++lastCompNodePos, isoLine.end() );
} // loop on isolines
} // loop on 2 directions
// Compute local isoline direction for internal nodes
/*
map < double, TIsoLine >& isos = isoMap[ 0 ]; // vertical isolines with const U
map < double, TIsoLine >::iterator isoIt = isos.begin();
for ( ; isoIt != isos.end(); isoIt++ )
{
TIsoLine & isoLine = (*isoIt).second;
TIsoLine::iterator nIt = isoLine.begin();
for ( ; nIt != isoLine.end(); nIt++ )
{
TIsoNode* node = *nIt;
if ( node->IsUVComputed() || !node->IsMovable() )
continue;
gp_Vec2d aTgt[2], aNorm[2];
double ratio[2];
bool OK = true;
for ( iDir = 0; iDir < 2; iDir++ )
{
TIsoNode* bndNode1 = node->GetBoundaryNode( iDir, 0 );
TIsoNode* bndNode2 = node->GetBoundaryNode( iDir, 1 );
if ( !bndNode1 || !bndNode2 ) {
OK = false;
break;
}
const int iCoord = 2 - iDir; // coord changing along an isoline
double par1 = bndNode1->myInitUV.Coord( iCoord );
double par2 = node->myInitUV.Coord( iCoord );
double par3 = bndNode2->myInitUV.Coord( iCoord );
ratio[ iDir ] = ( par2 - par1 ) / ( par3 - par1 );
gp_Vec2d tgt1( bndNode1->myDir[0].XY() + bndNode1->myDir[1].XY() );
gp_Vec2d tgt2( bndNode2->myDir[0].XY() + bndNode2->myDir[1].XY() );
if ( bool( iDir ) == reversed ) tgt2.Reverse(); // along perpend. isoline
else tgt1.Reverse();
//cout<<" tgt: " << tgt1.X()<<" "<<tgt1.Y()<<" | "<< tgt2.X()<<" "<<tgt2.Y()<<endl;
if ( ratio[ iDir ] < 0.5 )
aNorm[ iDir ] = gp_Vec2d( -tgt1.Y(), tgt1.X() ); // rotate tgt to the left
else
aNorm[ iDir ] = gp_Vec2d( -tgt2.Y(), tgt2.X() );
if ( iDir == 1 )
aNorm[ iDir ].Reverse(); // along iDir isoline
double angle = tgt1.Angle( tgt2 ); // [-PI, PI]
// maybe angle is more than |PI|
if ( Abs( angle ) > PI / 2. ) {
// check direction of the last but one perpendicular isoline
TIsoNode* prevNode = bndNode2->GetNext( iDir, 0 );
bndNode1 = prevNode->GetBoundaryNode( 1 - iDir, 0 );
bndNode2 = prevNode->GetBoundaryNode( 1 - iDir, 1 );
gp_Vec2d isoDir( bndNode1->myUV, bndNode2->myUV );
if ( isoDir * tgt2 < 0 )
isoDir.Reverse();
double angle2 = tgt1.Angle( isoDir );
//cout << " isoDir: "<< isoDir.X() <<" "<<isoDir.Y() << " ANGLE: "<< angle << " "<<angle2<<endl;
if (angle2 * angle < 0 && // check the sign of an angle close to PI
Abs ( Abs ( angle ) - PI ) <= PI / 180. ) {
//MESSAGE("REVERSE ANGLE");
angle = -angle;
}
if ( Abs( angle2 ) > Abs( angle ) ||
( angle2 * angle < 0 && Abs( angle2 ) > Abs( angle - angle2 ))) {
//MESSAGE("Add PI");
// cout << "NODE: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<endl;
// cout <<"ISO: " << isoParam << " " << (*iso2It).first << endl;
// cout << "bndNode1: " << bndNode1->myUV.X()<<" "<<bndNode1->myUV.Y()<< endl;
// cout << "bndNode2: " << bndNode2->myUV.X()<<" "<<bndNode2->myUV.Y()<<endl;
// cout <<" tgt: " << tgt1.X()<<" "<<tgt1.Y()<<" "<< tgt2.X()<<" "<<tgt2.Y()<<endl;
angle += ( angle < 0 ) ? 2. * PI : -2. * PI;
}
}
aTgt[ iDir ] = tgt1.Rotated( angle * ratio[ iDir ] ).XY();
} // loop on 2 dir
if ( OK ) {
for ( iDir = 0; iDir < 2; iDir++ )
{
aTgt[iDir].Normalize();
aNorm[1-iDir].Normalize();
double r = Abs ( ratio[iDir] - 0.5 ) * 2.0; // [0,1] - distance from the middle
r *= r;
node->myDir[iDir] = //aTgt[iDir];
aNorm[1-iDir] * r + aTgt[iDir] * ( 1. - r );
}
// cout << "NODE: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<endl;
// cout <<" tgt: " << tgt1.X()<<" "<<tgt1.Y()<<" - "<< tgt2.X()<<" "<<tgt2.Y()<<endl;
// cout << " isoDir: "<< node->myDir[0].X() <<" "<<node->myDir[0].Y()<<" | "
// << node->myDir[1].X() <<" "<<node->myDir[1].Y()<<endl;
}
} // loop on iso nodes
} // loop on isolines
*/
// Find nodes to start computing UV from
list< TIsoNode* > startNodes;
list< TIsoNode* >::iterator nIt = bndNodes.end();
TIsoNode* node = *(--nIt);
TIsoNode* prevNode = *(--nIt);
for ( nIt = bndNodes.begin(); nIt != bndNodes.end(); nIt++ )
{
TIsoNode* nextNode = *nIt;
gp_Vec2d initTgt1( prevNode->myInitUV, node->myInitUV );
gp_Vec2d initTgt2( node->myInitUV, nextNode->myInitUV );
double initAngle = initTgt1.Angle( initTgt2 );
double angle = node->myDir[0].Angle( node->myDir[1] );
if ( reversed ) angle = -angle;
if ( initAngle > angle && initAngle - angle > PI / 2.1 ) {
// find a close internal node
TIsoNode* nClose = 0;
list< TIsoNode* > testNodes;
testNodes.push_back( node );
list< TIsoNode* >::iterator it = testNodes.begin();
for ( ; !nClose && it != testNodes.end(); it++ )
{
for (int i = 0; i < 4; i++ )
{
nClose = (*it)->myNext[ i ];
if ( nClose ) {
if ( !nClose->IsUVComputed() )
break;
else {
testNodes.push_back( nClose );
nClose = 0;
}
}
}
}
startNodes.push_back( nClose );
// cout << "START: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<" UV: "<<
// node->myUV.X()<<" "<<node->myUV.Y()<<endl<<
// "initAngle: " << initAngle << " angle: " << angle << endl;
// cout <<" init tgt: " << initTgt1.X()<<" "<<initTgt1.Y()<<" | "<< initTgt2.X()<<" "<<initTgt2.Y()<<endl;
// cout << " tgt: "<< node->myDir[ 0 ].X() <<" "<<node->myDir[ 0 ].Y()<<" | "<<
// node->myDir[ 1 ].X() <<" "<<node->myDir[ 1 ].Y()<<endl;
// cout << "CLOSE: "<<nClose->myInitUV.X()<<" "<<nClose->myInitUV.Y()<<endl;
}
prevNode = node;
node = nextNode;
}
// Compute starting UV of internal nodes
list < TIsoNode* > internNodes;
bool needIteration = true;
if ( startNodes.empty() ) {
MESSAGE( " Starting UV by compUVByIsoIntersection()");
needIteration = false;
map < double, TIsoLine >& isos = isoMap[ 0 ];
map < double, TIsoLine >::iterator isoIt = isos.begin();
for ( ; isoIt != isos.end(); isoIt++ )
{
TIsoLine & isoLine = (*isoIt).second;
TIsoLine::iterator nIt = isoLine.begin();
for ( ; !needIteration && nIt != isoLine.end(); nIt++ )
{
TIsoNode* node = *nIt;
if ( !node->IsUVComputed() && node->IsMovable() ) {
internNodes.push_back( node );
//bool isDeformed;
if ( !compUVByIsoIntersection(theBndPoints, node->myInitUV,
node->myUV, needIteration ))
node->myUV = node->myInitUV;
}
}
}
if ( needIteration )
for ( nIt = bndNodes.begin(); nIt != bndNodes.end(); nIt++ )
{
TIsoNode* node = *nIt, *nClose = 0;
list< TIsoNode* > testNodes;
testNodes.push_back( node );
list< TIsoNode* >::iterator it = testNodes.begin();
for ( ; !nClose && it != testNodes.end(); it++ )
{
for (int i = 0; i < 4; i++ )
{
nClose = (*it)->myNext[ i ];
if ( nClose ) {
if ( !nClose->IsUVComputed() && nClose->IsMovable() )
break;
else {
testNodes.push_back( nClose );
nClose = 0;
}
}
}
}
startNodes.push_back( nClose );
}
}
double aMin[2], aMax[2], step[2];
uvBnd.Get( aMin[0], aMin[1], aMax[0], aMax[1] );
double minUvSize = Min ( aMax[0]-aMin[0], aMax[1]-aMin[1] );
step[0] = minUvSize / paramSet[ 0 ].size() / 10;
step[1] = minUvSize / paramSet[ 1 ].size() / 10;
//cout << "STEPS: " << step[0] << " " << step[1]<< endl;
for ( nIt = startNodes.begin(); nIt != startNodes.end(); nIt++ )
{
TIsoNode *node = *nIt;
if ( node->IsUVComputed() || !node->IsMovable() )
continue;
gp_XY newUV( 0, 0 ), sumDir( 0, 0 );
int nbComp = 0, nbPrev = 0;
for ( iDir = 0; iDir < 2; iDir++ )
{
TIsoNode* prevNode1 = 0, *prevNode2 = 0;
TIsoNode* n = node->GetNext( iDir, 0 );
if ( n->IsUVComputed() )
prevNode1 = n;
else
startNodes.push_back( n );
n = node->GetNext( iDir, 1 );
if ( n->IsUVComputed() )
prevNode2 = n;
else
startNodes.push_back( n );
if ( !prevNode1 ) {
prevNode1 = prevNode2;
prevNode2 = 0;
}
if ( prevNode1 ) nbPrev++;
if ( prevNode2 ) nbPrev++;
if ( prevNode1 ) {
gp_XY dir;
double prevPar = prevNode1->myInitUV.Coord( 2 - iDir );
double par = node->myInitUV.Coord( 2 - iDir );
bool isEnd = ( prevPar > par );
// dir = node->myDir[ 1 - iDir ].XY() * ( isEnd ? -1. : 1. );
//cout << "__________"<<endl<< "NODE: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<endl;
TIsoNode* bndNode = node->GetBoundaryNode( iDir, isEnd );
if ( !bndNode ) {
MESSAGE("Why we are here?");
continue;
}
gp_XY tgt( bndNode->myDir[0].XY() + bndNode->myDir[1].XY() );
dir.SetCoord( 1, tgt.Y() * ( reversed ? 1 : -1 ));
dir.SetCoord( 2, tgt.X() * ( reversed ? -1 : 1 ));
//cout << "bndNode UV: " << bndNode->myUV.X()<<" "<<bndNode->myUV.Y()<< endl;
// cout << " tgt: "<< bndNode->myDir[ 0 ].X() <<" "<<bndNode->myDir[ 0 ].Y()<<" | "<<
// bndNode->myDir[ 1 ].X() <<" "<<bndNode->myDir[ 1 ].Y()<<endl;
//cout << "prevNode UV: " << prevNode1->myUV.X()<<" "<<prevNode1->myUV.Y()<<
//" par: " << prevPar << endl;
// cout <<" tgt: " << tgt.X()<<" "<<tgt.Y()<<endl;
//cout << " DIR: "<< dir.X() <<" "<<dir.Y()<<endl;
if ( prevNode2 ) {
//cout << "____2next______"<<endl<< "NODE: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<endl;
gp_XY & uv1 = prevNode1->myUV;
gp_XY & uv2 = prevNode2->myUV;
// dir = ( uv2 - uv1 );
// double len = dir.Modulus();
// if ( len > DBL_MIN )
// dir /= len * 0.5;
double r = node->myRatio[ iDir ];
newUV += uv1 * ( 1 - r ) + uv2 * r;
}
else {
newUV += prevNode1->myUV + dir * step[ iDir ];
}
sumDir += dir;
nbComp++;
}
}
if ( !nbComp ) continue;
newUV /= nbComp;
node->myUV = newUV;
//cout << "NODE: "<<node->myInitUV.X()<<" "<<node->myInitUV.Y()<<endl;
// check if a quadrangle is not distorted
if ( nbPrev > 1 ) {
//int crit = ( nbPrev == 4 ) ? FIX_OLD : CHECK_NEW_IN;
if ( !checkQuads( node, newUV, reversed, FIX_OLD, step[0] + step[1] )) {
//cout <<" newUV: " << node->myUV.X() << " "<<node->myUV.Y() << " nbPrev: "<<nbPrev<< endl;
// cout << "_FIX_INIT_ fixedUV: " << newUV.X() << " "<<newUV.Y() << endl;
node->myUV = newUV;
}
}
internNodes.push_back( node );
}
// Move nodes
static int maxNbIter = 100;
#ifdef DEB_COMPUVBYELASTICISOLINES
// maxNbIter++;
bool useNbMoveNode = 0;
static int maxNbNodeMove = 100;
maxNbNodeMove++;
int nbNodeMove = 0;
if ( !useNbMoveNode )
maxNbIter = ( maxNbIter < 0 ) ? 100 : -1;
#endif
double maxMove;
int nbIter = 0;
do {
if ( !needIteration) break;
#ifdef DEB_COMPUVBYELASTICISOLINES
if ( nbIter >= maxNbIter ) break;
#endif
maxMove = 0.0;
list < TIsoNode* >::iterator nIt = internNodes.begin();
for ( ; nIt != internNodes.end(); nIt++ ) {
#ifdef DEB_COMPUVBYELASTICISOLINES
if (useNbMoveNode )
cout << nbNodeMove <<" =================================================="<<endl;
#endif
TIsoNode * node = *nIt;
// make lines
//gp_Lin2d line[2];
gp_XY loc[2];
for ( iDir = 0; iDir < 2; iDir++ )
{
gp_XY & uv1 = node->GetNext( iDir, 0 )->myUV;
gp_XY & uv2 = node->GetNext( iDir, 1 )->myUV;
double r = node->myRatio[ iDir ];
loc[ iDir ] = uv1 * ( 1 - r ) + uv2 * r;
// line[ iDir ].SetLocation( loc[ iDir ] );
// line[ iDir ].SetDirection( node->myDir[ iDir ] );
}
// define ratio
bool ok = true; // <- stupid fix TO AVOID PB OF NODES WITH NULL BND NODES
// double locR[2] = { 0, 0 };
for ( iDir = 0; iDir < 2; iDir++ )
{
const int iCoord = 2 - iDir; // coord changing along an isoline
TIsoNode* bndNode1 = node->GetBoundaryNode( iDir, 0 );
TIsoNode* bndNode2 = node->GetBoundaryNode( iDir, 1 );
if ( !bndNode1 || !bndNode2 ) {
ok = false; break;
}
double par1 = bndNode1->myInitUV.Coord( iCoord );
double par2 = node->myInitUV.Coord( iCoord );
double par3 = bndNode2->myInitUV.Coord( iCoord );
double r = ( par2 - par1 ) / ( par3 - par1 );
r = Abs ( r - 0.5 ) * 2.0; // [0,1] - distance from the middle
// locR[ iDir ] = ( 1 - r * r ) * 0.25;
}
//locR[0] = locR[1] = 0.25;
// intersect the 2 lines and move a node
//IntAna2d_AnaIntersection inter( line[0], line[1] );
if ( ok /*inter.IsDone() && inter.NbPoints() ==*/ )
{
// double intR = 1 - locR[0] - locR[1];
// gp_XY newUV = inter.Point(1).Value().XY();
// if ( !checkQuads( node, newUV, reversed, CHECK_NEW_IN ))
// newUV = ( locR[0] * loc[0] + locR[1] * loc[1] ) / ( 1 - intR );
// else
// newUV = intR * newUV + locR[0] * loc[0] + locR[1] * loc[1];
gp_XY newUV = 0.5 * ( loc[0] + loc[1] );
// avoid parallel isolines intersection
checkQuads( node, newUV, reversed );
maxMove = Max( maxMove, ( newUV - node->myUV ).SquareModulus());
node->myUV = newUV;
} // intersection found
#ifdef DEB_COMPUVBYELASTICISOLINES
if (useNbMoveNode && ++nbNodeMove >= maxNbNodeMove ) break;
#endif
} // loop on internal nodes
#ifdef DEB_COMPUVBYELASTICISOLINES
if (useNbMoveNode && nbNodeMove >= maxNbNodeMove ) break;
#endif
} while ( maxMove > 1e-8 && nbIter++ < maxNbIter );
MESSAGE( "compUVByElasticIsolines(): Nb iterations " << nbIter << " dist: " << sqrt( maxMove ));
if ( nbIter >= maxNbIter && sqrt(maxMove) > minUvSize * 0.05 ) {
MESSAGE( "compUVByElasticIsolines() failed: "<<sqrt(maxMove)<<">"<<minUvSize * 0.05);
#ifndef DEB_COMPUVBYELASTICISOLINES
return false;
#endif
}
// Set computed UV to points
for ( pIt = thePntToCompute.begin(); pIt != thePntToCompute.end(); pIt++ ) {
TPoint* point = *pIt;
//gp_XY oldUV = point->myUV;
double minDist = DBL_MAX;
list < TIsoNode >::iterator nIt = nodes.begin();
for ( ; nIt != nodes.end(); nIt++ ) {
double dist = ( (*nIt).myInitUV - point->myInitUV ).SquareModulus();
if ( dist < minDist ) {
minDist = dist;
point->myUV = (*nIt).myUV;
}
}
}
return true;
}
| bool SMESH_Pattern::compUVByIsoIntersection | ( | const std::list< std::list< TPoint * > > & | boundaryPoints, |
| const gp_XY & | theInitUV, | ||
| gp_XY & | theUV, | ||
| bool & | theIsDeformed | ||
| ) | [private] |
Definition at line 1061 of file SMESH_Pattern.cxx.
References Abs(), intersectIsolines(), MESSAGE, SMESH_Pattern.TPoint.myInitUV, SMESH_Pattern.TPoint.myUV, and SMESH_demo_hexa2_upd.zero.
{
// compute UV by intersection of 2 iso lines
//gp_Lin2d isoLine[2];
gp_XY uv1[2], uv2[2];
double ratio[2];
const double zero = DBL_MIN;
for ( int iIso = 0; iIso < 2; iIso++ )
{
// to build an iso line:
// find 2 pairs of consequent edge-points such that the range of their
// initial parameters encloses the in-face point initial parameter
gp_XY UV[2], initUV[2];
int nbUV = 0, iCoord = iIso + 1;
double initParam = theInitUV.Coord( iCoord );
list< list< TPoint* > >::const_iterator bndIt = theBndPoints.begin();
for ( ; bndIt != theBndPoints.end(); bndIt++ )
{
const list< TPoint* > & bndPoints = * bndIt;
TPoint* prevP = bndPoints.back(); // this is the first point
list< TPoint* >::const_iterator pIt = bndPoints.begin();
bool coincPrev = false;
// loop on the edge-points
for ( ; pIt != bndPoints.end(); pIt++ )
{
double paramDiff = initParam - (*pIt)->myInitUV.Coord( iCoord );
double prevParamDiff = initParam - prevP->myInitUV.Coord( iCoord );
double sumOfDiff = Abs(prevParamDiff) + Abs(paramDiff);
if (!coincPrev && // ignore if initParam coincides with prev point param
sumOfDiff > zero && // ignore if both points coincide with initParam
prevParamDiff * paramDiff <= zero )
{
// find UV in parametric space of theFace
double r = Abs(prevParamDiff) / sumOfDiff;
gp_XY uvInit = (*pIt)->myInitUV * r + prevP->myInitUV * ( 1 - r );
int i = nbUV++;
if ( i >= 2 ) {
// throw away uv most distant from <theInitUV>
gp_XY vec0 = initUV[0] - theInitUV;
gp_XY vec1 = initUV[1] - theInitUV;
gp_XY vec = uvInit - theInitUV;
bool isBetween = ( vec0 * vec1 < 0 ); // is theInitUV between initUV[0] and initUV[1]
double dist0 = vec0.SquareModulus();
double dist1 = vec1.SquareModulus();
double dist = vec .SquareModulus();
if ( !isBetween || dist < dist0 || dist < dist1 ) {
i = ( dist0 < dist1 ? 1 : 0 );
if ( isBetween && vec.Dot( i ? vec1 : vec0 ) < 0 )
i = 3; // theInitUV must remain between
}
}
if ( i < 2 ) {
initUV[ i ] = uvInit;
UV[ i ] = (*pIt)->myUV * r + prevP->myUV * ( 1 - r );
}
coincPrev = ( Abs(paramDiff) <= zero );
}
else
coincPrev = false;
prevP = *pIt;
}
}
if ( nbUV < 2 || (UV[0]-UV[1]).SquareModulus() <= DBL_MIN*DBL_MIN ) {
MESSAGE(" consequent edge-points not found, nb UV found: " << nbUV <<
", for point: " << theInitUV.X() <<" " << theInitUV.Y() );
return setErrorCode( ERR_APPLF_BAD_TOPOLOGY );
}
// an iso line should be normal to UV[0] - UV[1] direction
// and be located at the same relative distance as from initial ends
//gp_Lin2d iso( UV[0], UV[0] - UV[1] );
double r =
(initUV[0]-theInitUV).Modulus() / (initUV[0]-initUV[1]).Modulus();
//gp_Pnt2d isoLoc = UV[0] * ( 1 - r ) + UV[1] * r;
//isoLine[ iIso ] = iso.Normal( isoLoc );
uv1[ iIso ] = UV[0];
uv2[ iIso ] = UV[1];
ratio[ iIso ] = r;
}
if ( !intersectIsolines( uv1[0], uv2[0], ratio[0],
uv1[1], uv2[1], ratio[1], theUV, theIsDeformed )) {
MESSAGE(" Cant intersect isolines for a point "<<theInitUV.X()<<", "<<theInitUV.Y());
return setErrorCode( ERR_APPLF_BAD_TOPOLOGY );
}
return true;
}
| void SMESH_Pattern::createElements | ( | SMESH_Mesh * | theMesh, |
| const std::vector< const SMDS_MeshNode * > & | theNodesVector, | ||
| const std::list< std::list< int > > & | theElemNodeIDs, | ||
| const std::vector< const SMDS_MeshElement * > & | theElements | ||
| ) | [private] |
Definition at line 4016 of file SMESH_Pattern.cxx.
References SMESHDS_Mesh.AddFace(), SMESHDS_Mesh.AddPolygonalFace(), SMESHDS_Mesh.AddPolyhedralVolume(), SMESHDS_Mesh.AddVolume(), SMESH_subMesh.CHECK_COMPUTE_STATE, SMDS_MeshGroup.Contains(), SMESHDS_Mesh.GetGroups(), SMESHDS_SubMesh.GetNodes(), SMDS_MeshElement.getshapeId(), ex21_lamp.group, SMESHDS_Mesh.IndexToShape(), SMESHDS_Mesh.MeshElements(), SMESH_AdvancedEditor.nodes, SMDS_MeshElement.nodesIterator(), SMESHDS_Mesh.SetMeshElementOnShape(), SMESHDS_Mesh.SetNodeInVolume(), SMESHDS_Mesh.SetNodeOnFace(), SMESHDS_Mesh.ShapeToIndex(), SMESHDS_Mesh.ShapeToMesh(), SMDSAbs_Face, SMESHDS_Group.SMDSGroup(), and smdsNode.
{
SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS();
SMESH_MeshEditor editor( theMesh );
bool onMeshElements = !theElements.empty();
// shapes and groups theElements are on
vector< int > shapeIDs;
vector< list< SMESHDS_Group* > > groups;
set< const SMDS_MeshNode* > shellNodes;
if ( onMeshElements )
{
shapeIDs.resize( theElements.size() );
groups.resize( theElements.size() );
const set<SMESHDS_GroupBase*>& allGroups = aMeshDS->GetGroups();
set<SMESHDS_GroupBase*>::const_iterator grIt;
for ( int i = 0; i < theElements.size(); i++ )
{
shapeIDs[ i ] = editor.FindShape( theElements[ i ] );
for ( grIt = allGroups.begin(); grIt != allGroups.end(); grIt++ ) {
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
if ( group && group->SMDSGroup().Contains( theElements[ i ] ))
groups[ i ].push_back( group );
}
}
// get all nodes bound to shells because their SpacePosition is not set
// by SMESHDS_Mesh::SetNodeInVolume()
TopoDS_Shape aMainShape = aMeshDS->ShapeToMesh();
if ( !aMainShape.IsNull() ) {
TopExp_Explorer shellExp( aMainShape, TopAbs_SHELL );
for ( ; shellExp.More(); shellExp.Next() )
{
SMESHDS_SubMesh * sm = aMeshDS->MeshElements( shellExp.Current() );
if ( sm ) {
SMDS_NodeIteratorPtr nIt = sm->GetNodes();
while ( nIt->more() )
shellNodes.insert( nIt->next() );
}
}
}
}
// nb new elements per a refined element
int nbNewElemsPerOld = 1;
if ( onMeshElements )
nbNewElemsPerOld = theElemNodeIDs.size() / theElements.size();
bool is2d = myIs2D;
list< TElemDef >::const_iterator enIt = theElemNodeIDs.begin();
list< vector<int> >::iterator quantity = myPolyhedronQuantities.begin();
for ( int iElem = 0; enIt != theElemNodeIDs.end(); enIt++, iElem++ )
{
const TElemDef & elemNodeInd = *enIt;
// retrieve nodes
vector< const SMDS_MeshNode* > nodes( elemNodeInd.size() );
TElemDef::const_iterator id = elemNodeInd.begin();
int nbNodes;
for ( nbNodes = 0; id != elemNodeInd.end(); id++ ) {
if ( *id < theNodesVector.size() )
nodes[ nbNodes++ ] = theNodesVector[ *id ];
else
nodes[ nbNodes++ ] = myXYZIdToNodeMap[ *id ];
}
// dim of refined elem
int elemIndex = iElem / nbNewElemsPerOld; // refined element index
if ( onMeshElements ) {
is2d = ( theElements[ elemIndex ]->GetType() == SMDSAbs_Face );
}
// add an element
const SMDS_MeshElement* elem = 0;
if ( is2d ) {
switch ( nbNodes ) {
case 3:
elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2] ); break;
case 4:
elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break;
case 6:
if ( !onMeshElements ) {// create a quadratic face
elem = aMeshDS->AddFace (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4], nodes[5] ); break;
} // else do not break but create a polygon
case 8:
if ( !onMeshElements ) {// create a quadratic face
elem = aMeshDS->AddFace (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4], nodes[5], nodes[6], nodes[7] ); break;
} // else do not break but create a polygon
default:
elem = aMeshDS->AddPolygonalFace( nodes );
}
}
else {
switch ( nbNodes ) {
case 4:
elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3] ); break;
case 5:
elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4] ); break;
case 6:
elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4], nodes[5] ); break;
case 8:
elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4], nodes[5], nodes[6], nodes[7] ); break;
default:
elem = aMeshDS->AddPolyhedralVolume( nodes, *quantity++ );
}
}
// set element on a shape
if ( elem && onMeshElements ) // applied to mesh elements
{
int shapeID = shapeIDs[ elemIndex ];
if ( shapeID > 0 ) {
aMeshDS->SetMeshElementOnShape( elem, shapeID );
// set nodes on a shape
TopoDS_Shape S = aMeshDS->IndexToShape( shapeID );
if ( S.ShapeType() == TopAbs_SOLID ) {
TopoDS_Iterator shellIt( S );
if ( shellIt.More() )
shapeID = aMeshDS->ShapeToIndex( shellIt.Value() );
}
SMDS_ElemIteratorPtr noIt = elem->nodesIterator();
while ( noIt->more() ) {
SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>(smdsNode( noIt->next() ));
if (!node->getshapeId() &&
shellNodes.find( node ) == shellNodes.end() ) {
if ( S.ShapeType() == TopAbs_FACE )
aMeshDS->SetNodeOnFace( node, shapeID,
Precision::Infinite(),// <- it's a sign that UV is not set
Precision::Infinite());
else {
aMeshDS->SetNodeInVolume( node, shapeID );
shellNodes.insert( node );
}
}
}
}
// add elem in groups
list< SMESHDS_Group* >::iterator g = groups[ elemIndex ].begin();
for ( ; g != groups[ elemIndex ].end(); ++g )
(*g)->SMDSGroup().Add( elem );
}
if ( elem && !myShape.IsNull() ) // applied to shape
aMeshDS->SetMeshElementOnShape( elem, myShape );
}
// make that SMESH_subMesh::_computeState == COMPUTE_OK
// so that operations with hypotheses will erase the mesh being built
SMESH_subMesh * subMesh;
if ( !myShape.IsNull() ) {
subMesh = theMesh->GetSubMesh( myShape );
if ( subMesh )
subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
}
if ( onMeshElements ) {
list< int > elemIDs;
for ( int i = 0; i < theElements.size(); i++ )
{
subMesh = theMesh->GetSubMeshContaining( shapeIDs[ i ] );
if ( subMesh )
subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
elemIDs.push_back( theElements[ i ]->GetID() );
}
// remove refined elements
editor.Remove( elemIDs, false );
}
}
| void SMESH_Pattern::DumpPoints | ( | ) | const |
Definition at line 4734 of file SMESH_Pattern.cxx.
| bool SMESH_Pattern::findBoundaryPoints | ( | ) | [private] |
Definition at line 4371 of file SMESH_Pattern.cxx.
References SMESH_Block.GetShapeIDByParams(), SMESH_Block.IsVertexID(), MESSAGE, SMESH_Pattern.TPoint.myInitU, SMESH_Pattern.TPoint.myInitUV, and SMESH_Pattern.TPoint.myInitXYZ.
{
if ( myIsBoundaryPointsFound ) return true;
MESSAGE(" findBoundaryPoints() ");
myNbKeyPntInBoundary.clear();
if ( myIs2D )
{
set< TPoint* > pointsInElems;
// Find free links of elements:
// put links of all elements in a set and remove links encountered twice
typedef pair< TPoint*, TPoint*> TLink;
set< TLink > linkSet;
list<TElemDef >::iterator epIt = myElemPointIDs.begin();
for ( ; epIt != myElemPointIDs.end(); epIt++ )
{
TElemDef & elemPoints = *epIt;
TElemDef::iterator pIt = elemPoints.begin();
int prevP = elemPoints.back();
for ( ; pIt != elemPoints.end(); pIt++ ) {
TPoint* p1 = & myPoints[ prevP ];
TPoint* p2 = & myPoints[ *pIt ];
TLink link(( p1 < p2 ? p1 : p2 ), ( p1 < p2 ? p2 : p1 ));
ASSERT( link.first != link.second );
pair<set< TLink >::iterator,bool> itUniq = linkSet.insert( link );
if ( !itUniq.second )
linkSet.erase( itUniq.first );
prevP = *pIt;
pointsInElems.insert( p1 );
}
}
// Now linkSet contains only free links,
// find the points order that they have in boundaries
// 1. make a map of key-points
set< TPoint* > keyPointSet;
list< int >::iterator kpIt = myKeyPointIDs.begin();
for ( ; kpIt != myKeyPointIDs.end(); kpIt++ )
keyPointSet.insert( & myPoints[ *kpIt ]);
// 2. chain up boundary points
list< list< TPoint* > > boundaryList;
boundaryList.push_back( list< TPoint* >() );
list< TPoint* > * boundary = & boundaryList.back();
TPoint *point1, *point2, *keypoint1;
kpIt = myKeyPointIDs.begin();
point1 = keypoint1 = & myPoints[ *kpIt++ ];
// loop on free links: look for the next point
int iKeyPoint = 0;
set< TLink >::iterator lIt = linkSet.begin();
while ( lIt != linkSet.end() )
{
if ( (*lIt).first == point1 )
point2 = (*lIt).second;
else if ( (*lIt).second == point1 )
point2 = (*lIt).first;
else {
lIt++;
continue;
}
linkSet.erase( lIt );
lIt = linkSet.begin();
if ( keyPointSet.find( point2 ) == keyPointSet.end() ) // not a key-point
{
boundary->push_back( point2 );
}
else // a key-point found
{
keyPointSet.erase( point2 ); // keyPointSet contains not found key-points only
iKeyPoint++;
if ( point2 != keypoint1 ) // its not the boundary end
{
boundary->push_back( point2 );
}
else // the boundary end reached
{
boundary->push_front( keypoint1 );
boundary->push_back( keypoint1 );
myNbKeyPntInBoundary.push_back( iKeyPoint );
if ( keyPointSet.empty() )
break; // all boundaries containing key-points are found
// prepare to search for the next boundary
boundaryList.push_back( list< TPoint* >() );
boundary = & boundaryList.back();
point2 = keypoint1 = (*keyPointSet.begin());
}
}
point1 = point2;
} // loop on the free links set
if ( boundary->empty() ) {
MESSAGE(" a separate key-point");
return setErrorCode( ERR_READ_BAD_KEY_POINT );
}
// if there are several wires, arrange boundaryPoints so that
// the outer wire goes first and fix inner wires orientation;
// sort myKeyPointIDs to correspond to the order of key-points
// in boundaries
arrangeBoundaries( boundaryList );
// Find correspondence shape ID - points,
// compute points parameter on edge
keyPointSet.clear();
for ( kpIt = myKeyPointIDs.begin(); kpIt != myKeyPointIDs.end(); kpIt++ )
keyPointSet.insert( & myPoints[ *kpIt ]);
set< TPoint* > edgePointSet; // to find in-face points
int vertexID = 1; // the first index in TopTools_IndexedMapOfShape
int edgeID = myKeyPointIDs.size() + 1;
list< list< TPoint* > >::iterator bndIt = boundaryList.begin();
for ( ; bndIt != boundaryList.end(); bndIt++ )
{
boundary = & (*bndIt);
double edgeLength = 0;
list< TPoint* >::iterator pIt = boundary->begin();
getShapePoints( edgeID ).push_back( *pIt );
getShapePoints( vertexID++ ).push_back( *pIt );
for ( pIt++; pIt != boundary->end(); pIt++)
{
list< TPoint* > & edgePoints = getShapePoints( edgeID );
TPoint* prevP = edgePoints.empty() ? 0 : edgePoints.back();
TPoint* point = *pIt;
edgePointSet.insert( point );
if ( keyPointSet.find( point ) == keyPointSet.end() ) // inside-edge point
{
edgePoints.push_back( point );
edgeLength += ( point->myInitUV - prevP->myInitUV ).Modulus();
point->myInitU = edgeLength;
}
else // a key-point
{
// treat points on the edge which ends up: compute U [0,1]
edgePoints.push_back( point );
if ( edgePoints.size() > 2 ) {
edgeLength += ( point->myInitUV - prevP->myInitUV ).Modulus();
list< TPoint* >::iterator epIt = edgePoints.begin();
for ( ; epIt != edgePoints.end(); epIt++ )
(*epIt)->myInitU /= edgeLength;
}
// begin the next edge treatment
edgeLength = 0;
edgeID++;
if ( point != boundary->front() ) { // not the first key-point again
getShapePoints( edgeID ).push_back( point );
getShapePoints( vertexID++ ).push_back( point );
}
}
}
}
// find in-face points
list< TPoint* > & facePoints = getShapePoints( edgeID );
vector< TPoint >::iterator pVecIt = myPoints.begin();
for ( ; pVecIt != myPoints.end(); pVecIt++ ) {
TPoint* point = &(*pVecIt);
if ( edgePointSet.find( point ) == edgePointSet.end() &&
pointsInElems.find( point ) != pointsInElems.end())
facePoints.push_back( point );
}
} // 2D case
else // 3D case
{
// bind points to shapes according to point parameters
vector< TPoint >::iterator pVecIt = myPoints.begin();
for ( int i = 0; pVecIt != myPoints.end(); pVecIt++, i++ ) {
TPoint* point = &(*pVecIt);
int shapeID = SMESH_Block::GetShapeIDByParams( point->myInitXYZ );
getShapePoints( shapeID ).push_back( point );
// detect key-points
if ( SMESH_Block::IsVertexID( shapeID ))
myKeyPointIDs.push_back( i );
}
}
myIsBoundaryPointsFound = true;
return myIsBoundaryPointsFound;
}
Definition at line 215 of file SMESH_Pattern.hxx.
Referenced by SMESH_Pattern_i.GetElementPoints().
{ return myElemXYZIDs.empty() || !applied ? myElemPointIDs : myElemXYZIDs; }
| ErrorCode SMESH_Pattern.GetErrorCode | ( | ) | const |
Definition at line 199 of file SMESH_Pattern.hxx.
Referenced by SMESH_Pattern_i.GetErrorCode().
{ return myErrorCode; }
| bool SMESH_Pattern::getFacesDefinition | ( | const SMDS_MeshNode ** | theBndNodes, |
| const int | theNbBndNodes, | ||
| const std::vector< const SMDS_MeshNode * > & | theNodes, | ||
| std::list< int > & | theFaceDefs, | ||
| std::vector< int > & | theQuantity | ||
| ) | [private] |
Definition at line 3713 of file SMESH_Pattern.cxx.
References SMDS_VolumeTool.GetFaceNodesIndices(), SMDS_VolumeTool.GetType(), SMESH_test.ids, Max(), SMDS_VolumeTool.NbFaceNodes(), SMDS_VolumeTool.NbFaces(), SMDS_VolumeTool.UNKNOWN, and SMESH_demo_hexa2_upd.vol.
{
bool makePoly = false;
set< const SMDS_MeshNode* > bndNodeSet( theBndNodes, theBndNodes + theNbBndNodes);
map< TNodeSet, list< list< int > > >::iterator nn_IdList;
// make a set of all nodes on a face
set< int > ids;
if ( !myIs2D ) { // for 2D, merge only edges
nn_IdList = myIdsOnBoundary.find( bndNodeSet );
if ( nn_IdList != myIdsOnBoundary.end() ) {
list< int > & faceIds = nn_IdList->second.front();
if ( !faceIds.empty() ) {
makePoly = true;
ids.insert( faceIds.begin(), faceIds.end() );
}
}
}
// add ids on links and bnd nodes
int lastFreeId = Max( myXYZIdToNodeMap.rbegin()->first, theNodes.size() );
TElemDef faceDef; // definition for the case if there is no new adjacent volumes
for ( int iN = 0; iN < theNbBndNodes; ++iN )
{
// add id of iN-th bnd node
TNodeSet nSet;
nSet.insert( theBndNodes[ iN ] );
nn_IdList = myIdsOnBoundary.find( nSet );
int bndId = ++lastFreeId;
if ( nn_IdList != myIdsOnBoundary.end() ) {
bndId = nn_IdList->second.front().front();
ids.insert( bndId );
}
else {
myXYZIdToNodeMap.insert( make_pair( bndId, theBndNodes[ iN ] ));
}
faceDef.push_back( bndId );
// add ids on a link
TNodeSet linkNodes;
linkNodes.insert( theBndNodes[ iN ]);
linkNodes.insert( theBndNodes[ (iN + 1) % theNbBndNodes] );
nn_IdList = myIdsOnBoundary.find( linkNodes );
if ( nn_IdList != myIdsOnBoundary.end() ) {
list< int > & linkIds = nn_IdList->second.front();
if ( !linkIds.empty() )
{
makePoly = true;
ids.insert( linkIds.begin(), linkIds.end() );
if ( isReversed( theBndNodes[ iN ], linkIds ))
faceDef.insert( faceDef.end(), linkIds.begin(), linkIds.end() );
else
faceDef.insert( faceDef.end(), linkIds.rbegin(), linkIds.rend() );
}
}
}
// find faces definition of new volumes
bool defsAdded = false;
if ( !myIs2D ) { // for 2D, merge only edges
SMDS_VolumeTool vol;
set< TElemDef* > checkedVolDefs;
set< int >::iterator id = ids.begin();
for ( ; id != ids.end(); ++id )
{
// definitions of volumes sharing id
list< TElemDef* >& defList = myReverseConnectivity[ *id ];
ASSERT( !defList.empty() );
// loop on volume definitions
list< TElemDef* >::iterator pIdList = defList.begin();
for ( ; pIdList != defList.end(); ++pIdList)
{
if ( !checkedVolDefs.insert( *pIdList ).second )
continue; // skip already checked volume definition
vector< int > idVec( (*pIdList)->begin(), (*pIdList)->end() );
// loop on face defs of a volume
SMDS_VolumeTool::VolumeType volType = vol.GetType( idVec.size() );
if ( volType == SMDS_VolumeTool::UNKNOWN )
continue;
int nbFaces = vol.NbFaces( volType );
for ( int iF = 0; iF < nbFaces; ++iF )
{
const int* nodeInds = vol.GetFaceNodesIndices( volType, iF, true );
int iN, nbN = vol.NbFaceNodes( volType, iF );
// check if all nodes of a faces are in <ids>
bool all = true;
for ( iN = 0; iN < nbN && all; ++iN ) {
int nodeId = idVec[ nodeInds[ iN ]];
all = ( ids.find( nodeId ) != ids.end() );
}
if ( all ) {
// store a face definition
for ( iN = 0; iN < nbN; ++iN ) {
theFaceDefs.push_back( idVec[ nodeInds[ iN ]]);
}
theQuantity.push_back( nbN );
defsAdded = true;
}
}
}
}
}
if ( !defsAdded ) {
theQuantity.push_back( faceDef.size() );
theFaceDefs.splice( theFaceDefs.end(), faceDef );
}
return makePoly;
}
| const std::list< int >& SMESH_Pattern.GetKeyPointIDs | ( | ) | const |
Definition at line 211 of file SMESH_Pattern.hxx.
Referenced by SMESH_Pattern_i.GetKeyPoints().
{ return myKeyPointIDs; }
| bool SMESH_Pattern::GetMappedPoints | ( | std::list< const gp_XYZ * > & | thePoints | ) | const |
Definition at line 4659 of file SMESH_Pattern.cxx.
References isDefined(), and SMESH_AdvancedEditor.xyz.
Referenced by SMESH_Pattern_i.ApplyTo3DBlock(), SMESH_Pattern_i.ApplyToFace(), SMESH_Pattern_i.ApplyToHexahedrons(), and SMESH_Pattern_i.ApplyToMeshFaces().
{
thePoints.clear();
if ( !myIsComputed )
return false;
if ( myElements.empty() ) { // applied to shape
vector< TPoint >::const_iterator pVecIt = myPoints.begin();
for ( ; pVecIt != myPoints.end(); pVecIt++ )
thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
}
else { // applied to mesh elements
const gp_XYZ * definedXYZ = & myPoints[ myKeyPointIDs.front() ].myXYZ.XYZ();
vector<gp_XYZ>::const_iterator xyz = myXYZ.begin();
for ( ; xyz != myXYZ.end(); ++xyz )
if ( !isDefined( *xyz ))
thePoints.push_back( definedXYZ );
else
thePoints.push_back( & (*xyz) );
}
return !thePoints.empty();
}
| bool SMESH_Pattern.GetPoints | ( | std::list< const gp_XYZ * > & | thePoints | ) | const |
Referenced by SMESH_Pattern_i.GetPoints().
| list< SMESH_Pattern::TPoint * > & SMESH_Pattern::getShapePoints | ( | const TopoDS_Shape & | theShape | ) | [private] |
Definition at line 4708 of file SMESH_Pattern.cxx.
{
int aShapeID;
if ( !myShapeIDMap.Contains( theShape ))
aShapeID = myShapeIDMap.Add( theShape );
else
aShapeID = myShapeIDMap.FindIndex( theShape );
return myShapeIDToPointsMap[ aShapeID ];
}
| list< SMESH_Pattern::TPoint * > & SMESH_Pattern::getShapePoints | ( | const int | theShapeID | ) | [private] |
Definition at line 4724 of file SMESH_Pattern.cxx.
{
return myShapeIDToPointsMap[ theShapeID ];
}
| SMESHDS_SubMesh * SMESH_Pattern::getSubmeshWithElements | ( | SMESH_Mesh * | theMesh, |
| const TopoDS_Shape & | theShape | ||
| ) | [static, private] |
Definition at line 3286 of file SMESH_Pattern.cxx.
References SMESHDS_SubMesh.GetElements(), and SMESHDS_SubMesh.GetNodes().
{
SMESHDS_SubMesh * aSubMesh = theMesh->GetMeshDS()->MeshElements( theShape );
if ( aSubMesh && ( aSubMesh->GetElements()->more() || aSubMesh->GetNodes()->more() ))
return aSubMesh;
if ( theShape.ShapeType() == TopAbs_SHELL )
{
// look for submesh of VOLUME
TopTools_ListIteratorOfListOfShape it( theMesh->GetAncestors( theShape ));
for (; it.More(); it.Next()) {
aSubMesh = theMesh->GetMeshDS()->MeshElements( it.Value() );
if ( aSubMesh && ( aSubMesh->GetElements()->more() || aSubMesh->GetNodes()->more() ))
return aSubMesh;
}
}
return 0;
}
| TopoDS_Shape SMESH_Pattern.GetSubShape | ( | const int | i | ) | const |
Definition at line 226 of file SMESH_Pattern.hxx.
{
if ( i < 1 || i > myShapeIDMap.Extent() ) return TopoDS_Shape();
return myShapeIDMap( i );
}
| bool SMESH_Pattern.Is2D | ( | ) | const |
Definition at line 205 of file SMESH_Pattern.hxx.
Referenced by SMESH_Pattern_i.Is2D().
{ return myIs2D; }
| bool SMESH_Pattern.IsLoaded | ( | ) | const |
Definition at line 202 of file SMESH_Pattern.hxx.
Referenced by SMESH_Pattern_i.GetKeyPoints().
{ return !myPoints.empty() && !myElemPointIDs.empty(); }
| bool SMESH_Pattern::isReversed | ( | const SMDS_MeshNode * | theFirstNode, |
| const std::list< int > & | theIdsList | ||
| ) | const [private] |
Definition at line 4195 of file SMESH_Pattern.cxx.
References SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().
{
if ( theIdsList.size() < 2 )
return false;
gp_Pnt Pf ( theFirstNode->X(), theFirstNode->Y(), theFirstNode->Z() );
gp_Pnt P[2];
list<int>::const_iterator id = theIdsList.begin();
for ( int i = 0; i < 2; ++i, ++id ) {
if ( *id < myXYZ.size() )
P[ i ] = myXYZ[ *id ];
else {
map< int, const SMDS_MeshNode*>::const_iterator i_n;
i_n = myXYZIdToNodeMap.find( *id );
ASSERT( i_n != myXYZIdToNodeMap.end() );
const SMDS_MeshNode* n = i_n->second;
P[ i ].SetCoord( n->X(), n->Y(), n->Z() );
}
}
return Pf.SquareDistance( P[ 1 ] ) < Pf.SquareDistance( P[ 0 ] );
}
| bool SMESH_Pattern::Load | ( | SMESH_Mesh * | theMesh, |
| const TopoDS_Shell & | theBlock | ||
| ) |
Definition at line 3161 of file SMESH_Pattern.cxx.
References SMESH_Block.ComputeParameters(), SMESH_Block.GetCoordIndOnEdge(), SMESHDS_SubMesh.GetElements(), SMDS_MeshElement.GetNode(), SMESHDS_SubMesh.GetNodes(), SMDS_MeshNode.GetPosition(), SMESH_Block.GetShapeCoef(), SMDS_EdgePosition.GetUParameter(), SMESH_Block.IsForwardEdge(), SMESH_MeshEditor.IsMedium(), SMESH_Block.IsVertexID(), SMESH_Block.LoadBlockShapes(), MESSAGE, SMESH_Pattern.TPoint.myInitXYZ, SMESH_Pattern.TPoint.myXYZ, SMDS_MeshElement.NbCornerNodes(), SMESHDS_SubMesh.NbNodes(), ORDER_QUADRATIC, SMDSAbs_Edge, SMDSAbs_Volume, smdsNode, SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().
{
MESSAGE(" ::Load(volume) " );
Clear();
myIs2D = false;
SMESHDS_SubMesh * aSubMesh;
const bool isQuadMesh = theMesh->NbVolumes( ORDER_QUADRATIC );
// load shapes in myShapeIDMap
SMESH_Block block;
TopoDS_Vertex v1, v2;
if ( !block.LoadBlockShapes( theBlock, v1, v2, myShapeIDMap ))
return setErrorCode( ERR_LOADV_BAD_SHAPE );
// count nodes
int nbNodes = 0, shapeID;
for ( shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ )
{
const TopoDS_Shape& S = myShapeIDMap( shapeID );
aSubMesh = getSubmeshWithElements( theMesh, S );
if ( aSubMesh )
nbNodes += aSubMesh->NbNodes();
}
myPoints.resize( nbNodes );
// load U of points on edges
TNodePointIDMap nodePointIDMap;
int iPoint = 0;
for ( shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ )
{
const TopoDS_Shape& S = myShapeIDMap( shapeID );
list< TPoint* > & shapePoints = getShapePoints( shapeID );
aSubMesh = getSubmeshWithElements( theMesh, S );
if ( ! aSubMesh ) continue;
SMDS_NodeIteratorPtr nIt = aSubMesh->GetNodes();
if ( !nIt->more() ) continue;
// store a node and a point
while ( nIt->more() ) {
const SMDS_MeshNode* node = smdsNode( nIt->next() );
if ( isQuadMesh && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Volume ))
continue;
nodePointIDMap.insert( make_pair( node, iPoint ));
if ( block.IsVertexID( shapeID ))
myKeyPointIDs.push_back( iPoint );
TPoint* p = & myPoints[ iPoint++ ];
shapePoints.push_back( p );
p->myXYZ.SetCoord( node->X(), node->Y(), node->Z() );
p->myInitXYZ.SetCoord( 0,0,0 );
}
list< TPoint* >::iterator pIt = shapePoints.begin();
// compute init XYZ
switch ( S.ShapeType() )
{
case TopAbs_VERTEX:
case TopAbs_EDGE: {
for ( ; pIt != shapePoints.end(); pIt++ ) {
double * coef = block.GetShapeCoef( shapeID );
for ( int iCoord = 1; iCoord <= 3; iCoord++ )
if ( coef[ iCoord - 1] > 0 )
(*pIt)->myInitXYZ.SetCoord( iCoord, 1. );
}
if ( S.ShapeType() == TopAbs_VERTEX )
break;
const TopoDS_Edge& edge = TopoDS::Edge( S );
double f,l;
BRep_Tool::Range( edge, f, l );
int iCoord = SMESH_Block::GetCoordIndOnEdge( shapeID );
bool isForward = SMESH_Block::IsForwardEdge( edge, myShapeIDMap );
pIt = shapePoints.begin();
nIt = aSubMesh->GetNodes();
for ( ; nIt->more(); pIt++ )
{
const SMDS_MeshNode* node = nIt->next();
if ( isQuadMesh && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = ( epos->GetUParameter() - f ) / ( l - f );
(*pIt)->myInitXYZ.SetCoord( iCoord, isForward ? u : 1 - u );
}
break;
}
default:
for ( ; pIt != shapePoints.end(); pIt++ )
{
if ( !block.ComputeParameters( (*pIt)->myXYZ, (*pIt)->myInitXYZ, shapeID )) {
MESSAGE( "!block.ComputeParameters()" );
return setErrorCode( ERR_LOADV_COMPUTE_PARAMS );
}
}
}
} // loop on block sub-shapes
// load elements
aSubMesh = getSubmeshWithElements( theMesh, theBlock );
if ( aSubMesh )
{
SMDS_ElemIteratorPtr elemIt = aSubMesh->GetElements();
while ( elemIt->more() ) {
const SMDS_MeshElement* elem = elemIt->next();
myElemPointIDs.push_back( TElemDef() );
TElemDef& elemPoints = myElemPointIDs.back();
int nbNodes = elem->NbCornerNodes();
for ( int i = 0;i < nbNodes; ++i )
elemPoints.push_back( nodePointIDMap[ elem->GetNode( i )]);
}
}
myIsBoundaryPointsFound = true;
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern.Load | ( | SMESH_Mesh * | theMesh, |
| const TopoDS_Face & | theFace, | ||
| bool | theProject = false |
||
| ) |
| bool SMESH_Pattern::Load | ( | const char * | theFileContents | ) |
Definition at line 211 of file SMESH_Pattern.cxx.
References getDouble(), getInt(), MESSAGE, SMESH_Pattern.TPoint.myInitUV, SMESH_Pattern.TPoint.myInitXYZ, and readLine().
Referenced by SMESH_Pattern_i.LoadFrom3DBlock(), SMESH_Pattern_i.LoadFromFace(), and SMESH_Pattern_i.LoadFromFile().
{
MESSAGE("Load( file ) ");
Kernel_Utils::Localizer loc;
// file structure:
// ! This is a comment
// NB_POINTS ! 1 integer - the number of points in the pattern.
// X1 Y1 [Z1] ! 2 or 3 reals - nodes coordinates within 2D or 3D domain:
// X2 Y2 [Z2] ! the pattern dimention is defined by the number of coordinates
// ...
// [ ID1 ID2 ... IDn ] ! Indices of key-points for a 2D pattern (only).
// ! elements description goes after all
// ID1 ID2 ... IDn ! 2-4 or 4-8 integers - nodal connectivity of a 2D or 3D element.
// ...
Clear();
const char* lineBeg = theFileContents;
list <const char*> fields;
const bool clearFields = true;
// NB_POINTS ! 1 integer - the number of points in the pattern.
if ( readLine( fields, lineBeg, clearFields ) != 1 ) {
MESSAGE("Error reading NB_POINTS");
return setErrorCode( ERR_READ_NB_POINTS );
}
int nbPoints = getInt( fields.front() );
// X1 Y1 [Z1] ! 2 or 3 reals - nodes coordinates within 2D or 3D domain:
// read the first point coordinates to define pattern dimention
int dim = readLine( fields, lineBeg, clearFields );
if ( dim == 2 )
myIs2D = true;
else if ( dim == 3 )
myIs2D = false;
else {
MESSAGE("Error reading points: wrong nb of coordinates");
return setErrorCode( ERR_READ_POINT_COORDS );
}
if ( nbPoints <= dim ) {
MESSAGE(" Too few points ");
return setErrorCode( ERR_READ_TOO_FEW_POINTS );
}
// read the rest points
int iPoint;
for ( iPoint = 1; iPoint < nbPoints; iPoint++ )
if ( readLine( fields, lineBeg, !clearFields ) != dim ) {
MESSAGE("Error reading points : wrong nb of coordinates ");
return setErrorCode( ERR_READ_POINT_COORDS );
}
// store point coordinates
myPoints.resize( nbPoints );
list <const char*>::iterator fIt = fields.begin();
for ( iPoint = 0; iPoint < nbPoints; iPoint++ )
{
TPoint & p = myPoints[ iPoint ];
for ( int iCoord = 1; iCoord <= dim; iCoord++, fIt++ )
{
double coord = getDouble( *fIt );
if ( !myIs2D && ( coord < 0.0 || coord > 1.0 )) {
MESSAGE("Error reading 3D points, value should be in [0,1]: " << coord);
Clear();
return setErrorCode( ERR_READ_3D_COORD );
}
p.myInitXYZ.SetCoord( iCoord, coord );
if ( myIs2D )
p.myInitUV.SetCoord( iCoord, coord );
}
}
// [ ID1 ID2 ... IDn ] ! Indices of key-points for a 2D pattern (only).
if ( myIs2D )
{
if ( readLine( fields, lineBeg, clearFields ) == 0 ) {
MESSAGE("Error: missing key-points");
Clear();
return setErrorCode( ERR_READ_NO_KEYPOINT );
}
set<int> idSet;
for ( fIt = fields.begin(); fIt != fields.end(); fIt++ )
{
int pointIndex = getInt( *fIt );
if ( pointIndex >= nbPoints || pointIndex < 0 ) {
MESSAGE("Error: invalid point index " << pointIndex );
Clear();
return setErrorCode( ERR_READ_BAD_INDEX );
}
if ( idSet.insert( pointIndex ).second ) // unique?
myKeyPointIDs.push_back( pointIndex );
}
}
// ID1 ID2 ... IDn ! 2-4 or 4-8 integers - nodal connectivity of a 2D or 3D element.
while ( readLine( fields, lineBeg, clearFields ))
{
myElemPointIDs.push_back( TElemDef() );
TElemDef& elemPoints = myElemPointIDs.back();
for ( fIt = fields.begin(); fIt != fields.end(); fIt++ )
{
int pointIndex = getInt( *fIt );
if ( pointIndex >= nbPoints || pointIndex < 0 ) {
MESSAGE("Error: invalid point index " << pointIndex );
Clear();
return setErrorCode( ERR_READ_BAD_INDEX );
}
elemPoints.push_back( pointIndex );
}
// check the nb of nodes in element
bool Ok = true;
switch ( elemPoints.size() ) {
case 3: if ( !myIs2D ) Ok = false; break;
case 4: break;
case 5:
case 6:
case 8: if ( myIs2D ) Ok = false; break;
default: Ok = false;
}
if ( !Ok ) {
MESSAGE("Error: wrong nb of nodes in element " << elemPoints.size() );
Clear();
return setErrorCode( ERR_READ_ELEM_POINTS );
}
}
if ( myElemPointIDs.empty() ) {
MESSAGE("Error: no elements");
Clear();
return setErrorCode( ERR_READ_NO_ELEMS );
}
findBoundaryPoints(); // sort key-points
return setErrorCode( ERR_OK );
}
| bool SMESH_Pattern.MakeMesh | ( | SMESH_Mesh * | theMesh, |
| const bool | toCreatePolygons = false, |
||
| const bool | toCreatePolyedrs = false |
||
| ) |
Referenced by SMESH_Pattern_i.MakeMesh().
| void SMESH_Pattern::makePolyElements | ( | const std::vector< const SMDS_MeshNode * > & | theNodes, |
| const bool | toCreatePolygons, | ||
| const bool | toCreatePolyedrs | ||
| ) | [private] |
Definition at line 3513 of file SMESH_Pattern.cxx.
References SMESH_MeshEditor.FindFaceInSet(), SMDS_VolumeTool.GetFaceNodes(), SMDS_MeshNode.GetInverseElementIterator(), SMESH_AdvancedEditor.n1, SMESH_AdvancedEditor.n2, SMDS_VolumeTool.NbFaceNodes(), SMDS_VolumeTool.NbFaces(), SMDS_MeshElement.NbNodes(), SMESH_AdvancedEditor.nodes, SMDS_MeshElement.nodesIterator(), SMDS_VolumeTool.Set(), and smdsNode.
{
myPolyElemXYZIDs.clear();
myPolyElems.clear();
myPolyElems.reserve( myIdsOnBoundary.size() );
// make a set of refined elements
TIDSortedElemSet avoidSet, elemSet;
std::vector<const SMDS_MeshElement*>::iterator itv = myElements.begin();
for(; itv!=myElements.end(); itv++) {
const SMDS_MeshElement* el = (*itv);
avoidSet.insert( el );
}
//avoidSet.insert( myElements.begin(), myElements.end() );
map< TNodeSet, list< list< int > > >::iterator indListIt, nn_IdList;
if ( toCreatePolygons )
{
int lastFreeId = myXYZ.size();
// loop on links of refined elements
indListIt = myIdsOnBoundary.begin();
for ( ; indListIt != myIdsOnBoundary.end(); indListIt++ )
{
const TNodeSet & linkNodes = indListIt->first;
if ( linkNodes.size() != 2 )
continue; // skip face
const SMDS_MeshNode* n1 = * linkNodes.begin();
const SMDS_MeshNode* n2 = * linkNodes.rbegin();
list<list< int > >& idGroups = indListIt->second; // ids of nodes to build
if ( idGroups.empty() || idGroups.front().empty() )
continue;
// find not refined face having n1-n2 link
while (true)
{
const SMDS_MeshElement* face =
SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet );
if ( face )
{
avoidSet.insert ( face );
myPolyElems.push_back( face );
// some links of <face> are split;
// make list of xyz for <face>
myPolyElemXYZIDs.push_back(TElemDef());
TElemDef & faceNodeIds = myPolyElemXYZIDs.back();
// loop on links of a <face>
SMDS_ElemIteratorPtr nIt = face->nodesIterator();
int i = 0, nbNodes = face->NbNodes();
vector<const SMDS_MeshNode*> nodes( nbNodes + 1 );
while ( nIt->more() )
nodes[ i++ ] = smdsNode( nIt->next() );
nodes[ i ] = nodes[ 0 ];
for ( i = 0; i < nbNodes; ++i )
{
// look for point mapped on a link
TNodeSet faceLinkNodes;
faceLinkNodes.insert( nodes[ i ] );
faceLinkNodes.insert( nodes[ i + 1 ] );
if ( faceLinkNodes == linkNodes )
nn_IdList = indListIt;
else
nn_IdList = myIdsOnBoundary.find( faceLinkNodes );
// add face point ids
faceNodeIds.push_back( ++lastFreeId );
myXYZIdToNodeMap.insert( make_pair( lastFreeId, nodes[ i ]));
if ( nn_IdList != myIdsOnBoundary.end() )
{
// there are points mapped on a link
list< int >& mappedIds = nn_IdList->second.front();
if ( isReversed( nodes[ i ], mappedIds ))
faceNodeIds.insert (faceNodeIds.end(),mappedIds.rbegin(), mappedIds.rend() );
else
faceNodeIds.insert (faceNodeIds.end(),mappedIds.begin(), mappedIds.end() );
}
} // loop on links of a <face>
} // if ( face )
else
break;
} // while (true)
if ( myIs2D && idGroups.size() > 1 ) {
// sew new elements on 2 refined elements sharing n1-n2 link
list< int >& idsOnLink = idGroups.front();
// temporarily add ids of link nodes to idsOnLink
bool rev = isReversed( n1, idsOnLink );
for ( int i = 0; i < 2; ++i )
{
TNodeSet nodeSet;
nodeSet.insert( i ? n2 : n1 );
ASSERT( myIdsOnBoundary.find( nodeSet ) != myIdsOnBoundary.end() );
list<list< int > >& groups = myIdsOnBoundary[ nodeSet ];
int nodeId = groups.front().front();
bool append = i;
if ( rev ) append = !append;
if ( append )
idsOnLink.push_back( nodeId );
else
idsOnLink.push_front( nodeId );
}
list< int >::iterator id = idsOnLink.begin();
for ( ; id != idsOnLink.end(); ++id ) // loop on XYZ ids on a link
{
list< TElemDef* >& elemDefs = myReverseConnectivity[ *id ]; // elems sharing id
list< TElemDef* >::iterator pElemDef = elemDefs.begin();
for ( ; pElemDef != elemDefs.end(); pElemDef++ ) // loop on elements sharing id
{
TElemDef* pIdList = *pElemDef; // ptr on list of ids making element up
// look for <id> in element definition
TElemDef::iterator idDef = find( pIdList->begin(), pIdList->end(), *id );
ASSERT ( idDef != pIdList->end() );
// look for 2 neighbour ids of <id> in element definition
for ( int prev = 0; prev < 2; ++prev ) {
TElemDef::iterator idDef2 = idDef;
if ( prev )
idDef2 = ( idDef2 == pIdList->begin() ) ? --pIdList->end() : --idDef2;
else
idDef2 = ( ++idDef2 == pIdList->end() ) ? pIdList->begin() : idDef2;
// look for idDef2 on a link starting from id
list< int >::iterator id2 = find( id, idsOnLink.end(), *idDef2 );
if ( id2 != idsOnLink.end() && id != --id2 ) { // found not next to id
// insert ids located on link between <id> and <id2>
// into the element definition between idDef and idDef2
if ( prev )
for ( ; id2 != id; --id2 )
pIdList->insert( idDef, *id2 );
else {
list< int >::iterator id1 = id;
for ( ++id1, ++id2; id1 != id2; ++id1 )
pIdList->insert( idDef2, *id1 );
}
}
}
}
}
// remove ids of link nodes
idsOnLink.pop_front();
idsOnLink.pop_back();
}
} // loop on myIdsOnBoundary
} // if ( toCreatePolygons )
if ( toCreatePolyedrs )
{
// check volumes adjacent to the refined elements
SMDS_VolumeTool volTool;
vector<const SMDS_MeshElement*>::iterator refinedElem = myElements.begin();
for ( ; refinedElem != myElements.end(); ++refinedElem )
{
// loop on nodes of refinedElem
SMDS_ElemIteratorPtr nIt = (*refinedElem)->nodesIterator();
while ( nIt->more() ) {
const SMDS_MeshNode* node = smdsNode( nIt->next() );
// loop on inverse elements of node
SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator();
while ( eIt->more() )
{
const SMDS_MeshElement* elem = eIt->next();
if ( !volTool.Set( elem ) || !avoidSet.insert( elem ).second )
continue; // skip faces or refined elements
// add polyhedron definition
myPolyhedronQuantities.push_back(vector<int> ());
myPolyElemXYZIDs.push_back(TElemDef());
vector<int>& quantity = myPolyhedronQuantities.back();
TElemDef & elemDef = myPolyElemXYZIDs.back();
// get definitions of new elements on volume faces
bool makePoly = false;
for ( int iF = 0; iF < volTool.NbFaces(); ++iF )
{
if ( getFacesDefinition(volTool.GetFaceNodes( iF ),
volTool.NbFaceNodes( iF ),
theNodes, elemDef, quantity))
makePoly = true;
}
if ( makePoly )
myPolyElems.push_back( elem );
else {
myPolyhedronQuantities.pop_back();
myPolyElemXYZIDs.pop_back();
}
}
}
}
}
}
| void SMESH_Pattern::mergePoints | ( | const bool | uniteGroups | ) | [private] |
Definition at line 3422 of file SMESH_Pattern.cxx.
References ex13_hole1partial.box, isDefined(), SMESH_AdvancedEditor.nodes, undefinedXYZ(), SMDS_MeshNode.X(), ex13_hole1partial.x, SMDS_MeshNode.Y(), ex13_hole1partial.y, and SMDS_MeshNode.Z().
{
map< TNodeSet, list< list< int > > >::iterator idListIt = myIdsOnBoundary.begin();
for ( ; idListIt != myIdsOnBoundary.end(); idListIt++ )
{
list<list< int > >& groups = idListIt->second;
if ( groups.size() < 2 )
continue;
// find tolerance
const TNodeSet& nodes = idListIt->first;
double tol2 = 1.e-10;
if ( nodes.size() > 1 ) {
Bnd_Box box;
TNodeSet::const_iterator n = nodes.begin();
for ( ; n != nodes.end(); ++n )
box.Add( gp_Pnt( (*n)->X(), (*n)->Y(), (*n)->Z() ));
double x, y, z, X, Y, Z;
box.Get( x, y, z, X, Y, Z );
gp_Pnt p( x, y, z ), P( X, Y, Z );
tol2 = 1.e-4 * p.SquareDistance( P );
}
// to unite groups on link
bool unite = ( uniteGroups && nodes.size() == 2 );
map< double, int > distIndMap;
const SMDS_MeshNode* node = *nodes.begin();
gp_Pnt P( node->X(), node->Y(), node->Z() );
// compare points, replace indices
list< int >::iterator ind1, ind2;
list< list< int > >::iterator grpIt1, grpIt2;
for ( grpIt1 = groups.begin(); grpIt1 != groups.end(); grpIt1++ )
{
list< int >& indices1 = *grpIt1;
grpIt2 = grpIt1;
for ( grpIt2++; grpIt2 != groups.end(); grpIt2++ )
{
list< int >& indices2 = *grpIt2;
for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ )
{
gp_XYZ& p1 = myXYZ[ *ind1 ];
ind2 = indices2.begin();
while ( ind2 != indices2.end() )
{
gp_XYZ& p2 = myXYZ[ *ind2 ];
//MESSAGE("COMP: " << *ind1 << " " << *ind2 << " X: " << p2.X() << " tol2: " << tol2);
if ( ( p1 - p2 ).SquareModulus() <= tol2 )
{
ASSERT( myReverseConnectivity.find( *ind2 ) != myReverseConnectivity.end() );
list< TElemDef* > & elemXYZIDsList = myReverseConnectivity[ *ind2 ];
list< TElemDef* >::iterator elemXYZIDs = elemXYZIDsList.begin();
for ( ; elemXYZIDs != elemXYZIDsList.end(); elemXYZIDs++ )
{
//MESSAGE( " Replace " << *ind2 << " with " << *ind1 );
myXYZ[ *ind2 ] = undefinedXYZ();
replace( (*elemXYZIDs)->begin(), (*elemXYZIDs)->end(), *ind2, *ind1 );
}
ind2 = indices2.erase( ind2 );
}
else
ind2++;
}
}
}
if ( unite ) { // sort indices using distIndMap
for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ )
{
ASSERT( isDefined( myXYZ[ *ind1 ] ));
double dist = P.SquareDistance( myXYZ[ *ind1 ]);
distIndMap.insert( make_pair( dist, *ind1 ));
}
}
}
if ( unite ) { // put all sorted indices into the first group
list< int >& g = groups.front();
g.clear();
map< double, int >::iterator dist_ind = distIndMap.begin();
for ( ; dist_ind != distIndMap.end(); dist_ind++ )
g.push_back( dist_ind->second );
}
} // loop on myIdsOnBoundary
}
| bool SMESH_Pattern.Save | ( | std::ostream & | theFile | ) |
Referenced by SMESH_Pattern_i.GetString().
set ErrorCode and return true if it is Ok
Definition at line 4597 of file SMESH_Pattern.cxx.
{
myErrorCode = theErrorCode;
return myErrorCode == ERR_OK;
}
| double SMESH_Pattern::setFirstEdge | ( | std::list< TopoDS_Edge > & | theWire, |
| int | theFirstEdgeID | ||
| ) | [private] |
Definition at line 2104 of file SMESH_Pattern.cxx.
References Handle(), Max(), MESSAGE, SMESH_Pattern.TPoint.myUV, SMESH_Pattern.TPoint.myXYZ, and ex21_lamp.size.
{
int iE, nbEdges = theWire.size();
if ( nbEdges == 1 )
return 0;
// Transform UVs computed by iso to fit bnd box of a wire
// max nb of points on an edge
int maxNbPnt = 0;
int eID = theFirstEdgeID;
for ( iE = 0; iE < nbEdges; iE++ )
maxNbPnt = Max ( maxNbPnt, getShapePoints( eID++ ).size() );
// compute bnd boxes
TopoDS_Face face = TopoDS::Face( myShape );
Bnd_Box2d bndBox, eBndBox;
eID = theFirstEdgeID;
list< TopoDS_Edge >::iterator eIt;
list< TPoint* >::iterator pIt;
for ( eIt = theWire.begin(); eIt != theWire.end(); eIt++ )
{
// UV by isos stored in TPoint.myXYZ
list< TPoint* > & ePoints = getShapePoints( eID++ );
for ( pIt = ePoints.begin(); pIt != ePoints.end(); pIt++ ) {
TPoint* p = (*pIt);
bndBox.Add( gp_Pnt2d( p->myXYZ.X(), p->myXYZ.Y() ));
}
// UV by an edge p-curve
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface( *eIt, face, f, l );
double dU = ( l - f ) / ( maxNbPnt - 1 );
for ( int i = 0; i < maxNbPnt; i++ )
eBndBox.Add( C2d->Value( f + i * dU ));
}
// transform UVs by isos
double minPar[2], maxPar[2], eMinPar[2], eMaxPar[2];
bndBox.Get( minPar[0], minPar[1], maxPar[0], maxPar[1] );
eBndBox.Get( eMinPar[0], eMinPar[1], eMaxPar[0], eMaxPar[1] );
#ifdef DBG_SETFIRSTEDGE
MESSAGE ( "EDGES: X: " << eMinPar[0] << " - " << eMaxPar[0] << " Y: "
<< eMinPar[1] << " - " << eMaxPar[1] );
#endif
for ( int iC = 1, i = 0; i < 2; iC++, i++ ) // loop on 2 coordinates
{
double dMin = eMinPar[i] - minPar[i];
double dMax = eMaxPar[i] - maxPar[i];
double dPar = maxPar[i] - minPar[i];
eID = theFirstEdgeID;
for ( iE = 0; iE < nbEdges; iE++ ) // loop on edges of a boundary
{
list< TPoint* > & ePoints = getShapePoints( eID++ );
for ( pIt = ++ePoints.begin(); pIt != ePoints.end(); pIt++ ) // loop on edge points
{
double par = (*pIt)->myXYZ.Coord( iC );
double r = ( par - minPar[i] ) / dPar;
par += ( 1 - r ) * dMin + r * dMax;
(*pIt)->myXYZ.SetCoord( iC, par );
}
}
}
TopoDS_Edge eBest;
double minDist = DBL_MAX;
for ( iE = 0 ; iE < nbEdges; iE++ )
{
#ifdef DBG_SETFIRSTEDGE
MESSAGE ( " VARIANT " << iE );
#endif
// evaluate the distance between UV computed by the 2 methods:
// by isos intersection ( myXYZ ) and by edge p-curves ( myUV )
double dist = 0;
int eID = theFirstEdgeID;
for ( eIt = theWire.begin(); eIt != theWire.end(); eIt++ )
{
list< TPoint* > & ePoints = getShapePoints( eID++ );
computeUVOnEdge( *eIt, ePoints );
for ( pIt = ++ePoints.begin(); pIt != ePoints.end(); pIt++ ) {
TPoint* p = (*pIt);
dist += ( p->myUV - gp_XY( p->myXYZ.X(), p->myXYZ.Y() )).SquareModulus();
#ifdef DBG_SETFIRSTEDGE
MESSAGE ( " ISO : ( " << p->myXYZ.X() << ", "<< p->myXYZ.Y() << " ) PCURVE : ( " <<
p->myUV.X() << ", " << p->myUV.Y() << ") " );
#endif
}
}
#ifdef DBG_SETFIRSTEDGE
MESSAGE ( "dist -- " << dist );
#endif
if ( dist < minDist ) {
minDist = dist;
eBest = theWire.front();
}
// check variant with another first edge
theWire.splice( theWire.begin(), theWire, --theWire.end(), theWire.end() );
}
// put the best first edge to the theWire front
if ( eBest != theWire.front() ) {
eIt = find ( theWire.begin(), theWire.end(), eBest );
theWire.splice( theWire.begin(), theWire, eIt, theWire.end() );
}
return minDist;
}
| bool SMESH_Pattern::setShapeToMesh | ( | const TopoDS_Shape & | theShape | ) | [private] |
Definition at line 4608 of file SMESH_Pattern.cxx.
References MESSAGE.
{
if ( !IsLoaded() ) {
MESSAGE( "Pattern not loaded" );
return setErrorCode( ERR_APPL_NOT_LOADED );
}
TopAbs_ShapeEnum aType = theShape.ShapeType();
bool dimOk = ( myIs2D ? aType == TopAbs_FACE : aType == TopAbs_SHELL );
if ( !dimOk ) {
MESSAGE( "Pattern dimention mismatch" );
return setErrorCode( ERR_APPL_BAD_DIMENTION );
}
// check if a face is closed
int nbNodeOnSeamEdge = 0;
if ( myIs2D ) {
TopTools_MapOfShape seamVertices;
TopoDS_Face face = TopoDS::Face( theShape );
TopExp_Explorer eExp( theShape, TopAbs_EDGE );
for ( ; eExp.More() && nbNodeOnSeamEdge == 0; eExp.Next() ) {
const TopoDS_Edge& ee = TopoDS::Edge(eExp.Current());
if ( BRep_Tool::IsClosed(ee, face) ) {
// seam edge and vertices encounter twice in theFace
if ( !seamVertices.Add( TopExp::FirstVertex( ee ))) nbNodeOnSeamEdge++;
if ( !seamVertices.Add( TopExp::LastVertex( ee ))) nbNodeOnSeamEdge++;
}
}
}
// check nb of vertices
TopTools_IndexedMapOfShape vMap;
TopExp::MapShapes( theShape, TopAbs_VERTEX, vMap );
if ( vMap.Extent() + nbNodeOnSeamEdge != myKeyPointIDs.size() ) {
MESSAGE( myKeyPointIDs.size() + nbNodeOnSeamEdge << " != " << vMap.Extent() );
return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
}
myElements.clear(); // not refine elements
myElemXYZIDs.clear();
myShapeIDMap.Clear();
myShape = theShape;
return true;
}
| bool SMESH_Pattern::sortSameSizeWires | ( | TListOfEdgesList & | theWireList, |
| const TListOfEdgesList::iterator & | theFromWire, | ||
| const TListOfEdgesList::iterator & | theToWire, | ||
| const int | theFirstEdgeID, | ||
| std::list< std::list< TPoint * > > & | theEdgesPointsList | ||
| ) | [private] |
Definition at line 2219 of file SMESH_Pattern.cxx.
References Abs(), MESSAGE, SMESH_Pattern.TPoint.myInitUV, SMESH_Pattern.TPoint.myUV, SMESH_Pattern.TPoint.myXYZ, PAL_MESH_043_3D.wire, and XY().
{
TopoDS_Face F = TopoDS::Face( myShape );
int iW, nbWires = 0;
TListOfEdgesList::iterator wlIt = theFromWire;
while ( wlIt++ != theToWire )
nbWires++;
// Recompute key-point UVs by isolines intersection,
// compute CG of key-points for each wire and bnd boxes of GCs
bool aBool;
gp_XY orig( gp::Origin2d().XY() );
vector< gp_XY > vGcVec( nbWires, orig ), gcVec( nbWires, orig );
Bnd_Box2d bndBox, vBndBox;
int eID = theFirstEdgeID;
list< TopoDS_Edge >::iterator eIt;
for ( iW = 0, wlIt = theFromWire; wlIt != theToWire; wlIt++, iW++ )
{
list< TopoDS_Edge > & wire = *wlIt;
for ( eIt = wire.begin(); eIt != wire.end(); eIt++ )
{
list< TPoint* > & ePoints = getShapePoints( eID++ );
TPoint* p = ePoints.front();
if ( !compUVByIsoIntersection( theEdgesPointsList, p->myInitUV, p->myUV, aBool )) {
MESSAGE("cant sortSameSizeWires()");
return false;
}
gcVec[iW] += p->myUV;
bndBox.Add( gp_Pnt2d( p->myUV ));
TopoDS_Vertex V = TopExp::FirstVertex( *eIt, true );
gp_Pnt2d vXY = BRep_Tool::Parameters( V, F );
vGcVec[iW] += vXY.XY();
vBndBox.Add( vXY );
// keep the computed UV to compare against by setFirstEdge()
p->myXYZ.SetCoord( p->myUV.X(), p->myUV.Y(), 0. );
}
gcVec[iW] /= nbWires;
vGcVec[iW] /= nbWires;
// cout << " Wire " << iW << " iso: " << gcVec[iW].X() << " " << gcVec[iW].Y() << endl <<
// " \t vertex: " << vGcVec[iW].X() << " " << vGcVec[iW].Y() << endl;
}
// Transform GCs computed by isos to fit in bnd box of GCs by vertices
double minPar[2], maxPar[2], vMinPar[2], vMaxPar[2];
bndBox.Get( minPar[0], minPar[1], maxPar[0], maxPar[1] );
vBndBox.Get( vMinPar[0], vMinPar[1], vMaxPar[0], vMaxPar[1] );
for ( int iC = 1, i = 0; i < 2; iC++, i++ ) // loop on 2 coordinates
{
double dMin = vMinPar[i] - minPar[i];
double dMax = vMaxPar[i] - maxPar[i];
double dPar = maxPar[i] - minPar[i];
if ( Abs( dPar ) <= DBL_MIN )
continue;
for ( iW = 0; iW < nbWires; iW++ ) { // loop on GCs of wires
double par = gcVec[iW].Coord( iC );
double r = ( par - minPar[i] ) / dPar;
par += ( 1 - r ) * dMin + r * dMax;
gcVec[iW].SetCoord( iC, par );
}
}
// Define boundary - wire correspondence by GC closeness
TListOfEdgesList tmpWList;
tmpWList.splice( tmpWList.end(), theWireList, theFromWire, theToWire );
typedef map< int, TListOfEdgesList::iterator > TIntWirePosMap;
TIntWirePosMap bndIndWirePosMap;
vector< bool > bndFound( nbWires, false );
for ( iW = 0, wlIt = tmpWList.begin(); iW < nbWires; iW++, wlIt++ )
{
// cout << " TRSF Wire " << iW << " iso: " << gcVec[iW].X() << " " << gcVec[iW].Y() << endl <<
// " \t vertex: " << vGcVec[iW].X() << " " << vGcVec[iW].Y() << endl;
double minDist = DBL_MAX;
gp_XY & wGc = vGcVec[ iW ];
int bIndex;
for ( int iB = 0; iB < nbWires; iB++ ) {
if ( bndFound[ iB ] ) continue;
double dist = ( wGc - gcVec[ iB ] ).SquareModulus();
if ( dist < minDist ) {
minDist = dist;
bIndex = iB;
}
}
bndFound[ bIndex ] = true;
bndIndWirePosMap.insert( TIntWirePosMap::value_type( bIndex, wlIt ));
}
// Treat each wire
TIntWirePosMap::iterator bIndWPosIt = bndIndWirePosMap.begin();
eID = theFirstEdgeID;
for ( ; bIndWPosIt != bndIndWirePosMap.end(); bIndWPosIt++ )
{
TListOfEdgesList::iterator wirePos = (*bIndWPosIt).second;
list < TopoDS_Edge > & wire = ( *wirePos );
// choose the best first edge of a wire
setFirstEdge( wire, eID );
// compute eventual UV and fill theEdgesPointsList
theEdgesPointsList.push_back( list< TPoint* >() );
list< TPoint* > & edgesPoints = theEdgesPointsList.back();
for ( eIt = wire.begin(); eIt != wire.end(); eIt++ )
{
list< TPoint* > & ePoints = getShapePoints( eID++ );
computeUVOnEdge( *eIt, ePoints );
edgesPoints.insert( edgesPoints.end(), ePoints.begin(), (--ePoints.end()));
}
// put wire back to theWireList
wlIt = wirePos++;
theWireList.splice( theToWire, tmpWList, wlIt, wirePos );
}
return true;
}
| std::ostream& operator<< | ( | std::ostream & | OS, |
| const TPoint & | p | ||
| ) | [friend] |
Definition at line 4765 of file SMESH_Pattern.cxx.
{
gp_XYZ xyz = p.myInitXYZ;
OS << "\tinit( xyz( " << xyz.X() << " " << xyz.Y() << " " << xyz.Z() << " )";
gp_XY xy = p.myInitUV;
OS << " uv( " << xy.X() << " " << xy.Y() << " )";
double u = p.myInitU;
OS << " u( " << u << " )) " << &p << endl;
xyz = p.myXYZ.XYZ();
OS << "\t ( xyz( " << xyz.X() << " " << xyz.Y() << " " << xyz.Z() << " )";
xy = p.myUV;
OS << " uv( " << xy.X() << " " << xy.Y() << " )";
u = p.myU;
OS << " u( " << u << " ))" << endl;
return OS;
}
std::vector<const SMDS_MeshElement*> SMESH_Pattern.myElements [private] |
Definition at line 371 of file SMESH_Pattern.hxx.
std::list< TElemDef > SMESH_Pattern.myElemPointIDs [private] |
Definition at line 349 of file SMESH_Pattern.hxx.
std::list< TElemDef > SMESH_Pattern.myElemXYZIDs [private] |
Definition at line 369 of file SMESH_Pattern.hxx.
ErrorCode SMESH_Pattern.myErrorCode [private] |
Definition at line 351 of file SMESH_Pattern.hxx.
std::map<TNodeSet,std::list<std::list<int> > > SMESH_Pattern.myIdsOnBoundary [private] |
Definition at line 383 of file SMESH_Pattern.hxx.
bool SMESH_Pattern.myIs2D [private] |
Definition at line 346 of file SMESH_Pattern.hxx.
bool SMESH_Pattern.myIsBoundaryPointsFound [private] |
Definition at line 353 of file SMESH_Pattern.hxx.
bool SMESH_Pattern.myIsComputed [private] |
Definition at line 352 of file SMESH_Pattern.hxx.
std::list< int > SMESH_Pattern.myKeyPointIDs [private] |
Definition at line 348 of file SMESH_Pattern.hxx.
std::list< int > SMESH_Pattern.myNbKeyPntInBoundary [private] |
Definition at line 363 of file SMESH_Pattern.hxx.
std::vector<const SMDS_MeshNode*> SMESH_Pattern.myOrderedNodes [private] |
Definition at line 372 of file SMESH_Pattern.hxx.
std::vector< TPoint > SMESH_Pattern.myPoints [private] |
Definition at line 347 of file SMESH_Pattern.hxx.
std::vector<const SMDS_MeshElement*> SMESH_Pattern.myPolyElems [private] |
Definition at line 375 of file SMESH_Pattern.hxx.
std::list< TElemDef > SMESH_Pattern.myPolyElemXYZIDs [private] |
Definition at line 377 of file SMESH_Pattern.hxx.
std::list< std::vector<int> > SMESH_Pattern.myPolyhedronQuantities [private] |
Definition at line 378 of file SMESH_Pattern.hxx.
std::map< int, std::list< TElemDef* > > SMESH_Pattern.myReverseConnectivity [private] |
Definition at line 385 of file SMESH_Pattern.hxx.
TopoDS_Shape SMESH_Pattern.myShape [private] |
Definition at line 355 of file SMESH_Pattern.hxx.
TopTools_IndexedMapOfOrientedShape SMESH_Pattern.myShapeIDMap [private] |
Definition at line 358 of file SMESH_Pattern.hxx.
std::map< int, std::list< TPoint* > > SMESH_Pattern.myShapeIDToPointsMap [private] |
Definition at line 359 of file SMESH_Pattern.hxx.
std::vector<gp_XYZ> SMESH_Pattern.myXYZ [private] |
Definition at line 368 of file SMESH_Pattern.hxx.
std::map< int, const SMDS_MeshNode*> SMESH_Pattern.myXYZIdToNodeMap [private] |
Definition at line 370 of file SMESH_Pattern.hxx.