Skip to content
Snippets Groups Projects
Commit 944b22e3 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent f1e7cef9
Branches
Tags
No related merge requests found
// $Id: OCCEdge.cpp,v 1.19 2007-01-31 12:27:18 remacle Exp $ // $Id: OCCEdge.cpp,v 1.20 2007-02-03 00:02:16 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -45,7 +45,7 @@ OCCEdge::OCCEdge(GModel *model, TopoDS_Edge edge, int num, GVertex *v1, GVertex ...@@ -45,7 +45,7 @@ OCCEdge::OCCEdge(GModel *model, TopoDS_Edge edge, int num, GVertex *v1, GVertex
Range<double> OCCEdge::parBounds(int i) const Range<double> OCCEdge::parBounds(int i) const
{ {
return(Range<double>(s0,s1)); return Range<double>(s0, s1);
} }
void OCCEdge::setTrimmed (OCCFace *f) void OCCEdge::setTrimmed (OCCFace *f)
...@@ -54,7 +54,7 @@ void OCCEdge::setTrimmed (OCCFace *f) ...@@ -54,7 +54,7 @@ void OCCEdge::setTrimmed (OCCFace *f)
trimmed = f; trimmed = f;
const TopoDS_Face *s = (TopoDS_Face*) trimmed->getNativePtr(); const TopoDS_Face *s = (TopoDS_Face*) trimmed->getNativePtr();
curve2d = BRep_Tool::CurveOnSurface(c, *s, s0, s1); curve2d = BRep_Tool::CurveOnSurface(c, *s, s0, s1);
if (curve2d.IsNull()) trimmed = 0; if(curve2d.IsNull()) trimmed = 0;
} }
} }
...@@ -64,14 +64,12 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const ...@@ -64,14 +64,12 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const
double t0,t1; double t0,t1;
Handle(Geom2d_Curve) c2d; Handle(Geom2d_Curve) c2d;
if(dir == 1) if(dir == 1){
{ c2d = BRep_Tool::CurveOnSurface(c, *s, t0, t1);
c2d = BRep_Tool::CurveOnSurface(c, *s, t0, t1); }
} else{
else c2d = BRep_Tool::CurveOnSurface(c_rev, *s, t0, t1);
{ }
c2d = BRep_Tool::CurveOnSurface(c_rev, *s, t0, t1);
}
if(c2d.IsNull()){ if(c2d.IsNull()){
Msg(FATAL,"Reparam on face failed : curve %d is not on surface %d",tag(),face->tag()); Msg(FATAL,"Reparam on face failed : curve %d is not on surface %d",tag(),face->tag());
...@@ -89,24 +87,27 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const ...@@ -89,24 +87,27 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const
const double dy = p1.y()-p2.y(); const double dy = p1.y()-p2.y();
const double dz = p1.z()-p2.z(); const double dz = p1.z()-p2.z();
if(sqrt(dx*dx+dy*dy+dz*dz) > 1.e-7 * CTX.lc){ if(sqrt(dx*dx+dy*dy+dz*dz) > 1.e-7 * CTX.lc){
// return reparamOnFace(face, epar,-1); // return reparamOnFace(face, epar,-1);
Msg(WARNING,"Reparam on face partially failed for curve %d surface %d at point %g",tag(),face->tag(),epar); Msg(WARNING, "Reparam on face partially failed for curve %d surface %d at point %g",
Msg(WARNING,"On the face %d local (%g %g) global (%g %g %g)",face->tag(),u,v,p2.x(),p2.y(),p2.z()); tag(), face->tag(), epar);
Msg(WARNING,"On the edge %d local (%g) global (%g %g %g)",tag(),epar,p1.x(),p1.y(),p1.z()); Msg(WARNING, "On the face %d local (%g %g) global (%g %g %g)",
GPoint ppp = face->closestPoint(SPoint3(p1.x(),p1.y(),p1.z())); face->tag(), u, v, p2.x(), p2.y(), p2.z());
return SPoint2(ppp.u(),ppp.v()); Msg(WARNING, "On the edge %d local (%g) global (%g %g %g)",
tag(), epar, p1.x(), p1.y(), p1.z());
GPoint ppp = face->closestPoint(SPoint3(p1.x(), p1.y(), p1.z()));
return SPoint2(ppp.u(), ppp.v());
} }
} }
return SPoint2(u,v); return SPoint2(u, v);
} }
// True if the edge is a seam for the given face // True if the edge is a seam for the given face
int OCCEdge::isSeam(GFace *face) const int OCCEdge::isSeam(GFace *face) const
{ {
const TopoDS_Face *s = (TopoDS_Face*) face->getNativePtr(); const TopoDS_Face *s = (TopoDS_Face*) face->getNativePtr();
BRepAdaptor_Surface surface( *s ); BRepAdaptor_Surface surface(*s);
if(surface.IsUPeriodic() || surface.IsVPeriodic()){ if(surface.IsUPeriodic() || surface.IsVPeriodic()){
return BRep_Tool::IsClosed( c, *s ); return BRep_Tool::IsClosed(c, *s);
} }
return 0; return 0;
} }
...@@ -115,16 +116,16 @@ GPoint OCCEdge::point(double par) const ...@@ -115,16 +116,16 @@ GPoint OCCEdge::point(double par) const
{ {
if(!curve.IsNull()){ if(!curve.IsNull()){
gp_Pnt pnt = curve->Value (par); gp_Pnt pnt = curve->Value (par);
return GPoint(pnt.X(),pnt.Y(),pnt.Z()); return GPoint(pnt.X(), pnt.Y(), pnt.Z());
} }
else if(trimmed){ else if(trimmed){
double u,v; double u, v;
curve2d->Value(par).Coord(u,v); curve2d->Value(par).Coord(u, v);
return trimmed->point(u,v); return trimmed->point(u, v);
} }
else{ else{
Msg(WARNING,"OCC Curve %d is neither a 3D curve not a trimmed curve",tag()); Msg(WARNING, "OCC Curve %d is neither a 3D curve not a trimmed curve", tag());
return GPoint (0,0,0); return GPoint(0, 0, 0);
} }
} }
......
// $Id: gmshEdge.cpp,v 1.27 2007-02-02 17:16:46 remacle Exp $ // $Id: gmshEdge.cpp,v 1.28 2007-02-03 00:02:16 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -145,53 +145,53 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const ...@@ -145,53 +145,53 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const
{ {
Surface *s = (Surface*) face->getNativePtr(); Surface *s = (Surface*) face->getNativePtr();
if (s->geometry) if(s->geometry){
{ switch (c->Typ) {
switch (c->Typ) { case MSH_SEGM_LINE:
case MSH_SEGM_LINE: {
{ Vertex *v[3];
Vertex *v[3]; List_Read(c->Control_Points, 0, &v[1]);
List_Read(c->Control_Points, 0, &v[1]); List_Read(c->Control_Points, 1, &v[2]);
List_Read(c->Control_Points, 1, &v[2]); SPoint2 p = v[1]->pntOnGeometry +
SPoint2 p = v[1] -> pntOnGeometry + (v[2] -> pntOnGeometry - v[1] -> pntOnGeometry) * epar; (v[2]->pntOnGeometry - v[1]->pntOnGeometry) * epar;
return p; return p;
}
break;
case MSH_SEGM_SPLN :
{
Vertex *v[4];
Vertex temp1, temp2;
int N = List_Nbr(c->Control_Points);
int i = (int)((double)(N - 1) * epar);
if(i < 0)
i = 0;
if(i >= N - 1)
i = N - 2;
double t1 = (double)(i) / (double)(N - 1);
double t2 = (double)(i + 1) / (double)(N - 1);
double t = (epar - t1) / (t2 - t1);
List_Read(c->Control_Points, i, &v[1]);
List_Read(c->Control_Points, i + 1, &v[2]);
if(!i) {
v[0] = &temp1;
v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry;
}
else {
List_Read(c->Control_Points, i - 1, &v[0]);
}
if(i == N - 2) {
v[3] = &temp2;
v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry;
} }
break; else {
case MSH_SEGM_SPLN : List_Read(c->Control_Points, i + 2, &v[3]);
{ }
Vertex *v[4]; return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2,c->geometry);
Vertex temp1, temp2;
int N = List_Nbr(c->Control_Points);
int i = (int)((double)(N - 1) * epar);
if(i < 0)
i = 0;
if(i >= N - 1)
i = N - 2;
double t1 = (double)(i) / (double)(N - 1);
double t2 = (double)(i + 1) / (double)(N - 1);
double t = (epar - t1) / (t2 - t1);
List_Read(c->Control_Points, i, &v[1]);
List_Read(c->Control_Points, i + 1, &v[2]);
if(!i) {
v[0] = &temp1;
v[0]->pntOnGeometry = v[1]->pntOnGeometry * 2. - v[2]->pntOnGeometry;
}
else {
List_Read(c->Control_Points, i - 1, &v[0]);
}
if(i == N - 2) {
v[3] = &temp2;
v[3]->pntOnGeometry = v[2]->pntOnGeometry * 2. - v[1]->pntOnGeometry;
}
else {
List_Read(c->Control_Points, i + 2, &v[3]);
}
return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2,c->geometry);
}
default :
throw;
} }
default :
throw;
} }
}
if (s->Typ == MSH_SURF_REGL){ if (s->Typ == MSH_SURF_REGL){
Curve *C[4]; Curve *C[4];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment