Skip to content

Commit 330c776

Browse files
authored
Merge pull request #1 from Patch2PDF/chores-and-rotation-change
Chores and rotation change
2 parents e95d530 + 29e3d89 commit 330c776

6 files changed

Lines changed: 20 additions & 70 deletions

File tree

config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package rasterizer
22

3+
import "github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
4+
35
type RasterizerConfig struct {
46
CanvasConfig CanvasConfig
57
RenderLabels bool
6-
Rotation Rotation
8+
Rotation MeshTypes.Matrix
79
OverrideColors OverrideColorMap
810
}
911

examples/main.go

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"runtime/pprof"
1010

1111
GDTFMeshReader "github.com/Patch2PDF/GDTF-Mesh-Reader/v2"
12+
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
1213
MVRParser "github.com/Patch2PDF/MVR-Parser"
1314
MVRTypes "github.com/Patch2PDF/MVR-Parser/pkg/types"
1415
rasterizer "github.com/Patch2PDF/Stagemodel-Rasterizer"
@@ -43,14 +44,6 @@ func main() {
4344
}
4445
GDTFMeshReader.LoadPrimitives()
4546

46-
// content, err := gdtf.ParseGDTFByFilename("test.gdtf", true, false)
47-
// // content, err := gdtf.ParseGDTFByFilename("test3.gdtf", true, false)
48-
// if err != nil {
49-
// log.Fatalf("%s", err)
50-
// }
51-
// mesh, err := content.BuildMesh("32Ch")
52-
// // mesh, err := content.BuildMesh("36 channel")
53-
5447
mvr, err := zip.OpenReader("test5.mvr")
5548
if err != nil {
5649
log.Fatal(err)
@@ -87,13 +80,6 @@ func main() {
8780

8881
stage_model := mvrData.GetStageModel(model_config)
8982

90-
stageModelCopy1 := stage_model.Copy()
91-
stageModelCopy2 := stage_model.Copy()
92-
// TODO: instead of copy, rotate back? (multiply new matrix with inverse of previous) --> need to add function to Mesh-Reader module
93-
94-
// buf1 := &bytes.Buffer{}
95-
// buf2 := &bytes.Buffer{}
96-
9783
overrideColors := rasterizer.OverrideColorMap{
9884
// rasterizer.ModelTypeFixture: map[rasterizer.GeometryType]*color.NRGBA{
9985
// rasterizer.GeometryTypeAxis: {R: 255, G: 0, B: 0, A: 255},
@@ -109,29 +95,21 @@ func main() {
10995
LabelFontSize: 10,
11096
}
11197

112-
canvas1, err := rasterizer.Draw(&stageModelCopy1, rasterizer.RasterizerConfig{RenderLabels: true, Rotation: rasterizer.Rotation{Alpha: 80, Beta: 0, Gamma: 200}, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
98+
rotation1 := MeshTypes.GenerateRotationMatrix(80, 0, 200)
99+
canvas1, err := rasterizer.Draw(&stage_model, rasterizer.RasterizerConfig{RenderLabels: false, Rotation: rotation1, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
113100
if err != nil {
114101
log.Fatal(err)
115102
}
116-
// canvas1.SaveAsPNG(buf1)
103+
104+
rotation2 := MeshTypes.GenerateRotationMatrix(90, 0, 180)
105+
rotation2 = rotation2.ReverseTransformation(rotation1)
117106
rasterizer.SaveCanvasAsPNGFile("side.png", canvas1)
118-
canvas2, err := rasterizer.Draw(&stageModelCopy2, rasterizer.RasterizerConfig{RenderLabels: true, Rotation: rasterizer.Rotation{Alpha: 90, Beta: 0, Gamma: 180}, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
107+
canvas2, err := rasterizer.Draw(&stage_model, rasterizer.RasterizerConfig{RenderLabels: true, Rotation: rotation2, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
119108
if err != nil {
120109
log.Fatal(err)
121110
}
122-
// canvas2.SaveAsPNG(buf2)
123111
rasterizer.SaveCanvasAsPNGFile("front.png", canvas2)
124112

125-
// eg := errgroup.Group{}
126-
127-
// for range 2 {
128-
// eg.Go(func() error {
129-
// rasterizer.SaveCanvasAsPNGFile()
130-
// })
131-
// }
132-
133-
// wg.Wait()
134-
135113
pprof.StopCPUProfile()
136114

137115
runtime.GC() // Get up-to-date statistics
@@ -141,26 +119,3 @@ func main() {
141119

142120
f.Close()
143121
}
144-
145-
// func main() {
146-
// // fmt.Printf("%s", rasterizer.DrawLabel(0, 0))
147-
// // rasterizer.InitFace()
148-
149-
// // dst := image.NewNRGBA(image.Rect(0, 0, 110, 50))
150-
151-
// // fmt.Println(rasterizer.DrawLabelBox(dst, 0, 0, "Lgtm rtfm\nexcept you"))
152-
153-
// // f, err := os.Create("out.png")
154-
// // if err != nil {
155-
// // log.Fatalf("failed to create file: %v", err)
156-
// // }
157-
// // defer f.Close()
158-
159-
// // if err := png.Encode(f, dst); err != nil {
160-
// // log.Fatalf("failed to encode image: %v", err)
161-
// // }
162-
// err := rasterizer.DrawLabel(0, 0, "Lgtm rtfm\nexcept you")
163-
// if err != nil {
164-
// log.Fatal(err)
165-
// }
166-
// }

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/Patch2PDF/Stagemodel-Rasterizer
33
go 1.25.6
44

55
require (
6-
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1
7-
github.com/Patch2PDF/GDTF-Parser v0.3.0
8-
github.com/Patch2PDF/MVR-Parser v0.2.0
6+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.1.0
7+
github.com/Patch2PDF/GDTF-Parser v0.4.0
8+
github.com/Patch2PDF/MVR-Parser v0.3.0
99
)
1010

1111
require golang.org/x/text v0.34.0 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1 h1:xc6xxlDRv9s19um206MW6lYsZU7sXOfHgROuo7PxTZg=
2-
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1/go.mod h1:zAcGHlYdE75hdFo624nQfQHTzw9+NfPJT8Eo2mB1lI8=
3-
github.com/Patch2PDF/GDTF-Parser v0.3.0 h1:aUPiTMJrlNW06nMdzxbRuqU4ZVsrskC14ZzKN7gsUz0=
4-
github.com/Patch2PDF/GDTF-Parser v0.3.0/go.mod h1:4NWUS8fNAQJjQetvlZvrVE/lv2oFaEkuPUKc/r/TugE=
5-
github.com/Patch2PDF/MVR-Parser v0.2.0 h1:DeSFvosI2JdgoXJu8BADzngRgfXQN7sQkawg/zdzfrs=
6-
github.com/Patch2PDF/MVR-Parser v0.2.0/go.mod h1:Zrm84J9+nE/e0F8i6d94Am4u4xbGt8AgVa2JNkLcCNg=
1+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.1.0 h1:Do1+QFw7sNf6B1lE8T9rokVGQQ3I1EhYqK7OPL4ep1Q=
2+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.1.0/go.mod h1:zAcGHlYdE75hdFo624nQfQHTzw9+NfPJT8Eo2mB1lI8=
3+
github.com/Patch2PDF/GDTF-Parser v0.4.0 h1:ZdZDxIjm4K63tTVtf48K0sYJCyppuID1m4P2b4QfvM8=
4+
github.com/Patch2PDF/GDTF-Parser v0.4.0/go.mod h1:i3hZmZ2wIJ294MllgqQ+wQn4RtuYIWL1KLSn9Gseqdw=
5+
github.com/Patch2PDF/MVR-Parser v0.3.0 h1:bdvRFxkTc0oK2uxo7o0SK0JMtcdJu+/e2nsKNmODE80=
6+
github.com/Patch2PDF/MVR-Parser v0.3.0/go.mod h1:DwJgsZcqTyn+eD3KG6OVUwHvpK56HjXFqGdI/UY4z+E=
77
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
88
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
99
github.com/qmuntal/gltf v0.28.0 h1:C4A1temWMPtcI2+qNfpfRq8FEJxoBGUN3ZZM8BCc+xU=

model_manipulation.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ func calculateStageModelMinAndMax(stageModel *StageModel) (min MeshTypes.Vector,
6969
return min, max
7070
}
7171

72-
func normalizeAndRotateStageModel(canvas *Canvas, stageModel *StageModel, rotation Rotation) {
72+
func normalizeAndRotateStageModel(canvas *Canvas, stageModel *StageModel, rotationMatrix MeshTypes.Matrix) {
7373
// rotate
74-
rotationMatrix := generateRotationMatrix(rotation.Alpha, rotation.Beta, rotation.Gamma)
7574
rotateAndTranslateStageModel(stageModel, rotationMatrix)
7675

7776
// get bounding box

rasterizer.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import (
1111
MVRTypes "github.com/Patch2PDF/MVR-Parser/pkg/types"
1212
)
1313

14-
type Rotation struct {
15-
Alpha float64
16-
Beta float64
17-
Gamma float64
18-
}
19-
2014
type boundingBox struct {
2115
left int
2216
top int

0 commit comments

Comments
 (0)