- if (BRep_Tool::Degenerated(E))
- {
- // Edge is a degenerated Edge : We put n = 5 points on the edge.
- int NbPoints = 5;
- BRep_Tool::Range(E,f,l);
- double du = (l-f)/(NbPoints-1);
- MESSAGE("************* Degenerated edge! *****************");
-
- TopoDS_Vertex V1,V2;
- TopExp::Vertices (E,V1,V2);
- gp_Pnt P = BRep_Tool::Pnt(V1);
-
- int idPrev = idFirst;
- for (int i=2; i<NbPoints; i++)
- {
- double param = f + (i-1)*du;
- //Add the Node in the DataStructure
- int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
- //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
-
- Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
- Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
- meshDS->SetNodeOnEdge(node, E);
-
-// Handle (SMDS_EdgePosition) epos
-// = new SMDS_EdgePosition(theSubMesh->GetId(),param);
-// node->SetPosition(epos);
- Handle (SMDS_EdgePosition) epos
- = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
- epos->SetUParameter(param);
-
- int edgeId = meshDS->AddEdge(idPrev, nodeId);
- elt = meshDS->FindElement(edgeId);
- meshDS->SetMeshElementOnShape(elt, E);
- idPrev = nodeId;
- }
- int edgeId = meshDS->AddEdge(idPrev, idLast);
- Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
- meshDS->SetMeshElementOnShape(elt, E);
+ if (BRep_Tool::Degenerated(E))
+ {
+ // Edge is a degenerated Edge : We put n = 5 points on the edge.
+ int NbPoints = 5;
+ BRep_Tool::Range(E, f, l);
+ double du = (l - f) / (NbPoints - 1);
+ MESSAGE("************* Degenerated edge! *****************");
+
+ TopoDS_Vertex V1, V2;
+ TopExp::Vertices(E, V1, V2);
+ gp_Pnt P = BRep_Tool::Pnt(V1);
+
+ const SMDS_MeshNode * idPrev = idFirst;
+ for (int i = 2; i < NbPoints; i++)
+ {
+ double param = f + (i - 1) * du;
+ SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnEdge(node, E);
+
+// Handle (SMDS_EdgePosition) epos
+// = new SMDS_EdgePosition(theSubMesh->GetId(),param);
+// node->SetPosition(epos);
+ SMDS_EdgePosition* epos
+ = dynamic_cast<SMDS_EdgePosition*>(node->GetPosition());
+ epos->SetUParameter(param);
+
+ SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
+ meshDS->SetMeshElementOnShape(edge, E);
+ idPrev = node;
+ }
+ SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
+ meshDS->SetMeshElementOnShape(edge, E);
+ }
+ else
+ ASSERT(0);