Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
69bf9b0a
Commit
69bf9b0a
authored
8 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
don't crash if old bezier curves (GEO) have too few control points
parent
5ba10358
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Geo/GModelIO_GEO.cpp
+4
-0
4 additions, 0 deletions
Geo/GModelIO_GEO.cpp
Geo/GeoInterpolation.cpp
+7
-4
7 additions, 4 deletions
Geo/GeoInterpolation.cpp
with
11 additions
and
4 deletions
Geo/GModelIO_GEO.cpp
+
4
−
0
View file @
69bf9b0a
...
...
@@ -258,6 +258,10 @@ bool GEO_Internals::addBezier(int num, const std::vector<int> &vertexTags)
Msg
::
Error
(
"GEO edge with tag %d already exists"
,
num
);
return
false
;
}
if
(
vertexTags
.
size
()
<
4
){
Msg
::
Error
(
"Bezier curve requires at least 4 control points"
);
return
false
;
}
List_T
*
tmp
=
List_Create
(
2
,
2
,
sizeof
(
int
));
for
(
unsigned
int
i
=
0
;
i
<
vertexTags
.
size
();
i
++
){
int
t
=
vertexTags
[
i
];
...
...
This diff is collapsed.
Click to expand it.
Geo/GeoInterpolation.cpp
+
7
−
4
View file @
69bf9b0a
...
...
@@ -12,8 +12,6 @@
#define SQU(a) ((a)*(a))
// Cubic spline :
/*
static void InterpolateBezier(Vertex *v[4], double t, Vertex &V)
{
...
...
@@ -181,6 +179,11 @@ SPoint2 InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4],
static
Vertex
InterpolateBezier
(
Curve
*
Curve
,
double
u
,
int
derivee
)
{
int
NbCurves
=
(
List_Nbr
(
Curve
->
Control_Points
)
-
1
)
/
3
;
if
(
NbCurves
<=
0
){
Msg
::
Error
(
"Bezier curve requires at least 4 control points"
);
Vertex
V
;
return
V
;
}
int
iCurve
=
(
int
)
floor
(
u
*
(
double
)
NbCurves
);
if
(
iCurve
>=
NbCurves
)
iCurve
=
NbCurves
-
1
;
// u = 1
if
(
iCurve
<=
0
)
iCurve
=
0
;
...
...
@@ -240,7 +243,7 @@ static Vertex InterpolateUBS(Curve *Curve, double u, int derivee)
return
V
;
}
else
//
return InterpolateCubicSpline(v, t, Curve->mat, derivee, t1, t2);
// return InterpolateCubicSpline(v, t, Curve->mat, derivee, t1, t2);
return
InterpolateCubicSpline
(
v
,
t
);
}
...
...
@@ -557,7 +560,7 @@ static Vertex TransfiniteQua(Vertex c1, Vertex c2, Vertex c3, Vertex c4,
s1
.
Pos
.
Y
,
s2
.
Pos
.
Y
,
s3
.
Pos
.
Y
,
s4
.
Pos
.
Y
,
u
,
v
);
V
.
Pos
.
Z
=
TRAN_QUA
(
c1
.
Pos
.
Z
,
c2
.
Pos
.
Z
,
c3
.
Pos
.
Z
,
c4
.
Pos
.
Z
,
s1
.
Pos
.
Z
,
s2
.
Pos
.
Z
,
s3
.
Pos
.
Z
,
s4
.
Pos
.
Z
,
u
,
v
);
return
(
V
)
;
return
V
;
}
// Transfinite interpolation on a triangle :
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment