Comments (9)
Use CGAL::Polygon_triangulation_decomposition_2 to produce triangles, use Plane_3 to_3d to produce faces, and add_face on the Surface_mesh.
from cgal.
Ah, but it might be faster to just write a function to print a Polygon_with_holes_2 in obj format, as that is very simple.
from cgal.
I am a beginner,could you please write a demo (i could't find the demo about Polygon_triangulation_decomposition_2 )? thank you
from cgal.
Perhaps something like this:
bool PolygonsWithHolesToSurfaceMesh(const Plane& plane,
std::vector<Polygon_with_holes_2>& polygons,
Surface_mesh& result,
Vertex_map& vertex_map, bool flip = false) {
CGAL::Polygon_triangulation_decomposition_2<Kernel> triangulator;
for (const Polygon_with_holes_2& polygon : polygons) {
std::vector<Polygon_2> facets;
triangulator(polygon, std::back_inserter(facets));
for (auto& facet : facets) {
if (facet.orientation() != CGAL::Sign::POSITIVE) {
facet.reverse_orientation();
}
std::vector<Vertex_index> vertices;
for (const auto& point : facet) {
vertices.push_back(
ensureVertex(result, vertex_map, plane.to_3d(point)));
}
if (flip) {
std::reverse(vertices.begin(), vertices.end());
}
if (result.add_face(vertices) == Surface_mesh::null_face()) {
return false;
}
}
}
return true;
}
But I think you're still going about this the wrong way.
Generating an OBJ file from a Polygon_with_holes_2 should be simpler. :)
from cgal.
thank you, by the way could you tell me the simpler way Generating an OBJ file from a Polygon_with_holes_2?
from cgal.
v 0 0 0
v 1 0 0
v 1 1 0
v 0 1 0
v 0.5 0.5 1.6
f 5 2 3
f 4 5 3
f 6 3 2
f 5 6 2
f 4 6 5
f 6 4 3
Just write out the vertices (v) and the faces (f).
You'll still need to do the triangular decomposition since obj doesn't handle holes, but it's very simple.
from cgal.
i know .obj file format, and i know how to get all vertices . But i don't konw how to get the vertexIndex of every face such as "f 5 2 3", and how to get the "vn" value such as "vn -0.116639 0.196368 -0.973568".
from cgal.
Just go through all of the vertices and write them out.
The first vertex you write out has index 1, the second has index 2, and so on.
Next go through all of the triangles, mapping each vertex to its index.
Now you're done.
You don't need to add vertex normals, but vn 0 0 1 should be correct since this is a 2d polygon.
from cgal.
thank you , i have achieved the aim
from cgal.
Related Issues (20)
- PMP: CGAL::Polygon_mesh_processing::experimental::remove_self_intersections() abnormal result HOT 1
- Preconditon violation detection
- Bug with optimal transportation curve reconstruction
- How to determine a polygon_with_holes is simple. HOT 2
- Got strange exception when segment intersection HOT 18
- A point projected on line, but "bounded_side_2" returned not ON_BOUNDARY sometime HOT 7
- Unknown CMake command "create_single_source_cgal_program". HOT 4
- The vertex order of the bounding box outputted by CGAL::oriented_bounding_box() is not fixed. HOT 9
- LAStools support HOT 1
- Documentation in CGAL::Polyline_simplification_2::Stop_above_cost_threshold Class HOT 3
- Proposal to add variable sizing fields with respect to euclidean distance to a surface in a 3D image
- Use pointmatcher with CGAL fail HOT 2
- A same Surface_mesh randomly got self intersections HOT 2
- Got CGAL ERROR: precondition violation! while inserting a single Polygon_2 to Polygon_Set_2 HOT 2
- Degraded performance of Polygon_set_2 intersections in multithreaded environment HOT 2
- How to convert my double type data to exact type? Not related to CGAL::Cartesian_converter.
- Isotropic remeshing creates self intersections HOT 8
- create_interior_straight_skeleton_2 using too much memory and time HOT 2
- Compilation failure of CGAL::cross_product on Windows MSVC HOT 3
- 'get_parameter': no matching overloaded function found HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cgal.