Code Monkey home page Code Monkey logo

Comments (3)

Grantim avatar Grantim commented on May 18, 2024 1

Hello!
You can use

/// computes coordinates of point given as edge and relative position on it
[[nodiscard]] Vector3f edgePoint( const MeshEdgePoint & ep ) const { return edgePoint( ep.e, ep.a ); }

this function to extact points coordinates, also if you need to cut mesh in this path you should use cutMesh functionality:
/** \ingroup BooleanGroup
* \brief Converts SurfacePath to OneMeshContours
*
* Creates MR::OneMeshContour object from given surface path with ends for MR::cutMesh input
* `start` and surfacePath.front() should be from same face
* surfacePath.back() and `end` should be from same face
*
* note that whole path (including `start` and `end`) should not have self-intersections
* also following case is not supported (vertex -> edge (incident with vertex)):
*
* vert path edge point path edge end
* o----------o- -- -- -- -- O
* \ \ /
* \ \ /
* \ \ /
* \\/
* o path
*/
[[nodiscard]]
MRMESH_API OneMeshContour convertSurfacePathWithEndsToMeshContour( const Mesh& mesh,
const MeshTriPoint& start,
const SurfacePath& surfacePath,
const MeshTriPoint& end );

/** \ingroup BooleanGroup
* \brief Cuts mesh by given contours
*
* This function cuts mesh making new edges paths on place of input contours
* \param mesh Input mesh that will be cut
* \param contours Input contours to cut mesh with, find more \ref MR::OneMeshContours
* \param params Parameters describing some cut options, find more \ref MR::CutMeshParameters
* \return New edges that correspond to given contours, find more \ref MR::CutMeshResult
* \parblock
* \warning Input contours should have no intersections, faces where contours intersects (`bad faces`) will not be allowed for fill
* \endparblock
* \parblock
* \warning Input mesh will be changed in any case, if `bad faces` are in mesh, mesh will be spoiled, \n
* so if you cannot guarantee contours without intersections better make copy of mesh, before using this function
* \endparblock
*/
MRMESH_API CutMeshResult cutMesh( Mesh& mesh, const OneMeshContours& contours, const CutMeshParameters& params = {} );

from meshlib.

Grantim avatar Grantim commented on May 18, 2024

Hello! You can use

/// returns intermediate points of the geodesic path from start to end, where it crosses mesh edges;
/// It is the same as calling computeGeodesicPathApprox() then reducePath()
MRMESH_API Expected<SurfacePath, PathError> computeGeodesicPath( const Mesh & mesh,
const MeshTriPoint & start, const MeshTriPoint & end, GeodesicPathApprox atype,
int maxGeodesicIters = 100 ); ///< the maximum number of iterations to reduce approximate path length and convert it in geodesic path

this function (or other functions in this file) to find the path.

from meshlib.

xiaodongdong101 avatar xiaodongdong101 commented on May 18, 2024

After finding the required point, then use the SplitDge algorithm to find that the output results can not be visualized.
code**************************
auto cylinder = MR::MeshLoad::fromAnyStl("D:/code/meshlib221/chamfer/model/Subtraction.stl");
MR::MeshTriPoint a = MR::getVertexAsMeshTriPoint(cylinder->topology, MR::EdgeId(70), MR::VertId(21));
MR::MeshTriPoint b = MR::getVertexAsMeshTriPoint(cylinder->topology, MR::EdgeId(166), MR::VertId(24));
MR::GeodesicPathApprox Approx = MR::GeodesicPathApprox::DijkstraAStar;
auto geodesicpath = MR::computeGeodesicPath(*cylinder, a, b,Approx);

for (auto result : *geodesicpath)
{
	MR::EdgeId edge = MR::EdgeId(result.e);
	MR::VertId vertA = cylinder->topology.org(edge);
	MR::VertId vertB = cylinder->topology.org(edge.sym());
	MR::Vector3f pointA = cylinder->points[vertA];
	MR::Vector3f pointB = cylinder->points[vertB];
	MR::Vector3f point = point + (pointB - pointA) * result.a;
	cylinder->splitEdge(edge, point);
}
cylinder->invalidateCaches();

code**************************
Do I need to update each splitEdge?

from meshlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.