@@ -33,28 +33,96 @@ public enum MeshGranularity
3333 [ StructLayout ( LayoutKind . Sequential ) ]
3434 public struct MeshExtractOptions
3535 {
36+ public MeshExtractOptions ( PlateauVector3d referencePoint , CoordinateSystem meshAxes , MeshGranularity meshGranularity , uint minLOD , uint maxLOD , bool exportAppearance , int gridCountOfSide , float unitScale , int coordinateZoneID , bool excludeCityObjectOutsideExtent , bool excludePolygonsOutsideExtent , bool enableTexturePacking , uint texturePackingResolution , Extent extent )
37+ {
38+ this . ReferencePoint = referencePoint ;
39+ this . MeshAxes = meshAxes ;
40+ this . MeshGranularity = meshGranularity ;
41+ this . ExportAppearance = exportAppearance ;
42+ this . CoordinateZoneID = coordinateZoneID ;
43+ this . ExcludeCityObjectOutsideExtent = excludeCityObjectOutsideExtent ;
44+ this . ExcludePolygonsOutsideExtent = excludePolygonsOutsideExtent ;
45+ this . Extent = extent ;
46+ this . minLOD = minLOD ;
47+ this . maxLOD = maxLOD ;
48+ this . unitScale = unitScale ;
49+ this . gridCountOfSide = gridCountOfSide ;
50+ this . EnableTexturePacking = enableTexturePacking ;
51+ this . TexturePackingResolution = texturePackingResolution ;
52+
53+ // 上で全てのメンバー変数を設定できてますが、バリデーションをするため念のためメソッドやプロパティも呼びます。
54+ SetLODRange ( minLOD , maxLOD ) ;
55+ UnitScale = unitScale ;
56+ GridCountOfSide = gridCountOfSide ;
57+ }
58+
3659 /// <summary> 直交座標系における座標で、3Dモデルの原点をどこに設定するかです。 </summary>
37- public PlateauVector3d ReferencePoint ;
60+ public PlateauVector3d ReferencePoint ;
61+
3862 /// <summary> 座標軸の向きです。 </summary>
3963 public CoordinateSystem MeshAxes ;
64+
4065 /// <summary> メッシュ結合の粒度です。 </summary>
4166 public MeshGranularity MeshGranularity ;
67+
4268 /// <summary> 出力するLODの範囲上限です。 </summary>
43- public uint MaxLOD ;
69+ private uint maxLOD ;
70+
4471 /// <summary> 出力するLODの範囲の下限です。 </summary>
45- public uint MinLOD ;
72+ private uint minLOD ;
73+
74+ public void SetLODRange ( uint minLODArg , uint maxLODArg )
75+ {
76+ if ( minLODArg > maxLODArg )
77+ {
78+ throw new ArgumentException ( $ "Invalid LOD Range: { nameof ( this . minLOD ) } should not greater than { nameof ( this . maxLOD ) } .") ;
79+ }
80+ this . maxLOD = maxLODArg ;
81+ this . minLOD = minLODArg ;
82+ }
83+
4684 /// <summary> テクスチャを含めるかどうかです。 </summary>
4785 [ MarshalAs ( UnmanagedType . U1 ) ] public bool ExportAppearance ;
86+
4887 /// <summary> メッシュ結合の粒度が「都市モデル単位」の時のみ有効で、この設定では都市を格子状のグリッドに分割するので、その1辺あたりの分割数(縦の数 = 横の数)です。</summary>
49- public int GridCountOfSide ;
88+ private int gridCountOfSide ;
89+
90+ public int GridCountOfSide
91+ {
92+ get => this . gridCountOfSide ;
93+ set
94+ {
95+ if ( value <= 0 || value > 999 ) // 999の理由は、普通に考えればこれ以上に分割する理由はないだろうという大雑把な数。
96+ {
97+ throw new Exception ( $ "Invalid number : { nameof ( this . gridCountOfSide ) } should be positive number and below 1000.") ;
98+ }
99+ this . gridCountOfSide = value ;
100+ }
101+ }
102+
50103 /// <summary> 大きさ補正です。 </summary>
51- public float UnitScale ;
104+ private float unitScale ;
105+
106+ public float UnitScale
107+ {
108+ get => this . unitScale ;
109+ set
110+ {
111+ if ( Math . Abs ( this . UnitScale ) < 0.00000001 )
112+ {
113+ throw new ArgumentException ( $ "Validate failed : { nameof ( this . UnitScale ) } is too small.") ;
114+ }
115+ this . unitScale = value ;
116+ }
117+ }
118+
52119 /// <summary>
53120 /// 国土交通省が規定する、日本の平面直角座標系の基準点の番号です。
54121 /// 詳しくは次の国土地理院のサイトをご覧ください。
55122 /// <see href="https://www.gsi.go.jp/sokuchikijun/jpc.html"/>
56123 /// </summary>
57124 public int CoordinateZoneID ;
125+
58126 /// <summary>
59127 /// 範囲外の3Dモデルを出力から除外するための、2つの方法のうち1つを有効にするかどうかを bool で指定します。
60128 /// その方法とは、都市オブジェクトの最初の頂点の位置が範囲外のとき、そのオブジェクトはすべて範囲外とみなして出力から除外します。
@@ -63,61 +131,34 @@ public struct MeshExtractOptions
63131 /// したがって、この値は建物では true, 地形では false となるべきです。
64132 /// </summary>
65133 [ MarshalAs ( UnmanagedType . U1 ) ] public bool ExcludeCityObjectOutsideExtent ;
134+
66135 /// <summary>
67136 /// 範囲外の3Dモデルを出力から除外するための、2つの方法のうち1つを有効にするかどうかを bool で指定します。
68137 /// その方法とは、メッシュ操作によって、範囲外に存在するポリゴンを除外します。
69138 /// この方法であれば 10km×10km の地形など巨大なオブジェクトにも対応できます。
70139 /// </summary>
71140 [ MarshalAs ( UnmanagedType . U1 ) ] public bool ExcludePolygonsOutsideExtent ;
72-
141+
73142 /// <summary>
74143 /// テクスチャ結合(複数のテクスチャ画像を結合する機能)を有効にするかどうかを bool で指定します。
75144 /// </summary>
76145 [ MarshalAs ( UnmanagedType . U1 ) ] public bool EnableTexturePacking ;
77146
78147 /// <summary> テクスチャ結合時の結合先のテクスチャ画像の解像度(縦:texture_packing_resolution x 横:texture_packing_resolution) </summary>
79148 public uint TexturePackingResolution ;
80-
149+
81150 /// <summary> 対象範囲を緯度・経度・高さで指定します。 </summary>
82151 public Extent Extent ;
83-
152+
84153 /// <summary> デフォルト値の設定を返します。 </summary>
85- public static MeshExtractOptions DefaultValue ( )
154+ internal static MeshExtractOptions DefaultValue ( )
86155 {
87156 var apiResult = NativeMethods . plateau_mesh_extract_options_default_value ( out var defaultOptions ) ;
88157 DLLUtil . CheckDllError ( apiResult ) ;
89158 return defaultOptions ;
90159 }
91160
92- /// <summary>
93- /// 設定の値が正常なら true, 異常な点があれば false を返します。
94- /// <param name="failureMessage">異常な点があれば、それを説明する文字列が入ります。正常なら空文字列になります。</param>
95- /// </summary>
96- public bool Validate ( out string failureMessage )
97- {
98- failureMessage = "" ;
99- if ( this . MinLOD > this . MaxLOD )
100- {
101- failureMessage = $ "Validate failed : { nameof ( this . MinLOD ) } should not greater than { nameof ( this . MaxLOD ) } .";
102- return false ;
103- }
104-
105- if ( this . GridCountOfSide <= 0 )
106- {
107- failureMessage = $ "Validate failed : { nameof ( this . GridCountOfSide ) } should be positive number.";
108- return false ;
109- }
110-
111- if ( Math . Abs ( this . UnitScale ) < 0.00000001 )
112- {
113- failureMessage = $ "Validate failed : { nameof ( this . UnitScale ) } is too small.";
114- return false ;
115- }
116-
117- return true ;
118- }
119-
120- private static class NativeMethods
161+ private static class NativeMethods
121162 {
122163 [ DllImport ( DLLUtil . DllName ) ]
123164 internal static extern APIResult plateau_mesh_extract_options_default_value (
0 commit comments