AddFrom3DFaces creates additional area

AddFrom3DFaces creates additional area

soonhui
Advisor Advisor
622 Views
6 Replies
Message 1 of 7

AddFrom3DFaces creates additional area

soonhui
Advisor
Advisor

Not sure whether this is related to this one, but I found that AddFrom3DFaces will create additional (unwanted) area, when you are dealing with concave faces. Here's the code to reproduce the problem. 

 

     public void FromMesh()
        {
            try
            {
                using (var ts = ActiveACADDocument.TransactionManager.StartOpenCloseTransaction())
                {
                    
                    var surfaceId2 = TinSurface.Create(ActiveACADDocument.Database, "FromMeshTest");
                    var platformSurface = ts.GetObject(surfaceId2, OpenMode.ForWrite) as TinSurface;

                    var bt = (BlockTable)ts.GetObject(ActiveACADDocument.Database.BlockTableId, OpenMode.ForRead, false);
                    var btr = (BlockTableRecord)ts.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
                   
                    var vertices = platformSurface.Vertices;
                    if (vertices.Count != 0)
                    {
                        platformSurface.DeleteVertices(vertices);
                    }
                    var faces = new ObjectIdCollection();

                    var vertex1 = new Point3d(0, 0, 0);
                    var vertex2 = new Point3d(10, 0, 0);
                    var vertex3 = new Point3d(10, 10, 0);
                    var vertex4 = new Point3d(0, 10, 0);
                    var polyMesh1 = new Face(vertex1, vertex2, vertex3, vertex4, true, true, true, true);
                    polyMesh1.SetDatabaseDefaults();
                    btr.AppendEntity(polyMesh1);
                    ts.AddNewlyCreatedDBObject(polyMesh1, true);
                    faces.Add(polyMesh1.ObjectId);

                    var vertex5 = new Point3d(5,10,0);
                    var vertex6 = new Point3d(10,10,0);
                    var vertex7 = new Point3d(10, 20, 0);
                    var vertex8 = new Point3d(5, 20, 0);
                    var polyMesh2 = new Face(vertex5, vertex6, vertex7, vertex8, true, true, true, true);
                    polyMesh2.SetDatabaseDefaults();
                    btr.AppendEntity(polyMesh2);
                    ts.AddNewlyCreatedDBObject(polyMesh2, true);
                    faces.Add(polyMesh2.ObjectId);



                    platformSurface.DrawingObjectsDefinition.AddFrom3DFaces(faces, true, $"Normal Platform");
                    platformSurface.Rebuild();
                    ACADEditor.ZoomExtents();
                    ts.Commit();
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.ToString());
            }

        }

 

The correct area for this TINSurface should be 150 sq. meter, but Civil 3D gives 175 sq. meter!

 

surface area not maintaqin.png

How to properly add my faces to Surface, so that the topology is preserved? 

 

Note that the cousin method, AddFromPolyFaces, doesn't seem to work

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
623 Views
6 Replies
Replies (6)
Message 2 of 7

Jeff_M
Consultant
Consultant

Perhaps add a boundary for the perimeter?

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 7

soonhui
Advisor
Advisor

@Jeff_M , yes, adding boundaries to limit the triangulation works, but only in this contrived example.

 

In my actual application things are a bit more complicated. Actually I already have mesh as my surfaces. Mesh as in the sense of a list of points and triangles, and the triangles can be disjointed ( ie: visually you can see two separated "meshes"  in this one big Mesh data structure), or it can contain holes ( you can imagine it as a mesh where the internal triangles and edges and points are being deleted).

 

Now what I am doing for this thread is that, instead of PolyFaceMesh, I use Face to represent my mesh ( I tried to use PolyFaceMesh and I ran into a problem, most likely a bug). One triangle, one face.

 

So you can imagine the difficulties here, from visual inspection it's easy to tell where are all the boundaries ( how should we clip the Surface), but from code, it's pretty hard. 

 

Because of this, I would think that AddFrom3DFaces is not suitable for my operation, but AddFromPolyFaces is. However AddFromPolyFaces method has its own problem..

 

Do I miss anything? What do you think?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 4 of 7

WebberHu
Autodesk
Autodesk

WebberHu_0-1673488755751.png

You can try the Maximum Angle to remove the additional area. It seems to me the API creates a convex from all the points of the 3d faces.

0 Likes
Message 5 of 7

soonhui
Advisor
Advisor

@WebberHu , seems like a hack to me. Are you sure it works 100% of the time?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 6 of 7

WebberHu
Autodesk
Autodesk

@soonhui I am sure. If it does not work, try 89.9. I think you can also find the max angle in SurfaceBuildOptions. And yes, I agree, it does not seem to be a perfect solution. 

0 Likes
Message 7 of 7

soonhui
Advisor
Advisor

@WebberHu , I don't think what you said is a good idea. Because I will need a generic solution because that solution should be implemented in code. So fiddling with Max Angle on case to case basis and hoping that it works, is a no no for me. 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes