MeshPart: Final application of pre-commit
This commit is contained in:
committed by
Chris Hennes
parent
b8f8b232cb
commit
7593f0c112
@@ -22,17 +22,17 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <map>
|
||||
# include <set>
|
||||
# include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <Geom_BSplineSurface.hxx>
|
||||
# include <Geom_Surface.hxx>
|
||||
# include <Poly_Triangulation.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TColStd_Array1OfReal.hxx>
|
||||
# include <TopLoc_Location.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#endif
|
||||
|
||||
#include "MeshFlattening.h"
|
||||
@@ -50,30 +50,30 @@ std::vector<ColMat<double, 3>> getBoundaries(ColMat<double, 3> vertices, ColMat<
|
||||
std::vector<std::vector<long>> edge_vector;
|
||||
|
||||
|
||||
for (long i=0; i<tris.rows(); i++)
|
||||
{
|
||||
for (long j=0; j<3; j++)
|
||||
{
|
||||
for (long i = 0; i < tris.rows(); i++) {
|
||||
for (long j = 0; j < 3; j++) {
|
||||
long k = j + 1;
|
||||
if (k == 3)
|
||||
if (k == 3) {
|
||||
k = 0;
|
||||
}
|
||||
long v1 = tris(i, j);
|
||||
long v2 = tris(i, k);
|
||||
std::set<long> hash {v1, v2};
|
||||
hash_list.push_back(hash);
|
||||
if (v1 < v2)
|
||||
hash_map[hash] = std::vector<long>{v1, v2, 0};
|
||||
else
|
||||
hash_map[hash] = std::vector<long>{v2, v1, 0};
|
||||
if (v1 < v2) {
|
||||
hash_map[hash] = std::vector<long> {v1, v2, 0};
|
||||
}
|
||||
else {
|
||||
hash_map[hash] = std::vector<long> {v2, v1, 0};
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto & hash: hash_list)
|
||||
for (auto& hash : hash_list) {
|
||||
hash_map[hash][2] += 1;
|
||||
}
|
||||
|
||||
for (auto &hash: hash_map)
|
||||
{
|
||||
if (hash.second[2] == 1)
|
||||
{
|
||||
for (auto& hash : hash_map) {
|
||||
if (hash.second[2] == 1) {
|
||||
long v0 = hash.second[0];
|
||||
long v1 = hash.second[1];
|
||||
|
||||
@@ -83,8 +83,7 @@ std::vector<ColMat<double, 3>> getBoundaries(ColMat<double, 3> vertices, ColMat<
|
||||
}
|
||||
|
||||
|
||||
while (neighbour_map.size() != 0)
|
||||
{
|
||||
while (neighbour_map.size() != 0) {
|
||||
long start_index = neighbour_map.begin()->first;
|
||||
long close_index = start_index;
|
||||
long next_index = neighbour_map[start_index][1];
|
||||
@@ -94,33 +93,27 @@ std::vector<ColMat<double, 3>> getBoundaries(ColMat<double, 3> vertices, ColMat<
|
||||
edge_vector_0.push_back(start_index);
|
||||
neighbour_map.erase(start_index);
|
||||
edge_vector_0.push_back(next_index);
|
||||
while (next_index != close_index)
|
||||
{
|
||||
while (next_index != close_index) {
|
||||
temporary_next = neighbour_map[next_index][0];
|
||||
if (temporary_next != start_index)
|
||||
{
|
||||
if (temporary_next != start_index) {
|
||||
start_index = next_index;
|
||||
next_index = temporary_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
start_index = next_index;
|
||||
next_index = neighbour_map[start_index][1];
|
||||
}
|
||||
neighbour_map.erase(start_index);
|
||||
edge_vector_0.push_back(next_index);
|
||||
|
||||
}
|
||||
edge_vector.push_back(edge_vector_0);
|
||||
}
|
||||
std::vector<ColMat<double, 3>> edges;
|
||||
for (auto &edge: edge_vector)
|
||||
{
|
||||
for (auto& edge : edge_vector) {
|
||||
ColMat<double, 3> edge_vertices;
|
||||
edge_vertices.resize(edge.size(), 3);
|
||||
int i = 0;
|
||||
for (auto index: edge)
|
||||
{
|
||||
for (auto index : edge) {
|
||||
edge_vertices.row(i) = vertices.row(index);
|
||||
i++;
|
||||
}
|
||||
@@ -132,35 +125,33 @@ std::vector<ColMat<double, 3>> getBoundaries(ColMat<double, 3> vertices, ColMat<
|
||||
FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face)
|
||||
{
|
||||
long i = 0;
|
||||
// transform to nurbs:
|
||||
// transform to nurbs:
|
||||
TopLoc_Location location;
|
||||
|
||||
// triangulate:
|
||||
const Handle(Poly_Triangulation) &triangulation = BRep_Tool::Triangulation(face, location);
|
||||
// triangulate:
|
||||
const Handle(Poly_Triangulation)& triangulation = BRep_Tool::Triangulation(face, location);
|
||||
|
||||
if (triangulation.IsNull())
|
||||
if (triangulation.IsNull()) {
|
||||
throw std::runtime_error("null triangulation in face construction");
|
||||
}
|
||||
|
||||
Standard_Integer numNodes = triangulation->NbNodes();
|
||||
Standard_Integer numTriangles = triangulation->NbTriangles();
|
||||
|
||||
// compute uv coordinates
|
||||
if (triangulation->HasUVNodes())
|
||||
{
|
||||
// compute uv coordinates
|
||||
if (triangulation->HasUVNodes()) {
|
||||
this->uv_nodes.resize(numNodes, 2);
|
||||
i = 0;
|
||||
for (Standard_Integer index = 1; index <= numNodes; ++index)
|
||||
{
|
||||
for (Standard_Integer index = 1; index <= numNodes; ++index) {
|
||||
const gp_Pnt2d& _uv_node = triangulation->UVNode(index);
|
||||
this->uv_nodes.row(i) << _uv_node.X(), _uv_node.Y();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
this->xyz_nodes.resize(numNodes, 3);
|
||||
i = 0;
|
||||
for (Standard_Integer index = 1; index <= numNodes; ++index)
|
||||
{
|
||||
for (Standard_Integer index = 1; index <= numNodes; ++index) {
|
||||
gp_Pnt _node = triangulation->Node(index);
|
||||
this->xyz_nodes.row(i) << _node.X(), _node.Y(), _node.Z();
|
||||
i++;
|
||||
@@ -168,45 +159,47 @@ FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face)
|
||||
|
||||
this->tris.resize(numTriangles, 3);
|
||||
i = 0;
|
||||
for (Standard_Integer index = 1; index <= numTriangles; ++index)
|
||||
{
|
||||
for (Standard_Integer index = 1; index <= numTriangles; ++index) {
|
||||
int n1, n2, n3;
|
||||
const Poly_Triangle& _tri = triangulation->Triangle(index);
|
||||
_tri.Get(n1, n2, n3);
|
||||
this->tris.row(i) << n1-1, n2-1, n3-1;
|
||||
this->tris.row(i) << n1 - 1, n2 - 1, n3 - 1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void FaceUnwrapper::findFlatNodes(int steps, double val)
|
||||
{
|
||||
std::vector<long> fixed_pins; //TODO: INPUT
|
||||
lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(), this->tris.transpose(), fixed_pins);
|
||||
std::vector<long> fixed_pins;// TODO: INPUT
|
||||
lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(),
|
||||
this->tris.transpose(),
|
||||
fixed_pins);
|
||||
mesh_flattener.lscm();
|
||||
for (int j=0; j<steps; j++)
|
||||
for (int j = 0; j < steps; j++) {
|
||||
mesh_flattener.relax(val);
|
||||
}
|
||||
this->ze_nodes = mesh_flattener.flat_vertices.transpose();
|
||||
}
|
||||
|
||||
ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
|
||||
{
|
||||
if (this->uv_nodes.size() == 0)
|
||||
throw(std::runtime_error("no uv-coordinates found, interpolating with nurbs is only possible if the Flattener was constructed with a nurbs."));
|
||||
if (this->uv_nodes.size() == 0) {
|
||||
throw(std::runtime_error("no uv-coordinates found, interpolating with nurbs is only "
|
||||
"possible if the Flattener was constructed with a nurbs."));
|
||||
}
|
||||
|
||||
// extract xyz poles, knots, weights, degree
|
||||
const Handle(Geom_Surface) &_surface = BRep_Tool::Surface(face);
|
||||
const Handle(Geom_BSplineSurface) &_bspline = Handle(Geom_BSplineSurface)::DownCast(_surface);
|
||||
const Handle(Geom_Surface)& _surface = BRep_Tool::Surface(face);
|
||||
const Handle(Geom_BSplineSurface)& _bspline = Handle(Geom_BSplineSurface)::DownCast(_surface);
|
||||
|
||||
const TColStd_Array1OfReal &_uknots = _bspline->UKnotSequence();
|
||||
const TColStd_Array1OfReal &_vknots = _bspline->VKnotSequence();
|
||||
const TColStd_Array1OfReal& _uknots = _bspline->UKnotSequence();
|
||||
const TColStd_Array1OfReal& _vknots = _bspline->VKnotSequence();
|
||||
|
||||
Eigen::VectorXd weights;
|
||||
weights.resize(_bspline->NbUPoles() * _bspline->NbVPoles());
|
||||
long i = 0;
|
||||
for (long u=1; u <= _bspline->NbUPoles(); u++)
|
||||
{
|
||||
for (long v=1; v <= _bspline->NbVPoles(); v++)
|
||||
{
|
||||
for (long u = 1; u <= _bspline->NbUPoles(); u++) {
|
||||
for (long v = 1; v <= _bspline->NbVPoles(); v++) {
|
||||
weights[i] = _bspline->Weight(u, v);
|
||||
i++;
|
||||
}
|
||||
@@ -216,12 +209,10 @@ ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
|
||||
Eigen::VectorXd v_knots;
|
||||
u_knots.resize(_uknots.Length());
|
||||
v_knots.resize(_vknots.Length());
|
||||
for (long u=1; u <= _uknots.Length(); u++)
|
||||
{
|
||||
for (long u = 1; u <= _uknots.Length(); u++) {
|
||||
u_knots[u - 1] = _uknots.Value(u);
|
||||
}
|
||||
for (long v=1; v <= _vknots.Length(); v++)
|
||||
{
|
||||
for (long v = 1; v <= _vknots.Length(); v++) {
|
||||
v_knots[v - 1] = _vknots.Value(v);
|
||||
}
|
||||
|
||||
@@ -229,7 +220,7 @@ ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
|
||||
nu = nurbs::NurbsBase2D(u_knots, v_knots, weights, _bspline->UDegree(), _bspline->VDegree());
|
||||
A = nu.getInfluenceMatrix(this->uv_nodes);
|
||||
|
||||
Eigen::LeastSquaresConjugateGradient<spMat > solver;
|
||||
Eigen::LeastSquaresConjugateGradient<spMat> solver;
|
||||
solver.compute(A);
|
||||
ColMat<double, 2> ze_poles;
|
||||
ColMat<double, 3> flat_poles;
|
||||
@@ -243,17 +234,17 @@ ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
|
||||
}
|
||||
|
||||
|
||||
FaceUnwrapper::FaceUnwrapper(ColMat< double, int(3) > xyz_nodes, ColMat< long int, int(3) > tris)
|
||||
FaceUnwrapper::FaceUnwrapper(ColMat<double, int(3)> xyz_nodes, ColMat<long int, int(3)> tris)
|
||||
{
|
||||
this->tris = tris;
|
||||
this->xyz_nodes = xyz_nodes;
|
||||
|
||||
}
|
||||
|
||||
std::vector<ColMat<double, 3>> FaceUnwrapper::getFlatBoundaryNodes()
|
||||
{
|
||||
if (this->ze_nodes.size() == 0)
|
||||
if (this->ze_nodes.size() == 0) {
|
||||
throw(std::runtime_error("flat vertices not xet computed"));
|
||||
}
|
||||
|
||||
ColMat<double, 3> flat_vertices;
|
||||
flat_vertices.resize(this->ze_nodes.rows(), 3);
|
||||
|
||||
@@ -6,4 +6,3 @@
|
||||
<file>icons/MeshPart_CreateFlatMesh.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ felületeltérés szorozva az aktuális hálószakasz hosszával (él)</translat
|
||||
These groups will be exported for mesh output formats supporting
|
||||
this feature (e.g. the format OBJ).</source>
|
||||
<translation>A hálószegmensek az objektum felületek színe szerint lesznek csoportosítva.
|
||||
Ezek a csoportok a hálókimeneti formátumokhoz lesznek exportálva, amelyek
|
||||
Ezek a csoportok a hálókimeneti formátumokhoz lesznek exportálva, amelyek
|
||||
támogatják ezt a tulajdonságot (pl. OBJ formátum).</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -340,7 +340,7 @@ Surface deviation multiplied by the length of the current mesh segment (edge)</s
|
||||
These groups will be exported for mesh output formats supporting
|
||||
this feature (e.g. the format OBJ).</source>
|
||||
<translation>ქსელის სეგმენტები დაჯგუფდება ობიექტის ზედაპირის ფერის მიხედვით.
|
||||
ეს ჯგუფები გატანილი იქნება ბადის გამომავალი ფორმატებისთვის,
|
||||
ეს ჯგუფები გატანილი იქნება ბადის გამომავალი ფორმატებისთვის,
|
||||
რომლებსაც აქვთ ამ თვისების მხარდაჭერა(მაგ. ფორმატი OBJ).</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<location filename="../../Command.cpp" line="307"/>
|
||||
<source>Creates an approximated curve on top of a mesh.
|
||||
This command only works with a 'mesh' object.</source>
|
||||
<translation>Bir metal örgünün üstünde yaklaşık bir eğri oluşturur.
|
||||
<translation>Bir metal örgünün üstünde yaklaşık bir eğri oluşturur.
|
||||
Bu komut yalnızca bir 'metal örgü' nesnesiyle çalışır.</translation>
|
||||
</message>
|
||||
</context>
|
||||
@@ -220,7 +220,7 @@ Bu komut yalnızca bir 'metal örgü' nesnesiyle çalışır.</translation>
|
||||
<source>Press 'Start', then pick points on the mesh; when enough points have been set, right-click and choose 'Create'. Repeat this process to create more splines. Close this task panel to complete the operation.
|
||||
|
||||
This command only works with a 'mesh' object, not a regular face or surface. To convert an object to a mesh use the tools of the Mesh Workbench.</source>
|
||||
<translation>"Başlat"a basın, ardından metal örgü üzerindeki noktaları seçin; Yeterli nokta ayarlandığında, sağ tıklayın ve 'Oluştur'u seçin. Daha fazla spline oluşturmak için bu işlemi tekrarlayın. İşlemi tamamlamak için bu görev panelini kapatın.
|
||||
<translation>"Başlat"a basın, ardından metal örgü üzerindeki noktaları seçin; Yeterli nokta ayarlandığında, sağ tıklayın ve 'Oluştur'u seçin. Daha fazla spline oluşturmak için bu işlemi tekrarlayın. İşlemi tamamlamak için bu görev panelini kapatın.
|
||||
|
||||
Bu komut, normal bir yüz veya yüzeyle değil, yalnızca 'metal örgü' nesnesiyle çalışır. Bir nesneyi metal örgüye dönüştürmek için Metal Örgü Çalışma Tezgahının araçlarını kullanın.</translation>
|
||||
</message>
|
||||
@@ -338,7 +338,7 @@ Surface deviation multiplied by the length of the current mesh segment (edge)</s
|
||||
<source>Mesh segments will be grouped according to the color of the object faces.
|
||||
These groups will be exported for mesh output formats supporting
|
||||
this feature (e.g. the format OBJ).</source>
|
||||
<translation>Metal örgü bölümleri, nesne yüzlerinin rengine göre gruplandırılacaktır.
|
||||
<translation>Metal örgü bölümleri, nesne yüzlerinin rengine göre gruplandırılacaktır.
|
||||
Bu gruplar, bu özelliği destekleyen metal örgü çıktı biçimleri için dışa aktarılacaktır (ör. OBJ biçimi).</translation>
|
||||
</message>
|
||||
<message>
|
||||
@@ -427,7 +427,7 @@ En küçük değer 0'dır.</translation>
|
||||
<location filename="../../Tessellation.ui" line="279"/>
|
||||
<source>If this parameter is smaller, the mesh becomes finer.
|
||||
A value in the range of 0.1-1.</source>
|
||||
<translation>Bu parametre daha küçükse, metal örgü daha ince hale gelir.
|
||||
<translation>Bu parametre daha küçükse, metal örgü daha ince hale gelir.
|
||||
0.1-1 aralığında bir değer.</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
* \ingroup CWORKBENCHES
|
||||
* \brief Part to Mesh (and vice-versa) conversion tools
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user