Skip to content

Commit

Permalink
Replace tabs with spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jul 16, 2023
1 parent 21e7fdd commit f7cba33
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 129 deletions.
228 changes: 114 additions & 114 deletions occt-import-js/src/importer-brep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,149 +10,149 @@
class BrepShapeMesh : public Mesh
{
public:
BrepShapeMesh (const TopoDS_Shape& shape) :
Mesh (),
shape (shape)
{

}

virtual std::string GetName () const override
{
return std::string ();
}

virtual bool GetColor (Color&) const override
{
return false;
}

virtual void EnumerateFaces (const std::function<void (const Face&)>& onFace) const override
{
for (TopExp_Explorer ex (shape, TopAbs_FACE); ex.More (); ex.Next ()) {
const TopoDS_Face& face = TopoDS::Face (ex.Current ());
OcctFace outputFace (face);
onFace (outputFace);
}
}
BrepShapeMesh (const TopoDS_Shape& shape) :
Mesh (),
shape (shape)
{

}

virtual std::string GetName () const override
{
return std::string ();
}

virtual bool GetColor (Color&) const override
{
return false;
}

virtual void EnumerateFaces (const std::function<void (const Face&)>& onFace) const override
{
for (TopExp_Explorer ex (shape, TopAbs_FACE); ex.More (); ex.Next ()) {
const TopoDS_Face& face = TopoDS::Face (ex.Current ());
OcctFace outputFace (face);
onFace (outputFace);
}
}

private:
const TopoDS_Shape& shape;
const TopoDS_Shape& shape;
};

class BrepStandaloneFacesMesh : public Mesh
{
public:
BrepStandaloneFacesMesh (const TopoDS_Shape& shape) :
Mesh (),
shape (shape)
{

}

bool HasFaces () const
{
TopExp_Explorer ex (shape, TopAbs_FACE, TopAbs_SHELL);
return ex.More ();
}

virtual std::string GetName () const override
{
return std::string ();
}

virtual bool GetColor (Color&) const override
{
return false;
}

virtual void EnumerateFaces (const std::function<void (const Face& face)>& onFace) const override
{
for (TopExp_Explorer ex (shape, TopAbs_FACE, TopAbs_SHELL); ex.More (); ex.Next ()) {
const TopoDS_Face& face = TopoDS::Face (ex.Current ());
OcctFace outputFace (face);
onFace (outputFace);
}
}
BrepStandaloneFacesMesh (const TopoDS_Shape& shape) :
Mesh (),
shape (shape)
{

}

bool HasFaces () const
{
TopExp_Explorer ex (shape, TopAbs_FACE, TopAbs_SHELL);
return ex.More ();
}

virtual std::string GetName () const override
{
return std::string ();
}

virtual bool GetColor (Color&) const override
{
return false;
}

virtual void EnumerateFaces (const std::function<void (const Face& face)>& onFace) const override
{
for (TopExp_Explorer ex (shape, TopAbs_FACE, TopAbs_SHELL); ex.More (); ex.Next ()) {
const TopoDS_Face& face = TopoDS::Face (ex.Current ());
OcctFace outputFace (face);
onFace (outputFace);
}
}

private:
const TopoDS_Shape& shape;
const TopoDS_Shape& shape;
};

class BrepNode : public Node
{
public:
BrepNode (const TopoDS_Shape& shape) :
shape (shape)
{

}

virtual std::string GetName () const override
{
return std::string ();
}

virtual std::vector<NodePtr> GetChildren () const override
{
return {};
}

virtual bool IsMeshNode () const override
{
return true;
}

virtual void EnumerateMeshes (const std::function<void (const Mesh&)>& onMesh) const override
{
// Enumerate solids
for (TopExp_Explorer ex (shape, TopAbs_SOLID); ex.More (); ex.Next ()) {
const TopoDS_Shape& currentShape = ex.Current ();
BrepShapeMesh outputShapeMesh (currentShape);
onMesh (outputShapeMesh);
}

// Enumerate shells that are not part of a solid
for (TopExp_Explorer ex (shape, TopAbs_SHELL, TopAbs_SOLID); ex.More (); ex.Next ()) {
const TopoDS_Shape& currentShape = ex.Current ();
BrepShapeMesh outputShapeMesh (currentShape);
onMesh (outputShapeMesh);
}

// Create a mesh from faces that are not part of a shell
BrepStandaloneFacesMesh standaloneFacesMesh (shape);
if (standaloneFacesMesh.HasFaces ()) {
onMesh (standaloneFacesMesh);
}
}
BrepNode (const TopoDS_Shape& shape) :
shape (shape)
{

}

virtual std::string GetName () const override
{
return std::string ();
}

virtual std::vector<NodePtr> GetChildren () const override
{
return {};
}

virtual bool IsMeshNode () const override
{
return true;
}

virtual void EnumerateMeshes (const std::function<void (const Mesh&)>& onMesh) const override
{
// Enumerate solids
for (TopExp_Explorer ex (shape, TopAbs_SOLID); ex.More (); ex.Next ()) {
const TopoDS_Shape& currentShape = ex.Current ();
BrepShapeMesh outputShapeMesh (currentShape);
onMesh (outputShapeMesh);
}

// Enumerate shells that are not part of a solid
for (TopExp_Explorer ex (shape, TopAbs_SHELL, TopAbs_SOLID); ex.More (); ex.Next ()) {
const TopoDS_Shape& currentShape = ex.Current ();
BrepShapeMesh outputShapeMesh (currentShape);
onMesh (outputShapeMesh);
}

// Create a mesh from faces that are not part of a shell
BrepStandaloneFacesMesh standaloneFacesMesh (shape);
if (standaloneFacesMesh.HasFaces ()) {
onMesh (standaloneFacesMesh);
}
}

private:
const TopoDS_Shape& shape;
const TopoDS_Shape& shape;
};

ImporterBrep::ImporterBrep () :
Importer (),
shape ()
Importer (),
shape ()
{

}

Importer::Result ImporterBrep::LoadFile (const std::vector<std::uint8_t>& fileContent, const ImportParams& params)
{
VectorBuffer inputBuffer (fileContent);
std::istream inputStream (&inputBuffer);
VectorBuffer inputBuffer (fileContent);
std::istream inputStream (&inputBuffer);

BRep_Builder builder;
BRepTools::Read (shape, inputStream, builder);
if (shape.IsNull ()) {
return Importer::Result::ImportFailed;
}
BRep_Builder builder;
BRepTools::Read (shape, inputStream, builder);
if (shape.IsNull ()) {
return Importer::Result::ImportFailed;
}

TriangulateShape (shape, params);
return Importer::Result::Success;
TriangulateShape (shape, params);
return Importer::Result::Success;
}

NodePtr ImporterBrep::GetRootNode () const
{
return std::make_shared<BrepNode> (shape);
return std::make_shared<BrepNode> (shape);
}
8 changes: 4 additions & 4 deletions occt-import-js/src/importer-brep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
class ImporterBrep : public Importer
{
public:
ImporterBrep ();
ImporterBrep ();

virtual Result LoadFile (const std::vector<std::uint8_t>& fileContent, const ImportParams& params) override;
virtual NodePtr GetRootNode () const override;
virtual Result LoadFile (const std::vector<std::uint8_t>& fileContent, const ImportParams& params) override;
virtual NodePtr GetRootNode () const override;

private:
TopoDS_Shape shape;
TopoDS_Shape shape;
};
22 changes: 11 additions & 11 deletions occt-import-js/src/importer-utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
class VectorBuffer : public std::streambuf
{
public:
VectorBuffer (const std::vector<uint8_t>& v);
VectorBuffer (const std::vector<uint8_t>& v);
};

class OcctFace : public Face
{
public:
OcctFace (const TopoDS_Face& face);
OcctFace (const TopoDS_Face& face);

virtual bool HasNormals () const override;
virtual bool GetColor (Color& color) const override;
virtual bool HasNormals () const override;
virtual bool GetColor (Color& color) const override;

virtual void EnumerateVertices (const std::function<void (double, double, double)>& onVertex) const override;
virtual void EnumerateNormals (const std::function<void (double, double, double)>& onNormal) const override;
virtual void EnumerateTriangles (const std::function<void (int, int, int)>& onTriangle) const override;
virtual void EnumerateVertices (const std::function<void (double, double, double)>& onVertex) const override;
virtual void EnumerateNormals (const std::function<void (double, double, double)>& onNormal) const override;
virtual void EnumerateTriangles (const std::function<void (int, int, int)>& onTriangle) const override;

protected:
bool HasTriangulation () const;
bool HasTriangulation () const;

const TopoDS_Face& face;
Handle (Poly_Triangulation) triangulation;
TopLoc_Location location;
const TopoDS_Face& face;
Handle (Poly_Triangulation) triangulation;
TopLoc_Location location;
};

bool TriangulateShape (TopoDS_Shape& shape, const ImportParams& params);

0 comments on commit f7cba33

Please sign in to comment.