• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 13893925923

17 Mar 2025 07:33AM UTC coverage: 76.235% (+0.02%) from 76.22%
13893925923

Pull #581

github

web-flow
Merge ea8d614e6 into 5d7d96527
Pull Request #581: Implement Material

5504 of 7921 branches covered (69.49%)

Branch coverage included in aggregate %.

36 of 40 new or added lines in 4 files covered. (90.0%)

6 existing lines in 1 file now uncovered.

21695 of 27757 relevant lines covered (78.16%)

75550.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/src/ACadSharp/Objects/Material.cs
1
using ACadSharp.Attributes;
2
using CSUtilities.Extensions;
3

4
namespace ACadSharp.Objects
5
{
6
        public enum AmbientColorMethod
7
        {
8
                Current = 0,
9
                Override = 1,
10
        }
11

12
        public enum MapSource
13
        {
14
                UseCurrentScene = 0,
15
                UseImageFile = 1,
16
        }
17

18
        public enum ProjectionMethod
19
        {
20
                None = 0,
21
                Planar = 1,
22
                Box = 2,
23
                Cylinder = 3,
24
                Sphere = 4
25
        }
26

27
        public enum TilingMethod
28
        {
29
                None = 0,
30
                Tile = 1,
31
                Crop = 2,
32
                Clamp = 3
33
        }
34

35
        [System.Flags]
36
        public enum AutoTransformMethodFlags
37
        {
38
                /// <summary>
39
                /// None.
40
                /// </summary>
41
                None = 0,
42
                /// <summary>
43
                /// No auto transform.
44
                /// </summary>
45
                NoAutoTransform = 1,
46
                /// <summary>
47
                /// Scale mapper to current entity extents; translate mapper to entity origin.
48
                /// </summary>
49
                ScaleMapper = 2,
50
                /// <summary>
51
                /// Include current block transform in mapper transform.
52
                /// </summary>
53
                IncludeCurrentBlock = 4
54
        }
55

56
        /// <summary>
57
        /// Represents a <see cref="Material"/> object
58
        /// </summary>
59
        /// <remarks>
60
        /// Object name <see cref="DxfFileToken.ObjectMaterial"/> <br/>
61
        /// Dxf class name <see cref="DxfSubclassMarker.Material"/>
62
        /// </remarks>
63
        [DxfName(DxfFileToken.ObjectMaterial)]
64
        [DxfSubClass(DxfSubclassMarker.Material)]
65
        public class Material : NonGraphicalObject
66
        {
67
                /// <inheritdoc/>
68
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
69

70
                /// <inheritdoc/>
71
                public override string ObjectName => DxfFileToken.ObjectMaterial;
×
72

73
                /// <inheritdoc/>
74
                public override string SubclassMarker => DxfSubclassMarker.Material;
29,298✔
75

76
                /// <summary>
77
                /// Material name.
78
                /// </summary>
79
                [DxfCodeValue(1)]
80
                public override string Name
81
                {
82
                        get
83
                        {
1,164✔
84
                                return base.Name;
1,164✔
85
                        }
1,164✔
86
                        set
87
                        {
582✔
88
                                base.Name = value;
582✔
89
                        }
582✔
90
                }
91

92
                /// <summary>
93
                /// Material description.
94
                /// </summary>
95
                [DxfCodeValue(2)]
NEW
96
                public string Description { get; set; }
×
97

98
                /// <summary>
99
                /// Ambient color method.
100
                /// </summary>
101
                [DxfCodeValue(70)]
102
                public AmbientColorMethod AmbientColorMethod { get; set; } = AmbientColorMethod.Current;
583✔
103

104
                /// <summary>
105
                /// Ambient color factor.
106
                /// </summary>
107
                /// <value>
108
                /// valid range is 0.0 to 1.0)
109
                /// </value>
110
                [DxfCodeValue(40)]
111
                public double AmbientColorFactor
112
                {
NEW
113
                        get { return this._ambientColorFactor; }
×
114
                        set
115
                        {
1✔
116
                                ObjectExtensions.InRange(value, 0, 1, $"{nameof(AmbientColorFactor)} valid values are from 0.0 to 1.0");
1✔
117
                                this._ambientColorFactor = value;
1✔
118
                        }
1✔
119
                }
120

121
                private double _ambientColorFactor = 1.0;
583✔
122

123
                /// <summary>
124
                /// Ambient color value.
125
                /// </summary>
126
                [DxfCodeValue(90)]
127
                public Color AmbientColor { get; set; }
1✔
128

129
                /// <summary>
130
                /// Ambient color method.
131
                /// </summary>
132
                [DxfCodeValue(71)]
133
                public AmbientColorMethod DiffuseColorMethod { get; set; } = AmbientColorMethod.Current;
583✔
134

135
                /// <summary>
136
                /// Diffuse color factor.
137
                /// </summary>
138
                /// <value>
139
                /// valid range is 0.0 to 1.0)
140
                /// </value>
141
                [DxfCodeValue(41)]
142
                public double DiffuseColorFactor
143
                {
NEW
144
                        get { return this._diffuseColorFactor; }
×
145
                        set
146
                        {
1✔
147
                                ObjectExtensions.InRange(value, 0, 1, $"{nameof(DiffuseColorFactor)} valid values are from 0.0 to 1.0");
1✔
148
                                this._diffuseColorFactor = value;
1✔
149
                        }
1✔
150
                }
151

152
                private double _diffuseColorFactor = 1.0;
583✔
153

154
                /// <summary>
155
                /// Diffuse color value.
156
                /// </summary>
157
                [DxfCodeValue(91)]
158
                public Color DiffuseColor { get; set; }
1✔
159

160
                /// <summary>
161
                /// Diffuse map blend factor.
162
                /// </summary>
163
                [DxfCodeValue(42)]
164
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
584✔
165

166
                /// <summary>
167
                /// Diffuse map source.
168
                /// </summary>
169
                [DxfCodeValue(72)]
170
                public MapSource DiffuseMapSource { get; set; } = MapSource.UseImageFile;
583✔
171

172
                /// <summary>
173
                /// Diffuse map file name.
174
                /// </summary>
175
                /// <remarks>
176
                /// null file name specifies no map.
177
                /// </remarks>
178
                [DxfCodeValue(3)]
NEW
179
                public string DiffuseMapRileName { get; set; }
×
180

181
                /// <summary>
182
                /// Projection method of diffuse map mapper.
183
                /// </summary>
184
                [DxfCodeValue(73)]
185
                public ProjectionMethod ProjectionMethod { get; set; } = ProjectionMethod.Planar;
583✔
186

187
                /// <summary>
188
                /// Tiling method of diffuse map mapper.
189
                /// </summary>
190
                [DxfCodeValue(74)]
191
                public TilingMethod DiffuseMapper { get; set; } = TilingMethod.Tile;
583✔
192

193
                /// <summary>
194
                /// Auto transform method of diffuse map mapper.
195
                /// </summary>
196
                [DxfCodeValue(75)]
197
                public AutoTransformMethodFlags AutoTransformDiffuse { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
583✔
198

199
                //43
200

201
                //Transform matrix of diffuse map mapper(16 reals; row major format; default = identity matrix)
202

203
                //44
204

205
                //Specular gloss factor(real, default = 0.5)
206

207
                //76
208

209
                //Specular color method(default = 0) :
210

211
                //0 = Use current color
212

213
                //1 = Override current color
214

215
                //45
216

217
                //Specular color factor(real, default = 1.0; valid range is 0.0 to 1.0)
218

219
                //92
220

221
                //Specular color value(unsigned 32-bit integer representing an AcCmEntityColor)
222

223
                //46
224

225
                //Specular map blend factor(real; default = 1.0)
226

227
                //77
228

229
                //Specular map source(default = 1) :
230

231
                //0 = Use current scene
232

233
                //1 = Use image file(specified by file name; null file name specifies no map)
234

235
                //4
236

237
                //Specular map file name(string; default = null string)
238

239
                //78
240

241
                //Projection method of specular map mapper(default = 1):
242

243
                //1 = Planar
244

245
                //2 = Box
246

247
                //3 = Cylinder
248

249
                //4 = Sphere
250

251
                //79
252

253
                //Tiling method of specular map mapper(default = 1):
254

255
                //1 = Tile
256

257
                //2 = Crop
258

259
                //3 = Clamp
260

261
                //170
262

263
                //Auto transform method of specular map mapper(bitset; default = 1):
264

265
                //1 = No auto transform
266

267
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
268

269
                //4 = Include current block transform in mapper transform
270

271
                //47
272

273
                //Transform matrix of specular map mapper(16 reals; row major format; default = identity matrix)
274

275
                //48
276

277
                //Blend factor of reflection map(real, default = 1.0)
278

279
                //171
280

281
                //Reflection map source(default = 1) :
282

283
                //0 = Use current scene
284

285
                //1 = Use image file(specified by file name; null file name specifies no map)
286

287
                //6
288

289
                //Reflection map file name(string; default = null string)
290

291
                //172
292

293
                //Projection method of reflection map mapper(default = 1):
294

295
                //1 = Planar
296

297
                //2 = Box
298

299
                //3 = Cylinder
300

301
                //4 = Sphere
302

303
                //173
304

305
                //Tiling method of reflection map mapper(default = 1):
306

307
                //1 = Tile
308

309
                //2 = Crop
310

311
                //3 = Clamp
312

313
                //174
314

315
                //Auto transform method of reflection map mapper(bitset; default = 1):
316

317
                //1 = No auto transform
318

319
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
320

321
                //4 = Include current block transform in mapper transform
322

323
                //49
324

325
                //Transform matrix of reflection map mapper(16 reals; row major format; default = identity matrix)
326

327
                //140
328

329
                //Opacity percent(real; default = 1.0)
330

331
                //141
332

333
                //Blend factor of opacity map(real; default = 1.0)
334

335
                //175
336

337
                //Opacity map source(default = 1) :
338

339
                //0 = Use current scene
340

341
                //1 = Use image file(specified by file name; null file name specifies no map)
342

343
                //7
344

345
                //Opacity map file name(string; default = null string)
346

347
                //176
348

349
                //Projection method of opacity map mapper(default = 1):
350

351
                //1 = Planar
352

353
                //2 = Box
354

355
                //3 = Cylinder
356

357
                //4 = Sphere
358

359
                //177
360

361
                //Tiling method of opacity map mapper(default = 1):
362

363
                //1 = Tile
364

365
                //2 = Crop
366

367
                //3 = Clamp
368

369
                //178
370

371
                //Auto transform method of opacity map mapper(bitset; default = 1):
372

373
                //1 = No auto transform
374

375
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
376

377
                //4 = Include current block transform in mapper transform
378

379
                //142
380

381
                //Transform matrix of opacity map mapper(16 reals; row major format; default = identity matrix)
382

383
                //143
384

385
                //Blend factor of bump map(real; default = 1.0)
386

387
                //179
388

389
                //Bump map source(default = 1) :
390

391
                //0 = Use current scene
392

393
                //1 = Use image file(specified by file name; null file name specifies no map)
394

395
                //8
396

397
                //Bump map file name(string; default = null string)
398

399
                //270
400

401
                //Projection method of bump map mapper(default = 1):
402

403
                //1 = Planar
404

405
                //2 = Box
406

407
                //3 = Cylinder
408

409
                //4 = Sphere
410

411
                //271
412

413
                //Tiling method of bump map mapper(default = 1):
414

415
                //1 = Tile
416

417
                //2 = Crop
418

419
                //3 = Clamp
420

421
                //272
422

423
                //Auto transform method of bump map mapper(bitset; default = 1):
424

425
                //1 = No auto transform
426

427
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
428

429
                //4 = Include current block transform in mapper transform
430

431
                //144
432

433
                //Transform matrix of bump map mapper(16 reals; row major format; default = identity matrix)
434

435
                //145
436

437
                //Refraction index(real; default = 1.0)
438

439
                //146
440

441
                //Blend factor of refraction map(real; default = 1.0)
442

443
                //273
444

445
                //Refraction map source(default = 1) :
446

447
                //0 = Use current scene
448

449
                //1 = Use image file(specified by file name; null file name specifies no map)
450

451
                //9
452

453
                //Refraction map file name(string; default = null string)
454

455
                //274
456

457
                //Projection method of refraction map mapper(default = 1):
458

459
                //1 = Planar
460

461
                //2 = Box
462

463
                //3 = Cylinder
464

465
                //4 = Sphere
466

467
                //275
468

469
                //Tiling method of refraction map mapper(default = 1):
470

471
                //1 = Tile
472

473
                //2 = Crop
474

475
                //3 = Clamp
476

477
                //276
478

479
                //Auto transform method of refraction map mapper(bitset; default = 1):
480

481
                //1 = No auto transform
482

483
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
484

485
                //4 = Include current block transform in mapper transform
486

487
                //147
488

489
                //Transform matrix of refraction map mapper(16 reals; row major format; default = identity matrix)
490

491
                //460
492

493
                //Color Bleed Scale
494
                //461        Indirect Dump Scale
495
                //462        Reflectance Scale
496
                //463
497

498
                //Transmittance Scale
499
                //290        Two-sided Material
500
                //464        Luminance
501
                //270        Luminance Mode
502
                //271
503

504
                //Normal Map Method
505
                //465        Normal Map Strength
506
                //42        Normal Map Blend Factor
507
                //72
508

509
                //Normal Map Source
510
                //3        Normal Map Source File Name
511
                //73        Normal Mapper Projection
512
                //74        Normal Mapper Tiling
513
                //75        Normal Mapper Auto Transform
514
                //43        Normal Mapper Transform
515
                //293        Materials Anonymous
516
                //272        Global Illumination Mode
517
                //273        Final Gather Mode
518
                //300
519

520
                //GenProcName
521
                //291        GenProcValBool
522
                //271        GenProcValInt
523
                //469        GenProcValReal
524
                //301        GenProcValText
525
                //292        GenProcTableEnd
526
                //62        GenProcValColorIndex
527
                //420        GenProcValColorRGB
528
                //430        GenProcValColorName
529
                //270        Map UTile
530
                //148        Translucence
531
                //90        Self-Illuminaton
532
                //468        Reflectivity
533
                //93        Illumination Model
534
                //94        Channel Flags
535
        }
536
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc