Skip to content

Commit 05a76d7

Browse files
authored
Merge branch 'master' into streamlines-ui
2 parents 4a55d36 + b96ef6d commit 05a76d7

File tree

15 files changed

+1045
-146
lines changed

15 files changed

+1045
-146
lines changed

src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,59 +30,38 @@
3030

3131
SET(Core_Algorithms_Legacy_DataIO_SRCS
3232
DataIOAlgo.cc
33-
#MRCReader.cc
3433
ObjToFieldReader.cc
3534
VTKToTriSurfReader.cc
36-
#StreamData/StreamACQFile.cc
35+
TriSurfSTLBinaryConverter.cc
36+
TriSurfSTLASCIIConverter.cc
37+
STLUtils.cc
3738
)
3839

3940
SET(Core_Algorithms_Legacy_DataIO_HEADERS
4041
ObjToFieldReader.h
4142
VTKToTriSurfReader.h
4243
DataIOAlgo.h
44+
TriSurfSTLBinaryConverter.h
45+
TriSurfSTLASCIIConverter.h
46+
STLUtils.h
47+
share.h
4348
)
4449

45-
#IF(ITK_FOUND)
46-
# SET(Core_Algorithms_Legacy_DataIO_SRCS
47-
# ${Core_Algorithms_DataIO_SRCS}
48-
# AnalyzeImage.cc
49-
# AnalyzeReader.cc
50-
# AnalyzeSliceImageIO.cc)
51-
#ENDIF(ITK_FOUND)
52-
5350
SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_DataIO
5451
${Core_Algorithms_Legacy_DataIO_SRCS}
5552
${Core_Algorithms_Legacy_DataIO_HEADERS}
5653
)
5754

5855
TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_DataIO
59-
#Core_Algorithms_Util
6056
Algorithms_Base
6157
Core_Datatypes
6258
Core_Datatypes_Legacy_Field
6359
Core_Datatypes_Legacy_Nrrd
64-
#Core_Thread
65-
#Core_Exceptions
66-
#Core_Geometry
67-
#Core_Util
6860
Core_Math
6961
Core_Persistent
70-
#Core_Geom
7162
Core_ImportExport
72-
#Core_Volume
73-
#${SCI_TEEM_LIBRARY}
74-
#${SCI_ZLIB_LIBRARY}
75-
#${M_LIBRARY}
7663
)
7764

78-
#IF(ITK_FOUND)
79-
# TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_DataIO
80-
# ITKCommon
81-
# ITKIO
82-
# ${GDCM_LIBRARY}
83-
# ${GL_LIBRARY})
84-
#ENDIF(ITK_FOUND)
85-
8665
IF(BUILD_SHARED_LIBS)
8766
ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_DataIO)
8867
ENDIF(BUILD_SHARED_LIBS)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2014 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#include <Core/Algorithms/Legacy/DataIO/STLUtils.h>
30+
#include <Core/GeometryPrimitives/Vector.h>
31+
32+
using namespace SCIRun;
33+
using namespace SCIRun::Core::Algorithms;
34+
using namespace SCIRun::Core::Geometry;
35+
36+
boost::shared_array<float> SCIRun::Core::Algorithms::computeFaceNormal(const Point& p1, const Point& p2, const Point& p3)
37+
{
38+
Vector U = p2 - p1;
39+
Vector V = p3 - p1;
40+
41+
boost::shared_array<float> normal(new float[3]);
42+
normal[0] = U.y() * V.z() - U.z() * V.y();
43+
normal[1] = U.z() * V.x() - U.x() * V.z();
44+
normal[2] = U.x() * V.y() - U.y() * V.x();
45+
return normal;
46+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2014 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
30+
#ifndef CORE_ALGORITHMS_DATAIO_STLUTILS_H
31+
#define CORE_ALGORITHMS_DATAIO_STLUTILS_H 1
32+
33+
/// TODO: use std::unordered_map when porting to SCIRun 5
34+
#include <boost/unordered_map.hpp>
35+
#include <boost/shared_array.hpp>
36+
37+
#include <functional>
38+
#include <list>
39+
40+
#include <Core/GeometryPrimitives/Point.h>
41+
42+
#include <Core/Algorithms/Legacy/DataIO/share.h>
43+
44+
namespace SCIRun {
45+
namespace Core {
46+
namespace Algorithms {
47+
48+
struct SCISHARE PointHash : std::unary_function<Geometry::Point, std::size_t>
49+
{
50+
std::size_t operator()(Geometry::Point const& point) const
51+
{
52+
std::size_t seed = 0;
53+
boost::hash_combine( seed, point.x() );
54+
boost::hash_combine( seed, point.y() );
55+
boost::hash_combine( seed, point.z() );
56+
return seed;
57+
}
58+
};
59+
60+
struct SCISHARE Facet
61+
{
62+
Facet(const Geometry::Point& point1,
63+
const Geometry::Point& point2,
64+
const Geometry::Point& point3) :
65+
point1_( point1 ),
66+
point2_( point2 ),
67+
point3_( point3 )
68+
{}
69+
70+
const Geometry::Point point1_;
71+
const Geometry::Point point2_;
72+
const Geometry::Point point3_;
73+
};
74+
75+
// point(vertex) lookup table
76+
typedef boost::unordered_map< Geometry::Point, unsigned int, PointHash > PointTable;
77+
typedef std::list<Facet> FacetList;
78+
79+
/// compute face normal:
80+
/// U = p2 - p1
81+
/// V = p3 - p1
82+
/// Ni = UyVz - UzVy
83+
/// Nj = UzVx - UxVz
84+
/// Nk = UxVy - UyVx
85+
SCISHARE boost::shared_array<float> computeFaceNormal(const Geometry::Point& p1, const Geometry::Point& p2, const Geometry::Point& p3);
86+
87+
}}}
88+
89+
#endif

0 commit comments

Comments
 (0)