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
066827bd
Commit
066827bd
authored
11 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
geo : fix bezier curve (so that we can have perfect match with svg path)
parent
37ae059b
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/GeoInterpolation.cpp
+33
-2
33 additions, 2 deletions
Geo/GeoInterpolation.cpp
demos/splines.geo
+1
-2
1 addition, 2 deletions
demos/splines.geo
with
34 additions
and
4 deletions
Geo/GeoInterpolation.cpp
+
33
−
2
View file @
066827bd
...
...
@@ -135,6 +135,32 @@ SPoint2 InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4],
}
return
p
;
}
// Bezier
static
Vertex
InterpolateBezier
(
Curve
*
Curve
,
double
u
,
int
derivee
)
{
int
NbCurves
=
(
List_Nbr
(
Curve
->
Control_Points
)
-
1
)
/
3
;
int
iCurve
=
(
int
)
floor
(
u
*
(
double
)
NbCurves
);
if
(
iCurve
==
NbCurves
)
iCurve
-=
1
;
// u = 1
double
t1
=
(
double
)(
iCurve
)
/
(
double
)(
NbCurves
);
double
t2
=
(
double
)(
iCurve
+
1
)
/
(
double
)(
NbCurves
);
double
t
=
(
u
-
t1
)
/
(
t2
-
t1
);
Vertex
*
v
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
List_Read
(
Curve
->
Control_Points
,
iCurve
*
3
+
i
,
&
v
[
i
]);
}
if
(
Curve
->
geometry
){
SPoint2
pp
=
InterpolateCubicSpline
(
v
,
t
,
Curve
->
mat
,
t1
,
t2
,
Curve
->
geometry
,
derivee
);
SPoint3
pt
=
Curve
->
geometry
->
point
(
pp
);
Vertex
V
;
V
.
Pos
.
X
=
pt
.
x
();
V
.
Pos
.
Y
=
pt
.
y
();
V
.
Pos
.
Z
=
pt
.
z
();
return
V
;
}
else
return
InterpolateCubicSpline
(
v
,
t
,
Curve
->
mat
,
derivee
,
t1
,
t2
);
}
// Uniform BSplines
static
Vertex
InterpolateUBS
(
Curve
*
Curve
,
double
u
,
int
derivee
)
...
...
@@ -274,10 +300,13 @@ Vertex InterpolateCurve(Curve *c, double u, int derivee)
if
(
derivee
==
2
)
{
switch
(
c
->
Typ
)
{
case
MSH_SEGM_BSPLN
:
case
MSH_SEGM_BEZIER
:
V
=
InterpolateUBS
(
c
,
u
,
2
);
V
.
u
=
u
;
break
;
case
MSH_SEGM_BEZIER
:
V
=
InterpolateBezier
(
c
,
u
,
2
);
V
.
u
=
u
;
break
;
default
:
double
eps1
=
(
u
==
0
)
?
0
:
1.e-5
;
double
eps2
=
(
u
==
1
)
?
0
:
1.e-5
;
...
...
@@ -358,9 +387,11 @@ Vertex InterpolateCurve(Curve *c, double u, int derivee)
break
;
case
MSH_SEGM_BSPLN
:
case
MSH_SEGM_BEZIER
:
V
=
InterpolateUBS
(
c
,
u
,
0
);
break
;
case
MSH_SEGM_BEZIER
:
V
=
InterpolateBezier
(
c
,
u
,
0
);
break
;
case
MSH_SEGM_NURBS
:
V
=
InterpolateNurbs
(
c
,
u
,
0
);
...
...
This diff is collapsed.
Click to expand it.
demos/splines.geo
+
1
−
2
View file @
066827bd
...
...
@@ -56,8 +56,7 @@ Point(p+1) = {xx+.5, 0, 0, lc} ;
Point
(
p
+
2
)
=
{
xx
+
.5
,
1
,
0
,
0.1
*
lc
}
;
Point
(
p
+
3
)
=
{
xx
,
1
,
0
,
lc
}
;
l
=
newreg
;
//Bezier(l) = {p+3,p+2,p+1,p}; // Bezier curves are broken
BSpline
(
l
)
=
{
p
+
3
,
p
+
2
,
p
+
1
,
p
};
Bezier
(
l
)
=
{
p
+
3
,
p
+
2
,
p
+
1
,
p
};
// Bezier curves are broken
Line
(
l
+
1
)
=
{
p
,
p
+
3
};
s
=
newreg
;
Line
Loop
(
s
)
=
{
-
l
,
-
(
l
+
1
)};
...
...
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