# Voxelize

Hi,

I am new to Open Cascade (OCC) and would be very grateful for your help and advice.

One of my student project tasks is to convert data from a "geometrical" (preferable IGES; maybe STL and STEP, because they are supported from OCC, too) into a "bitmapped" representation. This means, to VOXELIZE the data.

Right now, I have two possibilities in mind but don?t know if and how I can employ Open Cascade to solve them.

1) Scan line algorithm
2. Calculate intersection points between IGES data surface and scan lines
3. Rasterize between intersection points in order to mark a voxel as inside our outside

Questions to the 2. step in this approach:
* How to calculate intersections? GeomAPI_IntCS returns intersections between a curve and a surface. How to convert the imported IGES data (probably an instance of TopoDS_Shape ?) into the required Geom_Surface instance?
* Is there a better way of calculating the intersections?

2) Tessellate with OCC and use already implemented scan line algorithm (with VTK)
2. Tessellate/triangulate IGES data surface into CLOSED polygonal/triangular mesh
3. Export polygonal (triangular) mesh and apply scan line algorithm by means of VTK

Questions to the 2. step in this approach:
* Is there a way to tessellate/triangulate the surface and get a closed polygonal mesh? (The VTK scan line algorithm requires a closed mesh.)

Which way is the one to go? Or could you suggest me another/better solution?

Best regards,
Reinhold I have the same quesion! esspacialy question 2 Hi,

I use IntCurvesFace_ShapeIntersector to calculate the intersections between the scanlines and the shape. The scanlines are on a grid in an area a bit larger than the shapes bounding box. That means all voxels from the start to the scanline to the first intersection are outside, then inside to the next and so on. If you have an odd number of intersections on a scanline then the line is just touching somewhere. Then you need additional checks with BRepClass3d_SolidClassifier. The simple approach of using BRepClass3d_SolidClassifier throughout is too slow.

Cheers, Torsten
{"ft_lang_label":"__label__en","ft_lang_prob":0.90017545,"math_prob":0.8361051,"size":2190,"snap":"2021-43-2021-49","text_gpt3_token_len":546,"char_repetition_ratio":0.11573651,"word_repetition_ratio":0.033613447,"special_character_ratio":0.22648402,"punctuation_ratio":0.11325301,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9602177,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-28T14:06:44Z\",\"WARC-Record-ID\":\"<urn:uuid:c37d2a7b-fbae-45a1-a8e2-428dde0cb53d>\",\"Content-Length\":\"29167\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9a241a26-62b4-42f0-96fb-a29d448dd1dd>\",\"WARC-Concurrent-To\":\"<urn:uuid:30af3033-5618-40fc-9b5b-8515b72359d2>\",\"WARC-IP-Address\":\"91.121.49.128\",\"WARC-Target-URI\":\"https://dev.opencascade.org/content/voxelize\",\"WARC-Payload-Digest\":\"sha1:SMLATJSQXH6VR2ILOYHNBBQMSDPJHAEB\",\"WARC-Block-Digest\":\"sha1:WGNZBLNO24C3SIXNRAJZQE77DCOJZIXD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588341.58_warc_CC-MAIN-20211028131628-20211028161628-00092.warc.gz\"}"}