Tesselation/CGR Details from CATPart_CATIA_API - api

I need to read the tessellation/cgr/visualisation details from a CATIA V5R18 Part file using CATIA V5R18 API.
Visualisation details such as:
Number of Vertices
Number of Triangles
Number of Strips
Number of Fans
Number of Normal
Bounding Sphere Centre and Radius
These details I have read from .cgr files using CAT3DRep/CATRep/CATSurfacicRep, but I am not able to read the same for .CATPart files.
From .CATPart with the help of CATIVisu I got CAT3DBagRep type, when I queried from PartFeatures. But to get Visualisation details I need CATSurfacicRep.
What interface should I query and from where should I query?

I am not sure about R18 but for R22 and R23 if you have the CAA documentation there is an example located at: C:\Program Files\Dassault Systemes\B23\CAADoc\CAATessellation.edu.
This example code has everything you need to get the tessellation data except normals and bounding spheres. I used this example code when I was teaching myself how to make a tessellated nurbs surface and it was quite useful for testing.

Related

Using MDAnalysis to extract coordinates in an array from pdb

I have a pdb file that is a subset of a much larger system. This pdb is special because I have some vectors based on this file's coordinate system. I want to draw these vectors and the basis vector of that system onto the pdb. Eventually I would like to visualize the vector and basis vectors as it moves through some MD simulation where I an update the vector position based on the trajectory over time.
To start, I would like to read a pdb that has coordinates that define the basis vectors that further define the other vectors I want to visualize. Right now I'm using this class in MDAnalysis:
https://docs.mdanalysis.org/1.0.0/_modules/MDAnalysis/coordinates/PDB.html#PDBReader
molecule=mda.coordinates.PDB.PDBReader('molecule.pdb')
This works and it reads the pdb just fine, but returns with this variable type
coordinates.PDB.Reader
I suppose this isn't a surprise, but I want to be able to print this variable and get some array of coordinate positions and atom types. I'd love to see the bonds as well but that's not necessary. Now when I print I get
<PDBReader molecule.pdb with 1 frames of 60 atoms>
I want something that would look like
[atomtype1,x1,y1,z1]...[atomtypen,xn,yn,zn]
Thank you,
Loading data: Universe
To get the coordinates in MDAnalysis you first load a Universe (you don't normally use the coordinate readers directly):
import MDAnalysis as mda
u = mda.Universe('molecule.pdb')
The Universe contains "topology" (atom types, bonds if available, etc) and the "trajectory" (i.e., coordinates).
Accessing per-atom data: Universe.atoms
All the atoms are stored in u.atoms (they form an AtomGroup). All information about the atoms is available from an AtomGroup. For example, all positions are available as a numpy array with
u.atoms.positions
The names are
u.atoms.names
and there are many more attributes. (The same works for residues: u.residues or u.atoms.residues gives the residues. You can also slice/index an AtomGroup to get a new AtomGroup. For example, the residues that belong to the first 20 atoms are u.atoms[:20].residues... AtomGroups are the key to working with MDAnalysis.)
Extracting atom names and positions
To build the list that you asked for:
names_positions = [[at] + list(pos) for at, pos in zip(u.atoms.names, u.atoms.positions)]
For example, with the test file PDB that is included with the MDAnalysisTests package:
import MDAnalysis as mda
from MDAnalysisTests.datafiles import PDB
u = mda.Universe(PDB)
names_positions = [[at] + list(pos) for at, pos in zip(u.atoms.names, u.atoms.positions)]
# show the first three entries
print(names_positions[:3])
gives
[['N', 52.017, 43.56, 31.555], ['H1', 51.188, 44.112, 31.722], ['H2', 51.551, 42.828, 31.039]]
Learning more...
For a rapid introduction to MDAnalysis have a look at the Quickstart Guide, which explains most of these things in more detail. It also tells you how to select specific atoms and form new AtomGroups.
Then you can have a look at the rest of the User Guide.
Bonds are a bit more tricky (you can get them with u.atoms.bonds but if you want to use them you have to learn more about how MDAnalysis represents topologies — I'd suggest you start by asking on user mailing list, see participating in MDAnalysis because this is where MDAnalysis developers primarily answer questions.)

Generate OPEN surface mesh from a set of 3D points

I have a set of points on an OPEN surface in 3D space.
I have identified a subset of points which lay on the boundary.
I mean to generate a triangulation of those points, which gives me an open surface and keeps my selected points on the boundary.
All references I found deal with (sometimes?) closed surfaces, e.g., CGAL.
See examples below.
In addition, some CGAL algorithms require oriented normals at each point, which I do not have.
Is there an available algorithm and code for this? (either CGAL Advancing_front_surface_reconstruction, properly handled, or any other)
See also this and this.
Example 1
I compiled and ran example reconstruction_surface_mesh.cpp from examples/Advancing_front_surface_reconstruction, out-of-the box (which uses file half.xyz as input for data points), and I obtained a closed surface:
I would like to get rid of the few triangles that close the surface.
I tried adding an extra point at the end of half.xyz, and I got
which is an open surface.
So far, with what I tested, I do not know:
How to indicate an open surface.
How to indicate which vertices lay at the boundary.
If this is a non-empty set (and it should have at least three vertices) this would imply an open surface.
Ideally, one would have a workflow which works without manual intervention.
Example 2
I compiled and ran example boundaries.cpp, out-of-the box (which also uses file half.xyz as input for data points).
The output is:
0 outliers:
Boundaries:
boundary
0.178269 0.438589 0.129521
0.0795598 0.419465 0.244812
0.0549683 0.377617 0.3119
-0.0295721 0.360972 0.329075
-0.111332 0.334417 0.342617
-0.186667 0.2953 0.346683
-0.2719 0.16555 0.375017
-0.336304 0.117058 0.339323
-0.393517 0.0775 0.285917
-0.421419 -0.126854 0.215271
-0.395217 -0.214417 0.20015
-0.354783 -0.2953 0.170767
-0.237067 -0.395867 0.172233
-0.178246 -0.438588 0.129553
0.0227767 -0.4873 0.0700833
0.220338 -0.438589 -7.23321e-06
0.293 -0.395867 0
0.36025 -0.334417 0
0.418077 -0.258382 6.0303e-05
0.46025 -0.17265 0
0.484417 -0.0425167 -0.0763333
0.485067 0.03875 -0.0782667
0.471547 0.117058 -0.076827
0.44605 0.197567 -0.0700833
0.4092 0.27125 -0.0433167
0.364885 0.329645 0
0.313633 0.377617 0.0441167
0.2509 0.41425 0.0879333
I did not find how to use this for
automatically removing triangles which would make my target boundary vertices not laying at the boundary.
Moreover, the output seems to be the list of boundary points, without the "spurious" triangles (I am not sure). I would like to specify this list.
The CGAL advancing front reconstruction algorithm does generate open surfaces in general.

GIS data files converting each address to lat/lon in dbf shape data

I need Lat/LON from GIS data
I have data files from
http://www.mngeo.state.mn.us/chouse/land_own_property.html
given in the format of
.dbf, .prj, .sbn, .sbx, .shp, and .shx
in the .dbf I see
PIN, Shape_area, Shape_len
PARC_CODE Parcel Polygon to Parcel Point numeric 2
and PIN Relationship Code
and in the .prj
PROJCS["NAD_1983_UTM_Zone_15N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
I also know the polygon points for each county
polygons points
Anoka 129139 129138
Carver 38134 38133
Dakota 135925 150294
Hennepin 422976 446623
Ramsey 149169 168233
Scott 55191 55191
Washington 98915 103915
and I know the bounding coordinates
-94.012
-92.732
45.415
44.471
there seems to be tons of software applications for GIS
http://en.wikipedia.org/wiki/List_of_geographic_information_systems_software
but what do I need to do?
I want the lat, lon of every house
Is there a library that will do this for me?
What is the data I need?
I think you need to install one GIS software. You can try open-source Qgis.
Because, firstly your data is not in long/lat (geographic) coordinates. Your .prj part of the shapefile (yes, all .dbf, .prj, .sbn, .sbx, .shp, and .shx files with the same name are one shapefile for GIS) says that the data are in the projected coordinate system NAD 1983 UTM Zone 15N. So, you need to transform your data to geographic system. This you easy can do in GIS, or programmatically by proj.4 library. (In Qgis add the shapefile to the project, then select it in the table of contents, right mouse button and choose "save as...". It will ask you for the target coordinate system.) Note, that you need to decide which geographic coordinates you wish, because your data are in the North American Datum (NAD 1983), but the most common worldwide now is WGS 1984.
Secondly, in GIS you will see your data, are they really points, or maybe polygons. (In case your houses are polygons you will need to get centroids of them, in Qgis menu Vector - Geometry Tools - Polygon Centroids).
Finally, when you really have your houses as points in geographic coordinates, you can get their coordinates, for example using advices from these questions Get list of coordinates for points in a layer and How do I calculate the latitude and longitude of points using QGIS.
Besides, there is a good library to work with GIS vector data, OGR, which can be used by many programming languages.
The file extensions above show, that the files are in ESRI Shape File format. In Java you could use GeoTools libraries, to read that.
The example below shows the first lines, search Internet for a more complete example.
// init shapefile
File shpFile = new File(fileName);
if (!shpFile.exists()) {
LOGGER.fatal(fileName + " does not exist");
}
Map<String, URL> connect = new HashMap<String, URL>();
FeatureCollection collection = null;
FeatureIterator iterator = null;
try {
connect.put("url", shpFile.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(connect);
String typeName = dataStore.getTypeNames()[0];
"I want the lat, lon of every house" suggests that what you want to do is the process called geocoding. There are services you can use for that, some free (for limited uses) some not. You could start by looking at the List of geocoding systems to get an idea of where to start. I don't think you want to start by learning GIS or shapefiles, other than to extract the addresses you are trying to geocode.
You could estimate the lat/lon of each house by computing the centroid of each parcel. You could more roughly estimate the lat/lon of each house by calculating the centroid of the bounding rectangle of each parcel. Either of those would require extracting the parcel coordinates. If you are doing that for every house in Minnesota you will processing lots of data. A geocoding service would be cheaper. The Census Geocoder might help.

How does Jeff Lamarches script binds the texture to objects [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Loading model using Jeff Lamarches script
Guys this might sound very newbie question anyway i'm very new to GLKit and OpenGL
I'm using the Jeff Lamarches scipt from here (https://github.com/jlamarche/iOS-OpenGLES-Stuff) to generate Objective C header file from Blender.
Let say I've created a cube and did UV mapping in Blender using some image suppose image.png.
So basically I would like to understand where in the header the information about the mapping of the texture on the 3D model is kept ? Because I see only the vertex coordinates and normals in it.
In his examples of the MeshVertexModel is a three field array i.e.
...
{/*v:*/{-0.351562, 0.828125, -0.242188}, /*n:*/{-0.183599, 0.982971, 0.005310}, /*t:*/{0.954205, 0.958702}},
...
But all I'm getting from generated header file is in following format
...
{/*v:*/{-0.351562, 0.828125, -0.242188}, /*n:*/{-0.183599, 0.982971, 0.005310}},
...
Found that similar issue has also Wavefront export, here http://projects.blender.org/tracker/index.php?func=detail&aid=30317&group_id=9&atid=498 in 2.63 Blender.
Just replacing the uv_layer = me.uv_textures.active.data by uv_layer = me.tessface_uv_textures.active.data helped to have generated texture coordinates.
Update : For the sphere and cube the script does not work normally, i.e. for Cube it does generate no vertices and for sphere it does generate the vertice of a circle, for other complecated objectes the patch works and generates all the data correctly.

CATIA-CAA CATIVisu

Hi i need the flow to read the visualisation details from a CATIA V5R18 Part file.
Visualisation details lik,
1.No of Vertices
2.No of Triangles
3.No of Strips
4.No of Fans
5.No of Normal
6.Bouding Sphere Centre and Radius
These details i have red from .cgr files using CAT3DRep/CATRep/CATSurfacicRep...
But i am not able to read the same for .CATPart files.
From .CATPart with the help of CATIVisu i got CAT3DBagRep type When i queried from PartFeatures But to get Visualisation details i need CATSurfacicRep.
Can anyone help?
Wat Interface i should query and from where i should query?
Well, information about the mesh (triangle, strips, fans, etc) is only carried by leaf Reps, like CAT3DSurfacicRep.
For complex files like CATPart or CATProduct, where you have a hierarchy of geometries, there's also a hierarchy of Reps. CAT3DBagRep is the class that allows building this hierarchy, as it has children Reps (which can of course be also CAT3DBagReps).
One solution may be to recursively explore this Rep hierarchy from the root CAT3DBagRep you get. The method to get the children Reps of a CAT3DBagRep is:
list<CATRep> *GetChildren();
You can go down the Rep tree until you get Reps of the expected type, like CATSurfacicRep. You may find many of them depending on your model.
When retrieving the mesh coordinates, normals and bounding element, please take into account that they are given in local Rep coordinates. A CAT3DBagRep carries positioning and orientation information (used when you position CATProducts, for example). This is returned by the following CAT3DBagRep method:
const CAT4x4Matrix * GetMatrix() const;
Depending on your scenario/model, you may need to take this positioning information into account.