gecos-lab / PZero

GNU Affero General Public License v3.0
22 stars 2 forks source link

new Gocad ASCII parser? #57

Open andrea-bistacchi opened 9 months ago

andrea-bistacchi commented 9 months ago

In PyVista a new Gocad ASCII parser is being tested. Maybe we can improve our parser using similar concepts. However we must check whether the methods used in PyVista work for multiple objects of heterogeneous type.

https://github.com/pyvista/pyvista/discussions/4903

gbene commented 1 week ago

I think in general with our parsers (also shp2vtk) is that they can be very useful but are buried in PZero's codebase. I think that it is a bit of a missed chance not to provide a simple gocadascii parser package as you suggested more than 4 years ago https://github.com/pyvista/pyvista/discussions/4903#discussioncomment-7021300 (how time flies!!). Now that we have gecos-lab, it would be also nice to populate it with simple but useful packages such as these!

@andrea-bistacchi If you want I can take a look at the gocad parser and see if it can be made in a more general package.

andrea-bistacchi commented 1 week ago

@gbene : I would focus on more structural stuff at the moment. The gocad parser we have now, even if its implementation is rather naive, works well. I've just imported around 1000 entities from a large project in a few seconds.

gbene commented 1 week ago

yes I know! That's why I think it is important to make it more accessible to all as a standalone package! Even if structural stuff needs to be done let's not forget about this opportunity!

andrea-bistacchi commented 1 week ago

OK, but for this we first need to have a prototype for all IO functions, with file interaction dialogues moved outside of the IO function.

Then we need to decide what we like to do. A general parser for GOCAD? I don't think so. A GOCAD -> VTK and viceversa function? This is what we already have and it could be useful, but structuring it as an independent module will mean extra work, and I'm not sure if it will be used by somebody else.

gbene commented 1 week ago

I was thinking of a parser that exposes the gocadascii file so that the information in the ascii file can be programmatically accessed (I don't know if by "general parser" you mean this). A solid basis is already present in PZero but it needs structure so that each sections are "independent". Probably when doing the class transition of the IO functions, this structure will emerge.

andrea-bistacchi commented 1 week ago

The problem with this is that a single gocad ascii file includes many entities, of different kinds (potentially all kinds), separated by END keywords. Other keywords appear within each object, with a meaning that depends on where they appear and in which sequence.

This means that you must read the file sequentially, otherwise it would not make sense. It is a 1989 format...

So, either (i) you read the whole file, store in memory all information organized in a multitude of objects with variable structure (e.g. point sets without topology, trianulated surfaces, tetrahedral volumes, regular grids etc.), and then you can choose what to use (but at the cost of reading and storing a lot of potentially useless stuff), or (ii) you read sequentially saving (eg. as VTK) the objects you are interested in when you find them, and disregard the rest. This is what we do now.