- else
- {
- int edgeID = meshDS->ShapeToIndex(LinEdge2);
- gp_Vec aVec = gp_Vec(P0,P2);
- // check orientation
- Handle(Geom_Curve) Crv = BRep_Tool::Curve(LinEdge2,fp,lp);
- gp_Pnt Ptmp = Crv->Value(fp);
- bool ori = false;
- if( P2.Distance(Ptmp) > Precision::Confusion() )
- ori = true;
- // get UV points for edge
- gp_Pnt2d PF,PL;
- BRep_Tool::UVPoints( LinEdge2, TopoDS::Face(aShape), PF, PL );
- gp_Vec2d V2d;
- if(ori) {
- V2d = gp_Vec2d(PF,PL);
- PC = PF;
- }
- else {
- V2d = gp_Vec2d(PL,PF);
- PC = PL;
- }
- double dp = lp-fp;
- for ( size_t i = 0; i < myLayerPositions.size(); i++ ) {
- gp_Pnt P( P0.X() + aVec.X()*myLayerPositions[i],
- P0.Y() + aVec.Y()*myLayerPositions[i],
- P0.Z() + aVec.Z()*myLayerPositions[i] );
- SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
- Nodes2[i] = node;
- double param;
- if(!ori)
- param = fp + dp*(1-myLayerPositions[i]);
- else
- param = fp + dp*myLayerPositions[i];
- meshDS->SetNodeOnEdge(node, edgeID, param);
- // parameters on face
- gp_Pnt2d P2d( PC.X() + V2d.X()*myLayerPositions[i],
- PC.Y() + V2d.Y()*myLayerPositions[i] );
- }
- Nodes2[ myLayerPositions.size() ] = NL;
- // create 1D elements on edge
- SMDS_MeshEdge* ME = myHelper->AddEdge( NC, Nodes2[0] );
- if ( ME ) meshDS->SetMeshElementOnShape(ME, edgeID);
- for ( size_t i = 1; i < Nodes2.size(); i++ ) {
- ME = myHelper->AddEdge( Nodes2[i-1], Nodes2[i] );
- if(ME) meshDS->SetMeshElementOnShape(ME, edgeID);
- }
- }
- markEdgeAsComputedByMe( LinEdge2, aMesh.GetSubMesh( F ));
- }
- markEdgeAsComputedByMe( CircEdge, aMesh.GetSubMesh( F ));
-
- // orientation
- bool IsForward = ( CircEdge.Orientation()==TopAbs_FORWARD );
- const double angleSign = ( F.Orientation() == TopAbs_REVERSED ? -1.0 : 1.0 );
-
- // create nodes and mesh elements on face
- // find axis of rotation
- gp_Pnt P2 = gp_Pnt( CNodes[1]->X(), CNodes[1]->Y(), CNodes[1]->Z() );
- gp_Vec Vec1(P0,P1);
- gp_Vec Vec2(P0,P2);
- gp_Vec Axis = Vec1.Crossed(Vec2);
- // create elements
- int i = 1;
- //cout<<"Angles.Length() = "<<Angles.Length()<<" Points.Length() = "<<Points.Length()<<endl;
- //cout<<"Nodes1.size() = "<<Nodes1.size()<<" Pnts2d1.Length() = "<<Pnts2d1.Length()<<endl;
- for(; i<Angles.Length(); i++) {
- vector< const SMDS_MeshNode* > tmpNodes;
- gp_Trsf aTrsf;
- gp_Ax1 theAxis(P0,gp_Dir(Axis));
- aTrsf.SetRotation( theAxis, Angles.Value(i) );
- gp_Trsf2d aTrsf2d;
- aTrsf2d.SetRotation( PC, Angles.Value(i) * angleSign );
- // create nodes
- int j = 1;
- for(; j<=Points.Length(); j++) {
- double cx,cy,cz;
- Points.Value(j).Coord( cx, cy, cz );
- aTrsf.Transforms( cx, cy, cz );
- SMDS_MeshNode* node = myHelper->AddNode( cx, cy, cz );
- // find parameters on face
- Pnts2d1.Value(j).Coord( cx, cy );
- aTrsf2d.Transforms( cx, cy );
- // set node on face
- meshDS->SetNodeOnFace( node, faceID, cx, cy );
- tmpNodes.push_back(node);
- }
- // create faces
- tmpNodes.push_back( CNodes[i] );
- // quad
- for ( j = 0; j < (int)Nodes1.size() - 1; j++ ) {
- SMDS_MeshFace* MF;
- if(IsForward)
- MF = myHelper->AddFace( tmpNodes[j], Nodes1[j],
- Nodes1[j+1], tmpNodes[j+1] );
- else
- MF = myHelper->AddFace( tmpNodes[j], tmpNodes[j+1],
- Nodes1[j+1], Nodes1[j] );
- if(MF) meshDS->SetMeshElementOnShape(MF, faceID);
- }
- // tria
- SMDS_MeshFace* MF;
- if(IsForward)
- MF = myHelper->AddFace( NC, Nodes1[0], tmpNodes[0] );
- else
- MF = myHelper->AddFace( NC, tmpNodes[0], Nodes1[0] );
- if ( MF ) meshDS->SetMeshElementOnShape(MF, faceID);
- for ( j = 0; j < (int) Nodes1.size(); j++ ) {
- Nodes1[j] = tmpNodes[j];
- }
- }
- // create last faces
- // quad
- for ( i = 0; i < (int)Nodes1.size()-1; i++ ) {
- SMDS_MeshFace* MF;
- if(IsForward)
- MF = myHelper->AddFace( Nodes2[i], Nodes1[i],
- Nodes1[i+1], Nodes2[i+1] );
- else
- MF = myHelper->AddFace( Nodes2[i], Nodes2[i+1],
- Nodes1[i+1], Nodes1[i] );
- if(MF) meshDS->SetMeshElementOnShape(MF, faceID);